Search in sources :

Example 11 with SliceItem

use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSliceTest method getWifiSlice_oneReachableAp_shouldNotReturnLoadingRow.

@Test
public void getWifiSlice_oneReachableAp_shouldNotReturnLoadingRow() {
    setWorkerResults(createAccessPoint(AP1_NAME, false, true));
    final Slice wifiSlice = mWifiSlice.getSlice();
    final List<SliceItem> sliceItems = wifiSlice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
    // No scanning text
    SliceTester.assertNoSliceItemContainsSubtitle(sliceItems, mContext.getString(R.string.wifi_empty_list_wifi_on));
}
Also used : Slice(androidx.slice.Slice) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 12 with SliceItem

use of androidx.slice.SliceItem in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSliceTest method getWifiSlice_allReachableAps_shouldNotReturnLoadingRow.

@Test
public void getWifiSlice_allReachableAps_shouldNotReturnLoadingRow() {
    setWorkerResults(createAccessPoint(AP1_NAME, false, true), createAccessPoint(AP2_NAME, false, true));
    final Slice wifiSlice = mWifiSlice.getSlice();
    final List<SliceItem> sliceItems = wifiSlice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP2_NAME);
    // No scanning text
    SliceTester.assertNoSliceItemContainsSubtitle(sliceItems, mContext.getString(R.string.wifi_empty_list_wifi_on));
}
Also used : Slice(androidx.slice.Slice) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 13 with SliceItem

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

the class ProviderModelSliceTest method getSlice_airplaneModeIsOn_oneWifiToggle.

@Test
@UiThreadTest
public void getSlice_airplaneModeIsOn_oneWifiToggle() {
    mWifiList.clear();
    mMockNetworkProviderWorker.updateSelfResults(null);
    mockHelperCondition(true, false, false, null);
    final Slice slice = mMockProviderModelSlice.getSlice();
    assertThat(slice).isNotNull();
    verify(mListBuilder, times(1)).addRow(any(ListBuilder.RowBuilder.class));
    final SliceItem sliceTitle = SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
    assertThat(sliceTitle.getText()).isEqualTo(ResourcesUtils.getResourcesString(mContext, "wifi_settings"));
}
Also used : Slice(androidx.slice.Slice) WifiSliceItem(com.android.settings.wifi.slice.WifiSliceItem) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 14 with SliceItem

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

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, 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 15 with SliceItem

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

the class SliceTester method testSettingsIntentSlice.

/**
 * Test the contents of an intent based slice, including:
 * - No toggles
 * - Correct intent
 * - Correct title
 * - Correct keywords
 * - TTL
 * - Color
 */
public static void testSettingsIntentSlice(Context context, Slice slice, SliceData sliceData) {
    final SliceMetadata metadata = SliceMetadata.from(context, slice);
    final long sliceTTL = metadata.getExpiry();
    assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
    final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
    final int color = colorItem.getInt();
    assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(context, sliceData));
    assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
    assertKeywords(metadata, sliceData);
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Aggregations

SliceItem (androidx.slice.SliceItem)46 SliceMetadata (androidx.slice.SliceMetadata)23 Slice (androidx.slice.Slice)22 Test (org.junit.Test)21 PendingIntent (android.app.PendingIntent)19 SliceAction (androidx.slice.core.SliceAction)19 IconCompat (androidx.core.graphics.drawable.IconCompat)6 ParceledListSlice (android.content.pm.ParceledListSlice)2 Intent (android.content.Intent)1 UiThreadTest (androidx.test.annotation.UiThreadTest)1 WifiSliceItem (com.android.settings.wifi.slice.WifiSliceItem)1 AccessPoint (com.android.settingslib.wifi.AccessPoint)1 Config (org.robolectric.annotation.Config)1