Test the getter methods of Conference API's.
1. Added a method to verify the various public getter methods of the
Conference API's in the Conference test.
2. Minor Bug fix in the existing Connection test.
BUG: 20303674
Change-Id: Ie601a69b9032ab5c86465355765d999da08807fd
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 0abf61f..d8b9904 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -451,7 +451,7 @@
assertEquals(connection.getConferenceables(), confConnections);
}
- void addAndVerifyConferenceCall(Call call1, Call call2) {
+ MockConference addAndVerifyConferenceCall(Call call1, Call call2) {
assertEquals("Lock should have no permits!", 0, mInCallCallbacks.lock.availablePermits());
int currentConfCallCount = 0;
if (mInCallCallbacks.getService() != null) {
@@ -480,6 +480,8 @@
assertEquals("InCallService should contain 1 more call after adding a conf call.",
currentConfCallCount + 1,
mInCallCallbacks.getService().getConferenceCallCount());
+ // Return the newly created conference object to the caller
+ return connectionService.conferences.get(currentConfCallCount);
}
void splitFromConferenceCall(Call call1) {
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
index 1651015..cb53cb9 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
@@ -23,6 +23,7 @@
import android.telecom.ConnectionRequest;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telecom.VideoProfile;
/**
* Extended suite of tests that use {@link CtsConnectionService} and {@link MockInCallService} to
@@ -33,10 +34,28 @@
Connection.CAPABILITY_DISCONNECT_FROM_CONFERENCE | Connection.CAPABILITY_HOLD |
Connection.CAPABILITY_MERGE_CONFERENCE | Connection.CAPABILITY_SWAP_CONFERENCE;
- private Call mCall1;
- private Call mCall2;
+ private Call mCall1, mCall2;
+ private MockConnection mConnection1, mConnection2;
MockInCallService mInCallService;
+ private void verifyConferenceObject(MockConference conferenceObject, MockConnection connection1,
+ MockConnection connection2) {
+ assertNull(conferenceObject.getCallAudioState());
+ assertTrue(conferenceObject.getConferenceableConnections().isEmpty());
+ assertEquals(connection1.getConnectionCapabilities(),
+ conferenceObject.getConnectionCapabilities());
+ assertEquals(connection1.getState(), conferenceObject.getState());
+ assertEquals(connection2.getState(), conferenceObject.getState());
+ assertTrue(conferenceObject.getConnections().contains(connection1));
+ assertTrue(conferenceObject.getConnections().contains(connection2));
+ assertEquals(connection1.getDisconnectCause(), conferenceObject.getDisconnectCause());
+ assertEquals(connection1.getExtras(), conferenceObject.getExtras());
+ assertEquals(connection1.getPhoneAccountHandle(), conferenceObject.getPhoneAccountHandle());
+ assertEquals(connection1.getStatusHints(), conferenceObject.getStatusHints());
+ assertEquals(VideoProfile.STATE_AUDIO_ONLY, conferenceObject.getVideoState());
+ assertNull(conferenceObject.getVideoProvider());
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -60,12 +79,12 @@
}, FLAG_REGISTER | FLAG_ENABLE);
placeAndVerifyCall();
- verifyConnectionForOutgoingCall(0);
+ mConnection1 = verifyConnectionForOutgoingCall(0);
mInCallService = mInCallCallbacks.getService();
mCall1 = mInCallService.getLastCall();
placeAndVerifyCall();
- verifyConnectionForOutgoingCall(1);
+ mConnection2 = verifyConnectionForOutgoingCall(1);
mCall2 = mInCallService.getLastCall();
setAndVerifyConferenceablesForOutgoingConnection(0);
@@ -77,7 +96,9 @@
if (!shouldTestTelecom(mContext)) {
return;
}
- addAndVerifyConferenceCall(mCall1, mCall2);
+ final MockConference conferenceObject = addAndVerifyConferenceCall(mCall1, mCall2);
+ verifyConferenceObject(conferenceObject, mConnection1, mConnection2);
+
final Call conf = mInCallService.getLastConferenceCall();
if (mCall1.getParent() != conf || mCall2.getParent() != conf) {
@@ -92,11 +113,15 @@
if (!shouldTestTelecom(mContext)) {
return;
}
+ final MockConference conferenceObject = addAndVerifyConferenceCall(mCall1, mCall2);
+ verifyConferenceObject(conferenceObject, mConnection1, mConnection2);
- addAndVerifyConferenceCall(mCall1, mCall2);
final Call conf = mInCallService.getLastConferenceCall();
- splitFromConferenceCall(mCall1);
+ if (!(mCall1.getParent() == conf) && (conf.getChildren().contains(mCall1))) {
+ fail("Call 1 not conferenced");
+ }
+ splitFromConferenceCall(mCall1);
if ((mCall1.getParent() == conf) || (conf.getChildren().contains(mCall1))) {
fail("Call 1 should not be still conferenced");
}
@@ -106,8 +131,9 @@
if (!shouldTestTelecom(mContext)) {
return;
}
+ final MockConference conferenceObject = addAndVerifyConferenceCall(mCall1, mCall2);
+ verifyConferenceObject(conferenceObject, mConnection1, mConnection2);
- addAndVerifyConferenceCall(mCall1, mCall2);
final Call conf = mInCallService.getLastConferenceCall();
conf.hold();
@@ -125,8 +151,9 @@
if (!shouldTestTelecom(mContext)) {
return;
}
+ final MockConference conferenceObject = addAndVerifyConferenceCall(mCall1, mCall2);
+ verifyConferenceObject(conferenceObject, mConnection1, mConnection2);
- addAndVerifyConferenceCall(mCall1, mCall2);
final Call conf = mInCallService.getLastConferenceCall();
conf.mergeConference();
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
index 5f271e8..c9fbbe5 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
@@ -265,7 +265,7 @@
public void testStateToString() {
assertEquals("INITIALIZING", Connection.stateToString(Connection.STATE_INITIALIZING));
assertEquals("NEW", Connection.stateToString(Connection.STATE_NEW));
- assertEquals("RINGING", Connection.stateToString(Connection.STATE_INITIALIZING));
+ assertEquals("RINGING", Connection.stateToString(Connection.STATE_RINGING));
assertEquals("DIALING", Connection.stateToString(Connection.STATE_DIALING));
assertEquals("ACTIVE", Connection.stateToString(Connection.STATE_ACTIVE));
assertEquals("HOLDING", Connection.stateToString(Connection.STATE_HOLDING));
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConference.java b/tests/tests/telecom/src/android/telecom/cts/MockConference.java
index ffc188f..138fd4a 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConference.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConference.java
@@ -32,11 +32,14 @@
super(phoneAccount);
}
- public MockConference(Connection a, Connection b) {
- super(null);
- setConnectionCapabilities(a.getConnectionCapabilities());
+ public MockConference(MockConnection a, MockConnection b) {
+ super(a.getPhoneAccountHandle());
addConnection(a);
addConnection(b);
+ // a is the primary connection, so inherit the properties from it.
+ setConnectionCapabilities(a.getConnectionCapabilities());
+ setStatusHints(a.getStatusHints());
+ setExtras(a.getExtras());
setActive();
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
index ee6918c..5c35c1c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
@@ -46,6 +46,7 @@
public List<MockConnection> outgoingConnections = new ArrayList<MockConnection>();
public List<MockConnection> incomingConnections = new ArrayList<MockConnection>();
public List<RemoteConnection> remoteConnections = new ArrayList<RemoteConnection>();
+ public List<MockConference> conferences = new ArrayList<MockConference>();
@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
@@ -82,8 +83,10 @@
public void onConference(Connection connection1, Connection connection2) {
// Make sure that these connections are already not conferenced.
if (connection1.getConference() == null && connection2.getConference() == null) {
- MockConference conference = new MockConference(connection1, connection2);
+ MockConference conference = new MockConference(
+ (MockConnection)connection1, (MockConnection)connection2);
CtsConnectionService.addConferenceToTelecom(conference);
+ conferences.add(conference);
}
}