use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSliceHelperTest method testWifiCallingSettingsToggleSlice.
private void testWifiCallingSettingsToggleSlice(Slice slice, SliceData sliceData) {
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction mainToggleAction = toggles.get(0);
// Check intent in Toggle Action
final PendingIntent togglePendingIntent = mainToggleAction.getAction();
final PendingIntent expectedToggleIntent = getBroadcastIntent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_CHANGED);
assertThat(togglePendingIntent).isEqualTo(expectedToggleIntent);
// Check primary intent
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
final PendingIntent expectedPendingIntent = getActivityIntent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_SETTINGS_ACTIVITY);
assertThat(primaryPendingIntent).isEqualTo(expectedPendingIntent);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, mContext.getString(R.string.wifi_calling_settings_title));
}
use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsToggleSlice.
private void testEnhanced4gLteSettingsToggleSlice(Slice slice) {
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction mainToggleAction = toggles.get(0);
// Check intent in Toggle Action
final PendingIntent togglePendingIntent = mainToggleAction.getAction();
final PendingIntent expectedToggleIntent = getBroadcastIntent(Enhanced4gLteSliceHelper.ACTION_ENHANCED_4G_LTE_CHANGED);
assertThat(togglePendingIntent).isEqualTo(expectedToggleIntent);
// Check primary intent
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
final PendingIntent expectedPendingIntent = getActivityIntent(Enhanced4gLteSliceHelper.ACTION_MOBILE_NETWORK_SETTINGS_ACTIVITY);
assertThat(primaryPendingIntent).isEqualTo(expectedPendingIntent);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, mContext.getString(R.string.enhanced_4g_lte_mode_title));
}
use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildIntentSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0, /* icon */
null);
Settings.Global.putInt(mContext.getContentResolver(), FakeUnavailablePreferenceController.AVAILABILITY_KEY, BasePreferenceController.DISABLED_DEPENDENT_SETTING);
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);
}
use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualWifiSliceTest method getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle.
@Test
public void getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle() {
mWifiSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
mWifiSlice.sPreviouslyDisplayed = true;
connectToWifi(makeValidatedNetworkCapabilities());
final Slice wifiSlice = mWifiSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Aggregations