mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TSI_MMFACLNT.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 // Header file: Basic  tests.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file TSI_MMFACLNT.h
       
    21 */
       
    22 
       
    23 #ifndef TSI_MMFACLNT_H__
       
    24 #define TSI_MMFACLNT_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <badesca.h>
       
    28 #include <e32test.h>
       
    29 #include <e32keys.h>
       
    30 #include <c32comm.h>
       
    31 #include <f32file.h>
       
    32 #include <etel.h>
       
    33 #include <etelmm.h>
       
    34 #include <utf.h>
       
    35 #include <testframework.h>
       
    36 
       
    37 #include <mdaaudiosampleplayer.h>
       
    38 #include <mdaaudiosampleeditor.h>
       
    39 #include <mdaaudiotoneplayer.h>
       
    40 #include <mmfformatimplementationuids.hrh>
       
    41 
       
    42 
       
    43 #include "toneTest.h"
       
    44 
       
    45 class CTestSuite ;
       
    46 
       
    47 /**
       
    48  * Global Data used within tests
       
    49  *
       
    50  */
       
    51 _LIT(KDTMFString,"01234, 56789, ABCDEF#*");
       
    52 _LIT(KShortDTMFString,"0");
       
    53 _LIT(KInvalidDTMFString,"XVB4, ?>, !1231\x00ac|");
       
    54 _LIT(KDefault,"C:\\AclntITestData\\xxxxx.xxx"); 
       
    55 
       
    56 
       
    57 #define _LIT8CORRUPTDATA__(name,data) const static TLitPtrC8 name={(sizeof(data) | (1<<5)),REINTERPRET_CAST(const TUint8*,data)}
       
    58 _LIT8CORRUPTDATA__(KCorruptFixedSequenceData,KFixedSequenceTestSequenceData);
       
    59 
       
    60 #define NUMBER_OF_REPEATS 3
       
    61 
       
    62 const TInt KTwelveOfMicroSecond = 83333;
       
    63 const TInt KTenPartOfSec	= 100000 ;
       
    64 const TInt KOneSecond		= 1000000;	// Used in a time out function, 1 second (in microSeconds)#
       
    65 const TInt KTwoSeconds		= KOneSecond*2;
       
    66 const TInt KTenSeconds		= 10000000;	// Used in a time out function, 10 seconds (in microSeconds)
       
    67 const TInt KFiveSeconds		= 5000000;	// 5 seconds (in microSeconds)
       
    68 const TInt KFifteenSeconds	= 15000000;	// 15 seconds (in microSeconds)
       
    69 const TInt KExpectedDeviation= 1500000; // 1.5 second tolerance for timed tests
       
    70 const TInt KNameBufSize		= 25;
       
    71 const TInt KIDBufSize       = 50;
       
    72 const TInt KExpectedDurationDeviation = 3000;	// 3 millisecond tolerance for duration
       
    73 
       
    74 //Amendment (for CTestMmfAclntConPosition)
       
    75 const TInt KDeviation= 1000000; // 1.0 second deviation
       
    76 
       
    77 
       
    78 //const TInt KPcm16FrameInterval = 371424;
       
    79 //const TInt KPcm16FrameInterval = 371512;
       
    80 //const TInt KPcm16FrameInterval = 278639;
       
    81 // frame size is now variable, depending on the sample rate
       
    82 //const TUint KFrameSize8K = 2048;	// frame size for 8Khz
       
    83 const TUint KFrameSize11K = 3072;	// frame size for 11Khz
       
    84 const TUint KPcmBitsPerSample8 = 8;
       
    85 const TUint KPcmChannels = 1;
       
    86 const TUint KSampleRate11K = 11025;
       
    87 const TInt KPcm16FrameInterval = 
       
    88 	(((KFrameSize11K * 1000000 / KSampleRate11K) /
       
    89 	 KPcmBitsPerSample8 * KPcmChannels)
       
    90 	* 8);
       
    91 
       
    92 
       
    93 const TInt KFixedSequenceCount = 6;
       
    94 const TInt KMaxVolume = 65535;
       
    95 
       
    96 const TInt KMaxBalance = 100;
       
    97 const TInt KMinBalance = -100;
       
    98 const TInt KRecSize = 10000;
       
    99 const TInt KToneFrequency = 880;
       
   100 const TInt KToneFrequencyTwo = 1880;
       
   101 const TInt KSoundFileLength = 8359183;
       
   102 const TInt KInvalidNumber =	6234623;
       
   103 
       
   104 //pinched from MmfAudioInput.h:
       
   105 const TUint KAudioInputMinFrameSize = 0x800; //2K
       
   106 const TUint KAudioInputMaxFrameSize = 0x4000; //16K
       
   107 const TUint KAudioInputDeltaFrameSize = 0x400;  //1K
       
   108 const TUint KAudioInputDefaultFrameSize = 0x1000;  //4K
       
   109 const TUint KAudioInputFramesPerSecond = 4;
       
   110 //pinched from gsm610.h:
       
   111 const TUint	KGsmEncodedFrameSize = 65;
       
   112 
       
   113 
       
   114 
       
   115 
       
   116 /**
       
   117  * @ TMmfAclntWavEncodeClipFormat, provides a class to support interfaces that require a 
       
   118  * @ TMdaClipFormat.
       
   119  */
       
   120 const TUid KMmfUidEncodeFormatWAV = {KMmfUidFormatWAVWrite};
       
   121 class TMmfAclntWavEncodeClipFormat : public TMdaClipFormat
       
   122 	{
       
   123 public:
       
   124 	inline TMmfAclntWavEncodeClipFormat();
       
   125 	};
       
   126 inline TMmfAclntWavEncodeClipFormat::TMmfAclntWavEncodeClipFormat() : 
       
   127 TMdaClipFormat(KMmfUidEncodeFormatWAV,sizeof(TMmfAclntWavEncodeClipFormat)) {}
       
   128 
       
   129 /**
       
   130  * @ TMmfAclntWavDecodeClipFormat, provides a class to support interfaces that require a 
       
   131  * @ TMdaClipFormat.
       
   132  */
       
   133 const TUid KMmfUidDecodeFormatWAV = {KMmfUidFormatWAVRead};
       
   134 class TMmfAclntWavDecodeClipFormat : public TMdaClipFormat
       
   135 	{
       
   136 public:
       
   137 	inline TMmfAclntWavDecodeClipFormat();
       
   138 	};
       
   139 inline TMmfAclntWavDecodeClipFormat::TMmfAclntWavDecodeClipFormat() : 
       
   140 TMdaClipFormat(KMmfUidDecodeFormatWAV,sizeof(TMmfAclntWavDecodeClipFormat)) {}
       
   141 
       
   142 
       
   143 /**
       
   144  * @ MCallbackHandlerObserver, provides an Observer
       
   145  * @ for monitoring callbacks.
       
   146  */
       
   147 class MCallbackHandlerObserver
       
   148 	{
       
   149 public:
       
   150 	virtual void MchoComplete(TInt aID, TInt aError)=0;
       
   151 	};
       
   152 
       
   153 /**
       
   154  * CCallbackHandler provides an Observer
       
   155  * for monitoring MMdaAudioPlayerCallback callbacks.
       
   156  *
       
   157  * @ class CPlayerCallbackHandler
       
   158  *
       
   159  */
       
   160 class CPlayerCallbackHandler : public MMdaAudioPlayerCallback
       
   161 	{
       
   162 public:
       
   163 	CPlayerCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver) : iMchObserver(aMchObserver), iID(aID)  {};
       
   164 	TInt ID();	
       
   165 
       
   166 	// from MMdaAudioPlayerCallback
       
   167     virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
       
   168     virtual void MapcPlayComplete(TInt aError);
       
   169 	
       
   170 private:
       
   171 	MCallbackHandlerObserver* iMchObserver;
       
   172 	TInt iID;
       
   173 	};
       
   174 
       
   175 /**
       
   176  * CCallbackHandler provides an Observer for 
       
   177  * monitoring MMdaObjectStateChangeObserver callbacks. 
       
   178  *
       
   179  * @class CStateCallbackHandler
       
   180  *
       
   181  */
       
   182 class CStateCallbackHandler : public MMdaObjectStateChangeObserver
       
   183 	{
       
   184 public:
       
   185 	CStateCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver) : iMchObserver(aMchObserver), iID(aID) {};
       
   186 	TInt ID();	
       
   187 
       
   188 	// from MMdaObjectStateChangeObserver
       
   189 	virtual void MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode);
       
   190 
       
   191 private:
       
   192 	MCallbackHandlerObserver* iMchObserver;
       
   193 	TInt iID;
       
   194 	};
       
   195 
       
   196 
       
   197 /**
       
   198  * provides an Observer for monitoring MMdaAudioToneObserver callbacks.
       
   199  *
       
   200  * @class CToneCallbackHandler
       
   201  *
       
   202  */
       
   203 class CToneCallbackHandler : public MMdaAudioToneObserver
       
   204 	{
       
   205 public:
       
   206 	CToneCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver) : iMchObserver(aMchObserver), iID(aID)  {};
       
   207 	TInt ID();	
       
   208 
       
   209 	// From MMdaAudioToneObserver
       
   210 	virtual void MatoPrepareComplete(TInt aError);
       
   211 	virtual void MatoPlayComplete(TInt aError);
       
   212 
       
   213 private:
       
   214 	MCallbackHandlerObserver* iMchObserver;
       
   215 	TInt iID;
       
   216 	};
       
   217 
       
   218 /**
       
   219  *
       
   220  * CActiveListener provides the asynchronous operation
       
   221  * of an active object
       
   222  *
       
   223  * @class CActiveListener
       
   224  *
       
   225  */
       
   226 class CActiveListener : public CActive
       
   227 	{
       
   228 public:
       
   229 	CActiveListener();
       
   230 	void InitialiseActiveListener();
       
   231 	// From CActive
       
   232 	virtual void RunL();
       
   233 	virtual void DoCancel() {};
       
   234 	};
       
   235 
       
   236 
       
   237 /**
       
   238  * It's a base class for all test steps.
       
   239  *
       
   240  * @class CTestMmfAclntStep 
       
   241  * @brief Test class that enables tests.
       
   242  *
       
   243  */
       
   244 class CTestMmfAclntStep : public CTestStep
       
   245 	{
       
   246 public:
       
   247 	CTestMmfAclntStep();
       
   248 	static void CleanUp(TAny *aPtr) ;
       
   249 	void SetTestSuite(const CTestSuite* aTestSuite );
       
   250 
       
   251 protected:
       
   252 	void WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds);
       
   253 	TBool TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDivation);
       
   254 
       
   255 	// tests may optionally implement pre- and post-ambles
       
   256 	virtual TVerdict DoTestStepPreambleL();
       
   257 	virtual TVerdict DoTestStepPostambleL();
       
   258 
       
   259 protected:
       
   260 	const CTestSuite* iTestSuite ;
       
   261 	CActiveScheduler* iActiveScheduler;
       
   262 	};
       
   263 
       
   264 /**
       
   265  * Test base class that adds codec specific
       
   266  * functionalty (applys to tests that create files).
       
   267  *
       
   268  * @class CTestMmfAclntCodecTest
       
   269  * @codec specific test base class.
       
   270  *
       
   271  */
       
   272 class CTestMmfAclntCodecTest : public CTestMmfAclntStep
       
   273 	{
       
   274 public:
       
   275 	enum TTestFormat
       
   276 		{
       
   277 		ENone,
       
   278 		EPcm16Wav,
       
   279 		EMulawRaw,
       
   280 		E16BitAu,
       
   281 		EAlawAu,
       
   282 		EPcm16Au,
       
   283 		EImaAdpcmWav,
       
   284 		EImasPcmWav,
       
   285 		EPcm8,
       
   286 		EPcmU8,
       
   287 		EPcmU16,
       
   288 		EAlawWav,
       
   289 		EEpocWve,
       
   290 		EGsmWav
       
   291 		};
       
   292 public:
       
   293 	void SetupFormatL(const TTestFormat aFormat);
       
   294 	TVerdict DoTestStepPostambleL();
       
   295 	
       
   296 protected:
       
   297 	TMdaClipFormat* iFormat;
       
   298 	TMdaPackage* iCodec;
       
   299 	TMdaAudioDataSettings iAudioSettings;
       
   300 	TTestFormat iTestFormat;
       
   301 	};
       
   302 
       
   303 
       
   304 TAny	GetDriveName(TDes& aFileName);
       
   305 const TInt	KSizeBuf = 256;
       
   306 
       
   307 
       
   308 #endif// TSI_MMFACLNT_H__
       
   309