Loading tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.media.AudioManager; import android.os.Looper; import android.support.v4.media.session.MediaControllerCompat; Loading Loading @@ -83,6 +84,9 @@ public class AvrcpControllerStateMachineTest { @Mock private AvrcpControllerService mAvrcpControllerService; @Mock private Resources mMockResources; AvrcpControllerStateMachine mAvrcpStateMachine; @Before Loading @@ -103,7 +107,9 @@ public class AvrcpControllerStateMachineTest { TestUtils.clearAdapterService(mAvrcpAdapterService); TestUtils.setAdapterService(mA2dpAdapterService); TestUtils.startService(mA2dpServiceRule, A2dpSinkService.class); doReturn(mTargetContext.getResources()).when(mAvrcpControllerService).getResources(); when(mMockResources.getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus)) .thenReturn(true); doReturn(mMockResources).when(mAvrcpControllerService).getResources(); doReturn(15).when(mAudioManager).getStreamMaxVolume(anyInt()); doReturn(8).when(mAudioManager).getStreamVolume(anyInt()); doReturn(true).when(mAudioManager).isVolumeFixed(); Loading Loading @@ -605,6 +611,8 @@ public class AvrcpControllerStateMachineTest { */ @Test public void testPlaybackWhileMusicPlaying() { when(mMockResources.getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus)) .thenReturn(false); Assert.assertEquals(AudioManager.AUDIOFOCUS_NONE, A2dpSinkService.getFocusState()); doReturn(true).when(mAudioManager).isMusicActive(); setUpConnectedState(true, true); Loading @@ -612,7 +620,6 @@ public class AvrcpControllerStateMachineTest { AvrcpControllerStateMachine.MESSAGE_PROCESS_PLAY_STATUS_CHANGED, PlaybackStateCompat.STATE_PLAYING); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); verify(mAudioManager, times(1)).isMusicActive(); verify(mAvrcpControllerService, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).sendPassThroughCommandNative( eq(mTestAddress), eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_DOWN)); Loading @@ -633,7 +640,6 @@ public class AvrcpControllerStateMachineTest { AvrcpControllerStateMachine.MESSAGE_PROCESS_PLAY_STATUS_CHANGED, PlaybackStateCompat.STATE_PLAYING); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); verify(mAudioManager, times(1)).isMusicActive(); TestUtils.waitForLooperToFinishScheduledTask( A2dpSinkService.getA2dpSinkService().getMainLooper()); Assert.assertEquals(AudioManager.AUDIOFOCUS_GAIN, A2dpSinkService.getFocusState()); Loading Loading
tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.media.AudioManager; import android.os.Looper; import android.support.v4.media.session.MediaControllerCompat; Loading Loading @@ -83,6 +84,9 @@ public class AvrcpControllerStateMachineTest { @Mock private AvrcpControllerService mAvrcpControllerService; @Mock private Resources mMockResources; AvrcpControllerStateMachine mAvrcpStateMachine; @Before Loading @@ -103,7 +107,9 @@ public class AvrcpControllerStateMachineTest { TestUtils.clearAdapterService(mAvrcpAdapterService); TestUtils.setAdapterService(mA2dpAdapterService); TestUtils.startService(mA2dpServiceRule, A2dpSinkService.class); doReturn(mTargetContext.getResources()).when(mAvrcpControllerService).getResources(); when(mMockResources.getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus)) .thenReturn(true); doReturn(mMockResources).when(mAvrcpControllerService).getResources(); doReturn(15).when(mAudioManager).getStreamMaxVolume(anyInt()); doReturn(8).when(mAudioManager).getStreamVolume(anyInt()); doReturn(true).when(mAudioManager).isVolumeFixed(); Loading Loading @@ -605,6 +611,8 @@ public class AvrcpControllerStateMachineTest { */ @Test public void testPlaybackWhileMusicPlaying() { when(mMockResources.getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus)) .thenReturn(false); Assert.assertEquals(AudioManager.AUDIOFOCUS_NONE, A2dpSinkService.getFocusState()); doReturn(true).when(mAudioManager).isMusicActive(); setUpConnectedState(true, true); Loading @@ -612,7 +620,6 @@ public class AvrcpControllerStateMachineTest { AvrcpControllerStateMachine.MESSAGE_PROCESS_PLAY_STATUS_CHANGED, PlaybackStateCompat.STATE_PLAYING); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); verify(mAudioManager, times(1)).isMusicActive(); verify(mAvrcpControllerService, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).sendPassThroughCommandNative( eq(mTestAddress), eq(AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE), eq(KEY_DOWN)); Loading @@ -633,7 +640,6 @@ public class AvrcpControllerStateMachineTest { AvrcpControllerStateMachine.MESSAGE_PROCESS_PLAY_STATUS_CHANGED, PlaybackStateCompat.STATE_PLAYING); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); verify(mAudioManager, times(1)).isMusicActive(); TestUtils.waitForLooperToFinishScheduledTask( A2dpSinkService.getA2dpSinkService().getMainLooper()); Assert.assertEquals(AudioManager.AUDIOFOCUS_GAIN, A2dpSinkService.getFocusState()); Loading