Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 315afc8f authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Prepare MOControllerTest for change in PhoneMediaDevice id assignment

Two tests (seemingly unintentionally) rely on the ids assigned by
PhoneMediaDevice being different from the ids assigned by the
system. More details in code.

This is blocking a fix for b/319103067, which is ag/25919934.

I see two options:
- We put in place a fix like the one in this CL.
- We disable these two tests.

In either case, the SysUI owners might want to revisit the decision
later.

Flag: NONE
Bug: b/319103067
Test: atest MediaOutputControllerTest
Change-Id: I05a1f851d8f162152148331bd95ac07112eac730
parent 2ecde8de
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -414,6 +414,18 @@ public class MediaOutputControllerTest extends SysuiTestCase {

    @Test
    public void onDeviceListUpdate_verifyDeviceListCallback() {
        // This test relies on mMediaOutputController.start being called while the selected device
        // list has exactly one item, and that item's id is:
        // - Different from both ids in mMediaDevices.
        // - Different from the id of the route published by the device under test (usually the
        //   built-in speakers).
        // So mock the selected device to respect these two preconditions.
        MediaDevice mockSelectedMediaDevice = Mockito.mock(MediaDevice.class);
        when(mockSelectedMediaDevice.getId()).thenReturn(TEST_DEVICE_3_ID);
        doReturn(List.of(mockSelectedMediaDevice))
                .when(mLocalMediaManager)
                .getSelectedMediaDevice();

        mMediaOutputController.start(mCb);
        reset(mCb);

@@ -434,6 +446,18 @@ public class MediaOutputControllerTest extends SysuiTestCase {

    @Test
    public void advanced_onDeviceListUpdateWithConnectedDeviceRemote_verifyItemSize() {
        // This test relies on mMediaOutputController.start being called while the selected device
        // list has exactly one item, and that item's id is:
        // - Different from both ids in mMediaDevices.
        // - Different from the id of the route published by the device under test (usually the
        //   built-in speakers).
        // So mock the selected device to respect these two preconditions.
        MediaDevice mockSelectedMediaDevice = Mockito.mock(MediaDevice.class);
        when(mockSelectedMediaDevice.getId()).thenReturn(TEST_DEVICE_3_ID);
        doReturn(List.of(mockSelectedMediaDevice))
                .when(mLocalMediaManager)
                .getSelectedMediaDevice();

        when(mMediaDevice1.getFeatures()).thenReturn(
                ImmutableList.of(MediaRoute2Info.FEATURE_REMOTE_PLAYBACK));
        when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mMediaDevice1);