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 // This program is designed to test the MMF_ACLNT.
20 @file TSI_MMFACLNT.cpp
22 #include <mda/common/audio.h>
23 #include <mda/common/gsmaudio.h>
24 #include "TSI_MMFACLNT.h"
25 #include "TSI_MMFACLNT.inl"
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
27 #include <mda/common/mdagsmwavcodec.h>
30 void CPlayerCallbackHandler::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
32 iMchObserver->MchoComplete(ID(),aError);
35 void CPlayerCallbackHandler::MapcPlayComplete(TInt aError)
37 iMchObserver->MchoComplete(ID(),aError);
40 void CStateCallbackHandler::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
42 iMchObserver->MchoComplete(ID(),aErrorCode);
45 void CToneCallbackHandler::MatoPrepareComplete(TInt aError)
47 iMchObserver->MchoComplete(ID(),aError);
50 void CToneCallbackHandler::MatoPlayComplete(TInt aError)
52 iMchObserver->MchoComplete(ID(),aError);
58 void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
60 TRequestStatus timerStatus;
63 timer.After(timerStatus,aNumberOfMicroSeconds);
65 User::WaitForRequest(aStatus, timerStatus);
66 if (timerStatus == KRequestPending)
69 User::WaitForRequest(timerStatus);
73 INFO_PRINTF1(_L("Time is over!!!")) ;
79 * Time comparison utility function
81 * @param "const TUint aActual"
82 * The actual timer value produced
83 * @param "const TUint aExpected"
84 * Expected timer value
85 * @param "const TUint aDeviation"
86 * Allowed deviation of the expected value
87 * from the actual value.
89 * Did actual timed value fall within deviation limits
91 TBool CTestMmfAclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
93 // save unnessary conditions
94 if(aActual == aExpected)
97 // Prevent unsigned wrapping errors
99 if(aActual > aExpected)
100 difference = aActual - aExpected;
102 difference = aExpected - aActual;
105 if(difference < aDeviation)
111 * Test Preample routines.
113 * Creates our own Active Scheduler.
116 * Did Preamble complete.
118 TVerdict CTestMmfAclntStep::DoTestStepPreambleL()
121 iActiveScheduler = new(ELeave) CActiveScheduler;
122 CActiveScheduler::Install(iActiveScheduler);
129 * Test Postamble routines.
131 * Destroys our Active Scheduler.
134 * Did Postamble complete.
136 TVerdict CTestMmfAclntStep::DoTestStepPostambleL()
138 delete iActiveScheduler;
139 iActiveScheduler = NULL;
145 * CTestMMFACLNTStep Implementation
147 * @parameter "const CTestSuite* aTestSuite"
148 * Sets test suite pointer
150 void CTestMmfAclntStep::SetTestSuite(const CTestSuite* aTestSuite )
152 iTestSuite = aTestSuite;
156 * CTestMMFACLNTStep Implementation
158 CTestMmfAclntStep::CTestMmfAclntStep()
159 :iActiveScheduler( NULL )
162 //------------------------------------------------------
165 * Deconstructors destroys iFormat and iCodec
168 TVerdict CTestMmfAclntCodecTest::DoTestStepPostambleL()
180 return CTestMmfAclntStep::DoTestStepPostambleL();
184 * Setup codec and format to test
186 * @parameter "const TTestFormat aFormat"
187 * enum of format to use
189 void CTestMmfAclntCodecTest::SetupFormatL(const TTestFormat aFormat)
201 iFormat = new (ELeave) TMdaWavClipFormat;
202 CleanupStack::PushL(iFormat);
203 iCodec = new (ELeave) TMdaPcmWavCodec;
204 CleanupStack::PushL(iCodec);
207 iFormat = new (ELeave) TMdaRawAudioClipFormat;
208 CleanupStack::PushL(iFormat);
209 iCodec = new (ELeave) TMdaAlawRawAudioCodec;
210 CleanupStack::PushL(iCodec);
213 iFormat = new (ELeave) TMdaAuClipFormat;
214 CleanupStack::PushL(iFormat);
215 iCodec = new (ELeave) TMdaAuCodec;
216 CleanupStack::PushL(iCodec);
219 iFormat = new (ELeave) TMdaAuClipFormat;
220 CleanupStack::PushL(iFormat);
221 iCodec = new (ELeave) TMdaAlawAuCodec;
222 CleanupStack::PushL(iCodec);
225 iFormat = new (ELeave) TMdaAuClipFormat;
226 CleanupStack::PushL(iFormat);
227 iCodec = new (ELeave) TMdaPcm16BitAuCodec;
228 CleanupStack::PushL(iCodec);
231 iFormat = new (ELeave) TMdaWavClipFormat;
232 CleanupStack::PushL(iFormat);
233 iCodec = new (ELeave) TMdaImaAdpcmWavCodec;
234 CleanupStack::PushL(iCodec);
237 iFormat = new (ELeave) TMdaWavClipFormat;
238 CleanupStack::PushL(iFormat);
239 iCodec = new (ELeave) TMdaAlawWavCodec;
240 CleanupStack::PushL(iCodec);
243 iFormat = new (ELeave) TMdaRawAudioClipFormat();
244 CleanupStack::PushL(iFormat);
245 iCodec = new (ELeave) TMdaUB16RawAudioCodec();
246 CleanupStack::PushL(iCodec);
249 iFormat = new (ELeave) TMdaRawAudioClipFormat();
250 CleanupStack::PushL(iFormat);
251 iCodec = new (ELeave) TMdaU8PcmRawAudioCodec();
252 CleanupStack::PushL(iCodec);
255 iFormat = new (ELeave) TMdaWavClipFormat();
256 CleanupStack::PushL(iFormat);
257 iCodec = new (ELeave) TMdaImaAdpcmWavCodec();
258 CleanupStack::PushL(iCodec);
261 iFormat = new (ELeave) TMdaWavClipFormat();
262 CleanupStack::PushL(iFormat);
263 iCodec = new (ELeave) TMdaPcmWavCodec(TMdaPcmWavCodec::E8BitPcm);
264 CleanupStack::PushL(iCodec);
267 iFormat = new (ELeave) TMdaWavClipFormat;
268 CleanupStack::PushL(iFormat);
269 iCodec = new (ELeave) TMdaGsmWavCodec;
270 CleanupStack::PushL(iCodec);
275 // will create an inconlusive result as preamble leaves.
281 if((iFormat != NULL) && (iCodec != NULL))
283 CleanupStack::Pop(); // iFormat
284 CleanupStack::Pop(); // iCodec