1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/AFMT/TSU_MMF_AFMT.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,229 @@
1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __TSU_MMF_AFMT_H__
1.20 +#define __TSU_MMF_AFMT_H__
1.21 +
1.22 +#include <testframework.h>
1.23 +#include <mmf/server/mmfbuffer.h>
1.24 +#include <mmf/server/mmfdatabuffer.h>
1.25 +#include <mmf/common/mmfutilities.h>
1.26 +#include <mmf/common/mmffourcc.h>
1.27 +#include <mmf/server/mmfdatasink.h>
1.28 +
1.29 +// Forward declaration
1.30 +class MMFTestDataSink;
1.31 +
1.32 +class CTestSuite ;
1.33 +class CTestSuite_MMF_AFMT;
1.34 +
1.35 +class MDataSource;
1.36 +class CMMFFormatDecode;
1.37 +class CMMFFormatEncode;
1.38 +
1.39 +// Constants
1.40 +const TUint KFormatDefaultFrameSize = 0x1000;
1.41 +const TUint KGSMAvgBytesPerSecond = 1625;
1.42 +const TInt KOneSecondInMicroSeconds(1000000);
1.43 +
1.44 +
1.45 +// NOTE: With the test files for audio formats, we have to use PCM only, as
1.46 +// any other compression type appears to require a whole 'chain' of codecs etc
1.47 +// to initialise correctly. This would be better done in System testing.
1.48 +#ifdef __WINS__
1.49 + #include "Tsu_mmf_afmt_WINS.h"
1.50 +#else
1.51 + // ARM build - if flag below set we use C drive for files
1.52 + #ifdef __AFMT_USE_C_DRIVE__
1.53 + #include "Tsu_mmf_afmt_WINS.h"
1.54 + #else
1.55 + #include "Tsu_mmf_afmt_ARM4.h"
1.56 + #endif // __AFMT_USE_C_DRIVE__
1.57 +#endif
1.58 +
1.59 +
1.60 +// Other constants
1.61 +const TInt KStartFrame = 1; // The first frame in a file.
1.62 +
1.63 +
1.64 +
1.65 +enum ENewLType {KNewLUndefined, // Default value (leave if we get this).
1.66 + KNewLUid, // Call NewL with a UID
1.67 + KNewLFilename, // Call NewL with a filename
1.68 + KNewLDescriptor,// Call NewL with a Descriptor of data
1.69 + KNewLClip // Call NewL passing in a CMMFClip
1.70 + };
1.71 +
1.72 +/** @xxxx
1.73 + * @class CTestStep_MMF_AFMT TSU_MMF_AFMT.h "TSU_MMF_AFMT.h"
1.74 + * @brief Test class that enables MMF Audio Format tests.
1.75 + * It's a base class for all test steps.
1.76 + */
1.77 +class CTestStep_MMF_AFMT : public CTestStep, public MAsyncEventHandler
1.78 + {
1.79 +public: // Constructor/Destructor
1.80 + CTestStep_MMF_AFMT() : iData(0,0,0) {};
1.81 + virtual ~CTestStep_MMF_AFMT();
1.82 + virtual void Close();
1.83 +
1.84 +public: // From CTestStep
1.85 + void SetTestSuite(const CTestSuite_MMF_AFMT* aTestSuite )
1.86 + { iAFMTTestSuite = aTestSuite;}
1.87 +
1.88 +public: // New functions
1.89 + virtual void BufferEmptiedCallback(CMMFBuffer* /*aBuffer*/){}
1.90 + virtual void BufferFilledCallback(CMMFBuffer* /*aBuffer*/){}
1.91 +
1.92 +
1.93 +protected: // New functions
1.94 +
1.95 + /**
1.96 + * This function creates a datasource object based on either a descriptor
1.97 + * or a file.
1.98 + * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based.
1.99 + * @param aFilename - If filebased, this is the file name passed to the DataSource
1.100 + * If descriptor based, the data is read from the file.
1.101 + * @param aOffset - The offset from the start of the file to read (for Descriptor
1.102 + * based DataSources only)
1.103 + */
1.104 + void CreateDataSource(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
1.105 +
1.106 +
1.107 + /**
1.108 + * This function creates a data sink object from a CMmfFile object.
1.109 + * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based [NOTE
1.110 + * use of CMmfDescriptor based sinks is currently not supported]
1.111 + * @param aFilename - If filebased, this is the file name passed to the DataSource
1.112 + * If descriptor based, the data is read from the file.
1.113 + * @param aOffset - The offset from the start of the file to read (for Descriptor
1.114 + * based DataSources only)
1.115 + */
1.116 + void CreateDataSink(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
1.117 +
1.118 +
1.119 + /**
1.120 + * This function creates a Format object (type of which is specified by 'aUid') and
1.121 + * a data source or data sink to go with the object. This function should be used
1.122 + * as a quick way for setting up objects for testing.
1.123 + * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using
1.124 + * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not
1.125 + * yet been added to this test harness for SINKs. Generally it's best to just use
1.126 + * CMmfFile based data sources rather than descriptors.
1.127 + * @param aFilename - The file which acts as the data sink. For a CMmfFile
1.128 + * based object, this is the file that data gets written to.
1.129 + * @param aUid - The UID of the format object to be created.
1.130 + */
1.131 + void CreateObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
1.132 +
1.133 +
1.134 + /**
1.135 + * This function is used as a quick way to setup objects for testing.
1.136 + * @param aFilename - The file which acts as the data sink. For a CMmfFile
1.137 + * based object, this is the file that data gets read/written.
1.138 + * @param aUid - The UID of the format object to be created.
1.139 + * @return TVerdict - Will always return EPass unless it leaves.
1.140 + */
1.141 + TVerdict SetupL(const TDesC& aFilename, TInt aUid);
1.142 +
1.143 +
1.144 + /**
1.145 + * This function deletes all of the pointer member variables which may have been
1.146 + * initialised.
1.147 + */
1.148 + void Cleanup();
1.149 +
1.150 +
1.151 + /**
1.152 + * This function reads from a source file into the member variable heap buffer, 'iDescHBuf'.
1.153 + * This can be used to compare the contents of a file with a buffer for example.
1.154 + * @param aFilename - The file to read from.
1.155 + * @param aPosition - Where to start reading from in the file.
1.156 + * @param aSize - How much of the file to read (in bytes) though if you pass '-1', it will
1.157 + * try and read the whole file from 'aPosition' onwards.
1.158 + */
1.159 + void ReadFileToDescriptorL(const TDesC& aFilename, TInt aPosition, TInt aSize);
1.160 +
1.161 +
1.162 + /**
1.163 + * This function can be used to make sure that a specified file is not present
1.164 + * before a set of tests are run.
1.165 + * @param aFilename - The name of the file to delete/check is not present.
1.166 + */
1.167 + void DeleteFileL(const TDesC& aFilename);
1.168 +
1.169 +
1.170 +private: // New functions
1.171 + /**
1.172 + * This function creates a datasource object based on either a descriptor
1.173 + * or a file.
1.174 + * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using
1.175 + * CMmfDescriptor as the DataSource
1.176 + * @param aFilename - The file which acts as the data source. For a CMmfFile
1.177 + * based object, this IS the file. For a CMmfDescriptor based object, this
1.178 + * file contains the data that is read into the descriptor for test purposes.
1.179 + * @param aUid - The UID of the format object to be created.
1.180 + */
1.181 + void CreateDecodeObjectL(TBool aBool, const TDesC& aFilename, TInt aUid);
1.182 +
1.183 +
1.184 + /**
1.185 + * This function creates a datasink object based on either a descriptor
1.186 + * or a file.
1.187 + * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using
1.188 + * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not
1.189 + * yet been added to this test harness for SINKs.
1.190 + * @param aFilename - The file which acts as the data sink. For a CMmfFile
1.191 + * based object, this IS the file.
1.192 + * @param aUid - The UID of the format object to be created.
1.193 + */
1.194 + void CreateEncodeObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
1.195 +
1.196 + //from MAsyncEventHandler
1.197 + virtual TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;}//XXX - can we do better here?
1.198 +
1.199 +
1.200 +protected:
1.201 + TBool iDecode; // ETrue if using CMmfXXXFormatRead/MDataSource
1.202 + // EFalse if using CMmfXXXFormatWrite/MDataSink
1.203 +
1.204 + const CTestSuite_MMF_AFMT* iAFMTTestSuite; // pointer to suite which owns this test
1.205 +
1.206 + MDataSource* iDataSource; // Ptr to a DataSource
1.207 + MDataSink* iDataSink; // Ptr to a DataSource
1.208 +
1.209 + CMMFFormatDecode* iFormatDec; // Ptr to a Format Decode object
1.210 + CMMFFormatEncode* iFormatEnc; // Ptr to a Format Encode object
1.211 +
1.212 + TUid iUID; // UID object
1.213 + TPtrC iFilename; // Filename
1.214 + TPtrC iPreferredSupplier; // Preferred supplier string
1.215 +//PAC TPtrC8 iData; // Used to hold binary data.
1.216 + TPtr8 iData; // Used to hold binary data.
1.217 + ENewLType iNewL; // Which NewL call to use when create Format object
1.218 +
1.219 + HBufC8* iDescHBuf; // HBuf for holding descriptor data
1.220 +
1.221 +private:
1.222 + };
1.223 +
1.224 +
1.225 +
1.226 +
1.227 +
1.228 +
1.229 +
1.230 +
1.231 +#endif// TSU_MMF_AFMT_H__
1.232 +