Update contrib.
2 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3 // All rights reserved.
4 // This component and the accompanying materials are made available
5 // under the terms of "Eclipse Public License v1.0"
6 // which accompanies this distribution, and is available
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 // Initial Contributors:
10 // Nokia Corporation - initial contribution.
15 // TestCapabilities.CPP
16 // This program is designed the test of the MMF_ACLNT.
21 @file TestPlayerUtils.cpp
24 #include <simulprocclient.h>
25 #include "TestPlayerCaps.h"
26 #include "TestPlayerCaps0014.h"
33 CTestMmfAclntCaps0014::CTestMmfAclntCaps0014(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
35 // store the name of this test case
36 // this is the name that is used by the script file
37 // Each test step initialises it's own name
38 iTestStepName = aTestName;
39 iSectName = aSectName;
43 CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
45 CTestMmfAclntCaps0014* self = new (ELeave) CTestMmfAclntCaps0014(aTestName, aSectName, aKeyName);
49 CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
51 CTestMmfAclntCaps0014* self = NewL(aTestName, aSectName, aKeyName);
52 CleanupStack::PushL(self);
56 //void CTestMmfAclntCaps0014::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
58 // INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
62 //void CTestMmfAclntCaps0014::MapcPlayComplete(TInt aError)
64 // INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
68 void CTestMmfAclntCaps0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
70 if (aErrorCode == KErrNone)
72 if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen)
76 else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording)
78 User::After( 1000000 ); // record for this long
81 CActiveScheduler::Stop();
83 else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
85 // this shouldn't happen as record will continue until interrupted
87 CActiveScheduler::Stop();
90 else if (aErrorCode == KErrInUse)
92 // double check state to ensure behaviour is correct
93 if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
96 CActiveScheduler::Stop();
103 CActiveScheduler::Stop();
108 /** Load and initialise an audio file.
110 TVerdict CTestMmfAclntCaps0014::DoTestStepL( void )
112 INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
115 iServerMonitor = CServerMonitor::NewL(this);
117 // TSI_MMF_SDEVSOUND, MM-MMF-SDEVSOUND-I-0010-HP runs before this
118 // this step does, I-0010-HP creates and uses
119 // rectest1.wav and rectest2.wav
120 // So we need to delete these to avoid errors In this test.
123 TRAPD(err,fsSession.Delete(_L("c:\\rectest1.wav")));
124 TRAP(err,fsSession.Delete(_L("c:\\rectest2.wav")));
127 // Start Server to play back from another process
129 User::LeaveIfError(server.Connect(_L("CapTestServer")));
130 CleanupClosePushL(server);
131 RTestSession session1;
132 User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
133 TRequestStatus* status = &iServerMonitor->ActiveStatus();
134 // Start Server playback. The RunL of the CServerMonitor class will be called by the server when
135 // playback has started
136 session1.StartProcessing(*status);
137 // Begin activescheduler loop. This will only exit when the whole test is complete
138 CActiveScheduler::Start();
140 // The test is complete. Now shut down the server and get any errors /messages from the server
142 TVerdict verdict = session1.EndProcessingAndReturnResult(message);
143 if (verdict != EPass)
145 TBuf16<256> copymess;
146 copymess.Copy(message);
147 INFO_PRINTF2(_L("end processing and return result: %S"),©mess);
149 CleanupStack::PopAndDestroy(&server);
153 void CTestMmfAclntCaps0014::CreatePlayer()
155 // Get the test filename from the configuration file
156 TBuf<KSizeBuf> filename;
158 if(!GetStringFromConfig(iSectName,iKeyName,filename1))
161 CActiveScheduler::Stop();
163 GetDriveName(filename);
164 filename.Append(filename1);
166 iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
167 iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
170 void CTestMmfAclntCaps0014::BeginPlayback()
176 void CTestMmfAclntCaps0014::DoProcess(TInt aError)
178 if (aError == KErrNone)
180 InternalState nextState = iState;
183 case EWaitingForServer:
185 nextState = EInitPlayer;
189 nextState = EPlaying;
193 CActiveScheduler::Stop();
201 INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
202 CActiveScheduler::Stop();
206 CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent)
207 :CActive(EPriorityNormal), iParent(aParent)
212 CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent)
214 CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
215 CleanupStack::PushL(self);
217 CleanupStack::Pop(self);
221 void CTestMmfAclntCaps0014::CServerMonitor::ConstructL()
223 CActiveScheduler::Add(this);
226 void CTestMmfAclntCaps0014::CServerMonitor::DoCancel()
231 void CTestMmfAclntCaps0014::CServerMonitor::RunL()
233 // start the client state machine
234 iParent->DoProcess(iStatus.Int());
237 TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus()
244 CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014()
248 void CTestMmfAclntCaps0014::Close()
251 delete iServerMonitor;