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

Commit 96bfa895 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "GattClientTest: User wrapper in all test" into main

parents 1ecb9965 c5e46b3f
Loading
Loading
Loading
Loading
+5 −21
Original line number Diff line number Diff line
@@ -100,25 +100,9 @@ public class GattClientTest {

    @Test
    public void fullGattClientLifecycle() throws Exception {
        advertiseWithBumble();

        BluetoothDevice device =
                mAdapter.getRemoteLeDevice(
                        Utils.BUMBLE_RANDOM_ADDRESS, BluetoothDevice.ADDRESS_TYPE_RANDOM);

        for (int i = 0; i < 10; i++) {
        BluetoothGattCallback gattCallback = mock(BluetoothGattCallback.class);
            BluetoothGatt gatt = device.connectGatt(mContext, false, gattCallback);
            verify(gattCallback, timeout(1000))
                    .onConnectionStateChange(any(), anyInt(), eq(BluetoothProfile.STATE_CONNECTED));

            gatt.disconnect();
            verify(gattCallback, timeout(1000))
                    .onConnectionStateChange(
                            any(), anyInt(), eq(BluetoothProfile.STATE_DISCONNECTED));

            gatt.close();
        }
        BluetoothGatt gatt = connectGattAndWaitConnection(gattCallback);
        disconnectAndWaitDisconnection(gatt, gattCallback);
    }

    @Test
@@ -179,9 +163,9 @@ public class GattClientTest {

    private void disconnectAndWaitDisconnection(
            BluetoothGatt gatt, BluetoothGattCallback callback) {
        final int state = BluetoothProfile.STATE_DISCONNECTED;
        gatt.disconnect();
        verify(callback, timeout(1000))
                .onConnectionStateChange(any(), anyInt(), eq(BluetoothProfile.STATE_DISCONNECTED));
        verify(callback, timeout(1000)).onConnectionStateChange(eq(gatt), anyInt(), eq(state));

        gatt.close();
        gatt = null;