Search in sources :

Example 36 with SliceItem

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

the class NotificationChannelSliceTest method getSummaryFromSliceItem.

private CharSequence getSummaryFromSliceItem(SliceItem rowItem) {
    if (rowItem == null) {
        return null;
    }
    final Slice rowSlice = rowItem.getSlice();
    if (rowSlice == null) {
        return null;
    }
    final List<SliceItem> rowSliceItems = rowSlice.getItems();
    if (rowSliceItems == null || rowSliceItems.size() < 2) {
        return null;
    }
    // Index 0: title; Index 1: summary.
    return rowSliceItems.get(1).getText();
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) SliceItem(androidx.slice.SliceItem)

Example 37 with SliceItem

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

the class BluetoothDevicesSliceTest method getSlice_hasBluetoothDevices_shouldMatchBluetoothMockTitle.

@Test
public void getSlice_hasBluetoothDevices_shouldMatchBluetoothMockTitle() {
    mockBluetoothDeviceList(1);
    doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getPairedBluetoothDevices();
    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)

Example 38 with SliceItem

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

the class BluetoothDevicesSliceTest method getSlice_bluetoothOn_shouldHaveBluetoothDevicesTitleAndPairNewDevice.

@Test
public void getSlice_bluetoothOn_shouldHaveBluetoothDevicesTitleAndPairNewDevice() {
    final Slice slice = mBluetoothDevicesSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_devices));
    final List<SliceItem> sliceItems = slice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, mContext.getString(R.string.bluetooth_pairing_pref_title));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 39 with SliceItem

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

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 40 with SliceItem

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

the class WifiCallingSliceHelperTest method testWifiCallingSettingsUnavailableSlice.

private void testWifiCallingSettingsUnavailableSlice(Slice slice, SliceData sliceData, PendingIntent expectedPrimaryAction, String title) {
    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 wifi calling settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Check the title
    final List<SliceItem> sliceItems = slice.getItems();
    assertTitle(sliceItems, title);
}
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