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

Commit 337a1f04 authored by Iván Budnik's avatar Iván Budnik
Browse files

Add test for IAE on address-less bluetooth routes in InfoMediaManager

This test checks the fix on ag/27873855.

Bug: 347499404
Test: atest InfoMediaManagerTest
Flag: TEST_ONLY
Change-Id: Ib929a8bd66d288d956524f67a941421294cc531b
parent 18357123
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -860,6 +860,23 @@ public class InfoMediaManagerTest {
        assertThat(mInfoMediaManager.mMediaDevices.size()).isEqualTo(0);
    }

    @Test
    public void addMediaDevice_withAddresslessBluetoothDevice_shouldIgnoreDeviceAndNotCrash() {
        MediaRoute2Info bluetoothRoute =
                new MediaRoute2Info.Builder(TEST_BLUETOOTH_ROUTE).setAddress(null).build();

        final CachedBluetoothDeviceManager cachedBluetoothDeviceManager =
                mock(CachedBluetoothDeviceManager.class);
        when(mLocalBluetoothManager.getCachedDeviceManager())
                .thenReturn(cachedBluetoothDeviceManager);
        when(cachedBluetoothDeviceManager.findDevice(any(BluetoothDevice.class))).thenReturn(null);

        mInfoMediaManager.mMediaDevices.clear();
        mInfoMediaManager.addMediaDevice(bluetoothRoute, TEST_SYSTEM_ROUTING_SESSION);

        assertThat(mInfoMediaManager.mMediaDevices.size()).isEqualTo(0);
    }

    @Test
    public void onRoutesUpdated_setsFirstSelectedRouteAsCurrentConnectedDevice() {
        final CachedBluetoothDeviceManager cachedBluetoothDeviceManager =