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

Commit 644bee41 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Add a few tests in BluetoothInCallServiceTest" am: b1282ec0...

Merge "Merge "Add a few tests in BluetoothInCallServiceTest" am: b1282ec0 am: e2675b02" into tm-qpr-dev-plus-aosp
parents d48ee69a 15a289b7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1480,7 +1480,9 @@ public class BluetoothInCallService extends InCallService {
        mBluetoothLeCallControl.currentCallsList(tbsCalls);
    }

    private final BluetoothLeCallControl.Callback mBluetoothLeCallControlCallback = new BluetoothLeCallControl.Callback() {
    @VisibleForTesting
    final BluetoothLeCallControl.Callback mBluetoothLeCallControlCallback =
            new BluetoothLeCallControl.Callback() {

        @Override
        public void onAcceptCall(int requestId, UUID callId) {
+60 −0
Original line number Diff line number Diff line
@@ -1354,6 +1354,66 @@ public class BluetoothInCallServiceTest {
        Assert.assertFalse(mBluetoothInCallService.mOnCreateCalled);
    }

    @Test
    public void testLeCallControlCallback_onAcceptCall_withUnknownCallId() {
        BluetoothLeCallControlProxy callControlProxy = mock(BluetoothLeCallControlProxy.class);
        mBluetoothInCallService.mBluetoothLeCallControl = callControlProxy;
        BluetoothLeCallControl.Callback callback =
                mBluetoothInCallService.mBluetoothLeCallControlCallback;

        int requestId = 1;
        UUID unknownCallId = UUID.randomUUID();
        callback.onAcceptCall(requestId, unknownCallId);

        verify(callControlProxy).requestResult(
                requestId, BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID);
    }

    @Test
    public void testLeCallControlCallback_onTerminateCall_withUnknownCallId() {
        BluetoothLeCallControlProxy callControlProxy = mock(BluetoothLeCallControlProxy.class);
        mBluetoothInCallService.mBluetoothLeCallControl = callControlProxy;
        BluetoothLeCallControl.Callback callback =
                mBluetoothInCallService.mBluetoothLeCallControlCallback;

        int requestId = 1;
        UUID unknownCallId = UUID.randomUUID();
        callback.onTerminateCall(requestId, unknownCallId);

        verify(callControlProxy).requestResult(
                requestId, BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID);
    }

    @Test
    public void testLeCallControlCallback_onHoldCall_withUnknownCallId() {
        BluetoothLeCallControlProxy callControlProxy = mock(BluetoothLeCallControlProxy.class);
        mBluetoothInCallService.mBluetoothLeCallControl = callControlProxy;
        BluetoothLeCallControl.Callback callback =
                mBluetoothInCallService.mBluetoothLeCallControlCallback;

        int requestId = 1;
        UUID unknownCallId = UUID.randomUUID();
        callback.onHoldCall(requestId, unknownCallId);

        verify(callControlProxy).requestResult(
                requestId, BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID);
    }

    @Test
    public void testLeCallControlCallback_onUnholdCall_withUnknownCallId() {
        BluetoothLeCallControlProxy callControlProxy = mock(BluetoothLeCallControlProxy.class);
        mBluetoothInCallService.mBluetoothLeCallControl = callControlProxy;
        BluetoothLeCallControl.Callback callback =
                mBluetoothInCallService.mBluetoothLeCallControlCallback;

        int requestId = 1;
        UUID unknownCallId = UUID.randomUUID();
        callback.onUnholdCall(requestId, unknownCallId);

        verify(callControlProxy).requestResult(
                requestId, BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID);
    }

    private void addCallCapability(BluetoothCall call, int capability) {
        when(call.can(capability)).thenReturn(true);
    }