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

Commit 2b1decbe authored by Ang Li's avatar Ang Li Committed by Android (Google) Code Review
Browse files

Merge "Add test for ACL state change on sub-device" into main

parents b1bd87b5 572462b4
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -340,6 +340,24 @@ public class BluetoothEventManagerTest {
                BluetoothAdapter.STATE_CONNECTED);
    }

    @Test
    public void dispatchAclConnectionStateChanged_forSubDevice_shouldDispatchCallback() {
        // This test verifies that ACL state changes for sub-devices are handled.
        // A previous implementation skipped this, but the check was removed.
        when(mCachedDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        Intent intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

        mContext.sendBroadcast(intent);

        // Verify that the callback is dispatched and the device state is updated.
        verify(mCachedBluetoothDevice).onAclStateChanged(eq(BluetoothAdapter.STATE_CONNECTED),
                anyInt());
        verify(mBluetoothCallback).onAclConnectionStateChanged(mCachedBluetoothDevice,
                BluetoothAdapter.STATE_CONNECTED);
    }

    @Test
    public void dispatchAclConnectionStateChanged_aclBeforeDeviceCreation_shouldDispatchCallback() {
        when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(null);