use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSliceHelperTest method testWifiCallingSettingsUnavailableSlice.
private void testWifiCallingSettingsUnavailableSlice(Slice slice, SliceData sliceData, PendingIntent expectedPrimaryAction, String title) {
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 wifi calling settings activity
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, title);
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationChannelSliceTest method getSlice_hasSuggestedApp_shouldSortByNotificationSentCount.
@Test
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_hasSuggestedApp_shouldSortByNotificationSentCount() {
addMockPackageToPackageManager(true, /* isRecentlyInstalled */
ApplicationInfo.FLAG_INSTALLED);
mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false, /* banned */
false);
final Slice slice = mNotificationChannelSlice.getSlice();
// Get all RowBuilders from Slice.
final List<SliceItem> rowItems = SliceQuery.findAll(slice, FORMAT_SLICE, HINT_LIST_ITEM, null);
// Ensure the total size of rows is equal to the notification channel count with header.
assertThat(rowItems).isNotNull();
assertThat(rowItems.size()).isEqualTo(CHANNEL_COUNT + 1);
// Remove the header of slice.
rowItems.remove(0);
// Test the rows of slice are sorted with notification sent count by descending.
for (int i = 0; i < rowItems.size(); i++) {
// Assert the summary text is the same as expectation.
assertThat(getSummaryFromSliceItem(rowItems.get(i))).isEqualTo(mContext.getResources().getQuantityString(R.plurals.notifications_sent_weekly, CHANNEL_COUNT - i, CHANNEL_COUNT - i));
}
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceInfoSliceTest method getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent.
@Test
public void getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent() {
final String phoneNumber = "1111111111";
doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
final Slice slice = mDeviceInfoSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_info_outline_24dp);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
final List<SliceItem> sliceItems = slice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceInfoSliceTest method getSlice_hasNoSubscriptionInfo_shouldShowUnknown.
@Test
public void getSlice_hasNoSubscriptionInfo_shouldShowUnknown() {
final Slice slice = mDeviceInfoSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
final List<SliceItem> sliceItems = slice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, mContext.getString(R.string.device_info_default));
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class Enhanced4gLteSliceHelperTest method assertTitle.
private void assertTitle(List<SliceItem> sliceItems, String title) {
boolean hasTitle = false;
for (SliceItem item : sliceItems) {
List<SliceItem> titleItems = SliceQuery.findAll(item, FORMAT_TEXT, HINT_TITLE, null);
if (titleItems == null) {
continue;
}
hasTitle = true;
for (SliceItem subTitleItem : titleItems) {
assertThat(subTitleItem.getText()).isEqualTo(title);
}
}
assertThat(hasTitle).isTrue();
}
Aggregations