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

Commit f9b2d602 authored by Sal Savage's avatar Sal Savage Committed by Gerrit Code Review
Browse files

Merge "Update test so a focus loss when paused expects no pause"

parents 8275c7a5 254251e8
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));
    }

    /**