Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // CPP file: Audio Resource Notification tests for Multiple Audio Clients.
19 @file TestMultiClientARN.cpp
22 #include "TestAudioClientUtilitiesARN.h"
24 //------------------------------------------------------------------------------
25 //********************PREQ 797 - Audio Resource Notification********************
26 //------------------------------------------------------------------------------
29 //CTestMdaAudioMultiClientCallbackSupport
35 CTestMdaAudioMultiClientCallbackSupport* CTestMdaAudioMultiClientCallbackSupport::NewL(MTestAudioResourceNotificationCallback& aCallback)
37 return new(ELeave) CTestMdaAudioMultiClientCallbackSupport(aCallback);
41 * MarncResourceAvailable
43 void CTestMdaAudioMultiClientCallbackSupport::MarncResourceAvailable(TUid aNotificationEventId, const TDesC8& aNotificationData)
45 iCallback.MarncResourceAvailableTest(aNotificationEventId, aNotificationData, *this);
51 CTestMdaAudioMultiClientCallbackSupport::CTestMdaAudioMultiClientCallbackSupport(MTestAudioResourceNotificationCallback& aCallback):iCallback(aCallback)
57 //CTestMmfAclntMultiClientARN
63 CTestMmfAclntMultiClientARN::CTestMmfAclntMultiClientARN(const TDesC& aTestName, const TDesC& aSectName)
65 // store the name of this test case
66 // this is the name that is used by the script file
67 // Each test step initialises it's own name
68 iTestStepName=aTestName;
70 iSectName = aSectName;
74 * MarncResourceAvailableTest
76 void CTestMmfAclntMultiClientARN::MarncResourceAvailableTest(TUid aNotificationEventId, const TDesC8& aNotificationData, CTestMdaAudioMultiClientCallbackSupport& aMdaAudioMultiClientCallbackSupport)
78 if (aNotificationEventId == KMMFEventCategoryAudioResourceAvailable)
80 INFO_PRINTF1(_L("iAudioOutputStream::MMMFAudioResourceNotificationCallback -> KMMFEventCategoryAudioResourceAvailable"));
82 //Convert TDesc8 to TInt64
83 TMMFTimeIntervalMicroSecondsPckg timeIntvbuf;
84 timeIntvbuf.Copy(aNotificationData);
85 TTimeIntervalMicroSeconds intPos = timeIntvbuf();
88 if (&aMdaAudioMultiClientCallbackSupport == iMdaAudioPlayerCallbackSupport)
90 INFO_PRINTF1(_L("iAudioPlayer -> MMMFAudioResourceNotificationCallback NotificationReceived"));
91 TRAP(iError, FsmL(EMarncResourceAvailablePlayer));
93 else if (&aMdaAudioMultiClientCallbackSupport == iMdaAudioRecorderCallbackSupport)
95 INFO_PRINTF1(_L("iAudioRecorder -> MMMFAudioResourceNotificationCallback NotificationReceived"));
96 TRAP(iError, FsmL(EMarncResourceAvailableRecorder));
98 else if (&aMdaAudioMultiClientCallbackSupport == iMdaAudioOutputStreamCallbackSupport)
100 INFO_PRINTF1(_L("iAudioOutputStream -> MMMFAudioResourceNotificationCallback NotificationReceived"));
101 TRAP(iError, FsmL(EMarncResourceAvailableOS));
106 INFO_PRINTF1(_L("MMMFAudioResourceNotificationCallback, but NOT KMMFEventCategoryAudioResourceAvailable"));
111 * MapcInitCompleteTest
113 void CTestMmfAclntMultiClientARN::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)
115 iDuration = aDuration;
116 INFO_PRINTF2(_L("iAudioPlayer -> MMdaAudioPlayerCallback InitComplete (%d)"),aError);
117 TRAP(iError, FsmL(EMapcInitComplete, aError));
121 * MapcPlayCompleteTest
123 void CTestMmfAclntMultiClientARN::MapcPlayComplete(TInt aError)
125 INFO_PRINTF2(_L("iAudioPlayer -> MMdaAudioPlayerCallback PlayComplete (%d)"), aError);
126 TRAP(iError, FsmL(EMapcPlayComplete, aError));
130 * MoscoStateChangeEventTest
132 void CTestMmfAclntMultiClientARN::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
134 INFO_PRINTF1(_L("iAudioRecorder -> MMdaObjectStateChangeObserver StateChanged"));
135 INFO_PRINTF4(_L("iTestAudioRecorder -> aErrorCode : %d, aPreviousState : %d, aCurrentState : %d"), aErrorCode, aPreviousState, aCurrentState);
136 TRAP(iError, FsmL(EMoscoStateChangeEvent, aErrorCode, iTestAudioRecorder->State()));
140 * MMdaAudioOutputStreamCallback->MaoscOpenComplete
142 void CTestMmfAclntMultiClientARN::MaoscOpenComplete(TInt aError)
144 INFO_PRINTF2(_L("iAudioOutputStream -> MMdaAudioOutputStreamCallback : MaoscOpenComplete (%d)"),aError);
145 TRAP(iError, FsmL(EMaoscOpenComplete, aError));
149 * MMdaAudioOutputStreamCallback->MaoscBufferCopied
151 void CTestMmfAclntMultiClientARN::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
153 INFO_PRINTF2(_L("iAudioOutputStream -> MMdaAudioOutputStreamCallback : MaoscBufferCopied (%d)"), aError);
154 TRAP(iError, FsmL(EMaoscBufferCopied, aError));
158 * MMdaAudioOutputStreamCallback->MaoscPlayComplete
160 void CTestMmfAclntMultiClientARN::MaoscPlayComplete(TInt aError)
162 INFO_PRINTF2(_L("iAudioOutputStream -> MMdaAudioOutputStreamCallback : MaoscPlayComplete (%d)"), aError);
163 TRAP(iError, FsmL(EMaoscPlayComplete, aError));
167 * DoTestStepPreambleL
169 TVerdict CTestMmfAclntMultiClientARN::DoTestStepPreambleL()
171 iError = KErrTimedOut;
175 // Install the scheduler - Call base DoTestStepPreambleL()
176 verdict = CTestMmfAclntStep::DoTestStepPreambleL();
177 if (verdict == EFail)
182 iEventChecker = CMultiEventChecker::NewL();
183 //************** Initialise CMdaAudioPlayerUtility***************
184 INFO_PRINTF1(_L("Initialise CMdaAudioPlayerUtility : EMdaPriorityNormal"));
186 if(!GetStringFromConfig(iSectName, _L("playerAudioFile1"), filename))
188 return EInconclusive;
190 GetDriveName(iFilenamePlayer);
191 iFilenamePlayer.Append(filename);
194 iMdaAudioPlayerCallbackSupport = CTestMdaAudioMultiClientCallbackSupport::NewL(*this);
196 // Initialise Audio Player
197 iTestAudioPlayer = CMdaAudioPlayerUtility::NewL(*this, EMdaPriorityNormal);
199 //************** Initialise CMdaAudioRecorderUtility*************
200 INFO_PRINTF1(_L("Initialise CMdaAudioRecorderUtility : EMdaPriorityMax"));
202 if(!GetStringFromConfig(iSectName, _L("playerAudioFile2"), filename))
204 return EInconclusive;
206 GetDriveName(iFilenameRecorder);
207 iFilenameRecorder.Append(filename);
210 iMdaAudioRecorderCallbackSupport = CTestMdaAudioMultiClientCallbackSupport::NewL(*this);
212 // Initialise Audio Recorder
213 iTestAudioRecorder = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax);
215 //************** Initialise CMdaAudioOutputStream****************
216 INFO_PRINTF1(_L("Initialise CMdaAudioOutputStream : EMdaPriorityMin"));
217 // Connect RFs session
218 TInt err = iFs.Connect();
221 INFO_PRINTF2(_L("Error connecting to File session (RFs) = %d"), err);
225 iMdaAudioOutputStreamCallbackSupport = CTestMdaAudioMultiClientCallbackSupport::NewL(*this);
227 // Initialise iTestAudioOutputStream
228 TRAP(err, iTestAudioOutputStream = CMdaAudioOutputStream::NewL(*this, EMdaPriorityMin, EMdaPriorityPreferenceTimeAndQuality));
229 if (err != KErrNone || iTestAudioOutputStream == NULL )
231 INFO_PRINTF2(_L("Error Creating iTestAudioOutputStream = %d"), err);
232 return EInconclusive;
235 err = iFile.Open(iFs, KStreamRawFile1, EFileRead);
238 INFO_PRINTF2(_L("Error opening iFile = %d"), err);
242 err = iFile.Size(iFileSize);
245 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
249 iBuf.CreateMaxL(iFileSize);
251 // Initialise the CCallBackTimer.
252 iCallBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler));
258 * DoTestStepPostambleL
260 TVerdict CTestMmfAclntMultiClientARN::DoTestStepPostambleL()
262 // Delete all the Audio Client utilities.
263 if (iTestAudioPlayer)
264 iTestAudioPlayer->Close();
265 delete iTestAudioPlayer;
266 iTestAudioPlayer = NULL;
267 iTestAudioRecorder->Close();
268 delete iTestAudioRecorder;
269 iTestAudioRecorder = NULL;
270 delete iTestAudioOutputStream;
271 iTestAudioOutputStream = NULL;
272 // Delete CTestMdaAudioRecorderCallbackSupport
273 delete iMdaAudioPlayerCallbackSupport;
274 delete iMdaAudioRecorderCallbackSupport;
275 delete iMdaAudioOutputStreamCallbackSupport;
278 // Delete the CCallBackTimer.
279 delete iCallBackTimer;
281 // Close the File Handles
284 delete iEventChecker;
286 return CTestMmfAclntStep::DoTestStepPostambleL();
292 TVerdict CTestMmfAclntMultiClientARN::DoTestStepL()
300 void CTestMmfAclntMultiClientARN::StateInit()
302 iExpectedEvent=EIdleMulti;
303 iExpectedRecorderState=CMdaAudioClipUtility::ENotReady;
304 iExpectedError=KErrNone;
311 void CTestMmfAclntMultiClientARN::StateChange(TMmfAudioMultiClientEvents aExpectedEvent, TInt aExpectedError, CMdaAudioClipUtility::TState aExpectedRecorderState)
313 iExpectedEvent=aExpectedEvent;
314 iExpectedRecorderState=aExpectedRecorderState;
315 iExpectedError=aExpectedError;
322 TBool CTestMmfAclntMultiClientARN::FsmCheck(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
324 TBool retFsmCheck = EFalse;
325 if ((iExpectedError !=KErrUnderflow) && (aError == KErrUnderflow))
327 INFO_PRINTF1(_L("Underflow !"));
329 else if (iExpectedEvent != aEventCode)
331 ERR_PRINTF3(_L("ExpectedEvent : %d, ActualEvent : %d"), iExpectedEvent, aEventCode);
332 iTestStepResult = EFail;
333 CActiveScheduler::Stop();
335 else if (iExpectedError != aError)
337 ERR_PRINTF3(_L("ExpectedError : %d, ActualError : %d"), iExpectedError, aError);
338 iTestStepResult = EFail;
339 CActiveScheduler::Stop();
341 else if (iExpectedRecorderState != aRecorderState)
343 ERR_PRINTF3(_L("ExpectedRecorderState : %d, ActualRecorderState : %d"), iExpectedRecorderState, aRecorderState);
344 iTestStepResult = EFail;
345 CActiveScheduler::Stop();
355 //CTestMmfAclntARN9001
361 CTestMmfAclntARN9001::CTestMmfAclntARN9001(const TDesC& aTestName, const TDesC& aSectName)
362 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
368 CTestMmfAclntARN9001* CTestMmfAclntARN9001::NewL(const TDesC& aTestName, const TDesC& aSectName)
370 CTestMmfAclntARN9001* self = new (ELeave) CTestMmfAclntARN9001(aTestName, aSectName);
377 TVerdict CTestMmfAclntARN9001::DoTestL()
379 return( PerformTestL() );
385 TBool CTestMmfAclntARN9001::FsmCheck(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
387 TBool retFsmCheck = EFalse;
388 if ((iExpectedError !=KErrUnderflow) && (aError == KErrUnderflow))
390 INFO_PRINTF1(_L("Underflow !"));
392 else if (iExpectedEvent != aEventCode)
394 if ((aEventCode == EMoscoStateChangeEvent))
397 if (iEventOccured == EMarncResourceAvailableOS)
403 iEventOccured = EMoscoStateChangeEvent;
406 else if (aEventCode == EMarncResourceAvailableOS)
409 if (iEventOccured == EMoscoStateChangeEvent)
415 iEventOccured = EMarncResourceAvailableOS;
420 ERR_PRINTF3(_L("ExpectedEvent : %d, ActualEvent : %d"), iExpectedEvent, aEventCode);
421 iTestStepResult = EFail;
422 CActiveScheduler::Stop();
425 else if (iExpectedError != aError)
427 ERR_PRINTF3(_L("ExpectedError : %d, ActualError : %d"), iExpectedError, aError);
428 iTestStepResult = EFail;
429 CActiveScheduler::Stop();
431 else if (iExpectedRecorderState != aRecorderState)
433 ERR_PRINTF3(_L("ExpectedRecorderState : %d, ActualRecorderState : %d"), iExpectedRecorderState, aRecorderState);
434 iTestStepResult = EFail;
435 CActiveScheduler::Stop();
447 void CTestMmfAclntARN9001::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
449 if (FsmCheck(aEventCode, aError, aRecorderState))
455 // Open iTestAudioPlayer
456 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
457 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
458 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
459 StateChange(EMapcInitComplete);
462 // Play iTestAudioPlayer
463 iTestAudioPlayer->Play();
464 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
465 // Open iTestAudioRecorder
466 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
467 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
468 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
469 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
472 // Play iTestAudioRecorder
473 iTestAudioRecorder->PlayL();
474 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
475 // Set ExpectedEvent and change the State
476 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EPlaying);
479 // iTestAudioPlayer gets PlayError.
480 StateChange(EMapcPlayComplete, KErrInUse);
483 // Register iTestAudioPlayer for Notification
484 err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
485 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
486 if( err != KErrNone )
488 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
489 iTestStepResult = EFail;
490 CActiveScheduler::Stop();
493 // Register iTestAudioOutputStream for Notification
494 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
495 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
496 if( err != KErrNone )
498 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
499 iTestStepResult = EFail;
500 CActiveScheduler::Stop();
503 // Open iTestAudioOutputStream
504 iTestAudioOutputStream->Open(NULL);
505 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
506 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
507 StateChange(EMaoscOpenComplete);
511 err = iFile.Read(iBuf); //-synchronous
514 INFO_PRINTF2(_L("Error reading iFile %d"), err);
517 // iTestAudioOutputStream->WriteL()
518 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
519 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
520 // Set ExpectedEvent & ExpectedError and change the State
521 StateChange(EMaoscBufferCopied, KErrInUse);
524 // Set ExpectedEvent & ExpectedError and change the State
525 StateChange(EMaoscPlayComplete, KErrInUse);
528 // Delete the instance iTestAudioPlayer
529 delete iTestAudioPlayer;
530 iTestAudioPlayer = NULL;
531 INFO_PRINTF1(_L("delete iTestAudioPlayer"));
533 // Wait for iTestAudioRecorder to complete playing
534 // Set ExpectedEvent and change the State
535 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
538 // Timer to check if Notification Event Occurs.
539 iCallBackTimer->After(2000000);
540 // Set ExpectedEvent and change the State
541 StateChange(EMarncResourceAvailableOS, KErrNone);
544 iCallBackTimer->Cancel(); // in case something else stopped the AS
545 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
546 iTestStepResult = EPass;
547 CActiveScheduler::Stop();
556 TVerdict CTestMmfAclntARN9001::PerformTestL()
558 INFO_PRINTF1(_L("Receipt of Notification (on deleting the Audio Play Client instance of a Notified Client) of a Resource Available Event."));
559 iTestStepResult = EFail;
561 // Initialise the state variables
565 FsmL(EIdleMulti, CMdaAudioClipUtility::ENotReady);
567 // Start the scheduler - Done only once !
568 CActiveScheduler::Start();
570 return iTestStepResult;
575 //CTestMmfAclntARN9002
581 CTestMmfAclntARN9002::CTestMmfAclntARN9002(const TDesC& aTestName, const TDesC& aSectName)
582 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
588 CTestMmfAclntARN9002* CTestMmfAclntARN9002::NewL(const TDesC& aTestName, const TDesC& aSectName)
590 CTestMmfAclntARN9002* self = new (ELeave) CTestMmfAclntARN9002(aTestName, aSectName);
597 TVerdict CTestMmfAclntARN9002::DoTestL()
599 return( PerformTestL() );
602 void CTestMmfAclntARN9002::InitTest()
604 iEventChecker = CMultiEventChecker::NewL();
605 //Keep adding handlers
606 iStateHandlers[EStateApInitComplete] = &CTestMmfAclntARN9002::HandleStateApInitComplete;
607 iStateHandlers[EStateRecoderOpen] = &CTestMmfAclntARN9002::HandleStateRecorderOpen;
608 iStateHandlers[EStateRecoderPlaying] = &CTestMmfAclntARN9002::HandleStateRecorderPlaying;
609 iStateHandlers[EStateApPlayCompleteKErrInUse] = &CTestMmfAclntARN9002::HandleApPlayCompleteKErrInUse;
610 iStateHandlers[EStateAosOpenComplete] = &CTestMmfAclntARN9002::HandleStateAosOpenComplete;
611 iStateHandlers[EStateAosBufferCopiedKErrInUse] = &CTestMmfAclntARN9002::HandleStateAosBufferCopiedKErrInUse;
612 iStateHandlers[EStateAosPlayCompleteKErrInUse] = &CTestMmfAclntARN9002::HandleStateAosPlayCompleteKErrInUse;
613 iStateHandlers[EStateRecorderrelease] = &CTestMmfAclntARN9002::HandleStateRecorderrelease;
614 iStateHandlers[EStateApResourceAvailable] = &CTestMmfAclntARN9002::HandleStateApResourceAvailable;
615 iStateHandlers[EStateApPlayComplete] = &CTestMmfAclntARN9002::HandleStateApPlayComplete;
616 iStateHandlers[EStateAosResourceAvailable] = &CTestMmfAclntARN9002::HandleStateAosResourceAvailable;
619 void CTestMmfAclntARN9002::StartTestL()
621 // Open iTestAudioPlayer
622 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
623 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
624 iEventChecker->SetExpectedEvent(0,EMapcInitComplete,KErrNone);
625 iEventChecker->SetExpectedState(EStateApInitComplete);
628 TVerdict CTestMmfAclntARN9002::HandleStateApInitComplete()
630 iTestAudioPlayer->Play();
631 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
632 // Open iTestAudioRecorder
633 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
634 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
635 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone,CMdaAudioClipUtility::EOpen);
636 iEventChecker->SetExpectedState(EStateRecoderOpen);
640 TVerdict CTestMmfAclntARN9002::HandleStateRecorderOpen()
642 iTestAudioRecorder->PlayL();
643 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
644 // Set ExpectedEvent and change the State
645 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EPlaying);
646 iEventChecker->SetExpectedState(EStateRecoderPlaying);
650 TVerdict CTestMmfAclntARN9002::HandleStateRecorderPlaying()
652 iEventChecker->SetExpectedEvent(0,EMapcPlayComplete,KErrInUse);
653 iEventChecker->SetExpectedState(EStateApPlayCompleteKErrInUse);
657 TVerdict CTestMmfAclntARN9002::HandleApPlayCompleteKErrInUse()
659 TInt err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
660 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
661 if( err != KErrNone )
663 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
664 iTestStepResult = EFail;
665 CActiveScheduler::Stop();
667 // Register iTestAudioOutputStream for Notification
668 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
669 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
670 if( err != KErrNone )
672 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
673 iTestStepResult = EFail;
674 CActiveScheduler::Stop();
676 // Open iTestAudioOutputStream
677 iTestAudioOutputStream->Open(NULL);
678 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
679 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
680 iEventChecker->SetExpectedEvent(2,EMaoscOpenComplete,KErrNone);
681 iEventChecker->SetExpectedState(EStateAosOpenComplete);
685 TVerdict CTestMmfAclntARN9002::HandleStateAosOpenComplete()
688 TInt err = iFile.Read(iBuf); //-synchronous
691 INFO_PRINTF2(_L("Error reading iFile %d"), err);
694 // iTestAudioOutputStream->WriteL()
695 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
696 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
697 // Set ExpectedEvent & ExpectedError and change the State
698 iEventChecker->SetExpectedEvent(2,EMaoscBufferCopied,KErrInUse);
699 iEventChecker->SetExpectedState(EStateAosBufferCopiedKErrInUse);
703 TVerdict CTestMmfAclntARN9002::HandleStateAosBufferCopiedKErrInUse()
705 iEventChecker->SetExpectedEvent(2,EMaoscPlayComplete,KErrInUse);
706 iEventChecker->SetExpectedState(EStateAosPlayCompleteKErrInUse);
710 TVerdict CTestMmfAclntARN9002::HandleStateAosPlayCompleteKErrInUse()
712 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EOpen);
713 iEventChecker->SetExpectedState(EStateRecorderrelease);
717 TVerdict CTestMmfAclntARN9002::HandleStateRecorderrelease()
719 // Timer to check if Notification Event Occurs.
720 iCallBackTimer->After(2000000);
721 // Set ExpectedEvent and change the State
722 iEventChecker->SetExpectedEvent(0,EMarncResourceAvailablePlayer,KErrNone);
723 iEventChecker->SetExpectedState(EStateApResourceAvailable);
727 TVerdict CTestMmfAclntARN9002::HandleStateApResourceAvailable()
729 iCallBackTimer->Cancel(); // in case something else stopped the AS
730 INFO_PRINTF1(_L("iTestAudioPlayer->NotificationReceived"));
731 TInt err = iTestAudioPlayer->WillResumePlay();
732 INFO_PRINTF1(_L("iTestAudioPlayer->WillResumePlay()"));
733 if( err != KErrNone )
735 ERR_PRINTF2(_L("iTestAudioPlayer->WillResumePlay() - Failed with Error : %d"), err);
736 iTestStepResult = EFail;
737 CActiveScheduler::Stop();
739 iTestAudioPlayer->SetPosition(iPosition);
740 INFO_PRINTF1(_L("iTestAudioPlayer->SetPosition()"));
741 // Play iTestAudioPlayer
742 iTestAudioPlayer->Play();
743 // Set ExpectedEvent & ExpectedError and change the State
744 iEventChecker->RegisterClientEventToMonitor(0,EMapcPlayComplete,KErrNone,EStateApPlayComplete);
745 iEventChecker->RegisterClientEventToMonitor(2,EMarncResourceAvailableOS,KErrNone,EStateAosResourceAvailable);
746 iEventChecker->EnableMultipleEventMonitor();
750 TVerdict CTestMmfAclntARN9002::HandleStateApPlayComplete()
752 INFO_PRINTF1(_L("AudioPlayer->PlayComplete"));
753 if(iEventChecker->IsMonitoringFinished())
755 iTestStepResult = EPass;
756 iCallBackTimer->Cancel();
757 iEventChecker->StopTest();
761 iEventChecker->EnableMultipleEventMonitor();
766 TVerdict CTestMmfAclntARN9002::HandleStateAosResourceAvailable()
768 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
769 if(iEventChecker->IsMonitoringFinished())
771 iCallBackTimer->Cancel();
772 iTestStepResult = EPass;
773 iEventChecker->StopTest();
777 iEventChecker->EnableMultipleEventMonitor();
782 void CTestMmfAclntARN9002::DecideFsmState(TInt aClientNumber,CMultiEventChecker::TClientUtilityType aClientType, TInt aEventCode, TInt aError,CMdaAudioClipUtility::TState aRecorderState)
784 if (iEventChecker->CheckFsm(aClientNumber, aClientType, aEventCode, aError,aRecorderState))
786 iTestStepResult = (this->*(iStateHandlers[iEventChecker->NextState()]))();
787 if(iTestStepResult != EPass)
789 iEventChecker->StopTest();
794 void CTestMmfAclntARN9002::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
796 if (aEventCode == EMapcInitComplete || aEventCode == EMapcPlayComplete || aEventCode == EMarncResourceAvailablePlayer)
798 DecideFsmState(0,CMultiEventChecker::EAudioPlayer,aEventCode,aError);
800 if (aEventCode == EMoscoStateChangeEvent || aEventCode == EMarncResourceAvailableRecorder)
802 DecideFsmState(1,CMultiEventChecker::EAudioRecorder,aEventCode,aError,aRecorderState);
804 if (aEventCode == EMaoscOpenComplete || aEventCode == EMaoscBufferCopied || aEventCode == EMaoscPlayComplete || aEventCode == EMarncResourceAvailableOS)
806 DecideFsmState(2,CMultiEventChecker::EAudioStream,aEventCode,aError);
810 TVerdict CTestMmfAclntARN9002::PerformTestL()
812 INFO_PRINTF1(_L("Receipt of Notification (on completion of play of a Notifed Client) of a Resource Available Event."));
813 iTestStepResult = EFail;
815 // Initialise the handler functions
818 // Initiate the process
821 // Start the scheduler - Done only once !
822 CActiveScheduler::Start();
824 return iTestStepResult;
829 //CTestMmfAclntARN9003
835 CTestMmfAclntARN9003::CTestMmfAclntARN9003(const TDesC& aTestName, const TDesC& aSectName)
836 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
842 CTestMmfAclntARN9003* CTestMmfAclntARN9003::NewL(const TDesC& aTestName, const TDesC& aSectName)
844 CTestMmfAclntARN9003* self = new (ELeave) CTestMmfAclntARN9003(aTestName, aSectName);
851 TVerdict CTestMmfAclntARN9003::DoTestL()
853 return( PerformTestL() );
859 void CTestMmfAclntARN9003::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
861 if (FsmCheck(aEventCode, aError, aRecorderState))
867 // Open iTestAudioPlayer
868 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
869 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
870 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
871 StateChange(EMapcInitComplete);
874 // Play iTestAudioPlayer
875 iTestAudioPlayer->Play();
876 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
877 // Open iTestAudioRecorder
878 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
879 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
880 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
881 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
884 // Play iTestAudioRecorder
885 iTestAudioRecorder->PlayL();
886 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
887 // Set ExpectedEvent and change the State
888 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EPlaying);
891 // iTestAudioPlayer gets PlayError.
892 StateChange(EMapcPlayComplete, KErrInUse);
895 // Register iTestAudioPlayer for Notification
896 err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
897 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
898 if( err != KErrNone )
900 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
901 iTestStepResult = EFail;
902 CActiveScheduler::Stop();
905 // Register iTestAudioOutputStream for Notification
906 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
907 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
908 if( err != KErrNone )
910 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
911 iTestStepResult = EFail;
912 CActiveScheduler::Stop();
915 // Open iTestAudioOutputStream
916 iTestAudioOutputStream->Open(NULL);
917 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
918 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
919 StateChange(EMaoscOpenComplete);
923 err = iFile.Read(iBuf); //-synchronous
926 INFO_PRINTF2(_L("Error reading iFile %d"), err);
929 // iTestAudioOutputStream->WriteL()
930 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
931 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
932 // Set ExpectedEvent & ExpectedError and change the State
933 StateChange(EMaoscBufferCopied, KErrInUse);
936 // Set ExpectedEvent & ExpectedError and change the State
937 StateChange(EMaoscPlayComplete, KErrInUse);
940 // Wait for iTestAudioRecorder to complete playing
941 // Set ExpectedEvent and change the State
942 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
945 // Timer to check if Notification Event Occurs.
946 iCallBackTimer->After(2000000);
947 // Set ExpectedEvent and change the State
948 StateChange(EMarncResourceAvailablePlayer, KErrNone);
951 iCallBackTimer->Cancel(); // in case something else stopped the AS
952 INFO_PRINTF1(_L("iTestAudioPlayer->NotificationReceived"));
953 err = iTestAudioPlayer->WillResumePlay();
954 INFO_PRINTF1(_L("iTestAudioPlayer->WillResumePlay()"));
955 if( err != KErrNone )
957 ERR_PRINTF2(_L("iTestAudioPlayer->WillResumePlay() - Failed with Error : %d"), err);
958 iTestStepResult = EFail;
959 CActiveScheduler::Stop();
962 iTestAudioPlayer->SetPosition(iPosition);
963 INFO_PRINTF1(_L("iTestAudioPlayer->SetPosition()"));
964 // Play iTestAudioPlayer
965 iTestAudioPlayer->Play();
966 // Stop & Close iTestAudioPlayer
967 WaitWithTimeout(iRequestStatus,1000000);
968 iTestAudioPlayer->Stop();
969 INFO_PRINTF1(_L("iTestAudioPlayer->Stop()"));
970 iTestAudioPlayer->Close();
971 INFO_PRINTF1(_L("iTestAudioPlayer->Close()"));
972 // Timer to check if Notification Event Occurs.
973 iCallBackTimer->After(2000000);
974 // Set ExpectedEvent and change the State
975 StateChange(EMarncResourceAvailableOS);
978 iCallBackTimer->Cancel(); // in case something else stopped the AS
979 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
980 iTestStepResult = EPass;
981 CActiveScheduler::Stop();
990 TVerdict CTestMmfAclntARN9003::PerformTestL()
992 INFO_PRINTF1(_L("Receipt of Notification (on stopping play of a Notitifed Client) of a Resource Available Event."));
993 iTestStepResult = EFail;
995 // Initialise the state variables
999 FsmL(EIdleMulti, CMdaAudioClipUtility::ENotReady);
1001 // Start the scheduler - Done only once !
1002 CActiveScheduler::Start();
1004 return iTestStepResult;
1008 //CTestMmfAclntARN9004
1014 CTestMmfAclntARN9004::CTestMmfAclntARN9004(const TDesC& aTestName, const TDesC& aSectName)
1015 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
1021 CTestMmfAclntARN9004* CTestMmfAclntARN9004::NewL(const TDesC& aTestName, const TDesC& aSectName)
1023 CTestMmfAclntARN9004* self = new (ELeave) CTestMmfAclntARN9004(aTestName, aSectName);
1030 TVerdict CTestMmfAclntARN9004::DoTestL()
1032 return( PerformTestL() );
1038 TBool CTestMmfAclntARN9004::FsmCheck(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1040 TBool retFsmCheck = EFalse;
1041 if ((iExpectedError !=KErrUnderflow) && (aError == KErrUnderflow))
1043 INFO_PRINTF1(_L("Underflow !"));
1045 else if (iExpectedEvent != aEventCode)
1047 if ((aEventCode == EMoscoStateChangeEvent))
1049 retFsmCheck = ETrue;
1050 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1051 if (iEventOccured == EMarncResourceAvailablePlayer)
1053 if (iEventOccured == EMarncResourceAvailableOS)
1060 iEventOccured = EMoscoStateChangeEvent;
1063 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1064 else if (aEventCode == EMarncResourceAvailablePlayer)
1066 else if (aEventCode == EMarncResourceAvailableOS)
1069 retFsmCheck = ETrue;
1070 if (iEventOccured == EMoscoStateChangeEvent)
1076 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1077 iEventOccured = EMarncResourceAvailablePlayer;
1079 iEventOccured = EMarncResourceAvailableOS;
1085 ERR_PRINTF3(_L("ExpectedEvent : %d, ActualEvent : %d"), iExpectedEvent, aEventCode);
1086 iTestStepResult = EFail;
1087 CActiveScheduler::Stop();
1090 else if (iExpectedError != aError)
1092 ERR_PRINTF3(_L("ExpectedError : %d, ActualError : %d"), iExpectedError, aError);
1093 iTestStepResult = EFail;
1094 CActiveScheduler::Stop();
1096 else if (iExpectedRecorderState != aRecorderState)
1098 ERR_PRINTF3(_L("ExpectedRecorderState : %d, ActualRecorderState : %d"), iExpectedRecorderState, aRecorderState);
1099 iTestStepResult = EFail;
1100 CActiveScheduler::Stop();
1104 retFsmCheck = ETrue;
1112 void CTestMmfAclntARN9004::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1114 if (FsmCheck(aEventCode, aError, aRecorderState))
1116 TInt err = KErrNone;
1120 // Open iTestAudioPlayer
1121 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
1122 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
1123 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1124 StateChange(EMapcInitComplete);
1127 // Play iTestAudioPlayer
1128 iTestAudioPlayer->Play();
1129 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
1130 // Open iTestAudioRecorder
1131 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
1132 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
1133 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1134 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
1137 // Play iTestAudioRecorder
1138 iTestAudioRecorder->PlayL();
1139 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
1140 // Set ExpectedEvent and change the State
1141 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EPlaying);
1144 // iTestAudioPlayer gets PlayError.
1145 StateChange(EMapcPlayComplete, KErrInUse);
1148 // Register iTestAudioOutputStream for Notification
1149 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1150 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
1151 if( err != KErrNone )
1153 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1154 iTestStepResult = EFail;
1155 CActiveScheduler::Stop();
1158 // Register iTestAudioPlayer for Notification
1159 err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1160 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
1161 if( err != KErrNone )
1163 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1164 iTestStepResult = EFail;
1165 CActiveScheduler::Stop();
1168 // Open iTestAudioOutputStream
1169 iTestAudioOutputStream->Open(NULL);
1170 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
1171 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1172 StateChange(EMaoscOpenComplete);
1176 err = iFile.Read(iBuf); //-synchronous
1177 if (err != KErrNone)
1179 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1182 // iTestAudioOutputStream->WriteL()
1183 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
1184 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
1185 // Set ExpectedEvent & ExpectedError and change the State
1186 StateChange(EMaoscBufferCopied, KErrInUse);
1189 // Set ExpectedEvent & ExpectedError and change the State
1190 StateChange(EMaoscPlayComplete, KErrInUse);
1193 // Wait for iTestAudioRecorder to complete playing
1194 // Set ExpectedEvent and change the State
1195 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
1198 // Timer to check if Notification Event Occurs.
1199 iCallBackTimer->After(2000000);
1200 // Set ExpectedEvent and change the State
1201 StateChange(EMarncResourceAvailableOS);
1204 iCallBackTimer->Cancel(); // in case something else stopped the AS
1205 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
1206 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1207 StateChange(EMarncResourceAvailablePlayer);
1209 iTestStepResult = EPass;
1210 CActiveScheduler::Stop();
1213 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1215 INFO_PRINTF1(_L("iTestAudioPlayer->NotificationReceived"));
1216 err = iTestAudioPlayer->WillResumePlay();
1217 INFO_PRINTF1(_L("iTestAudioPlayer->WillResumePlay()"));
1218 if( err != KErrNone )
1220 ERR_PRINTF2(_L("iTestAudioPlayer->WillResumePlay() - Failed with Error : %d"), err);
1221 iTestStepResult = EFail;
1222 CActiveScheduler::Stop();
1225 iTestStepResult = EPass;
1226 CActiveScheduler::Stop();
1236 TVerdict CTestMmfAclntARN9004::PerformTestL()
1238 INFO_PRINTF1(_L("Receipt of Notification (chronological order for equal priority clients) of a Resource Available Event."));
1239 iTestStepResult = EFail;
1241 // Initialise the state variables
1244 // Set the priorities
1245 iTestAudioPlayer->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceTimeAndQuality);
1246 INFO_PRINTF1(_L("Reset Priority for CMdaAudioPlayerUtility : EMdaPriorityMin"));
1247 iTestAudioOutputStream->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceTimeAndQuality);
1248 INFO_PRINTF1(_L("Reset Priority for CMdaAudioOutputStream : EMdaPriorityMin"));
1250 // Begin the process
1251 FsmL(EIdleMulti, CMdaAudioClipUtility::ENotReady);
1253 // Start the scheduler - Done only once !
1254 CActiveScheduler::Start();
1256 return iTestStepResult;
1260 //CTestMmfAclntARN9005
1266 CTestMmfAclntARN9005::CTestMmfAclntARN9005(const TDesC& aTestName, const TDesC& aSectName)
1267 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
1273 CTestMmfAclntARN9005* CTestMmfAclntARN9005::NewL(const TDesC& aTestName, const TDesC& aSectName)
1275 CTestMmfAclntARN9005* self = new (ELeave) CTestMmfAclntARN9005(aTestName, aSectName);
1282 TVerdict CTestMmfAclntARN9005::DoTestL()
1284 return( PerformTestL() );
1287 void CTestMmfAclntARN9005::InitTest()
1289 //Keep adding handlers
1290 iStateHandlers[EStateApInitComplete] = &CTestMmfAclntARN9005::HandleStateApInitComplete;
1291 iStateHandlers[EStateRecoderOpen] = &CTestMmfAclntARN9005::HandleStateRecorderOpen;
1292 iStateHandlers[EStateRecoderPlaying] = &CTestMmfAclntARN9005::HandleStateRecorderPlaying;
1293 iStateHandlers[EStateApPlayCompleteKErrInUse] = &CTestMmfAclntARN9005::HandleApPlayCompleteKErrInUse;
1294 iStateHandlers[EStateAosOpenComplete] = &CTestMmfAclntARN9005::HandleStateAosOpenComplete;
1295 iStateHandlers[EStateAosBufferCopiedKErrInUse] = &CTestMmfAclntARN9005::HandleStateAosBufferCopiedKErrInUse;
1296 iStateHandlers[EStateAosPlayCompleteKErrInUse] = &CTestMmfAclntARN9005::HandleStateAosPlayCompleteKErrInUse;
1297 iStateHandlers[EStateRecorderrelease] = &CTestMmfAclntARN9005::HandleStateRecorderrelease;
1298 iStateHandlers[EStateApResourceAvailable] = &CTestMmfAclntARN9005::HandleStateApResourceAvailable;
1299 iStateHandlers[EStateApPlayComplete] = &CTestMmfAclntARN9005::HandleStateApPlayComplete;
1300 iStateHandlers[EStateAosResourceAvailable] = &CTestMmfAclntARN9005::HandleStateAosResourceAvailable;
1303 void CTestMmfAclntARN9005::DecideFsmState(TInt aClientNumber,CMultiEventChecker::TClientUtilityType aClientType, TInt aEventCode, TInt aError,CMdaAudioClipUtility::TState aRecorderState)
1305 if (iEventChecker->CheckFsm(aClientNumber, aClientType, aEventCode, aError,aRecorderState))
1307 iTestStepResult = (this->*(iStateHandlers[iEventChecker->NextState()]))();
1308 if(iTestStepResult != EPass)
1310 iEventChecker->StopTest();
1315 void CTestMmfAclntARN9005::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1317 if (aEventCode == EMapcInitComplete || aEventCode == EMapcPlayComplete || aEventCode == EMarncResourceAvailablePlayer)
1319 DecideFsmState(0,CMultiEventChecker::EAudioPlayer,aEventCode,aError);
1321 if (aEventCode == EMoscoStateChangeEvent || aEventCode == EMarncResourceAvailableRecorder)
1323 DecideFsmState(1,CMultiEventChecker::EAudioRecorder,aEventCode,aError,aRecorderState);
1325 if (aEventCode == EMaoscOpenComplete || aEventCode == EMaoscBufferCopied || aEventCode == EMaoscPlayComplete || aEventCode == EMarncResourceAvailableOS)
1327 DecideFsmState(2,CMultiEventChecker::EAudioStream,aEventCode,aError);
1331 void CTestMmfAclntARN9005::StartTestL()
1333 // Open iTestAudioPlayer
1334 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
1335 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
1336 iEventChecker->SetExpectedEvent(0,EMapcInitComplete,KErrNone);
1337 iEventChecker->SetExpectedState(EStateApInitComplete);
1340 TVerdict CTestMmfAclntARN9005::HandleStateApInitComplete()
1342 iTestAudioPlayer->Play();
1343 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
1344 // Open iTestAudioRecorder
1345 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
1346 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
1347 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone,CMdaAudioClipUtility::EOpen);
1348 iEventChecker->SetExpectedState(EStateRecoderOpen);
1352 TVerdict CTestMmfAclntARN9005::HandleStateRecorderOpen()
1354 iTestAudioRecorder->PlayL();
1355 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
1356 // Set ExpectedEvent and change the State
1357 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EPlaying);
1358 iEventChecker->SetExpectedState(EStateRecoderPlaying);
1362 TVerdict CTestMmfAclntARN9005::HandleStateRecorderPlaying()
1364 iEventChecker->SetExpectedEvent(0,EMapcPlayComplete,KErrInUse);
1365 iEventChecker->SetExpectedState(EStateApPlayCompleteKErrInUse);
1369 TVerdict CTestMmfAclntARN9005::HandleApPlayCompleteKErrInUse()
1371 TInt err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1372 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
1373 if( err != KErrNone )
1375 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1376 iTestStepResult = EFail;
1377 CActiveScheduler::Stop();
1379 // Register iTestAudioOutputStream for Notification
1380 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1381 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
1382 if( err != KErrNone )
1384 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1385 iTestStepResult = EFail;
1386 CActiveScheduler::Stop();
1388 // Open iTestAudioOutputStream
1389 iTestAudioOutputStream->Open(NULL);
1390 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
1391 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1392 iEventChecker->SetExpectedEvent(2,EMaoscOpenComplete,KErrNone);
1393 iEventChecker->SetExpectedState(EStateAosOpenComplete);
1397 TVerdict CTestMmfAclntARN9005::HandleStateAosOpenComplete()
1400 TInt err = iFile.Read(iBuf); //-synchronous
1401 if (err != KErrNone)
1403 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1406 // iTestAudioOutputStream->WriteL()
1407 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
1408 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
1409 // Set ExpectedEvent & ExpectedError and change the State
1410 iEventChecker->SetExpectedEvent(2,EMaoscBufferCopied,KErrInUse);
1411 iEventChecker->SetExpectedState(EStateAosBufferCopiedKErrInUse);
1415 TVerdict CTestMmfAclntARN9005::HandleStateAosBufferCopiedKErrInUse()
1417 iEventChecker->SetExpectedEvent(2,EMaoscPlayComplete,KErrInUse);
1418 iEventChecker->SetExpectedState(EStateAosPlayCompleteKErrInUse);
1422 TVerdict CTestMmfAclntARN9005::HandleStateAosPlayCompleteKErrInUse()
1424 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EOpen);
1425 iEventChecker->SetExpectedState(EStateRecorderrelease);
1429 TVerdict CTestMmfAclntARN9005::HandleStateRecorderrelease()
1431 // Timer to check if Notification Event Occurs.
1432 iCallBackTimer->After(2000000);
1433 // Set ExpectedEvent and change the State
1434 iEventChecker->SetExpectedEvent(0,EMarncResourceAvailablePlayer,KErrNone);
1435 iEventChecker->SetExpectedState(EStateApResourceAvailable);
1439 TVerdict CTestMmfAclntARN9005::HandleStateApResourceAvailable()
1441 iCallBackTimer->Cancel(); // in case something else stopped the AS
1442 INFO_PRINTF1(_L("iTestAudioPlayer->NotificationReceived"));
1443 TInt err = iTestAudioPlayer->WillResumePlay();
1444 INFO_PRINTF1(_L("iTestAudioPlayer->WillResumePlay()"));
1445 if( err != KErrNone )
1447 ERR_PRINTF2(_L("iTestAudioPlayer->WillResumePlay() - Failed with Error : %d"), err);
1448 iTestStepResult = EFail;
1449 CActiveScheduler::Stop();
1452 iTestAudioPlayer->SetPosition(iPosition);
1453 INFO_PRINTF1(_L("iTestAudioPlayer->SetPosition()"));
1454 // Play iTestAudioPlayer
1455 iTestAudioPlayer->Play();
1456 // Set ExpectedEvent & ExpectedError and change the State
1457 iEventChecker->RegisterClientEventToMonitor(0,EMapcPlayComplete,KErrNone,EStateApPlayComplete);
1458 iEventChecker->RegisterClientEventToMonitor(2,EMarncResourceAvailableOS,KErrNone,EStateAosResourceAvailable);
1459 iEventChecker->EnableMultipleEventMonitor();
1463 TVerdict CTestMmfAclntARN9005::HandleStateApPlayComplete()
1465 INFO_PRINTF1(_L("AudioPlayer->PlayComplete"));
1466 if(iEventChecker->IsMonitoringFinished())
1468 iTestStepResult = EPass;
1469 iCallBackTimer->Cancel();
1470 iEventChecker->StopTest();
1474 iEventChecker->EnableMultipleEventMonitor();
1479 TVerdict CTestMmfAclntARN9005::HandleStateAosResourceAvailable()
1481 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
1482 if(iEventChecker->IsMonitoringFinished())
1484 iCallBackTimer->Cancel();
1485 iTestStepResult = EPass;
1486 iEventChecker->StopTest();
1490 iEventChecker->EnableMultipleEventMonitor();
1498 TVerdict CTestMmfAclntARN9005::PerformTestL()
1500 INFO_PRINTF1(_L("Non Receipt of Notification (on calling WillResumePlay() of a notified client) of a Resource Available Event."));
1501 iTestStepResult = EFail;
1503 // Initialise the state variables
1506 // Begin the process
1509 // Start the scheduler - Done only once !
1510 CActiveScheduler::Start();
1512 return iTestStepResult;
1516 //CTestMmfAclntARN9006
1522 CTestMmfAclntARN9006::CTestMmfAclntARN9006(const TDesC& aTestName, const TDesC& aSectName)
1523 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
1529 CTestMmfAclntARN9006* CTestMmfAclntARN9006::NewL(const TDesC& aTestName, const TDesC& aSectName)
1531 CTestMmfAclntARN9006* self = new (ELeave) CTestMmfAclntARN9006(aTestName, aSectName);
1538 TVerdict CTestMmfAclntARN9006::DoTestL()
1540 return( PerformTestL() );
1543 void CTestMmfAclntARN9006::DecideFsmState(TInt aClientNumber,CMultiEventChecker::TClientUtilityType aClientType, TInt aEventCode, TInt aError,CMdaAudioClipUtility::TState aRecorderState)
1545 if (iEventChecker->CheckFsm(aClientNumber, aClientType, aEventCode, aError,aRecorderState))
1547 iTestStepResult = (this->*(iStateHandlers[iEventChecker->NextState()]))();
1548 if(iTestStepResult != EPass)
1550 iEventChecker->StopTest();
1555 void CTestMmfAclntARN9006::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1557 if (aEventCode == EMapcInitComplete || aEventCode == EMapcPlayComplete || aEventCode == EMarncResourceAvailablePlayer)
1559 DecideFsmState(0,CMultiEventChecker::EAudioPlayer,aEventCode,aError);
1561 if (aEventCode == EMoscoStateChangeEvent || aEventCode == EMarncResourceAvailableRecorder)
1563 DecideFsmState(1,CMultiEventChecker::EAudioRecorder,aEventCode,aError,aRecorderState);
1565 if (aEventCode == EMaoscOpenComplete || aEventCode == EMaoscBufferCopied || aEventCode == EMaoscPlayComplete || aEventCode == EMarncResourceAvailableOS)
1567 DecideFsmState(2,CMultiEventChecker::EAudioStream,aEventCode,aError);
1571 void CTestMmfAclntARN9006::InitTest()
1573 //Keep adding handlers
1574 iStateHandlers[EStateApInitComplete] = &CTestMmfAclntARN9006::HandleStateApInitComplete;
1575 iStateHandlers[EStateRecoderOpen] = &CTestMmfAclntARN9006::HandleStateRecorderOpen;
1576 iStateHandlers[EStateRecoderPlaying] = &CTestMmfAclntARN9006::HandleStateRecorderPlaying;
1577 iStateHandlers[EStateApPlayCompleteKErrInUse] = &CTestMmfAclntARN9006::HandleApPlayCompleteKErrInUse;
1578 iStateHandlers[EStateAosOpenComplete] = &CTestMmfAclntARN9006::HandleStateAosOpenComplete;
1579 iStateHandlers[EStateAosBufferCopiedKErrInUse] = &CTestMmfAclntARN9006::HandleStateAosBufferCopiedKErrInUse;
1580 iStateHandlers[EStateAosPlayCompleteKErrInUse] = &CTestMmfAclntARN9006::HandleStateAosPlayCompleteKErrInUse;
1581 iStateHandlers[EStateRecorderrelease] = &CTestMmfAclntARN9006::HandleStateRecorderrelease;
1582 iStateHandlers[EStateApResourceAvailable] = &CTestMmfAclntARN9006::HandleStateApResourceAvailable;
1583 iStateHandlers[EStateAosResourceAvailable] = &CTestMmfAclntARN9006::HandleStateAosResourceAvailable;
1586 void CTestMmfAclntARN9006::StartTestL()
1588 // Open iTestAudioPlayer
1589 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
1590 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
1591 iEventChecker->SetExpectedEvent(0,EMapcInitComplete,KErrNone);
1592 iEventChecker->SetExpectedState(EStateApInitComplete);
1595 TVerdict CTestMmfAclntARN9006::HandleStateApInitComplete()
1597 iTestAudioPlayer->Play();
1598 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
1599 // Open iTestAudioRecorder
1600 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
1601 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
1602 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone,CMdaAudioClipUtility::EOpen);
1603 iEventChecker->SetExpectedState(EStateRecoderOpen);
1607 TVerdict CTestMmfAclntARN9006::HandleStateRecorderOpen()
1609 iTestAudioRecorder->PlayL();
1610 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
1611 // Set ExpectedEvent and change the State
1612 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EPlaying);
1613 iEventChecker->SetExpectedState(EStateRecoderPlaying);
1617 TVerdict CTestMmfAclntARN9006::HandleStateRecorderPlaying()
1619 iEventChecker->SetExpectedEvent(0,EMapcPlayComplete,KErrInUse);
1620 iEventChecker->SetExpectedState(EStateApPlayCompleteKErrInUse);
1624 TVerdict CTestMmfAclntARN9006::HandleApPlayCompleteKErrInUse()
1626 TInt err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1627 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
1628 if( err != KErrNone )
1630 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1631 iTestStepResult = EFail;
1632 CActiveScheduler::Stop();
1635 // Register iTestAudioOutputStream for Notification
1636 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1637 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
1638 if( err != KErrNone )
1640 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1641 iTestStepResult = EFail;
1642 CActiveScheduler::Stop();
1645 // Open iTestAudioOutputStream
1646 iTestAudioOutputStream->Open(NULL);
1647 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
1648 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1649 iEventChecker->SetExpectedEvent(2,EMaoscOpenComplete,KErrNone);
1650 iEventChecker->SetExpectedState(EStateAosOpenComplete);
1654 TVerdict CTestMmfAclntARN9006::HandleStateAosOpenComplete()
1657 TInt err = iFile.Read(iBuf); //-synchronous
1658 if (err != KErrNone)
1660 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1663 // iTestAudioOutputStream->WriteL()
1664 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
1665 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
1666 // Set ExpectedEvent & ExpectedError and change the State
1667 iEventChecker->SetExpectedEvent(2,EMaoscBufferCopied,KErrInUse);
1668 iEventChecker->SetExpectedState(EStateAosBufferCopiedKErrInUse);
1672 TVerdict CTestMmfAclntARN9006::HandleStateAosBufferCopiedKErrInUse()
1674 iEventChecker->SetExpectedEvent(2,EMaoscPlayComplete,KErrInUse);
1675 iEventChecker->SetExpectedState(EStateAosPlayCompleteKErrInUse);
1679 TVerdict CTestMmfAclntARN9006::HandleStateAosPlayCompleteKErrInUse()
1681 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EOpen);
1682 iEventChecker->SetExpectedState(EStateRecorderrelease);
1686 TVerdict CTestMmfAclntARN9006::HandleStateRecorderrelease()
1688 // Timer to check if Notification Event Occurs.
1689 iCallBackTimer->After(2000000);
1690 // Set ExpectedEvent and change the State
1691 iEventChecker->SetExpectedEvent(0,EMarncResourceAvailablePlayer,KErrNone);
1692 iEventChecker->SetExpectedState(EStateApResourceAvailable);
1696 TVerdict CTestMmfAclntARN9006::HandleStateApResourceAvailable()
1698 iCallBackTimer->Cancel(); // in case something else stopped the AS
1699 INFO_PRINTF1(_L("iTestAudioPlayer->NotificationReceived"));
1700 TInt err = iTestAudioPlayer->WillResumePlay();
1701 INFO_PRINTF1(_L("iTestAudioPlayer->WillResumePlay()"));
1702 if( err != KErrNone )
1704 ERR_PRINTF2(_L("iTestAudioPlayer->WillResumePlay() - Failed with Error : %d"), err);
1705 iTestStepResult = EFail;
1706 CActiveScheduler::Stop();
1709 iCallBackTimer->After(10000000);
1710 // Set ExpectedEvent & ExpectedError and change the State
1711 iEventChecker->SetExpectedEvent(2,EMarncResourceAvailableOS,KErrNone);
1712 iEventChecker->SetExpectedState(EStateAosResourceAvailable);
1716 TVerdict CTestMmfAclntARN9006::HandleStateAosResourceAvailable()
1718 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
1719 iCallBackTimer->Cancel();
1720 iTestStepResult = EPass;
1721 iEventChecker->StopTest();
1728 TVerdict CTestMmfAclntARN9006::PerformTestL()
1730 INFO_PRINTF1(_L("Receipt of Notification (on timeout of a notified client, 1 sec assumed, call WillResumePlay() after 1 second) of a Resource Available Event."));
1731 iTestStepResult = EFail;
1733 // Initialise the handler functions
1736 // Initiate the process
1739 // Start the scheduler - Done only once !
1740 CActiveScheduler::Start();
1742 return iTestStepResult;
1746 //CTestMmfAclntARN9007
1752 CTestMmfAclntARN9007::CTestMmfAclntARN9007(const TDesC& aTestName, const TDesC& aSectName)
1753 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
1759 CTestMmfAclntARN9007* CTestMmfAclntARN9007::NewL(const TDesC& aTestName, const TDesC& aSectName)
1761 CTestMmfAclntARN9007* self = new (ELeave) CTestMmfAclntARN9007(aTestName, aSectName);
1768 TVerdict CTestMmfAclntARN9007::DoTestL()
1770 return( PerformTestL() );
1776 TBool CTestMmfAclntARN9007::FsmCheck(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1778 TBool retFsmCheck = EFalse;
1779 if ((iExpectedError !=KErrUnderflow) && (aError == KErrUnderflow))
1781 INFO_PRINTF1(_L("Underflow !"));
1783 else if (iExpectedEvent != aEventCode)
1785 if ((aEventCode == EMoscoStateChangeEvent))
1787 retFsmCheck = ETrue;
1788 if (iEventOccured == EMarncResourceAvailableOS)
1794 iEventOccured = EMoscoStateChangeEvent;
1797 else if (aEventCode == EMarncResourceAvailableOS)
1799 retFsmCheck = ETrue;
1800 if (iEventOccured == EMoscoStateChangeEvent)
1806 iEventOccured = EMarncResourceAvailableOS;
1811 ERR_PRINTF3(_L("ExpectedEvent : %d, ActualEvent : %d"), iExpectedEvent, aEventCode);
1812 iTestStepResult = EFail;
1813 CActiveScheduler::Stop();
1816 else if (iExpectedError != aError)
1818 ERR_PRINTF3(_L("ExpectedError : %d, ActualError : %d"), iExpectedError, aError);
1819 iTestStepResult = EFail;
1820 CActiveScheduler::Stop();
1822 else if (iExpectedRecorderState != aRecorderState)
1824 ERR_PRINTF3(_L("ExpectedRecorderState : %d, ActualRecorderState : %d"), iExpectedRecorderState, aRecorderState);
1825 iTestStepResult = EFail;
1826 CActiveScheduler::Stop();
1830 retFsmCheck = ETrue;
1838 void CTestMmfAclntARN9007::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
1840 if (FsmCheck(aEventCode, aError, aRecorderState))
1842 TInt err = KErrNone;
1846 // Open iTestAudioPlayer
1847 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
1848 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
1849 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1850 StateChange(EMapcInitComplete);
1853 // Play iTestAudioPlayer
1854 iTestAudioPlayer->Play();
1855 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
1856 // Open iTestAudioRecorder
1857 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
1858 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
1859 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1860 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
1863 // Play iTestAudioRecorder
1864 iTestAudioRecorder->PlayL();
1865 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
1866 // Set ExpectedEvent and change the State
1867 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EPlaying);
1870 // iTestAudioPlayer gets PlayError.
1871 StateChange(EMapcPlayComplete, KErrInUse);
1874 // Register iTestAudioPlayer for Notification
1875 err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1876 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
1877 if( err != KErrNone )
1879 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1880 iTestStepResult = EFail;
1881 CActiveScheduler::Stop();
1884 // Register iTestAudioOutputStream for Notification
1885 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
1886 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
1887 if( err != KErrNone )
1889 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
1890 iTestStepResult = EFail;
1891 CActiveScheduler::Stop();
1894 // Open iTestAudioOutputStream
1895 iTestAudioOutputStream->Open(NULL);
1896 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
1897 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
1898 StateChange(EMaoscOpenComplete);
1902 err = iFile.Read(iBuf); //-synchronous
1903 if (err != KErrNone)
1905 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1908 // iTestAudioOutputStream->WriteL()
1909 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
1910 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
1911 // Set ExpectedEvent & ExpectedError and change the State
1912 StateChange(EMaoscBufferCopied, KErrInUse);
1915 // Set ExpectedEvent & ExpectedError and change the State
1916 StateChange(EMaoscPlayComplete, KErrInUse);
1919 // Cancel the Notification request for iTestAudioPlayer
1920 err = iTestAudioPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
1921 INFO_PRINTF2(_L("iTestAudioPlayer->CancelRegisterAudioResourceNotification : Return Code = %d"), err);
1922 if( err != KErrNone )
1924 ERR_PRINTF2(_L("iTestAudioPlayer->CancelRegisterAudioResourceNotification - Failed with Error : %d"), err);
1925 iTestStepResult = EFail;
1926 CActiveScheduler::Stop();
1929 // Wait for iTestAudioRecorder to complete playing
1930 // Set ExpectedEvent and change the State
1931 StateChange(EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
1934 // Timer to check if Notification Event Occurs.
1935 iCallBackTimer->After(2000000);
1936 // Set ExpectedEvent and change the State
1937 StateChange(EMarncResourceAvailableOS);
1940 iCallBackTimer->Cancel(); // in case something else stopped the AS
1941 INFO_PRINTF1(_L("iTestAudioOutputStream->NotificationReceived"));
1942 iTestStepResult = EPass;
1943 CActiveScheduler::Stop();
1952 TVerdict CTestMmfAclntARN9007::PerformTestL()
1954 INFO_PRINTF1(_L("Receipt of Notification (on cancellation of the notification of a client that has requested for notification) of a Resource Available Event."));
1955 INFO_PRINTF1(_L("[Cancel before receipt of Notification]"));
1956 iTestStepResult = EFail;
1958 // Initialise the state variables
1961 // Begin the process
1962 FsmL(EIdleMulti, CMdaAudioClipUtility::ENotReady);
1964 // Start the scheduler - Done only once !
1965 CActiveScheduler::Start();
1967 return iTestStepResult;
1971 //CTestMmfAclntARN9008
1977 CTestMmfAclntARN9008::CTestMmfAclntARN9008(const TDesC& aTestName, const TDesC& aSectName)
1978 : CTestMmfAclntMultiClientARN(aTestName, aSectName)
1984 CTestMmfAclntARN9008* CTestMmfAclntARN9008::NewL(const TDesC& aTestName, const TDesC& aSectName)
1986 CTestMmfAclntARN9008* self = new (ELeave) CTestMmfAclntARN9008(aTestName, aSectName);
1993 TVerdict CTestMmfAclntARN9008::DoTestL()
1995 return( PerformTestL() );
1998 void CTestMmfAclntARN9008::DecideFsmState(TInt aClientNumber,CMultiEventChecker::TClientUtilityType aClientType, TInt aEventCode, TInt aError,CMdaAudioClipUtility::TState aRecorderState)
2000 if (iEventChecker->CheckFsm(aClientNumber, aClientType, aEventCode, aError,aRecorderState))
2002 iTestStepResult = (this->*(iStateHandlers[iEventChecker->NextState()]))();
2003 if(iTestStepResult != EPass)
2005 iEventChecker->StopTest();
2010 void CTestMmfAclntARN9008::FsmL(TMmfAudioMultiClientEvents aEventCode, TInt aError, CMdaAudioClipUtility::TState aRecorderState)
2012 if (aEventCode == EMapcInitComplete || aEventCode == EMapcPlayComplete || aEventCode == EMarncResourceAvailablePlayer)
2014 DecideFsmState(0,CMultiEventChecker::EAudioPlayer,aEventCode,aError);
2016 if (aEventCode == EMoscoStateChangeEvent || aEventCode == EMarncResourceAvailableRecorder)
2018 DecideFsmState(1,CMultiEventChecker::EAudioRecorder,aEventCode,aError,aRecorderState);
2020 if (aEventCode == EMaoscOpenComplete || aEventCode == EMaoscBufferCopied || aEventCode == EMaoscPlayComplete || aEventCode == EMarncResourceAvailableOS)
2022 DecideFsmState(2,CMultiEventChecker::EAudioStream,aEventCode,aError);
2026 void CTestMmfAclntARN9008::InitTest()
2028 //Keep adding handlers
2029 iStateHandlers[EStateApInitComplete] = &CTestMmfAclntARN9008::HandleStateApInitComplete;
2030 iStateHandlers[EStateRecoderOpen] = &CTestMmfAclntARN9008::HandleStateRecorderOpen;
2031 iStateHandlers[EStateRecoderPlaying] = &CTestMmfAclntARN9008::HandleStateRecorderPlaying;
2032 iStateHandlers[EStateApPlayCompleteKErrInUse] = &CTestMmfAclntARN9008::HandleApPlayCompleteKErrInUse;
2033 iStateHandlers[EStateAosOpenComplete] = &CTestMmfAclntARN9008::HandleStateAosOpenComplete;
2034 iStateHandlers[EStateAosBufferCopiedKErrInUse] = &CTestMmfAclntARN9008::HandleStateAosBufferCopiedKErrInUse;
2035 iStateHandlers[EStateAosPlayCompleteKErrInUse] = &CTestMmfAclntARN9008::HandleStateAosPlayCompleteKErrInUse;
2036 iStateHandlers[EStateRecorderrelease] = &CTestMmfAclntARN9008::HandleStateRecorderrelease;
2037 iStateHandlers[EStateApResourceAvailable] = &CTestMmfAclntARN9008::HandleStateApResourceAvailable;
2038 iStateHandlers[EStateApPlayComplete] = &CTestMmfAclntARN9008::HandleStateApPlayComplete;
2039 iStateHandlers[EStateAosResourceAvailable] = &CTestMmfAclntARN9008::HandleStateAosResourceAvailable;
2040 iStateHandlers[EStateRecorderResumePlay] = &CTestMmfAclntARN9008::HandleStateRecorderResumePlay;
2041 iStateHandlers[EStateRecorderPlayComplete]= &CTestMmfAclntARN9008::HandleStateRecorderPlayComplete;
2044 void CTestMmfAclntARN9008::StartTestL()
2046 // Open iTestAudioPlayer
2047 iTestAudioPlayer->OpenFileL(iFilenamePlayer);
2048 INFO_PRINTF1(_L("iTestAudioPlayer->OpenFileL()"));
2049 iEventChecker->SetExpectedEvent(0,EMapcInitComplete,KErrNone);
2050 iEventChecker->SetExpectedState(EStateApInitComplete);
2053 TVerdict CTestMmfAclntARN9008::HandleStateApInitComplete()
2055 iTestAudioPlayer->Play();
2056 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
2057 // Open iTestAudioRecorder
2058 iTestAudioRecorder->OpenFileL(iFilenameRecorder);
2059 INFO_PRINTF1(_L("iTestAudioRecorder->OpenFileL()"));
2060 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone,CMdaAudioClipUtility::EOpen);
2061 iEventChecker->SetExpectedState(EStateRecoderOpen);
2065 TVerdict CTestMmfAclntARN9008::HandleStateRecorderOpen()
2067 iTestAudioRecorder->PlayL();
2068 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
2069 // Set ExpectedEvent and change the State
2070 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EPlaying);
2071 iEventChecker->SetExpectedState(EStateRecoderPlaying);
2075 TVerdict CTestMmfAclntARN9008::HandleStateRecorderPlaying()
2077 iEventChecker->SetExpectedEvent(0,EMapcPlayComplete,KErrInUse);
2078 iEventChecker->SetExpectedState(EStateApPlayCompleteKErrInUse);
2082 TVerdict CTestMmfAclntARN9008::HandleApPlayCompleteKErrInUse()
2084 TInt err = iTestAudioPlayer->RegisterAudioResourceNotification(*iMdaAudioPlayerCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
2085 INFO_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification : Status - %d "), err);
2086 if( err != KErrNone )
2088 ERR_PRINTF2(_L("iTestAudioPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), err);
2089 iTestStepResult = EFail;
2090 CActiveScheduler::Stop();
2092 // Register iTestAudioOutputStream for Notification
2093 err = iTestAudioOutputStream->RegisterAudioResourceNotification(*iMdaAudioOutputStreamCallbackSupport, KMMFEventCategoryAudioResourceAvailable);
2094 INFO_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification : Status - %d "), err);
2095 if( err != KErrNone )
2097 ERR_PRINTF2(_L("iTestAudioOutputStream->RegisterAudioResourceNotification - Failed with Error : %d"), err);
2098 iTestStepResult = EFail;
2099 CActiveScheduler::Stop();
2101 // Open iTestAudioOutputStream
2102 iTestAudioOutputStream->Open(NULL);
2103 INFO_PRINTF1(_L("iTestAudioOutputStream->Open()"));
2104 // Set ExpectedEvent, ExpectedError, ExpectedRecorderState and change the State
2105 iEventChecker->SetExpectedEvent(2,EMaoscOpenComplete,KErrNone);
2106 iEventChecker->SetExpectedState(EStateAosOpenComplete);
2110 TVerdict CTestMmfAclntARN9008::HandleStateAosOpenComplete()
2113 TInt err = iFile.Read(iBuf); //-synchronous
2114 if (err != KErrNone)
2116 INFO_PRINTF2(_L("Error reading iFile %d"), err);
2119 // iTestAudioOutputStream->WriteL()
2120 INFO_PRINTF1(_L("iTestAudioOutputStream->WriteL()"));
2121 iTestAudioOutputStream->WriteL(iBuf); //-Should get Play Error.
2122 // Set ExpectedEvent & ExpectedError and change the State
2123 iEventChecker->SetExpectedEvent(2,EMaoscBufferCopied,KErrInUse);
2124 iEventChecker->SetExpectedState(EStateAosBufferCopiedKErrInUse);
2128 TVerdict CTestMmfAclntARN9008::HandleStateAosBufferCopiedKErrInUse()
2130 iEventChecker->SetExpectedEvent(2,EMaoscPlayComplete,KErrInUse);
2131 iEventChecker->SetExpectedState(EStateAosPlayCompleteKErrInUse);
2135 TVerdict CTestMmfAclntARN9008::HandleStateAosPlayCompleteKErrInUse()
2137 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EOpen);
2138 iEventChecker->SetExpectedState(EStateRecorderrelease);
2142 TVerdict CTestMmfAclntARN9008::HandleStateRecorderrelease()
2144 // Set ExpectedEvent and change the State
2145 iEventChecker->SetExpectedEvent(0,EMarncResourceAvailablePlayer,KErrNone);
2146 iEventChecker->SetExpectedState(EStateApResourceAvailable);
2150 TVerdict CTestMmfAclntARN9008::HandleStateApResourceAvailable()
2152 // iTestAudioPlayer resumes the playback.
2153 iTestAudioPlayer->SetPosition(iPosition);
2154 INFO_PRINTF1(_L("iTestAudioPlayer->SetPosition()"));
2155 iTestAudioPlayer->Play();
2156 INFO_PRINTF1(_L("iTestAudioPlayer->Play()"));
2157 // Cancel the Notification request for iTestAudioPlayer
2158 TInt err = iTestAudioPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
2159 INFO_PRINTF2(_L("iTestAudioPlayer->CancelRegisterAudioResourceNotification : Return Code = %d"), err);
2160 if( err != KErrNone )
2162 ERR_PRINTF2(_L("iTestAudioPlayer->CancelRegisterAudioResourceNotification - Failed with Error : %d"), err);
2163 iTestStepResult = EFail;
2164 CActiveScheduler::Stop();
2167 // Play iTestAudioRecorder
2168 iTestAudioRecorder->PlayL();
2169 INFO_PRINTF1(_L("iTestAudioRecorder->PlayL()"));
2170 // Set ExpectedEvent and change the State
2171 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent,KErrNone,CMdaAudioClipUtility::EPlaying);
2172 iEventChecker->SetExpectedState(EStateRecorderResumePlay);
2175 TVerdict CTestMmfAclntARN9008::HandleStateRecorderResumePlay()
2177 iEventChecker->RegisterClientEventToMonitor(0,EMapcPlayComplete,KErrInUse,EStateApPlayComplete);
2178 iEventChecker->RegisterClientEventToMonitor(2,EMarncResourceAvailableOS,KErrNone,EStateAosResourceAvailable);
2179 iEventChecker->EnableMultipleEventMonitor();
2182 TVerdict CTestMmfAclntARN9008::HandleStateApPlayComplete()
2184 INFO_PRINTF1(_L("AudioPlayer->PlayComplete"));
2185 if(iEventChecker->IsMonitoringFinished())
2187 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
2188 iEventChecker->SetExpectedState(EStateRecorderPlayComplete);
2192 iEventChecker->EnableMultipleEventMonitor();
2197 TVerdict CTestMmfAclntARN9008::HandleStateAosResourceAvailable()
2199 INFO_PRINTF1(_L("AudioPlayer->PlayComplete"));
2200 if(iEventChecker->IsMonitoringFinished())
2202 iEventChecker->SetExpectedEvent(1,EMoscoStateChangeEvent, KErrNone, CMdaAudioClipUtility::EOpen);
2203 iEventChecker->SetExpectedState(EStateRecorderPlayComplete);
2207 iEventChecker->EnableMultipleEventMonitor();
2212 TVerdict CTestMmfAclntARN9008::HandleStateRecorderPlayComplete()
2214 INFO_PRINTF1(_L("AudioRecorder->Complete"));
2215 iEventChecker->StopTest();
2219 TVerdict CTestMmfAclntARN9008::PerformTestL()
2221 INFO_PRINTF1(_L("Receipt of Notification (on cancellation of notification of a client that has just received notification) of a Resource Available Event."));
2222 INFO_PRINTF1(_L("[Cancel after receipt of Notification]"));
2223 iTestStepResult = EFail;
2225 // Initialise the handler functions
2228 // Initiate the process
2231 // Start the scheduler - Done only once !
2232 CActiveScheduler::Start();
2234 return iTestStepResult;
2237 CMultiEventChecker* CMultiEventChecker::NewL()
2239 CMultiEventChecker* s = new(ELeave) CMultiEventChecker();
2240 CleanupStack::PushL(s);
2242 CleanupStack::Pop();
2246 CMultiEventChecker::CMultiEventChecker()
2250 void CMultiEventChecker::ConstructL()
2252 iExpectedRecorderState = CMdaAudioClipUtility::ENotReady;
2253 iMonitorMultipleEvents = EFalse;
2256 void CMultiEventChecker::SetExpectedState(TInt aState)
2258 iNextState = aState;
2261 void CMultiEventChecker::StopTest()
2263 CActiveScheduler::Stop();
2266 void CMultiEventChecker::SetExpectedEvent(TInt aClientNumber, TInt aExpectedEvent, TInt aExpectedError,CMdaAudioClipUtility::TState aRecorderState)
2268 iClientEventsToMonitor[aClientNumber]= aExpectedEvent;
2269 iClientError[aClientNumber] = aExpectedError;
2270 iExpectedRecorderState = aRecorderState;
2273 void CMultiEventChecker::RegisterClientEventToMonitor(TInt aClientNumber, TInt aEventCode, TInt aError, TInt aFsmState,CMdaAudioClipUtility::TState aRecorderState)
2275 iClientsRegistered++;
2276 iClientEventsToMonitor[aClientNumber] = aEventCode;
2277 iClientError[aClientNumber] = aError;
2278 iFsmStateforClient[aClientNumber] = aFsmState;
2279 iExpectedRecorderState = aRecorderState;
2282 TBool CMultiEventChecker::IsMonitoringFinished()
2284 if(iClientsRegistered == 0)
2294 TBool CMultiEventChecker::CheckFsm(TInt aClientNumber,TClientUtilityType aClientType, TInt aEventCode, TInt aError,CMdaAudioClipUtility::TState aRecorderState)
2296 TBool retFsmCheck = ETrue;
2297 if (iMonitorMultipleEvents)
2299 if(iClientEventsToMonitor[aClientNumber] == aEventCode && iClientError[aClientNumber] == aError )
2301 SetExpectedState(iFsmStateforClient[aClientNumber]);
2305 retFsmCheck = EFalse;
2310 //Client event has finished
2311 iClientsRegistered--;
2313 iMonitorMultipleEvents = EFalse;
2317 if(iClientEventsToMonitor[aClientNumber] != aEventCode)
2319 retFsmCheck = EFalse;
2321 else if(iClientError[aClientNumber] != aError)
2323 retFsmCheck = EFalse;
2325 else if (aClientType == EAudioRecorder)
2327 if (iExpectedRecorderState != aRecorderState)
2329 retFsmCheck = EFalse;