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);
}
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));
}
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));
}
}
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();
}
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();
}
Aggregations