Enable SPEAKERPHONE CTS tests.
Fix following tests by indicating that SPEAKER should not be set, thus
allowing more robust testing.
Bug: 24578220
Change-Id: Id185a89be03f5fd2693cba34ef194378cd70e03a
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 01f64b5..5773a0b 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -348,14 +348,6 @@
bug: 23827982
},
{
- description: "tests not yet ready",
- names: [
- "android.telecom.cts.OutgoingCallTest#testStartCallWithSpeakerphoneFalse_SpeakerphoneOffInCall",
- "android.telecom.cts.OutgoingCallTest#testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault"
- ],
- bug: 24067587
-},
-{
description: "protected broadcast not working",
names: [
"android.permission2.cts.ProtectedBroadcastsTest#testSendProtectedBroadcasts"
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index d7fe239..37dcd3a 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -590,6 +590,25 @@
);
}
+ void assertNotAudioRoute(final InCallService incallService, final int route) {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return new Boolean(true);
+ }
+
+ @Override
+ public Object actual() {
+ final CallAudioState state = incallService.getCallAudioState();
+ return route != state.getRoute();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "Phone's audio route should not be: " + route
+ );
+ }
+
void assertAudioRoute(final MockConnection connection, final int route) {
waitUntilConditionIsTrueOrTimeout(
new Condition() {
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index bba9a44..fa19751 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -68,15 +68,11 @@
return;
}
- AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- int expectedRoute = am.isWiredHeadsetOn() ?
- CallAudioState.ROUTE_WIRED_HEADSET : CallAudioState.ROUTE_EARPIECE;
-
final Bundle extras = new Bundle();
extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
placeAndVerifyCall(extras);
verifyConnectionForOutgoingCall();
- assertAudioRoute(mInCallCallbacks.getService(), expectedRoute);
+ assertNotAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_SPEAKER);
}
public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
@@ -85,11 +81,9 @@
}
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- int expectedRoute = am.isWiredHeadsetOn() ?
- CallAudioState.ROUTE_WIRED_HEADSET : CallAudioState.ROUTE_EARPIECE;
placeAndVerifyCall();
verifyConnectionForOutgoingCall();
- assertAudioRoute(mInCallCallbacks.getService(), expectedRoute);
+ assertNotAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_SPEAKER);
}
}