Search in sources :

Example 1 with MediaDevice

use of com.android.settingslib.media.MediaDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaOutputSliceTest method onNotifyChange_notFoundMediaDevice_doNothing.

@Test
public void onNotifyChange_notFoundMediaDevice_doNothing() {
    mDevices.clear();
    final MediaDevice device = mock(MediaDevice.class);
    when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
    when(mLocalMediaManager.getMediaDeviceById(mDevices, TEST_DEVICE_1_ID)).thenReturn(device);
    mDevices.add(device);
    mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
    final Intent intent = new Intent();
    intent.putExtra("media_device_id", "fake_123");
    mMediaOutputSlice.onNotifyChange(intent);
    verify(mLocalMediaManager, never()).connectDevice(device);
}
Also used : Intent(android.content.Intent) MediaDevice(com.android.settingslib.media.MediaDevice) Test(org.junit.Test)

Example 2 with MediaDevice

use of com.android.settingslib.media.MediaDevice 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 3 with MediaDevice

use of com.android.settingslib.media.MediaDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaOutputSliceTest method onNotifyChange_foundMediaDevice_connect.

@Test
public void onNotifyChange_foundMediaDevice_connect() {
    mDevices.clear();
    final MediaDevice device = mock(MediaDevice.class);
    when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
    when(mLocalMediaManager.getMediaDeviceById(mDevices, TEST_DEVICE_1_ID)).thenReturn(device);
    mDevices.add(device);
    mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
    final Intent intent = new Intent();
    intent.putExtra("media_device_id", TEST_DEVICE_1_ID);
    mMediaOutputSlice.onNotifyChange(intent);
    verify(mLocalMediaManager).connectDevice(device);
}
Also used : Intent(android.content.Intent) MediaDevice(com.android.settingslib.media.MediaDevice) Test(org.junit.Test)

Example 4 with MediaDevice

use of com.android.settingslib.media.MediaDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaDeviceUpdateWorkerTest method onDeviceListUpdate_add1DeviceToDeviceList_shouldBeEqual.

@Test
public void onDeviceListUpdate_add1DeviceToDeviceList_shouldBeEqual() {
    mMediaDeviceUpdateWorker.onDeviceListUpdate(mMediaDevices);
    final List<MediaDevice> newDevices = new ArrayList<>();
    final MediaDevice device3 = mock(MediaDevice.class);
    when(mMediaDevice2.getId()).thenReturn(TEST_DEVICE_3_ID);
    newDevices.add(mMediaDevice1);
    newDevices.add(mMediaDevice2);
    newDevices.add(device3);
    mMediaDeviceUpdateWorker.onDeviceListUpdate(newDevices);
    final List<MediaDevice> devices = mMediaDeviceUpdateWorker.getMediaDevices();
    assertThat(devices.size()).isEqualTo(newDevices.size());
}
Also used : ArrayList(java.util.ArrayList) MediaDevice(com.android.settingslib.media.MediaDevice) Test(org.junit.Test)

Example 5 with MediaDevice

use of com.android.settingslib.media.MediaDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaOutputSlice method onNotifyChange.

@Override
public void onNotifyChange(Intent intent) {
    final MediaDeviceUpdateWorker worker = getWorker();
    final String id = intent != null ? intent.getStringExtra(MEDIA_DEVICE_ID) : "";
    final MediaDevice device = worker.getMediaDeviceById(id);
    if (device != null) {
        Log.d(TAG, "onNotifyChange() device name : " + device.getName());
        worker.connectDevice(device);
    }
}
Also used : MediaDevice(com.android.settingslib.media.MediaDevice)

Aggregations

MediaDevice (com.android.settingslib.media.MediaDevice)6 Test (org.junit.Test)4 Intent (android.content.Intent)2 Slice (androidx.slice.Slice)1 SliceMetadata (androidx.slice.SliceMetadata)1 ListBuilder (androidx.slice.builders.ListBuilder)1 SliceAction (androidx.slice.core.SliceAction)1 ArrayList (java.util.ArrayList)1