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

Commit 8b660256 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9342863 from 7168e5f1 to tm-qpr2-release

Change-Id: I7e9b5cf1b68576de61722667d1875a630d7dfcba
parents ce586982 7168e5f1
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -146,7 +146,8 @@ public class HeadsetStateMachine extends StateMachine {
    private boolean mHasNrecEnabled = false;
    private boolean mHasWbsEnabled = false;
    // AT Phone book keeps a group of states used by AT+CPBR commands
    private final AtPhonebook mPhonebook;
    @VisibleForTesting
    final AtPhonebook mPhonebook;
    // HSP specific
    private boolean mNeedDialingOutReply;
    // Audio disconnect timeout retry count
@@ -1516,7 +1517,8 @@ public class HeadsetStateMachine extends StateMachine {
    /*
     * Put the AT command, company ID, arguments, and device in an Intent and broadcast it.
     */
    private void broadcastVendorSpecificEventIntent(String command, int companyId, int commandType,
    @VisibleForTesting
    void broadcastVendorSpecificEventIntent(String command, int companyId, int commandType,
            Object[] arguments, BluetoothDevice device) {
        log("broadcastVendorSpecificEventIntent(" + command + ")");
        Intent intent = new Intent(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT);
@@ -1540,7 +1542,8 @@ public class HeadsetStateMachine extends StateMachine {
        am.setBluetoothHeadsetProperties(getCurrentDeviceName(), mHasNrecEnabled, mHasWbsEnabled);
    }

    private String parseUnknownAt(String atString) {
    @VisibleForTesting
    String parseUnknownAt(String atString) {
        StringBuilder atCommand = new StringBuilder(atString.length());

        for (int i = 0; i < atString.length(); i++) {
@@ -1561,7 +1564,8 @@ public class HeadsetStateMachine extends StateMachine {
        return atCommand.toString();
    }

    private int getAtCommandType(String atCommand) {
    @VisibleForTesting
    int getAtCommandType(String atCommand) {
        int commandType = AtPhonebook.TYPE_UNKNOWN;
        String atString = null;
        atCommand = atCommand.trim();
@@ -1691,7 +1695,8 @@ public class HeadsetStateMachine extends StateMachine {
    }

    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    private void processAtChld(int chld, BluetoothDevice device) {
    @VisibleForTesting
    void processAtChld(int chld, BluetoothDevice device) {
        if (mSystemInterface.processChld(chld)) {
            mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0);
        } else {
@@ -1756,7 +1761,8 @@ public class HeadsetStateMachine extends StateMachine {
    }

    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    private void processAtClcc(BluetoothDevice device) {
    @VisibleForTesting
    void processAtClcc(BluetoothDevice device) {
        if (mHeadsetService.isVirtualCallStarted()) {
            // In virtual call, send our phone number instead of remote phone number
            String phoneNumber = mSystemInterface.getSubscriberNumber();
@@ -1811,7 +1817,8 @@ public class HeadsetStateMachine extends StateMachine {
     * Find a character ch, ignoring quoted sections.
     * Return input.length() if not found.
     */
    private static int findChar(char ch, String input, int fromIndex) {
    @VisibleForTesting
    static int findChar(char ch, String input, int fromIndex) {
        for (int i = fromIndex; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c == '"') {
@@ -1831,7 +1838,8 @@ public class HeadsetStateMachine extends StateMachine {
     * Integer arguments are turned into Integer objects. Otherwise a String
     * object is used.
     */
    private static Object[] generateArgs(String input) {
    @VisibleForTesting
    static Object[] generateArgs(String input) {
        int i = 0;
        int j;
        ArrayList<Object> out = new ArrayList<Object>();
@@ -2028,7 +2036,8 @@ public class HeadsetStateMachine extends StateMachine {
        }
    }

    private void processAtBiev(int indId, int indValue, BluetoothDevice device) {
    @VisibleForTesting
    void processAtBiev(int indId, int indValue, BluetoothDevice device) {
        log("processAtBiev: ind_id=" + indId + ", ind_value=" + indValue);
        sendIndicatorIntent(device, indId, indValue);
    }
@@ -2105,7 +2114,8 @@ public class HeadsetStateMachine extends StateMachine {
        return builder.toString();
    }

    private void handleAccessPermissionResult(Intent intent) {
    @VisibleForTesting
    void handleAccessPermissionResult(Intent intent) {
        log("handleAccessPermissionResult");
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        if (!mPhonebook.getCheckingAccessPermission()) {
+21 −7
Original line number Diff line number Diff line
@@ -103,11 +103,17 @@ public class BluetoothInCallService extends InCallService {
    private BluetoothCall mOldHeldCall = null;
    private boolean mHeadsetUpdatedRecently = false;
    private boolean mIsDisconnectedTonePlaying = false;
    private boolean mIsTerminatedByClient = false;

    @VisibleForTesting
    boolean mIsTerminatedByClient = false;

    private static final Object LOCK = new Object();
    private BluetoothHeadsetProxy mBluetoothHeadset;
    private BluetoothLeCallControlProxy mBluetoothLeCallControl;

    @VisibleForTesting
    BluetoothHeadsetProxy mBluetoothHeadset;

    @VisibleForTesting
    BluetoothLeCallControlProxy mBluetoothLeCallControl;
    private ExecutorService mExecutor;

    @VisibleForTesting
@@ -640,8 +646,8 @@ public class BluetoothInCallService extends InCallService {
        super.onCreate();
        BluetoothAdapter.getDefaultAdapter()
                .getProfileProxy(this, mProfileListener, BluetoothProfile.HEADSET);
        BluetoothAdapter.getDefaultAdapter().
                getProfileProxy(this, mProfileListener, BluetoothProfile.LE_CALL_CONTROL);
        BluetoothAdapter.getDefaultAdapter()
                .getProfileProxy(this, mProfileListener, BluetoothProfile.LE_CALL_CONTROL);
        mBluetoothAdapterReceiver = new BluetoothAdapterReceiver();
        IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(mBluetoothAdapterReceiver, intentFilter);
@@ -656,7 +662,14 @@ public class BluetoothInCallService extends InCallService {
        super.onDestroy();
    }

    private void clear() {
    @Override
    @VisibleForTesting
    public void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @VisibleForTesting
    void clear() {
        Log.d(TAG, "clear");
        if (mBluetoothAdapterReceiver != null) {
            unregisterReceiver(mBluetoothAdapterReceiver);
@@ -1339,7 +1352,8 @@ public class BluetoothInCallService extends InCallService {
        return null;
    }

    private int getTbsTerminationReason(BluetoothCall call) {
    @VisibleForTesting
    int getTbsTerminationReason(BluetoothCall call) {
        DisconnectCause cause = call.getDisconnectCause();
        if (cause == null) {
            Log.w(TAG, " termination cause is null");
+152 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;

/**
 * Tests for {@link HeadsetStateMachine}
 */
@@ -84,6 +86,7 @@ public class HeadsetStateMachineTest {
    @Mock private HeadsetSystemInterface mSystemInterface;
    @Mock private AudioManager mAudioManager;
    @Mock private HeadsetPhoneState mPhoneState;
    @Mock private Intent mIntent;
    private MockContentResolver mMockContentResolver;
    private HeadsetNativeInterface mNativeInterface;

@@ -1095,6 +1098,155 @@ public class HeadsetStateMachineTest {
                PhoneStateListener.LISTEN_NONE);
    }

    @Test
    public void testBroadcastVendorSpecificEventIntent() {
        mHeadsetStateMachine.broadcastVendorSpecificEventIntent(
                "command", 1, 1, null, mTestDevice);
        verify(mHeadsetService, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).sendBroadcastAsUser(
                mIntentArgument.capture(), eq(UserHandle.ALL), eq(BLUETOOTH_CONNECT),
                any(Bundle.class));
    }

    @Test
    public void testFindChar_withCharFound() {
        char ch = 's';
        String input = "test";
        int fromIndex = 0;

        Assert.assertEquals(HeadsetStateMachine.findChar(ch, input, fromIndex), 2);
    }

    @Test
    public void testFindChar_withCharNotFound() {
        char ch = 'x';
        String input = "test";
        int fromIndex = 0;

        Assert.assertEquals(HeadsetStateMachine.findChar(ch, input, fromIndex), input.length());
    }

    @Test
    public void testFindChar_withQuotes() {
        char ch = 's';
        String input = "te\"st";
        int fromIndex = 0;

        Assert.assertEquals(HeadsetStateMachine.findChar(ch, input, fromIndex), input.length());
    }

    @Test
    public void testGenerateArgs() {
        String input = "11,notint";
        ArrayList<Object> expected = new ArrayList<Object>();
        expected.add(11);
        expected.add("notint");

        Assert.assertEquals(HeadsetStateMachine.generateArgs(input), expected.toArray());
    }

    @Test
    public void testGetAtCommandType() {
        String atCommand = "start?";
        Assert.assertEquals(mHeadsetStateMachine.getAtCommandType(atCommand),
                AtPhonebook.TYPE_READ);

        atCommand = "start=?";
        Assert.assertEquals(mHeadsetStateMachine.getAtCommandType(atCommand),
                AtPhonebook.TYPE_TEST);

        atCommand = "start=comm";
        Assert.assertEquals(mHeadsetStateMachine.getAtCommandType(atCommand), AtPhonebook.TYPE_SET);

        atCommand = "start!";
        Assert.assertEquals(mHeadsetStateMachine.getAtCommandType(atCommand),
                AtPhonebook.TYPE_UNKNOWN);
    }

    @Test
    public void testParseUnknownAt() {
        String atString = "\"command\"";

        Assert.assertEquals(mHeadsetStateMachine.parseUnknownAt(atString), "\"command\"");
    }

    @Test
    public void testParseUnknownAt_withUnmatchingQuotes() {
        String atString = "\"command";

        Assert.assertEquals(mHeadsetStateMachine.parseUnknownAt(atString), "\"command\"");
    }

    @Test
    public void testParseUnknownAt_withCharOutsideQuotes() {
        String atString = "a\"command\"";

        Assert.assertEquals(mHeadsetStateMachine.parseUnknownAt(atString), "A\"command\"");
    }

    @Test
    public void testHandleAccessPermissionResult_withNoChangeInAtCommandResult() {
        when(mIntent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)).thenReturn(null);
        when(mIntent.getAction()).thenReturn(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
        when(mIntent.getIntExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
                BluetoothDevice.CONNECTION_ACCESS_NO))
                .thenReturn(BluetoothDevice.CONNECTION_ACCESS_NO);
        when(mIntent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)).thenReturn(true);
        mHeadsetStateMachine.mPhonebook.setCheckingAccessPermission(true);

        mHeadsetStateMachine.handleAccessPermissionResult(mIntent);

        verify(mNativeInterface).atResponseCode(null, 0, 0);
    }

    @Test
    public void testProcessAtBievCommand() {
        mHeadsetStateMachine.processAtBiev(1, 1, mTestDevice);

        verify(mHeadsetService, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).sendBroadcast(
                mIntentArgument.capture(), eq(BLUETOOTH_CONNECT), any(Bundle.class));
    }

    @Test
    public void testProcessAtChld_withProcessChldTrue() {
        int chld = 1;
        when(mSystemInterface.processChld(chld)).thenReturn(true);

        mHeadsetStateMachine.processAtChld(chld, mTestDevice);

        verify(mNativeInterface).atResponseCode(mTestDevice, HeadsetHalConstants.AT_RESPONSE_OK, 0);
    }

    @Test
    public void testProcessAtChld_withProcessChldFalse() {
        int chld = 1;
        when(mSystemInterface.processChld(chld)).thenReturn(false);

        mHeadsetStateMachine.processAtChld(chld, mTestDevice);

        verify(mNativeInterface).atResponseCode(mTestDevice, HeadsetHalConstants.AT_RESPONSE_ERROR,
                0);
    }

    @Test
    public void testProcessAtClcc_withVirtualCallStarted() {
        when(mHeadsetService.isVirtualCallStarted()).thenReturn(true);
        when(mSystemInterface.getSubscriberNumber()).thenReturn(null);

        mHeadsetStateMachine.processAtClcc(mTestDevice);

        verify(mNativeInterface).clccResponse(mTestDevice, 0, 0, 0, 0, false, "", 0);
    }

    @Test
    public void testProcessAtClcc_withVirtualCallNotStarted() {
        when(mHeadsetService.isVirtualCallStarted()).thenReturn(false);
        when(mSystemInterface.listCurrentCalls()).thenReturn(false);

        mHeadsetStateMachine.processAtClcc(mTestDevice);

        verify(mNativeInterface).clccResponse(mTestDevice, 0, 0, 0, 0, false, "", 0);
    }

    /**
     * Setup Connecting State
     * @return number of times mHeadsetService.sendBroadcastAsUser() has been invoked
+391 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth.telephony;

import static org.junit.Assert.assertThrows;

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

import android.telecom.Call;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@SmallTest
@RunWith(AndroidJUnit4.class)
public class BluetoothCallTest {
    private BluetoothCall mBluetoothCall;

    @Before
    public void setUp() {
        mBluetoothCall = new BluetoothCall(null);
    }

    @Test
    public void getCall() {
        assertThat(mBluetoothCall.getCall()).isNull();
    }

    @Test
    public void isCallNull() {
        assertThat(mBluetoothCall.isCallNull()).isTrue();
    }

    @Test
    public void setCall() {
        mBluetoothCall.setCall(null);

        assertThat(mBluetoothCall.isCallNull()).isTrue();
    }

    @Test
    public void constructor_withUuid() {
        UUID uuid = UUID.randomUUID();

        BluetoothCall bluetoothCall = new BluetoothCall(null, uuid);

        assertThat(bluetoothCall.getTbsCallId()).isEqualTo(uuid);
    }

    @Test
    public void setTbsCallId() {
        UUID uuid = UUID.randomUUID();

        mBluetoothCall.setTbsCallId(uuid);

        assertThat(mBluetoothCall.getTbsCallId()).isEqualTo(uuid);
    }

    @Test
    public void getRemainingPostDialSequence_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.getRemainingPostDialSequence());
    }

    @Test
    public void answer_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.answer(1));
    }

    @Test
    public void deflect_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.deflect(null));
    }

    @Test
    public void reject_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.reject(true, "text"));
    }

    @Test
    public void disconnect_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.disconnect());
    }

    @Test
    public void hold_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.hold());
    }

    @Test
    public void unhold_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.unhold());
    }

    @Test
    public void enterBackgroundAudioProcessing_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.enterBackgroundAudioProcessing());
    }

    @Test
    public void exitBackgroundAudioProcessing_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.exitBackgroundAudioProcessing(true));
    }

    @Test
    public void playDtmfTone_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.playDtmfTone('c'));
    }

    @Test
    public void stopDtmfTone_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.stopDtmfTone());
    }

    @Test
    public void postDialContinue_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.postDialContinue(true));
    }

    @Test
    public void phoneAccountSelected_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.phoneAccountSelected(null, true));
    }

    @Test
    public void conference_whenInnerCallIsNull_throwsNPE() {
        BluetoothCall bluetoothCall = new BluetoothCall(null);

        assertThrows(NullPointerException.class, () -> mBluetoothCall.conference(bluetoothCall));
    }

    @Test
    public void splitFromConference_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.splitFromConference());
    }

    @Test
    public void mergeConference_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.mergeConference());
    }

    @Test
    public void swapConference_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.swapConference());
    }

    @Test
    public void pullExternalCall_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.pullExternalCall());
    }

    @Test
    public void sendCallEvent_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.sendCallEvent("event", null));
    }

    @Test
    public void sendRttRequest_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.sendRttRequest());
    }

    @Test
    public void respondToRttRequest_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.respondToRttRequest(1, true));
    }

    @Test
    public void handoverTo_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.handoverTo(null, 1, null));
    }

    @Test
    public void stopRtt_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.stopRtt());
    }

    @Test
    public void removeExtras_withArrayListOfStrings_whenInnerCallIsNull_throwsNPE() {
        ArrayList<String> strings = new ArrayList<>();

        assertThrows(NullPointerException.class, () -> mBluetoothCall.removeExtras(strings));
    }

    @Test
    public void removeExtras_withString_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.removeExtras("text"));
    }

    @Test
    public void getParentId_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getParentId());
    }

    @Test
    public void getChildrenIds_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getChildrenIds());
    }

    @Test
    public void getConferenceableCalls_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getConferenceableCalls());
    }

    @Test
    public void getState_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getState());
    }

    @Test
    public void getCannedTextResponses_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getCannedTextResponses());
    }

    @Test
    public void getVideoCall_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getVideoCall());
    }

    @Test
    public void getDetails_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getDetails());
    }

    @Test
    public void getRttCall_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getRttCall());
    }

    @Test
    public void isRttActive_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.isRttActive());
    }

    @Test
    public void registerCallback_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.registerCallback(null));
    }

    @Test
    public void registerCallback_withHandler_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.registerCallback(null, null));
    }

    @Test
    public void unregisterCallback_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.unregisterCallback(null));
    }

    @Test
    public void toString_throwsException_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.toString());
    }

    @Test
    public void addListener_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.addListener(null));
    }

    @Test
    public void removeListener_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.removeListener(null));
    }

    @Test
    public void getGenericConferenceActiveChildCallId_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.getGenericConferenceActiveChildCallId());
    }

    @Test
    public void getContactDisplayName_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getContactDisplayName());
    }

    @Test
    public void getAccountHandle_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getAccountHandle());
    }

    @Test
    public void getVideoState_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getVideoState());
    }

    @Test
    public void getCallerDisplayName_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getCallerDisplayName());
    }

    @Test
    public void equals_withNull() {
        assertThat(mBluetoothCall.equals(null)).isTrue();
    }

    @Test
    public void equals_withBluetoothCall() {
        BluetoothCall bluetoothCall = new BluetoothCall(null);

        assertThat(mBluetoothCall).isEqualTo(bluetoothCall);
    }

    @Test
    public void isSilentRingingRequested_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.isSilentRingingRequested());
    }

    @Test
    public void isConference_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.isConference());
    }

    @Test
    public void can_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.can(1));
    }

    @Test
    public void getHandle_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getHandle());
    }

    @Test
    public void getGatewayInfo_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getGatewayInfo());
    }

    @Test
    public void isIncoming_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.isIncoming());
    }

    @Test
    public void isExternalCall_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.isExternalCall());
    }

    @Test
    public void getId() {
        assertThat(mBluetoothCall.getId()).isEqualTo(System.identityHashCode(null));
    }

    @Test
    public void wasConferencePreviouslyMerged_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class,
                () -> mBluetoothCall.wasConferencePreviouslyMerged());
    }

    @Test
    public void getDisconnectCause_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.getDisconnectCause());
    }

    @Test
    public void getIds_withEmptyList() {
        List<Call> calls = new ArrayList<>();

        List<Integer> result = BluetoothCall.getIds(calls);

        assertThat(result).isEmpty();
    }

    @Test
    public void hasProperty_whenInnerCallIsNull_throwsNPE() {
        assertThrows(NullPointerException.class, () -> mBluetoothCall.hasProperty(1));
    }
}
+164 −8

File changed.

Preview size limit exceeded, changes collapsed.

Loading