Search in sources :

Example 21 with SliceItem

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

the class WifiSliceTest method getWifiSlice_noAp_shouldReturnLoadingRow.

@Test
public void getWifiSlice_noAp_shouldReturnLoadingRow() {
    final Slice wifiSlice = mWifiSlice.getSlice();
    final int rows = SliceQuery.findAll(wifiSlice, FORMAT_SLICE, HINT_LIST_ITEM, null).size();
    final List<SliceItem> sliceItems = wifiSlice.getItems();
    // All AP rows + title row
    assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT + 1);
    // 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 22 with SliceItem

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

the class WifiSliceTest method getWifiSlice_oneConnectedApAndOneDisconnectedAp_shouldReturnLoadingRow.

@Test
public void getWifiSlice_oneConnectedApAndOneDisconnectedAp_shouldReturnLoadingRow() {
    setWorkerResults(createWifiSliceItem(AP1_NAME, WifiEntry.CONNECTED_STATE_CONNECTED), createWifiSliceItem(AP2_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);
    // 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 23 with SliceItem

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

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

Example 24 with SliceItem

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

the class DataUsageSliceTest method getSlice_hasNoSim_shouldShowNoSimCard.

@Test
public void getSlice_hasNoSim_shouldShowNoSimCard() {
    ShadowDataUsageUtils.HAS_SIM = false;
    final Slice slice = mDataUsageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.data_usage_summary_title));
    final List<SliceItem> sliceItems = slice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, mContext.getString(R.string.no_sim_card));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 25 with SliceItem

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

the class BluetoothDevicesSliceTest method getSlice_hasBluetoothDevices_shouldMatchBluetoothMockTitle.

@Test
public void getSlice_hasBluetoothDevices_shouldMatchBluetoothMockTitle() {
    mockBluetoothDeviceList(1);
    doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
    final Slice slice = mBluetoothDevicesSlice.getSlice();
    final List<SliceItem> sliceItems = slice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, BLUETOOTH_MOCK_TITLE);
}
Also used : Slice(androidx.slice.Slice) 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