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

Commit 572462b4 authored by AI test gen's avatar AI test gen Committed by Ang Li
Browse files

Add test for ACL state change on sub-device

Adds a unit test to verify that ACL connection state changes for sub-devices are correctly handled and dispatched. This covers the behavior modified by the removal of the sub-device check in `AclStateChangedHandler`.

Please help fill out the survey for feedback: https://forms.gle/Qz9q5boo4h4tESyd7
Original Change: ag/35256714
Test: passed ABTD tests http://go/forrest-run/L13000030017280691
Bug: 431235865
Flag: TEST_ONLY

Change-Id: Ia44f41e21654ba425243cb79abc8c46338df6c8a
parent da5e98d6
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);