Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a108056c authored by weichinweng's avatar weichinweng
Browse files

Fix BluetoothInstrumentationTests tearDown flakiness.

Bug: 182940721
Test: atest BluetoothInstrumentationTests
Tag: #compatibility
Change-Id: I6051e11a7657b18c9d252b73b2ccaf229746cf15
parent 0be05d61
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class A2dpServiceTest {

        TestUtils.setAdapterService(mAdapterService);
        doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices();
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        doReturn(false).when(mAdapterService).isQuietModeEnabled();
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();

@@ -126,7 +126,6 @@ public class A2dpServiceTest {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp)) {
            return;
        }
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        stopService();
        mTargetContext.unregisterReceiver(mA2dpIntentReceiver);
        mConnectionStateChangedQueue.clear();
+1 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class A2dpSinkServiceTest {
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        setMaxConnectedAudioDevices(1);
        TestUtils.startService(mServiceRule, A2dpSinkService.class);
        mService = A2dpSinkService.getA2dpSinkService();
@@ -77,7 +77,6 @@ public class A2dpSinkServiceTest {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_a2dp_sink)) {
            return;
        }
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        TestUtils.stopService(mServiceRule, A2dpSinkService.class);
        mService = A2dpSinkService.getA2dpSinkService();
        Assert.assertNull(mService);
+1 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class AvrcpControllerServiceTest {
                        .getBoolean(R.bool.profile_supported_avrcp_controller));
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        TestUtils.startService(mServiceRule, AvrcpControllerService.class);
        mService = AvrcpControllerService.getAvrcpControllerService();
        Assert.assertNotNull(mService);
@@ -73,7 +73,6 @@ public class AvrcpControllerServiceTest {
        if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_avrcp_controller)) {
            return;
        }
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        TestUtils.stopService(mServiceRule, AvrcpControllerService.class);
        mService = AvrcpControllerService.getAvrcpControllerService();
        Assert.assertNull(mService);
+1 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class HearingAidServiceTest {

        TestUtils.setAdapterService(mAdapterService);
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());

        mAdapter = BluetoothAdapter.getDefaultAdapter();

@@ -129,7 +129,6 @@ public class HearingAidServiceTest {
                            R.bool.config_hearing_aid_profile_supported)) {
            return;
        }
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        stopService();
        mTargetContext.unregisterReceiver(mHearingAidIntentReceiver);
        mDeviceQueueMap.clear();
+1 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ public class HeadsetServiceAndStateMachineTest {
        doReturn(new ParcelUuid[]{BluetoothUuid.HFP}).when(mAdapterService)
                .getRemoteUuids(any(BluetoothDevice.class));
        doReturn(mDatabaseManager).when(mAdapterService).getDatabase();
        doReturn(true).when(mAdapterService).isStartedProfile(anyString());
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        // We cannot mock HeadsetObjectsFactory.getInstance() with Mockito.
        // Hence we need to use reflection to call a private method to
        // initialize properly the HeadsetObjectsFactory.sInstance field.
@@ -241,7 +241,6 @@ public class HeadsetServiceAndStateMachineTest {
            return;
        }
        mTargetContext.unregisterReceiver(mHeadsetIntentReceiver);
        doReturn(false).when(mAdapterService).isStartedProfile(anyString());
        TestUtils.stopService(mServiceRule, HeadsetService.class);
        HeadsetService.sStartVrTimeoutMs = mOriginalVrTimeoutMs;
        Intents.release();
Loading