Search in sources :

Example 46 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelperTest method testWifiCallingPreferenceSlice.

private void testWifiCallingPreferenceSlice(Slice slice, SliceData sliceData, PendingIntent expectedPrimaryAction) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    // Check there is no toggle action
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    // Check whether the primary action is to open wifi calling settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Get all the rows
    final ListContent listContent = new ListContent(mContext, slice);
    final ArrayList<SliceContent> rowItems = listContent.getRowItems();
    assertThat(rowItems.size()).isEqualTo(4);
    // First row is HEADER
    RowContent rowContent = (RowContent) rowItems.get(0);
    assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(R.string.wifi_calling_mode_title));
    // next is WIFI_ONLY
    rowContent = (RowContent) rowItems.get(1);
    assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_wifi_only_summary));
    // next is WIFI_PREFERRED
    rowContent = (RowContent) rowItems.get(2);
    assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_wifi_preferred_summary));
    // next is CELLULAR_PREFERRED
    rowContent = (RowContent) rowItems.get(3);
    assertThat(rowContent.getTitleItem().getText()).isEqualTo(mContext.getText(com.android.internal.R.string.wfc_mode_cellular_preferred_summary));
}
Also used : ListContent(androidx.slice.widget.ListContent) RowContent(androidx.slice.widget.RowContent) SliceContent(androidx.slice.widget.SliceContent) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) PendingIntent(android.app.PendingIntent)

Example 47 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelperTest method testWifiCallingSettingsUnavailableSlice.

private void testWifiCallingSettingsUnavailableSlice(Slice slice, SliceData sliceData, PendingIntent expectedPrimaryAction, String title) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    // Check there is no toggle action
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    // Check whether the primary action is to open wifi calling settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Check the title
    final List<SliceItem> sliceItems = slice.getItems();
    assertTitle(sliceItems, title);
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 48 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class MobileDataSliceTest method getSlice_shouldHaveTitleAndToggle.

@Test
public void getSlice_shouldHaveTitleAndToggle() {
    final Slice mobileData = mMobileDataSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 49 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsUnavailableSlice.

private void testEnhanced4gLteSettingsUnavailableSlice(Slice slice, PendingIntent expectedPrimaryAction) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    // Check there is no toggle action
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    // Check whether the primary action is to open Enhanced4gLte settings activity
    final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
    assertThat(primaryPendingIntent).isEqualTo(expectedPrimaryAction);
    // Check the title
    final List<SliceItem> sliceItems = slice.getItems();
    assertTitle(sliceItems, ResourcesUtils.getResourcesString(mContext, "enhanced_4g_lte_mode_title"));
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 50 with SliceAction

use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.

the class LocationSliceTest method getLocationSlice_correctSliceContent.

@Test
public void getLocationSlice_correctSliceContent() {
    final Slice LocationSlice = new LocationSlice(mContext).getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, LocationSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.location_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Aggregations

SliceAction (androidx.slice.core.SliceAction)54 SliceMetadata (androidx.slice.SliceMetadata)53 Slice (androidx.slice.Slice)27 Test (org.junit.Test)27 PendingIntent (android.app.PendingIntent)23 SliceItem (androidx.slice.SliceItem)19 IconCompat (androidx.core.graphics.drawable.IconCompat)18 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)3 VisibleForTesting (androidx.annotation.VisibleForTesting)2 ListContent (androidx.slice.widget.ListContent)2 RowContent (androidx.slice.widget.RowContent)2 SliceContent (androidx.slice.widget.SliceContent)2 SharedPreferences (android.content.SharedPreferences)1 ArraySet (android.util.ArraySet)1 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)1 MediaDevice (com.android.settingslib.media.MediaDevice)1