Search in sources :

Example 86 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_audioModeIsRingtone_returnErrorSlice.

@Test
public void getSlice_audioModeIsRingtone_returnErrorSlice() {
    mDevices.add(mDevice1);
    mDevices.add(mDevice2);
    when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
    doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
    mAudioManager.setMode(AudioManager.MODE_RINGTONE);
    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 87 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_noConnectedDevice_returnErrorSlice.

@Test
public void getSlice_noConnectedDevice_returnErrorSlice() {
    mDevices.clear();
    when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
    mAudioManager.setMode(AudioManager.MODE_NORMAL);
    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 88 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_audioModeIsInCommunication_returnErrorSlice.

@Test
public void getSlice_audioModeIsInCommunication_returnErrorSlice() {
    mDevices.add(mDevice1);
    mDevices.add(mDevice2);
    when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
    doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
    mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
    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 89 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_withConnectedDevice_verifyMetadata.

@Test
public void getSlice_withConnectedDevice_verifyMetadata() {
    initPackage();
    mShadowPackageManager.addPackage(mPackageInfo, mPackageStats);
    mDevices.add(mDevice1);
    when(sMediaOutputIndicatorWorker.getMediaDevices()).thenReturn(mDevices);
    when(sMediaOutputIndicatorWorker.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
    doReturn(mMediaController).when(sMediaOutputIndicatorWorker).getActiveLocalMediaController();
    doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
    mAudioManager.setMode(AudioManager.MODE_NORMAL);
    final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.media_output_label_title, Utils.getApplicationLabel(mContext, TEST_PACKAGE_NAME)));
    assertThat(metadata.getSubtitle()).isEqualTo(TEST_DEVICE_1_NAME);
    assertThat(metadata.isErrorSlice()).isFalse();
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 90 with SliceMetadata

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

the class MobileDataSliceTest method getSlice_shouldHaveTitleAndToggle.

@Test
public void getSlice_shouldHaveTitleAndToggle() {
    final Slice mobileData = mMobileDataSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

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