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

Commit 4acc99e3 authored by Ang Li's avatar Ang Li Committed by Android (Google) Code Review
Browse files

Merge "Add test for non-BLE device selected with personal audio sharing" into main

parents a9322002 3248486b
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -616,6 +616,36 @@ public class AudioManagerRouteControllerTest {
                .isEqualTo(RoutingSessionInfo.RELEASE_UNSUPPORTED);
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_OUTPUT_SWITCHER_PERSONAL_AUDIO_SHARING)
    public void getRoutes_nonBLEDeviceSelectedAndOutputNotBroadcast_returnsCorrectStates() {
        setUpControllerAndLEAudioMocks();
        when(mMockBluetoothDeviceRoutesManager.isLEAudioBroadcastSupported()).thenReturn(true);
        // Select the built-in speaker, but have a BLE device available.
        addAvailableAudioDeviceInfo(
                /* newSelectedDevice= */ FAKE_AUDIO_DEVICE_INFO_BUILTIN_SPEAKER,
                /* newAvailableDevices...= */ FAKE_AUDIO_DEVICE_LE_HEADSET_1);

        List<MediaRoute2Info> selectableRoutes = mControllerUnderTest.getSelectableRoutes();
        List<String> selectedRoutesNames =
                mControllerUnderTest.getSelectedRoutes().stream()
                        .map(it -> it.getName().toString())
                        .toList();
        List<MediaRoute2Info> deselectableRoutes = mControllerUnderTest.getDeselectableRoutes();

        // When a non-BLE device is selected, no other devices should be selectable for broadcast.
        assertThat(selectableRoutes).isEmpty();
        // The selected route should be the built-in speaker.
        assertThat(selectedRoutesNames)
                .containsExactly(
                        FAKE_AUDIO_DEVICE_INFO_BUILTIN_SPEAKER.getProductName().toString());
        // Deselectable routes should be empty since we are not in a broadcast session.
        assertThat(deselectableRoutes).isEmpty();
        // Session release type should be unsupported.
        assertThat(mControllerUnderTest.getSessionReleaseType())
                .isEqualTo(RoutingSessionInfo.RELEASE_UNSUPPORTED);
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_OUTPUT_SWITCHER_PERSONAL_AUDIO_SHARING)
    public void getRoutes_singleDeviceSelectedAndOutputIsBroadcast_returnsCorrectStates() {