use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DarkThemeSliceTest method getSlice_notAvailable_returnErrorSlice.
@Test
public void getSlice_notAvailable_returnErrorSlice() {
doReturn(true).when(mDarkThemeSlice).isDarkThemeMode(mContext);
final Slice mediaSlice = mDarkThemeSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
assertThat(metadata.isErrorSlice()).isTrue();
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DarkThemeSliceTest method getSlice_isAvailable_showTitleSubtitle.
@Test
public void getSlice_isAvailable_showTitleSubtitle() {
setBatteryCapacityLevel(40);
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));
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DarkThemeSliceTest method getSlice_newSession_notAvailable_returnErrorSlice.
@Test
public void getSlice_newSession_notAvailable_returnErrorSlice() {
// previous displayed: yes
mDarkThemeSlice.sKeepSliceShow = true;
// Session: use original value + 1 to become a new session
mDarkThemeSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken() + 1;
doReturn(true).when(mDarkThemeSlice).isDarkThemeMode(mContext);
final Slice mediaSlice = mDarkThemeSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
assertThat(metadata.isErrorSlice()).isTrue();
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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, mContext.getString(R.string.enhanced_4g_lte_mode_title));
}
use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MobileDataSliceTest method getSlice_shouldHaveTitleAndToggle.
@Test
public void getSlice_shouldHaveTitleAndToggle() {
final Slice mobileData = mMobileDataSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Aggregations