Search in sources :

Example 91 with SliceMetadata

use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.

the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsUnavailableSlice.

private void testEnhanced4gLteSettingsUnavailableSlice(Slice slice, PendingIntent expectedPrimaryAction) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    // Check there is no toggle action
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    // Check whether the primary action is to open Enhanced4gLte settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Check the title
    final List<SliceItem> sliceItems = slice.getItems();
    assertTitle(sliceItems, ResourcesUtils.getResourcesString(mContext, "enhanced_4g_lte_mode_title"));
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 92 with SliceMetadata

use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.

the class LocationSliceTest method getLocationSlice_correctSliceContent.

@Test
public void getLocationSlice_correctSliceContent() {
    final Slice LocationSlice = new LocationSlice(mContext).getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, LocationSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.location_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
    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 93 with SliceMetadata

use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.

the class DarkThemeSliceTest method getSlice_isAvailable_showTitleSubtitle.

@Test
public void getSlice_isAvailable_showTitleSubtitle() {
    setBatteryCapacityLevel(40);
    setNightMode(UiModeManager.MODE_NIGHT_NO);
    final Slice slice = mDarkThemeSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.dark_theme_slice_title));
    assertThat(metadata.getSubtitle()).isEqualTo(mContext.getString(R.string.dark_theme_slice_subtitle));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 94 with SliceMetadata

use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.

the class DarkThemeSliceTest method getSlice_sliceNotClicked_notAvailable_returnErrorSlice.

@Test
public void getSlice_sliceNotClicked_notAvailable_returnErrorSlice() {
    mDarkThemeSlice.sSliceClicked = false;
    mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
    final Slice mediaSlice = mDarkThemeSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    assertThat(metadata.isErrorSlice()).isTrue();
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 95 with SliceMetadata

use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.

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 = getMockData(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)

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