Search in sources :

Example 61 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceBuilderUtilsTest method buildIntentSlice_noIconPassed_returnsSliceWithIcon.

@Test
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
    final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
    final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT, 0x0);
    final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
    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 62 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceBuilderUtilsTest method buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon.

@Test
public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
    final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
    final SliceData data = getDummyData(FakeUnavailablePreferenceController.class, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0, /* icon */
    null);
    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);
    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 63 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualWifiSliceTest method getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle() {
    mWifiSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
    mWifiSlice.sPreviouslyDisplayed = true;
    connectToWifi(makeValidatedNetworkCapabilities());
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 64 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualWifiSliceTest method getWifiSlice_isCaptivePortal_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_isCaptivePortal_shouldHaveTitleAndToggle() {
    mWifiSlice.sPreviouslyDisplayed = false;
    connectToWifi(WifiSliceTest.makeCaptivePortalNetworkCapabilities());
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 65 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSliceTest method getWifiSlice_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_shouldHaveTitleAndToggle() {
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) 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