Search in sources :

Example 1 with SliceMetadata

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

the class BluetoothSliceBuilderTest method getBluetoothSlice_correctSliceContent.

@Test
public void getBluetoothSlice_correctSliceContent() {
    final Slice BluetoothSlice = BluetoothSliceBuilder.getSlice(mContext);
    final SliceMetadata metadata = SliceMetadata.from(mContext, BluetoothSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
    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 2 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_noActiveDevice_verifyDefaultName.

@Test
public void getSlice_noActiveDevice_verifyDefaultName() {
    mDevicesList.add(mA2dpDevice);
    when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
    when(mA2dpProfile.getActiveDevice()).thenReturn(null);
    // Verify slice title and subtitle
    final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
    assertThat(metadata.getSubtitle()).isEqualTo(mContext.getText(R.string.media_output_default_summary));
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 3 with SliceMetadata

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

the class MediaOutputIndicatorSliceTest method getSlice_A2dpDeviceActive_verifyName.

@Test
public void getSlice_A2dpDeviceActive_verifyName() {
    mDevicesList.add(mA2dpDevice);
    when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
    when(mA2dpProfile.getActiveDevice()).thenReturn(mA2dpDevice);
    final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
    assertThat(metadata.getSubtitle()).isEqualTo(TEST_A2DP_DEVICE_NAME);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test)

Example 4 with SliceMetadata

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

the class MediaOutputSliceTest method getSlice_shouldHaveActiveDeviceName.

@Test
public void getSlice_shouldHaveActiveDeviceName() {
    mDevices.clear();
    final MediaDevice device = mock(MediaDevice.class);
    when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
    when(device.getIcon()).thenReturn(mTestDrawable);
    when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
    final Slice mediaSlice = mMediaOutputSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, mediaSlice);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    assertThat(primaryAction.getTitle().toString()).isEqualTo(TEST_DEVICE_1_NAME);
}
Also used : Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) MediaDevice(com.android.settingslib.media.MediaDevice) Test(org.junit.Test)

Example 5 with SliceMetadata

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

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

SliceMetadata (androidx.slice.SliceMetadata)57 Slice (androidx.slice.Slice)44 Test (org.junit.Test)43 SliceAction (androidx.slice.core.SliceAction)29 PendingIntent (android.app.PendingIntent)12 SliceItem (androidx.slice.SliceItem)12 ParceledListSlice (android.content.pm.ParceledListSlice)11 IconCompat (androidx.core.graphics.drawable.IconCompat)11 Config (org.robolectric.annotation.Config)9 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)3 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)2 Uri (android.net.Uri)1 Handler (android.os.Handler)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ListContent (androidx.slice.widget.ListContent)1 RowContent (androidx.slice.widget.RowContent)1 SliceContent (androidx.slice.widget.SliceContent)1 MediaDevice (com.android.settingslib.media.MediaDevice)1