use of androidx.slice.SliceMetadata in project android_packages_apps_Settings by omnirom.
the class BluetoothDevicesSliceTest method getSlice_bluetoothOff_shouldHaveBluetoothOffTitleAndSummary.
@Test
public void getSlice_bluetoothOff_shouldHaveBluetoothOffTitleAndSummary() {
mShadowBluetoothAdapter.setEnabled(false);
mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_OFF);
final Slice slice = mBluetoothDevicesSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_devices_card_off_title));
assertThat(metadata.getSummary()).isEqualTo(mContext.getString(R.string.bluetooth_devices_card_off_summary));
}
use of androidx.slice.SliceMetadata 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.SliceMetadata 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.SliceMetadata in project android_packages_apps_Settings by omnirom.
the class WifiCallingSliceHelperTest method testWifiCallingPreferenceSlice.
private void testWifiCallingPreferenceSlice(Slice slice, SliceData sliceData, PendingIntent expectedPrimaryAction) {
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);
// Get all the rows
final ListContent listContent = new ListContent(mContext, slice);
final ArrayList<SliceContent> rowItems = listContent.getRowItems();
assertThat(rowItems.size()).isEqualTo(4);
// First row is HEADER
RowContent rowContent = (RowContent) rowItems.get(0);
assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(R.string.wifi_calling_mode_title));
// next is WIFI_ONLY
rowContent = (RowContent) rowItems.get(1);
assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_wifi_only_summary));
// next is WIFI_PREFERRED
rowContent = (RowContent) rowItems.get(2);
assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_wifi_preferred_summary));
// next is CELLULAR_PREFERRED
rowContent = (RowContent) rowItems.get(3);
assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_cellular_preferred_summary));
}
use of androidx.slice.SliceMetadata 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