Migrate Telecom tests to JUnit4
Change all tests to use AndroidJUnitRunner instead of
InstrumentationRunner.
TelecomTestCase no longer inherits from AndroidTestCase.
Update the lite_test_telecom script to use JUnit4.
This allows Telecom tests to use modern JUnit4 features. Refactorings
along those lines will be in subsequent CLs.
Bug: 69482930
Test: lite_test_telecom -a
Change-Id: I64a41fa049f2a23f28b7652d7b835d7705e2179a
Merged-In: I64a41fa049f2a23f28b7652d7b835d7705e2179a
diff --git a/scripts/telecom_testing.sh b/scripts/telecom_testing.sh
index 723b041..779f449 100644
--- a/scripts/telecom_testing.sh
+++ b/scripts/telecom_testing.sh
@@ -58,7 +58,7 @@
build_dir="packages/services/Telecomm/tests"
apk_loc="data/app/TelecomUnitTests/TelecomUnitTests.apk"
package_prefix="com.android.server.telecom.tests"
- instrumentation="android.test.InstrumentationTestRunner";;
+ instrumentation="android.support.test.runner.AndroidJUnitRunner";;
"telephony")
build_dir="frameworks/opt/telephony/tests/"
apk_loc="data/app/FrameworksTelephonyTests/FrameworksTelephonyTests.apk"
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index eccd513..0e79fce 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -51,7 +51,7 @@
adb shell am instrument -w -e class com.android.server.telecom.tests.unit.FooUnitTest \
com.android.server.telecom.tests/android.test.InstrumentationTestRunner
-->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.server.telecom.tests"
android:label="Telecomm application tests"
android:debuggable="true"/>
diff --git a/tests/src/com/android/server/telecom/tests/AnalyticsTests.java b/tests/src/com/android/server/telecom/tests/AnalyticsTests.java
index c5516c7..9d64f18 100644
--- a/tests/src/com/android/server/telecom/tests/AnalyticsTests.java
+++ b/tests/src/com/android/server/telecom/tests/AnalyticsTests.java
@@ -42,6 +42,12 @@
import com.android.server.telecom.LogUtils;
import com.android.server.telecom.nano.TelecomLogClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
@@ -53,13 +59,32 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+@RunWith(JUnit4.class)
public class AnalyticsTests extends TelecomSystemTest {
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
@MediumTest
+ @Test
public void testAnalyticsSingleCall() throws Exception {
IdPair testCall = startAndMakeActiveIncomingCall(
"650-555-1212",
@@ -101,6 +126,7 @@
@FlakyTest
@MediumTest
+ @Test
public void testAnalyticsDumping() throws Exception {
Analytics.reset();
IdPair testCall = startAndMakeActiveIncomingCall(
@@ -144,6 +170,7 @@
}
@MediumTest
+ @Test
public void testAnalyticsTwoCalls() throws Exception {
IdPair testCall1 = startAndMakeActiveIncomingCall(
"650-555-1212",
@@ -196,6 +223,7 @@
}
@MediumTest
+ @Test
public void testAnalyticsVideo() throws Exception {
Analytics.reset();
IdPair callIds = startAndMakeActiveOutgoingCall(
@@ -245,6 +273,7 @@
}
@SmallTest
+ @Test
public void testAnalyticsRounding() {
long[] testVals = {0, -1, -10, -100, -57836, 1, 10, 100, 1000, 458457};
long[] expected = {0, -1, -10, -100, -60000, 1, 10, 100, 1000, 500000};
@@ -254,6 +283,7 @@
}
@SmallTest
+ @Test
public void testAnalyticsLogSessionTiming() throws Exception {
long minTime = 50;
Log.startSession(LogUtils.Sessions.CSW_ADD_CONFERENCE_CALL);
@@ -268,6 +298,7 @@
}
@MediumTest
+ @Test
public void testAnalyticsDumpToProto() throws Exception {
Analytics.reset();
IdPair testCall = startAndMakeActiveIncomingCall(
@@ -315,6 +346,7 @@
}
@MediumTest
+ @Test
public void testAnalyticsAudioRoutes() throws Exception {
Analytics.reset();
IdPair testCall = startAndMakeActiveIncomingCall(
@@ -355,6 +387,7 @@
}
@MediumTest
+ @Test
public void testAnalyticsConnectionProperties() throws Exception {
Analytics.reset();
IdPair testCall = startAndMakeActiveIncomingCall(
@@ -390,6 +423,7 @@
}
@SmallTest
+ @Test
public void testAnalyticsMaxSize() throws Exception {
Analytics.reset();
for (int i = 0; i < Analytics.MAX_NUM_CALLS_TO_STORE * 2; i++) {
diff --git a/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java b/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
index 79d711b..66ae17d 100644
--- a/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/AsyncBlockCheckFilterTest.java
@@ -26,6 +26,10 @@
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import java.util.concurrent.CountDownLatch;
@@ -37,6 +41,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class AsyncBlockCheckFilterTest extends TelecomTestCase {
@Mock private Context mContext;
@Mock private BlockCheckerAdapter mBlockCheckerAdapter;
@@ -62,6 +67,7 @@
private static final int TEST_TIMEOUT = 100;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
when(mCall.getHandle()).thenReturn(TEST_HANDLE);
@@ -69,6 +75,7 @@
}
@SmallTest
+ @Test
public void testBlockNumber() {
final CountDownLatch latch = new CountDownLatch(1);
doAnswer(invocation -> {
@@ -83,6 +90,7 @@
}
@SmallTest
+ @Test
public void testDontBlockNumber() {
final CountDownLatch latch = new CountDownLatch(1);
doAnswer(invocation -> {
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index 41a775f..9db70fd 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -16,6 +16,10 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
@@ -56,6 +60,11 @@
import com.google.common.base.Predicate;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -69,11 +78,25 @@
/**
* Performs various basic call tests in Telecom.
*/
+@RunWith(JUnit4.class)
public class BasicCallTests extends TelecomSystemTest {
private static final String TEST_BUNDLE_KEY = "android.telecom.extra.TEST";
private static final String TEST_EVENT = "android.telecom.event.TEST";
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
@LargeTest
+ @Test
public void testSingleOutgoingCallLocalDisconnect() throws Exception {
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -102,6 +125,7 @@
}
@LargeTest
+ @Test
public void testSingleOutgoingCallRemoteDisconnect() throws Exception {
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -123,6 +147,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testTelecomManagerAcceptRingingCall() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
mConnectionServiceFixtureA);
@@ -149,6 +174,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testTelecomManagerAcceptRingingVideoCall() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA);
@@ -177,6 +203,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testTelecomManagerAcceptRingingVideoCallAsAudio() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA);
@@ -204,6 +231,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testTelecomManagerAcceptRingingInvalidVideoState() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA);
@@ -225,6 +253,7 @@
}
@LargeTest
+ @Test
public void testSingleIncomingCallLocalDisconnect() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -242,6 +271,7 @@
}
@LargeTest
+ @Test
public void testSingleIncomingCallRemoteDisconnect() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -256,6 +286,7 @@
}
@LargeTest
+ @Test
public void testIncomingEmergencyCallback() throws Exception {
// Make an outgoing emergency call
String phoneNumber = "650-555-1212";
@@ -279,15 +310,16 @@
.createConnection(any(PhoneAccountHandle.class), anyString(),
connectionRequestCaptor.capture(), eq(true), eq(false), any());
- assert(connectionRequestCaptor.getValue().getExtras().containsKey(
+ assertTrue(connectionRequestCaptor.getValue().getExtras().containsKey(
android.telecom.Call.EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS));
assertTrue(connectionRequestCaptor.getValue().getExtras().getLong(
android.telecom.Call.EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS, 0) > 0);
- assert(connectionRequestCaptor.getValue().getExtras().containsKey(
+ assertTrue(connectionRequestCaptor.getValue().getExtras().containsKey(
TelecomManager.EXTRA_INCOMING_CALL_ADDRESS));
}
@LargeTest
+ @Test
public void testOutgoingCallAndSelectPhoneAccount() throws Exception {
// Remove default PhoneAccount so that the Call moves into the correct
// SELECT_PHONE_ACCOUNT state.
@@ -317,6 +349,7 @@
}
@LargeTest
+ @Test
public void testIncomingCallFromContactWithSendToVoicemailIsRejected() throws Exception {
Bundle extras = new Bundle();
extras.putParcelable(
@@ -359,6 +392,7 @@
}
@LargeTest
+ @Test
public void testIncomingCallCallerInfoLookupTimesOutIsAllowed() throws Exception {
when(mClockProxy.currentTimeMillis()).thenReturn(TEST_CREATE_TIME);
when(mClockProxy.elapsedRealtime()).thenReturn(TEST_CREATE_ELAPSED_TIME);
@@ -405,6 +439,7 @@
}
@LargeTest
+ @Test
public void testIncomingCallFromBlockedNumberIsRejected() throws Exception {
String phoneNumber = "650-555-1212";
blockNumber(phoneNumber);
@@ -443,6 +478,7 @@
}
@LargeTest
+ @Test
public void testIncomingCallBlockCheckTimesoutIsAllowed() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
String phoneNumber = "650-555-1212";
@@ -490,20 +526,8 @@
});
}
- @MediumTest
- public void testDeadlockOnOutgoingCall() throws Exception {
- for (int i = 0; i < 100; i++) {
- BasicCallTests test = new BasicCallTests();
- test.setContext(getContext());
- test.setTestContext(getTestContext());
- test.setName(getName());
- test.setUp();
- test.do_testDeadlockOnOutgoingCall();
- test.tearDown();
- }
- }
-
@LargeTest
+ @Test
public void testIncomingThenOutgoingCalls() throws Exception {
// TODO: We have to use the same PhoneAccount for both; see http://b/18461539
IdPair incoming = startAndMakeActiveIncomingCall("650-555-2323",
@@ -516,6 +540,7 @@
}
@LargeTest
+ @Test
public void testOutgoingThenIncomingCalls() throws Exception {
// TODO: We have to use the same PhoneAccount for both; see http://b/18461539
IdPair outgoing = startAndMakeActiveOutgoingCall("650-555-1212",
@@ -537,6 +562,7 @@
}
@LargeTest
+ @Test
public void testAudioManagerOperations() throws Exception {
AudioManager audioManager = (AudioManager) mComponentContextFixture.getTestDouble()
.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
@@ -598,11 +624,13 @@
}
@MediumTest
+ @Test
public void testBasicConferenceCall() throws Exception {
makeConferenceCall();
}
@MediumTest
+ @Test
public void testAddCallToConference1() throws Exception {
ParcelableCall conferenceCall = makeConferenceCall();
IdPair callId3 = startAndMakeActiveOutgoingCall("650-555-1214",
@@ -620,6 +648,7 @@
}
@MediumTest
+ @Test
public void testAddCallToConference2() throws Exception {
ParcelableCall conferenceCall = makeConferenceCall();
IdPair callId3 = startAndMakeActiveOutgoingCall("650-555-1214",
@@ -642,6 +671,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testPullNonExternalCall() throws Exception {
// TODO: Revisit this unit test once telecom support for filtering external calls from
// InCall services is implemented.
@@ -662,6 +692,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSendConnectionEventNull() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -677,6 +708,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSendConnectionEventNotNull() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -698,6 +730,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSendCallEventNull() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -714,6 +747,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSendCallEventNonNull() throws Exception {
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
@@ -776,6 +810,7 @@
* property set.
*/
@MediumTest
+ @Test
public void testCdmaEnhancedPrivacyVoiceCall() throws Exception {
mConnectionServiceFixtureA.mConnectionServiceDelegate.mProperties =
Connection.PROPERTY_HAS_CDMA_VOICE_PRIVACY;
@@ -794,6 +829,7 @@
* when the Connection.PROPERTY_HAS_CDMA_VOICE_PRIVACY property is removed from the Connection.
*/
@MediumTest
+ @Test
public void testDropCdmaEnhancedPrivacyVoiceCall() throws Exception {
mConnectionServiceFixtureA.mConnectionServiceDelegate.mProperties =
Connection.PROPERTY_HAS_CDMA_VOICE_PRIVACY;
@@ -815,6 +851,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testPullExternalCall() throws Exception {
// TODO: Revisit this unit test once telecom support for filtering external calls from
// InCall services is implemented.
@@ -841,6 +878,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testPullNonPullableExternalCall() throws Exception {
// TODO: Revisit this unit test once telecom support for filtering external calls from
// InCall services is implemented.
@@ -864,6 +902,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testOutgoingCallSelectPhoneAccountVideo() throws Exception {
startOutgoingPhoneCallPendingCreateConnection("650-555-1212",
null, mConnectionServiceFixtureA,
@@ -886,6 +925,7 @@
*/
@FlakyTest
@LargeTest
+ @Test
public void testOutgoingCallSelectPhoneAccountNoVideo() throws Exception {
startOutgoingPhoneCallPendingCreateConnection("650-555-1212",
null, mConnectionServiceFixtureA,
@@ -906,6 +946,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testSelfManagedOutgoing() throws Exception {
PhoneAccountHandle phoneAccountHandle = mPhoneAccountSelfManaged.getAccountHandle();
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212", phoneAccountHandle,
@@ -920,6 +961,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testSelfManagedIncoming() throws Exception {
PhoneAccountHandle phoneAccountHandle = mPhoneAccountSelfManaged.getAccountHandle();
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212", phoneAccountHandle,
@@ -935,6 +977,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testIsOutgoingCallPermitted() throws Exception {
assertTrue(mTelecomSystem.getTelecomServiceImpl().getBinder()
.isOutgoingCallPermitted(mPhoneAccountSelfManaged.getAccountHandle()));
@@ -946,6 +989,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testIsOutgoingCallPermittedOngoing() throws Exception {
// Start a regular call; the self-managed CS can't make a call now.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -962,6 +1006,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testDisconnectSelfManaged() throws Exception {
// Add a self-managed call.
PhoneAccountHandle phoneAccountHandle = mPhoneAccountSelfManaged.getAccountHandle();
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
index 05f3dd6..59934dc 100644
--- a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
@@ -31,12 +31,20 @@
import com.android.server.telecom.bluetooth.BluetoothDeviceManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
+@RunWith(JUnit4.class)
public class BluetoothDeviceManagerTest extends TelecomTestCase {
@Mock BluetoothRouteManager mRouteManager;
@Mock BluetoothHeadsetProxy mHeadsetProxy;
@@ -50,6 +58,8 @@
private BluetoothDevice device2;
private BluetoothDevice device3;
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
device1 = makeBluetoothDevice("00:00:00:00:00:01");
@@ -80,6 +90,7 @@
}
@SmallTest
+ @Test
public void testSingleDeviceConnectAndDisconnect() {
receiverUnderTest.onReceive(mContext,
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1));
@@ -93,6 +104,7 @@
}
@SmallTest
+ @Test
public void testMultiDeviceConnectAndDisconnect() {
receiverUnderTest.onReceive(mContext,
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1));
@@ -115,6 +127,7 @@
}
@SmallTest
+ @Test
public void testExclusionaryGetRecentDevices() {
receiverUnderTest.onReceive(mContext,
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1));
@@ -132,6 +145,7 @@
}
@SmallTest
+ @Test
public void testHeadsetServiceDisconnect() {
receiverUnderTest.onReceive(mContext,
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1));
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothPhoneServiceTest.java b/tests/src/com/android/server/telecom/tests/BluetoothPhoneServiceTest.java
index 885fbc4..a5feab7 100644
--- a/tests/src/com/android/server/telecom/tests/BluetoothPhoneServiceTest.java
+++ b/tests/src/com/android/server/telecom/tests/BluetoothPhoneServiceTest.java
@@ -22,12 +22,10 @@
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Binder;
-import android.os.Debug;
import android.telecom.Connection;
import android.telecom.GatewayInfo;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.MediumTest;
@@ -42,12 +40,18 @@
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.TelecomSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.LinkedList;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
@@ -64,6 +68,7 @@
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
+@RunWith(JUnit4.class)
public class BluetoothPhoneServiceTest extends TelecomTestCase {
private static final int TEST_DTMF_TONE = 0;
@@ -97,6 +102,7 @@
@Mock BluetoothHeadsetProxy mMockBluetoothHeadset;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -120,6 +126,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mBluetoothPhoneService = null;
@@ -127,6 +134,7 @@
}
@SmallTest
+ @Test
public void testHeadsetAnswerCall() throws Exception {
Call mockCall = createRingingCall();
@@ -137,6 +145,7 @@
}
@SmallTest
+ @Test
public void testHeadsetAnswerCallNull() throws Exception {
when(mMockCallsManager.getRingingCall()).thenReturn(null);
@@ -147,6 +156,7 @@
}
@SmallTest
+ @Test
public void testHeadsetHangupCall() throws Exception {
Call mockCall = createForegroundCall();
@@ -157,6 +167,7 @@
}
@SmallTest
+ @Test
public void testHeadsetHangupCallNull() throws Exception {
when(mMockCallsManager.getForegroundCall()).thenReturn(null);
@@ -167,6 +178,7 @@
}
@SmallTest
+ @Test
public void testHeadsetSendDTMF() throws Exception {
Call mockCall = createForegroundCall();
@@ -178,6 +190,7 @@
}
@SmallTest
+ @Test
public void testHeadsetSendDTMFNull() throws Exception {
when(mMockCallsManager.getForegroundCall()).thenReturn(null);
@@ -189,6 +202,7 @@
}
@SmallTest
+ @Test
public void testGetNetworkOperator() throws Exception {
Call mockCall = createForegroundCall();
PhoneAccount fakePhoneAccount = makeQuickAccount("id0", TEST_ACCOUNT_INDEX);
@@ -201,6 +215,7 @@
}
@SmallTest
+ @Test
public void testGetNetworkOperatorNoPhoneAccount() throws Exception {
when(mMockCallsManager.getForegroundCall()).thenReturn(null);
@@ -210,6 +225,7 @@
}
@SmallTest
+ @Test
public void testGetSubscriberNumber() throws Exception {
Call mockCall = createForegroundCall();
PhoneAccount fakePhoneAccount = makeQuickAccount("id0", TEST_ACCOUNT_INDEX);
@@ -222,6 +238,7 @@
}
@SmallTest
+ @Test
public void testGetSubscriberNumberFallbackToTelephony() throws Exception {
Call mockCall = createForegroundCall();
String fakeNumber = "8675309";
@@ -237,6 +254,7 @@
}
@MediumTest
+ @Test
public void testListCurrentCallsOneCall() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
Call activeCall = createActiveCall();
@@ -254,6 +272,7 @@
}
@MediumTest
+ @Test
public void testConferenceInProgressCDMA() throws Exception {
// If two calls are being conferenced and updateHeadsetWithCallState runs while this is
// still occuring, it will look like there is an active and held call still while we are
@@ -304,6 +323,7 @@
}
@MediumTest
+ @Test
public void testListCurrentCallsCdmaHold() throws Exception {
// Call has been put into a CDMA "conference" with one call on hold.
ArrayList<Call> calls = new ArrayList<>();
@@ -345,6 +365,7 @@
}
@MediumTest
+ @Test
public void testListCurrentCallsCdmaConference() throws Exception {
// Call is in a true CDMA conference
ArrayList<Call> calls = new ArrayList<>();
@@ -386,6 +407,7 @@
}
@MediumTest
+ @Test
public void testWaitingCallClccResponse() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -408,6 +430,7 @@
}
@MediumTest
+ @Test
public void testNewCallClccResponse() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -423,6 +446,7 @@
}
@MediumTest
+ @Test
public void testRingingCallClccResponse() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -443,6 +467,7 @@
}
@MediumTest
+ @Test
public void testCallClccCache() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -477,6 +502,7 @@
}
@MediumTest
+ @Test
public void testAlertingCallClccResponse() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -497,6 +523,7 @@
}
@MediumTest
+ @Test
public void testHoldingCallClccResponse() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
when(mMockCallsManager.getCalls()).thenReturn(calls);
@@ -526,6 +553,7 @@
}
@MediumTest
+ @Test
public void testListCurrentCallsImsConference() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
Call parentCall = createActiveCall();
@@ -544,6 +572,7 @@
}
@MediumTest
+ @Test
public void testListCurrentCallsHeldImsCepConference() throws Exception {
ArrayList<Call> calls = new ArrayList<>();
Call parentCall = createHeldCall();
@@ -574,6 +603,7 @@
}
@MediumTest
+ @Test
public void testQueryPhoneState() throws Exception {
Call ringingCall = createRingingCall();
when(ringingCall.getHandle()).thenReturn(Uri.parse("tel:5550000"));
@@ -585,6 +615,7 @@
}
@MediumTest
+ @Test
public void testCDMAConferenceQueryState() throws Exception {
Call parentConfCall = createActiveCall();
final Call confCall1 = mock(Call.class);
@@ -605,6 +636,7 @@
}
@MediumTest
+ @Test
public void testProcessChldTypeReleaseHeldRinging() throws Exception {
Call ringingCall = createRingingCall();
@@ -615,6 +647,7 @@
}
@MediumTest
+ @Test
public void testProcessChldTypeReleaseHeldHold() throws Exception {
Call onHoldCall = createHeldCall();
@@ -625,6 +658,7 @@
}
@MediumTest
+ @Test
public void testProcessChldReleaseActiveRinging() throws Exception {
Call activeCall = createActiveCall();
Call ringingCall = createRingingCall();
@@ -638,6 +672,7 @@
}
@MediumTest
+ @Test
public void testProcessChldReleaseActiveHold() throws Exception {
Call activeCall = createActiveCall();
Call heldCall = createHeldCall();
@@ -651,6 +686,7 @@
}
@MediumTest
+ @Test
public void testProcessChldHoldActiveRinging() throws Exception {
Call ringingCall = createRingingCall();
@@ -662,6 +698,7 @@
}
@MediumTest
+ @Test
public void testProcessChldHoldActiveUnhold() throws Exception {
Call heldCall = createHeldCall();
@@ -673,6 +710,7 @@
}
@MediumTest
+ @Test
public void testProcessChldHoldActiveHold() throws Exception {
Call activeCall = createActiveCall();
addCallCapability(activeCall, Connection.CAPABILITY_HOLD);
@@ -685,6 +723,7 @@
}
@MediumTest
+ @Test
public void testProcessChldAddHeldToConfHolding() throws Exception {
Call activeCall = createActiveCall();
addCallCapability(activeCall, Connection.CAPABILITY_MERGE_CONFERENCE);
@@ -696,6 +735,7 @@
}
@MediumTest
+ @Test
public void testProcessChldAddHeldToConf() throws Exception {
Call activeCall = createActiveCall();
removeCallCapability(activeCall, Connection.CAPABILITY_MERGE_CONFERENCE);
@@ -711,6 +751,7 @@
}
@MediumTest
+ @Test
public void testProcessChldHoldActiveSwapConference() throws Exception {
// Create an active CDMA Call with a call on hold and simulate a swapConference().
Call parentCall = createActiveCall();
@@ -736,6 +777,7 @@
// Testing the CallsManager Listener Functionality on Bluetooth
@MediumTest
+ @Test
public void testOnCallAddedRinging() throws Exception {
Call ringingCall = createRingingCall();
when(ringingCall.getHandle()).thenReturn(Uri.parse("tel:555000"));
@@ -748,6 +790,7 @@
}
@MediumTest
+ @Test
public void testOnCallAddedCdmaActiveHold() throws Exception {
// Call has been put into a CDMA "conference" with one call on hold.
Call parentCall = createActiveCall();
@@ -769,6 +812,7 @@
}
@MediumTest
+ @Test
public void testOnCallRemoved() throws Exception {
Call activeCall = createActiveCall();
mBluetoothPhoneService.mCallsManagerListener.onCallAdded(activeCall);
@@ -780,6 +824,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChangedConnectingCall() throws Exception {
Call activeCall = mock(Call.class);
Call connectingCall = mock(Call.class);
@@ -797,6 +842,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChangedDialing() throws Exception {
Call activeCall = createActiveCall();
@@ -808,6 +854,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChangedAlerting() throws Exception {
Call outgoingCall = createOutgoingCall();
@@ -819,6 +866,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChangedDisconnected() throws Exception {
Call disconnectedCall = createDisconnectedCall();
doReturn(true).when(mMockCallsManager).hasOnlyDisconnectedCalls();
@@ -838,6 +886,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChanged() throws Exception {
Call ringingCall = createRingingCall();
when(ringingCall.getHandle()).thenReturn(Uri.parse("tel:555-0000"));
@@ -858,6 +907,7 @@
}
@MediumTest
+ @Test
public void testOnCallStateChangedGSMSwap() throws Exception {
Call heldCall = createHeldCall();
when(heldCall.getHandle()).thenReturn(Uri.parse("tel:555-0000"));
@@ -870,6 +920,7 @@
}
@MediumTest
+ @Test
public void testOnIsConferencedChanged() throws Exception {
// Start with two calls that are being merged into a CDMA conference call. The
// onIsConferencedChanged method will be called multiple times during the call. Make sure
@@ -906,6 +957,7 @@
}
@MediumTest
+ @Test
public void testBluetoothAdapterReceiver() throws Exception {
Call ringingCall = createRingingCall();
when(ringingCall.getHandle()).thenReturn(Uri.parse("tel:5550000"));
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java
index 2b2caaf..247d698 100644
--- a/tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/BluetoothRouteManagerTest.java
@@ -31,6 +31,10 @@
import com.android.server.telecom.bluetooth.BluetoothDeviceManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import java.util.ArrayList;
@@ -38,6 +42,7 @@
import java.util.List;
import java.util.Objects;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
@@ -48,6 +53,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class BluetoothRouteManagerTest extends StateMachineTestBase<BluetoothRouteManager> {
private enum ListenerUpdate {
DEVICE_LIST_CHANGED, DEVICE_AVAILABLE, DEVICE_UNAVAILABLE,
@@ -207,6 +213,7 @@
private BluetoothDevice device3;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -217,12 +224,14 @@
}
@LargeTest
+ @Test
public void testTransitions() throws Throwable {
List<BluetoothRouteTestParameters> testCases = generateTestCases();
parametrizedTestStateMachine(testCases);
}
@SmallTest
+ @Test
public void testConnectHfpRetryWhileNotConnected() {
BluetoothRouteManager sm = setupStateMachine(
BluetoothRouteManager.AUDIO_OFF_STATE_NAME, null);
@@ -244,6 +253,7 @@
}
@SmallTest
+ @Test
public void testConnectHfpRetryWhileConnectedToAnotherDevice() {
BluetoothRouteManager sm = setupStateMachine(
BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX, device1);
@@ -268,6 +278,7 @@
}
@SmallTest
+ @Test
public void testProperFallbackOrder1() {
// Device 1, 2, 3 are connected in that order. Device 1 is activated, then device 2.
// Disconnect device 2, verify fallback to device 1. Disconnect device 1, fallback to
@@ -319,6 +330,7 @@
}
@SmallTest
+ @Test
public void testProperFallbackOrder2() {
// Device 1, 2, 3 are connected in that order. Device 3 is activated.
// Disconnect device 3, verify fallback to device 2. Disconnect device 2, fallback to
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java b/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
index 488ac29..78f7b50 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
@@ -32,6 +32,10 @@
import com.android.server.telecom.RingbackPlayer;
import com.android.server.telecom.Ringer;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -39,6 +43,8 @@
import java.util.List;
import java.util.stream.Collectors;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -49,6 +55,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class CallAudioManagerTest extends TelecomTestCase {
@Mock private CallAudioRouteStateMachine mCallAudioRouteStateMachine;
@Mock private CallsManager mCallsManager;
@@ -61,6 +68,7 @@
private CallAudioManager mCallAudioManager;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
doAnswer((invocation) -> {
@@ -82,6 +90,7 @@
}
@MediumTest
+ @Test
public void testUnmuteOfSecondIncomingCall() {
// Start with a single incoming call.
Call call = createIncomingCall();
@@ -145,6 +154,7 @@
}
@MediumTest
+ @Test
public void testSingleIncomingCallFlowWithoutMTSpeedUp() {
Call call = createIncomingCall();
when(call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO))
@@ -180,6 +190,7 @@
}
@MediumTest
+ @Test
public void testSingleIncomingCallFlowWithMTSpeedUp() {
Call call = createIncomingCall();
when(call.can(android.telecom.Call.Details.CAPABILITY_SPEED_UP_MT_AUDIO))
@@ -213,6 +224,7 @@
}
@MediumTest
+ @Test
public void testSingleOutgoingCall() {
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.CONNECTING);
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioModeStateMachineTest.java b/tests/src/com/android/server/telecom/tests/CallAudioModeStateMachineTest.java
index af1d3a2..c50ea60 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioModeStateMachineTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioModeStateMachineTest.java
@@ -23,11 +23,16 @@
import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.CallAudioModeStateMachine;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import java.util.ArrayList;
import java.util.List;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
@@ -35,6 +40,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class CallAudioModeStateMachineTest extends StateMachineTestBase<CallAudioModeStateMachine> {
private static class ModeTestParameters extends TestParameters {
public String name;
@@ -91,18 +97,21 @@
@Mock private CallAudioManager mCallAudioManager;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
}
@LargeTest
+ @Test
public void testTransitions() throws Throwable {
List<ModeTestParameters> testCases = generateTestCases();
parametrizedTestStateMachine(testCases);
}
@SmallTest
+ @Test
public void testNoFocusWhenRingerSilenced() throws Throwable {
CallAudioModeStateMachine sm = new CallAudioModeStateMachine(mAudioManager);
sm.setCallAudioManager(mCallAudioManager);
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java b/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
index cb6bbba..4f91df0 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
@@ -37,6 +37,10 @@
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.WiredHeadsetManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -49,7 +53,9 @@
import java.util.Collections;
import java.util.List;
-import static org.mockito.ArgumentMatchers.isNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.same;
@@ -63,6 +69,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class CallAudioRouteStateMachineTest
extends StateMachineTestBase<CallAudioRouteStateMachine> {
private static final int NONE = 0;
@@ -162,6 +169,7 @@
private final TelecomSystem.SyncRoot mLock = new TelecomSystem.SyncRoot() { };
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -187,6 +195,7 @@
}
@SmallTest
+ @Test
public void testEarpieceAutodetect() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -204,18 +213,21 @@
}
@LargeTest
+ @Test
public void testStateMachineTransitionsWithFocus() throws Throwable {
List<RoutingTestParameters> paramList = generateTransitionTests(true);
parametrizedTestStateMachine(paramList);
}
@LargeTest
+ @Test
public void testStateMachineTransitionsWithoutFocus() throws Throwable {
List<RoutingTestParameters> paramList = generateTransitionTests(false);
parametrizedTestStateMachine(paramList);
}
@MediumTest
+ @Test
public void testSpeakerPersistence() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -259,6 +271,7 @@
}
@MediumTest
+ @Test
public void testUserBluetoothSwitchOff() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -300,6 +313,7 @@
}
@MediumTest
+ @Test
public void testUserBluetoothSwitchOffAndOnAgain() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -371,6 +385,7 @@
}
@MediumTest
+ @Test
public void testBluetoothRinging() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -404,6 +419,7 @@
}
@MediumTest
+ @Test
public void testConnectBluetoothDuringRinging() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -449,6 +465,7 @@
}
@SmallTest
+ @Test
public void testConnectSpecificBluetoothDevice() {
CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
mContext,
@@ -496,6 +513,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithEarpieceNoHeadsetNoBluetooth() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_EARPIECE,
CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER);
@@ -503,6 +521,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithEarpieceAndHeadsetNoBluetooth() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_WIRED_HEADSET,
CallAudioState.ROUTE_WIRED_HEADSET | CallAudioState.ROUTE_SPEAKER);
@@ -510,6 +529,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithEarpieceAndHeadsetAndBluetooth() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH,
CallAudioState.ROUTE_WIRED_HEADSET | CallAudioState.ROUTE_SPEAKER
@@ -518,6 +538,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithEarpieceAndBluetoothNoHeadset() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH,
CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER
@@ -526,6 +547,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithNoEarpieceNoHeadsetNoBluetooth() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER,
CallAudioState.ROUTE_SPEAKER);
@@ -533,6 +555,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithHeadsetNoBluetoothNoEarpiece() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_WIRED_HEADSET,
CallAudioState.ROUTE_WIRED_HEADSET | CallAudioState.ROUTE_SPEAKER);
@@ -540,6 +563,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithHeadsetAndBluetoothNoEarpiece() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH,
CallAudioState.ROUTE_WIRED_HEADSET | CallAudioState.ROUTE_SPEAKER
@@ -548,6 +572,7 @@
}
@SmallTest
+ @Test
public void testInitializationWithBluetoothNoHeadsetNoEarpiece() {
CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_BLUETOOTH,
CallAudioState.ROUTE_SPEAKER | CallAudioState.ROUTE_BLUETOOTH);
diff --git a/tests/src/com/android/server/telecom/tests/CallExtrasTest.java b/tests/src/com/android/server/telecom/tests/CallExtrasTest.java
index e9cd733..44578c5 100644
--- a/tests/src/com/android/server/telecom/tests/CallExtrasTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallExtrasTest.java
@@ -25,12 +25,24 @@
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.ArrayList;
import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests the {@link Connection} and {@link Call} extras functionality.
*/
+@RunWith(JUnit4.class)
public class CallExtrasTest extends TelecomSystemTest {
public final static String EXTRA_KEY_STR = "STRINGKEY";
@@ -41,6 +53,18 @@
public final static String EXTRA_VALUE2_STR = "mozzarella";
public final static int EXTRA_VALUE_INT = 1234;
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
/**
* Tests setting extras on the connection side and ensuring they are propagated through to
* the InCallService.
@@ -48,6 +72,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsPutExtras() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -74,6 +99,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsPutBooleanExtra() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -95,6 +121,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsPutIntExtra() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -116,6 +143,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsPutStringExtra() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -138,6 +166,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsRemoveExtra() throws Exception {
// Get a call up and running."STRING"
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -168,6 +197,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsUpdateExisting() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -204,6 +234,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCsSetExtras() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -243,6 +274,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testICSPutExtras() throws Exception {
Bundle extras = new Bundle();
extras.putString(EXTRA_KEY_STR, EXTRA_VALUE_STR);
@@ -270,6 +302,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testExtrasBidirectional() throws Exception {
// Get a call up and running.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -322,6 +355,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testConferenceSetExtras() throws Exception {
ParcelableCall call = makeConferenceCall();
String conferenceId = call.getId();
@@ -364,6 +398,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testConferenceExtraOperations() throws Exception {
ParcelableCall call = makeConferenceCall();
String conferenceId = call.getId();
@@ -399,6 +434,7 @@
* @throws Exception
*/
@LargeTest
+ @Test
public void testConferenceICS() throws Exception {
ParcelableCall call = makeConferenceCall();
String conferenceId = call.getId();
diff --git a/tests/src/com/android/server/telecom/tests/CallLogManagerTest.java b/tests/src/com/android/server/telecom/tests/CallLogManagerTest.java
index 3bf044c..52f1b0f 100644
--- a/tests/src/com/android/server/telecom/tests/CallLogManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallLogManagerTest.java
@@ -48,9 +48,12 @@
import com.android.server.telecom.CallState;
import com.android.server.telecom.MissedCallNotifier;
import com.android.server.telecom.PhoneAccountRegistrar;
-import com.android.server.telecom.R;
import com.android.server.telecom.TelephonyUtil;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
@@ -61,14 +64,18 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.util.Arrays;
-import java.util.Locale;
+@RunWith(JUnit4.class)
public class CallLogManagerTest extends TelecomTestCase {
private CallLogManager mCallLogManager;
@@ -103,6 +110,7 @@
MissedCallNotifier mMissedCallNotifier;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -153,6 +161,7 @@
}
@MediumTest
+ @Test
public void testDontLogCancelledCall() {
Call fakeCall = makeFakeCall(
DisconnectCause.CANCELED,
@@ -174,6 +183,7 @@
}
@MediumTest
+ @Test
public void testDontLogChoosingAccountCall() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -196,6 +206,7 @@
}
@MediumTest
+ @Test
public void testDontLogCallsFromEmergencyAccount() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(EMERGENCY_ACCT_HANDLE, 0));
@@ -224,6 +235,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionOutgoing() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -248,6 +260,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionIncoming() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -272,6 +285,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionMissed() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -300,6 +314,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionRejected() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -325,6 +340,7 @@
}
@MediumTest
+ @Test
public void testCreationTimeAndAge() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -352,6 +368,7 @@
}
@MediumTest
+ @Test
public void testLogPhoneAccountId() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -375,6 +392,7 @@
}
@MediumTest
+ @Test
public void testLogCorrectPhoneNumber() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -401,6 +419,7 @@
}
@MediumTest
+ @Test
public void testLogCallVideoFeatures() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -425,6 +444,7 @@
@MediumTest
@FlakyTest
+ @Test
public void testLogCallDirectionOutgoingWithMultiUserCapability() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mOtherUserAccountHandle,
@@ -457,6 +477,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionIncomingWithMultiUserCapability() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mOtherUserAccountHandle,
@@ -489,6 +510,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionOutgoingWithMultiUserCapabilityFromManagedProfile() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mManagedProfileAccountHandle,
@@ -519,6 +541,7 @@
@MediumTest
@FlakyTest
+ @Test
public void testLogCallDirectionOutgoingFromManagedProfile() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mManagedProfileAccountHandle, 0));
@@ -548,6 +571,7 @@
}
@MediumTest
+ @Test
public void testLogCallDirectionIngoingFromManagedProfile() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mManagedProfileAccountHandle, 0));
@@ -580,6 +604,7 @@
* Ensure call data usage is persisted to the call log when present in the call.
*/
@MediumTest
+ @Test
public void testLogCallDataUsageSet() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -606,6 +631,7 @@
* Ensures call data usage is null in the call log when not set on the call.
*/
@MediumTest
+ @Test
public void testLogCallDataUsageNotSet() {
when(mMockPhoneAccountRegistrar.getPhoneAccountUnchecked(any(PhoneAccountHandle.class)))
.thenReturn(makeFakePhoneAccount(mDefaultAccountHandle, CURRENT_USER_ID));
@@ -629,6 +655,7 @@
}
@SmallTest
+ @Test
public void testCountryIso_setCache() {
Country testCountry = new Country(TEST_ISO, Country.COUNTRY_SOURCE_LOCALE);
CountryDetector mockDetector = (CountryDetector) mContext.getSystemService(
@@ -641,6 +668,7 @@
}
@SmallTest
+ @Test
public void testCountryIso_newCountryDetected() {
Country testCountry = new Country(TEST_ISO, Country.COUNTRY_SOURCE_LOCALE);
Country testCountry2 = new Country(TEST_ISO_2, Country.COUNTRY_SOURCE_LOCALE);
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
index 6782d52..a319fad 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
@@ -15,6 +15,7 @@
*/
package com.android.server.telecom.tests;
+
import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
@@ -37,29 +38,32 @@
import com.android.server.telecom.DefaultDialerCache;
import com.android.server.telecom.ParcelableCallUtils;
import com.android.server.telecom.PhoneAccountRegistrar;
-import com.android.server.telecom.TelecomServiceImpl;
import com.android.server.telecom.callfiltering.CallFilterResultCallback;
import com.android.server.telecom.callfiltering.CallFilteringResult;
import com.android.server.telecom.callfiltering.CallScreeningServiceFilter;
import com.android.server.telecom.TelecomSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import java.util.Collections;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class CallScreeningServiceFilterTest extends TelecomTestCase {
@Mock Context mContext;
@Mock CallsManager mCallsManager;
@@ -90,13 +94,14 @@
);
private CallScreeningServiceFilter mFilter;
+
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
when(mCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mCall.getId()).thenReturn(CALL_ID);
-// when(mBinder.queryLocalInterface(anyString())).thenReturn(mCallScreeningService);
doReturn(mCallScreeningService).when(mBinder).queryLocalInterface(anyString());
mResolveInfo = new ResolveInfo() {{
@@ -120,6 +125,7 @@
}
@SmallTest
+ @Test
public void testNoDefaultDialer() {
when(mDefaultDialerCache.getDefaultDialerApplication(eq(UserHandle.USER_CURRENT)))
.thenReturn(null);
@@ -128,6 +134,7 @@
}
@SmallTest
+ @Test
public void testNoResolveEntries() {
when(mPackageManager.queryIntentServicesAsUser(nullable(Intent.class), anyInt(), anyInt()))
.thenReturn(Collections.emptyList());
@@ -136,6 +143,7 @@
}
@SmallTest
+ @Test
public void testBadResolveEntry() {
mResolveInfo.serviceInfo = null;
mFilter.startFilterLookup(mCall, mCallback);
@@ -143,6 +151,7 @@
}
@SmallTest
+ @Test
public void testPermissionlessFilterService() {
mResolveInfo.serviceInfo.permission = null;
mFilter.startFilterLookup(mCall, mCallback);
@@ -150,6 +159,7 @@
}
@SmallTest
+ @Test
public void testContextFailToBind() {
when(mContext.bindServiceAsUser(nullable(Intent.class), nullable(ServiceConnection.class),
anyInt(), eq(UserHandle.CURRENT))).thenReturn(false);
@@ -158,6 +168,7 @@
}
@SmallTest
+ @Test
public void testExceptionInScreeningService() throws Exception {
doThrow(new RemoteException()).when(mCallScreeningService).screenCall(
nullable(ICallScreeningAdapter.class), nullable(ParcelableCall.class));
@@ -168,6 +179,7 @@
}
@SmallTest
+ @Test
public void testAllowCall() throws Exception {
mFilter.startFilterLookup(mCall, mCallback);
ServiceConnection serviceConnection = verifyBindingIntent();
@@ -178,6 +190,7 @@
}
@SmallTest
+ @Test
public void testDisallowCall() throws Exception {
mFilter.startFilterLookup(mCall, mCallback);
ServiceConnection serviceConnection = verifyBindingIntent();
diff --git a/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java b/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
index 2ae717d..74d07d8 100644
--- a/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallerInfoLookupHelperTest.java
@@ -21,36 +21,40 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.support.test.InstrumentationRegistry;
import android.test.suitebuilder.annotation.SmallTest;
import android.telecom.Logging.Session;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.CallerInfoAsyncQuery;
-import com.android.server.telecom.Call;
import com.android.server.telecom.CallerInfoAsyncQueryFactory;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.ContactsAsyncHelper;
import com.android.server.telecom.TelecomSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import java.io.FileNotFoundException;
import java.io.InputStream;
-import java.net.URI;
import java.util.concurrent.CountDownLatch;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
-import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class CallerInfoLookupHelperTest extends TelecomTestCase {
@Mock Context mContext;
@Mock CallerInfoAsyncQueryFactory mFactory;
@@ -72,6 +76,7 @@
Bitmap mBitmap;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mCallerInfoLookupHelper = new CallerInfoLookupHelper(mContext,
@@ -85,7 +90,8 @@
if (mBitmap == null) {
InputStream is;
try {
- is = getTestContext().getContentResolver().openInputStream(CONTACTS_PHOTO_URI);
+ is = InstrumentationRegistry.getContext()
+ .getContentResolver().openInputStream(CONTACTS_PHOTO_URI);
} catch (FileNotFoundException e) {
return;
}
@@ -96,6 +102,7 @@
}
@SmallTest
+ @Test
public void testLookupWithEmptyHandle() {
CallerInfoLookupHelper.OnQueryCompleteListener listener = mock(
CallerInfoLookupHelper.OnQueryCompleteListener.class);
@@ -105,6 +112,8 @@
verifyProperCleanup();
}
+ @SmallTest
+ @Test
public void testSimpleLookup() {
CallerInfoLookupHelper.OnQueryCompleteListener listener = mock(
CallerInfoLookupHelper.OnQueryCompleteListener.class);
@@ -140,6 +149,8 @@
verifyProperCleanup();
}
+ @SmallTest
+ @Test
public void testLookupWithTwoListeners() {
CallerInfoLookupHelper.OnQueryCompleteListener callListener = mock(
CallerInfoLookupHelper.OnQueryCompleteListener.class);
@@ -179,6 +190,8 @@
verifyProperCleanup();
}
+ @SmallTest
+ @Test
public void testListenerAddedAfterCallerInfoBeforePhoto() {
CallerInfoLookupHelper.OnQueryCompleteListener callListener = mock(
CallerInfoLookupHelper.OnQueryCompleteListener.class);
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 714261a..bf9decb 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -16,6 +16,8 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyChar;
@@ -62,6 +64,10 @@
import com.android.server.telecom.WiredHeadsetManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -71,6 +77,7 @@
import java.util.Collections;
import java.util.List;
+@RunWith(JUnit4.class)
public class CallsManagerTest extends TelecomTestCase {
private static final PhoneAccountHandle SIM_1_HANDLE = new PhoneAccountHandle(
ComponentName.unflattenFromString("com.foo/.Blah"), "Sim1");
@@ -123,6 +130,7 @@
private CallsManager mCallsManager;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -168,6 +176,7 @@
}
@MediumTest
+ @Test
public void testConstructPossiblePhoneAccounts() throws Exception {
// Should be empty since the URI is null.
assertEquals(0, mCallsManager.constructPossiblePhoneAccounts(null, null, false).size());
@@ -179,6 +188,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception {
setupMsimAccounts();
@@ -212,6 +222,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testConstructPossiblePhoneAccountsMultiSimIdle() throws Exception {
setupMsimAccounts();
@@ -226,6 +237,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testFindOutgoingCallPhoneAccountSelfManaged() throws Exception {
List<PhoneAccountHandle> accounts = mCallsManager.findOutgoingCallPhoneAccount(
SELF_MANAGED_HANDLE, TEST_ADDRESS, false /* isVideo */, null /* userHandle */);
@@ -239,6 +251,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testFindOutgoingCallAccountDefault() throws Exception {
when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
SIM_1_HANDLE);
@@ -260,6 +273,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testFindOutgoingCallAccountNoDefault() throws Exception {
when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
null);
@@ -281,6 +295,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testFindOutgoingCallAccountVideo() throws Exception {
when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
null);
@@ -301,6 +316,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testFindOutgoingCallAccountVideoNotAvailable() throws Exception {
when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
null);
@@ -325,6 +341,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testUseSpecifiedAccount() throws Exception {
when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
null);
@@ -344,6 +361,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testPlayDtmfWhenActive() throws Exception {
Call callSpy = addSpyCall();
mCallsManager.playDtmfTone(callSpy, '1');
@@ -355,6 +373,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSuppessDtmfWhenHeld() throws Exception {
Call callSpy = addSpyCall();
callSpy.setState(CallState.ON_HOLD, "test");
@@ -368,6 +387,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testCancelDtmfWhenHeld() throws Exception {
Call callSpy = addSpyCall();
mCallsManager.playDtmfTone(callSpy, '1');
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
index 27202cf..9cdd120 100644
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
@@ -26,6 +26,7 @@
import org.mockito.Mockito;
import android.content.ComponentName;
+import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@@ -76,6 +77,10 @@
int mCapabilities = NOT_SPECIFIED;
int mProperties = NOT_SPECIFIED;
+ public FakeConnectionServiceDelegate(Context base) {
+ attachBaseContext(base);
+ }
+
@Override
public Connection onCreateUnknownConnection(
PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
@@ -377,10 +382,8 @@
int error, Session.Info sessionInfo) {}
}
- FakeConnectionServiceDelegate mConnectionServiceDelegate =
- new FakeConnectionServiceDelegate();
- private IConnectionService mConnectionServiceDelegateAdapter =
- IConnectionService.Stub.asInterface(mConnectionServiceDelegate.onBind(null));
+ FakeConnectionServiceDelegate mConnectionServiceDelegate;
+ private IConnectionService mConnectionServiceDelegateAdapter;
FakeConnectionService mConnectionService = new FakeConnectionService();
private IConnectionService.Stub mConnectionServiceSpy = Mockito.spy(mConnectionService);
@@ -435,7 +438,11 @@
public final List<ComponentName> mRemoteConnectionServiceNames = new ArrayList<>();
public final List<IBinder> mRemoteConnectionServices = new ArrayList<>();
- public ConnectionServiceFixture() throws Exception { }
+ public ConnectionServiceFixture(Context context) throws Exception {
+ mConnectionServiceDelegate = new FakeConnectionServiceDelegate(context);
+ mConnectionServiceDelegateAdapter = IConnectionService.Stub.asInterface(
+ mConnectionServiceDelegate.onBind(null));
+ }
@Override
public IConnectionService getTestDouble() {
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java
index affa4e9..bd855f9 100644
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java
@@ -23,10 +23,19 @@
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.ConnectionServiceFocusManager;
import com.android.server.telecom.ConnectionServiceFocusManager.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
@@ -34,6 +43,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class ConnectionServiceFocusManagerTest extends TelecomTestCase {
@Mock CallsManagerRequester mockCallsManagerRequester;
@@ -50,6 +60,7 @@
private CallsManager.CallsManagerListener mCallsManagerListener;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mFocusManagerUT = new ConnectionServiceFocusManager(
@@ -63,6 +74,7 @@
}
@SmallTest
+ @Test
public void testRequestFocusWithoutActiveFocusExisted() {
// GIVEN the ConnectionServiceFocusManager without focus ConnectionService.
@@ -74,6 +86,7 @@
}
@SmallTest
+ @Test
public void testRequestFocusWithActiveFocusExisted() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService.
requestFocus(mActiveCall, null);
@@ -106,6 +119,7 @@
}
@SmallTest
+ @Test
public void testRequestConnectionServiceSameAsFocusConnectionService() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService.
requestFocus(mActiveCall, null);
@@ -122,6 +136,7 @@
}
@SmallTest
+ @Test
public void testFocusConnectionServiceDoesNotRespondToFocusLost() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService.
requestFocus(mActiveCall, null);
@@ -148,6 +163,7 @@
}
@SmallTest
+ @Test
public void testNonFocusConnectionServiceReleased() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
requestFocus(mActiveCall, null);
@@ -163,6 +179,7 @@
}
@SmallTest
+ @Test
public void testFocusConnectionServiceReleased() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
requestFocus(mActiveCall, null);
@@ -179,6 +196,7 @@
}
@SmallTest
+ @Test
public void testCallStateChangedAffectCallFocus() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService.
CallFocus activeCall = createFakeCall(mActiveConnectionService, CallState.ACTIVE);
@@ -207,6 +225,7 @@
}
@SmallTest
+ @Test
public void testCallStateChangedDoesNotAffectCallFocusIfConnectionServiceIsDifferent() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
requestFocus(mActiveCall, null);
@@ -229,6 +248,7 @@
}
@SmallTest
+ @Test
public void testFocusCallIsNullWhenRemoveTheFocusCall() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
requestFocus(mActiveCall, null);
@@ -243,6 +263,7 @@
}
@SmallTest
+ @Test
public void testConnectionServiceFocusDeath() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
requestFocus(mActiveCall, null);
@@ -259,6 +280,7 @@
}
@SmallTest
+ @Test
public void testNonExternalCallChangedToExternalCall() {
// GIVEN the ConnectionServiceFocusManager with the focus ConnectionService.
requestFocus(mActiveCall, null);
@@ -273,6 +295,7 @@
}
@SmallTest
+ @Test
public void testExternalCallChangedToNonExternalCall() {
// GIVEN the ConnectionServiceFocusManager without focus ConnectionService
diff --git a/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java b/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
index 960a170..81263ae 100644
--- a/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
+++ b/tests/src/com/android/server/telecom/tests/ContactsAsyncHelperTest.java
@@ -21,15 +21,21 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.support.test.InstrumentationRegistry;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.server.telecom.ContactsAsyncHelper;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject;
@@ -40,6 +46,7 @@
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
+@RunWith(JUnit4.class)
public class ContactsAsyncHelperTest extends TelecomTestCase {
private static final Uri SAMPLE_CONTACT_PHOTO_URI = Uri.parse(
"android.resource://com.android.server.telecom.tests/"
@@ -82,12 +89,14 @@
};
@Override
+ @Before
public void setUp() throws Exception {
- mContext = getTestContext();
super.setUp();
+ mContext = InstrumentationRegistry.getTargetContext();
}
@SmallTest
+ @Test
public void testEmptyUri() throws Exception {
ContactsAsyncHelper cah = new ContactsAsyncHelper(mNullContentResolverAdapter);
try {
@@ -101,6 +110,7 @@
}
@SmallTest
+ @Test
public void testNullReturnFromOpenInputStream() {
ContactsAsyncHelper cah = new ContactsAsyncHelper(mNullContentResolverAdapter);
cah.startObtainPhotoAsync(TOKEN, mContext, SAMPLE_CONTACT_PHOTO_URI, mListener, COOKIE);
@@ -110,6 +120,7 @@
}
@SmallTest
+ @Test
public void testImageScaling() {
ContactsAsyncHelper cah = new ContactsAsyncHelper(mWorkingContentResolverAdapter);
cah.startObtainPhotoAsync(TOKEN, mContext, SAMPLE_CONTACT_PHOTO_URI, mListener, COOKIE);
@@ -129,6 +140,7 @@
}
@SmallTest
+ @Test
public void testNoScaling() {
ContactsAsyncHelper cah = new ContactsAsyncHelper(mWorkingContentResolverAdapter);
cah.startObtainPhotoAsync(TOKEN, mContext, SAMPLE_CONTACT_PHOTO_URI_SMALL,
diff --git a/tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java b/tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java
index 350afa3..be8b9b9 100644
--- a/tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java
+++ b/tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java
@@ -20,7 +20,6 @@
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Binder;
-import android.os.Debug;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -34,6 +33,11 @@
import com.android.server.telecom.CreateConnectionResponse;
import com.android.server.telecom.PhoneAccountRegistrar;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -51,6 +55,7 @@
/**
* Unit testing for CreateConnectionProcessor as well as CreateConnectionTimeout classes.
*/
+@RunWith(JUnit4.class)
public class CreateConnectionProcessorTest extends TelecomTestCase {
private static final String TEST_PACKAGE = "com.android.server.telecom.tests";
@@ -69,6 +74,7 @@
CreateConnectionProcessor mTestCreateConnectionProcessor;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -80,12 +86,14 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mTestCreateConnectionProcessor = null;
super.tearDown();
}
@SmallTest
+ @Test
public void testSimPhoneAccountSuccess() throws Exception {
PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -106,6 +114,7 @@
}
@SmallTest
+ @Test
public void testbadPhoneAccount() throws Exception {
PhoneAccountHandle pAHandle = null;
when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -124,6 +133,7 @@
}
@SmallTest
+ @Test
public void testConnectionManagerSuccess() throws Exception {
PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -149,6 +159,7 @@
}
@SmallTest
+ @Test
public void testConnectionManagerFailedFallToSim() throws Exception {
PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -184,6 +195,7 @@
}
@SmallTest
+ @Test
public void testConnectionManagerFailedDoNotFallToSim() throws Exception {
PhoneAccountHandle pAHandle = getNewTargetPhoneAccountHandle("tel_acct");
when(mMockCall.isEmergencyCall()).thenReturn(false);
@@ -214,6 +226,7 @@
}
@SmallTest
+ @Test
public void testEmergencyCallToSim() throws Exception {
when(mMockCall.isEmergencyCall()).thenReturn(true);
// Put in a regular phone account to be sure it doesn't call that
@@ -237,6 +250,7 @@
}
@SmallTest
+ @Test
public void testEmergencyCallSimFailToConnectionManager() throws Exception {
when(mMockCall.isEmergencyCall()).thenReturn(true);
when(mMockCall.getHandle()).thenReturn(Uri.parse(""));
diff --git a/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java b/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
index 82fee3e..94e6631 100644
--- a/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
+++ b/tests/src/com/android/server/telecom/tests/DefaultDialerCacheTest.java
@@ -29,9 +29,14 @@
import com.android.server.telecom.DefaultDialerCache;
import com.android.server.telecom.TelecomSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
@@ -39,6 +44,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class DefaultDialerCacheTest extends TelecomTestCase {
private static final String DIALER1 = "com.android.dialer";
@@ -55,6 +61,8 @@
@Mock private DefaultDialerCache.DefaultDialerManagerAdapter mMockDefaultDialerManager;
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -88,6 +96,7 @@
}
@SmallTest
+ @Test
public void testThreeUsers() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
@@ -107,6 +116,7 @@
}
@SmallTest
+ @Test
public void testDialer1PackageChanged() {
// Populate the caches first
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
@@ -129,6 +139,7 @@
}
@SmallTest
+ @Test
public void testRandomOtherPackageChanged() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
@@ -146,6 +157,7 @@
}
@SmallTest
+ @Test
public void testUserRemoved() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
@@ -164,6 +176,7 @@
}
@SmallTest
+ @Test
public void testPackageRemovedWithoutReplace() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
@@ -183,6 +196,7 @@
}
@SmallTest
+ @Test
public void testPackageAdded() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
@@ -201,6 +215,7 @@
}
@SmallTest
+ @Test
public void testPackageRemovedWithReplace() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
@@ -220,6 +235,7 @@
}
@SmallTest
+ @Test
public void testDefaultDialerSettingChanged() {
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER0), DIALER1);
assertEquals(mDefaultDialerCache.getDefaultDialerApplication(USER1), DIALER2);
diff --git a/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java b/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
index 2ebb6fc..af4c168 100644
--- a/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/DirectToVoicemailCallFilterTest.java
@@ -26,6 +26,10 @@
import com.android.server.telecom.callfiltering.CallFilteringResult;
import com.android.server.telecom.callfiltering.DirectToVoicemailCallFilter;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -33,6 +37,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class DirectToVoicemailCallFilterTest extends TelecomTestCase {
@Mock private CallerInfoLookupHelper mCallerInfoLookupHelper;
@Mock private CallFilterResultCallback mCallback;
@@ -40,11 +45,14 @@
private static final Uri TEST_HANDLE = Uri.parse("tel:1235551234");
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
}
@SmallTest
+ @Test
public void testSendToVoicemail() {
CallerInfoLookupHelper.OnQueryCompleteListener queryListener = verifyLookupStart();
@@ -62,6 +70,7 @@
}
@SmallTest
+ @Test
public void testDontSendToVoicemail() {
CallerInfoLookupHelper.OnQueryCompleteListener queryListener = verifyLookupStart();
@@ -79,6 +88,7 @@
}
@SmallTest
+ @Test
public void testNullResponseFromLookupHelper() {
CallerInfoLookupHelper.OnQueryCompleteListener queryListener = verifyLookupStart(null);
diff --git a/tests/src/com/android/server/telecom/tests/DtmfLocalTonePlayerTest.java b/tests/src/com/android/server/telecom/tests/DtmfLocalTonePlayerTest.java
index 223cb58..24dd18f 100644
--- a/tests/src/com/android/server/telecom/tests/DtmfLocalTonePlayerTest.java
+++ b/tests/src/com/android/server/telecom/tests/DtmfLocalTonePlayerTest.java
@@ -15,7 +15,6 @@
package com.android.server.telecom.tests;
-import android.media.AudioManager;
import android.media.ToneGenerator;
import android.test.suitebuilder.annotation.SmallTest;
@@ -23,6 +22,10 @@
import com.android.server.telecom.DtmfLocalTonePlayer;
import com.android.server.telecom.R;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import static org.mockito.Matchers.anyInt;
@@ -31,6 +34,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class DtmfLocalTonePlayerTest extends TelecomTestCase {
private static final int TIMEOUT = 2000;
@Mock DtmfLocalTonePlayer.ToneGeneratorProxy mToneProxy;
@@ -38,6 +42,7 @@
DtmfLocalTonePlayer mPlayer;
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -46,6 +51,7 @@
}
@SmallTest
+ @Test
public void testSupportedStart() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(true);
when(mToneProxy.isPresent()).thenReturn(true);
@@ -55,6 +61,7 @@
}
@SmallTest
+ @Test
public void testUnsupportedStart() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(false);
when(mToneProxy.isPresent()).thenReturn(true);
@@ -64,6 +71,7 @@
}
@SmallTest
+ @Test
public void testPlayToneWhenUninitialized() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(false);
when(mToneProxy.isPresent()).thenReturn(false);
@@ -74,6 +82,7 @@
}
@SmallTest
+ @Test
public void testPlayToneWhenInitialized() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(true);
when(mToneProxy.isPresent()).thenReturn(true);
@@ -84,6 +93,7 @@
}
@SmallTest
+ @Test
public void testStopToneWhenUninitialized() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(false);
when(mToneProxy.isPresent()).thenReturn(false);
@@ -94,6 +104,7 @@
}
@SmallTest
+ @Test
public void testStopToneWhenInitialized() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(true);
when(mToneProxy.isPresent()).thenReturn(true);
@@ -104,6 +115,7 @@
}
@SmallTest
+ @Test
public void testProperTeardown() {
when(mContext.getResources().getBoolean(R.bool.allow_local_dtmf_tones)).thenReturn(true);
when(mToneProxy.isPresent()).thenReturn(true);
diff --git a/tests/src/com/android/server/telecom/tests/EventManagerTest.java b/tests/src/com/android/server/telecom/tests/EventManagerTest.java
index bb07306..24394ec 100644
--- a/tests/src/com/android/server/telecom/tests/EventManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/EventManagerTest.java
@@ -19,14 +19,25 @@
import android.telecom.Logging.EventManager;
import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit tests for android.telecom.Logging.EventManager.
*/
-
+@RunWith(JUnit4.class)
public class EventManagerTest extends TelecomTestCase {
private EventManager mTestEventManager;
@@ -60,6 +71,7 @@
}
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mTestEventManager = new EventManager(() -> "");
@@ -67,6 +79,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mTestEventManager = null;
mAddedEventRecord = null;
@@ -78,6 +91,7 @@
* the eventRecordAdded callback is working.
*/
@SmallTest
+ @Test
public void testAddEventRecord() throws Exception {
TestRecord testRecord = new TestRecord("testId", "testDescription");
mTestEventManager.event(testRecord, TEST_EVENT, null);
@@ -94,6 +108,7 @@
* the oldest entry is dropped.
*/
@SmallTest
+ @Test
public void testAddEventRecordOverflowMaxEvents() throws Exception {
TestRecord oldestRecordEntry = new TestRecord("id0", "desc0");
// Add the oldest record separately so that we can verify it is dropped later
@@ -119,6 +134,7 @@
* If the queue is resized to be smaller, the oldest records are dropped.
*/
@SmallTest
+ @Test
public void testChangeQueueSize() throws Exception {
TestRecord oldestRecordEntry = new TestRecord("id0", "desc0");
// Add the oldest record separately so that we can verify it is dropped later
@@ -151,6 +167,7 @@
* timing response is correct.
*/
@SmallTest
+ @Test
public void testExtractEventTimings() throws Exception {
TestRecord testRecord = new TestRecord("testId", "testDesc");
// Add unassociated event
@@ -179,6 +196,7 @@
* Verify that adding events to different records does not create a valid TimedEventPair
*/
@SmallTest
+ @Test
public void testExtractEventTimingsDifferentRecords() throws Exception {
TestRecord testRecord = new TestRecord("testId", "testDesc");
TestRecord testRecord2 = new TestRecord("testId2", "testDesc2");
diff --git a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
index 0c6d3c7..0671a4e 100644
--- a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
+++ b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
@@ -54,6 +54,11 @@
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -63,6 +68,8 @@
import java.util.Collections;
import java.util.LinkedList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -76,6 +83,7 @@
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
+@RunWith(JUnit4.class)
public class InCallControllerTests extends TelecomTestCase {
@Mock CallsManager mMockCallsManager;
@Mock PhoneAccountRegistrar mMockPhoneAccountRegistrar;
@@ -102,6 +110,7 @@
private EmergencyCallHelper mEmergencyCallHelper;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -118,11 +127,13 @@
}
@Override
+ @After
public void tearDown() throws Exception {
super.tearDown();
}
@MediumTest
+ @Test
public void testBindToService_NoServicesFound_IncomingCall() throws Exception {
when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mUserHandle);
when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
@@ -150,6 +161,7 @@
}
@MediumTest
+ @Test
public void testBindToService_NoServicesFound_OutgoingCall() throws Exception {
Bundle callExtras = new Bundle();
callExtras.putBoolean("whatever", true);
@@ -186,6 +198,7 @@
}
@MediumTest
+ @Test
public void testBindToService_DefaultDialer_NoEmergency() throws Exception {
Bundle callExtras = new Bundle();
callExtras.putBoolean("whatever", true);
@@ -236,6 +249,7 @@
}
@MediumTest
+ @Test
public void testBindToService_SystemDialer_Emergency() throws Exception {
Bundle callExtras = new Bundle();
callExtras.putBoolean("whatever", true);
@@ -303,6 +317,7 @@
}
@MediumTest
+ @Test
public void testBindToService_DefaultDialer_FallBackToSystem() throws Exception {
Bundle callExtras = new Bundle();
callExtras.putBoolean("whatever", true);
@@ -391,6 +406,7 @@
* supports external calls.
*/
@MediumTest
+ @Test
public void testBindToService_IncludeExternal() throws Exception {
setupMocks(true /* isExternalCall */);
setupMockPackageManager(true /* default */, true /* system */, true /* external calls */);
@@ -427,6 +443,7 @@
* call gets connected soon after, the new call will still be sent to the in-call service.
*/
@MediumTest
+ @Test
public void testUnbindDueToCallDisconnect() throws Exception {
when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mUserHandle);
when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
diff --git a/tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java b/tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java
index 3a8c2d9..fd581f3 100644
--- a/tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java
+++ b/tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java
@@ -30,8 +30,14 @@
import com.android.server.telecom.InCallWakeLockController;
import com.android.server.telecom.TelecomWakeLock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
+@RunWith(JUnit4.class)
public class InCallWakeLockControllerTest extends TelecomTestCase {
@Mock CallsManager mCallsManager;
@@ -40,6 +46,7 @@
private InCallWakeLockController mInCallWakeLockController;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
TelecomWakeLock telecomWakeLock = new TelecomWakeLock(
@@ -50,12 +57,14 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mInCallWakeLockController = null;
super.tearDown();
}
@SmallTest
+ @Test
public void testRingingCallAdded() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(mCall);
when(mWakeLockAdapter.isHeld()).thenReturn(false);
@@ -66,6 +75,7 @@
}
@SmallTest
+ @Test
public void testNonRingingCallAdded() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(null);
when(mWakeLockAdapter.isHeld()).thenReturn(false);
@@ -76,6 +86,7 @@
}
@SmallTest
+ @Test
public void testRingingCallTransition() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(mCall);
when(mWakeLockAdapter.isHeld()).thenReturn(false);
@@ -86,6 +97,7 @@
}
@SmallTest
+ @Test
public void testRingingCallRemoved() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(null);
when(mWakeLockAdapter.isHeld()).thenReturn(false);
@@ -96,6 +108,7 @@
}
@SmallTest
+ @Test
public void testWakeLockReleased() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(null);
when(mWakeLockAdapter.isHeld()).thenReturn(true);
@@ -106,6 +119,7 @@
}
@SmallTest
+ @Test
public void testAcquireWakeLockWhenHeld() throws Exception {
when(mCallsManager.getRingingCall()).thenReturn(mCall);
when(mWakeLockAdapter.isHeld()).thenReturn(true);
diff --git a/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java b/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
index 6861ad5..d975ec2 100644
--- a/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/IncomingCallFilterTest.java
@@ -28,12 +28,17 @@
import com.android.server.telecom.callfiltering.IncomingCallFilter;
import com.android.server.telecom.TelecomSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atMost;
@@ -41,6 +46,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class IncomingCallFilterTest extends TelecomTestCase {
@Mock private CallFilterResultCallback mResultCallback;
@Mock private Call mCall;
@@ -82,6 +88,8 @@
private static final CallFilteringResult DEFAULT_RESULT = RESULT1;
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -90,6 +98,7 @@
}
@SmallTest
+ @Test
public void testSingleFilter() {
IncomingCallFilter testFilter = new IncomingCallFilter(mContext, mResultCallback, mCall,
mLock, mTimeoutsAdapter, Collections.singletonList(mFilter1));
@@ -102,6 +111,7 @@
}
@SmallTest
+ @Test
public void testMultipleFilters() {
List<IncomingCallFilter.CallFilter> filters =
new ArrayList<IncomingCallFilter.CallFilter>() {{
@@ -130,6 +140,7 @@
}
@SmallTest
+ @Test
public void testFilterTimeout() throws Exception {
setTimeoutLength(SHORT_TIMEOUT);
IncomingCallFilter testFilter = new IncomingCallFilter(mContext, mResultCallback, mCall,
@@ -145,6 +156,7 @@
}
@SmallTest
+ @Test
public void testFilterTimeoutDoesntTrip() throws Exception {
setTimeoutLength(SHORT_TIMEOUT);
IncomingCallFilter testFilter = new IncomingCallFilter(mContext, mResultCallback, mCall,
@@ -158,6 +170,7 @@
}
@SmallTest
+ @Test
public void testToString() {
assertEquals("[Allow, logged, notified]", RESULT1.toString());
assertEquals("[Reject, notified]", RESULT2.toString());
diff --git a/tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java b/tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java
index 1909259..6419bba 100644
--- a/tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java
+++ b/tests/src/com/android/server/telecom/tests/IncomingCallNotifierTest.java
@@ -28,6 +28,10 @@
import com.android.server.telecom.HandoverState;
import com.android.server.telecom.ui.IncomingCallNotifier;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import static org.mockito.Matchers.any;
@@ -41,6 +45,7 @@
/**
* Tests for the {@link com.android.server.telecom.ui.IncomingCallNotifier} class.
*/
+@RunWith(JUnit4.class)
public class IncomingCallNotifierTest extends TelecomTestCase {
@Mock private IncomingCallNotifier.CallsManagerProxy mCallsManagerProxy;
@@ -50,6 +55,8 @@
private IncomingCallNotifier mIncomingCallNotifier;
private NotificationManager mNotificationManager;
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -78,6 +85,7 @@
* Add a call that isn't ringing.
*/
@SmallTest
+ @Test
public void testSingleCall() {
mIncomingCallNotifier.onCallAdded(mAudioCall);
verify(mNotificationManager, never()).notify(eq(IncomingCallNotifier.NOTIFICATION_TAG),
@@ -88,6 +96,7 @@
* Add a ringing call when there is no other ongoing call.
*/
@SmallTest
+ @Test
public void testIncomingDuringOngoingCall() {
when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false);
mIncomingCallNotifier.onCallAdded(mRingingCall);
@@ -99,6 +108,7 @@
* Add a ringing call with another call ongoing, not from a different phone account.
*/
@SmallTest
+ @Test
public void testIncomingDuringOngoingCall2() {
when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(false);
when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(0);
@@ -114,6 +124,7 @@
* Remove ringing call with another call ongoing.
*/
@SmallTest
+ @Test
public void testCallRemoved() {
when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true);
when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1);
@@ -132,6 +143,7 @@
* Ensure notification doesn't show during handover.
*/
@SmallTest
+ @Test
public void testDontShowDuringHandover1() {
when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true);
when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1);
@@ -150,6 +162,7 @@
* Ensure notification doesn't show during handover.
*/
@SmallTest
+ @Test
public void testDontShowDuringHandover2() {
when(mCallsManagerProxy.hasCallsForOtherPhoneAccount(any())).thenReturn(true);
when(mCallsManagerProxy.getNumCallsForOtherPhoneAccount(any())).thenReturn(1);
diff --git a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
index 950cb2c..a3bdb10 100644
--- a/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/MissedCallNotifierImplTest.java
@@ -51,6 +51,11 @@
import com.android.server.telecom.ui.MissedCallNotifierImpl;
import com.android.server.telecom.ui.MissedCallNotifierImpl.NotificationBuilderFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -60,6 +65,8 @@
import java.util.LinkedList;
import java.util.List;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
@@ -74,6 +81,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class MissedCallNotifierImplTest extends TelecomTestCase {
private static class MockMissedCallCursorBuilder {
@@ -149,6 +157,7 @@
@Mock private DefaultDialerCache mDefaultDialerCache;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -174,17 +183,20 @@
}
@Override
+ @After
public void tearDown() throws Exception {
TelecomSystem.setInstance(null);
when(mTelecomSystem.isBootComplete()).thenReturn(false);
}
@SmallTest
+ @Test
public void testCancelNotificationInPrimaryUser() {
cancelNotificationTestInternal(PRIMARY_USER);
}
@SmallTest
+ @Test
public void testCancelNotificationInSecondaryUser() {
cancelNotificationTestInternal(SECONARY_USER);
}
@@ -217,6 +229,7 @@
}
@SmallTest
+ @Test
public void testNotifyMultipleMissedCalls() {
Notification.Builder[] builders = new Notification.Builder[4];
@@ -280,18 +293,21 @@
}
@SmallTest
+ @Test
public void testNotifySingleCallInPrimaryUser() {
PhoneAccount phoneAccount = makePhoneAccount(PRIMARY_USER, NO_CAPABILITY);
notifySingleCallTestInternal(phoneAccount, PRIMARY_USER);
}
@SmallTest
+ @Test
public void testNotifySingleCallInSecondaryUser() {
PhoneAccount phoneAccount = makePhoneAccount(SECONARY_USER, NO_CAPABILITY);
notifySingleCallTestInternal(phoneAccount, PRIMARY_USER);
}
@SmallTest
+ @Test
public void testNotifySingleCallInSecondaryUserWithMultiUserCapability() {
PhoneAccount phoneAccount = makePhoneAccount(PRIMARY_USER,
PhoneAccount.CAPABILITY_MULTI_USER);
@@ -299,12 +315,14 @@
}
@SmallTest
+ @Test
public void testNotifySingleCallWhenCurrentUserIsSecondaryUser() {
PhoneAccount phoneAccount = makePhoneAccount(PRIMARY_USER, NO_CAPABILITY);
notifySingleCallTestInternal(phoneAccount, SECONARY_USER);
}
@SmallTest
+ @Test
public void testNotifySingleCall() {
PhoneAccount phoneAccount = makePhoneAccount(PRIMARY_USER, NO_CAPABILITY);
notifySingleCallTestInternal(phoneAccount, PRIMARY_USER);
@@ -375,6 +393,7 @@
}
@SmallTest
+ @Test
public void testNoSmsBackAfterMissedSipCall() {
Notification.Builder builder1 = makeNotificationBuilder("builder1");
MissedCallNotifierImpl.NotificationBuilderFactory fakeBuilderFactory =
@@ -410,6 +429,7 @@
}
@SmallTest
+ @Test
public void testLoadOneCallFromDb() throws Exception {
CallerInfoLookupHelper mockCallerInfoLookupHelper = mock(CallerInfoLookupHelper.class);
MissedCallNotifier.CallInfoFactory mockCallInfoFactory =
@@ -474,6 +494,7 @@
}
@SmallTest
+ @Test
public void testLoadTwoCallsFromDb() throws Exception {
TelecomSystem.setInstance(mTelecomSystem);
when(mTelecomSystem.isBootComplete()).thenReturn(true);
diff --git a/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java b/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
index ad262f1..4c0e76a 100644
--- a/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
+++ b/tests/src/com/android/server/telecom/tests/NewOutgoingCallIntentBroadcasterTest.java
@@ -40,9 +40,16 @@
import com.android.server.telecom.PhoneNumberUtilsAdapterImpl;
import com.android.server.telecom.TelecomSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
@@ -57,6 +64,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class NewOutgoingCallIntentBroadcasterTest extends TelecomTestCase {
private static class ReceiverIntentPair {
public BroadcastReceiver receiver;
@@ -74,6 +82,7 @@
private PhoneNumberUtilsAdapter mPhoneNumberUtilsAdapterSpy;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -83,6 +92,7 @@
}
@SmallTest
+ @Test
public void testNullHandle() {
Intent intent = new Intent(Intent.ACTION_CALL, null);
int result = processIntent(intent, true);
@@ -92,6 +102,7 @@
}
@SmallTest
+ @Test
public void testVoicemailCall() {
String voicemailNumber = "voicemail:18005551234";
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(voicemailNumber));
@@ -105,16 +116,19 @@
}
@SmallTest
+ @Test
public void testVoicemailCallWithBadAction() {
badCallActionHelper(Uri.parse("voicemail:18005551234"), DisconnectCause.OUTGOING_CANCELED);
}
@SmallTest
+ @Test
public void testTelCallWithBadCallAction() {
badCallActionHelper(Uri.parse("tel:6505551234"), DisconnectCause.INVALID_NUMBER);
}
@SmallTest
+ @Test
public void testSipCallWithBadCallAction() {
badCallActionHelper(Uri.parse("sip:testuser@testsite.com"), DisconnectCause.INVALID_NUMBER);
}
@@ -130,6 +144,7 @@
}
@SmallTest
+ @Test
public void testAlreadyDisconnectedCall() {
Uri handle = Uri.parse("tel:6505551234");
doReturn(true).when(mCall).isDisconnected();
@@ -144,6 +159,7 @@
}
@SmallTest
+ @Test
public void testNoNumberSupplied() {
Uri handle = Uri.parse("tel:");
Intent intent = new Intent(Intent.ACTION_CALL, handle);
@@ -156,6 +172,7 @@
}
@SmallTest
+ @Test
public void testEmergencyCallWithNonDefaultDialer() {
Uri handle = Uri.parse("tel:6505551911");
doReturn(true).when(mPhoneNumberUtilsAdapterSpy).isPotentialLocalEmergencyNumber(
@@ -185,6 +202,7 @@
}
@SmallTest
+ @Test
public void testActionCallEmergencyCall() {
Uri handle = Uri.parse("tel:6505551911");
Intent intent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -192,6 +210,7 @@
}
@SmallTest
+ @Test
public void testActionEmergencyWithEmergencyNumber() {
Uri handle = Uri.parse("tel:6505551911");
Intent intent = buildIntent(handle, Intent.ACTION_CALL_EMERGENCY, null);
@@ -199,6 +218,7 @@
}
@SmallTest
+ @Test
public void testActionPrivCallWithEmergencyNumber() {
Uri handle = Uri.parse("tel:6505551911");
Intent intent = buildIntent(handle, Intent.ACTION_CALL_PRIVILEGED, null);
@@ -206,6 +226,7 @@
}
@SmallTest
+ @Test
public void testEmergencyCallWithGatewayExtras() {
Uri handle = Uri.parse("tel:6505551911");
Bundle gatewayExtras = new Bundle();
@@ -218,6 +239,7 @@
}
@SmallTest
+ @Test
public void testActionEmergencyWithNonEmergencyNumber() {
Uri handle = Uri.parse("tel:6505551911");
doReturn(false).when(mPhoneNumberUtilsAdapterSpy).isPotentialLocalEmergencyNumber(
@@ -254,6 +276,7 @@
}
@SmallTest
+ @Test
public void testUnmodifiedRegularCall() {
Uri handle = Uri.parse("tel:6505551234");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -269,6 +292,7 @@
}
@SmallTest
+ @Test
public void testUnmodifiedSipCall() {
Uri handle = Uri.parse("sip:test@test.com");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -286,6 +310,7 @@
}
@SmallTest
+ @Test
public void testCallWithGatewayInfo() {
Uri handle = Uri.parse("tel:6505551234");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -305,6 +330,7 @@
}
@SmallTest
+ @Test
public void testCallNumberModifiedToNull() {
Uri handle = Uri.parse("tel:6505551234");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -320,6 +346,7 @@
}
@SmallTest
+ @Test
public void testCallNumberModifiedToNullWithLongCustomTimeout() {
Uri handle = Uri.parse("tel:6505551234");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
@@ -339,6 +366,7 @@
}
@SmallTest
+ @Test
public void testCallModifiedToEmergency() {
Uri handle = Uri.parse("tel:6505551234");
Intent callIntent = buildIntent(handle, Intent.ACTION_CALL, null);
diff --git a/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java b/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
index 6403d03..7d9cf88 100644
--- a/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
+++ b/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
@@ -26,6 +26,8 @@
import android.os.Parcel;
import android.os.Process;
import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.test.InstrumentationRegistry;
import android.telecom.Log;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -39,6 +41,11 @@
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.PhoneAccountRegistrar.DefaultPhoneAccountHandle;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -54,10 +61,17 @@
import java.util.List;
import java.util.Set;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class PhoneAccountRegistrarTest extends TelecomTestCase {
private static final int MAX_VERSION = Integer.MAX_VALUE;
@@ -69,6 +83,7 @@
@Mock private PhoneAccountRegistrar.AppLabelProxy mAppLabelProxy;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
@@ -87,6 +102,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mRegistrar = null;
new File(
@@ -97,6 +113,7 @@
}
@MediumTest
+ @Test
public void testPhoneAccountHandle() throws Exception {
PhoneAccountHandle input = new PhoneAccountHandle(new ComponentName("pkg0", "cls0"), "id0");
PhoneAccountHandle result = roundTripXml(this, input,
@@ -111,6 +128,7 @@
}
@MediumTest
+ @Test
public void testPhoneAccount() throws Exception {
Bundle testBundle = new Bundle();
testBundle.putInt("EXTRA_INT_1", 1);
@@ -133,9 +151,14 @@
}
@MediumTest
+ @Test
public void testDefaultPhoneAccountHandleEmptyGroup() throws Exception {
DefaultPhoneAccountHandle input = new DefaultPhoneAccountHandle(Process.myUserHandle(),
makeQuickAccountHandle("i1"), "");
+ when(UserManager.get(mContext).getSerialNumberForUser(input.userHandle))
+ .thenReturn(0L);
+ when(UserManager.get(mContext).getUserForSerialNumber(0L))
+ .thenReturn(input.userHandle);
DefaultPhoneAccountHandle result = roundTripXml(this, input,
PhoneAccountRegistrar.sDefaultPhoneAcountHandleXml, mContext);
@@ -147,6 +170,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testPhoneAccountExtrasEdge() throws Exception {
Bundle testBundle = new Bundle();
// Ensure null values for string are not persisted.
@@ -176,6 +200,7 @@
}
@MediumTest
+ @Test
public void testState() throws Exception {
PhoneAccountRegistrar.State input = makeQuickState();
PhoneAccountRegistrar.State result = roundTripXml(this, input,
@@ -190,6 +215,7 @@
}
@MediumTest
+ @Test
public void testAccounts() throws Exception {
int i = 0;
@@ -220,11 +246,13 @@
}
@MediumTest
+ @Test
public void testSimCallManager() throws Exception {
// TODO
}
@MediumTest
+ @Test
public void testDefaultOutgoing() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -273,6 +301,7 @@
}
@MediumTest
+ @Test
public void testReplacePhoneAccountByGroup() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -317,6 +346,7 @@
}
@MediumTest
+ @Test
public void testAddSameDefault() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -361,6 +391,7 @@
}
@MediumTest
+ @Test
public void testAddSameGroup() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -406,6 +437,7 @@
}
@MediumTest
+ @Test
public void testAddSameGroupButDifferentComponent() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -444,6 +476,7 @@
}
@MediumTest
+ @Test
public void testAddSameGroupButDifferentComponent2() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -496,6 +529,7 @@
}
@MediumTest
+ @Test
public void testPhoneAccountParceling() throws Exception {
PhoneAccountHandle handle = makeQuickAccountHandle("foo");
roundTripPhoneAccount(new PhoneAccount.Builder(handle, null).build());
@@ -520,7 +554,7 @@
.setHighlightColor(0xf0f0f0)
.setIcon(Icon.createWithBitmap(
BitmapFactory.decodeResource(
- getContext().getResources(),
+ InstrumentationRegistry.getContext().getResources(),
R.drawable.stat_sys_phone_call)))
.setShortDescription("short description")
.setSubscriptionAddress(Uri.parse("tel:2345678"))
@@ -535,6 +569,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSelfManagedPhoneAccount() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -558,6 +593,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testSelfManagedCapabilityOverride() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -579,6 +615,7 @@
}
@MediumTest
+ @Test
public void testSortSimFirst() throws Exception {
ComponentName componentA = new ComponentName("a", "a");
ComponentName componentB = new ComponentName("b", "b");
@@ -609,6 +646,7 @@
}
@MediumTest
+ @Test
public void testSortBySortOrder() throws Exception {
ComponentName componentA = new ComponentName("a", "a");
ComponentName componentB = new ComponentName("b", "b");
@@ -648,6 +686,7 @@
}
@MediumTest
+ @Test
public void testSortByLabel() throws Exception {
ComponentName componentA = new ComponentName("a", "a");
ComponentName componentB = new ComponentName("b", "b");
@@ -685,6 +724,7 @@
}
@MediumTest
+ @Test
public void testSortAll() throws Exception {
ComponentName componentA = new ComponentName("a", "a");
ComponentName componentB = new ComponentName("b", "b");
@@ -770,6 +810,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testGetByEnabledState() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -789,6 +830,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testGetByScheme() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -815,6 +857,7 @@
* @throws Exception
*/
@MediumTest
+ @Test
public void testGetByCapability() throws Exception {
mComponentContextFixture.addConnectionService(makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
@@ -1011,6 +1054,10 @@
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
new ComponentName("pkg0", "cls0"), "id0");
UserHandle userHandle = phoneAccountHandle.getUserHandle();
+ when(UserManager.get(mContext).getSerialNumberForUser(userHandle))
+ .thenReturn(0L);
+ when(UserManager.get(mContext).getUserForSerialNumber(0L))
+ .thenReturn(userHandle);
s.defaultOutgoingAccountHandles
.put(userHandle, new DefaultPhoneAccountHandle(userHandle, phoneAccountHandle,
"testGroup"));
diff --git a/tests/src/com/android/server/telecom/tests/ProximitySensorManagerTest.java b/tests/src/com/android/server/telecom/tests/ProximitySensorManagerTest.java
index 01bd09e..eafaa53 100644
--- a/tests/src/com/android/server/telecom/tests/ProximitySensorManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/ProximitySensorManagerTest.java
@@ -24,6 +24,11 @@
import com.android.server.telecom.ProximitySensorManager;
import com.android.server.telecom.TelecomWakeLock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
import java.util.ArrayList;
@@ -33,6 +38,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class ProximitySensorManagerTest extends TelecomTestCase{
@Mock CallsManager mCallsManager;
@@ -41,6 +47,7 @@
private ProximitySensorManager mProximitySensorManager;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
TelecomWakeLock telecomWakeLock = new TelecomWakeLock(
@@ -51,12 +58,14 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mProximitySensorManager = null;
super.tearDown();
}
@SmallTest
+ @Test
public void testTurnOnProximityWithCallsActive() throws Exception {
when(mCallsManager.getCalls()).thenReturn(new ArrayList<Call>(){{
add(mCall);
@@ -69,6 +78,7 @@
}
@SmallTest
+ @Test
public void testTurnOnProximityWithNoCallsActive() throws Exception {
when(mCallsManager.getCalls()).thenReturn(new ArrayList<Call>());
when(mWakeLockAdapter.isHeld()).thenReturn(false);
@@ -80,6 +90,7 @@
}
@SmallTest
+ @Test
public void testTurnOffProximityExplicitly() throws Exception {
when(mWakeLockAdapter.isHeld()).thenReturn(true);
@@ -89,6 +100,7 @@
}
@SmallTest
+ @Test
public void testCallRemovedFromCallsManagerCallsActive() throws Exception {
when(mCallsManager.getCalls()).thenReturn(new ArrayList<Call>(){{
add(mCall);
@@ -101,6 +113,7 @@
}
@SmallTest
+ @Test
public void testCallRemovedFromCallsManagerNoCallsActive() throws Exception {
when(mCallsManager.getCalls()).thenReturn(new ArrayList<Call>());
when(mWakeLockAdapter.isHeld()).thenReturn(true);
diff --git a/tests/src/com/android/server/telecom/tests/RingerTest.java b/tests/src/com/android/server/telecom/tests/RingerTest.java
index 2953fce..47ac174 100644
--- a/tests/src/com/android/server/telecom/tests/RingerTest.java
+++ b/tests/src/com/android/server/telecom/tests/RingerTest.java
@@ -34,8 +34,14 @@
import com.android.server.telecom.RingtoneFactory;
import com.android.server.telecom.SystemSettingsUtil;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Mock;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
@@ -43,6 +49,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class RingerTest extends TelecomTestCase {
@Mock InCallTonePlayer.Factory mockPlayerFactory;
@Mock SystemSettingsUtil mockSystemSettingsUtil;
@@ -57,6 +64,9 @@
Ringer mRingerUnderTest;
AudioManager mockAudioManager;
+
+ @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -72,6 +82,7 @@
}
@SmallTest
+ @Test
public void testNoActionInTheaterMode() {
// Start call waiting to make sure that it doesn't stop when we start ringing
mRingerUnderTest.startCallWaiting(mockCall1);
@@ -84,6 +95,7 @@
}
@SmallTest
+ @Test
public void testNoActionWhenDialerRings() {
// Start call waiting to make sure that it doesn't stop when we start ringing
mRingerUnderTest.startCallWaiting(mockCall1);
@@ -96,6 +108,7 @@
}
@SmallTest
+ @Test
public void testAudioFocusStillAcquiredWhenDialerRings() {
// Start call waiting to make sure that it doesn't stop when we start ringing
mRingerUnderTest.startCallWaiting(mockCall1);
@@ -109,6 +122,7 @@
}
@SmallTest
+ @Test
public void testNoActionWhenCallIsSelfManaged() {
// Start call waiting to make sure that it doesn't stop when we start ringing
mRingerUnderTest.startCallWaiting(mockCall1);
@@ -122,6 +136,7 @@
}
@SmallTest
+ @Test
public void testCallWaitingButNoRingForSpecificContacts() {
NotificationManager notificationManager =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -138,6 +153,7 @@
}
@SmallTest
+ @Test
public void testVibrateButNoRingForNullRingtone() {
mRingerUnderTest.startCallWaiting(mockCall1);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(null);
@@ -150,6 +166,7 @@
}
@SmallTest
+ @Test
public void testVibrateButNoRingForSilentRingtone() {
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
@@ -164,6 +181,7 @@
}
@SmallTest
+ @Test
public void testRingAndNoVibrate() {
mRingerUnderTest.startCallWaiting(mockCall1);
ensureRingerIsAudible();
@@ -176,6 +194,7 @@
}
@SmallTest
+ @Test
public void testSilentRingWithHfpStillAcquiresFocus1() {
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
@@ -191,6 +210,7 @@
}
@SmallTest
+ @Test
public void testSilentRingWithHfpStillAcquiresFocus2() {
mRingerUnderTest.startCallWaiting(mockCall1);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(null);
diff --git a/tests/src/com/android/server/telecom/tests/SessionManagerTest.java b/tests/src/com/android/server/telecom/tests/SessionManagerTest.java
index 2d9b0c6..85a9bff 100644
--- a/tests/src/com/android/server/telecom/tests/SessionManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/SessionManagerTest.java
@@ -16,16 +16,29 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import android.telecom.Logging.Session;
import android.telecom.Logging.SessionManager;
import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.lang.ref.WeakReference;
/**
* Unit tests for android.telecom.Logging.SessionManager
*/
+@RunWith(JUnit4.class)
public class SessionManagerTest extends TelecomTestCase {
private static final String TEST_PARENT_NAME = "testParent";
@@ -40,6 +53,7 @@
private String mFullSessionMethodName = "";
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mTestSessionManager = new SessionManager();
@@ -52,6 +66,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
mFullSessionMethodName = "";
mfullSessionCompleteTime = Session.UNDEFINED;
@@ -63,6 +78,7 @@
* Starts a Session on the current thread and verifies that it exists in the HashMap
*/
@SmallTest
+ @Test
public void testStartSession() {
assertTrue(mTestSessionManager.mSessionMapper.isEmpty());
@@ -81,6 +97,7 @@
* session and the second session will be attached to that thread ID.
*/
@SmallTest
+ @Test
public void testStartInvisibleChildSession() {
assertTrue(mTestSessionManager.mSessionMapper.isEmpty());
@@ -105,6 +122,7 @@
* End the active Session and verify that it is completed and removed from mSessionMapper.
*/
@SmallTest
+ @Test
public void testEndSession() {
assertTrue(mTestSessionManager.mSessionMapper.isEmpty());
// Set the thread Id to 0
@@ -129,6 +147,7 @@
* into mSessionMapper.
*/
@SmallTest
+ @Test
public void testEndInvisibleChildSession() {
assertTrue(mTestSessionManager.mSessionMapper.isEmpty());
// Set the thread Id to 0 for the parent
@@ -154,6 +173,7 @@
* in a different thread.
*/
@SmallTest
+ @Test
public void testCreateSubsession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -176,6 +196,7 @@
* marked as completed and never added to mSessionMapper.
*/
@SmallTest
+ @Test
public void testCancelSubsession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -196,6 +217,7 @@
* its parent are in mSessionMapper.
*/
@SmallTest
+ @Test
public void testContinueSubsession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -219,6 +241,7 @@
* no longer exists in mSessionMapper.
*/
@SmallTest
+ @Test
public void testEndSubsession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -241,6 +264,7 @@
* sessions that are complete as well and note the completion time of the entire chain.
*/
@SmallTest
+ @Test
public void testEndSubsessionWithParentComplete() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -276,6 +300,7 @@
* correctly generates the child session.
*/
@SmallTest
+ @Test
public void testStartExternalSession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -298,6 +323,7 @@
* external session from mSessionMapper.
*/
@SmallTest
+ @Test
public void testEndExternalSession() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -323,6 +349,7 @@
* the external Session, but the one subsession underneath.
*/
@SmallTest
+ @Test
public void testEndExternalSessionListenerCallback() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -346,6 +373,7 @@
* Verifies that the recursive method for getting the full ID works correctly.
*/
@SmallTest
+ @Test
public void testFullMethodPath() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
@@ -364,6 +392,7 @@
* correctly to ensure that there are no dangling sessions.
*/
@SmallTest
+ @Test
public void testStaleSessionCleanupTimer() {
mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID;
mTestSessionManager.startSession(TEST_PARENT_NAME, null);
diff --git a/tests/src/com/android/server/telecom/tests/SystemStateProviderTest.java b/tests/src/com/android/server/telecom/tests/SystemStateProviderTest.java
index ad740f4..033f929 100644
--- a/tests/src/com/android/server/telecom/tests/SystemStateProviderTest.java
+++ b/tests/src/com/android/server/telecom/tests/SystemStateProviderTest.java
@@ -16,6 +16,9 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -31,6 +34,11 @@
import com.android.server.telecom.SystemStateProvider;
import com.android.server.telecom.SystemStateProvider.SystemStateListener;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -38,10 +46,9 @@
/**
* Unit tests for SystemStateProvider
*/
+@RunWith(JUnit4.class)
public class SystemStateProviderTest extends TelecomTestCase {
- SystemStateProvider mSystemStateProvider;
-
@Mock Context mContext;
@Mock SystemStateListener mSystemStateListener;
@Mock UiModeManager mUiModeManager;
@@ -49,17 +56,20 @@
@Mock Intent mIntentExit;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
}
@Override
+ @After
public void tearDown() throws Exception {
super.tearDown();
}
@SmallTest
+ @Test
public void testListeners() throws Exception {
SystemStateProvider systemStateProvider = new SystemStateProvider(mContext);
@@ -70,6 +80,7 @@
}
@SmallTest
+ @Test
public void testQuerySystemForCarMode_True() {
when(mContext.getSystemService(Context.UI_MODE_SERVICE)).thenReturn(mUiModeManager);
when(mUiModeManager.getCurrentModeType()).thenReturn(Configuration.UI_MODE_TYPE_CAR);
@@ -77,6 +88,7 @@
}
@SmallTest
+ @Test
public void testQuerySystemForCarMode_False() {
when(mContext.getSystemService(Context.UI_MODE_SERVICE)).thenReturn(mUiModeManager);
when(mUiModeManager.getCurrentModeType()).thenReturn(Configuration.UI_MODE_TYPE_NORMAL);
@@ -84,6 +96,7 @@
}
@SmallTest
+ @Test
public void testReceiverAndIntentFilter() {
ArgumentCaptor<IntentFilter> intentFilter = ArgumentCaptor.forClass(IntentFilter.class);
new SystemStateProvider(mContext);
@@ -95,6 +108,7 @@
}
@SmallTest
+ @Test
public void testOnEnterExitCarMode() {
ArgumentCaptor<BroadcastReceiver> receiver =
ArgumentCaptor.forClass(BroadcastReceiver.class);
diff --git a/tests/src/com/android/server/telecom/tests/TODO b/tests/src/com/android/server/telecom/tests/TODO
deleted file mode 100644
index f412b4a..0000000
--- a/tests/src/com/android/server/telecom/tests/TODO
+++ /dev/null
@@ -1,14 +0,0 @@
-* Implement acquireProvider("settings")
-* Implement acquireUnstableProvider("com.android.contacts")
-* ComponentContextFixture to have "setUp/tearDown" to check for things like un-released providers
-
-Bluetooth
-Speakerphone and audio modes
-Video calling
-Connection managers
-DTMF tones
-Call logging
-Ringback
-Missed calls
-Respond via SMS
-Permissions in registering PhoneAccounts
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index bf2e8f8..b19e5d3 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -53,6 +53,10 @@
import com.android.server.telecom.components.UserCallIntentProcessor;
import com.android.server.telecom.components.UserCallIntentProcessorFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
@@ -63,6 +67,11 @@
import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
@@ -80,6 +89,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@RunWith(JUnit4.class)
public class TelecomServiceImplTest extends TelecomTestCase {
public static class CallIntentProcessAdapterFake implements CallIntentProcessor.Adapter {
@Override
@@ -148,6 +158,7 @@
new ComponentName("test", "sipComponentName"), "3", Binder.getCallingUserHandle());
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -186,6 +197,7 @@
}
@SmallTest
+ @Test
public void testGetDefaultOutgoingPhoneAccount() throws RemoteException {
when(mFakePhoneAccountRegistrar
.getOutgoingPhoneAccountForScheme(eq("tel"), any(UserHandle.class)))
@@ -205,6 +217,7 @@
}
@SmallTest
+ @Test
public void testGetDefaultOutgoingPhoneAccountFailure() throws RemoteException {
// make sure that the list of user profiles doesn't include anything the PhoneAccountHandles
// are associated with
@@ -225,6 +238,7 @@
}
@SmallTest
+ @Test
public void testGetUserSelectedOutgoingPhoneAccount() throws RemoteException {
when(mFakePhoneAccountRegistrar.getUserSelectedOutgoingPhoneAccount(any(UserHandle.class)))
.thenReturn(TEL_PA_HANDLE_16);
@@ -237,6 +251,7 @@
}
@SmallTest
+ @Test
public void testSetUserSelectedOutgoingPhoneAccount() throws RemoteException {
mTSIBinder.setUserSelectedOutgoingPhoneAccount(TEL_PA_HANDLE_16);
verify(mFakePhoneAccountRegistrar)
@@ -244,6 +259,7 @@
}
@SmallTest
+ @Test
public void testSetUserSelectedOutgoingPhoneAccountFailure() throws RemoteException {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
anyString(), nullable(String.class));
@@ -258,6 +274,7 @@
}
@SmallTest
+ @Test
public void testGetCallCapablePhoneAccounts() throws RemoteException {
List<PhoneAccountHandle> fullPHList = new ArrayList<PhoneAccountHandle>() {{
add(TEL_PA_HANDLE_16);
@@ -284,6 +301,7 @@
}
@SmallTest
+ @Test
public void testGetCallCapablePhoneAccountsFailure() throws RemoteException {
List<String> enforcedPermissions = new ArrayList<String>() {{
add(READ_PHONE_STATE);
@@ -304,6 +322,7 @@
}
@SmallTest
+ @Test
public void testGetPhoneAccountsSupportingScheme() throws RemoteException {
List<PhoneAccountHandle> sipPHList = new ArrayList<PhoneAccountHandle>() {{
add(SIP_PA_HANDLE_17);
@@ -327,6 +346,7 @@
}
@SmallTest
+ @Test
public void testGetPhoneAccountsForPackage() throws RemoteException {
List<PhoneAccountHandle> phoneAccountHandleList = new ArrayList<PhoneAccountHandle>() {{
add(TEL_PA_HANDLE_16);
@@ -342,6 +362,7 @@
}
@SmallTest
+ @Test
public void testGetPhoneAccount() throws RemoteException {
makeAccountsVisibleToAllUsers(TEL_PA_HANDLE_16, SIP_PA_HANDLE_17);
assertEquals(TEL_PA_HANDLE_16, mTSIBinder.getPhoneAccount(TEL_PA_HANDLE_16)
@@ -351,6 +372,7 @@
}
@SmallTest
+ @Test
public void testGetAllPhoneAccounts() throws RemoteException {
List<PhoneAccount> phoneAccountList = new ArrayList<PhoneAccount>() {{
add(makePhoneAccount(TEL_PA_HANDLE_16).build());
@@ -363,6 +385,7 @@
}
@SmallTest
+ @Test
public void testRegisterPhoneAccount() throws RemoteException {
String packageNameToUse = "com.android.officialpackage";
PhoneAccountHandle phHandle = new PhoneAccountHandle(new ComponentName(
@@ -375,6 +398,7 @@
}
@SmallTest
+ @Test
public void testRegisterPhoneAccountWithoutModifyPermission() throws RemoteException {
// tests the case where the package does not have MODIFY_PHONE_STATE but is
// registering its own phone account as a third-party connection service
@@ -392,6 +416,7 @@
}
@SmallTest
+ @Test
public void testRegisterPhoneAccountWithoutModifyPermissionFailure() throws RemoteException {
// tests the case where the third party package should not be allowed to register a phone
// account due to the lack of modify permission.
@@ -409,6 +434,7 @@
}
@SmallTest
+ @Test
public void testRegisterPhoneAccountWithoutSimSubscriptionPermissionFailure()
throws RemoteException {
String packageNameToUse = "com.thirdparty.connectionservice";
@@ -428,6 +454,7 @@
}
@SmallTest
+ @Test
public void testRegisterPhoneAccountWithoutMultiUserPermissionFailure()
throws Exception {
String packageNameToUse = "com.thirdparty.connectionservice";
@@ -466,6 +493,7 @@
}
@SmallTest
+ @Test
public void testUnregisterPhoneAccount() throws RemoteException {
String packageNameToUse = "com.android.officialpackage";
PhoneAccountHandle phHandle = new PhoneAccountHandle(new ComponentName(
@@ -480,6 +508,7 @@
}
@SmallTest
+ @Test
public void testUnregisterPhoneAccountFailure() throws RemoteException {
String packageNameToUse = "com.thirdparty.connectionservice";
PhoneAccountHandle phHandle = new PhoneAccountHandle(new ComponentName(
@@ -502,6 +531,7 @@
}
@SmallTest
+ @Test
public void testAddNewIncomingCall() throws Exception {
PhoneAccount phoneAccount = makePhoneAccount(TEL_PA_HANDLE_CURRENT).build();
phoneAccount.setIsEnabled(true);
@@ -517,6 +547,7 @@
}
@SmallTest
+ @Test
public void testAddNewIncomingCallFailure() throws Exception {
try {
mTSIBinder.addNewIncomingCall(TEL_PA_HANDLE_16, null);
@@ -538,6 +569,7 @@
}
@SmallTest
+ @Test
public void testAddNewUnknownCall() throws Exception {
PhoneAccount phoneAccount = makePhoneAccount(TEL_PA_HANDLE_CURRENT).build();
phoneAccount.setIsEnabled(true);
@@ -553,6 +585,7 @@
}
@SmallTest
+ @Test
public void testAddNewUnknownCallFailure() throws Exception {
try {
mTSIBinder.addNewUnknownCall(TEL_PA_HANDLE_16, null);
@@ -603,6 +636,7 @@
}
@SmallTest
+ @Test
public void testPlaceCallWithNonEmergencyPermission() throws Exception {
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
@@ -617,6 +651,7 @@
}
@SmallTest
+ @Test
public void testPlaceCallWithAppOpsOff() throws Exception {
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
@@ -631,6 +666,7 @@
}
@SmallTest
+ @Test
public void testPlaceCallWithNoCallingPermission() throws Exception {
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
@@ -656,6 +692,7 @@
}
@SmallTest
+ @Test
public void testPlaceCallFailure() throws Exception {
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
@@ -674,6 +711,7 @@
}
@SmallTest
+ @Test
public void testSetDefaultDialer() throws Exception {
String packageName = "sample.package";
int currentUser = ActivityManager.getCurrentUser();
@@ -694,6 +732,7 @@
}
@SmallTest
+ @Test
public void testSetDefaultDialerNoModifyPhoneStatePermission() throws Exception {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
eq(MODIFY_PHONE_STATE), nullable(String.class));
@@ -701,6 +740,7 @@
}
@SmallTest
+ @Test
public void testSetDefaultDialerNoWriteSecureSettingsPermission() throws Exception {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
eq(WRITE_SECURE_SETTINGS), nullable(String.class));
@@ -720,6 +760,7 @@
}
@SmallTest
+ @Test
public void testIsVoicemailNumber() throws Exception {
String vmNumber = "010";
makeAccountsVisibleToAllUsers(TEL_PA_HANDLE_CURRENT);
@@ -731,6 +772,7 @@
}
@SmallTest
+ @Test
public void testIsVoicemailNumberAccountNotVisibleFailure() throws Exception {
String vmNumber = "010";
@@ -744,6 +786,7 @@
}
@SmallTest
+ @Test
public void testGetVoicemailNumberWithNullAccountHandle() throws Exception {
when(mFakePhoneAccountRegistrar.getPhoneAccount(isNull(PhoneAccountHandle.class),
eq(Binder.getCallingUserHandle())))
@@ -760,6 +803,7 @@
}
@SmallTest
+ @Test
public void testGetVoicemailNumberWithNonNullAccountHandle() throws Exception {
when(mFakePhoneAccountRegistrar.getPhoneAccount(eq(TEL_PA_HANDLE_CURRENT),
eq(Binder.getCallingUserHandle())))
@@ -778,6 +822,7 @@
}
@SmallTest
+ @Test
public void testGetLine1Number() throws Exception {
int subId = 58374;
String line1Number = "9482752023479";
@@ -793,6 +838,7 @@
}
@SmallTest
+ @Test
public void testEndCallWithRingingForegroundCall() throws Exception {
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.RINGING);
@@ -802,6 +848,7 @@
}
@SmallTest
+ @Test
public void testEndCallWithNonRingingForegroundCall() throws Exception {
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.ACTIVE);
@@ -811,6 +858,7 @@
}
@SmallTest
+ @Test
public void testEndCallWithNoForegroundCall() throws Exception {
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.ACTIVE);
@@ -821,11 +869,13 @@
}
@SmallTest
+ @Test
public void testEndCallWithNoCalls() throws Exception {
assertFalse(mTSIBinder.endCall());
}
@SmallTest
+ @Test
public void testAcceptRingingCall() throws Exception {
Call call = mock(Call.class);
when(mFakeCallsManager.getFirstCallWithState(anyInt())).thenReturn(call);
@@ -838,6 +888,7 @@
}
@SmallTest
+ @Test
public void testAcceptRingingCallWithValidVideoState() throws Exception {
Call call = mock(Call.class);
when(mFakeCallsManager.getFirstCallWithState(anyInt())).thenReturn(call);
@@ -851,18 +902,21 @@
}
@SmallTest
+ @Test
public void testIsInCall() throws Exception {
when(mFakeCallsManager.hasOngoingCalls()).thenReturn(true);
assertTrue(mTSIBinder.isInCall(DEFAULT_DIALER_PACKAGE));
}
@SmallTest
+ @Test
public void testNotIsInCall() throws Exception {
when(mFakeCallsManager.hasOngoingCalls()).thenReturn(false);
assertFalse(mTSIBinder.isInCall(DEFAULT_DIALER_PACKAGE));
}
@SmallTest
+ @Test
public void testIsInCallFail() throws Exception {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
anyString(), any());
@@ -876,18 +930,21 @@
}
@SmallTest
+ @Test
public void testIsInManagedCall() throws Exception {
when(mFakeCallsManager.hasOngoingManagedCalls()).thenReturn(true);
assertTrue(mTSIBinder.isInManagedCall(DEFAULT_DIALER_PACKAGE));
}
@SmallTest
+ @Test
public void testNotIsInManagedCall() throws Exception {
when(mFakeCallsManager.hasOngoingManagedCalls()).thenReturn(false);
assertFalse(mTSIBinder.isInManagedCall(DEFAULT_DIALER_PACKAGE));
}
@SmallTest
+ @Test
public void testIsInManagedCallFail() throws Exception {
doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
anyString(), any());
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index b84f9d5..f369049 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -17,6 +17,10 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
@@ -35,7 +39,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -467,8 +470,8 @@
}
private void setupConnectionServices() throws Exception {
- mConnectionServiceFixtureA = new ConnectionServiceFixture();
- mConnectionServiceFixtureB = new ConnectionServiceFixture();
+ mConnectionServiceFixtureA = new ConnectionServiceFixture(mContext);
+ mConnectionServiceFixtureB = new ConnectionServiceFixture(mContext);
mComponentContextFixture.addConnectionService(mConnectionServiceComponentNameA,
mConnectionServiceFixtureA.getTestDouble());
diff --git a/tests/src/com/android/server/telecom/tests/TelecomTestCase.java b/tests/src/com/android/server/telecom/tests/TelecomTestCase.java
index 1892b99..b656c98 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomTestCase.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomTestCase.java
@@ -18,30 +18,31 @@
import org.mockito.MockitoAnnotations;
+import android.content.Context;
import android.os.Handler;
+import android.support.test.InstrumentationRegistry;
import android.telecom.Log;
-import android.test.AndroidTestCase;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-public abstract class TelecomTestCase extends AndroidTestCase {
+public abstract class TelecomTestCase {
protected static final String TESTING_TAG = "Telecom-TEST";
+ protected Context mContext;
MockitoHelper mMockitoHelper = new MockitoHelper();
ComponentContextFixture mComponentContextFixture;
- @Override
public void setUp() throws Exception {
Log.setTag(TESTING_TAG);
- mMockitoHelper.setUp(getContext(), getClass());
+ mMockitoHelper.setUp(InstrumentationRegistry.getContext(), getClass());
mComponentContextFixture = new ComponentContextFixture();
+ mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
Log.setSessionContext(mComponentContextFixture.getTestDouble().getApplicationContext());
Log.getSessionManager().mCleanStaleSessions = null;
MockitoAnnotations.initMocks(this);
}
- @Override
public void tearDown() throws Exception {
mComponentContextFixture = null;
mMockitoHelper.tearDown();
diff --git a/tests/src/com/android/server/telecom/tests/VideoCallTests.java b/tests/src/com/android/server/telecom/tests/VideoCallTests.java
index c91f86e..97e71d1 100644
--- a/tests/src/com/android/server/telecom/tests/VideoCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/VideoCallTests.java
@@ -16,6 +16,11 @@
package com.android.server.telecom.tests;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import android.os.Process;
@@ -31,6 +36,10 @@
import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
@@ -39,13 +48,27 @@
* TODO: Add unit tests which ensure that auto-speakerphone does not occur when using a wired
* headset or a bluetooth headset.
*/
+@RunWith(JUnit4.class)
public class VideoCallTests extends TelecomSystemTest {
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
/**
* Tests to ensure an incoming video-call is automatically routed to the speakerphone when
* the call is answered and neither a wired headset nor bluetooth headset are connected.
*/
@MediumTest
+ @Test
public void testAutoSpeakerphoneIncomingBidirectional() throws Exception {
// Start an incoming video call.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -62,6 +85,7 @@
* party dialer to answer an incoming video call a a one-way video call.
*/
@MediumTest
+ @Test
public void testAutoSpeakerphoneIncomingReceiveOnly() throws Exception {
// Start an incoming video call.
IdPair ids = startAndMakeActiveIncomingCall("650-555-1212",
@@ -76,6 +100,7 @@
* in speaker mode.
*/
@MediumTest
+ @Test
public void testAutoSpeakerphoneOutgoingBidirectional() throws Exception {
// Start an incoming video call.
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212",
@@ -91,6 +116,7 @@
* APIs do and a third party incall UI could choose to support that.
*/
@MediumTest
+ @Test
public void testAutoSpeakerphoneOutgoingTransmitOnly() throws Exception {
// Start an incoming video call.
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212",
@@ -106,6 +132,7 @@
* APIs do and a third party incall UI could choose to support that.
*/
@MediumTest
+ @Test
public void testNoAutoSpeakerphoneOnOutgoing() throws Exception {
// Start an incoming video call.
IdPair ids = startAndMakeActiveOutgoingCall("650-555-1212",
@@ -119,6 +146,7 @@
* Tests to ensure an incoming audio-only call is routed to the earpiece.
*/
@MediumTest
+ @Test
public void testNoAutoSpeakerphoneOnIncoming() throws Exception {
// Start an incoming video call.
@@ -134,6 +162,7 @@
* video calling. This is important for the call log.
*/
@LargeTest
+ @Test
public void testIncomingVideoCallMissedCheckVideoHistory() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA);
@@ -150,6 +179,7 @@
* video calling. This is important for the call log.
*/
@LargeTest
+ @Test
public void testIncomingVideoCallRejectedCheckVideoHistory() throws Exception {
IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA);
@@ -167,6 +197,7 @@
* video calling. This is important for the call log.
*/
@LargeTest
+ @Test
public void testOutgoingVideoCallCanceledCheckVideoHistory() throws Exception {
IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
mConnectionServiceFixtureA, Process.myUserHandle(),
@@ -184,6 +215,7 @@
* video calling. This is important for the call log.
*/
@LargeTest
+ @Test
public void testOutgoingVideoCallRejectedCheckVideoHistory() throws Exception {
IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
mConnectionServiceFixtureA, Process.myUserHandle(),
@@ -201,6 +233,7 @@
* shows that the call was audio only. This is important for the call log.
*/
@LargeTest
+ @Test
public void testOutgoingVideoCallAnsweredAsAudio() throws Exception {
IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(),
mConnectionServiceFixtureA, Process.myUserHandle(),
diff --git a/tests/src/com/android/server/telecom/tests/VideoProfileTest.java b/tests/src/com/android/server/telecom/tests/VideoProfileTest.java
index 8e972e6..6acadf7 100644
--- a/tests/src/com/android/server/telecom/tests/VideoProfileTest.java
+++ b/tests/src/com/android/server/telecom/tests/VideoProfileTest.java
@@ -16,15 +16,24 @@
package com.android.server.telecom.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.telecom.VideoProfile;
-import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
/**
* Unit tests for the {@link android.telecom.VideoProfile} class.
*/
-public class VideoProfileTest extends AndroidTestCase {
+@RunWith(JUnit4.class)
+public class VideoProfileTest extends TelecomTestCase {
@SmallTest
+ @Test
public void testToString() {
assertEquals("Audio Only", VideoProfile.videoStateToString(VideoProfile.STATE_AUDIO_ONLY));
assertEquals("Audio Tx", VideoProfile.videoStateToString(VideoProfile.STATE_TX_ENABLED));
@@ -42,6 +51,7 @@
}
@SmallTest
+ @Test
public void testIsAudioOnly() {
assertFalse(VideoProfile.isAudioOnly(VideoProfile.STATE_RX_ENABLED));
assertFalse(VideoProfile.isAudioOnly(VideoProfile.STATE_TX_ENABLED));
diff --git a/tests/src/com/android/server/telecom/tests/VideoProviderTest.java b/tests/src/com/android/server/telecom/tests/VideoProviderTest.java
index 3234c1f..75dc36f 100644
--- a/tests/src/com/android/server/telecom/tests/VideoProviderTest.java
+++ b/tests/src/com/android/server/telecom/tests/VideoProviderTest.java
@@ -16,10 +16,13 @@
package com.android.server.telecom.tests;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.internal.exceptions.ExceptionIncludingMockitoWarnings;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -46,7 +49,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static android.test.MoreAsserts.assertEquals;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
@@ -56,17 +59,16 @@
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
/**
* Performs tests of the {@link VideoProvider} and {@link VideoCall} APIs. Ensures that requests
* sent from an InCallService are routed through Telecom to a VideoProvider, and that callbacks are
* correctly routed.
*/
+@RunWith(JUnit4.class)
public class VideoProviderTest extends TelecomSystemTest {
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 90;
@@ -89,6 +91,7 @@
};
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
mContext = mComponentContextFixture.getTestDouble().getApplicationContext();
@@ -121,6 +124,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
super.tearDown();
}
@@ -131,6 +135,7 @@
* APIS.
*/
@MediumTest
+ @Test
public void testCameraChange() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -165,6 +170,7 @@
* change from a non-permitted caller is ignored.
*/
@MediumTest
+ @Test
public void testCameraChangePermissionFail() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback).onCallSessionEvent(anyInt());
@@ -193,6 +199,7 @@
* change from a non-permitted caller is ignored.
*/
@MediumTest
+ @Test
public void testCameraChangeAppOpsFail() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback).onCallSessionEvent(anyInt());
@@ -222,6 +229,7 @@
* of a CAMERA_PERMISSION_ERROR.
*/
@MediumTest
+ @Test
public void testCameraChangeAppOpsBelowNMR1Fail() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback).onCallSessionEvent(anyInt());
@@ -251,6 +259,7 @@
* change from a background user is not permitted.
*/
@MediumTest
+ @Test
public void testCameraChangeUserFail() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback).onCallSessionEvent(anyInt());
@@ -278,6 +287,7 @@
* caller can null out the camera, even if they do not have camera permission.
*/
@MediumTest
+ @Test
public void testCameraChangeNullNoPermission() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback).onCallSessionEvent(anyInt());
@@ -306,6 +316,7 @@
* {@link VideoProvider#onSetPreviewSurface(Surface)} APIs.
*/
@MediumTest
+ @Test
public void testSetPreviewSurface() throws Exception {
final Surface surface = new Surface(new SurfaceTexture(1));
mVideoCall.setPreviewSurface(surface);
@@ -332,6 +343,7 @@
* {@link VideoProvider#onSetDisplaySurface(Surface)} APIs.
*/
@MediumTest
+ @Test
public void testSetDisplaySurface() throws Exception {
final Surface surface = new Surface(new SurfaceTexture(1));
mVideoCall.setDisplaySurface(surface);
@@ -358,6 +370,7 @@
* {@link VideoProvider#onSetDeviceOrientation(int)} APIs.
*/
@MediumTest
+ @Test
public void testSetDeviceOrientation() throws Exception {
mVideoCall.setDeviceOrientation(ORIENTATION_0);
@@ -382,6 +395,7 @@
* Tests the {@link VideoCall#setZoom(float)} and {@link VideoProvider#onSetZoom(float)} APIs.
*/
@MediumTest
+ @Test
public void testSetZoom() throws Exception {
mVideoCall.setZoom(ZOOM_LEVEL);
@@ -404,6 +418,7 @@
* peer accepts as-is.
*/
@MediumTest
+ @Test
public void testSessionModifyRequest() throws Exception {
VideoProfile requestProfile = new VideoProfile(VideoProfile.STATE_BIDIRECTIONAL);
@@ -442,6 +457,7 @@
* and {@link VideoProvider#onSendSessionModifyResponse(VideoProfile)} APIs.
*/
@MediumTest
+ @Test
public void testSessionModifyResponse() throws Exception {
VideoProfile sessionModifyResponse = new VideoProfile(VideoProfile.STATE_TX_ENABLED);
@@ -463,6 +479,7 @@
* {@link VideoCall.Callback#onCameraCapabilitiesChanged(CameraCapabilities)} APIs.
*/
@MediumTest
+ @Test
public void testRequestCameraCapabilities() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -481,6 +498,7 @@
* {@link VideoProvider#onSetPauseImage(Uri)} APIs.
*/
@MediumTest
+ @Test
public void testSetPauseImage() throws Exception {
final Uri testUri = Uri.fromParts("file", "test.jpg", null);
mVideoCall.setPauseImage(testUri);
@@ -500,6 +518,7 @@
* {@link VideoCall.Callback#onCallDataUsageChanged(long)} APIs.
*/
@MediumTest
+ @Test
public void testRequestDataUsage() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -518,6 +537,7 @@
* {@link VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)} APIs.
*/
@MediumTest
+ @Test
public void testReceiveSessionModifyRequest() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -541,6 +561,7 @@
* {@link VideoCall.Callback#onCallSessionEvent(int)} APIs.
*/
@MediumTest
+ @Test
public void testSessionEvent() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -560,6 +581,7 @@
* {@link VideoCall.Callback#onPeerDimensionsChanged(int, int)} APIs.
*/
@MediumTest
+ @Test
public void testPeerDimensionChange() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)
@@ -580,6 +602,7 @@
* {@link VideoCall.Callback#onVideoQualityChanged(int)} APIs.
*/
@MediumTest
+ @Test
public void testVideoQualityChange() throws Exception {
// Wait until the callback has been received before performing verification.
doAnswer(mVerification).when(mVideoCallCallback)