|
1 // Copyright (c) 2000-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 GMXML_TEST_UTILS_H_ |
|
17 #define GMXML_TEST_UTILS_H_ |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <e32test.h> |
|
21 #include <simtsy.h> |
|
22 |
|
23 |
|
24 // Constants |
|
25 |
|
26 //Test Harness Logging |
|
27 |
|
28 #define KLogsDir _L("c:\\logs\\") |
|
29 #define KTestHeader _L("Test Results") |
|
30 #define KTestStartingWithDesc _L("Test %d Starting (%S)") |
|
31 #define KTestPassed _L("Test %d OK") |
|
32 #define KTestFailed _L("Test %d FAILED (error = %d)") |
|
33 #define KTestHarnessCompleted _L("Tests Completed") |
|
34 #define KTestHarnessFailed _L("Tests FAILED (error = %d)") |
|
35 #define KTestCommentPrepend _L(" ") |
|
36 |
|
37 #define KTestShowMenu _L("/manual") |
|
38 |
|
39 |
|
40 // |
|
41 // |
|
42 // CTestTimer |
|
43 // |
|
44 // |
|
45 |
|
46 class CTestTimer : public CTimer |
|
47 { |
|
48 public: |
|
49 static CTestTimer* NewL(); |
|
50 void AfterReq(TTimeIntervalMicroSeconds32 aSec, TRequestStatus& aStatus); |
|
51 protected: |
|
52 CTestTimer(); |
|
53 void RunL(); |
|
54 |
|
55 private: |
|
56 TRequestStatus* iReport; |
|
57 }; |
|
58 |
|
59 // |
|
60 // |
|
61 // CTestUtils |
|
62 // |
|
63 // |
|
64 |
|
65 class CTestUtils : public CBase |
|
66 { |
|
67 public: |
|
68 //File Logging |
|
69 |
|
70 void TestStart(TInt aTest, const TDesC& aTestDescription); |
|
71 void TestFinish(TInt aTest, TInt aError = KErrNone); |
|
72 void TestHarnessCompleted(); |
|
73 void TestHarnessFailed(TInt aError); |
|
74 void WriteComment(const TDesC& aComment); |
|
75 |
|
76 |
|
77 //Test Utils |
|
78 |
|
79 virtual void CreateAllTestDirectories(); |
|
80 |
|
81 // File location |
|
82 |
|
83 |
|
84 TInt ResolveLogFile(const TDesC& aFileName, TParse& aParseOut); |
|
85 |
|
86 void Printf(TRefByValue<const TDesC> aFmt,...); //prints to RTest and LogFile, depending on iLogToConsole and iLogToFile |
|
87 |
|
88 |
|
89 inline RTest& Test() const; |
|
90 |
|
91 TBool RunAuto() const; |
|
92 void SetRunAuto(TBool aRunAuto = ETrue); |
|
93 |
|
94 public: |
|
95 |
|
96 protected: |
|
97 virtual void ConstructL(); |
|
98 CTestUtils(RTest& aRTest); |
|
99 ~CTestUtils(); |
|
100 |
|
101 |
|
102 virtual void Panic(TInt aPanic) = 0; |
|
103 |
|
104 void AppendTestName(TDes &aFileName); |
|
105 void AppendVariantName(TDes& aFileName); |
|
106 |
|
107 TInt OpenMainLogL(); |
|
108 void CloseMainLog(); |
|
109 void WriteToLog(TRefByValue<const TDesC> aFmt,...); |
|
110 |
|
111 |
|
112 |
|
113 protected: |
|
114 |
|
115 RFs iFs; |
|
116 RFile iFile; |
|
117 RTest& iRTest; |
|
118 TBool iLogToConsole; |
|
119 TBool iLogToFile; |
|
120 |
|
121 TBool iRunAuto; |
|
122 HBufC* iLogBuf; |
|
123 HBufC8* iLogBuf8; |
|
124 |
|
125 }; |
|
126 |
|
127 class TTestOverflow : public TDes16Overflow |
|
128 { |
|
129 public: |
|
130 TTestOverflow(CTestUtils& aTest) |
|
131 : iTest(aTest) {}; |
|
132 |
|
133 // TDes16Overflow pure virtual |
|
134 virtual void Overflow(TDes16& /*aDes*/) {iTest.Printf(_L("ERROR: Printf Overflow\n")); iTest.Test()(EFalse);}; |
|
135 |
|
136 private: |
|
137 CTestUtils& iTest; |
|
138 }; |
|
139 |
|
140 |
|
141 |
|
142 #include "GmxmlTestUtils.inl" |
|
143 |
|
144 #endif |