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);
}
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);
}
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);
}
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());
}
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);
}
}
Aggregations