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

Commit 254251e8 authored by Sal Savage's avatar Sal Savage
Browse files

Update test so a focus loss when paused expects no pause

Tag: #stability
Bug: 260948676
Test: atest BluetoothInstrumentationTests
Change-Id: I90e24cc9bf65b4fc532dc876d5384aa073dd5e39
parent 66bca36b
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -1426,12 +1426,13 @@ public class AvrcpControllerStateMachineTest {
    }

    /**
     * Test receiving an audio focus loss event. A pause should be sent
     * Test receiving an audio focus loss event. A pause should be sent if we were playing
     */
    @Test
    public void testOnAudioFocusLoss_pauseSent() {
    public void testOnAudioFocusLossWhilePlaying_pauseSent() {
        setUpConnectedState(true, true);
        sendAudioFocusUpdate(AudioManager.AUDIOFOCUS_GAIN);
        setPlaybackState(PlaybackStateCompat.STATE_PLAYING);
        sendAudioFocusUpdate(AudioManager.AUDIOFOCUS_LOSS);

        TestUtils.waitForLooperToBeIdle(mAvrcpStateMachine.getHandler().getLooper());
@@ -1439,7 +1440,23 @@ public class AvrcpControllerStateMachineTest {
                eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_DOWN));
        verify(mAvrcpControllerService, times(1)).sendPassThroughCommandNative(eq(mTestAddress),
                eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_UP));
    }

    /**
     * Test receiving an audio focus loss event. A pause should not be sent if we were paused
     */
    @Test
    public void testOnAudioFocusLossWhilePause_pauseNotSent() {
        setUpConnectedState(true, true);
        sendAudioFocusUpdate(AudioManager.AUDIOFOCUS_GAIN);
        setPlaybackState(PlaybackStateCompat.STATE_PAUSED);
        sendAudioFocusUpdate(AudioManager.AUDIOFOCUS_LOSS);

        TestUtils.waitForLooperToBeIdle(mAvrcpStateMachine.getHandler().getLooper());
        verify(mAvrcpControllerService, times(0)).sendPassThroughCommandNative(eq(mTestAddress),
                eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_DOWN));
        verify(mAvrcpControllerService, times(0)).sendPassThroughCommandNative(eq(mTestAddress),
                eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_UP));
    }

    /**