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 // This program is designed the test of the TSU_MMFMIDICLNT.cpp.
20 @file TSU_MMFMIDICLNT.cpp
23 #include "TSU_MMFMIDICLNT.h"
29 void CTestMmfMidiClntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
31 TRequestStatus timerStatus;
34 timer.After(timerStatus,aNumberOfMicroSeconds);
36 User::WaitForRequest(aStatus, timerStatus);
37 if (timerStatus == KRequestPending)
40 User::WaitForRequest(timerStatus);
44 INFO_PRINTF1(_L("CTestMmfMidiClntStep wait timed out")) ;
50 * Time comparison utility function
52 * @param "const TUint aActual"
53 * The actual timer value produced
54 * @param "const TUint aExpected"
55 * Expected timer value
56 * @param "const TUint aDeviation"
57 * Allowed deviation of the expected value
58 * from the actual value.
60 * Did actual timed value fall within deviation limits
62 TBool CTestMmfMidiClntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
64 // save unnessary conditions
65 if(aActual == aExpected)
68 // Prevent unsigned wrapping errors
70 if(aActual > aExpected)
71 difference = aActual - aExpected;
73 difference = aExpected - aActual;
76 if(difference < aDeviation)
82 * Test Preamble routines.
84 * Creates our own Active Scheduler.
87 * Did Preamble complete.
89 TVerdict CTestMmfMidiClntStep::DoTestStepPreambleL()
91 iActiveScheduler = new(ELeave) CActiveScheduler;
92 //[ push the scheduler on the stack ]
93 CleanupStack::PushL( iActiveScheduler );
95 //[install the active scheduler ]
96 CActiveScheduler::Install(iActiveScheduler);
98 // Pop the element from the stack
105 * Test Postamble routines.
107 * Destroys our Active Scheduler.
110 * Did Postamble complete.
112 TVerdict CTestMmfMidiClntStep::DoTestStepPostambleL()
114 delete iActiveScheduler;
115 iActiveScheduler = NULL;
126 * CTestMMFVCLNTStep Implementation
128 CTestMmfMidiClntStep::CTestMmfMidiClntStep(const TDesC& aTestName, const TTestStepType aTestType)
130 iActiveScheduler( NULL )
132 // store the name of this test step
133 // this is the name that is used by the script file
134 // Each test step initialises it's own name
135 iTestStepName = aTestName;
136 iTestType = aTestType;
139 CTestMmfMidiClntStep::CTestMmfMidiClntStep()
140 :iActiveScheduler( NULL )
141 // for test step that sets its own name
143 iTestType = ETestValid;
146 CTestMmfMidiClntStep::~CTestMmfMidiClntStep()
150 /*void CTestMmfMidiClntStep::Close()
158 * DoTestStepL : same as CTestMidiClientOpenFile::DoTestStepL() but with no file opening
161 * Generally, test steps should NOT override this, but put their processing in DoTestL()
164 TVerdict CTestMmfMidiClntStep::DoTestStepL()
167 CMidiClientUtility* player = CMidiClientUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
170 ERR_PRINTF1(_L("Could not create a CMidiClientUtility"));
171 return EInconclusive;
174 CleanupStack::PushL(player);
176 TMMFMessageDestinationPckg dummyPckg;
177 TInt dummyFunc = 0; //EDevMidiOff;
179 player->CustomCommandSyncL(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff);
181 TVerdict ret = DoTestL(player);
183 INFO_PRINTF1(_L("CMidiClientUtility: Destroying"));
184 CleanupStack::PopAndDestroy(player);
186 if(iError != KErrNone)
187 ERR_PRINTF2( _L("CMidiClientUtility failed with error %d"),iError );
193 TVerdict CTestMmfMidiClntStep::DoTestL(CMidiClientUtility* /*aMidi*/)
198 void CTestMmfMidiClntStep::InitWservL()
200 TInt err = iWs.Connect();
203 // Access violation if ws is null
204 INFO_PRINTF1(_L("Cannot test, no window server available"));
208 iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session
209 User::LeaveIfError(iScreen->Construct()); // and complete its construction
211 RWindowGroup rootWindow = RWindowGroup(iWs);
212 User::LeaveIfError(rootWindow.Construct((TUint32)this, ETrue));
214 iWindow = new(ELeave) RWindow(iWs);
215 User::LeaveIfError(((RWindow*)iWindow)->Construct(rootWindow,((TUint32)(this)) + 1));
216 iWindow->SetExtent(TPoint(0,0), TSize(100,100));
217 iWindow->SetVisible(ETrue);
222 // MMidiClientUtilityObserver
224 void CTestMmfMidiClntStep::MmcuoStateChanged(TMidiState aOldState, TMidiState aNewState,
225 const TTimeIntervalMicroSeconds& /* aTime */, TInt aError)
227 INFO_PRINTF3(_L("MmcuoStateChanged callback, oldState = %d, newState = %d"), aOldState, aNewState);
230 iCurrentState = aNewState;
231 CActiveScheduler::Stop(); // check if asynchronous
234 void CTestMmfMidiClntStep::MmcuoTempoChanged(TInt /* aMicroBeatsPerMinute */)
236 INFO_PRINTF1(_L("MmcuoTempoChanged callback"));
239 void CTestMmfMidiClntStep::MmcuoVolumeChanged(TInt /*aChannel*/,TReal32 /*aVolumeInDecibels*/)
241 INFO_PRINTF1(_L("MmcuoVolumeChanged callback"));
244 void CTestMmfMidiClntStep::MmcuoMuteChanged(TInt /* aChannel */, TBool /* aMuted */)
246 INFO_PRINTF1(_L("MmcuoMuteChanged callback"));
249 void CTestMmfMidiClntStep::MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& /* aMicroSeconds */, TInt64 /* aMicroBeats */)
251 INFO_PRINTF1(_L("MmcuoSyncUpdate callback"));
254 void CTestMmfMidiClntStep::MmcuoMetaDataEntryFound(const TInt /*aMetaDataEntryId*/,const TTimeIntervalMicroSeconds& /*aPosition*/)
256 INFO_PRINTF1(_L("MmcuoSmfMetaDataEntryFound callback"));
259 void CTestMmfMidiClntStep::MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& /* aEntry */)
261 INFO_PRINTF1(_L("MmcuoMipMessageReceived callback"));
264 void CTestMmfMidiClntStep::MmcuoPolyphonyChanged(TInt /* aNewPolyphony */)
266 INFO_PRINTF1(_L("MmcuoPolyphonyChanged callback"));
269 void CTestMmfMidiClntStep::MmcuoInstrumentChanged(TInt /* aChannel */, TInt /* aBankId */, TInt /* aInstrumentId */)
271 INFO_PRINTF1(_L("MmcuoInstrumentChanged callback"));