use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSliceHelperTest method testWifiCallingSettingsToggleSlice.
private void testWifiCallingSettingsToggleSlice(Slice slice, SliceData sliceData) {
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction mainToggleAction = toggles.get(0);
// Check intent in Toggle Action
final PendingIntent togglePendingIntent = mainToggleAction.getAction();
final PendingIntent expectedToggleIntent = getBroadcastIntent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_CHANGED);
assertThat(togglePendingIntent).isEqualTo(expectedToggleIntent);
// Check primary intent
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
final PendingIntent expectedPendingIntent = getActivityIntent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_SETTINGS_ACTIVITY);
assertThat(primaryPendingIntent).isEqualTo(expectedPendingIntent);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, mContext.getString(R.string.wifi_calling_settings_title));
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSliceHelperTest 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();
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsToggleSlice.
private void testEnhanced4gLteSettingsToggleSlice(Slice slice) {
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction mainToggleAction = toggles.get(0);
// Check intent in Toggle Action
final PendingIntent togglePendingIntent = mainToggleAction.getAction();
final PendingIntent expectedToggleIntent = getBroadcastIntent(Enhanced4gLteSliceHelper.ACTION_ENHANCED_4G_LTE_CHANGED);
assertThat(togglePendingIntent).isEqualTo(expectedToggleIntent);
// Check primary intent
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
final PendingIntent expectedPendingIntent = getActivityIntent(Enhanced4gLteSliceHelper.ACTION_MOBILE_NETWORK_SETTINGS_ACTIVITY);
assertThat(primaryPendingIntent).isEqualTo(expectedPendingIntent);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, mContext.getString(R.string.enhanced_4g_lte_mode_title));
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSliceTest method getWifiSlice_oneActiveAp_shouldReturnLoadingRow.
@Test
public void getWifiSlice_oneActiveAp_shouldReturnLoadingRow() {
setWorkerResults(createAccessPoint(AP1_NAME, true, true));
final Slice wifiSlice = mWifiSlice.getSlice();
final List<SliceItem> sliceItems = wifiSlice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
// Has scanning text
SliceTester.assertAnySliceItemContainsSubtitle(sliceItems, mContext.getString(R.string.wifi_empty_list_wifi_on));
}
use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSliceTest method getWifiSlice_isCaptivePortal_shouldHaveCaptivePortalItems.
@Test
public void getWifiSlice_isCaptivePortal_shouldHaveCaptivePortalItems() {
setWorkerResults(createAccessPoint(AP1_NAME, true, true));
doReturn(makeCaptivePortalNetworkCapabilities()).when(mConnectivityManager).getNetworkCapabilities(any());
final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
final Slice wifiSlice = mWifiSlice.getSlice();
final List<SliceItem> sliceItems = wifiSlice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
SliceTester.assertAnySliceItemContainsIcon(sliceItems, expectedIcon);
}
Aggregations