Loading android/app/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java +10 −3 Original line number Diff line number Diff line Loading @@ -668,11 +668,18 @@ public class AvrcpControllerStateMachineTest { secondAvrcpStateMachine.start(); Assert.assertFalse(mAvrcpStateMachine.isActive()); // Connect device 1 and 2 and verify first one is set as active // Connect device 1 and 2 and verify second one is set as active setUpConnectedState(true, true); secondAvrcpStateMachine.connect(StackEvent.connectionStateChanged(true, true)); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); Assert.assertTrue(mAvrcpStateMachine.isActive()); Assert.assertFalse(secondAvrcpStateMachine.isActive()); secondAvrcpStateMachine.connect(StackEvent.connectionStateChanged(true, true)); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); TestUtils.waitForLooperToFinishScheduledTask(secondAvrcpStateMachine.getHandler() .getLooper()); Assert.assertFalse(mAvrcpStateMachine.isActive()); Assert.assertTrue(secondAvrcpStateMachine.isActive()); // Request the second device to play an item and verify active device switched BrowseTree.BrowseNode results = mAvrcpStateMachine.findNode(rootName); Loading android/app/tests/unit/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachineTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.Utils; import org.hamcrest.core.AllOf; Loading Loading @@ -96,6 +97,7 @@ public class HeadsetClientStateMachineTest { new HeadsetClientStateMachine(mHeadsetClientService, mHandlerThread.getLooper(), mNativeInterface); mHeadsetClientStateMachine.start(); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); } @After Loading @@ -103,6 +105,7 @@ public class HeadsetClientStateMachineTest { if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient)) { return; } TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); mHeadsetClientStateMachine.doQuit(); mHandlerThread.quit(); } Loading Loading @@ -292,10 +295,11 @@ public class HeadsetClientStateMachineTest { -1)); Assert.assertEquals(true, mHeadsetClientStateMachine.getInBandRing()); // Simulate a new incoming phone call StackEvent eventCallStatusUpdated = new StackEvent(StackEvent.EVENT_TYPE_CLIP); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); mHeadsetClientStateMachine.sendMessage(StackEvent.STACK_EVENT, eventCallStatusUpdated); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); verify(mHeadsetClientService, timeout(STANDARD_WAIT_MILLIS).times(3)).sendBroadcast( intentArgument.capture(), anyString()); Loading @@ -319,11 +323,11 @@ public class HeadsetClientStateMachineTest { StackEvent eventCommandStatus = new StackEvent(StackEvent.EVENT_TYPE_CMD_RESULT); eventCommandStatus.valueInt = AT_OK; mHeadsetClientStateMachine.sendMessage(StackEvent.STACK_EVENT, eventCommandStatus); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); verify(mHeadsetClientService, timeout(QUERY_CURRENT_CALLS_TEST_WAIT_MILLIS).times(4)) .sendBroadcast( intentArgument.capture(), anyString()); // Verify that the new call is being registered with the inBandRing flag set. Assert.assertEquals(true, ((BluetoothHeadsetClientCall) intentArgument.getValue().getParcelableExtra( Loading android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java +5 −13 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.bluetooth.BluetoothProfile; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.filters.FlakyTest; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -73,7 +72,6 @@ public class MapClientTest { TestUtils.startService(mServiceRule, MapClientService.class); mService = MapClientService.getMapClientService(); Assert.assertNotNull(mService); cleanUpInstanceMap(); mAdapter = BluetoothAdapter.getDefaultAdapter(); when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager); } Loading @@ -89,16 +87,6 @@ public class MapClientTest { TestUtils.clearAdapterService(mAdapterService); } private void cleanUpInstanceMap() { if (!mService.getInstanceMap().isEmpty()) { List<BluetoothDevice> deviceList = mService.getConnectedDevices(); for (BluetoothDevice d : deviceList) { mService.disconnect(d); } } Assert.assertTrue(mService.getInstanceMap().isEmpty()); } /** * Mock the priority of a bluetooth device * Loading Loading @@ -132,13 +120,17 @@ public class MapClientTest { Map<BluetoothDevice, MceStateMachine> map = mService.getInstanceMap(); Assert.assertEquals(1, map.size()); Assert.assertNotNull(map.get(device)); TestUtils.waitForLooperToFinishScheduledTask(mService.getMainLooper()); Assert.assertEquals(map.get(device).getState(), BluetoothProfile.STATE_CONNECTING); mService.cleanupDevice(device); Assert.assertNull(mService.getInstanceMap().get(device)); } /** * Test that a PRIORITY_OFF device is not connected to */ @Test @FlakyTest public void testConnectPriorityOffDevice() { // make sure there is no statemachine already defined for this device BluetoothDevice device = makeBluetoothDevice("11:11:11:11:11:11"); Loading Loading
android/app/tests/unit/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachineTest.java +10 −3 Original line number Diff line number Diff line Loading @@ -668,11 +668,18 @@ public class AvrcpControllerStateMachineTest { secondAvrcpStateMachine.start(); Assert.assertFalse(mAvrcpStateMachine.isActive()); // Connect device 1 and 2 and verify first one is set as active // Connect device 1 and 2 and verify second one is set as active setUpConnectedState(true, true); secondAvrcpStateMachine.connect(StackEvent.connectionStateChanged(true, true)); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); Assert.assertTrue(mAvrcpStateMachine.isActive()); Assert.assertFalse(secondAvrcpStateMachine.isActive()); secondAvrcpStateMachine.connect(StackEvent.connectionStateChanged(true, true)); TestUtils.waitForLooperToFinishScheduledTask(mAvrcpStateMachine.getHandler().getLooper()); TestUtils.waitForLooperToFinishScheduledTask(secondAvrcpStateMachine.getHandler() .getLooper()); Assert.assertFalse(mAvrcpStateMachine.isActive()); Assert.assertTrue(secondAvrcpStateMachine.isActive()); // Request the second device to play an item and verify active device switched BrowseTree.BrowseNode results = mAvrcpStateMachine.findNode(rootName); Loading
android/app/tests/unit/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachineTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.Utils; import org.hamcrest.core.AllOf; Loading Loading @@ -96,6 +97,7 @@ public class HeadsetClientStateMachineTest { new HeadsetClientStateMachine(mHeadsetClientService, mHandlerThread.getLooper(), mNativeInterface); mHeadsetClientStateMachine.start(); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); } @After Loading @@ -103,6 +105,7 @@ public class HeadsetClientStateMachineTest { if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_hfpclient)) { return; } TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); mHeadsetClientStateMachine.doQuit(); mHandlerThread.quit(); } Loading Loading @@ -292,10 +295,11 @@ public class HeadsetClientStateMachineTest { -1)); Assert.assertEquals(true, mHeadsetClientStateMachine.getInBandRing()); // Simulate a new incoming phone call StackEvent eventCallStatusUpdated = new StackEvent(StackEvent.EVENT_TYPE_CLIP); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); mHeadsetClientStateMachine.sendMessage(StackEvent.STACK_EVENT, eventCallStatusUpdated); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); verify(mHeadsetClientService, timeout(STANDARD_WAIT_MILLIS).times(3)).sendBroadcast( intentArgument.capture(), anyString()); Loading @@ -319,11 +323,11 @@ public class HeadsetClientStateMachineTest { StackEvent eventCommandStatus = new StackEvent(StackEvent.EVENT_TYPE_CMD_RESULT); eventCommandStatus.valueInt = AT_OK; mHeadsetClientStateMachine.sendMessage(StackEvent.STACK_EVENT, eventCommandStatus); TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); verify(mHeadsetClientService, timeout(QUERY_CURRENT_CALLS_TEST_WAIT_MILLIS).times(4)) .sendBroadcast( intentArgument.capture(), anyString()); // Verify that the new call is being registered with the inBandRing flag set. Assert.assertEquals(true, ((BluetoothHeadsetClientCall) intentArgument.getValue().getParcelableExtra( Loading
android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java +5 −13 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.bluetooth.BluetoothProfile; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.filters.FlakyTest; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -73,7 +72,6 @@ public class MapClientTest { TestUtils.startService(mServiceRule, MapClientService.class); mService = MapClientService.getMapClientService(); Assert.assertNotNull(mService); cleanUpInstanceMap(); mAdapter = BluetoothAdapter.getDefaultAdapter(); when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager); } Loading @@ -89,16 +87,6 @@ public class MapClientTest { TestUtils.clearAdapterService(mAdapterService); } private void cleanUpInstanceMap() { if (!mService.getInstanceMap().isEmpty()) { List<BluetoothDevice> deviceList = mService.getConnectedDevices(); for (BluetoothDevice d : deviceList) { mService.disconnect(d); } } Assert.assertTrue(mService.getInstanceMap().isEmpty()); } /** * Mock the priority of a bluetooth device * Loading Loading @@ -132,13 +120,17 @@ public class MapClientTest { Map<BluetoothDevice, MceStateMachine> map = mService.getInstanceMap(); Assert.assertEquals(1, map.size()); Assert.assertNotNull(map.get(device)); TestUtils.waitForLooperToFinishScheduledTask(mService.getMainLooper()); Assert.assertEquals(map.get(device).getState(), BluetoothProfile.STATE_CONNECTING); mService.cleanupDevice(device); Assert.assertNull(mService.getInstanceMap().get(device)); } /** * Test that a PRIORITY_OFF device is not connected to */ @Test @FlakyTest public void testConnectPriorityOffDevice() { // make sure there is no statemachine already defined for this device BluetoothDevice device = makeBluetoothDevice("11:11:11:11:11:11"); Loading