Search in sources :

Example 16 with Slice

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

the class WifiCallingSliceHelperTest method test_SettingSliceProvider_getsRightSliceWifiCalling.

@Test
public void test_SettingSliceProvider_getsRightSliceWifiCalling() {
    when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
    when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
    when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
    when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
    when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
    when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext)).thenReturn(mWfcSliceHelper);
    final Slice slice = mProvider.onBindSlice(CustomSliceRegistry.WIFI_CALLING_URI);
    assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
    testWifiCallingSettingsToggleSlice(slice, null);
}
Also used : Slice(androidx.slice.Slice) Test(org.junit.Test)

Example 17 with Slice

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

the class NotificationChannelSliceTest method getSlice_hasSuggestedApp_shouldHaveNotificationChannelTitle.

@Test
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_hasSuggestedApp_shouldHaveNotificationChannelTitle() {
    addMockPackageToPackageManager(true, /* 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.manage_app_notification, APP_LABEL));
}
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 18 with Slice

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

the class NotificationChannelSliceTest method getSlice_hasSuggestedApp_shouldSortByNotificationSentCount.

@Test
@Config(shadows = ShadowRestrictedLockUtilsInternal.class)
public void getSlice_hasSuggestedApp_shouldSortByNotificationSentCount() {
    addMockPackageToPackageManager(true, /* isRecentlyInstalled */
    ApplicationInfo.FLAG_INSTALLED);
    mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false, /* banned */
    false);
    final Slice slice = mNotificationChannelSlice.getSlice();
    // Get all RowBuilders from Slice.
    final List<SliceItem> rowItems = SliceQuery.findAll(slice, FORMAT_SLICE, HINT_LIST_ITEM, null);
    // Ensure the total size of rows is equal to the notification channel count with header.
    assertThat(rowItems).isNotNull();
    assertThat(rowItems.size()).isEqualTo(CHANNEL_COUNT + 1);
    // Remove the header of slice.
    rowItems.remove(0);
    // Test the rows of slice are sorted with notification sent count by descending.
    for (int i = 0; i < rowItems.size(); i++) {
        // Assert the summary text is the same as expectation.
        assertThat(getSummaryFromSliceItem(rowItems.get(i))).isEqualTo(mContext.getResources().getQuantityString(R.plurals.notifications_sent_weekly, CHANNEL_COUNT - i, CHANNEL_COUNT - i));
    }
}
Also used : Slice(androidx.slice.Slice) ParceledListSlice(android.content.pm.ParceledListSlice) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 19 with Slice

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

the class BatteryFixSliceTest method getSlice_unimportantSlice_shouldSkip.

@Test
public void getSlice_unimportantSlice_shouldSkip() {
    final List<BatteryTip> tips = new ArrayList<>();
    tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
    tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
    ShadowBatteryTipLoader.setBatteryTips(tips);
    BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
    final Slice slice = mSlice.getSlice();
    assertThat(SliceMetadata.from(mContext, slice).isErrorSlice()).isTrue();
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) Slice(androidx.slice.Slice) ArrayList(java.util.ArrayList) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) Test(org.junit.Test)

Example 20 with Slice

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

the class BatteryFixSliceTest method getSlice_hasImportantTip_shouldTintIcon.

@Test
@Config(shadows = { BatteryFixSliceTest.ShadowEarlyWarningTip.class, BatteryFixSliceTest.ShadowSliceBackgroundWorker.class })
public void getSlice_hasImportantTip_shouldTintIcon() {
    final List<BatteryTip> tips = new ArrayList<>();
    tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
    // Create fake cache data
    ShadowBatteryTipLoader.setBatteryTips(tips);
    BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
    // Create fake background worker data
    BatteryFixSlice.BatteryTipWorker batteryTipWorker = mock(BatteryFixSlice.BatteryTipWorker.class);
    when(batteryTipWorker.getResults()).thenReturn(tips);
    ShadowSliceBackgroundWorker.setBatteryTipWorkerWorker(batteryTipWorker);
    final Slice slice = mSlice.getSlice();
    assertThat(ShadowEarlyWarningTip.isIconTintColorIdCalled()).isTrue();
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) Slice(androidx.slice.Slice) ArrayList(java.util.ArrayList) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

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