CallAudioModeStateMachineTest.java revision fbed016fbd4cdc744f306b13fb3a2d9042d6bd5a
1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package com.android.server.telecom.tests; 18 19import android.content.Context; 20import android.media.AudioManager; 21import android.telecom.CallAudioState; 22import android.test.suitebuilder.annotation.LargeTest; 23 24import com.android.server.telecom.CallAudioManager; 25import com.android.server.telecom.CallAudioModeStateMachine; 26 27import org.mockito.Mock; 28 29import java.util.ArrayList; 30import java.util.List; 31 32import static org.mockito.Matchers.anyInt; 33import static org.mockito.Matchers.eq; 34import static org.mockito.Mockito.never; 35import static org.mockito.Mockito.reset; 36import static org.mockito.Mockito.verify; 37 38public class CallAudioModeStateMachineTest extends StateMachineTestBase<CallAudioModeStateMachine> { 39 private static class ModeTestParameters extends TestParameters { 40 public String name; 41 public int initialAudioState; // One of the explicit switch focus constants in CAMSM 42 public int messageType; // Any of the commands from the state machine 43 public CallAudioModeStateMachine.MessageArgs externalState; 44 public String expectedFinalStateName; 45 public int expectedFocus; // one of the FOCUS_* constants below 46 public int expectedMode; // NO_CHANGE, or an AudioManager.MODE_* constant 47 public int expectedRingingInteraction; // NO_CHANGE, ON, or OFF 48 public int expectedCallWaitingInteraction; // NO_CHANGE, ON, or OFF 49 50 public ModeTestParameters(String name, int initialAudioState, int messageType, 51 CallAudioModeStateMachine.MessageArgs externalState, String 52 expectedFinalStateName, int expectedFocus, int expectedMode, int 53 expectedRingingInteraction, int expectedCallWaitingInteraction) { 54 this.name = name; 55 this.initialAudioState = initialAudioState; 56 this.messageType = messageType; 57 this.externalState = externalState; 58 this.expectedFinalStateName = expectedFinalStateName; 59 this.expectedFocus = expectedFocus; 60 this.expectedMode = expectedMode; 61 this.expectedRingingInteraction = expectedRingingInteraction; 62 this.expectedCallWaitingInteraction = expectedCallWaitingInteraction; 63 } 64 65 @Override 66 public String toString() { 67 return "ModeTestParameters{" + 68 "name='" + name + '\'' + 69 ", initialAudioState=" + initialAudioState + 70 ", messageType=" + messageType + 71 ", externalState=" + externalState + 72 ", expectedFinalStateName='" + expectedFinalStateName + '\'' + 73 ", expectedFocus=" + expectedFocus + 74 ", expectedMode=" + expectedMode + 75 ", expectedRingingInteraction=" + expectedRingingInteraction + 76 ", expectedCallWaitingInteraction=" + expectedCallWaitingInteraction + 77 '}'; 78 } 79 } 80 81 private static final int FOCUS_NO_CHANGE = 0; 82 private static final int FOCUS_RING = 1; 83 private static final int FOCUS_VOICE = 2; 84 private static final int FOCUS_OFF = 3; 85 86 private static final int NO_CHANGE = -1; 87 private static final int ON = 0; 88 private static final int OFF = 1; 89 90 @Mock private AudioManager mAudioManager; 91 @Mock private CallAudioManager mCallAudioManager; 92 93 @Override 94 public void setUp() throws Exception { 95 super.setUp(); 96 mContext = mComponentContextFixture.getTestDouble().getApplicationContext(); 97 } 98 99 @LargeTest 100 public void testTransitions() throws Throwable { 101 List<ModeTestParameters> testCases = generateTestCases(); 102 parametrizedTestStateMachine(testCases); 103 } 104 105 private List<ModeTestParameters> generateTestCases() { 106 List<ModeTestParameters> result = new ArrayList<>(); 107 result.add(new ModeTestParameters( 108 "New active/dialing call with no other calls when unfocused", 109 CallAudioModeStateMachine.ABANDON_FOCUS_FOR_TESTING, // initialAudioState 110 CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType 111 new CallAudioModeStateMachine.MessageArgs( 112 true, // hasActiveOrDialingCalls 113 false, // hasRingingCalls 114 false, // hasHoldingCalls 115 false, // isTonePlaying 116 false, // foregroundCallIsVoip 117 null // session 118 ), 119 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 120 FOCUS_VOICE, // expectedFocus 121 AudioManager.MODE_IN_CALL, // expectedMode 122 NO_CHANGE, // expectedRingingInteraction 123 NO_CHANGE // expectedCallWaitingInteraction 124 )); 125 126 result.add(new ModeTestParameters( 127 "New active/dialing voip call with no other calls when unfocused", 128 CallAudioModeStateMachine.ABANDON_FOCUS_FOR_TESTING, // initialAudioState 129 CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType 130 new CallAudioModeStateMachine.MessageArgs( 131 true, // hasActiveOrDialingCalls 132 false, // hasRingingCalls 133 false, // hasHoldingCalls 134 false, // isTonePlaying 135 true, // foregroundCallIsVoip 136 null // session 137 ), 138 CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName 139 FOCUS_VOICE, // expectedFocus 140 AudioManager.MODE_IN_COMMUNICATION, // expectedMode 141 NO_CHANGE, // expectedRingingInteraction 142 NO_CHANGE // expectedCallWaitingInteraction 143 )); 144 145 result.add(new ModeTestParameters( 146 "New ringing call with no other calls when unfocused", 147 CallAudioModeStateMachine.ABANDON_FOCUS_FOR_TESTING, // initialAudioState 148 CallAudioModeStateMachine.NEW_RINGING_CALL, // messageType 149 new CallAudioModeStateMachine.MessageArgs( 150 false, // hasActiveOrDialingCalls 151 true, // hasRingingCalls 152 false, // hasHoldingCalls 153 false, // isTonePlaying 154 false, // foregroundCallIsVoip 155 null // session 156 ), 157 CallAudioModeStateMachine.RING_STATE_NAME, // expectedFinalStateName 158 FOCUS_RING, // expectedFocus 159 AudioManager.MODE_RINGTONE, // expectedMode 160 ON, // expectedRingingInteraction 161 OFF // expectedCallWaitingInteraction 162 )); 163 164 result.add(new ModeTestParameters( 165 "New ringing call coming in on top of active/dialing call", 166 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 167 CallAudioModeStateMachine.NEW_RINGING_CALL, // messageType 168 new CallAudioModeStateMachine.MessageArgs( 169 true, // hasActiveOrDialingCalls 170 true, // hasRingingCalls 171 false, // hasHoldingCalls 172 false, // isTonePlaying 173 false, // foregroundCallIsVoip 174 null // session 175 ), 176 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 177 NO_CHANGE, // expectedFocus 178 NO_CHANGE, // expectedMode 179 NO_CHANGE, // expectedRingingInteraction 180 ON // expectedCallWaitingInteraction 181 )); 182 183 result.add(new ModeTestParameters( 184 "Ringing call becomes active, part 1", 185 CallAudioModeStateMachine.ENTER_RING_FOCUS_FOR_TESTING, // initialAudioState 186 CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType 187 new CallAudioModeStateMachine.MessageArgs( 188 true, // hasActiveOrDialingCalls 189 false, // hasRingingCalls 190 false, // hasHoldingCalls 191 false, // isTonePlaying 192 false, // foregroundCallIsVoip 193 null // session 194 ), 195 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 196 FOCUS_VOICE, // expectedFocus 197 AudioManager.MODE_IN_CALL, // expectedMode 198 OFF, // expectedRingingInteraction 199 NO_CHANGE // expectedCallWaitingInteraction 200 )); 201 202 result.add(new ModeTestParameters( 203 "Ringing call becomes active, part 2", 204 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 205 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 206 new CallAudioModeStateMachine.MessageArgs( 207 true, // hasActiveOrDialingCalls 208 false, // hasRingingCalls 209 false, // hasHoldingCalls 210 false, // isTonePlaying 211 false, // foregroundCallIsVoip 212 null // session 213 ), 214 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 215 NO_CHANGE, // expectedFocus 216 NO_CHANGE, // expectedMode 217 NO_CHANGE, // expectedRingingInteraction 218 NO_CHANGE // expectedCallWaitingInteraction 219 )); 220 221 result.add(new ModeTestParameters( 222 "Active call disconnects, but tone is playing", 223 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 224 CallAudioModeStateMachine.NO_MORE_ACTIVE_OR_DIALING_CALLS, // messageType 225 new CallAudioModeStateMachine.MessageArgs( 226 false, // hasActiveOrDialingCalls 227 false, // hasRingingCalls 228 false, // hasHoldingCalls 229 true, // isTonePlaying 230 false, // foregroundCallIsVoip 231 null // session 232 ), 233 CallAudioModeStateMachine.TONE_HOLD_STATE_NAME, // expectedFinalStateName 234 FOCUS_VOICE, // expectedFocus 235 AudioManager.MODE_IN_CALL, // expectedMode 236 NO_CHANGE, // expectedRingingInteraction 237 NO_CHANGE // expectedCallWaitingInteraction 238 )); 239 240 result.add(new ModeTestParameters( 241 "Tone stops playing, with no active calls", 242 CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState 243 CallAudioModeStateMachine.TONE_STOPPED_PLAYING, // messageType 244 new CallAudioModeStateMachine.MessageArgs( 245 false, // hasActiveOrDialingCalls 246 false, // hasRingingCalls 247 false, // hasHoldingCalls 248 false, // isTonePlaying 249 false, // foregroundCallIsVoip 250 null // session 251 ), 252 CallAudioModeStateMachine.UNFOCUSED_STATE_NAME, // expectedFinalStateName 253 FOCUS_OFF, // expectedFocus 254 AudioManager.MODE_NORMAL, // expectedMode 255 NO_CHANGE, // expectedRingingInteraction 256 NO_CHANGE // expectedCallWaitingInteraction 257 )); 258 259 result.add(new ModeTestParameters( 260 "Ringing call disconnects", 261 CallAudioModeStateMachine.ENTER_RING_FOCUS_FOR_TESTING, // initialAudioState 262 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 263 new CallAudioModeStateMachine.MessageArgs( 264 false, // hasActiveOrDialingCalls 265 false, // hasRingingCalls 266 false, // hasHoldingCalls 267 false, // isTonePlaying 268 false, // foregroundCallIsVoip 269 null // session 270 ), 271 CallAudioModeStateMachine.UNFOCUSED_STATE_NAME, // expectedFinalStateName 272 FOCUS_OFF, // expectedFocus 273 AudioManager.MODE_NORMAL, // expectedMode 274 OFF, // expectedRingingInteraction 275 NO_CHANGE // expectedCallWaitingInteraction 276 )); 277 278 result.add(new ModeTestParameters( 279 "Call-waiting call disconnects", 280 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 281 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 282 new CallAudioModeStateMachine.MessageArgs( 283 true, // hasActiveOrDialingCalls 284 false, // hasRingingCalls 285 false, // hasHoldingCalls 286 true, // isTonePlaying 287 false, // foregroundCallIsVoip 288 null // session 289 ), 290 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 291 FOCUS_NO_CHANGE, // expectedFocus 292 NO_CHANGE, // expectedMode 293 NO_CHANGE, // expectedRingingInteraction 294 OFF // expectedCallWaitingInteraction 295 )); 296 297 result.add(new ModeTestParameters( 298 "Call is placed on hold - 1", 299 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 300 CallAudioModeStateMachine.NO_MORE_ACTIVE_OR_DIALING_CALLS, // messageType 301 new CallAudioModeStateMachine.MessageArgs( 302 false, // hasActiveOrDialingCalls 303 false, // hasRingingCalls 304 true, // hasHoldingCalls 305 false, // isTonePlaying 306 false, // foregroundCallIsVoip 307 null // session 308 ), 309 CallAudioModeStateMachine.TONE_HOLD_STATE_NAME, // expectedFinalStateName 310 FOCUS_VOICE, // expectedFocus 311 AudioManager.MODE_IN_CALL, // expectedMode 312 NO_CHANGE, // expectedRingingInteraction 313 NO_CHANGE // expectedCallWaitingInteraction 314 )); 315 316 result.add(new ModeTestParameters( 317 "Call is placed on hold - 2", 318 CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState 319 CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType 320 new CallAudioModeStateMachine.MessageArgs( 321 false, // hasActiveOrDialingCalls 322 false, // hasRingingCalls 323 true, // hasHoldingCalls 324 false, // isTonePlaying 325 false, // foregroundCallIsVoip 326 null // session 327 ), 328 CallAudioModeStateMachine.TONE_HOLD_STATE_NAME, // expectedFinalStateName 329 FOCUS_NO_CHANGE, // expectedFocus 330 NO_CHANGE, // expectedMode 331 NO_CHANGE, // expectedRingingInteraction 332 NO_CHANGE // expectedCallWaitingInteraction 333 )); 334 335 result.add(new ModeTestParameters( 336 "Call is taken off hold - 1", 337 CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState 338 CallAudioModeStateMachine.NO_MORE_HOLDING_CALLS, // messageType 339 new CallAudioModeStateMachine.MessageArgs( 340 true, // hasActiveOrDialingCalls 341 false, // hasRingingCalls 342 false, // hasHoldingCalls 343 false, // isTonePlaying 344 false, // foregroundCallIsVoip 345 null // session 346 ), 347 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 348 FOCUS_VOICE, // expectedFocus 349 AudioManager.MODE_IN_CALL, // expectedMode 350 NO_CHANGE, // expectedRingingInteraction 351 NO_CHANGE // expectedCallWaitingInteraction 352 )); 353 354 result.add(new ModeTestParameters( 355 "Call is taken off hold - 2", 356 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 357 CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType 358 new CallAudioModeStateMachine.MessageArgs( 359 true, // hasActiveOrDialingCalls 360 false, // hasRingingCalls 361 false, // hasHoldingCalls 362 false, // isTonePlaying 363 false, // foregroundCallIsVoip 364 null // session 365 ), 366 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 367 FOCUS_NO_CHANGE, // expectedFocus 368 NO_CHANGE, // expectedMode 369 NO_CHANGE, // expectedRingingInteraction 370 NO_CHANGE // expectedCallWaitingInteraction 371 )); 372 373 result.add(new ModeTestParameters( 374 "Active call disconnects while there's a call-waiting call", 375 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 376 CallAudioModeStateMachine.NO_MORE_ACTIVE_OR_DIALING_CALLS, // messageType 377 new CallAudioModeStateMachine.MessageArgs( 378 false, // hasActiveOrDialingCalls 379 true, // hasRingingCalls 380 false, // hasHoldingCalls 381 true, // isTonePlaying 382 false, // foregroundCallIsVoip 383 null // session 384 ), 385 CallAudioModeStateMachine.RING_STATE_NAME, // expectedFinalStateName 386 FOCUS_RING, // expectedFocus 387 AudioManager.MODE_RINGTONE, // expectedMode 388 ON, // expectedRingingInteraction 389 OFF // expectedCallWaitingInteraction 390 )); 391 392 result.add(new ModeTestParameters( 393 "New dialing call when there's a call on hold", 394 CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState 395 CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType 396 new CallAudioModeStateMachine.MessageArgs( 397 true, // hasActiveOrDialingCalls 398 false, // hasRingingCalls 399 true, // hasHoldingCalls 400 false, // isTonePlaying 401 false, // foregroundCallIsVoip 402 null // session 403 ), 404 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 405 FOCUS_VOICE, // expectedFocus 406 AudioManager.MODE_IN_CALL, // expectedMode 407 NO_CHANGE, // expectedRingingInteraction 408 NO_CHANGE // expectedCallWaitingInteraction 409 )); 410 411 result.add(new ModeTestParameters( 412 "Ringing call disconnects with a holding call in the background", 413 CallAudioModeStateMachine.ENTER_RING_FOCUS_FOR_TESTING, // initialAudioState 414 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 415 new CallAudioModeStateMachine.MessageArgs( 416 false, // hasActiveOrDialingCalls 417 false, // hasRingingCalls 418 true, // hasHoldingCalls 419 false, // isTonePlaying 420 false, // foregroundCallIsVoip 421 null // session 422 ), 423 CallAudioModeStateMachine.TONE_HOLD_STATE_NAME, // expectedFinalStateName 424 FOCUS_VOICE, // expectedFocus 425 AudioManager.MODE_NORMAL, // expectedMode -- we're expecting this because 426 // mMostRecentMode hasn't been set properly. 427 OFF, // expectedRingingInteraction 428 NO_CHANGE // expectedCallWaitingInteraction 429 )); 430 431 result.add(new ModeTestParameters( 432 "Foreground call transitions from sim to voip", 433 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 434 CallAudioModeStateMachine.FOREGROUND_VOIP_MODE_CHANGE, // messageType 435 new CallAudioModeStateMachine.MessageArgs( 436 true, // hasActiveOrDialingCalls 437 false, // hasRingingCalls 438 false, // hasHoldingCalls 439 false, // isTonePlaying 440 true, // foregroundCallIsVoip 441 null // session 442 ), 443 CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName 444 FOCUS_VOICE, // expectedFocus 445 AudioManager.MODE_IN_COMMUNICATION, // expectedMode 446 NO_CHANGE, // expectedRingingInteraction 447 NO_CHANGE // expectedCallWaitingInteraction 448 )); 449 450 result.add(new ModeTestParameters( 451 "Foreground call transitions from voip to sim", 452 CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState 453 CallAudioModeStateMachine.FOREGROUND_VOIP_MODE_CHANGE, // messageType 454 new CallAudioModeStateMachine.MessageArgs( 455 true, // hasActiveOrDialingCalls 456 false, // hasRingingCalls 457 false, // hasHoldingCalls 458 false, // isTonePlaying 459 false, // foregroundCallIsVoip 460 null // session 461 ), 462 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 463 FOCUS_VOICE, // expectedFocus 464 AudioManager.MODE_IN_CALL, // expectedMode 465 NO_CHANGE, // expectedRingingInteraction 466 NO_CHANGE // expectedCallWaitingInteraction 467 )); 468 469 result.add(new ModeTestParameters( 470 "Call-waiting hangs up before being answered, with another sim call in " + 471 "foreground", 472 CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState 473 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 474 new CallAudioModeStateMachine.MessageArgs( 475 true, // hasActiveOrDialingCalls 476 false, // hasRingingCalls 477 false, // hasHoldingCalls 478 true, // isTonePlaying 479 false, // foregroundCallIsVoip 480 null // session 481 ), 482 CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName 483 FOCUS_NO_CHANGE, // expectedFocus 484 NO_CHANGE, // expectedMode 485 NO_CHANGE, // expectedRingingInteraction 486 OFF // expectedCallWaitingInteraction 487 )); 488 489 result.add(new ModeTestParameters( 490 "Call-waiting hangs up before being answered, with another voip call in " + 491 "foreground", 492 CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState 493 CallAudioModeStateMachine.NO_MORE_RINGING_CALLS, // messageType 494 new CallAudioModeStateMachine.MessageArgs( 495 true, // hasActiveOrDialingCalls 496 false, // hasRingingCalls 497 false, // hasHoldingCalls 498 true, // isTonePlaying 499 true, // foregroundCallIsVoip 500 null // session 501 ), 502 CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName 503 FOCUS_NO_CHANGE, // expectedFocus 504 NO_CHANGE, // expectedMode 505 NO_CHANGE, // expectedRingingInteraction 506 OFF // expectedCallWaitingInteraction 507 )); 508 509 return result; 510 } 511 512 @Override 513 protected void runParametrizedTestCase(TestParameters _params) { 514 ModeTestParameters params = (ModeTestParameters) _params; 515 CallAudioModeStateMachine sm = new CallAudioModeStateMachine(mAudioManager); 516 sm.setCallAudioManager(mCallAudioManager); 517 sm.sendMessage(params.initialAudioState); 518 waitForStateMachineActionCompletion(sm, CallAudioModeStateMachine.RUN_RUNNABLE); 519 520 resetMocks(); 521 522 sm.sendMessage(params.messageType, params.externalState); 523 waitForStateMachineActionCompletion(sm, CallAudioModeStateMachine.RUN_RUNNABLE); 524 525 assertEquals(params.expectedFinalStateName, sm.getCurrentStateName()); 526 527 switch (params.expectedFocus) { 528 case FOCUS_NO_CHANGE: 529 verify(mAudioManager, never()).requestAudioFocusForCall(anyInt(), anyInt()); 530 break; 531 case FOCUS_OFF: 532 verify(mAudioManager).abandonAudioFocusForCall(); 533 break; 534 case FOCUS_RING: 535 verify(mAudioManager).requestAudioFocusForCall( 536 eq(AudioManager.STREAM_RING), anyInt()); 537 break; 538 case FOCUS_VOICE: 539 verify(mAudioManager).requestAudioFocusForCall( 540 eq(AudioManager.STREAM_VOICE_CALL), anyInt()); 541 break; 542 } 543 544 if (params.expectedMode != NO_CHANGE) { 545 verify(mAudioManager).setMode(eq(params.expectedMode)); 546 } else { 547 verify(mAudioManager, never()).setMode(anyInt()); 548 } 549 550 switch (params.expectedRingingInteraction) { 551 case NO_CHANGE: 552 verify(mCallAudioManager, never()).startRinging(); 553 verify(mCallAudioManager, never()).stopRinging(); 554 break; 555 case ON: 556 verify(mCallAudioManager).startRinging(); 557 break; 558 case OFF: 559 verify(mCallAudioManager).stopRinging(); 560 break; 561 } 562 563 switch (params.expectedCallWaitingInteraction) { 564 case NO_CHANGE: 565 verify(mCallAudioManager, never()).startCallWaiting(); 566 verify(mCallAudioManager, never()).stopCallWaiting(); 567 break; 568 case ON: 569 verify(mCallAudioManager).startCallWaiting(); 570 break; 571 case OFF: 572 verify(mCallAudioManager).stopCallWaiting(); 573 break; 574 } 575 } 576 577 private void resetMocks() { 578 reset(mCallAudioManager, mAudioManager); 579 } 580} 581