Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +14 −11 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.ParcelUuid; import android.os.PowerManager; import android.os.RemoteException; import android.telecom.PhoneAccount; import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.espresso.intent.Intents; Loading Loading @@ -82,9 +83,11 @@ import java.util.concurrent.LinkedBlockingQueue; @MediumTest @RunWith(AndroidJUnit4.class) public class HeadsetServiceAndStateMachineTest { private static final String TAG = "HeadsetServiceAndStateMachineTest"; private static final int ASYNC_CALL_TIMEOUT_MILLIS = 250; private static final int START_VR_TIMEOUT_MILLIS = 1000; private static final int START_VR_TIMEOUT_WAIT_MILLIS = START_VR_TIMEOUT_MILLIS * 3 / 2; private static final int STATE_CHANGE_TIMEOUT_MILLIS = 1000; private static final int MAX_HEADSET_CONNECTIONS = 5; private static final ParcelUuid[] FAKE_HEADSET_UUID = {BluetoothUuid.HFP}; private static final String TEST_PHONE_NUMBER = "1234567890"; Loading Loading @@ -470,7 +473,7 @@ public class HeadsetServiceAndStateMachineTest { BluetoothDevice activeDevice = connectedDevices.get(MAX_HEADSET_CONNECTIONS / 2); Assert.assertTrue(mHeadsetService.setActiveDevice(activeDevice)); verify(mNativeInterface).setActiveDevice(activeDevice); waitAndVerifyActiveDeviceChangedIntent(ASYNC_CALL_TIMEOUT_MILLIS, activeDevice); verify(mActiveDeviceManager).hfpActiveStateChanged(activeDevice); Assert.assertEquals(activeDevice, mHeadsetService.getActiveDevice()); // Start virtual call Assert.assertTrue(mHeadsetService.startScoUsingVirtualVoiceCall()); Loading Loading @@ -1176,11 +1179,11 @@ public class HeadsetServiceAndStateMachineTest { verify(mObjectsFactory).makeStateMachine(device, mHeadsetService.getStateMachinesThreadLooper(), mHeadsetService, mAdapterService, mNativeInterface, mSystemInterface); // Wait ASYNC_CALL_TIMEOUT_MILLIS for state to settle, timing is also tested here and // 250ms for processing two messages should be way more than enough. Anything that breaks // this indicate some breakage in other part of Android OS waitAndVerifyConnectionStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_DISCONNECTED); verify(mActiveDeviceManager, timeout(STATE_CHANGE_TIMEOUT_MILLIS)) .hfpConnectionStateChanged( device, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_CONNECTING); Assert.assertEquals(BluetoothProfile.STATE_CONNECTING, mHeadsetService.getConnectionState(device)); Assert.assertEquals(Collections.singletonList(device), Loading @@ -1191,11 +1194,11 @@ public class HeadsetServiceAndStateMachineTest { new HeadsetStackEvent(HeadsetStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED, HeadsetHalConstants.CONNECTION_STATE_SLC_CONNECTED, device); mHeadsetService.messageFromNative(slcConnectedEvent); // Wait ASYNC_CALL_TIMEOUT_MILLIS for state to settle, timing is also tested here and // 250ms for processing two messages should be way more than enough. Anything that breaks // this indicate some breakage in other part of Android OS waitAndVerifyConnectionStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_CONNECTING); verify(mActiveDeviceManager, timeout(STATE_CHANGE_TIMEOUT_MILLIS)) .hfpConnectionStateChanged( device, BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED); Assert.assertEquals(BluetoothProfile.STATE_CONNECTED, mHeadsetService.getConnectionState(device)); } Loading Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +14 −11 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.ParcelUuid; import android.os.PowerManager; import android.os.RemoteException; import android.telecom.PhoneAccount; import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.espresso.intent.Intents; Loading Loading @@ -82,9 +83,11 @@ import java.util.concurrent.LinkedBlockingQueue; @MediumTest @RunWith(AndroidJUnit4.class) public class HeadsetServiceAndStateMachineTest { private static final String TAG = "HeadsetServiceAndStateMachineTest"; private static final int ASYNC_CALL_TIMEOUT_MILLIS = 250; private static final int START_VR_TIMEOUT_MILLIS = 1000; private static final int START_VR_TIMEOUT_WAIT_MILLIS = START_VR_TIMEOUT_MILLIS * 3 / 2; private static final int STATE_CHANGE_TIMEOUT_MILLIS = 1000; private static final int MAX_HEADSET_CONNECTIONS = 5; private static final ParcelUuid[] FAKE_HEADSET_UUID = {BluetoothUuid.HFP}; private static final String TEST_PHONE_NUMBER = "1234567890"; Loading Loading @@ -470,7 +473,7 @@ public class HeadsetServiceAndStateMachineTest { BluetoothDevice activeDevice = connectedDevices.get(MAX_HEADSET_CONNECTIONS / 2); Assert.assertTrue(mHeadsetService.setActiveDevice(activeDevice)); verify(mNativeInterface).setActiveDevice(activeDevice); waitAndVerifyActiveDeviceChangedIntent(ASYNC_CALL_TIMEOUT_MILLIS, activeDevice); verify(mActiveDeviceManager).hfpActiveStateChanged(activeDevice); Assert.assertEquals(activeDevice, mHeadsetService.getActiveDevice()); // Start virtual call Assert.assertTrue(mHeadsetService.startScoUsingVirtualVoiceCall()); Loading Loading @@ -1176,11 +1179,11 @@ public class HeadsetServiceAndStateMachineTest { verify(mObjectsFactory).makeStateMachine(device, mHeadsetService.getStateMachinesThreadLooper(), mHeadsetService, mAdapterService, mNativeInterface, mSystemInterface); // Wait ASYNC_CALL_TIMEOUT_MILLIS for state to settle, timing is also tested here and // 250ms for processing two messages should be way more than enough. Anything that breaks // this indicate some breakage in other part of Android OS waitAndVerifyConnectionStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_DISCONNECTED); verify(mActiveDeviceManager, timeout(STATE_CHANGE_TIMEOUT_MILLIS)) .hfpConnectionStateChanged( device, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_CONNECTING); Assert.assertEquals(BluetoothProfile.STATE_CONNECTING, mHeadsetService.getConnectionState(device)); Assert.assertEquals(Collections.singletonList(device), Loading @@ -1191,11 +1194,11 @@ public class HeadsetServiceAndStateMachineTest { new HeadsetStackEvent(HeadsetStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED, HeadsetHalConstants.CONNECTION_STATE_SLC_CONNECTED, device); mHeadsetService.messageFromNative(slcConnectedEvent); // Wait ASYNC_CALL_TIMEOUT_MILLIS for state to settle, timing is also tested here and // 250ms for processing two messages should be way more than enough. Anything that breaks // this indicate some breakage in other part of Android OS waitAndVerifyConnectionStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_CONNECTING); verify(mActiveDeviceManager, timeout(STATE_CHANGE_TIMEOUT_MILLIS)) .hfpConnectionStateChanged( device, BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED); Assert.assertEquals(BluetoothProfile.STATE_CONNECTED, mHeadsetService.getConnectionState(device)); } Loading