diff options
Diffstat (limited to 'tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java')
-rw-r--r-- | tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java b/tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java index 70854d8d1..ccfd9f810 100644 --- a/tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java +++ b/tests/unit/src/com/android/bluetooth/mapclient/MapClientStateMachineTest.java @@ -150,6 +150,36 @@ public class MapClientStateMachineTest { Assert.assertEquals(BluetoothProfile.STATE_CONNECTED, mMceStateMachine.getState()); } + /** + * Test transition from STATE_CONNECTING --> (receive MSG_MAS_CONNECTED) --> STATE_CONNECTED + * --> (receive MSG_MAS_DISCONNECTED) --> STATE_DISCONNECTED + */ + @Test + public void testStateTransitionFromConnectedWithMasDisconnected() { + Log.i(TAG, "in testStateTransitionFromConnectedWithMasDisconnected"); + + setupSdpRecordReceipt(); + Message msg = Message.obtain(mHandler, MceStateMachine.MSG_MAS_CONNECTED); + mMceStateMachine.sendMessage(msg); + + // Wait until the message is processed and a broadcast request is sent to + // to MapClientService to change + // state from STATE_CONNECTING to STATE_CONNECTED + verify(mMockMapClientService, + timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(2)).sendBroadcast( + mIntentArgument.capture(), eq(ProfileService.BLUETOOTH_PERM)); + Assert.assertEquals(BluetoothProfile.STATE_CONNECTED, mMceStateMachine.getState()); + + msg = Message.obtain(mHandler, MceStateMachine.MSG_MAS_DISCONNECTED); + mMceStateMachine.sendMessage(msg); + verify(mMockMapClientService, + timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(4)).sendBroadcast( + mIntentArgument.capture(), eq(ProfileService.BLUETOOTH_PERM)); + + Assert.assertEquals(BluetoothProfile.STATE_DISCONNECTED, mMceStateMachine.getState()); + } + + /** * Test receiving an empty event report */ |