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

Commit 6f366387 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Ensures handling messages

Unhandled message could affect following tests

Bug: 347561340
Test: atest PanServiceTest
Flag: EXEMPT, test only change
Change-Id: I1c20b4c26c84de247adfe5c9757e7ce491c7b383
parent d8fb1d14
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -21,7 +21,10 @@ import static android.net.TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL;


import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAdapter;
@@ -55,6 +58,8 @@ public class PanServiceTest {
    private static final String REMOTE_DEVICE_ADDRESS = "00:00:00:00:00:00";
    private static final String REMOTE_DEVICE_ADDRESS = "00:00:00:00:00:00";
    private static final byte[] REMOTE_DEVICE_ADDRESS_AS_ARRAY = new byte[] {0, 0, 0, 0, 0, 0};
    private static final byte[] REMOTE_DEVICE_ADDRESS_AS_ARRAY = new byte[] {0, 0, 0, 0, 0, 0};


    private static final int TIMEOUT_MS = 5_000;

    private PanService mService = null;
    private PanService mService = null;
    private BluetoothAdapter mAdapter = null;
    private BluetoothAdapter mAdapter = null;
    private BluetoothDevice mRemoteDevice;
    private BluetoothDevice mRemoteDevice;
@@ -124,11 +129,13 @@ public class PanServiceTest {
                        BluetoothProfile.STATE_DISCONNECTED, PAN_ROLE_NONE, PAN_ROLE_NONE));
                        BluetoothProfile.STATE_DISCONNECTED, PAN_ROLE_NONE, PAN_ROLE_NONE));


        assertThat(mService.connect(mRemoteDevice)).isTrue();
        assertThat(mService.connect(mRemoteDevice)).isTrue();
        verify(mNativeInterface, timeout(TIMEOUT_MS)).connect(any());
    }
    }


    @Test
    @Test
    public void disconnect_returnsTrue() {
    public void disconnect_returnsTrue() {
        assertThat(mService.disconnect(mRemoteDevice)).isTrue();
        assertThat(mService.disconnect(mRemoteDevice)).isTrue();
        verify(mNativeInterface, timeout(TIMEOUT_MS)).disconnect(any());
    }
    }


    @Test
    @Test
@@ -192,6 +199,7 @@ public class PanServiceTest {
                        mService.setConnectionPolicy(
                        mService.setConnectionPolicy(
                                mRemoteDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED))
                                mRemoteDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED))
                .isTrue();
                .isTrue();
        verify(mNativeInterface, timeout(TIMEOUT_MS)).connect(any());


        when(mDatabaseManager.setProfileConnectionPolicy(
        when(mDatabaseManager.setProfileConnectionPolicy(
                        mRemoteDevice,
                        mRemoteDevice,
@@ -202,6 +210,7 @@ public class PanServiceTest {
                        mService.setConnectionPolicy(
                        mService.setConnectionPolicy(
                                mRemoteDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN))
                                mRemoteDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN))
                .isTrue();
                .isTrue();
        verify(mNativeInterface, timeout(TIMEOUT_MS)).disconnect(any());
    }
    }


    @Test
    @Test