diff options
Diffstat (limited to 'tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java')
-rw-r--r-- | tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java b/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java index b1d1743d0..4fedc889a 100644 --- a/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java +++ b/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java @@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; +import android.media.AudioManager; import android.media.session.MediaController; import android.os.Looper; @@ -70,6 +71,8 @@ public class AvrcpControllerStateMachineTest { @Mock private AdapterService mAdapterService; @Mock + private AudioManager mAudioManager; + @Mock private AvrcpControllerService mAvrcpControllerService; AvrcpControllerStateMachine mAvrcpStateMachine; @@ -90,6 +93,11 @@ public class AvrcpControllerStateMachineTest { TestUtils.setAdapterService(mAdapterService); TestUtils.startService(mServiceRule, AvrcpControllerService.class); doReturn(mTargetContext.getResources()).when(mAvrcpControllerService).getResources(); + doReturn(15).when(mAudioManager).getStreamMaxVolume(anyInt()); + doReturn(8).when(mAudioManager).getStreamVolume(anyInt()); + doReturn(true).when(mAudioManager).isVolumeFixed(); + doReturn(mAudioManager).when(mAvrcpControllerService) + .getSystemService(Context.AUDIO_SERVICE); // This line must be called to make sure relevant objects are initialized properly mAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -487,6 +495,18 @@ public class AvrcpControllerStateMachineTest { } /** + * Test that Absolute Volume Registration is working + */ + @Test + public void testRegisterAbsVolumeNotification() { + setUpConnectedState(true, true); + mAvrcpStateMachine.sendMessage( + AvrcpControllerStateMachine.MESSAGE_PROCESS_REGISTER_ABS_VOL_NOTIFICATION); + verify(mAvrcpControllerService, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)) + .sendRegisterAbsVolRspNative(any(), anyByte(), eq(127), anyInt()); + } + + /** * Setup Connected State * * @return number of times mAvrcpControllerService.sendBroadcastAsUser() has been invoked |