First public contribution.
1 // Copyright (c) 2001-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__IPUTESTUTILS_H__)
17 #define __IPUTESTUTILS_H__
29 const TUid KUidIpuTestUtils = {0x10005188};
30 const TInt KMaxUserEntrySize = 50;
32 //Test Harness Logging
34 #define KLogsDir _L("c:\\logs\\testexecute\\")
35 #define KInuLogsDirName _L("InetProtUtil")
37 #define KTestHeader _L("Test Results")
38 #define KTestStarting _L("Test %d Starting")
39 #define KTestStartingWithDesc _L("Test %d Starting (%S)")
40 #define KNextTestStepWithDesc _L("Test %d Step %d (%S)")
41 #define KTestPassed _L("Test %d OK")
42 #define KTestFailed _L("Test %d FAILED (error = %d)")
43 #define KTestHarnessCompleted _L("Tests Completed Ok")
44 #define KTestHarnessFailed _L("Test FAILED (%d failed test(s))")
45 #define KTestFailInfo _L("Test %d : %S failed with Error %d")
46 #define KTestCommentPrepend _L("\t")
48 class CIpuTestHarness : public CBase
50 // Test harness providing logging features
60 IMPORT_C static CIpuTestHarness* NewLC(const TDesC& aTitle);
61 IMPORT_C static CIpuTestHarness* NewL(const TDesC& aTitle);
64 IMPORT_C void StartTestL(const TDesC& aName);
65 IMPORT_C void NextStep(const TDesC& aStepName);
66 IMPORT_C void EndTest(TInt aErrorCode);
67 IMPORT_C void LogIt(TRefByValue<const TDesC> aFmt, ...);
68 IMPORT_C void operator()(TInt aResult,TInt aLineNum);
69 IMPORT_C void operator()(TInt aResult);
70 IMPORT_C void PressAnyKey();
71 IMPORT_C void DumpData(HBufC8& aData, TBool logIt = EFalse);
72 IMPORT_C void GetAnEntry(const TDesC & ourPrompt, TDes & currentstring);
73 IMPORT_C TInt GetSelection(const TDesC& ourPrompt, const TDesC& validChoices);
74 IMPORT_C void SetScript(RFile& scriptFile);
75 inline void DoResourceLeakTest(TBool aValue);
77 inline void SetTestMode(TTestMode aTestMode);
79 inline static void DefaultLogFileName(TDes& aFileName);
81 CIpuTestHarness(const TDesC& aTitle);
82 void ConstructL(const TDesC& aTitle);
83 void Panic(TInt aPanic);
84 void TestHarnessFailed();
85 void TestHarnessComplete();
86 void ResourceLeakTest();
87 inline void CreateFlogger(const TDesC& aFileName, TInt aShowDate=ETrue, TInt aShowTime=ETrue);
88 inline void WriteComment(const TDesC& aComment);
89 TInt ReadLineFromScript(TDes& aBuffer);
92 // Helper class to store failed tests
102 RFileLogger iFlogger;
105 CArrayPtrFlat<CTestInfo>* iFailedTests;
109 TInt iStartHandleCount;
110 TBool iDoResourceLeakTest;
111 TBool iScriptRunning;
115 class CIpuTestHarness::CTestInfo : public CBase
117 // Holds test number and name
120 static CTestInfo* NewLC(const TDesC& aName, TInt aNumber, TInt aErrorCode);
121 static CTestInfo* NewL(const TDesC& aName, TInt aNumber, TInt aErrorCode);
124 void SetNameL(const TDesC& aName);
125 void SetNumber(TInt aNumber);
126 void SetErrorCode(TInt aErrorCode);
128 inline TPtr Name() const;
129 inline TInt Number() const;
130 inline TInt ErrorCode() const;
133 void ConstructL(const TDesC& aName, TInt aNumber, TInt aErrorCode);
140 #include "IpuTestUtils.inl"
142 #endif // __IPUTESTUTILS_H__