Search in sources :

Example 31 with SliceMetadata

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

the class RemoteMediaSliceTest method getSlice_withActiveSession_checkTitle.

@Test
public void getSlice_withActiveSession_checkTitle() {
    final Slice slice = mRemoteMediaSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    assertThat(primaryAction.getTitle().toString()).isEqualTo(mContext.getText(com.android.settings.R.string.remote_media_volume_option_title));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 32 with SliceMetadata

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

the class DarkThemeSliceTest method getSlice_newSession_notAvailable_returnErrorSlice.

@Test
public void getSlice_newSession_notAvailable_returnErrorSlice() {
    // previous displayed: yes
    mDarkThemeSlice.sKeepSliceShow = true;
    // Session: use original value + 1 to become a new session
    mDarkThemeSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken() + 1;
    mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
    final Slice mediaSlice = mDarkThemeSlice.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 33 with SliceMetadata

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

the class DarkThemeSliceTest method getSlice_batterySaver_returnErrorSlice.

@Test
public void getSlice_batterySaver_returnErrorSlice() {
    when(mPowerManager.isPowerSaveMode()).thenReturn(true);
    final Slice mediaSlice = mDarkThemeSlice.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 34 with SliceMetadata

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

the class DarkThemeSliceTest method getSlice_notAvailable_returnErrorSlice.

@Test
public void getSlice_notAvailable_returnErrorSlice() {
    mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
    final Slice mediaSlice = mDarkThemeSlice.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 35 with SliceMetadata

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

the class SliceBuilderUtilsTest method buildIntentSlice_noIconPassed_returnsSliceWithIcon.

@Test
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
    final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
    final SliceData sliceData = getMockData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT, 0x0);
    final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
    assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
Also used : Slice(androidx.slice.Slice) 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