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

Commit b1282ec0 authored by Hyundo Moon's avatar Hyundo Moon Committed by Gerrit Code Review
Browse files

Merge "Add a few tests in BluetoothInCallServiceTest"

parents 9a848614 36fdfa88
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);
    }