Non-deselectable routes can be deselected

-Check deselectable list
-Add test case

Bug: 157098549
Test: make -j42 RunSettingsRoboTests
Change-Id: I254a9d3825319aa7b262d04e4f4c580f76afe381
This commit is contained in:
Tim Peng
2020-05-21 11:13:44 +08:00
committed by tim peng
parent 37318d03a4
commit 1af5b0cd7b
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);