Merge "Non-deselectable routes can be deselected" into rvc-dev am: 49217faf8e am: e20f765484 am: ceb23093e9 am: 7a87480f82

Change-Id: Id18ba750a4c3902f56375d44337bef6bf9bafbb6
This commit is contained in:
tim peng
2020-05-27 06:32:45 +00:00
committed by Automerger Merge Worker
3 changed files with 53 additions and 12 deletions

View File

@@ -90,6 +90,7 @@ public class MediaOutputGroupSliceTest {
private final List<MediaDevice> mSelectableDevices = new ArrayList<>();
private final List<MediaDevice> mSelectedDevices = new ArrayList<>();
private final List<MediaDevice> mDeselectableDevices = new ArrayList<>();
private Context mContext;
private MediaOutputGroupSlice mMediaOutputGroupSlice;
@@ -227,14 +228,19 @@ public class MediaOutputGroupSliceTest {
verify(sMediaDeviceUpdateWorker).addDeviceToPlayMedia(mDevice2);
}
@Test
public void onNotifyChange_sendSelectedDevice_verifyRemoveSession() {
public void onNotifyChange_sendDeselectableDevice_verifyRemoveSession() {
mSelectedDevices.add(mDevice1);
mSelectedDevices.add(mDevice2);
mDeselectableDevices.add(mDevice1);
mDeselectableDevices.add(mDevice2);
when(mLocalMediaManager.getMediaDeviceById(mSelectedDevices, TEST_DEVICE_2_ID))
.thenReturn(mDevice2);
sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectedDevices);
when(sMediaDeviceUpdateWorker.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
when(sMediaDeviceUpdateWorker.getDeselectableMediaDevice()).thenReturn(
mDeselectableDevices);
final Intent intent = new Intent();
intent.putExtra(MEDIA_DEVICE_ID, TEST_DEVICE_2_ID);
intent.putExtra(CUSTOMIZED_ACTION, ACTION_MEDIA_SESSION_OPERATION);
@@ -244,6 +250,26 @@ public class MediaOutputGroupSliceTest {
verify(sMediaDeviceUpdateWorker).removeDeviceFromPlayMedia(mDevice2);
}
@Test
public void onNotifyChange_sendNonDeselectableDevice_notRemoveSession() {
mSelectedDevices.add(mDevice1);
mSelectedDevices.add(mDevice2);
mDeselectableDevices.add(mDevice1);
when(mLocalMediaManager.getMediaDeviceById(mSelectedDevices, TEST_DEVICE_2_ID))
.thenReturn(mDevice2);
sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectedDevices);
when(sMediaDeviceUpdateWorker.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
when(sMediaDeviceUpdateWorker.getDeselectableMediaDevice()).thenReturn(
mDeselectableDevices);
final Intent intent = new Intent();
intent.putExtra(MEDIA_DEVICE_ID, TEST_DEVICE_2_ID);
intent.putExtra(CUSTOMIZED_ACTION, ACTION_MEDIA_SESSION_OPERATION);
mMediaOutputGroupSlice.onNotifyChange(intent);
verify(sMediaDeviceUpdateWorker, never()).removeDeviceFromPlayMedia(mDevice2);
}
@Test
public void onNotifyChange_noId_doNothing() {
mSelectableDevices.add(mDevice1);