1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/tonetruepause.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1330 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Part of the TSI_MMFACLNT suite that tests CR1566 (TruePause) on AudioToneUtility
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file ToneTruePause.cpp
1.23 +*/
1.24 +
1.25 +#include "tonetruepause.h"
1.26 +#include "toneTest.h"
1.27 +
1.28 +/*
1.29 + *
1.30 + * RMdaToneUtilityTestBase - Test step constructor
1.31 + *
1.32 + */
1.33 +RMdaToneUtilityTestBase::RMdaToneUtilityTestBase(const TDesC& aTestName, const TDesC& aSectName)
1.34 + : iToneUtilityState(EStateInitial),
1.35 + iToneUtility(NULL),
1.36 + iTimer(NULL),
1.37 + iWait(EFalse),
1.38 + iStop(EFalse),
1.39 + iConfig(EFalse),
1.40 + iPrepare(EFalse),
1.41 + iNegative(EFalse),
1.42 + iCount(0),
1.43 + iVolume(0),
1.44 + iBalance(0),
1.45 + iDuration(0),
1.46 + iPause(0),
1.47 + iExpected(0),
1.48 + iFilename(KNullDesC)
1.49 + {
1.50 + iTestStepName = aTestName;
1.51 + iSectName = aSectName;
1.52 + }
1.53 +
1.54 +/*
1.55 + *
1.56 + * ~RMdaToneUtilityTestBase - Test step destructor
1.57 + *
1.58 + */
1.59 +RMdaToneUtilityTestBase::~RMdaToneUtilityTestBase()
1.60 + {
1.61 + if (iToneUtility)
1.62 + {
1.63 + delete iToneUtility;
1.64 + }
1.65 + if(iTimer)
1.66 + {
1.67 + delete iTimer;
1.68 + }
1.69 + iFile.Close();
1.70 + iFs.Close();
1.71 + }
1.72 +
1.73 +/*
1.74 + *
1.75 + * KickoffTestL - Starts the test
1.76 + *
1.77 + */
1.78 +void RMdaToneUtilityTestBase::KickoffTestL()
1.79 + {
1.80 + User::LeaveIfError(iFs.Connect());
1.81 + INFO_PRINTF1(_L("__________ Creating Tone Utility object ___________"));
1.82 +
1.83 + TRAPD(err, iToneUtility = CMdaAudioToneUtility::NewL(*this));
1.84 + if (err != KErrNone)
1.85 + {
1.86 + ERR_PRINTF2(_L("Could not create Tone Utility object. Error = %d"), err);
1.87 + StopTest(err);
1.88 + return;
1.89 + }
1.90 + INFO_PRINTF1(_L("Tone Utility State: EStateCreated"));
1.91 + iToneUtilityState = EStateCreated;
1.92 +
1.93 + DoKickoffTestL();
1.94 +
1.95 + INFO_PRINTF1(_L("Tone Utility Event: EEventInitialize"));
1.96 + Fsm(EEventInitialize, KErrNone);
1.97 + }
1.98 +
1.99 +/*
1.100 + *
1.101 + * CloseTest
1.102 + *
1.103 + */
1.104 +void RMdaToneUtilityTestBase::CloseTest()
1.105 + {
1.106 + INFO_PRINTF1(_L("Deleting Tone Utility object"));
1.107 + delete iToneUtility;
1.108 + delete iTimer;
1.109 + }
1.110 +
1.111 +/*
1.112 + *
1.113 + * StartTimer - Starts timer and timer callback
1.114 + *
1.115 + */
1.116 +void RMdaToneUtilityTestBase::StartTimer(TTimeIntervalMicroSeconds32 aWaitTime)
1.117 + {
1.118 + TTimeIntervalMicroSeconds32 timeInterval;
1.119 +
1.120 + if(aWaitTime <= TTimeIntervalMicroSeconds32(0))
1.121 + {
1.122 + timeInterval = KOneSecond;
1.123 + }
1.124 + else
1.125 + {
1.126 + timeInterval = aWaitTime;
1.127 + }
1.128 + TCallBack callback (TimerCallback, this);
1.129 + iTimer->Start(timeInterval, timeInterval, callback);
1.130 + INFO_PRINTF1(_L("Timer has been started"));
1.131 + }
1.132 +
1.133 +/*
1.134 + *
1.135 + * TimerCallback
1.136 + *
1.137 + */
1.138 +TInt RMdaToneUtilityTestBase::TimerCallback(TAny* aPtr)
1.139 + {
1.140 + static_cast<RMdaToneUtilityTestBase*>(aPtr)->DoTimerCallback();
1.141 + return KErrNone;
1.142 + }
1.143 +
1.144 +/*
1.145 + *
1.146 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.147 + *
1.148 + */
1.149 +void RMdaToneUtilityTestBase::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
1.150 + {
1.151 + TInt error = 0;
1.152 + switch (iToneUtilityState)
1.153 + {
1.154 + case EStateCreated:
1.155 + {
1.156 + if (aMdaAudioUtilityEvent == EEventInitialize)
1.157 + {
1.158 + if(!iNegative)
1.159 + {
1.160 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
1.161 + iToneUtility->PrepareToPlayFileSequence(iFile);
1.162 + }
1.163 + else
1.164 + {
1.165 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDTMFString"));
1.166 + iToneUtility->PrepareToPlayDTMFString(KDTMFString);
1.167 + }
1.168 + INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1.169 + iToneUtilityState = EStateInitializing;
1.170 + }
1.171 + else
1.172 + {
1.173 + ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.174 + StopTest(aError, EFail);
1.175 + }
1.176 + break;
1.177 + }
1.178 + case EStateInitializing:
1.179 + {
1.180 + if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
1.181 + {
1.182 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.183 + iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
1.184 + INFO_PRINTF1(_L("Starting playback"));
1.185 + iToneUtility->Play();
1.186 + iStartTime.HomeTime();
1.187 + iToneUtilityState = EStatePlaying;
1.188 + StartTimer(iPause*KOneSecond); //wait to pause
1.189 + }
1.190 + else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
1.191 + {
1.192 + ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
1.193 + StopTest(aError);
1.194 + }
1.195 + else
1.196 + {
1.197 + ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.198 + StopTest(aError, EFail);
1.199 + }
1.200 + break;
1.201 + }
1.202 + case EStatePlaying:
1.203 + {
1.204 + if(aMdaAudioUtilityEvent == EEventTimerComplete)
1.205 + {
1.206 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause"));
1.207 + error = iToneUtility->Pause();
1.208 + if(!iNegative)
1.209 + {
1.210 + INFO_PRINTF1(_L("MdaAudioUtility State: EStatePause"));
1.211 + iToneUtilityState = EStatePause;
1.212 + iWait = EFalse;
1.213 + }
1.214 + else
1.215 + {
1.216 + if(error == KErrNotSupported)
1.217 + {
1.218 + INFO_PRINTF1(_L("Pause while in a mode different than prepare to play file sequence returned with KErrNotSupported as expected"));
1.219 + }
1.220 + else
1.221 + {
1.222 + ERR_PRINTF2(_L("Pause while in a mode different than prepare to play file sequence returned with %d instead of KErrNotSupported as expected"),error);
1.223 + StopTest(error);
1.224 + }
1.225 + }
1.226 + }
1.227 + else
1.228 + {
1.229 + ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.230 + StopTest(aError, EFail);
1.231 + }
1.232 + break;
1.233 + }
1.234 + case EStatePause:
1.235 + {
1.236 + if (aMdaAudioUtilityEvent == EEventTimerComplete)
1.237 + {
1.238 + if(!iWait && !iConfig && !iPrepare)
1.239 + {
1.240 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
1.241 + error = iToneUtility->Resume();
1.242 + if(error == KErrNone)
1.243 + {
1.244 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.245 + iToneUtilityState = EStatePlaying;
1.246 + }
1.247 + else
1.248 + {
1.249 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.250 + StopTest(error);
1.251 + }
1.252 + }
1.253 + else if(!iWait && iConfig)
1.254 + {
1.255 + INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
1.256 + INFO_PRINTF3(_L("Changing Volume and Balance while paused to Volume = %d and Balance = %d"),iVolume,iBalance);
1.257 + iToneUtility->SetVolume(iVolume);
1.258 + iToneUtility->SetBalanceL(iBalance);
1.259 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
1.260 + error = iToneUtility->Resume();
1.261 + if(error == KErrNone)
1.262 + {
1.263 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.264 + iToneUtilityState = EStatePlaying;
1.265 + }
1.266 + else
1.267 + {
1.268 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.269 + StopTest(error);
1.270 + }
1.271 + iConfig = EFalse;
1.272 + }
1.273 + else if(!iWait && iPrepare)
1.274 + {
1.275 + INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
1.276 + INFO_PRINTF1(_L("Calling PrepareToPlayFileSequence while in Pause"));
1.277 + iToneUtility->PrepareToPlayFileSequence(iFile);
1.278 + iToneUtilityState = EStatePlaying;
1.279 + }
1.280 + }
1.281 + else
1.282 + {
1.283 + ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.284 + StopTest(aError, EFail);
1.285 + }
1.286 + break;
1.287 + }
1.288 + case EStateStopped:
1.289 + {
1.290 + if (aMdaAudioUtilityEvent == EEventTimerComplete)
1.291 + {
1.292 + if(iWait)
1.293 + {
1.294 + INFO_PRINTF1(_L("Playback stopped for 2 seconds"));
1.295 + iWait = EFalse;
1.296 + }
1.297 + else
1.298 + {
1.299 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume while stopped"));
1.300 + error = iToneUtility->Resume();
1.301 + if(error == KErrNotReady)
1.302 + {
1.303 + INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
1.304 + iToneUtilityState = EStatePlaying;
1.305 + }
1.306 + else
1.307 + {
1.308 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
1.309 + StopTest(error);
1.310 + }
1.311 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
1.312 + iToneUtility->Play();
1.313 + }
1.314 + }
1.315 + else
1.316 + {
1.317 + ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.318 + StopTest(aError, EFail);
1.319 + }
1.320 + break;
1.321 + }
1.322 + default:
1.323 + {
1.324 + ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
1.325 + StopTest(KErrGeneral);
1.326 + }
1.327 + }
1.328 + }
1.329 +
1.330 +/*
1.331 + *
1.332 + * MatoPrepareComplete - From MMdaAudioToneObserver
1.333 + *
1.334 + */
1.335 +void RMdaToneUtilityTestBase::MatoPrepareComplete(TInt aError)
1.336 + {
1.337 + INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
1.338 + if(iToneUtilityState == EStateInitializing)
1.339 + {
1.340 + INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
1.341 + Fsm(EEventPrepareComplete, aError);
1.342 + }
1.343 + }
1.344 +
1.345 +/*
1.346 + *
1.347 + * MatoPlayComplete - From MMdaAudioToneObserver
1.348 + *
1.349 + */
1.350 +void RMdaToneUtilityTestBase::MatoPlayComplete(TInt aError)
1.351 + {
1.352 + INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
1.353 + if (aError == KErrNone)
1.354 + {
1.355 + INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
1.356 + iEndTime.HomeTime();
1.357 + TTimeIntervalMicroSeconds playduration = iEndTime.MicroSecondsFrom(iStartTime);
1.358 + if(playduration > iExpected - KVariation && playduration < iExpected + KVariation)
1.359 + {
1.360 + INFO_PRINTF2(_L("Tone played for %ld. Value is between acceptable threshold"),playduration.Int64());
1.361 + StopTest(aError,EPass);
1.362 + }
1.363 + else
1.364 + {
1.365 + ERR_PRINTF2(_L("Tone played for %ld. Value is not between acceptable threshold"),playduration.Int64());
1.366 + StopTest(KErrGeneral);
1.367 + }
1.368 + }
1.369 + else
1.370 + {
1.371 + ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
1.372 + ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1.373 + StopTest(aError);
1.374 + }
1.375 + }
1.376 +
1.377 +/*
1.378 + *========================================================================================================
1.379 + * MM-MMF-ACLNT-I-0168-HP
1.380 + *========================================================================================================
1.381 + */
1.382 +RMdaToneUtilityResumeTest::RMdaToneUtilityResumeTest(const TDesC& aTestName, const TDesC& aSectName)
1.383 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.384 + {
1.385 + }
1.386 +
1.387 +/*
1.388 + *
1.389 + * NewL
1.390 + *
1.391 + */
1.392 +RMdaToneUtilityResumeTest* RMdaToneUtilityResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.393 + {
1.394 + RMdaToneUtilityResumeTest * self = new(ELeave)RMdaToneUtilityResumeTest(aTestName,aSectName);
1.395 + return self;
1.396 + }
1.397 +
1.398 +/*
1.399 + *
1.400 + * DoKickoffTestL
1.401 + *
1.402 + */
1.403 +void RMdaToneUtilityResumeTest::DoKickoffTestL()
1.404 + {
1.405 + TPtrC filename;
1.406 + // Get the duration of the audio file to play
1.407 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.408 + {
1.409 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.410 + StopTest(KErrNotFound);
1.411 + return;
1.412 + }
1.413 + // Get the pause time
1.414 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.415 + {
1.416 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.417 + StopTest(KErrNotFound);
1.418 + return;
1.419 + }
1.420 + // Get the filename of the audio file to play
1.421 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.422 + {
1.423 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.424 + StopTest(KErrNotFound);
1.425 + return;
1.426 + }
1.427 + // open using RFile for playback
1.428 + iFilename.Copy(filename);
1.429 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.430 + if (err != KErrNone)
1.431 + {
1.432 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.433 + iFs.Close();
1.434 + User::Leave(err);
1.435 + }
1.436 + iWait = ETrue;
1.437 + iExpected = iDuration + iPause*KOneSecond;
1.438 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.439 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.440 + }
1.441 +
1.442 +/*
1.443 + *
1.444 + * DoTimerCallback
1.445 + *
1.446 + */
1.447 +void RMdaToneUtilityResumeTest::DoTimerCallback()
1.448 + {
1.449 + if(!iWait)
1.450 + {
1.451 + INFO_PRINTF1(_L("Cancelling timer"));
1.452 + iTimer->Cancel();
1.453 + }
1.454 + else
1.455 + {
1.456 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.457 + }
1.458 + Fsm (EEventTimerComplete, KErrNone);
1.459 + }
1.460 +
1.461 +/*
1.462 + *========================================================================================================
1.463 + * MM-MMF-ACLNT-I-0169-HP
1.464 + *========================================================================================================
1.465 + */
1.466 +RMdaToneUtilityResumeThreeTest::RMdaToneUtilityResumeThreeTest(const TDesC& aTestName, const TDesC& aSectName)
1.467 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.468 + {
1.469 + }
1.470 +
1.471 +/*
1.472 + *
1.473 + * NewL
1.474 + *
1.475 + */
1.476 +RMdaToneUtilityResumeThreeTest* RMdaToneUtilityResumeThreeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.477 + {
1.478 + RMdaToneUtilityResumeThreeTest * self = new(ELeave)RMdaToneUtilityResumeThreeTest(aTestName,aSectName);
1.479 + return self;
1.480 + }
1.481 +
1.482 +/*
1.483 + *
1.484 + * DoKickoffTestL
1.485 + *
1.486 + */
1.487 +void RMdaToneUtilityResumeThreeTest::DoKickoffTestL()
1.488 + {
1.489 + TPtrC filename;
1.490 + // Get the duration of the audio file to play
1.491 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.492 + {
1.493 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.494 + StopTest(KErrNotFound);
1.495 + return;
1.496 + }
1.497 + // Get the pause time
1.498 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.499 + {
1.500 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.501 + StopTest(KErrNotFound);
1.502 + return;
1.503 + }
1.504 + // Get the filename of the audio file to play
1.505 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.506 + {
1.507 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.508 + StopTest(KErrNotFound);
1.509 + return;
1.510 + }
1.511 + // open using RFile for playback
1.512 + iFilename.Copy(filename);
1.513 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.514 + if (err != KErrNone)
1.515 + {
1.516 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.517 + iFs.Close();
1.518 + User::Leave(err);
1.519 + }
1.520 + iWait = ETrue;
1.521 + iExpected = iDuration + 3*(iPause*KOneSecond);
1.522 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.523 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.524 + iCount = 0;
1.525 + }
1.526 +
1.527 +/*
1.528 + *
1.529 + * DoTimerCallback
1.530 + *
1.531 + */
1.532 +void RMdaToneUtilityResumeThreeTest::DoTimerCallback()
1.533 + {
1.534 + iCount++;
1.535 + if(!iWait && iCount == 6) //Repeating Pause-Resume cycle three times
1.536 + {
1.537 + iTimer->Cancel();
1.538 + Fsm (EEventTimerComplete, KErrNone);
1.539 + }
1.540 + else
1.541 + {
1.542 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.543 + Fsm (EEventTimerComplete, KErrNone);
1.544 + }
1.545 + }
1.546 +
1.547 +/*
1.548 + *========================================================================================================
1.549 + * MM-MMF-ACLNT-I-0170-HP
1.550 + *========================================================================================================
1.551 + */
1.552 +RMdaToneUtilityPlayPauseStopPlayTest::RMdaToneUtilityPlayPauseStopPlayTest(const TDesC& aTestName, const TDesC& aSectName)
1.553 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.554 + {
1.555 + }
1.556 +
1.557 +/*
1.558 + *
1.559 + * NewL
1.560 + *
1.561 + */
1.562 +RMdaToneUtilityPlayPauseStopPlayTest* RMdaToneUtilityPlayPauseStopPlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.563 + {
1.564 + RMdaToneUtilityPlayPauseStopPlayTest * self = new(ELeave)RMdaToneUtilityPlayPauseStopPlayTest(aTestName,aSectName);
1.565 + return self;
1.566 + }
1.567 +
1.568 +/*
1.569 + *
1.570 + * DoKickoffTestL
1.571 + *
1.572 + */
1.573 +void RMdaToneUtilityPlayPauseStopPlayTest::DoKickoffTestL()
1.574 + {
1.575 + TPtrC filename;
1.576 + // Get the duration of the audio file to play
1.577 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.578 + {
1.579 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.580 + StopTest(KErrNotFound);
1.581 + return;
1.582 + }
1.583 + // Get the pause time
1.584 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.585 + {
1.586 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.587 + StopTest(KErrNotFound);
1.588 + return;
1.589 + }
1.590 + // Get the filename of the audio file to play
1.591 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.592 + {
1.593 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.594 + StopTest(KErrNotFound);
1.595 + return;
1.596 + }
1.597 + // open using RFile for playback
1.598 + iFilename.Copy(filename);
1.599 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.600 + if (err != KErrNone)
1.601 + {
1.602 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.603 + iFs.Close();
1.604 + User::Leave(err);
1.605 + return;
1.606 + }
1.607 + iWait = ETrue;
1.608 + iStop = ETrue;
1.609 + iExpected = iDuration + 3*(iPause*KOneSecond);
1.610 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.611 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.612 + iCount = 0;
1.613 + }
1.614 +
1.615 +/*
1.616 + *
1.617 + * DoTimerCallback
1.618 + *
1.619 + */
1.620 +void RMdaToneUtilityPlayPauseStopPlayTest::DoTimerCallback()
1.621 + {
1.622 + if(!iWait && iStop)
1.623 + {
1.624 + INFO_PRINTF1(_L("Stopping playback"));
1.625 + iToneUtility->CancelPlay();
1.626 + iStop = EFalse;
1.627 + iToneUtilityState = EStateStopped;
1.628 + iWait = ETrue;
1.629 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.630 + Fsm (EEventTimerComplete, KErrNone);
1.631 + }
1.632 + else if(!iWait && !iStop)
1.633 + {
1.634 + iTimer->Cancel();
1.635 + Fsm (EEventTimerComplete, KErrNone);
1.636 + }
1.637 + else
1.638 + {
1.639 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.640 + Fsm (EEventTimerComplete, KErrNone);
1.641 + }
1.642 + }
1.643 +
1.644 +/*
1.645 + *========================================================================================================
1.646 + * MM-MMF-ACLNT-I-0171-HP
1.647 + *========================================================================================================
1.648 + */
1.649 +RMdaToneUtilityConfigResumeTest::RMdaToneUtilityConfigResumeTest(const TDesC& aTestName, const TDesC& aSectName)
1.650 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.651 + {
1.652 + }
1.653 +
1.654 +/*
1.655 + *
1.656 + * NewL
1.657 + *
1.658 + */
1.659 +RMdaToneUtilityConfigResumeTest* RMdaToneUtilityConfigResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.660 + {
1.661 + RMdaToneUtilityConfigResumeTest * self = new(ELeave)RMdaToneUtilityConfigResumeTest(aTestName,aSectName);
1.662 + return self;
1.663 + }
1.664 +
1.665 +/*
1.666 + *
1.667 + * DoKickoffTestL
1.668 + *
1.669 + */
1.670 +void RMdaToneUtilityConfigResumeTest::DoKickoffTestL()
1.671 + {
1.672 + TPtrC filename;
1.673 + // Get the duration of the audio file to play
1.674 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.675 + {
1.676 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.677 + StopTest(KErrNotFound);
1.678 + return;
1.679 + }
1.680 + // Get the pause time
1.681 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.682 + {
1.683 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.684 + StopTest(KErrNotFound);
1.685 + return;
1.686 + }
1.687 + // Get the filename of the audio file to play
1.688 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.689 + {
1.690 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.691 + StopTest(KErrNotFound);
1.692 + return;
1.693 + }
1.694 + // Get the volume
1.695 + if (!GetIntFromConfig(iSectName, KVolume, iVolume))
1.696 + {
1.697 + ERR_PRINTF1(_L("Volume could not be retrieved from ini file"));
1.698 + StopTest(KErrNotFound);
1.699 + return;
1.700 + }
1.701 + // Get the balance
1.702 + if (!GetIntFromConfig(iSectName, KBalance, iBalance))
1.703 + {
1.704 + ERR_PRINTF1(_L("Balance could not be retrieved from ini file"));
1.705 + StopTest(KErrNotFound);
1.706 + return;
1.707 + }
1.708 + // open using RFile for playback
1.709 + iFilename.Copy(filename);
1.710 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.711 + if (err != KErrNone)
1.712 + {
1.713 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.714 + iFs.Close();
1.715 + User::Leave(err);
1.716 + return;
1.717 + }
1.718 + iWait = ETrue;
1.719 + iConfig = ETrue;
1.720 + iExpected = iDuration + iPause*KOneSecond;
1.721 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.722 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.723 + }
1.724 +
1.725 +/*
1.726 + *
1.727 + * DoTimerCallback
1.728 + *
1.729 + */
1.730 +void RMdaToneUtilityConfigResumeTest::DoTimerCallback()
1.731 + {
1.732 + if(!iWait && !iConfig)
1.733 + {
1.734 + iTimer->Cancel();
1.735 + INFO_PRINTF1(_L("Comparing Volume and Balance with values set"));
1.736 + if (iVolume == iToneUtility->Volume() && Abs(iBalance - iToneUtility->GetBalanceL())<KBalanceTolerance)
1.737 + {
1.738 + INFO_PRINTF3(_L("Volume = %d and Balance = %d as expected"),iVolume,iBalance);
1.739 + }
1.740 + else
1.741 + {
1.742 + ERR_PRINTF1(_L("Retrieved values are different than expected"));
1.743 + ERR_PRINTF5(_L("Retrieved Volume = %d and Balance = %d. Expected Volume = %d and Balance = %d"),iToneUtility->Volume(),iToneUtility->GetBalanceL(),iVolume,iBalance);
1.744 + StopTest(KErrGeneral);
1.745 + }
1.746 + }
1.747 + else
1.748 + {
1.749 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.750 + Fsm (EEventTimerComplete, KErrNone);
1.751 + }
1.752 + }
1.753 +
1.754 +/*
1.755 + *========================================================================================================
1.756 + * MM-MMF-ACLNT-I-0172-HP
1.757 + *========================================================================================================
1.758 + */
1.759 +RMdaToneUtilityPrepareInPauseTest::RMdaToneUtilityPrepareInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1.760 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.761 + {
1.762 + }
1.763 +
1.764 +/*
1.765 + *
1.766 + * NewL
1.767 + *
1.768 + */
1.769 +RMdaToneUtilityPrepareInPauseTest* RMdaToneUtilityPrepareInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.770 + {
1.771 + RMdaToneUtilityPrepareInPauseTest * self = new(ELeave)RMdaToneUtilityPrepareInPauseTest(aTestName,aSectName);
1.772 + return self;
1.773 + }
1.774 +
1.775 +/*
1.776 + *
1.777 + * DoKickoffTestL
1.778 + *
1.779 + */
1.780 +void RMdaToneUtilityPrepareInPauseTest::DoKickoffTestL()
1.781 + {
1.782 + TPtrC filename;
1.783 + // Get the duration of the audio file to play
1.784 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.785 + {
1.786 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.787 + StopTest(KErrNotFound);
1.788 + return;
1.789 + }
1.790 + // Get the pause time
1.791 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.792 + {
1.793 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.794 + StopTest(KErrNotFound);
1.795 + return;
1.796 + }
1.797 + // Get the filename of the audio file to play
1.798 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.799 + {
1.800 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.801 + StopTest(KErrNotFound);
1.802 + return;
1.803 + }
1.804 + // open using RFile for playback
1.805 + iFilename.Copy(filename);
1.806 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.807 + if (err != KErrNone)
1.808 + {
1.809 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.810 + iFs.Close();
1.811 + User::Leave(err);
1.812 + return;
1.813 + }
1.814 + iWait = ETrue;
1.815 + iPrepare = ETrue;
1.816 + iExpected = iDuration;
1.817 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.818 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.819 + }
1.820 +
1.821 +/*
1.822 + *
1.823 + * DoTimerCallback
1.824 + *
1.825 + */
1.826 +void RMdaToneUtilityPrepareInPauseTest::DoTimerCallback()
1.827 + {
1.828 + if(!iWait)
1.829 + {
1.830 + iTimer->Cancel();
1.831 + Fsm (EEventTimerComplete, KErrNone);
1.832 + }
1.833 + else
1.834 + {
1.835 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.836 + Fsm (EEventTimerComplete, KErrNone);
1.837 + }
1.838 + }
1.839 +
1.840 +/*
1.841 + *
1.842 + * MatoPrepareComplete - From MMdaAudioToneObserver
1.843 + *
1.844 + */
1.845 +void RMdaToneUtilityPrepareInPauseTest::MatoPrepareComplete(TInt aError)
1.846 + {
1.847 + INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
1.848 + if(iToneUtilityState == EStateInitializing)
1.849 + {
1.850 + INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
1.851 + Fsm(EEventPrepareComplete, aError);
1.852 + }
1.853 + else if(iToneUtilityState == EStatePlaying)
1.854 + {
1.855 + if(aError == KErrNone)
1.856 + {
1.857 + INFO_PRINTF2(_L("Tone Utility returned with expected error %d"),aError);
1.858 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
1.859 + iStartTime.HomeTime(); //Register start time here. Tone should restart
1.860 + iToneUtility->Play();
1.861 + }
1.862 + else
1.863 + {
1.864 + ERR_PRINTF1(_L("Preparing tone playback was not successful while paused. This is unexpected"));
1.865 + StopTest(aError);
1.866 + }
1.867 + }
1.868 + }
1.869 +
1.870 +/*
1.871 + *========================================================================================================
1.872 + * MM-MMF-ACLNT-I-0173-HP
1.873 + *========================================================================================================
1.874 + */
1.875 +RMdaToneUtilityPauseBeforePlayTest::RMdaToneUtilityPauseBeforePlayTest(const TDesC& aTestName, const TDesC& aSectName)
1.876 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.877 + {
1.878 + }
1.879 +
1.880 +/*
1.881 + *
1.882 + * NewL
1.883 + *
1.884 + */
1.885 +RMdaToneUtilityPauseBeforePlayTest* RMdaToneUtilityPauseBeforePlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.886 + {
1.887 + RMdaToneUtilityPauseBeforePlayTest * self = new(ELeave)RMdaToneUtilityPauseBeforePlayTest(aTestName,aSectName);
1.888 + return self;
1.889 + }
1.890 +
1.891 +/*
1.892 + *
1.893 + * DoKickoffTestL
1.894 + *
1.895 + */
1.896 +void RMdaToneUtilityPauseBeforePlayTest::DoKickoffTestL()
1.897 + {
1.898 + TPtrC filename;
1.899 + // Get the duration of the audio file to play
1.900 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.901 + {
1.902 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.903 + StopTest(KErrNotFound);
1.904 + return;
1.905 + }
1.906 + // Get the filename of the audio file to play
1.907 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.908 + {
1.909 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.910 + StopTest(KErrNotFound);
1.911 + return;
1.912 + }
1.913 + // open using RFile for playback
1.914 + iFilename.Copy(filename);
1.915 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.916 + if (err != KErrNone)
1.917 + {
1.918 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.919 + iFs.Close();
1.920 + User::Leave(err);
1.921 + return;
1.922 + }
1.923 + iExpected = iDuration;
1.924 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.925 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.926 + }
1.927 +
1.928 +/*
1.929 + *
1.930 + * MatoPrepareComplete - From MMdaAudioToneObserver
1.931 + *
1.932 + */
1.933 +void RMdaToneUtilityPauseBeforePlayTest::MatoPrepareComplete(TInt aError)
1.934 + {
1.935 + INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
1.936 + if(iToneUtilityState == EStateInitializing)
1.937 + {
1.938 + INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
1.939 + Fsm(EEventPrepareComplete, aError);
1.940 + }
1.941 + }
1.942 +
1.943 +/*
1.944 + *
1.945 + * Fsm - Executes playing events of AudioPlayerUtility in sequence
1.946 + *
1.947 + */
1.948 +void RMdaToneUtilityPauseBeforePlayTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
1.949 + {
1.950 + TInt error = 0;
1.951 + switch (iToneUtilityState)
1.952 + {
1.953 + case EStateCreated:
1.954 + {
1.955 + if (aMdaAudioUtilityEvent == EEventInitialize)
1.956 + {
1.957 + StartTimer(20*KOneSecond); //wait twenty seconds. If timer callback occurrs then Pause worked while not in play
1.958 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before preparing to play"));
1.959 + error = iToneUtility->Pause();
1.960 + if(error == KErrNotReady)
1.961 + {
1.962 + INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
1.963 + }
1.964 + else
1.965 + {
1.966 + ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
1.967 + StopTest(error);
1.968 + }
1.969 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
1.970 + iToneUtility->PrepareToPlayFileSequence(iFile);
1.971 +
1.972 + INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1.973 + iToneUtilityState = EStateInitializing;
1.974 + }
1.975 + else
1.976 + {
1.977 + ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.978 + StopTest(aError, EFail);
1.979 + }
1.980 + break;
1.981 + }
1.982 + case EStateInitializing:
1.983 + {
1.984 + if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
1.985 + {
1.986 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.987 + iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
1.988 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before playing"));
1.989 + error = iToneUtility->Pause();
1.990 + if(error == KErrNotReady)
1.991 + {
1.992 + INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
1.993 + }
1.994 + else
1.995 + {
1.996 + ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
1.997 + StopTest(error);
1.998 + }
1.999 + INFO_PRINTF1(_L("Starting playback"));
1.1000 + iToneUtility->Play();
1.1001 + iStartTime.HomeTime();
1.1002 + }
1.1003 + else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
1.1004 + {
1.1005 + ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
1.1006 + StopTest(aError);
1.1007 + }
1.1008 + else
1.1009 + {
1.1010 + ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.1011 + StopTest(aError, EFail);
1.1012 + }
1.1013 + break;
1.1014 + }
1.1015 + default:
1.1016 + {
1.1017 + ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
1.1018 + StopTest(KErrGeneral);
1.1019 + }
1.1020 + }
1.1021 + }
1.1022 +
1.1023 +/*
1.1024 + *
1.1025 + * DoTimerCallback
1.1026 + *
1.1027 + */
1.1028 +void RMdaToneUtilityPauseBeforePlayTest::DoTimerCallback()
1.1029 + {
1.1030 + ERR_PRINTF1(_L("Timer callback received. This is unexpected"));
1.1031 + StopTest(KErrGeneral);
1.1032 + }
1.1033 +
1.1034 +/*
1.1035 + *========================================================================================================
1.1036 + * MM-MMF-ACLNT-I-0174-HP Negative
1.1037 + *========================================================================================================
1.1038 + */
1.1039 +RMdaToneUtilityNegPauseResumeTest::RMdaToneUtilityNegPauseResumeTest(const TDesC& aTestName, const TDesC& aSectName)
1.1040 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.1041 + {
1.1042 + }
1.1043 +
1.1044 +/*
1.1045 + *
1.1046 + * NewL
1.1047 + *
1.1048 + */
1.1049 +RMdaToneUtilityNegPauseResumeTest* RMdaToneUtilityNegPauseResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1050 + {
1.1051 + RMdaToneUtilityNegPauseResumeTest * self = new(ELeave)RMdaToneUtilityNegPauseResumeTest(aTestName,aSectName);
1.1052 + return self;
1.1053 + }
1.1054 +
1.1055 +/*
1.1056 + *
1.1057 + * DoKickoffTestL
1.1058 + *
1.1059 + */
1.1060 +void RMdaToneUtilityNegPauseResumeTest::DoKickoffTestL()
1.1061 + {
1.1062 + TPtrC filename;
1.1063 + // Get the pause time
1.1064 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1065 + {
1.1066 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1067 + StopTest(KErrNotFound);
1.1068 + return;
1.1069 + }
1.1070 + // Get the filename of the audio file to play
1.1071 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.1072 + {
1.1073 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1074 + StopTest(KErrNotFound);
1.1075 + return;
1.1076 + }
1.1077 + // open using RFile for playback
1.1078 + iFilename.Copy(filename);
1.1079 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1080 + if (err != KErrNone)
1.1081 + {
1.1082 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1083 + iFs.Close();
1.1084 + User::Leave(err);
1.1085 + return;
1.1086 + }
1.1087 + iWait = ETrue;
1.1088 + iNegative = ETrue;
1.1089 + iCount = 0;
1.1090 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1091 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1092 + }
1.1093 +
1.1094 +/*
1.1095 + *
1.1096 + * DoTimerCallback
1.1097 + *
1.1098 + */
1.1099 +void RMdaToneUtilityNegPauseResumeTest::DoTimerCallback()
1.1100 + {
1.1101 + INFO_PRINTF1(_L("Cancelling timer"));
1.1102 + iTimer->Cancel();
1.1103 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.1104 + Fsm (EEventTimerComplete, KErrNone);
1.1105 + }
1.1106 +
1.1107 +/*
1.1108 + *
1.1109 + * MatoPlayComplete - From MMdaAudioToneObserver
1.1110 + *
1.1111 + */
1.1112 +void RMdaToneUtilityNegPauseResumeTest::MatoPlayComplete(TInt aError)
1.1113 + {
1.1114 + INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
1.1115 + iCount++;
1.1116 + if (aError == KErrNone)
1.1117 + {
1.1118 + INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
1.1119 + switch(iCount)
1.1120 + {
1.1121 + //NOTE:"PlayFixedSequence is not supported on A3F"
1.1122 + case 1:
1.1123 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayTone"));
1.1124 + iToneUtility->PrepareToPlayTone(KToneFrequency, KFiveSeconds);
1.1125 + INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1.1126 + iToneUtilityState = EStateInitializing;
1.1127 + break;
1.1128 + case 2:
1.1129 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDualTone"));
1.1130 + iToneUtility->PrepareToPlayDualTone(KToneFrequency, KToneFrequencyTwo, KFiveSeconds);
1.1131 + INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1.1132 + iToneUtilityState = EStateInitializing;
1.1133 + break;
1.1134 + case 3:
1.1135 + INFO_PRINTF1(_L("All tone variations have been tested"));
1.1136 + StopTest(aError);
1.1137 + break;
1.1138 + }
1.1139 + }
1.1140 + else
1.1141 + {
1.1142 + ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
1.1143 + ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1.1144 + StopTest(aError);
1.1145 + }
1.1146 + }
1.1147 +
1.1148 +/*
1.1149 + *========================================================================================================
1.1150 + * MM-MMF-ACLNT-I-0183-HP
1.1151 + *========================================================================================================
1.1152 + */
1.1153 +RMdaToneUtilityPauseNonA3fTest::RMdaToneUtilityPauseNonA3fTest(const TDesC& aTestName, const TDesC& aSectName)
1.1154 + : RMdaToneUtilityTestBase(aTestName,aSectName)
1.1155 + {
1.1156 + }
1.1157 +
1.1158 +/*
1.1159 + *
1.1160 + * NewL
1.1161 + *
1.1162 + */
1.1163 +RMdaToneUtilityPauseNonA3fTest* RMdaToneUtilityPauseNonA3fTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1164 + {
1.1165 + RMdaToneUtilityPauseNonA3fTest * self = new(ELeave)RMdaToneUtilityPauseNonA3fTest(aTestName,aSectName);
1.1166 + return self;
1.1167 + }
1.1168 +
1.1169 +/*
1.1170 + *
1.1171 + * DoKickoffTestL
1.1172 + *
1.1173 + */
1.1174 +void RMdaToneUtilityPauseNonA3fTest::DoKickoffTestL()
1.1175 + {
1.1176 + TPtrC filename;
1.1177 + // Get the filename of the audio file to play
1.1178 + if (!GetStringFromConfig(iSectName, KSequence, filename))
1.1179 + {
1.1180 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1181 + StopTest(KErrNotFound);
1.1182 + return;
1.1183 + }
1.1184 + // open using RFile for playback
1.1185 + iFilename.Copy(filename);
1.1186 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1187 + if (err != KErrNone)
1.1188 + {
1.1189 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1190 + iFs.Close();
1.1191 + User::Leave(err);
1.1192 + return;
1.1193 + }
1.1194 + // Get the duration of the audio file to play
1.1195 + if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1.1196 + {
1.1197 + ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1.1198 + User::Leave(KErrNotFound);
1.1199 + return;
1.1200 + }
1.1201 + // Get the pause time
1.1202 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1203 + {
1.1204 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1205 + User::Leave(KErrNotFound);
1.1206 + return;
1.1207 + }
1.1208 + iExpected = iDuration;
1.1209 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1210 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1211 + }
1.1212 +
1.1213 +/*
1.1214 + *
1.1215 + * MatoPrepareComplete - From MMdaAudioToneObserver
1.1216 + *
1.1217 + */
1.1218 +void RMdaToneUtilityPauseNonA3fTest::MatoPrepareComplete(TInt aError)
1.1219 + {
1.1220 + INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
1.1221 + if(iToneUtilityState == EStateInitializing)
1.1222 + {
1.1223 + INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
1.1224 + Fsm(EEventPrepareComplete, aError);
1.1225 + }
1.1226 + }
1.1227 +
1.1228 +/*
1.1229 + *
1.1230 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.1231 + *
1.1232 + */
1.1233 +void RMdaToneUtilityPauseNonA3fTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
1.1234 + {
1.1235 + TInt error = 0;
1.1236 + switch (iToneUtilityState)
1.1237 + {
1.1238 + case EStateCreated:
1.1239 + {
1.1240 + if (aMdaAudioUtilityEvent == EEventInitialize)
1.1241 + {
1.1242 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
1.1243 + iToneUtility->PrepareToPlayFileSequence(iFile);
1.1244 +
1.1245 + INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1.1246 + iToneUtilityState = EStateInitializing;
1.1247 + }
1.1248 + else
1.1249 + {
1.1250 + ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.1251 + StopTest(aError, EFail);
1.1252 + }
1.1253 + break;
1.1254 + }
1.1255 + case EStateInitializing:
1.1256 + {
1.1257 + if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
1.1258 + {
1.1259 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.1260 + iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
1.1261 + INFO_PRINTF1(_L("Starting playback"));
1.1262 + iToneUtility->Play();
1.1263 + iStartTime.HomeTime();
1.1264 + iToneUtilityState = EStatePlaying;
1.1265 + StartTimer(iPause*KOneSecond); //wait to pause
1.1266 + }
1.1267 + else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
1.1268 + {
1.1269 + ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
1.1270 + StopTest(aError);
1.1271 + }
1.1272 + else
1.1273 + {
1.1274 + ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.1275 + StopTest(aError, EFail);
1.1276 + }
1.1277 + break;
1.1278 + }
1.1279 + case EStatePlaying:
1.1280 + {
1.1281 + if(aMdaAudioUtilityEvent == EEventTimerComplete)
1.1282 + {
1.1283 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause in non-a3f configuration"));
1.1284 + error = iToneUtility->Pause();
1.1285 + if(error == KErrNotSupported)
1.1286 + {
1.1287 + INFO_PRINTF1(_L("Pause in ToneUtility returned with KErrNotSupported as expected"));
1.1288 + }
1.1289 + else
1.1290 + {
1.1291 + ERR_PRINTF2(_L("Pause in ToneUtility returned with %d instead of KErrNotSupported as expected"),error);
1.1292 + StopTest(error);
1.1293 + }
1.1294 + INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume in non-a3f configuration"));
1.1295 + error = iToneUtility->Resume();
1.1296 + if(error == KErrNotReady)
1.1297 + {
1.1298 + INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
1.1299 + iToneUtilityState = EStatePlaying;
1.1300 + }
1.1301 + else
1.1302 + {
1.1303 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
1.1304 + StopTest(error);
1.1305 + }
1.1306 + }
1.1307 + else
1.1308 + {
1.1309 + ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1.1310 + StopTest(aError, EFail);
1.1311 + }
1.1312 + break;
1.1313 + }
1.1314 + default:
1.1315 + {
1.1316 + ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
1.1317 + StopTest(KErrGeneral);
1.1318 + }
1.1319 + }
1.1320 + }
1.1321 +
1.1322 +/*
1.1323 + *
1.1324 + * DoTimerCallback
1.1325 + *
1.1326 + */
1.1327 +void RMdaToneUtilityPauseNonA3fTest::DoTimerCallback()
1.1328 + {
1.1329 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.1330 + INFO_PRINTF1(_L("Cancelling timer"));
1.1331 + iTimer->Cancel();
1.1332 + Fsm (EEventTimerComplete, KErrNone);
1.1333 + }