xml/wbxmlparser/test/rtest/tsrc/stabilitytestclass.h
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __STABILITYTESTCLASS_H__
       
    17 #define __STABILITYTESTCLASS_H__
       
    18 
       
    19 #include <f32file.h>
       
    20 
       
    21 #include <xml/contenthandler.h>
       
    22 #include <xml/parser.h>
       
    23 #include <xml/stringdictionarycollection.h>
       
    24 #include <xml/wbxmlextensionhandler.h>
       
    25 
       
    26 class RTest;
       
    27 
       
    28 struct TPassOrFailureSettings {
       
    29 	TInt			iParseMode;
       
    30 	const TDesC8*	iStringDictionaryUri;
       
    31 	TBool			iDoParseDocument;
       
    32 	TBool			iFilenameProvided;
       
    33 	TInt			iExpectedCode;
       
    34 	
       
    35 };
       
    36 
       
    37 
       
    38 #define BUFFER_SIZE  2000             // buffer to build strings. per element
       
    39 #define XBUFFER_SIZE BUFFER_SIZE+1000 // additional size increase
       
    40 #define OUTPUT_SIZE  16000            // concatenate BUFFER strings
       
    41 
       
    42 
       
    43 class CStabilityTestClass : public CBase, public Xml::MWbxmlExtensionHandler, public Xml::MContentHandler
       
    44 /**
       
    45 This class provides common usage between stability tests.
       
    46 Keeping code to a minimum and reuse high.
       
    47 
       
    48 */
       
    49 	{
       
    50 public:
       
    51 
       
    52 	static CStabilityTestClass* NewL(RTest& aTest, 
       
    53 									 TBool aIsOomTest = EFalse, 
       
    54 									 TInt aChunkSize = 0);
       
    55 
       
    56 	virtual ~CStabilityTestClass();
       
    57 
       
    58 	typedef void (CStabilityTestClass::*ClassFuncPtrL) (const TDesC&);
       
    59 	typedef void (CStabilityTestClass::*ClassFuncPtr2L) (CStabilityTestClass::ClassFuncPtrL);
       
    60 
       
    61 	void StabilityTestL(const TDesC& aAbsoluteDirPath, 
       
    62 						const TDesC& aExt, 
       
    63 						ClassFuncPtrL aTestFuncL);
       
    64 
       
    65 	void ParseDirL(const TDesC& aAbsoluteDirPath, const TDesC& aExt, 
       
    66 				   ClassFuncPtrL aTestFuncL);
       
    67 
       
    68 	void ParseEntryL(const TDesC& aAbsoluteFilename,
       
    69 					 ClassFuncPtrL aTestFuncL);
       
    70 									  
       
    71 	void OomProcess(ClassFuncPtrL aTestFuncL);
       
    72 	
       
    73 	void TestWholeL(const TDesC& aFileName);
       
    74 	void TestChunkL(const TDesC& aFileName);
       
    75 
       
    76 	void TestBehaviour(const TDesC& aSrc, TPassOrFailureSettings& aTestSettings);
       
    77 	void BehaviourTestL(const TDesC& aSrc, TPassOrFailureSettings& aTestSettings);
       
    78 
       
    79 	// From MContentHandler
       
    80 
       
    81 	void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
       
    82 	void OnEndDocumentL(TInt aErrorCode);
       
    83 	void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
       
    84 	void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
       
    85 	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
    86 	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
       
    87 	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
    88 	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
    89 	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
    90 	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
       
    91 	TAny* GetExtendedInterface(const TInt32 aUid);
       
    92 	
       
    93 	void OnError(TInt aErrorCode);
       
    94 
       
    95 
       
    96 	// From MWbxmlExtensionHandler
       
    97 
       
    98 	void OnExtensionL(const RString& aData, TInt aToken, TInt aErrorCode);
       
    99 
       
   100 
       
   101 public:
       
   102 
       
   103 #ifdef __COMPARE_OUTPUT__
       
   104 	TBuf16<OUTPUT_SIZE> *iOutput;
       
   105 #endif // __COMPARE_OUTPUT__
       
   106 
       
   107 protected:
       
   108 
       
   109 	CStabilityTestClass(RTest& aTest, TBool aIsOomTest = EFalse, TInt aChunkSize = 0);
       
   110 
       
   111 	void ConstructL();
       
   112 
       
   113 protected:
       
   114 
       
   115 	Xml::RStringDictionaryCollection iStringDictionaryCollection;
       
   116 	Xml::CParser* iParser;
       
   117 	TInt						iError;
       
   118 	TInt						iParseMode;
       
   119 	TParse						iFileName;
       
   120 	RFs							iFs;
       
   121 	RTest&						iTest;
       
   122 	TInt						iChunkSize;
       
   123 	TBool						iIsOomTest;
       
   124 	RArray<TInt>				iCurrentIndex;
       
   125 	RPointerArray<CDir>			iEntries;
       
   126 
       
   127 	TBuf16<BUFFER_SIZE>	*		iBuffer;
       
   128 
       
   129 #ifdef __SHOW_MANUAL_OUTPUT__
       
   130 	TBuf16<XBUFFER_SIZE> *		iFormat;
       
   131 #endif // __SHOW_MANUAL_OUTPUT__
       
   132 	};
       
   133 
       
   134 #endif // __STABILITYTESTCLASS_H__