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

Commit 3248486b authored by Ang Li's avatar Ang Li Committed by Yuexi Ma
Browse files

Add test for non-BLE device selected with personal audio sharing

Adds a new unit test to cover the scenario where personal audio sharing (LE Audio Broadcast) is supported, but the currently selected audio output device is not a BLE headset (e.g., the built-in speaker).

This test verifies that in this state:
- No routes are available for selection to start a broadcast session.
- No routes are deselectable.
- The session release type is correctly reported as unsupported.


Please help fill out the survey for feedback: https://docs.google.com/forms/d/e/1FAIpQLSeKFKpHImCAqZIa_OR801cw72HQUreM2oGM25C3mKKT2tBFnw/viewform?usp=pp_url&entry.1586624956=ag/35413605

Please feel free to use your domain knowledge to make changes to the generated tests to make it more valuable for your team.

Original Change: ag/34855603 (Note tests are based on the original CL but may add coverage beyond the specific changes to improve overall code health)

Test: ATP tests passed http://ab/I82500010441880672
Bug: 431235865
Flag: TEST_ONLY



Change-Id: Idd70307209c04fab8b5158113fda18e88bdd8267
parent aa8287c6
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() {