First public contribution.
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 // Start Server to play back from another process
119 User::LeaveIfError(server.Connect(_L("CapTestServer")));
120 CleanupClosePushL(server);
122 RTestSession session1;
123 User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
124 TRequestStatus* status = &iServerMonitor->ActiveStatus();
125 // Start Server playback. The RunL of the CServerMonitor class will be called by the server when
126 // playback has started
127 session1.StartProcessing(*status);
128 // Begin activescheduler loop. This will only exit when the whole test is complete
129 CActiveScheduler::Start();
131 // The test is complete. Now shut down the server and get any errors /messages from the server
133 TVerdict verdict = session1.EndProcessingAndReturnResult(message);
134 if (verdict != EPass)
136 TBuf16<256> copymess;
137 copymess.Copy(message);
138 INFO_PRINTF2(_L("end processing and return result: %S"),©mess);
140 CleanupStack::PopAndDestroy(&server);
144 void CTestMmfAclntCaps0014::CreatePlayer()
146 // Get the test filename from the configuration file
147 TBuf<KSizeBuf> filename;
149 if(!GetStringFromConfig(iSectName,iKeyName,filename1))
152 CActiveScheduler::Stop();
154 GetDriveName(filename);
155 filename.Append(filename1);
157 iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
158 iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
161 void CTestMmfAclntCaps0014::BeginPlayback()
167 void CTestMmfAclntCaps0014::DoProcess(TInt aError)
169 if (aError == KErrNone)
171 InternalState nextState = iState;
174 case EWaitingForServer:
176 nextState = EInitPlayer;
180 nextState = EPlaying;
184 CActiveScheduler::Stop();
192 INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
193 CActiveScheduler::Stop();
197 CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent)
198 :CActive(EPriorityNormal), iParent(aParent)
203 CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent)
205 CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
206 CleanupStack::PushL(self);
208 CleanupStack::Pop(self);
212 void CTestMmfAclntCaps0014::CServerMonitor::ConstructL()
214 CActiveScheduler::Add(this);
217 void CTestMmfAclntCaps0014::CServerMonitor::DoCancel()
222 void CTestMmfAclntCaps0014::CServerMonitor::RunL()
224 // start the client state machine
225 iParent->DoProcess(iStatus.Int());
228 TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus()
235 CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014()
238 delete iServerMonitor;