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

Commit 92b4d1e2 authored by William Escande's avatar William Escande
Browse files

waitForNoIntent: don't return null

Bug: 311772251
Test: atest BluetoothInstrumentationTests
Flag: TEST_ONLY
Change-Id: I821dee17f540179be4861fe4800204ecbc7d0ef1
parent 90cef83f
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -186,17 +186,14 @@ public class TestUtils {
     *
     * @param timeoutMs the time (in milliseconds) to wait and verify no intent has been received
     * @param queue the queue for the intent
     * @return the received intent. Should be null under normal circumstances
     */
    public static Intent waitForNoIntent(int timeoutMs, BlockingQueue<Intent> queue) {
    public static void waitForNoIntent(int timeoutMs, BlockingQueue<Intent> queue) {
        try {
            Intent intent = queue.poll(timeoutMs, TimeUnit.MILLISECONDS);
            Assert.assertNull(intent);
            return intent;
        } catch (InterruptedException e) {
            Assert.fail("Cannot obtain an Intent from the queue: " + e.getMessage());
        }
        return null;
    }

    /**
+7 −12
Original line number Diff line number Diff line
@@ -607,8 +607,7 @@ public class LeAudioServiceTest {
        if (expectedIntent) {
            verifyActiveDeviceStateIntent(AUDIO_MANAGER_DEVICE_ADD_TIMEOUT_MS, device);
        } else {
            Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(device));
            assertThat(intent).isNull();
            TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(device));
        }
    }

@@ -622,8 +621,7 @@ public class LeAudioServiceTest {
        if (expectedIntent) {
            verifyActiveDeviceStateIntent(AUDIO_MANAGER_DEVICE_ADD_TIMEOUT_MS, null);
        } else {
            Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(device));
            assertThat(intent).isNull();
            TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(device));
        }
    }

@@ -1073,8 +1071,7 @@ public class LeAudioServiceTest {
    }

    private void verifyNoConnectionStateIntent(int timeoutMs, BluetoothDevice device) {
        Intent intent = TestUtils.waitForNoIntent(timeoutMs, mDeviceQueueMap.get(device));
        assertThat(intent).isNull();
        TestUtils.waitForNoIntent(timeoutMs, mDeviceQueueMap.get(device));
    }

    /** Test setting connection policy */
@@ -1936,12 +1933,12 @@ public class LeAudioServiceTest {
                3);
        injectGroupStatusChange(testGroupId, BluetoothLeAudio.GROUP_STATUS_ACTIVE);

        /* Expect 2 calles to Audio Manager - one for output and second for input as this is
        /* Expect 2 calls to Audio Manager - one for output and second for input as this is
         * Conversational use case */
        verify(mAudioManager, times(2))
                .handleBluetoothActiveDeviceChanged(
                        any(), any(), any(BluetoothProfileConnectionInfo.class));
        /* Since LeAudioService called AudioManager - assume Audio manager calles properly callback
        /* Since LeAudioService called AudioManager - assume Audio manager calls properly callback
         * mAudioManager.onAudioDeviceAdded
         */
        injectAudioDeviceAdded(mSingleDevice, AudioDeviceInfo.TYPE_BLE_HEADSET, true, false, true);
@@ -1957,8 +1954,7 @@ public class LeAudioServiceTest {
                BluetoothLeAudio.CONTEXT_TYPE_MEDIA | BluetoothLeAudio.CONTEXT_TYPE_CONVERSATIONAL;
        injectAudioConfChanged(testGroupId, contexts, 3);

        Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice));
        assertThat(intent).isNull();
        TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice));
    }

    /** Test native interface audio configuration changed message handling */
@@ -1968,8 +1964,7 @@ public class LeAudioServiceTest {
        connectTestDevice(mSingleDevice, testGroupId);

        injectAudioConfChanged(testGroupId, 0, 3);
        Intent intent = TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice));
        assertThat(intent).isNull();
        TestUtils.waitForNoIntent(TIMEOUT_MS, mDeviceQueueMap.get(mSingleDevice));
    }

    /**