sl@0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#if !defined(__IPUTESTUTILS_H__)
|
sl@0
|
17 |
#define __IPUTESTUTILS_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
// System includes
|
sl@0
|
21 |
//
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
#include <e32test.h>
|
sl@0
|
24 |
#include <f32file.h>
|
sl@0
|
25 |
#include <flogger.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
// Constants
|
sl@0
|
29 |
const TUid KUidIpuTestUtils = {0x10005188};
|
sl@0
|
30 |
const TInt KMaxUserEntrySize = 50;
|
sl@0
|
31 |
|
sl@0
|
32 |
//Test Harness Logging
|
sl@0
|
33 |
|
sl@0
|
34 |
#define KLogsDir _L("c:\\logs\\testexecute\\")
|
sl@0
|
35 |
#define KInuLogsDirName _L("InetProtUtil")
|
sl@0
|
36 |
|
sl@0
|
37 |
#define KTestHeader _L("Test Results")
|
sl@0
|
38 |
#define KTestStarting _L("Test %d Starting")
|
sl@0
|
39 |
#define KTestStartingWithDesc _L("Test %d Starting (%S)")
|
sl@0
|
40 |
#define KNextTestStepWithDesc _L("Test %d Step %d (%S)")
|
sl@0
|
41 |
#define KTestPassed _L("Test %d OK")
|
sl@0
|
42 |
#define KTestFailed _L("Test %d FAILED (error = %d)")
|
sl@0
|
43 |
#define KTestHarnessCompleted _L("Tests Completed Ok")
|
sl@0
|
44 |
#define KTestHarnessFailed _L("Test FAILED (%d failed test(s))")
|
sl@0
|
45 |
#define KTestFailInfo _L("Test %d : %S failed with Error %d")
|
sl@0
|
46 |
#define KTestCommentPrepend _L("\t")
|
sl@0
|
47 |
|
sl@0
|
48 |
class CIpuTestHarness : public CBase
|
sl@0
|
49 |
//
|
sl@0
|
50 |
// Test harness providing logging features
|
sl@0
|
51 |
{
|
sl@0
|
52 |
public:
|
sl@0
|
53 |
|
sl@0
|
54 |
enum TTestMode
|
sl@0
|
55 |
{
|
sl@0
|
56 |
ETestModeNormal,
|
sl@0
|
57 |
ETestModeMemoryLeak
|
sl@0
|
58 |
};
|
sl@0
|
59 |
|
sl@0
|
60 |
IMPORT_C static CIpuTestHarness* NewLC(const TDesC& aTitle);
|
sl@0
|
61 |
IMPORT_C static CIpuTestHarness* NewL(const TDesC& aTitle);
|
sl@0
|
62 |
~CIpuTestHarness();
|
sl@0
|
63 |
|
sl@0
|
64 |
IMPORT_C void StartTestL(const TDesC& aName);
|
sl@0
|
65 |
IMPORT_C void NextStep(const TDesC& aStepName);
|
sl@0
|
66 |
IMPORT_C void EndTest(TInt aErrorCode);
|
sl@0
|
67 |
IMPORT_C void LogIt(TRefByValue<const TDesC> aFmt, ...);
|
sl@0
|
68 |
IMPORT_C void operator()(TInt aResult,TInt aLineNum);
|
sl@0
|
69 |
IMPORT_C void operator()(TInt aResult);
|
sl@0
|
70 |
IMPORT_C void PressAnyKey();
|
sl@0
|
71 |
IMPORT_C void DumpData(HBufC8& aData, TBool logIt = EFalse);
|
sl@0
|
72 |
IMPORT_C void GetAnEntry(const TDesC & ourPrompt, TDes & currentstring);
|
sl@0
|
73 |
IMPORT_C TInt GetSelection(const TDesC& ourPrompt, const TDesC& validChoices);
|
sl@0
|
74 |
IMPORT_C void SetScript(RFile& scriptFile);
|
sl@0
|
75 |
inline void DoResourceLeakTest(TBool aValue);
|
sl@0
|
76 |
inline RTest& Test();
|
sl@0
|
77 |
inline void SetTestMode(TTestMode aTestMode);
|
sl@0
|
78 |
|
sl@0
|
79 |
inline static void DefaultLogFileName(TDes& aFileName);
|
sl@0
|
80 |
private:
|
sl@0
|
81 |
CIpuTestHarness(const TDesC& aTitle);
|
sl@0
|
82 |
void ConstructL(const TDesC& aTitle);
|
sl@0
|
83 |
void Panic(TInt aPanic);
|
sl@0
|
84 |
void TestHarnessFailed();
|
sl@0
|
85 |
void TestHarnessComplete();
|
sl@0
|
86 |
void ResourceLeakTest();
|
sl@0
|
87 |
inline void CreateFlogger(const TDesC& aFileName, TInt aShowDate=ETrue, TInt aShowTime=ETrue);
|
sl@0
|
88 |
inline void WriteComment(const TDesC& aComment);
|
sl@0
|
89 |
TInt ReadLineFromScript(TDes& aBuffer);
|
sl@0
|
90 |
|
sl@0
|
91 |
private:
|
sl@0
|
92 |
// Helper class to store failed tests
|
sl@0
|
93 |
class CTestInfo;
|
sl@0
|
94 |
enum TPanicCode
|
sl@0
|
95 |
{
|
sl@0
|
96 |
EBadStartTest,
|
sl@0
|
97 |
EBadEndTest,
|
sl@0
|
98 |
EBadCLogPtr
|
sl@0
|
99 |
};
|
sl@0
|
100 |
private:
|
sl@0
|
101 |
RTest iTest;
|
sl@0
|
102 |
RFileLogger iFlogger;
|
sl@0
|
103 |
RFile* iScriptFile;
|
sl@0
|
104 |
TInt iTestCount;
|
sl@0
|
105 |
CArrayPtrFlat<CTestInfo>* iFailedTests;
|
sl@0
|
106 |
TTime iStartTime;
|
sl@0
|
107 |
TBool iCanStartTest;
|
sl@0
|
108 |
TInt iStepNumber;
|
sl@0
|
109 |
TInt iStartHandleCount;
|
sl@0
|
110 |
TBool iDoResourceLeakTest;
|
sl@0
|
111 |
TBool iScriptRunning;
|
sl@0
|
112 |
TTestMode iTestMode;
|
sl@0
|
113 |
};
|
sl@0
|
114 |
|
sl@0
|
115 |
class CIpuTestHarness::CTestInfo : public CBase
|
sl@0
|
116 |
//
|
sl@0
|
117 |
// Holds test number and name
|
sl@0
|
118 |
{
|
sl@0
|
119 |
public:
|
sl@0
|
120 |
static CTestInfo* NewLC(const TDesC& aName, TInt aNumber, TInt aErrorCode);
|
sl@0
|
121 |
static CTestInfo* NewL(const TDesC& aName, TInt aNumber, TInt aErrorCode);
|
sl@0
|
122 |
~CTestInfo();
|
sl@0
|
123 |
|
sl@0
|
124 |
void SetNameL(const TDesC& aName);
|
sl@0
|
125 |
void SetNumber(TInt aNumber);
|
sl@0
|
126 |
void SetErrorCode(TInt aErrorCode);
|
sl@0
|
127 |
|
sl@0
|
128 |
inline TPtr Name() const;
|
sl@0
|
129 |
inline TInt Number() const;
|
sl@0
|
130 |
inline TInt ErrorCode() const;
|
sl@0
|
131 |
private:
|
sl@0
|
132 |
CTestInfo();
|
sl@0
|
133 |
void ConstructL(const TDesC& aName, TInt aNumber, TInt aErrorCode);
|
sl@0
|
134 |
private:
|
sl@0
|
135 |
HBufC* iName;
|
sl@0
|
136 |
TInt iNumber;
|
sl@0
|
137 |
TInt iErrorCode;
|
sl@0
|
138 |
};
|
sl@0
|
139 |
|
sl@0
|
140 |
#include "IpuTestUtils.inl"
|
sl@0
|
141 |
|
sl@0
|
142 |
#endif // __IPUTESTUTILS_H__
|