1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/testoutputstreamtruepause.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1883 @@
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 AudioOutputStream
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file TestOutputStreamTruePause.cpp
1.23 +*/
1.24 +
1.25 +#include "testoutputstreamtruepause.h"
1.26 +
1.27 +/*
1.28 + *
1.29 + * RMdaOutputStreamTestBase - Test step constructor
1.30 + *
1.31 + */
1.32 +RMdaOutputStreamTestBase::RMdaOutputStreamTestBase(const TDesC& aTestName, const TDesC& aSectName)
1.33 + : iAudioOutputStreamState(EStateAOSInitial),
1.34 + iAudioOutputStream(NULL),
1.35 + iTimer(NULL),
1.36 + iWait(EFalse),
1.37 + iConfig(EFalse),
1.38 + iInvalidConfig(EFalse),
1.39 + iGetBytes(EFalse),
1.40 + iCount(0),
1.41 + iVolume(0),
1.42 + iBalance(0),
1.43 + iDuration(0),
1.44 + iPause(0),
1.45 + iBytes(0),
1.46 + iPosition(0),
1.47 + iFilename(KNullDesC)
1.48 + {
1.49 + iTestStepName = aTestName;
1.50 + iSectName = aSectName;
1.51 + }
1.52 +
1.53 +/*
1.54 + *
1.55 + * ~RMdaOutputStreamTestBase - Test step destructor
1.56 + *
1.57 + */
1.58 +RMdaOutputStreamTestBase::~RMdaOutputStreamTestBase()
1.59 + {
1.60 + if (iAudioOutputStream)
1.61 + {
1.62 + delete iAudioOutputStream;
1.63 + }
1.64 + if(iTimer)
1.65 + {
1.66 + delete iTimer;
1.67 + }
1.68 + iFile.Close();
1.69 + iFs.Close();
1.70 + iBuffer.Close();
1.71 + }
1.72 +
1.73 +/*
1.74 + *
1.75 + * KickoffTestL - Starts the test
1.76 + *
1.77 + */
1.78 +void RMdaOutputStreamTestBase::KickoffTestL()
1.79 + {
1.80 + User::LeaveIfError(iFs.Connect());
1.81 + INFO_PRINTF1(_L("__________ Creating AudioOutputStream object ___________"));
1.82 +
1.83 + TRAPD(err, iAudioOutputStream = CMdaAudioOutputStream::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("AudioOutputStream State: EStateCreated"));
1.91 + iAudioOutputStreamState = EStateAOSCreated;
1.92 +
1.93 + DoKickoffTestL();
1.94 +
1.95 + INFO_PRINTF1(_L("AudioOutputStream: EEventInitialize"));
1.96 + Fsm(EEventAOSInitialize, KErrNone);
1.97 + }
1.98 +
1.99 +/*
1.100 + *
1.101 + * CloseTest
1.102 + *
1.103 + */
1.104 +void RMdaOutputStreamTestBase::CloseTest()
1.105 + {
1.106 + INFO_PRINTF1(_L("Deleting AudioOutputStream object"));
1.107 + delete iAudioOutputStream;
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 RMdaOutputStreamTestBase::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 RMdaOutputStreamTestBase::TimerCallback(TAny* aPtr)
1.139 + {
1.140 + static_cast<RMdaOutputStreamTestBase*>(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 RMdaOutputStreamTestBase::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1.150 + {
1.151 + TInt error = 0;
1.152 + TTimeIntervalMicroSeconds resumeposition;
1.153 + switch (iAudioOutputStreamState)
1.154 + {
1.155 + case EStateAOSCreated:
1.156 + {
1.157 + if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1.158 + {
1.159 + TMdaAudioDataSettings settings;
1.160 + //Default settings
1.161 + settings.Query();
1.162 + settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1.163 + settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1.164 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1.165 + iAudioOutputStream->Open(&settings);
1.166 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1.167 + iAudioOutputStreamState = EStateAOSInitializing;
1.168 + }
1.169 + else
1.170 + {
1.171 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.172 + StopTest(aError, EFail);
1.173 + }
1.174 + break;
1.175 + }
1.176 + case EStateAOSInitializing:
1.177 + {
1.178 + if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1.179 + {
1.180 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.181 + iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1.182 + INFO_PRINTF1(_L("Starting playback"));
1.183 + iAudioOutputStream->WriteL(iBuffer);
1.184 + iAudioOutputStreamState = EStateAOSPlaying;
1.185 + StartTimer(iPause*KOneSecond);
1.186 + }
1.187 + else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1.188 + {
1.189 + ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1.190 + StopTest(aError);
1.191 + }
1.192 + else
1.193 + {
1.194 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.195 + StopTest(aError, EFail);
1.196 + }
1.197 + break;
1.198 + }
1.199 + case EStateAOSPlaying:
1.200 + {
1.201 + if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.202 + {
1.203 + if(!iGetBytes)
1.204 + {
1.205 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
1.206 + error = iAudioOutputStream->Pause();
1.207 + if(error == KErrNone)
1.208 + {
1.209 + INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
1.210 + }
1.211 + else
1.212 + {
1.213 + ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
1.214 + StopTest(error);
1.215 + }
1.216 + iPosition = iAudioOutputStream->Position();
1.217 + INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
1.218 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
1.219 + iAudioOutputStreamState = EStateAOSPause;
1.220 + iWait = EFalse;
1.221 + }
1.222 + if(iGetBytes)
1.223 + {
1.224 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
1.225 + error = iAudioOutputStream->Pause();
1.226 + if(error == KErrNone)
1.227 + {
1.228 + INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
1.229 + }
1.230 + else
1.231 + {
1.232 + ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
1.233 + StopTest(error);
1.234 + }
1.235 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
1.236 + iPosition = iAudioOutputStream->Position();
1.237 + INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
1.238 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
1.239 + iAudioOutputStreamState = EStateAOSPause;
1.240 + iWait = EFalse;
1.241 + INFO_PRINTF1(_L("Calling GetBytes"));
1.242 + iBytes = iAudioOutputStream->GetBytes();
1.243 + }
1.244 + }
1.245 + else
1.246 + {
1.247 + ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.248 + StopTest(aError, EFail);
1.249 + }
1.250 + break;
1.251 + }
1.252 + case EStateAOSPause:
1.253 + {
1.254 + if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.255 + {
1.256 + if(!iWait && !iConfig && !iInvalidConfig && !iGetBytes)
1.257 + {
1.258 + if(iPosition == iAudioOutputStream->Position())
1.259 + {
1.260 + INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1.261 + }
1.262 + else
1.263 + {
1.264 + ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1.265 + StopTest(KErrGeneral);
1.266 + }
1.267 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1.268 + error = iAudioOutputStream->Resume();
1.269 + resumeposition = iAudioOutputStream->Position();
1.270 + if(error == KErrNone)
1.271 + {
1.272 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.273 + iAudioOutputStreamState = EStateAOSPlaying;
1.274 + if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1.275 + {
1.276 + INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1.277 + }
1.278 + else
1.279 + {
1.280 + ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1.281 + StopTest(KErrGeneral);
1.282 + }
1.283 + }
1.284 + else
1.285 + {
1.286 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.287 + StopTest(error);
1.288 + }
1.289 + }
1.290 + else if(!iWait && iConfig)
1.291 + {
1.292 + if(iPosition == iAudioOutputStream->Position())
1.293 + {
1.294 + INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1.295 + }
1.296 + else
1.297 + {
1.298 + ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1.299 + StopTest(KErrGeneral);
1.300 + }
1.301 + INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
1.302 + INFO_PRINTF3(_L("Changing Volume and Balance while paused to Volume = %d and Balance = %d"),iVolume,iBalance);
1.303 + iAudioOutputStream->SetVolume(iVolume);
1.304 + iAudioOutputStream->SetBalanceL(iBalance);
1.305 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1.306 + error = iAudioOutputStream->Resume();
1.307 + resumeposition = iAudioOutputStream->Position();
1.308 + if(error == KErrNone)
1.309 + {
1.310 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.311 + iAudioOutputStreamState = EStateAOSPlaying;
1.312 + if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1.313 + {
1.314 + INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1.315 + }
1.316 + else
1.317 + {
1.318 + ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1.319 + StopTest(KErrGeneral);
1.320 + }
1.321 + }
1.322 + else
1.323 + {
1.324 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.325 + StopTest(error);
1.326 + }
1.327 + iConfig = EFalse;
1.328 + }
1.329 + else if(!iWait && iInvalidConfig)
1.330 + {
1.331 + if(iPosition == iAudioOutputStream->Position())
1.332 + {
1.333 + INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1.334 + }
1.335 + else
1.336 + {
1.337 + ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1.338 + StopTest(KErrGeneral);
1.339 + }
1.340 + INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
1.341 + INFO_PRINTF1(_L("Changing AudioProperties while paused"));
1.342 + TRAPD(err,iAudioOutputStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate48000Hz, TMdaAudioDataSettings::EChannelsStereo));
1.343 + if(err == KErrNotReady)
1.344 + {
1.345 + INFO_PRINTF1(_L("SetAudioPropertiesL returned with KErrNotReady as expected"));
1.346 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1.347 + error = iAudioOutputStream->Resume();
1.348 + resumeposition = iAudioOutputStream->Position();
1.349 + if(error == KErrNone)
1.350 + {
1.351 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.352 + iAudioOutputStreamState = EStateAOSPlaying;
1.353 + if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1.354 + {
1.355 + INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1.356 + }
1.357 + else
1.358 + {
1.359 + ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1.360 + StopTest(KErrGeneral);
1.361 + }
1.362 + }
1.363 + else
1.364 + {
1.365 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),err);
1.366 + StopTest(err);
1.367 + }
1.368 + iInvalidConfig = EFalse;
1.369 + }
1.370 + else
1.371 + {
1.372 + ERR_PRINTF2(_L("SetAudioPropertiesL did not return with KErrNotSupported as expected, returned with %d instead"), err);
1.373 + StopTest(KErrGeneral);
1.374 + }
1.375 + }
1.376 + else if(!iWait && iGetBytes)
1.377 + {
1.378 + if(iPosition == iAudioOutputStream->Position())
1.379 + {
1.380 + INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1.381 + }
1.382 + else
1.383 + {
1.384 + ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1.385 + StopTest(KErrGeneral);
1.386 + }
1.387 + INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
1.388 + INFO_PRINTF1(_L("Calling GetBytes to verify the value hasn't changed"));
1.389 + TInt myBytes = iAudioOutputStream->GetBytes();
1.390 + if(myBytes == iBytes)
1.391 + {
1.392 + INFO_PRINTF1(_L("GetBytes value did not change while in pause, this is expected."));
1.393 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1.394 + error = iAudioOutputStream->Resume();
1.395 + resumeposition = iAudioOutputStream->Position();
1.396 + if(error == KErrNone)
1.397 + {
1.398 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.399 + iAudioOutputStreamState = EStateAOSPlaying;
1.400 + if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1.401 + {
1.402 + INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1.403 + }
1.404 + else
1.405 + {
1.406 + ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1.407 + StopTest(KErrGeneral);
1.408 + }
1.409 + }
1.410 + else
1.411 + {
1.412 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.413 + StopTest(error);
1.414 + }
1.415 + iGetBytes = EFalse;
1.416 + }
1.417 + else
1.418 + {
1.419 + ERR_PRINTF3(_L("GetBytes value changed while in pause, this is unexpected. Expected = %d Retrieved = %d"),iBytes,myBytes);
1.420 + StopTest(KErrGeneral);
1.421 + }
1.422 + }
1.423 + }
1.424 + else
1.425 + {
1.426 + ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.427 + StopTest(aError, EFail);
1.428 + }
1.429 + break;
1.430 + }
1.431 + default:
1.432 + {
1.433 + ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1.434 + StopTest(KErrGeneral);
1.435 + }
1.436 + }
1.437 + }
1.438 +
1.439 +/*
1.440 + *
1.441 + * MaoscOpenComplete - From MMdaAudioOutputStreamObserver
1.442 + *
1.443 + */
1.444 +void RMdaOutputStreamTestBase::MaoscOpenComplete(TInt aError)
1.445 + {
1.446 + INFO_PRINTF1(_L("========== AudioOutputStream MaoscOpenComplete() callback =========="));
1.447 + if(iAudioOutputStreamState == EStateAOSInitializing)
1.448 + {
1.449 + INFO_PRINTF1(_L("AudioOutputStream MaoscOpenComplete"));
1.450 + Fsm(EEventAOSOpenComplete, aError);
1.451 + }
1.452 + }
1.453 +
1.454 +/*
1.455 + *
1.456 + * MaoscBufferCopied - From MMdaAudioOutputStreamObserver
1.457 + *
1.458 + */
1.459 +void RMdaOutputStreamTestBase::MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
1.460 + {
1.461 + INFO_PRINTF1(_L("========== AudioOutputStream MaoscBufferCopied() callback =========="));
1.462 + INFO_PRINTF1(_L("Reading file"));
1.463 + TInt err = iFile.Read(iBuffer);
1.464 + if (err != KErrNone)
1.465 + {
1.466 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.467 + StopTest(err);
1.468 + }
1.469 + if (iBuffer != KNullDesC8 && iAudioOutputStreamState != EStateAOSStopped)
1.470 + {
1.471 + INFO_PRINTF1(_L("Writing to stream"));
1.472 + iAudioOutputStream->WriteL(iBuffer);
1.473 + }
1.474 + if(iAudioOutputStreamState == EStateAOSPlaying)
1.475 + {
1.476 + INFO_PRINTF1(_L("AudioOutputStream MaoscBufferCopied"));
1.477 + }
1.478 + else if(iAudioOutputStreamState == EStateAOSPause)
1.479 + {
1.480 + ERR_PRINTF1(_L("AudioOutputStream MaoscBufferCopied in Paused. This is unexpected"));
1.481 + StopTest(KErrGeneral);
1.482 + }
1.483 + }
1.484 +
1.485 +/*
1.486 + *
1.487 + * MaoscPlayComplete - From MMdaAudioOutputStreamObserver
1.488 + *
1.489 + */
1.490 +void RMdaOutputStreamTestBase::MaoscPlayComplete(TInt aError)
1.491 + {
1.492 + INFO_PRINTF1(_L("========== AudioOutputStream MaoscPlayComplete() callback =========="));
1.493 + if (aError == KErrUnderflow)
1.494 + {
1.495 + INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
1.496 + StopTest(EPass);
1.497 + }
1.498 + else
1.499 + {
1.500 + ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
1.501 + ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1.502 + StopTest(aError);
1.503 + }
1.504 + }
1.505 +
1.506 +/*
1.507 + *========================================================================================================
1.508 + * MM-MMF-ACLNT-I-0175-HP
1.509 + *========================================================================================================
1.510 + */
1.511 +RMdaOutputStreamPauseResumeBeforeWriteTest::RMdaOutputStreamPauseResumeBeforeWriteTest(const TDesC& aTestName, const TDesC& aSectName)
1.512 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.513 + {
1.514 + }
1.515 +
1.516 +/*
1.517 + *
1.518 + * NewL
1.519 + *
1.520 + */
1.521 +RMdaOutputStreamPauseResumeBeforeWriteTest* RMdaOutputStreamPauseResumeBeforeWriteTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.522 + {
1.523 + RMdaOutputStreamPauseResumeBeforeWriteTest * self = new(ELeave)RMdaOutputStreamPauseResumeBeforeWriteTest(aTestName,aSectName);
1.524 + return self;
1.525 + }
1.526 +
1.527 +/*
1.528 + *
1.529 + * DoKickoffTestL
1.530 + *
1.531 + */
1.532 +void RMdaOutputStreamPauseResumeBeforeWriteTest::DoKickoffTestL()
1.533 + {
1.534 + TPtrC filename;
1.535 + // Get the filename of the audio file to play
1.536 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.537 + {
1.538 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.539 + StopTest(KErrNotFound);
1.540 + return;
1.541 + }
1.542 + // open using RFile for playback
1.543 + iFilename.Copy(filename);
1.544 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.545 + if (err != KErrNone)
1.546 + {
1.547 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.548 + iFs.Close();
1.549 + StopTest(err);
1.550 + return;
1.551 + }
1.552 + // Get size of iFile
1.553 + TInt filesize = 0;
1.554 + err = iFile.Size(filesize);
1.555 + if (err != KErrNone)
1.556 + {
1.557 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.558 + StopTest(err);
1.559 + return;
1.560 + }
1.561 + // Initialise iBuf
1.562 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.563 +
1.564 + //Read first half of the file
1.565 + err = iFile.Read(iBuffer);
1.566 + if (err != KErrNone)
1.567 + {
1.568 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.569 + StopTest(err);
1.570 + }
1.571 +
1.572 + iWait = ETrue;
1.573 + iPause = KTimeout; //Set timeout to stop test if playback was paused
1.574 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.575 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.576 + }
1.577 +
1.578 +/*
1.579 + *
1.580 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.581 + *
1.582 + */
1.583 +void RMdaOutputStreamPauseResumeBeforeWriteTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1.584 + {
1.585 + TInt error = 0;
1.586 + TTimeIntervalMicroSeconds resumeposition;
1.587 + switch (iAudioOutputStreamState)
1.588 + {
1.589 + case EStateAOSCreated:
1.590 + {
1.591 + if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1.592 + {
1.593 + TMdaAudioDataSettings settings;
1.594 + //Default settings
1.595 + settings.Query();
1.596 + settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1.597 + settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1.598 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause before Open"));
1.599 + error = iAudioOutputStream->Pause();
1.600 + if(error == KErrNotReady)
1.601 + {
1.602 + INFO_PRINTF1(_L("Pause before open returned with KErrNotReady as expected"));
1.603 + }
1.604 + else
1.605 + {
1.606 + ERR_PRINTF2(_L("Pause before open returned with %d instead of KErrNotReady as expected"),error);
1.607 + StopTest(error);
1.608 + }
1.609 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1.610 + iAudioOutputStream->Open(&settings);
1.611 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1.612 + iAudioOutputStreamState = EStateAOSInitializing;
1.613 + }
1.614 + else
1.615 + {
1.616 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.617 + StopTest(aError, EFail);
1.618 + }
1.619 + break;
1.620 + }
1.621 + case EStateAOSInitializing:
1.622 + {
1.623 + if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1.624 + {
1.625 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.626 + iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1.627 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause before first WriteL"));
1.628 + error = iAudioOutputStream->Pause();
1.629 + if(error == KErrNotReady)
1.630 + {
1.631 + INFO_PRINTF1(_L("Pause before first WriteL returned with KErrNotReady as expected"));
1.632 + }
1.633 + else
1.634 + {
1.635 + ERR_PRINTF2(_L("Pause before first WriteL returned with %d instead of KErrNotReady as expected"),error);
1.636 + StopTest(error);
1.637 + }
1.638 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume before first WriteL"));
1.639 + error = iAudioOutputStream->Resume();
1.640 + if(error == KErrNotReady)
1.641 + {
1.642 + INFO_PRINTF1(_L("Resume before first WriteL returned with KErrNotReady as expected"));
1.643 + }
1.644 + else
1.645 + {
1.646 + ERR_PRINTF2(_L("Resume before first WriteL returned with %d instead of KErrNotReady as expected"),error);
1.647 + StopTest(error);
1.648 + }
1.649 + INFO_PRINTF1(_L("Starting playback"));
1.650 + iAudioOutputStream->WriteL(iBuffer);
1.651 + iAudioOutputStreamState = EStateAOSPlaying;
1.652 + StartTimer(iPause*KOneSecond);
1.653 + }
1.654 + else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1.655 + {
1.656 + ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1.657 + StopTest(aError);
1.658 + }
1.659 + else
1.660 + {
1.661 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.662 + StopTest(aError, EFail);
1.663 + }
1.664 + break;
1.665 + }
1.666 + default:
1.667 + {
1.668 + ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1.669 + StopTest(KErrGeneral);
1.670 + }
1.671 + }
1.672 + }
1.673 +
1.674 +/*
1.675 + *
1.676 + * DoTimerCallback
1.677 + *
1.678 + */
1.679 +void RMdaOutputStreamPauseResumeBeforeWriteTest::DoTimerCallback()
1.680 + {
1.681 + INFO_PRINTF1(_L("Cancelling timer"));
1.682 + iTimer->Cancel();
1.683 + ERR_PRINTF1(_L("Playback was paused when it shouldn't"));
1.684 + StopTest(KErrGeneral);
1.685 + }
1.686 +
1.687 +/*
1.688 + *========================================================================================================
1.689 + * MM-MMF-ACLNT-I-0176-HP
1.690 + *========================================================================================================
1.691 + */
1.692 +RMdaOutputStreamResumeTest::RMdaOutputStreamResumeTest(const TDesC& aTestName, const TDesC& aSectName)
1.693 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.694 + {
1.695 + }
1.696 +
1.697 +/*
1.698 + *
1.699 + * NewL
1.700 + *
1.701 + */
1.702 +RMdaOutputStreamResumeTest* RMdaOutputStreamResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.703 + {
1.704 + RMdaOutputStreamResumeTest * self = new(ELeave)RMdaOutputStreamResumeTest(aTestName,aSectName);
1.705 + return self;
1.706 + }
1.707 +
1.708 +/*
1.709 + *
1.710 + * DoKickoffTestL
1.711 + *
1.712 + */
1.713 +void RMdaOutputStreamResumeTest::DoKickoffTestL()
1.714 + {
1.715 + TPtrC filename;
1.716 + // Get the pause time
1.717 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.718 + {
1.719 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.720 + StopTest(KErrNotFound);
1.721 + return;
1.722 + }
1.723 + // Get the filename of the audio file to play
1.724 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.725 + {
1.726 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.727 + StopTest(KErrNotFound);
1.728 + return;
1.729 + }
1.730 + // open using RFile for playback
1.731 + iFilename.Copy(filename);
1.732 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.733 + if (err != KErrNone)
1.734 + {
1.735 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.736 + iFs.Close();
1.737 + StopTest(err);
1.738 + return;
1.739 + }
1.740 + // Get size of iFile
1.741 + TInt filesize = 0;
1.742 + err = iFile.Size(filesize);
1.743 + if (err != KErrNone)
1.744 + {
1.745 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.746 + StopTest(err);
1.747 + return;
1.748 + }
1.749 + // Initialise iBuf
1.750 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.751 +
1.752 + //Read first half of the file
1.753 + err = iFile.Read(iBuffer);
1.754 + if (err != KErrNone)
1.755 + {
1.756 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.757 + StopTest(err);
1.758 + }
1.759 +
1.760 + iWait = ETrue;
1.761 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.762 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.763 + }
1.764 +
1.765 +/*
1.766 + *
1.767 + * DoTimerCallback
1.768 + *
1.769 + */
1.770 +void RMdaOutputStreamResumeTest::DoTimerCallback()
1.771 + {
1.772 + if(!iWait)
1.773 + {
1.774 + INFO_PRINTF1(_L("Cancelling timer"));
1.775 + iTimer->Cancel();
1.776 + }
1.777 + else
1.778 + {
1.779 + INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
1.780 + }
1.781 + Fsm (EEventAOSTimerComplete, KErrNone);
1.782 + }
1.783 +
1.784 +/*
1.785 + *========================================================================================================
1.786 + * MM-MMF-ACLNT-I-0177-HP
1.787 + *========================================================================================================
1.788 + */
1.789 +RMdaOutputStreamResumeThriceTest::RMdaOutputStreamResumeThriceTest(const TDesC& aTestName, const TDesC& aSectName)
1.790 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.791 + {
1.792 + }
1.793 +
1.794 +/*
1.795 + *
1.796 + * NewL
1.797 + *
1.798 + */
1.799 +RMdaOutputStreamResumeThriceTest* RMdaOutputStreamResumeThriceTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.800 + {
1.801 + RMdaOutputStreamResumeThriceTest * self = new(ELeave)RMdaOutputStreamResumeThriceTest(aTestName,aSectName);
1.802 + return self;
1.803 + }
1.804 +
1.805 +/*
1.806 + *
1.807 + * DoKickoffTestL
1.808 + *
1.809 + */
1.810 +void RMdaOutputStreamResumeThriceTest::DoKickoffTestL()
1.811 + {
1.812 + TPtrC filename;
1.813 + // Get the pause time
1.814 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.815 + {
1.816 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.817 + StopTest(KErrNotFound);
1.818 + return;
1.819 + }
1.820 + // Get the filename of the audio file to play
1.821 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.822 + {
1.823 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.824 + StopTest(KErrNotFound);
1.825 + return;
1.826 + }
1.827 + // open using RFile for playback
1.828 + iFilename.Copy(filename);
1.829 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.830 + if (err != KErrNone)
1.831 + {
1.832 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.833 + iFs.Close();
1.834 + StopTest(err);
1.835 + return;
1.836 + }
1.837 + // Get size of iFile
1.838 + TInt filesize = 0;
1.839 + err = iFile.Size(filesize);
1.840 + if (err != KErrNone)
1.841 + {
1.842 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.843 + StopTest(err);
1.844 + return;
1.845 + }
1.846 + // Initialise iBuf
1.847 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.848 +
1.849 + //Read first half of the file
1.850 + err = iFile.Read(iBuffer);
1.851 + if (err != KErrNone)
1.852 + {
1.853 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.854 + StopTest(err);
1.855 + }
1.856 +
1.857 + iWait = ETrue;
1.858 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.859 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.860 + }
1.861 +
1.862 +/*
1.863 + *
1.864 + * DoTimerCallback
1.865 + *
1.866 + */
1.867 +void RMdaOutputStreamResumeThriceTest::DoTimerCallback()
1.868 + {
1.869 + iCount++;
1.870 + if(!iWait && iCount == 2*KRepeatThrice) //Repeating Pause-Resume cycle three times. Timer should be called 6 times
1.871 + {
1.872 + iTimer->Cancel();
1.873 + Fsm (EEventAOSTimerComplete, KErrNone);
1.874 + }
1.875 + else
1.876 + {
1.877 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.878 + Fsm (EEventAOSTimerComplete, KErrNone);
1.879 + }
1.880 + }
1.881 +
1.882 +/*
1.883 + *========================================================================================================
1.884 + * MM-MMF-ACLNT-I-0178-HP
1.885 + *========================================================================================================
1.886 + */
1.887 +RMdaOutputStreamConfigInPauseTest::RMdaOutputStreamConfigInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1.888 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.889 + {
1.890 + }
1.891 +
1.892 +/*
1.893 + *
1.894 + * NewL
1.895 + *
1.896 + */
1.897 +RMdaOutputStreamConfigInPauseTest* RMdaOutputStreamConfigInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.898 + {
1.899 + RMdaOutputStreamConfigInPauseTest * self = new(ELeave)RMdaOutputStreamConfigInPauseTest(aTestName,aSectName);
1.900 + return self;
1.901 + }
1.902 +
1.903 +/*
1.904 + *
1.905 + * DoKickoffTestL
1.906 + *
1.907 + */
1.908 +void RMdaOutputStreamConfigInPauseTest::DoKickoffTestL()
1.909 + {
1.910 + TPtrC filename;
1.911 + // Get the pause time
1.912 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.913 + {
1.914 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.915 + StopTest(KErrNotFound);
1.916 + return;
1.917 + }
1.918 + // Get the filename of the audio file to play
1.919 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.920 + {
1.921 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.922 + StopTest(KErrNotFound);
1.923 + return;
1.924 + }
1.925 + // Get the volume
1.926 + if (!GetIntFromConfig(iSectName, KVolume, iVolume))
1.927 + {
1.928 + ERR_PRINTF1(_L("Volume could not be retrieved from ini file"));
1.929 + StopTest(KErrNotFound);
1.930 + return;
1.931 + }
1.932 + // Get the balance
1.933 + if (!GetIntFromConfig(iSectName, KBalance, iBalance))
1.934 + {
1.935 + ERR_PRINTF1(_L("Balance could not be retrieved from ini file"));
1.936 + StopTest(KErrNotFound);
1.937 + return;
1.938 + }
1.939 + // open using RFile for playback
1.940 + iFilename.Copy(filename);
1.941 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.942 + if (err != KErrNone)
1.943 + {
1.944 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.945 + iFs.Close();
1.946 + StopTest(err);
1.947 + return;
1.948 + }
1.949 + // Get size of iFile
1.950 + TInt filesize = 0;
1.951 + err = iFile.Size(filesize);
1.952 + if (err != KErrNone)
1.953 + {
1.954 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.955 + StopTest(err);
1.956 + return;
1.957 + }
1.958 + // Initialise iBuf
1.959 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.960 +
1.961 + //Read first half of the file
1.962 + err = iFile.Read(iBuffer);
1.963 + if (err != KErrNone)
1.964 + {
1.965 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.966 + StopTest(err);
1.967 + }
1.968 +
1.969 + iWait = ETrue;
1.970 + iConfig = ETrue;
1.971 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.972 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.973 + }
1.974 +
1.975 +/*
1.976 + *
1.977 + * DoTimerCallback
1.978 + *
1.979 + */
1.980 +void RMdaOutputStreamConfigInPauseTest::DoTimerCallback()
1.981 + {
1.982 + if(!iWait && !iConfig)
1.983 + {
1.984 + iTimer->Cancel();
1.985 + INFO_PRINTF1(_L("Comparing Volume and Balance with values set"));
1.986 + if (iVolume == iAudioOutputStream->Volume() && Abs(iBalance - iAudioOutputStream->GetBalanceL())<KBalanceTolerance)
1.987 + {
1.988 + INFO_PRINTF3(_L("Volume = %d and Balance = %d as expected"),iVolume,iBalance);
1.989 + }
1.990 + else
1.991 + {
1.992 + ERR_PRINTF1(_L("Retrieved values are different than expected"));
1.993 + ERR_PRINTF5(_L("Retrieved Volume = %d and Balance = %d. Expected Volume = %d and Balance = %d"),iAudioOutputStream->Volume(),iAudioOutputStream->GetBalanceL(),iVolume,iBalance);
1.994 + StopTest(KErrGeneral);
1.995 + }
1.996 + }
1.997 + else
1.998 + {
1.999 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.1000 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1001 + }
1.1002 + }
1.1003 +
1.1004 +/*
1.1005 + *========================================================================================================
1.1006 + * MM-MMF-ACLNT-I-0179-HP
1.1007 + *========================================================================================================
1.1008 + */
1.1009 +RMdaOutputStreamInvalidConfigInPauseTest::RMdaOutputStreamInvalidConfigInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1.1010 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.1011 + {
1.1012 + }
1.1013 +
1.1014 +/*
1.1015 + *
1.1016 + * NewL
1.1017 + *
1.1018 + */
1.1019 +RMdaOutputStreamInvalidConfigInPauseTest* RMdaOutputStreamInvalidConfigInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1020 + {
1.1021 + RMdaOutputStreamInvalidConfigInPauseTest * self = new(ELeave)RMdaOutputStreamInvalidConfigInPauseTest(aTestName,aSectName);
1.1022 + return self;
1.1023 + }
1.1024 +
1.1025 +/*
1.1026 + *
1.1027 + * DoKickoffTestL
1.1028 + *
1.1029 + */
1.1030 +void RMdaOutputStreamInvalidConfigInPauseTest::DoKickoffTestL()
1.1031 + {
1.1032 + TPtrC filename;
1.1033 + // Get the pause time
1.1034 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1035 + {
1.1036 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1037 + StopTest(KErrNotFound);
1.1038 + return;
1.1039 + }
1.1040 + // Get the filename of the audio file to play
1.1041 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.1042 + {
1.1043 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1044 + StopTest(KErrNotFound);
1.1045 + return;
1.1046 + }
1.1047 + // open using RFile for playback
1.1048 + iFilename.Copy(filename);
1.1049 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1050 + if (err != KErrNone)
1.1051 + {
1.1052 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1053 + iFs.Close();
1.1054 + StopTest(err);
1.1055 + return;
1.1056 + }
1.1057 + // Get size of iFile
1.1058 + TInt filesize = 0;
1.1059 + err = iFile.Size(filesize);
1.1060 + if (err != KErrNone)
1.1061 + {
1.1062 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.1063 + StopTest(err);
1.1064 + return;
1.1065 + }
1.1066 + // Initialise iBuf
1.1067 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.1068 +
1.1069 + //Read first half of the file
1.1070 + err = iFile.Read(iBuffer);
1.1071 + if (err != KErrNone)
1.1072 + {
1.1073 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.1074 + StopTest(err);
1.1075 + }
1.1076 +
1.1077 + iWait = ETrue;
1.1078 + iInvalidConfig = ETrue;
1.1079 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1080 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1081 + }
1.1082 +
1.1083 +/*
1.1084 + *
1.1085 + * DoTimerCallback
1.1086 + *
1.1087 + */
1.1088 +void RMdaOutputStreamInvalidConfigInPauseTest::DoTimerCallback()
1.1089 + {
1.1090 + if(!iWait)
1.1091 + {
1.1092 + INFO_PRINTF1(_L("Cancelling timer"));
1.1093 + iTimer->Cancel();
1.1094 + }
1.1095 + else
1.1096 + {
1.1097 + INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
1.1098 + }
1.1099 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1100 + }
1.1101 +
1.1102 +/*
1.1103 + *========================================================================================================
1.1104 + * MM-MMF-ACLNT-I-0180-HP
1.1105 + *========================================================================================================
1.1106 + */
1.1107 +RMdaOutputStreamGetBytesInPauseTest::RMdaOutputStreamGetBytesInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1.1108 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.1109 + {
1.1110 + }
1.1111 +
1.1112 +/*
1.1113 + *
1.1114 + * NewL
1.1115 + *
1.1116 + */
1.1117 +RMdaOutputStreamGetBytesInPauseTest* RMdaOutputStreamGetBytesInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1118 + {
1.1119 + RMdaOutputStreamGetBytesInPauseTest * self = new(ELeave)RMdaOutputStreamGetBytesInPauseTest(aTestName,aSectName);
1.1120 + return self;
1.1121 + }
1.1122 +
1.1123 +/*
1.1124 + *
1.1125 + * DoKickoffTestL
1.1126 + *
1.1127 + */
1.1128 +void RMdaOutputStreamGetBytesInPauseTest::DoKickoffTestL()
1.1129 + {
1.1130 + TPtrC filename;
1.1131 + // Get the pause time
1.1132 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1133 + {
1.1134 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1135 + StopTest(KErrNotFound);
1.1136 + return;
1.1137 + }
1.1138 + // Get the filename of the audio file to play
1.1139 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.1140 + {
1.1141 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1142 + StopTest(KErrNotFound);
1.1143 + return;
1.1144 + }
1.1145 + // open using RFile for playback
1.1146 + iFilename.Copy(filename);
1.1147 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1148 + if (err != KErrNone)
1.1149 + {
1.1150 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1151 + iFs.Close();
1.1152 + StopTest(err);
1.1153 + return;
1.1154 + }
1.1155 + // Get size of iFile
1.1156 + TInt filesize = 0;
1.1157 + err = iFile.Size(filesize);
1.1158 + if (err != KErrNone)
1.1159 + {
1.1160 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.1161 + StopTest(err);
1.1162 + return;
1.1163 + }
1.1164 + // Initialise iBuf
1.1165 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.1166 +
1.1167 + //Read first half of the file
1.1168 + err = iFile.Read(iBuffer);
1.1169 + if (err != KErrNone)
1.1170 + {
1.1171 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.1172 + StopTest(err);
1.1173 + }
1.1174 +
1.1175 + iWait = ETrue;
1.1176 + iGetBytes = ETrue;
1.1177 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1178 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1179 + }
1.1180 +
1.1181 +/*
1.1182 + *
1.1183 + * DoTimerCallback
1.1184 + *
1.1185 + */
1.1186 +void RMdaOutputStreamGetBytesInPauseTest::DoTimerCallback()
1.1187 + {
1.1188 + if(!iWait)
1.1189 + {
1.1190 + INFO_PRINTF1(_L("Cancelling timer"));
1.1191 + iTimer->Cancel();
1.1192 + }
1.1193 + else
1.1194 + {
1.1195 + INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
1.1196 + }
1.1197 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1198 + }
1.1199 +
1.1200 +/*
1.1201 + *========================================================================================================
1.1202 + * MM-MMF-ACLNT-I-0181-HP
1.1203 + *========================================================================================================
1.1204 + */
1.1205 +RMdaOutputStreamPlayPauseStopPlayTest::RMdaOutputStreamPlayPauseStopPlayTest(const TDesC& aTestName, const TDesC& aSectName)
1.1206 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.1207 + {
1.1208 + }
1.1209 +
1.1210 +/*
1.1211 + *
1.1212 + * NewL
1.1213 + *
1.1214 + */
1.1215 +RMdaOutputStreamPlayPauseStopPlayTest* RMdaOutputStreamPlayPauseStopPlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1216 + {
1.1217 + RMdaOutputStreamPlayPauseStopPlayTest * self = new(ELeave)RMdaOutputStreamPlayPauseStopPlayTest(aTestName,aSectName);
1.1218 + return self;
1.1219 + }
1.1220 +
1.1221 +/*
1.1222 + *
1.1223 + * DoKickoffTestL
1.1224 + *
1.1225 + */
1.1226 +void RMdaOutputStreamPlayPauseStopPlayTest::DoKickoffTestL()
1.1227 + {
1.1228 + TPtrC filename;
1.1229 + // Get the pause time
1.1230 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1231 + {
1.1232 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1233 + StopTest(KErrNotFound);
1.1234 + return;
1.1235 + }
1.1236 + // Get the filename of the audio file to play
1.1237 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.1238 + {
1.1239 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1240 + StopTest(KErrNotFound);
1.1241 + return;
1.1242 + }
1.1243 + // open using RFile for playback
1.1244 + iFilename.Copy(filename);
1.1245 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1246 + if (err != KErrNone)
1.1247 + {
1.1248 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1249 + iFs.Close();
1.1250 + StopTest(err);
1.1251 + return;
1.1252 + }
1.1253 + // Get size of iFile
1.1254 + TInt filesize = 0;
1.1255 + err = iFile.Size(filesize);
1.1256 + if (err != KErrNone)
1.1257 + {
1.1258 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.1259 + StopTest(err);
1.1260 + return;
1.1261 + }
1.1262 + // Initialise iBuf
1.1263 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.1264 +
1.1265 + //Read first half of the file
1.1266 + err = iFile.Read(iBuffer);
1.1267 + if (err != KErrNone)
1.1268 + {
1.1269 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.1270 + StopTest(err);
1.1271 + }
1.1272 +
1.1273 + iWait = ETrue;
1.1274 + iStop = ETrue;
1.1275 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1276 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1277 + }
1.1278 +
1.1279 +/*
1.1280 + *
1.1281 + * DoTimerCallback
1.1282 + *
1.1283 + */
1.1284 +void RMdaOutputStreamPlayPauseStopPlayTest::DoTimerCallback()
1.1285 + {
1.1286 + if(!iWait && iStop)
1.1287 + {
1.1288 + iAudioOutputStreamState = EStateAOSStopped;
1.1289 + iStop = EFalse;
1.1290 + iWait = ETrue;
1.1291 + INFO_PRINTF1(_L("MAudioOutputStream Event: EEventTimerComplete"));
1.1292 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1293 + }
1.1294 + else if(!iWait && !iStop)
1.1295 + {
1.1296 + iTimer->Cancel();
1.1297 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1298 + }
1.1299 + else
1.1300 + {
1.1301 + INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1.1302 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1303 + }
1.1304 + }
1.1305 +
1.1306 +/*
1.1307 + *
1.1308 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.1309 + *
1.1310 + */
1.1311 +void RMdaOutputStreamPlayPauseStopPlayTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1.1312 + {
1.1313 + TInt error = 0;
1.1314 + TTimeIntervalMicroSeconds resumeposition;
1.1315 + switch (iAudioOutputStreamState)
1.1316 + {
1.1317 + case EStateAOSCreated:
1.1318 + {
1.1319 + if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1.1320 + {
1.1321 + TMdaAudioDataSettings settings;
1.1322 + //Default settings
1.1323 + settings.Query();
1.1324 + settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1.1325 + settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1.1326 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1.1327 + iAudioOutputStream->Open(&settings);
1.1328 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1.1329 + iAudioOutputStreamState = EStateAOSInitializing;
1.1330 + }
1.1331 + else
1.1332 + {
1.1333 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1334 + StopTest(aError, EFail);
1.1335 + }
1.1336 + break;
1.1337 + }
1.1338 + case EStateAOSInitializing:
1.1339 + {
1.1340 + if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1.1341 + {
1.1342 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.1343 + iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1.1344 + INFO_PRINTF1(_L("Starting playback"));
1.1345 + iAudioOutputStream->WriteL(iBuffer);
1.1346 + iAudioOutputStreamState = EStateAOSPlaying;
1.1347 + StartTimer(iPause*KOneSecond);
1.1348 + }
1.1349 + else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1.1350 + {
1.1351 + ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1.1352 + StopTest(aError);
1.1353 + }
1.1354 + else
1.1355 + {
1.1356 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1357 + StopTest(aError, EFail);
1.1358 + }
1.1359 + break;
1.1360 + }
1.1361 + case EStateAOSPlaying:
1.1362 + {
1.1363 + if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.1364 + {
1.1365 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
1.1366 + error = iAudioOutputStream->Pause();
1.1367 + if(error == KErrNone)
1.1368 + {
1.1369 + INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
1.1370 + }
1.1371 + else
1.1372 + {
1.1373 + ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
1.1374 + StopTest(error);
1.1375 + }
1.1376 + iPosition = iAudioOutputStream->Position();
1.1377 + INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
1.1378 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
1.1379 + iAudioOutputStreamState = EStateAOSPause;
1.1380 + iWait = EFalse;
1.1381 + }
1.1382 + else
1.1383 + {
1.1384 + ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1385 + StopTest(aError, EFail);
1.1386 + }
1.1387 + break;
1.1388 + }
1.1389 + case EStateAOSPause:
1.1390 + {
1.1391 + if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.1392 + {
1.1393 + if(iPosition == iAudioOutputStream->Position())
1.1394 + {
1.1395 + INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1.1396 + }
1.1397 + else
1.1398 + {
1.1399 + ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1.1400 + StopTest(KErrGeneral);
1.1401 + }
1.1402 + INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1.1403 + error = iAudioOutputStream->Resume();
1.1404 + resumeposition = iAudioOutputStream->Position();
1.1405 + if(error == KErrNone)
1.1406 + {
1.1407 + INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1.1408 + iAudioOutputStreamState = EStateAOSPlaying;
1.1409 + if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1.1410 + {
1.1411 + INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1.1412 + }
1.1413 + else
1.1414 + {
1.1415 + ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1.1416 + StopTest(KErrGeneral);
1.1417 + }
1.1418 + }
1.1419 + else
1.1420 + {
1.1421 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1.1422 + StopTest(error);
1.1423 + }
1.1424 + }
1.1425 + else
1.1426 + {
1.1427 + ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1428 + StopTest(aError, EFail);
1.1429 + }
1.1430 + break;
1.1431 + }
1.1432 + case EStateAOSStopped:
1.1433 + {
1.1434 + if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.1435 + {
1.1436 + if(iWait)
1.1437 + {
1.1438 + INFO_PRINTF1(_L("Stopping playback for 2 seconds"));
1.1439 + iAudioOutputStream->Stop();
1.1440 + iWait = EFalse;
1.1441 + }
1.1442 + else
1.1443 + {
1.1444 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume while in Stop"));
1.1445 + error = iAudioOutputStream->Resume();
1.1446 + if(error == KErrNotReady)
1.1447 + {
1.1448 + INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
1.1449 + }
1.1450 + else
1.1451 + {
1.1452 + ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
1.1453 + StopTest(error);
1.1454 + }
1.1455 + TInt filepos = 0;
1.1456 + INFO_PRINTF1(_L("Restarting file to start position"));
1.1457 + error = iFile.Seek(ESeekStart, filepos);
1.1458 + if (error != KErrNone)
1.1459 + {
1.1460 + INFO_PRINTF2(_L("Error restarting iFile %d"), error);
1.1461 + StopTest(error);
1.1462 + }
1.1463 + error = iFile.Read(iBuffer);
1.1464 + if (error != KErrNone)
1.1465 + {
1.1466 + INFO_PRINTF2(_L("Error reading iFile %d"), error);
1.1467 + StopTest(error);
1.1468 + }
1.1469 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::WriteL while in Stop to restart playback"));
1.1470 + iAudioOutputStream->WriteL(iBuffer);
1.1471 + iAudioOutputStreamState = EStateAOSPlaying;
1.1472 + }
1.1473 + }
1.1474 + else
1.1475 + {
1.1476 + ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1477 + StopTest(aError, EFail);
1.1478 + }
1.1479 + break;
1.1480 + }
1.1481 + default:
1.1482 + {
1.1483 + ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1.1484 + StopTest(KErrGeneral);
1.1485 + }
1.1486 + }
1.1487 + }
1.1488 +
1.1489 +/*
1.1490 + *
1.1491 + * MaoscPlayComplete - From MMdaAudioOutputStreamObserver
1.1492 + *
1.1493 + */
1.1494 +void RMdaOutputStreamPlayPauseStopPlayTest::MaoscPlayComplete(TInt aError)
1.1495 + {
1.1496 + INFO_PRINTF1(_L("========== AudioOutputStream MaoscPlayComplete() callback =========="));
1.1497 + if(iAudioOutputStreamState == EStateAOSStopped)
1.1498 + {
1.1499 + if (aError == KErrCancel)
1.1500 + {
1.1501 + INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
1.1502 + }
1.1503 + else
1.1504 + {
1.1505 + ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
1.1506 + ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1.1507 + StopTest(aError);
1.1508 + }
1.1509 + }
1.1510 + else if(iAudioOutputStreamState == EStateAOSPlaying)
1.1511 + {
1.1512 + if(aError == KErrUnderflow)
1.1513 + {
1.1514 + INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
1.1515 + StopTest(EPass);
1.1516 + }
1.1517 + else
1.1518 + {
1.1519 + ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
1.1520 + ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1.1521 + StopTest(aError);
1.1522 + }
1.1523 + }
1.1524 + else
1.1525 + {
1.1526 + ERR_PRINTF1(_L("AudioOutputStream called MaoscPlayComplete at invalid state"));
1.1527 + StopTest(KErrGeneral);
1.1528 + }
1.1529 + }
1.1530 +
1.1531 +/*
1.1532 + *========================================================================================================
1.1533 + * MM-MMF-ACLNT-I-0182-HP
1.1534 + *========================================================================================================
1.1535 + */
1.1536 +RMdaOutputStreamInvalidFormatsTest::RMdaOutputStreamInvalidFormatsTest(const TDesC& aTestName, const TDesC& aSectName)
1.1537 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.1538 + {
1.1539 + }
1.1540 +
1.1541 +/*
1.1542 + *
1.1543 + * NewL
1.1544 + *
1.1545 + */
1.1546 +RMdaOutputStreamInvalidFormatsTest* RMdaOutputStreamInvalidFormatsTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1547 + {
1.1548 + RMdaOutputStreamInvalidFormatsTest * self = new(ELeave)RMdaOutputStreamInvalidFormatsTest(aTestName,aSectName);
1.1549 + return self;
1.1550 + }
1.1551 +
1.1552 +/*
1.1553 + *
1.1554 + * DoKickoffTestL
1.1555 + *
1.1556 + */
1.1557 +void RMdaOutputStreamInvalidFormatsTest::DoKickoffTestL()
1.1558 + {
1.1559 + TPtrC filename;
1.1560 + // Get the pause time
1.1561 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1562 + {
1.1563 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1564 + StopTest(KErrNotFound);
1.1565 + return;
1.1566 + }
1.1567 + // Get the filename of the audio file to play
1.1568 + if (!GetStringFromConfig(iSectName, KOggFile, filename))
1.1569 + {
1.1570 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1571 + StopTest(KErrNotFound);
1.1572 + return;
1.1573 + }
1.1574 + // open using RFile for playback
1.1575 + iFilename.Copy(filename);
1.1576 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1577 + if (err != KErrNone)
1.1578 + {
1.1579 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1580 + iFs.Close();
1.1581 + StopTest(err);
1.1582 + return;
1.1583 + }
1.1584 + // Get size of iFile
1.1585 + TInt filesize = 0;
1.1586 + err = iFile.Size(filesize);
1.1587 + if (err != KErrNone)
1.1588 + {
1.1589 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.1590 + StopTest(err);
1.1591 + return;
1.1592 + }
1.1593 + // Initialise iBuf
1.1594 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.1595 +
1.1596 + //Read first half of the file
1.1597 + err = iFile.Read(iBuffer);
1.1598 + if (err != KErrNone)
1.1599 + {
1.1600 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.1601 + StopTest(err);
1.1602 + }
1.1603 +
1.1604 + iWait = ETrue;
1.1605 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1606 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1607 + }
1.1608 +
1.1609 +/*
1.1610 + *
1.1611 + * DoTimerCallback
1.1612 + *
1.1613 + */
1.1614 +void RMdaOutputStreamInvalidFormatsTest::DoTimerCallback()
1.1615 + {
1.1616 + INFO_PRINTF1(_L("Cancelling timer"));
1.1617 + iTimer->Cancel();
1.1618 + Fsm (EEventAOSTimerComplete, KErrNone);
1.1619 + }
1.1620 +
1.1621 +/*
1.1622 + *
1.1623 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.1624 + *
1.1625 + */
1.1626 +void RMdaOutputStreamInvalidFormatsTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1.1627 + {
1.1628 + TInt error = 0;
1.1629 + TTimeIntervalMicroSeconds resumeposition;
1.1630 + switch (iAudioOutputStreamState)
1.1631 + {
1.1632 + case EStateAOSCreated:
1.1633 + {
1.1634 + if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1.1635 + {
1.1636 + TMdaAudioDataSettings settings;
1.1637 + //setting for OGG file
1.1638 + settings.Query();
1.1639 + settings.iChannels = TMdaAudioDataSettings::EChannelsStereo;
1.1640 + settings.iSampleRate = TMdaAudioDataSettings::ESampleRate44100Hz;
1.1641 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1.1642 + iAudioOutputStream->Open(&settings);
1.1643 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1.1644 + iAudioOutputStreamState = EStateAOSInitializing;
1.1645 + }
1.1646 + else
1.1647 + {
1.1648 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1649 + StopTest(aError, EFail);
1.1650 + }
1.1651 + break;
1.1652 + }
1.1653 + case EStateAOSInitializing:
1.1654 + {
1.1655 + if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1.1656 + {
1.1657 + TFourCC KVORBDataType('V', 'O', 'R', 'B');
1.1658 + TRAPD(err,iAudioOutputStream->SetDataTypeL(KVORBDataType));
1.1659 + if(err != KErrNone)
1.1660 + {
1.1661 + INFO_PRINTF1(_L("Failed to set non-PCM Format"));
1.1662 + StopTest(err);
1.1663 + }
1.1664 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.1665 + iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1.1666 + INFO_PRINTF1(_L("Starting playback"));
1.1667 + iAudioOutputStream->WriteL(iBuffer);
1.1668 + iAudioOutputStreamState = EStateAOSPlaying;
1.1669 + StartTimer(iPause*KOneSecond);
1.1670 + }
1.1671 + else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1.1672 + {
1.1673 + ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1.1674 + StopTest(aError);
1.1675 + }
1.1676 + else
1.1677 + {
1.1678 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1679 + StopTest(aError, EFail);
1.1680 + }
1.1681 + break;
1.1682 + }
1.1683 + case EStateAOSPlaying:
1.1684 + {
1.1685 + if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1.1686 + {
1.1687 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause while playing non-PCM format"));
1.1688 + error = iAudioOutputStream->Pause();
1.1689 + if(error == KErrNotSupported)
1.1690 + {
1.1691 + INFO_PRINTF1(_L("Pause while playing non-PCM format returned with KErrNotSupported as expected"));
1.1692 + }
1.1693 + else
1.1694 + {
1.1695 + ERR_PRINTF2(_L("Pause while playing non-PCM format returned with %d instead of KErrNotReady as expected"),error);
1.1696 + StopTest(error);
1.1697 + }
1.1698 + }
1.1699 + else
1.1700 + {
1.1701 + ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1702 + StopTest(aError, EFail);
1.1703 + }
1.1704 + break;
1.1705 + }
1.1706 + default:
1.1707 + {
1.1708 + ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1.1709 + StopTest(KErrGeneral);
1.1710 + }
1.1711 + }
1.1712 + }
1.1713 +
1.1714 +/*
1.1715 + *========================================================================================================
1.1716 + * MM-MMF-ACLNT-I-0184-HP
1.1717 + *========================================================================================================
1.1718 + */
1.1719 +RMdaOutputStreamPauseNonA3FTest::RMdaOutputStreamPauseNonA3FTest(const TDesC& aTestName, const TDesC& aSectName)
1.1720 + : RMdaOutputStreamTestBase(aTestName,aSectName)
1.1721 + {
1.1722 + }
1.1723 +
1.1724 +/*
1.1725 + *
1.1726 + * NewL
1.1727 + *
1.1728 + */
1.1729 +RMdaOutputStreamPauseNonA3FTest* RMdaOutputStreamPauseNonA3FTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.1730 + {
1.1731 + RMdaOutputStreamPauseNonA3FTest * self = new(ELeave)RMdaOutputStreamPauseNonA3FTest(aTestName,aSectName);
1.1732 + return self;
1.1733 + }
1.1734 +
1.1735 +/*
1.1736 + *
1.1737 + * DoKickoffTestL
1.1738 + *
1.1739 + */
1.1740 +void RMdaOutputStreamPauseNonA3FTest::DoKickoffTestL()
1.1741 + {
1.1742 + TPtrC filename;
1.1743 + // Get the pause time
1.1744 + if (!GetIntFromConfig(iSectName, KPause, iPause))
1.1745 + {
1.1746 + ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1.1747 + StopTest(KErrNotFound);
1.1748 + return;
1.1749 + }
1.1750 + // Get the filename of the audio file to play
1.1751 + if (!GetStringFromConfig(iSectName, KRawFile, filename))
1.1752 + {
1.1753 + ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1.1754 + StopTest(KErrNotFound);
1.1755 + return;
1.1756 + }
1.1757 + // open using RFile for playback
1.1758 + iFilename.Copy(filename);
1.1759 + TInt err = iFile.Open(iFs, iFilename, EFileRead);
1.1760 + if (err != KErrNone)
1.1761 + {
1.1762 + ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1.1763 + iFs.Close();
1.1764 + StopTest(err);
1.1765 + return;
1.1766 + }
1.1767 + // Get size of iFile
1.1768 + TInt filesize = 0;
1.1769 + err = iFile.Size(filesize);
1.1770 + if (err != KErrNone)
1.1771 + {
1.1772 + INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1.1773 + StopTest(err);
1.1774 + return;
1.1775 + }
1.1776 + // Initialise iBuf
1.1777 + iBuffer.CreateMaxL(filesize/KFileDivision);
1.1778 +
1.1779 + //Read first half of the file
1.1780 + err = iFile.Read(iBuffer);
1.1781 + if (err != KErrNone)
1.1782 + {
1.1783 + INFO_PRINTF2(_L("Error reading iFile %d"), err);
1.1784 + StopTest(err);
1.1785 + }
1.1786 +
1.1787 + iPause = KTimeout; //Set timeout to stop test if playback was paused
1.1788 + iWait = ETrue;
1.1789 + INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1.1790 + iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1.1791 + }
1.1792 +
1.1793 +/*
1.1794 + *
1.1795 + * DoTimerCallback
1.1796 + *
1.1797 + */
1.1798 +void RMdaOutputStreamPauseNonA3FTest::DoTimerCallback()
1.1799 + {
1.1800 + INFO_PRINTF1(_L("Cancelling timer"));
1.1801 + iTimer->Cancel();
1.1802 + ERR_PRINTF1(_L("Playback was paused when it shouldn't"));
1.1803 + StopTest(KErrGeneral);
1.1804 + }
1.1805 +
1.1806 +/*
1.1807 + *
1.1808 + * Fsm - Executes playing events of AudioToneUtility in sequence
1.1809 + *
1.1810 + */
1.1811 +void RMdaOutputStreamPauseNonA3FTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1.1812 + {
1.1813 + switch (iAudioOutputStreamState)
1.1814 + {
1.1815 + case EStateAOSCreated:
1.1816 + {
1.1817 + if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1.1818 + {
1.1819 + TMdaAudioDataSettings settings;
1.1820 + //Default settings
1.1821 + settings.Query();
1.1822 + settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1.1823 + settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1.1824 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1.1825 + iAudioOutputStream->Open(&settings);
1.1826 + INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1.1827 + iAudioOutputStreamState = EStateAOSInitializing;
1.1828 + }
1.1829 + else
1.1830 + {
1.1831 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1832 + StopTest(aError, EFail);
1.1833 + }
1.1834 + break;
1.1835 + }
1.1836 + case EStateAOSInitializing:
1.1837 + {
1.1838 + if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1.1839 + {
1.1840 + INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1.1841 + iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1.1842 + INFO_PRINTF1(_L("Starting playback"));
1.1843 + iAudioOutputStream->WriteL(iBuffer);
1.1844 + StartTimer(iPause*KOneSecond);
1.1845 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause in non-a3f configuration"));
1.1846 + TInt err = iAudioOutputStream->Pause();
1.1847 + if(err == KErrNotSupported)
1.1848 + {
1.1849 + INFO_PRINTF1(_L("Pause in CMdaAudioOutputStream returned with KErrNotSupported as expected"));
1.1850 + }
1.1851 + else
1.1852 + {
1.1853 + ERR_PRINTF2(_L("Pause in CMdaAudioOutputStream returned with %d instead of KErrNotSupported as expected"),err);
1.1854 + StopTest(err);
1.1855 + }
1.1856 + INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume in non-a3f configuration"));
1.1857 + err = iAudioOutputStream->Resume();
1.1858 + if(err == KErrNotReady)
1.1859 + {
1.1860 + INFO_PRINTF1(_L("Resume in CMdaAudioOutputStream returned with KErrNotReady as expected"));
1.1861 + }
1.1862 + else
1.1863 + {
1.1864 + ERR_PRINTF2(_L("Resume in CMdaAudioOutputStream returned with %d instead of KErrNotReady as expected"),err);
1.1865 + StopTest(err);
1.1866 + }
1.1867 + }
1.1868 + else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1.1869 + {
1.1870 + ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1.1871 + StopTest(aError);
1.1872 + }
1.1873 + else
1.1874 + {
1.1875 + ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1.1876 + StopTest(aError, EFail);
1.1877 + }
1.1878 + break;
1.1879 + }
1.1880 + default:
1.1881 + {
1.1882 + ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1.1883 + StopTest(KErrGeneral);
1.1884 + }
1.1885 + }
1.1886 + }