diff options
author | Joseph Pirozzo <pirozzoj@google.com> | 2019-06-24 17:08:50 -0700 |
---|---|---|
committer | Joseph Pirozzo <pirozzoj@google.com> | 2020-03-16 18:45:11 +0000 |
commit | 7c3a74093b155ffea85038c75621fb73a1a46b36 (patch) | |
tree | 2cf7599a9c75ca23e12c0ed66519e7cad77a671e /tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java | |
parent | 4d931c8105fd62a7e2290f2e0e37d601fd0942d2 (diff) | |
download | android_packages_apps_Bluetooth-7c3a74093b155ffea85038c75621fb73a1a46b36.tar.gz android_packages_apps_Bluetooth-7c3a74093b155ffea85038c75621fb73a1a46b36.tar.bz2 android_packages_apps_Bluetooth-7c3a74093b155ffea85038c75621fb73a1a46b36.zip |
AVRCP Controller AbsoluteVolumeNotification
Update AbsoluteVolumeNotification request to properly respond to
requests based upon the Fixed vs Dynamic volume levels.
Bug: 129478624
Test: atest com.android.bluetooth.avrcpcontroller.AvrcpControllerStateMachineTest#testRegisterAbsVolumeNotification
Change-Id: Ic9b745641a84712c005d40ecec50e55e9684d3ef
(cherry picked from commit 8fd119d8a27d42e09a90280020925859fd0a1678)
Merged-In: Ic9b745641a84712c005d40ecec50e55e9684d3ef
Change-Id: I1212a70ab84e3aed926bcfcac04dc62efed4b489
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 0ebb31e9e..4c77e0afa 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.os.Looper; import android.support.v4.media.session.MediaControllerCompat; @@ -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(); @@ -525,6 +533,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 |