324 { |
324 { |
325 iTelephoneUtils->iAudioOutputAtStartup = CTelephonyAudioRouting::EHandset; |
325 iTelephoneUtils->iAudioOutputAtStartup = CTelephonyAudioRouting::EHandset; |
326 |
326 |
327 iTelephoneUtils->iTelephonyAudioRouting->iCurrentOutput = |
327 iTelephoneUtils->iTelephonyAudioRouting->iCurrentOutput = |
328 CTelephonyAudioRouting::ELoudspeaker; |
328 CTelephonyAudioRouting::ELoudspeaker; |
|
329 iTelephoneUtils->iRepository->Set( KTelIncallLoudspeakerVolume, 8 ); |
|
330 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
331 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
329 |
332 |
330 iTelephoneUtils->OutputChanged( *iTelephoneUtils->iTelephonyAudioRouting ); |
333 iTelephoneUtils->OutputChanged( *iTelephoneUtils->iTelephonyAudioRouting ); |
331 |
334 |
332 EUNIT_ASSERT_EQUALS( iTelephoneUtils->iAudioOutputAtStartup, |
335 EUNIT_ASSERT_EQUALS( iTelephoneUtils->iAudioOutputAtStartup, |
333 CTelephonyAudioRouting::ELoudspeaker ) |
336 CTelephonyAudioRouting::ELoudspeaker ) |
334 |
337 |
|
338 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 8 ) |
|
339 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
335 // Test observer |
340 // Test observer |
336 |
341 |
337 iTelephoneUtils->SetAudioRoutingObserver( iObserver ); |
342 iTelephoneUtils->SetAudioRoutingObserver( iObserver ); |
|
343 iTelephoneUtils->SetVolumeChangeObserver(iObserver); |
338 |
344 |
339 iTelephoneUtils->iTelephonyAudioRouting->iCurrentOutput = |
345 iTelephoneUtils->iTelephonyAudioRouting->iCurrentOutput = |
340 CTelephonyAudioRouting::EHandset; |
346 CTelephonyAudioRouting::EHandset; |
341 |
347 |
342 iTelephoneUtils->OutputChanged( *iTelephoneUtils->iTelephonyAudioRouting ); |
348 iTelephoneUtils->OutputChanged( *iTelephoneUtils->iTelephonyAudioRouting ); |
343 |
349 |
|
350 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
351 EUNIT_ASSERT( iObserver->iVolume == 4 ); |
344 EUNIT_ASSERT_EQUALS( iTelephoneUtils->iAudioOutputAtStartup, |
352 EUNIT_ASSERT_EQUALS( iTelephoneUtils->iAudioOutputAtStartup, |
345 CTelephonyAudioRouting::EHandset ) |
353 CTelephonyAudioRouting::EHandset ) |
346 |
354 |
347 EUNIT_ASSERT( iObserver->iAudioRoutingChangedCalled ) |
355 EUNIT_ASSERT( iObserver->iAudioRoutingChangedCalled ) |
348 } |
356 } |
353 // ----------------------------------------------------------------------------- |
361 // ----------------------------------------------------------------------------- |
354 // |
362 // |
355 void UT_CMusEngTelephoneUtils::UT_SetOutputCompleteL() |
363 void UT_CMusEngTelephoneUtils::UT_SetOutputCompleteL() |
356 { |
364 { |
357 iTelephoneUtils->SetAudioRoutingObserver( iObserver ); |
365 iTelephoneUtils->SetAudioRoutingObserver( iObserver ); |
358 |
366 iTelephoneUtils->SetVolumeChangeObserver(iObserver); |
|
367 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
|
368 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
369 |
359 // Setoutput fails |
370 // Setoutput fails |
360 iTelephoneUtils->SetOutputComplete( |
371 iTelephoneUtils->SetOutputComplete( |
361 *iTelephoneUtils->iTelephonyAudioRouting, |
372 *iTelephoneUtils->iTelephonyAudioRouting, |
362 KErrGeneral ); |
373 KErrGeneral ); |
363 |
374 |
364 EUNIT_ASSERT( !iObserver->iAudioRoutingChangedCalled ) |
375 EUNIT_ASSERT( !iObserver->iAudioRoutingChangedCalled ) |
|
376 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
365 |
377 |
366 // Setoutput succesful and note is shown by audiorouting api |
378 // Setoutput succesful and note is shown by audiorouting api |
367 // There's already next pending setoutput for which we are going to |
379 // There's already next pending setoutput for which we are going to |
368 // show note -> that cannot be forgotten |
380 // show note -> that cannot be forgotten |
|
381 iTelephoneUtils->iRepository->Set( KTelIncallEarVolume, 5 ); |
369 iTelephoneUtils->iShowDialog = ETrue; |
382 iTelephoneUtils->iShowDialog = ETrue; |
370 iTelephoneUtils->iTelephonyAudioRouting->SetShowNote( ETrue ); |
383 iTelephoneUtils->iTelephonyAudioRouting->SetShowNote( ETrue ); |
371 iTelephoneUtils->SetOutputComplete( |
384 iTelephoneUtils->SetOutputComplete( |
372 *iTelephoneUtils->iTelephonyAudioRouting, |
385 *iTelephoneUtils->iTelephonyAudioRouting, |
373 KErrNone ); |
386 KErrNone ); |
374 EUNIT_ASSERT( iObserver->iAudioRoutingChangedCalled == ETrue ) |
387 EUNIT_ASSERT( iObserver->iAudioRoutingChangedCalled == ETrue ) |
375 EUNIT_ASSERT( iObserver->iShowNote == EFalse ) |
388 EUNIT_ASSERT( iObserver->iShowNote == EFalse ) |
376 EUNIT_ASSERT( iTelephoneUtils->iShowDialog == ETrue ) |
389 EUNIT_ASSERT( iTelephoneUtils->iShowDialog == ETrue ) |
|
390 EUNIT_ASSERT( iObserver->iVolume == 5 ); |
|
391 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 5 ) |
377 |
392 |
378 iObserver->Reset(); |
393 iObserver->Reset(); |
379 |
394 |
380 // Setoutput succesful and note is shown by us |
395 // Setoutput succesful and note is shown by us |
381 iTelephoneUtils->iTelephonyAudioRouting->SetShowNote( EFalse ); |
396 iTelephoneUtils->iTelephonyAudioRouting->SetShowNote( EFalse ); |
452 CTelephonyAudioRouting::ELoudspeaker; |
467 CTelephonyAudioRouting::ELoudspeaker; |
453 CleanupStack::PopAndDestroy( utils ); |
468 CleanupStack::PopAndDestroy( utils ); |
454 // Cannot really assert anything |
469 // Cannot really assert anything |
455 } |
470 } |
456 |
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void UT_CMusEngTelephoneUtils::UT_UpdateCurrentVolumeL() |
|
477 { |
|
478 //Volume changed, no observer |
|
479 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
480 iTelephoneUtils->iRepository->Set( KTelIncallEarVolume, 5 ); |
|
481 iTelephoneUtils->UpdateCurrentVolume(EFalse); |
|
482 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 5 ) |
|
483 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
|
484 |
|
485 //Volume changed, observer set |
|
486 iTelephoneUtils->SetVolumeChangeObserver(iObserver); |
|
487 iTelephoneUtils->iRepository->Set( KTelIncallEarVolume, 6 ); |
|
488 iTelephoneUtils->UpdateCurrentVolume(EFalse); |
|
489 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 6 ) |
|
490 EUNIT_ASSERT( iObserver->iVolume == 6 ); |
|
491 |
|
492 //Volume didn't change, observer not notified |
|
493 iObserver->iVolume = 0; |
|
494 iTelephoneUtils->UpdateCurrentVolume(EFalse); |
|
495 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 6 ) |
|
496 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 void UT_CMusEngTelephoneUtils::UT_HandleNotifyGenericL() |
|
504 { |
|
505 //Loudspeakers volume changed, no observer |
|
506 iTelephoneUtils->iRepository->Set( KTelIncallLoudspeakerVolume, 8 ); |
|
507 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
508 iTelephoneUtils->HandleNotifyGeneric(KTelIncallLoudspeakerVolume); |
|
509 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 8 ) |
|
510 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
|
511 |
|
512 //Ear volume changed, observer set => observer notified |
|
513 iTelephoneUtils->SetVolumeChangeObserver(iObserver); |
|
514 iTelephoneUtils->HandleNotifyGeneric(KTelIncallEarVolume); |
|
515 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
516 EUNIT_ASSERT( iObserver->iVolume == 4 ); |
|
517 |
|
518 //Volume hasn't changed => observer not notifies |
|
519 iObserver->iVolume = 0; |
|
520 iTelephoneUtils->HandleNotifyGeneric(KTelIncallEarVolume); |
|
521 EUNIT_ASSERT( iTelephoneUtils->iCurrentVolume == 4 ) |
|
522 EUNIT_ASSERT( iObserver->iVolume == 0 ); |
|
523 } |
457 |
524 |
458 |
525 |
459 // TEST TABLE |
526 // TEST TABLE |
460 |
527 |
461 EUNIT_BEGIN_TEST_TABLE( |
528 EUNIT_BEGIN_TEST_TABLE( |
538 "CMusEngTelephoneUtils", |
605 "CMusEngTelephoneUtils", |
539 "Destructor", |
606 "Destructor", |
540 "FUNCTIONALITY", |
607 "FUNCTIONALITY", |
541 SetupL, UT_DestructorL, Teardown) |
608 SetupL, UT_DestructorL, Teardown) |
542 |
609 |
543 |
610 EUNIT_TEST( |
|
611 "UpdateCurrentVolume - test ", |
|
612 "UpdateCurrentVolume", |
|
613 "Destructor", |
|
614 "FUNCTIONALITY", |
|
615 SetupL, UT_UpdateCurrentVolumeL, Teardown) |
|
616 |
|
617 EUNIT_TEST( |
|
618 "HandleNotifyGeneric - test ", |
|
619 "CMusEngTelephoneUtils", |
|
620 "HandleNotifyGeneric", |
|
621 "FUNCTIONALITY", |
|
622 SetupL, UT_HandleNotifyGenericL, Teardown) |
|
623 |
544 |
624 |
545 EUNIT_END_TEST_TABLE |
625 EUNIT_END_TEST_TABLE |
546 |
626 |
547 // END OF FILE |
627 // END OF FILE |
548 |
628 |