Search in sources :

Example 41 with SliceMetadata

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

the class LowStorageSliceTest method getSlice_storageFree_shouldHaveStorageSettingsTitle.

@Test
@Config(shadows = ShadowPrivateStorageInfo.class)
public void getSlice_storageFree_shouldHaveStorageSettingsTitle() {
    ShadowPrivateStorageInfo.setPrivateStorageInfo(new PrivateStorageInfo(100L, 100L));
    final Slice slice = mLowStorageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_settings));
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) ShadowPrivateStorageInfo(com.android.settings.testutils.shadow.ShadowPrivateStorageInfo) Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 42 with SliceMetadata

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

the class BluetoothDevicesSliceTest method getSlice_bluetoothTurningOn_shouldHaveBluetoothDevicesTitleAndPairNewDevice.

@Test
public void getSlice_bluetoothTurningOn_shouldHaveBluetoothDevicesTitleAndPairNewDevice() {
    mShadowBluetoothAdapter.setEnabled(false);
    mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_OFF);
    final Intent intent = new Intent().putExtra(EXTRA_ENABLE_BLUETOOTH, true);
    mBluetoothDevicesSlice.onNotifyChange(intent);
    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) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 43 with SliceMetadata

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

the class LowStorageSliceTest method getSlice_lowStorage_shouldHaveStorageFreeTitle.

@Test
@Config(shadows = ShadowPrivateStorageInfo.class)
public void getSlice_lowStorage_shouldHaveStorageFreeTitle() {
    ShadowPrivateStorageInfo.setPrivateStorageInfo(new PrivateStorageInfo(10L, 100L));
    final Slice slice = mLowStorageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_menu_free));
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) ShadowPrivateStorageInfo(com.android.settings.testutils.shadow.ShadowPrivateStorageInfo) Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 44 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_audioModeIsInCall_returnErrorSlice.

@Test
public void getSlice_audioModeIsInCall_returnErrorSlice() {
    mDevices.add(mDevice1);
    mDevices.add(mDevice2);
    when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
    doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
    mAudioManager.setMode(AudioManager.MODE_IN_CALL);
    final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    assertThat(metadata.isErrorSlice()).isTrue();
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 45 with SliceMetadata

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

the class ContextualWifiSliceTest method assertWifiHeader.

private void assertWifiHeader(Slice slice) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction)

Aggregations

SliceMetadata (androidx.slice.SliceMetadata)100 Slice (androidx.slice.Slice)72 Test (org.junit.Test)72 SliceAction (androidx.slice.core.SliceAction)53 PendingIntent (android.app.PendingIntent)24 SliceItem (androidx.slice.SliceItem)23 IconCompat (androidx.core.graphics.drawable.IconCompat)18 ParceledListSlice (android.content.pm.ParceledListSlice)11 Config (org.robolectric.annotation.Config)11 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)5 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)3 Uri (android.net.Uri)2 Handler (android.os.Handler)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 ListContent (androidx.slice.widget.ListContent)2 RowContent (androidx.slice.widget.RowContent)2 SliceContent (androidx.slice.widget.SliceContent)2 ShadowPrivateStorageInfo (com.android.settings.testutils.shadow.ShadowPrivateStorageInfo)2 Intent (android.content.Intent)1 FaceManager (android.hardware.face.FaceManager)1