use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeSliceBuilderTest method getZenModeSlice_correctSliceContent.
@Test
public void getZenModeSlice_correctSliceContent() {
final Slice dndSlice = ZenModeSliceBuilder.getSlice(mContext);
final SliceMetadata metadata = SliceMetadata.from(mContext, dndSlice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.zen_mode_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
assertThat(primaryAction.getIcon()).isNull();
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildSliderSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildUnavailableSlice_notCustomizeSubtitle_returnsSliceWithDefaultSubtitle.
@Test
public void buildUnavailableSlice_notCustomizeSubtitle_returnsSliceWithDefaultSubtitle() {
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class, SliceData.SliceType.SWITCH);
Settings.Global.putInt(mContext.getContentResolver(), FakeUnavailablePreferenceController.AVAILABILITY_KEY, BasePreferenceController.DISABLED_DEPENDENT_SETTING);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getSubtitle()).isEqualTo(mContext.getString(R.string.disabled_dependent_setting_summary));
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildUnavailableSlice_customizeSubtitle_returnsSliceWithCustomizedSubtitle.
@Test
public void buildUnavailableSlice_customizeSubtitle_returnsSliceWithCustomizedSubtitle() {
final String subtitleOfUnavailableSlice = "subtitleOfUnavailableSlice";
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0, /* icon */
subtitleOfUnavailableSlice);
Settings.Global.putInt(mContext.getContentResolver(), FakeUnavailablePreferenceController.AVAILABILITY_KEY, BasePreferenceController.DISABLED_DEPENDENT_SETTING);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getSubtitle()).isEqualTo(subtitleOfUnavailableSlice);
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildToggleSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, dummyData);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
Aggregations