Search in sources :

Example 11 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationChannelSliceTest method getSlice_channelCountIsLessThanDefaultRows_subTitleShouldNotHaveTapToManagerAll.

@Test
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_channelCountIsLessThanDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
    addMockPackageToPackageManager(true, /* isRecentlyInstalled */
    ApplicationInfo.FLAG_INSTALLED);
    mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false, /* banned */
    false);
    final Slice slice = mNotificationChannelSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getSubtitle()).isEqualTo(mContext.getResources().getQuantityString(R.plurals.notification_few_channel_count_summary, CHANNEL_COUNT - 1, CHANNEL_COUNT - 1));
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 12 with SliceMetadata

use of androidx.slice.SliceMetadata 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 13 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DeviceInfoSliceTest method getSlice_hasNoSubscriptionInfo_shouldShowUnknown.

@Test
public void getSlice_hasNoSubscriptionInfo_shouldShowUnknown() {
    final Slice slice = mDeviceInfoSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
    final List<SliceItem> sliceItems = slice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, mContext.getString(R.string.device_info_default));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 14 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothDevicesSliceTest method getSlice_hasBluetoothDevices_shouldHaveBluetoothDevicesTitle.

@Test
public void getSlice_hasBluetoothDevices_shouldHaveBluetoothDevicesTitle() {
    mockBluetoothDeviceList(1);
    doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
    final Slice slice = mBluetoothDevicesSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_devices));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 15 with SliceMetadata

use of androidx.slice.SliceMetadata in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothDevicesSliceTest method getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle.

@Test
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
    doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
    final Slice slice = mBluetoothDevicesSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_bluetooth_devices));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) 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