Search in sources :

Example 1 with SliceContent

use of androidx.slice.widget.SliceContent in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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)

Aggregations

PendingIntent (android.app.PendingIntent)1 SliceMetadata (androidx.slice.SliceMetadata)1 SliceAction (androidx.slice.core.SliceAction)1 ListContent (androidx.slice.widget.ListContent)1 RowContent (androidx.slice.widget.RowContent)1 SliceContent (androidx.slice.widget.SliceContent)1