Search in sources :

Example 21 with Slice

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

the class NotificationChannelSliceTest method getSlice_noRecentlyInstalledApp_shouldHaveNoSuggestedAppTitle.

@Test
public void getSlice_noRecentlyInstalledApp_shouldHaveNoSuggestedAppTitle() {
    addMockPackageToPackageManager(false, /* isRecentlyInstalled */
    ApplicationInfo.FLAG_INSTALLED);
    mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false, /* banned */
    false);
    final Slice slice = mNotificationChannelSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 22 with Slice

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

the class NotificationChannelSliceTest method getSlice_noMultiChannelApp_shouldHaveNoSuggestedAppTitle.

@Test
public void getSlice_noMultiChannelApp_shouldHaveNoSuggestedAppTitle() {
    addMockPackageToPackageManager(true, /* isRecentlyInstalled */
    ApplicationInfo.FLAG_INSTALLED);
    mockNotificationBackend(1, /* channelCount */
    NOTIFICATION_COUNT, false, /* banned */
    false);
    final Slice slice = mNotificationChannelSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 23 with Slice

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

the class NotificationChannelSliceTest method getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows.

@Test
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows() {
    addMockPackageToPackageManager(true, /* isRecentlyInstalled */
    ApplicationInfo.FLAG_INSTALLED);
    mockNotificationBackend(NotificationChannelSlice.DEFAULT_EXPANDED_ROW_COUNT * 2, NOTIFICATION_COUNT, false, /* banned */
    false);
    final Slice slice = mNotificationChannelSlice.getSlice();
    // Get the number of RowBuilders from Slice.
    final int rows = SliceQuery.findAll(slice, FORMAT_SLICE, HINT_LIST_ITEM, null).size();
    // The header of this slice is built by RowBuilder. Hence, the row count will contain it.
    assertThat(rows).isEqualTo(NotificationChannelSlice.DEFAULT_EXPANDED_ROW_COUNT + 1);
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 24 with Slice

use of androidx.slice.Slice 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 25 with Slice

use of androidx.slice.Slice 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)

Aggregations

Slice (androidx.slice.Slice)216 Test (org.junit.Test)204 SliceMetadata (androidx.slice.SliceMetadata)73 SliceAction (androidx.slice.core.SliceAction)28 SliceItem (androidx.slice.SliceItem)22 Config (org.robolectric.annotation.Config)20 Uri (android.net.Uri)17 ParceledListSlice (android.content.pm.ParceledListSlice)14 IconCompat (androidx.core.graphics.drawable.IconCompat)14 ContextualWifiSlice (com.android.settings.wifi.slice.ContextualWifiSlice)9 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)9 UiThreadTest (androidx.test.annotation.UiThreadTest)8 VisibleForTesting (androidx.annotation.VisibleForTesting)5 EmergencyInfoSlice (com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice)5 ArrayList (java.util.ArrayList)5 PendingIntent (android.app.PendingIntent)4 Intent (android.content.Intent)4 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)4 EarlyWarningTip (com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip)4 LowBatteryTip (com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip)4