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

Commit 8647bb0d authored by Kihong Seong's avatar Kihong Seong
Browse files

Fix ScanManager#profileConnectionStateChanged_sendStartConnectionMessage

This fixes the previously flaky test by checking if the function
correctly calls ScanManager#handleConnectingState, which makes
ScanManger.mIsConnecting true.

Bug: 300012915
Test: atest BluetoothInstrumentationTests
Change-Id: I5538cc85d6a15040aca6d8b7254982ed6b18da0b
parent 84daa526
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ public class ScanManager {
    private static final int SCAN_MODE_MAX_IN_CONCURRENCY = ScanSettings.SCAN_MODE_BALANCED;
    private final SparseBooleanArray mIsUidForegroundMap = new SparseBooleanArray();
    private boolean mScreenOn = false;
    private boolean mIsConnecting;
    @VisibleForTesting boolean mIsConnecting;
    private int mProfilesConnecting, mProfilesConnected, mProfilesDisconnecting;

    @VisibleForTesting
+9 −1
Original line number Diff line number Diff line
@@ -1361,10 +1361,18 @@ public class ScanManagerTest {

    @Test
    public void profileConnectionStateChanged_sendStartConnectionMessage() {
        // Set scan downgrade duration through Mock
        when(mAdapterService.getScanDowngradeDurationMillis())
                .thenReturn((long) DELAY_SCAN_DOWNGRADE_DURATION_MS);
        assertThat(mScanManager.mIsConnecting).isFalse();

        mScanManager.handleBluetoothProfileConnectionStateChanged(
                BluetoothProfile.A2DP,
                BluetoothProfile.STATE_DISCONNECTED,
                BluetoothProfile.STATE_CONNECTING);
        assertThat(mHandler.hasMessages(ScanManager.MSG_START_CONNECTING)).isTrue();

        // Wait for handleConnectingState to happen
        TestUtils.waitForLooperToBeIdle(mHandler.getLooper());
        assertThat(mScanManager.mIsConnecting).isTrue();
    }
}