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();
}
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);
}
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));
}
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));
}
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);
}
Aggregations