Augment tests for Connection-related APIs

Bug: 20303674

Change-Id: I4d937368c3e68dff9ce91d7ece1cbead72c082de
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 2a9a273..323190c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -581,7 +581,7 @@
 
                     @Override
                     public Object actual() {
-                        final CallAudioState state = connection.getCallAudioState();
+                        final CallAudioState state = ((Connection) connection).getCallAudioState();
                         return state == null ? null : state.getRoute();
                     }
                 },
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
index c9fbbe5..b6818c8 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionTest.java
@@ -263,6 +263,10 @@
     }
 
     public void testStateToString() {
+        if (!shouldTestTelecom(getContext())) {
+            return;
+        }
+
         assertEquals("INITIALIZING", Connection.stateToString(Connection.STATE_INITIALIZING));
         assertEquals("NEW", Connection.stateToString(Connection.STATE_NEW));
         assertEquals("RINGING", Connection.stateToString(Connection.STATE_RINGING));
@@ -272,6 +276,23 @@
         assertEquals("DISCONNECTED", Connection.stateToString(Connection.STATE_DISCONNECTED));
     }
 
+    public void testCapabilitiesToString() {
+        if (!shouldTestTelecom(getContext())) {
+            return;
+        }
+
+        assertEquals("[Capabilities: CAPABILITY_HOLD]",
+                Connection.capabilitiesToString(Connection.CAPABILITY_HOLD));
+        assertEquals("[Capabilities: CAPABILITY_MUTE]",
+                Connection.capabilitiesToString(Connection.CAPABILITY_MUTE));
+        assertEquals("[Capabilities: CAPABILITY_HOLD "
+                + "CAPABILITY_RESPOND_VIA_TEXT "
+                + "CAPABILITY_MANAGE_CONFERENCE]",
+                Connection.capabilitiesToString(Connection.CAPABILITY_HOLD
+                        | Connection.CAPABILITY_RESPOND_VIA_TEXT
+                        | Connection.CAPABILITY_MANAGE_CONFERENCE));
+    }
+
     private static Connection createConnection(final Semaphore lock) {
         BasicConnection connection = new BasicConnection();
         connection.setLock(lock);
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
index ee8708b..ad64e5c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
@@ -74,7 +74,7 @@
         final MockConnection connection = new MockConnection();
         connection.setAddress(request.getAddress(), CONNECTION_PRESENTATION);
         connection.createMockVideoProvider();
-        connection.setVideoState(request.getVideoState());
+        ((Connection) connection).setVideoState(request.getVideoState());
 
         incomingConnections.add(connection);
         lock.release();