Search in sources :

Example 26 with SliceItem

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));
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 27 with SliceItem

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();
}
Also used : SliceItem(androidx.slice.SliceItem)

Example 28 with SliceItem

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));
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 29 with SliceItem

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));
}
Also used : Slice(androidx.slice.Slice) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 30 with SliceItem

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);
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

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