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

Commit a8460f1e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "TbsGatt: test null URI for incoming call" into main

parents 0f346d57 99321739
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -127,8 +127,11 @@ public class TbsCall {
    }

    public String getSafeUri() {
        if (mUri != null) {
            return Uri.parse(mUri).toSafeString();
        }
        return null;
    }

    public int getFlags() {
        return mFlags;
+32 −0
Original line number Diff line number Diff line
@@ -222,6 +222,38 @@ public class TbsGenericTest {
        assertThat(capturedTbsCall.getFriendlyName()).isEqualTo("aFriendlyCaller");
    }

    @Test
    public void testCallAddedWithNullUri() {
        Integer ccid = prepareTestBearer();
        reset(mTbsGatt);

        BluetoothLeCall tbsCall =
                new BluetoothLeCall(
                        UUID.randomUUID(),
                        null,
                        "aFriendlyCaller",
                        BluetoothLeCall.STATE_INCOMING,
                        0);
        mTbsGeneric.callAdded(ccid, tbsCall);

        ArgumentCaptor<Integer> callIndexCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mTbsGatt).setIncomingCall(callIndexCaptor.capture(), eq(null));
        Integer capturedCallIndex = callIndexCaptor.getValue();
        verify(mTbsGatt).setCallFriendlyName(eq(capturedCallIndex), eq("aFriendlyCaller"));
        ArgumentCaptor<Map> currentCallsCaptor = ArgumentCaptor.forClass(Map.class);
        verify(mTbsGatt).setCallState(currentCallsCaptor.capture());
        Map<Integer, TbsCall> capturedCurrentCalls = currentCallsCaptor.getValue();
        assertThat(capturedCurrentCalls.size()).isEqualTo(1);
        TbsCall capturedTbsCall = capturedCurrentCalls.get(capturedCallIndex);
        assertThat(capturedTbsCall).isNotNull();
        assertThat(capturedTbsCall.getState()).isEqualTo(BluetoothLeCall.STATE_INCOMING);
        assertThat(capturedTbsCall.getUri()).isEqualTo(null);
        assertThat(capturedTbsCall.getSafeUri()).isEqualTo(null);
        assertThat(capturedTbsCall.getFlags()).isEqualTo(0);
        assertThat(capturedTbsCall.isIncoming()).isTrue();
        assertThat(capturedTbsCall.getFriendlyName()).isEqualTo("aFriendlyCaller");
    }

    @Test
    public void testCallRemoved() {
        Integer ccid = prepareTestBearer();