Search in sources :

Example 21 with SliceMetadata

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();
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 22 with SliceMetadata

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);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 23 with SliceMetadata

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));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 24 with SliceMetadata

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);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 25 with SliceMetadata

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);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Aggregations

SliceMetadata (androidx.slice.SliceMetadata)100 Slice (androidx.slice.Slice)72 Test (org.junit.Test)72 SliceAction (androidx.slice.core.SliceAction)53 PendingIntent (android.app.PendingIntent)24 SliceItem (androidx.slice.SliceItem)23 IconCompat (androidx.core.graphics.drawable.IconCompat)18 ParceledListSlice (android.content.pm.ParceledListSlice)11 Config (org.robolectric.annotation.Config)11 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)5 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)3 Uri (android.net.Uri)2 Handler (android.os.Handler)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 ListContent (androidx.slice.widget.ListContent)2 RowContent (androidx.slice.widget.RowContent)2 SliceContent (androidx.slice.widget.SliceContent)2 ShadowPrivateStorageInfo (com.android.settings.testutils.shadow.ShadowPrivateStorageInfo)2 Intent (android.content.Intent)1 FaceManager (android.hardware.face.FaceManager)1