Search in sources :

Example 26 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class ZenModeSliceBuilderTest method getZenModeSlice_correctSliceContent.

@Test
public void getZenModeSlice_correctSliceContent() {
    final Slice dndSlice = ZenModeSliceBuilder.getSlice(mContext);
    final SliceMetadata metadata = SliceMetadata.from(mContext, dndSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.zen_mode_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    assertThat(primaryAction.getIcon()).isNull();
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 27 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class FlashlightSliceTest method getFlashlightSlice_correctData.

@Test
public void getFlashlightSlice_correctData() {
    Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 1);
    final Slice slice = new FlashlightSlice(mContext).getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.power_flashlight));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 28 with SliceAction

use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageSliceTest method getSlice_hasSim_shouldBeCorrectSliceContent.

@Test
public void getSlice_hasSim_shouldBeCorrectSliceContent() {
    ShadowDataUsageUtils.HAS_SIM = true;
    doReturn(DATA_USAGE_TITLE).when(mDataUsageSlice).getDataUsageText(any());
    doReturn(DATA_USAGE_SUMMARY).when(mDataUsageSlice).getCycleTime(any());
    final Slice slice = mDataUsageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.data_usage_summary_title));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_data_usage);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.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)

Example 29 with SliceAction

use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageSliceTest method getSlice_shouldBeCorrectSliceContent.

@Test
public void getSlice_shouldBeCorrectSliceContent() {
    final PrivateStorageInfo info = new PrivateStorageInfo(100L, 600L);
    doReturn(info).when(mStorageSlice).getPrivateStorageInfo();
    doReturn(USED_BYTES_TEXT).when(mStorageSlice).getStorageUsedText(any());
    doReturn(SUMMARY_TEXT).when(mStorageSlice).getStorageSummaryText(any());
    final Slice slice = mStorageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_label));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_homepage_storage);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 30 with SliceAction

use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FlashlightSliceTest method getFlashlightSlice_correctData.

@Test
public void getFlashlightSlice_correctData() {
    Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 1);
    final Slice slice = new FlashlightSlice(mContext).getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.power_flashlight));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Aggregations

SliceAction (androidx.slice.core.SliceAction)54 SliceMetadata (androidx.slice.SliceMetadata)53 Slice (androidx.slice.Slice)27 Test (org.junit.Test)27 PendingIntent (android.app.PendingIntent)23 SliceItem (androidx.slice.SliceItem)19 IconCompat (androidx.core.graphics.drawable.IconCompat)18 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)3 VisibleForTesting (androidx.annotation.VisibleForTesting)2 ListContent (androidx.slice.widget.ListContent)2 RowContent (androidx.slice.widget.RowContent)2 SliceContent (androidx.slice.widget.SliceContent)2 SharedPreferences (android.content.SharedPreferences)1 ArraySet (android.util.ArraySet)1 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)1 MediaDevice (com.android.settingslib.media.MediaDevice)1