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

Commit a3799ae6 authored by Hall Liu's avatar Hall Liu
Browse files

Add even more test annotations

Bug: 26853070
Change-Id: I8c6a6cdf2164afe88cc1cca1b5ea402c304994b3
parent 0e76dab1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -455,6 +455,7 @@ public class BasicCallTests extends TelecomSystemTest {
        mInCallServiceFixtureX.mInCallAdapter.disconnectCall(outgoing.mCallId);
    }

    @LargeTest
    public void testAudioManagerOperations() throws Exception {
        AudioManager audioManager = (AudioManager) mComponentContextFixture.getTestDouble()
                .getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
+17 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Parcel;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.server.telecom.BluetoothAdapterProxy;
import com.android.server.telecom.BluetoothHeadsetProxy;
@@ -72,24 +73,28 @@ public class BluetoothManagerTest extends TelecomTestCase {
        mBluetoothManager.setBluetoothHeadsetForTesting(mHeadsetProxy);
    }

    @SmallTest
    public void testIsBluetoothAvailableWithNoDevices() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.<BluetoothDevice>emptyList());
        assertFalse(mBluetoothManager.isBluetoothAvailable());
    }

    @SmallTest
    public void testIsBluetoothAvailable() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
        assertTrue(mBluetoothManager.isBluetoothAvailable());
    }

    @SmallTest
    public void testIsAudioConnectedWithNoDevices() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.<BluetoothDevice>emptyList());
        assertFalse(mBluetoothManager.isBluetoothAudioConnected());
    }

    @SmallTest
    public void testIsAudioConnectedWhenAudioNotOn() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
@@ -97,6 +102,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
        assertFalse(mBluetoothManager.isBluetoothAudioConnected());
    }

    @SmallTest
    public void testIsAudioConnectedWhenAudioOn() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
@@ -104,6 +110,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
        assertTrue(mBluetoothManager.isBluetoothAudioConnected());
    }

    @SmallTest
    public void testShouldBePendingAfterConnectAudio() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
@@ -114,17 +121,20 @@ public class BluetoothManagerTest extends TelecomTestCase {
        assertTrue(mBluetoothManager.isBluetoothAudioConnectedOrPending());
    }

    @SmallTest
    public void testDisconnectAudioWhenHeadsetServiceConnected() {
        mBluetoothManager.disconnectBluetoothAudio();
        verify(mHeadsetProxy).disconnectAudio();
    }

    @SmallTest
    public void testDisconnectAudioWithNoHeadsetService() {
        mBluetoothManager.setBluetoothHeadsetForTesting(null);
        mBluetoothManager.disconnectBluetoothAudio();
        verify(mHeadsetProxy, never()).disconnectAudio();
    }

    @SmallTest
    public void testConnectServiceWhenUninitialized1() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.<BluetoothDevice>emptyList());
@@ -133,6 +143,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_DISCONNECTED);
    }

    @SmallTest
    public void testConnectServiceWhenUninitialized2() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
@@ -142,6 +153,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_DEVICE_CONNECTED);
    }

    @SmallTest
    public void testConnectServiceWhenUninitialized3() {
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
                Collections.singletonList(device1));
@@ -151,6 +163,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_AUDIO_CONNECTED);
    }

    @SmallTest
    public void testReceiveAudioDisconnectWhenConnected() {
        mBluetoothManager.setInternalBluetoothState(BluetoothManager.BLUETOOTH_AUDIO_CONNECTED);
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
@@ -162,6 +175,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_DEVICE_CONNECTED);
    }

    @SmallTest
    public void testReceiveAudioConnectWhenDisconnected() {
        mBluetoothManager.setInternalBluetoothState(BluetoothManager.BLUETOOTH_DEVICE_CONNECTED);
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
@@ -173,6 +187,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_AUDIO_CONNECTED);
    }

    @SmallTest
    public void testReceiveAudioConnectWhenPending() {
        mBluetoothManager.setInternalBluetoothState(BluetoothManager.BLUETOOTH_AUDIO_PENDING);
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
@@ -184,6 +199,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_AUDIO_CONNECTED);
    }

    @SmallTest
    public void testReceiveAudioDisconnectWhenPending() {
        mBluetoothManager.setInternalBluetoothState(BluetoothManager.BLUETOOTH_AUDIO_PENDING);
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
@@ -195,6 +211,7 @@ public class BluetoothManagerTest extends TelecomTestCase {
                BluetoothManager.BLUETOOTH_DEVICE_CONNECTED);
    }

    @SmallTest
    public void testReceiveAudioConnectingWhenPending() {
        mBluetoothManager.setInternalBluetoothState(BluetoothManager.BLUETOOTH_AUDIO_PENDING);
        when(mHeadsetProxy.getConnectedDevices()).thenReturn(
+0 −2
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@

package com.android.server.telecom.tests;

import android.content.Context;
import android.media.AudioManager;
import android.telecom.CallAudioState;
import android.test.suitebuilder.annotation.LargeTest;

import com.android.server.telecom.CallAudioManager;
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Debug;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.server.telecom.Call;
import com.android.server.telecom.CallIdMapper;
@@ -83,6 +84,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        super.tearDown();
    }

    @SmallTest
    public void testSimPhoneAccountSuccess() throws Exception {
        PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
        when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -102,6 +104,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        verify(mMockCreateConnectionResponse).handleCreateConnectionSuccess(mockCallIdMapper, null);
    }

    @SmallTest
    public void testbadPhoneAccount() throws Exception {
        PhoneAccountHandle pAHandle = null;
        when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -119,6 +122,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
                eq(new DisconnectCause(DisconnectCause.ERROR)));
    }

    @SmallTest
    public void testConnectionManagerSuccess() throws Exception {
        PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
        when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -143,6 +147,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        verify(mMockCreateConnectionResponse).handleCreateConnectionSuccess(mockCallIdMapper, null);
    }

    @SmallTest
    public void testConnectionManagerFailedFallToSim() throws Exception {
        PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
        when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -177,6 +182,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        verify(mMockCreateConnectionResponse).handleCreateConnectionSuccess(mockCallIdMapper, null);
    }

    @SmallTest
    public void testConnectionManagerFailedDoNotFallToSim() throws Exception {
        PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
        when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -206,6 +212,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
                new DisconnectCause(DisconnectCause.OTHER));
    }

    @SmallTest
    public void testEmergencyCallToSim() throws Exception {
        when(mMockCall.isEmergencyCall()).thenReturn(true);
        // Put in a regular phone account to be sure it doesn't call that
@@ -228,6 +235,7 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        verify(mMockCreateConnectionResponse).handleCreateConnectionSuccess(mockCallIdMapper, null);
    }

    @SmallTest
    public void testEmergencyCallSimFailToConnectionManager() throws Exception {
        when(mMockCall.isEmergencyCall()).thenReturn(true);
        when(mMockCall.getHandle()).thenReturn(Uri.parse(""));
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.telecom.InCallService;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.test.mock.MockContext;
import android.test.suitebuilder.annotation.MediumTest;

import com.android.server.telecom.BluetoothHeadsetProxy;
import com.android.server.telecom.Call;
@@ -98,6 +99,7 @@ public class InCallControllerTests extends TelecomTestCase {
        super.tearDown();
    }

    @MediumTest
    public void testBindToService_NoServicesFound_IncomingCall() throws Exception {
        when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mUserHandle);
        when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
@@ -124,6 +126,7 @@ public class InCallControllerTests extends TelecomTestCase {
        assertNull(bindIntent.getExtras());
    }

    @MediumTest
    public void testBindToService_NoServicesFound_OutgoingCall() throws Exception {
        Bundle callExtras = new Bundle();
        callExtras.putBoolean("whatever", true);
Loading