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

Commit 45890f36 authored by Hyundo Moon's avatar Hyundo Moon
Browse files

PbapClientStateMachineTest: Increase disconnection timeout

Also merges two test methods into one.

Bug: 283643682
Test: atest PbapClientStateMachineTest
Change-Id: Ief5515183171ed67dfc9d6744f968599f975742e
parent d64126cb
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class PbapClientStateMachineTest{
    private ArgumentCaptor<Intent> mIntentArgument = ArgumentCaptor.forClass(Intent.class);


    static final int DISCONNECT_TIMEOUT = 3100;
    static final int DISCONNECT_TIMEOUT = 5000;

    @Before
    public void setUp() throws Exception {
@@ -114,10 +114,11 @@ public class PbapClientStateMachineTest{
    }

    /**
     * Test transition from STATE_CONNECTING to STATE_DISCONNECTING with MSG_DISCONNECT
     * Test transition from STATE_CONNECTING to STATE_DISCONNECTING
     * and then to STATE_DISCONNECTED after timeout.
     */
    @Test
    public void testStateTransitionFromConnectingToDisconnecting() {
    public void testStateTransitionFromConnectingToDisconnected() {
        assertThat(mPbapClientStateMachine.getConnectionState())
                .isEqualTo(BluetoothProfile.STATE_CONNECTING);

@@ -127,19 +128,11 @@ public class PbapClientStateMachineTest{
                .getLooper());
        assertThat(mPbapClientStateMachine.getConnectionState())
                .isEqualTo(BluetoothProfile.STATE_DISCONNECTING);
    }

    /**
     * Test transition from STATE_DISCONNECTING to STATE_DISCONNECTED with MSG_DISCONNECT_TIMEOUT
     */
    @Test
    public void testStateTransitionFromDisconnectingToDisconnected_Timeout() {
        testStateTransitionFromConnectingToDisconnecting();

        //wait until timeout occurs
        verify(mMockPbapClientService,
                timeout(DISCONNECT_TIMEOUT).times(3)).sendBroadcastMultiplePermissions(
                mIntentArgument.capture(), any(String[].class),
        Mockito.clearInvocations(mMockPbapClientService);
        verify(mMockPbapClientService, timeout(DISCONNECT_TIMEOUT))
                .sendBroadcastMultiplePermissions(mIntentArgument.capture(), any(String[].class),
                        any(BroadcastOptions.class));
        assertThat(mPbapClientStateMachine.getConnectionState())
                .isEqualTo(BluetoothProfile.STATE_DISCONNECTED);