sl@0: sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This program is designed the test of the TSU_MMFMIDICLNT.cpp. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file TSU_MMFMIDICLNT.cpp sl@0: */ sl@0: sl@0: #include "TSU_MMFMIDICLNT.h" sl@0: sl@0: sl@0: /** sl@0: * Timeout function sl@0: */ sl@0: void CTestMmfMidiClntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds) sl@0: { sl@0: TRequestStatus timerStatus; sl@0: RTimer timer; sl@0: timer.CreateLocal() ; sl@0: timer.After(timerStatus,aNumberOfMicroSeconds); sl@0: sl@0: User::WaitForRequest(aStatus, timerStatus); sl@0: if (timerStatus == KRequestPending) sl@0: { sl@0: timer.Cancel(); sl@0: User::WaitForRequest(timerStatus); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CTestMmfMidiClntStep wait timed out")) ; sl@0: } sl@0: timer.Close() ; sl@0: } sl@0: sl@0: /** sl@0: * Time comparison utility function sl@0: * sl@0: * @param "const TUint aActual" sl@0: * The actual timer value produced sl@0: * @param "const TUint aExpected" sl@0: * Expected timer value sl@0: * @param "const TUint aDeviation" sl@0: * Allowed deviation of the expected value sl@0: * from the actual value. sl@0: * @return "TBool" sl@0: * Did actual timed value fall within deviation limits sl@0: */ sl@0: TBool CTestMmfMidiClntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation) sl@0: { sl@0: // save unnessary conditions sl@0: if(aActual == aExpected) sl@0: return ETrue; sl@0: sl@0: // Prevent unsigned wrapping errors sl@0: TUint difference; sl@0: if(aActual > aExpected) sl@0: difference = aActual - aExpected; sl@0: else sl@0: difference = aExpected - aActual; sl@0: sl@0: // compare sl@0: if(difference < aDeviation) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Test Preamble routines. sl@0: * sl@0: * Creates our own Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Preamble complete. sl@0: */ sl@0: TVerdict CTestMmfMidiClntStep::DoTestStepPreambleL() sl@0: { sl@0: iActiveScheduler = new(ELeave) CActiveScheduler; sl@0: //[ push the scheduler on the stack ] sl@0: CleanupStack::PushL( iActiveScheduler ); sl@0: sl@0: //[install the active scheduler ] sl@0: CActiveScheduler::Install(iActiveScheduler); sl@0: sl@0: // Pop the element from the stack sl@0: CleanupStack::Pop(); sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * Test Postamble routines. sl@0: * sl@0: * Destroys our Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Postamble complete. sl@0: */ sl@0: TVerdict CTestMmfMidiClntStep::DoTestStepPostambleL() sl@0: { sl@0: delete iActiveScheduler; sl@0: iActiveScheduler = NULL; sl@0: sl@0: delete iScreen; sl@0: delete iWindow; sl@0: iWs.Close(); sl@0: sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * CTestMMFVCLNTStep Implementation sl@0: */ sl@0: CTestMmfMidiClntStep::CTestMmfMidiClntStep(const TDesC& aTestName, const TTestStepType aTestType) sl@0: :CTestStep(), sl@0: iActiveScheduler( NULL ) sl@0: { sl@0: // store the name of this test step sl@0: // this is the name that is used by the script file sl@0: // Each test step initialises it's own name sl@0: iTestStepName = aTestName; sl@0: iTestType = aTestType; sl@0: } sl@0: sl@0: CTestMmfMidiClntStep::CTestMmfMidiClntStep() sl@0: :iActiveScheduler( NULL ) sl@0: // for test step that sets its own name sl@0: { sl@0: iTestType = ETestValid; sl@0: } sl@0: sl@0: CTestMmfMidiClntStep::~CTestMmfMidiClntStep() sl@0: { sl@0: } sl@0: sl@0: /*void CTestMmfMidiClntStep::Close() sl@0: { sl@0: delete iScreen; sl@0: delete iWindow; sl@0: iWs.Close(); sl@0: }*/ sl@0: sl@0: /** sl@0: * DoTestStepL : same as CTestMidiClientOpenFile::DoTestStepL() but with no file opening sl@0: * routines. sl@0: * sl@0: * Generally, test steps should NOT override this, but put their processing in DoTestL() sl@0: * sl@0: */ sl@0: TVerdict CTestMmfMidiClntStep::DoTestStepL() sl@0: { sl@0: __MM_HEAP_MARK; sl@0: CMidiClientUtility* player = CMidiClientUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality); sl@0: if (!player) sl@0: { sl@0: ERR_PRINTF1(_L("Could not create a CMidiClientUtility")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: CleanupStack::PushL(player); sl@0: sl@0: TMMFMessageDestinationPckg dummyPckg; sl@0: TInt dummyFunc = 0; //EDevMidiOff; sl@0: TBuf8<8> dummyBuff; sl@0: player->CustomCommandSyncL(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff); sl@0: sl@0: TVerdict ret = DoTestL(player); sl@0: sl@0: INFO_PRINTF1(_L("CMidiClientUtility: Destroying")); sl@0: CleanupStack::PopAndDestroy(player); sl@0: sl@0: if(iError != KErrNone) sl@0: ERR_PRINTF2( _L("CMidiClientUtility failed with error %d"),iError ); sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: return ret; sl@0: } sl@0: sl@0: TVerdict CTestMmfMidiClntStep::DoTestL(CMidiClientUtility* /*aMidi*/) sl@0: { sl@0: return EPass; sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::InitWservL() sl@0: { sl@0: TInt err = iWs.Connect(); sl@0: if (err != KErrNone) sl@0: { sl@0: // Access violation if ws is null sl@0: INFO_PRINTF1(_L("Cannot test, no window server available")); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session sl@0: User::LeaveIfError(iScreen->Construct()); // and complete its construction sl@0: sl@0: RWindowGroup rootWindow = RWindowGroup(iWs); sl@0: User::LeaveIfError(rootWindow.Construct((TUint32)this, ETrue)); sl@0: sl@0: iWindow = new(ELeave) RWindow(iWs); sl@0: User::LeaveIfError(((RWindow*)iWindow)->Construct(rootWindow,((TUint32)(this)) + 1)); sl@0: iWindow->SetExtent(TPoint(0,0), TSize(100,100)); sl@0: iWindow->SetVisible(ETrue); sl@0: iWindow->Activate(); sl@0: iWs.Flush(); sl@0: } sl@0: sl@0: // MMidiClientUtilityObserver sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoStateChanged(TMidiState aOldState, TMidiState aNewState, sl@0: const TTimeIntervalMicroSeconds& /* aTime */, TInt aError) sl@0: { sl@0: INFO_PRINTF3(_L("MmcuoStateChanged callback, oldState = %d, newState = %d"), aOldState, aNewState); sl@0: sl@0: iError = aError; sl@0: iCurrentState = aNewState; sl@0: CActiveScheduler::Stop(); // check if asynchronous sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoTempoChanged(TInt /* aMicroBeatsPerMinute */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoTempoChanged callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoVolumeChanged(TInt /*aChannel*/,TReal32 /*aVolumeInDecibels*/) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoVolumeChanged callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoMuteChanged(TInt /* aChannel */, TBool /* aMuted */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoMuteChanged callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& /* aMicroSeconds */, TInt64 /* aMicroBeats */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoSyncUpdate callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoMetaDataEntryFound(const TInt /*aMetaDataEntryId*/,const TTimeIntervalMicroSeconds& /*aPosition*/) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoSmfMetaDataEntryFound callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoMipMessageReceived(const RArray& /* aEntry */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoMipMessageReceived callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoPolyphonyChanged(TInt /* aNewPolyphony */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoPolyphonyChanged callback")); sl@0: } sl@0: sl@0: void CTestMmfMidiClntStep::MmcuoInstrumentChanged(TInt /* aChannel */, TInt /* aBankId */, TInt /* aInstrumentId */) sl@0: { sl@0: INFO_PRINTF1(_L("MmcuoInstrumentChanged callback")); sl@0: } sl@0: