mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/TSU_MMFMIDICLNT.h
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 
       
     2 // Copyright (c) 2001-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".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:
       
    15 // TSI_MMFMIDICLNT.h
       
    16 // Header file: Basic  tests.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file TSI_MMFVCLNT.h
       
    22 */
       
    23 
       
    24 #ifndef TSU_MMFMIDICLNT_H__
       
    25 #define TSU_MMFMIDICLNT_H__
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <badesca.h>
       
    29 #include <e32test.h>
       
    30 #include <e32keys.h>
       
    31 #include <c32comm.h>
       
    32 #include <f32file.h>
       
    33 #include <etel.h>
       
    34 #include <etelmm.h>
       
    35 #include <testframework.h>
       
    36 
       
    37 #include <fbs.h>
       
    38 #include <w32std.h>
       
    39 #include <mmf/common/mmfstandardcustomcommands.h>
       
    40 #include <midiclientutility.h>
       
    41 #include <mmf/common/mmfcontrollerframework.h>
       
    42 
       
    43 // Uncomment this line for Jet-stream project
       
    44 //#define JETSTREAM_TESTS  1 
       
    45 
       
    46 class CTestSuite ;
       
    47 
       
    48 // Flags for test step differentiation
       
    49 enum TTestStepType
       
    50 {
       
    51 	ETestValid = 0,
       
    52 	ETestNegative,
       
    53 	ETestNullMessage,
       
    54 	ETestInvalidMessage,
       
    55 	ETestInvalidId,
       
    56 	ETestInvalidIndex,
       
    57 	ETestInvalidChannel,
       
    58 	ETestAlreadyLoaded,
       
    59 	ETestNotLoaded,
       
    60 	ETestNotUnloadable,
       
    61 	ETestOutOfRangeHigh,
       
    62 	ETestOutOfRangeLow,
       
    63 	ETestTimeOutOfRangeHigh,
       
    64 	ETestTimeOutOfRangeLow,
       
    65 	ETestUnsupported,
       
    66 	ETestCorrupt,
       
    67 	ETestOverflow,
       
    68 	ETestNoPlugin,
       
    69 	ETestInvalidState,
       
    70 	ETestNoResource,
       
    71 	ETestZeroDurationOutOfRange,
       
    72 	ETestInvalidChannelOutOfRange,
       
    73 	ETestNoteHighOutOfRange,
       
    74 	ETestNoteLowOutOfRange,
       
    75 	ETestAttackHighOutOfRange,
       
    76 	ETestAttackLowOutOfRange,
       
    77 	ETestReleaseHighOutOfRange,
       
    78 	ETestReleaseLowOutOfRange,
       
    79 	ETestNoNoteAvailable,
       
    80 	ETestDifferentNoteVelocity,
       
    81 	ETestVelocityHighOutOfRange,
       
    82 	ETestVelocityLowOutOfRange,
       
    83 	ETestBeatsHighOutOfRange,
       
    84 	ETestBeatsLowOutOfRange,
       
    85 	ETestInvalidTrack,
       
    86 	ETestNoResourcePlaying,
       
    87 	ETestMicrosecondsHighOutOfRange,
       
    88 	ETestMicrosecondsLowOutOfRange,
       
    89 	ETestMicrobeatsHighOutOfRange,
       
    90 	ETestMicrobeatsLowOutOfRange,
       
    91 	ETestMicrosecondsMicrobeatsZero,
       
    92 	ETestVolumeHighOutOfRange,
       
    93 	ETestVolumeLowOutOfRange,
       
    94 	ETestRampDurationHighOutOfRange,
       
    95 	ETestRampDurationLowOutOfRange,
       
    96 	ETestBalanceHighOutOfRange,
       
    97 	ETestBalanceLowOutOfRange,
       
    98 	ETestPreferenceConflictsCannotBeResolved,
       
    99 	ETestMetaDataIndexInvalid,
       
   100 	ETestOutOfRange,
       
   101 	ETestNoStandardBanks,
       
   102 	ETestNoCustomBanks,
       
   103 	ETestCheckInterface
       
   104 };
       
   105 
       
   106 /**
       
   107  * @ MCallbackHandlerObserver, provides an Observer
       
   108  * @ for monitoring callbacks.
       
   109  */
       
   110 class MCallbackHandlerObserver
       
   111 	{
       
   112 public:
       
   113 	virtual void MchoComplete(TInt aID, TInt aError)=0;
       
   114 	};
       
   115 
       
   116 /**
       
   117  *
       
   118  * CActiveListener provides the asynchronous operation
       
   119  * of an active object
       
   120  *
       
   121  * @class CActiveListener
       
   122  *
       
   123  */
       
   124 class CActiveListener : public CActive
       
   125 	{
       
   126 public:
       
   127 	CActiveListener() : CActive(CActive::EPriorityIdle) { CActiveScheduler::Add(this); }
       
   128 	void InitialiseActiveListener() { iStatus = KRequestPending; SetActive(); }
       
   129 	// From CActive, From Base Class
       
   130 	void RunL() { CActiveScheduler::Stop(); }
       
   131 	void DoCancel() {};
       
   132 	};
       
   133 
       
   134 /**
       
   135  * Global Data used within tests
       
   136  *
       
   137  */
       
   138 
       
   139 const TInt KTwelfthOfSec		= 83333;
       
   140 const TInt KTenthOfSec			= 100000 ;
       
   141 const TInt KOneSecond			= 1000000;	// Used in a time out function, 1 second (in microSeconds)
       
   142 const TInt KTenSeconds			= 10000000;	// Used in a time out function, 10 seconds (in microSeconds)
       
   143 const TInt KFiveSeconds			= 5000000;	// 5 seconds (in microSeconds)
       
   144 const TInt KFifteenSeconds		= 15000000;	// 15 seconds (in microSeconds)
       
   145 const TInt KExpectedDeviation	= 1500000;	// 1.5 second tolerance for timed tests
       
   146 const TInt KNameBufSize			= 25;
       
   147 
       
   148 const TInt KMaxBalance	=  100;
       
   149 const TInt KMinBalance  = -100;
       
   150 
       
   151 const TInt KMaxVolume   =  100;
       
   152 
       
   153 
       
   154 enum TDevMidiByPass
       
   155 	{
       
   156     EDevMidiOff = 0,
       
   157     EDevMidiOn = 1
       
   158 	};
       
   159 
       
   160 /**
       
   161  * It's a base class for all test steps.
       
   162  *
       
   163  * @class CTestMmfVclntStep 
       
   164  * @brief Test class that enables tests.
       
   165  *
       
   166  */
       
   167 class CTestMmfMidiClntStep : public CTestStep, public MMidiClientUtilityObserver
       
   168 	{
       
   169 public:
       
   170 	CTestMmfMidiClntStep(const TDesC& aTestName, const TTestStepType aTestType);
       
   171 	CTestMmfMidiClntStep();
       
   172 	~CTestMmfMidiClntStep();
       
   173 	//void Close();
       
   174 	static void CleanUp(TAny *aPtr) ;
       
   175 	void SetTestSuite(const CTestSuite* aTestSuite ) { iTestSuite = aTestSuite; }  
       
   176 
       
   177 	// MMidiClientUtilityObserver
       
   178 	virtual void MmcuoStateChanged(TMidiState aOldState,TMidiState aNewState,const TTimeIntervalMicroSeconds& aTime,TInt aError);
       
   179 	virtual void MmcuoTempoChanged(TInt aMicroBeatsPerMinute);
       
   180 	virtual void MmcuoVolumeChanged(TInt aChannel,TReal32 aVolumeInDecibels);
       
   181 	virtual void MmcuoMuteChanged(TInt aChannel,TBool aMuted);
       
   182 	virtual void MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats);
       
   183 	virtual void MmcuoMetaDataEntryFound(const TInt aMetaDataEntryId,const TTimeIntervalMicroSeconds& aPosition);
       
   184 	virtual void MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& aEntry);
       
   185 	virtual void MmcuoPolyphonyChanged(TInt aNewPolyphony);
       
   186 	virtual void MmcuoInstrumentChanged(TInt aChannel,TInt aBankId,TInt aInstrumentId);
       
   187 
       
   188 protected:
       
   189 	void WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds);
       
   190 	TBool TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDivation);
       
   191 	// tests may optionally implement pre- and post-ambles, From Base Class
       
   192 	virtual TVerdict DoTestStepPreambleL();
       
   193 	virtual TVerdict DoTestStepPostambleL();
       
   194 	virtual TVerdict DoTestStepL();
       
   195 	virtual TVerdict DoTestL(CMidiClientUtility* aMidi);
       
   196 	void InitWservL();
       
   197 
       
   198 protected:
       
   199 	const CTestSuite* iTestSuite ;
       
   200 	CActiveScheduler* iActiveScheduler;
       
   201 	TInt iError;
       
   202 
       
   203 	TInt iTestType;
       
   204 
       
   205 	CWsScreenDevice* iScreen;
       
   206 	RWindow* iWindow;
       
   207 	RWsSession iWs;
       
   208 	TMidiState iCurrentState;
       
   209 	};
       
   210 
       
   211 #endif
       
   212 
       
   213 
       
   214 
       
   215