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/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 7f0c800..af1ddb6 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -430,9 +430,9 @@
super(phoneAccountHandle);
- mTelecomAccountRegistry = telecomAccountRegistry;
- mFeatureFlagProxy = featureFlagProxy;
- mCarrierConfig = carrierConfig;
+ mTelecomAccountRegistry = Objects.requireNonNull(telecomAccountRegistry);
+ mFeatureFlagProxy = Objects.requireNonNull(featureFlagProxy);
+ mCarrierConfig = Objects.requireNonNull(carrierConfig);
// Specify the connection time of the conference to be the connection time of the original
// connection.
diff --git a/src/com/android/services/telephony/ImsConferenceController.java b/src/com/android/services/telephony/ImsConferenceController.java
index fa2151b..ca3bcfe 100644
--- a/src/com/android/services/telephony/ImsConferenceController.java
+++ b/src/com/android/services/telephony/ImsConferenceController.java
@@ -142,9 +142,9 @@
public ImsConferenceController(TelecomAccountRegistry telecomAccountRegistry,
TelephonyConnectionServiceProxy connectionService,
ImsConference.FeatureFlagProxy featureFlagProxy) {
- mConnectionService = connectionService;
- mTelecomAccountRegistry = telecomAccountRegistry;
- mFeatureFlagProxy = featureFlagProxy;
+ mConnectionService = Objects.requireNonNull(connectionService);
+ mTelecomAccountRegistry = Objects.requireNonNull(telecomAccountRegistry);
+ mFeatureFlagProxy = Objects.requireNonNull(featureFlagProxy);
}
void addConference(ImsConference conference) {
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