use of androidx.slice.SliceItem in project android_packages_apps_Settings by omnirom.
the class WifiSliceTest method getWifiSlice_oneConnectedAp_shouldReturnLoadingRow.
@Test
public void getWifiSlice_oneConnectedAp_shouldReturnLoadingRow() {
setWorkerResults(createWifiSliceItem(AP1_NAME, WifiEntry.CONNECTED_STATE_CONNECTED));
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 android_packages_apps_Settings by omnirom.
the class WifiSliceTest method getWifiSlice_apReachExpandedCount_shouldNotReturnLoadingRow.
@Test
public void getWifiSlice_apReachExpandedCount_shouldNotReturnLoadingRow() {
setWorkerResults(createWifiSliceItem(AP1_NAME, WifiEntry.CONNECTED_STATE_DISCONNECTED), createWifiSliceItem(AP2_NAME, WifiEntry.CONNECTED_STATE_DISCONNECTED), createWifiSliceItem(AP3_NAME, WifiEntry.CONNECTED_STATE_DISCONNECTED));
final Slice wifiSlice = mWifiSlice.getSlice();
final List<SliceItem> sliceItems = wifiSlice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP2_NAME);
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP3_NAME);
// No scanning text
SliceTester.assertNoSliceItemContainsSubtitle(sliceItems, mContext.getString(R.string.wifi_empty_list_wifi_on));
}
use of androidx.slice.SliceItem in project android_packages_apps_Settings by omnirom.
the class Enhanced4gLteSliceHelperTest method assertTitle.
private void assertTitle(List<SliceItem> sliceItems, String title) {
boolean hasTitle = false;
for (SliceItem item : sliceItems) {
final 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 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"));
}
use of androidx.slice.SliceItem in project android_packages_apps_Settings by omnirom.
the class SliceTester method testSettingsSliderSlice.
/**
* Test the contents of an slider based slice, including:
* - No intent
* - Correct title
* - Correct keywords
* - TTL
* - Color
*/
public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
final SliceMetadata metadata = SliceMetadata.from(context, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat icon = primaryAction.getIcon();
if (icon == null) {
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
final int color = colorItem.getInt();
assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
} else {
final IconCompat expectedIcon = IconCompat.createWithResource(context, sliceData.getIconResource());
assertThat(expectedIcon.toString()).isEqualTo(icon.toString());
}
final long sliceTTL = metadata.getExpiry();
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
final int headerType = metadata.getHeaderType();
assertThat(headerType).isEqualTo(EventInfo.ROW_TYPE_SLIDER);
// Check primary intent
final PendingIntent primaryPendingIntent = primaryAction.getAction();
assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(context, sliceData));
assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
Aggregations