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