ImsConferenceControllerTest extends TelephonyTestBase
This will improve test isolation and reduce test code duplication.
Also, pretend to support Telephony calling
Bug: 365800992
Test: atest com.android.services.telephony.ImsConferenceControllerTest
Flag: EXEMPT only test + extra assertions
Change-Id: Ie350aa91555a4b74c72c2b2ada2862a28370e553
diff --git a/tests/src/com/android/TestContext.java b/tests/src/com/android/TestContext.java
index e464ad5..6e14574 100644
--- a/tests/src/com/android/TestContext.java
+++ b/tests/src/com/android/TestContext.java
@@ -212,6 +212,11 @@
}
@Override
+ public Looper getMainLooper() {
+ return Looper.getMainLooper();
+ }
+
+ @Override
public Handler getMainThreadHandler() {
return new Handler(Looper.getMainLooper());
}
diff --git a/tests/src/com/android/services/telephony/ImsConferenceControllerTest.java b/tests/src/com/android/services/telephony/ImsConferenceControllerTest.java
index b1572f1..eacb001 100644
--- a/tests/src/com/android/services/telephony/ImsConferenceControllerTest.java
+++ b/tests/src/com/android/services/telephony/ImsConferenceControllerTest.java
@@ -25,21 +25,27 @@
import static org.mockito.Mockito.when;
import android.content.ComponentName;
-import android.os.Looper;
+import android.content.pm.PackageManager;
import android.telecom.PhoneAccountHandle;
import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+import com.android.TelephonyTestBase;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
/**
* Tests the functionality in ImsConferenceController.java
*/
-
-public class ImsConferenceControllerTest {
+@RunWith(AndroidJUnit4.class)
+public class ImsConferenceControllerTest extends TelephonyTestBase {
+ @Mock
+ PackageManager mPackageManager;
@Mock
private TelephonyConnectionServiceProxy mMockTelephonyConnectionServiceProxy;
@@ -64,11 +70,14 @@
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- if (Looper.myLooper() == null) {
- Looper.prepare();
- }
- mTelecomAccountRegistry = TelecomAccountRegistry.getInstance(null);
+ super.setUp();
+
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)).thenReturn(true);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CALLING))
+ .thenReturn(true);
+
+ mTelecomAccountRegistry = TelecomAccountRegistry.getInstance(mContext);
mTestTelephonyConnectionA = new TestTelephonyConnection();
mTestTelephonyConnectionB = new TestTelephonyConnection();
@@ -79,6 +88,11 @@
mMockTelephonyConnectionServiceProxy, () -> false);
}
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
/**
* Behavior: add telephony connections B and A to conference controller,
* set status for connections, remove one call