Search in sources :

Example 6 with SliceAction

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

the class DeviceInfoSliceTest method getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent.

@Test
public void getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent() {
    final String phoneNumber = "1111111111";
    doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
    doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
    final Slice slice = mDeviceInfoSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_info_outline_24dp);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
    final List<SliceItem> sliceItems = slice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 7 with SliceAction

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

the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsUnavailableSlice.

private void testEnhanced4gLteSettingsUnavailableSlice(Slice slice, 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 Enhanced4gLte settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Check the title
    final List<SliceItem> sliceItems = slice.getItems();
    assertTitle(sliceItems, mContext.getString(R.string.enhanced_4g_lte_mode_title));
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 8 with SliceAction

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

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)

Example 9 with SliceAction

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

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 10 with SliceAction

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

the class SliceBuilderUtilsTest method buildSliderSlice_noIconPassed_returnsSliceWithIcon.

@Test
public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
    final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
    final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
    final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
    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

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