sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef __T_TESTHANDLER_H__
|
sl@0
|
20 |
#define __T_TESTHANDLER_H__
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
#include <f32file.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
class MTestSpec;
|
sl@0
|
26 |
class Output;
|
sl@0
|
27 |
class CTestHandlerSettings;
|
sl@0
|
28 |
class CTestSetup;
|
sl@0
|
29 |
class CTestAction;
|
sl@0
|
30 |
class CTestRunner;
|
sl@0
|
31 |
|
sl@0
|
32 |
class TTestSummary
|
sl@0
|
33 |
{
|
sl@0
|
34 |
public:
|
sl@0
|
35 |
TTestSummary();
|
sl@0
|
36 |
TBool AllTestsPassed();
|
sl@0
|
37 |
void PrintL(Output& aOut);
|
sl@0
|
38 |
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
TInt iTestsRun;
|
sl@0
|
41 |
TInt iTestsFailed;
|
sl@0
|
42 |
};
|
sl@0
|
43 |
|
sl@0
|
44 |
/**
|
sl@0
|
45 |
* CTestHandler is the class which runs the tests, and outputs results
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
class CTestHandler : public CBase
|
sl@0
|
48 |
{
|
sl@0
|
49 |
public:
|
sl@0
|
50 |
/*
|
sl@0
|
51 |
* MTestSpec is the interface class, providing GetNextTest
|
sl@0
|
52 |
* TTestHandlerSettings provides the command line switches
|
sl@0
|
53 |
*
|
sl@0
|
54 |
*
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
|
sl@0
|
57 |
IMPORT_C static CTestHandler* NewLC(RFs& aFs, MTestSpec& aTestSpec,
|
sl@0
|
58 |
CTestHandlerSettings& aSettings,
|
sl@0
|
59 |
CConsoleBase* aConsole,
|
sl@0
|
60 |
Output* aOut);
|
sl@0
|
61 |
~CTestHandler();
|
sl@0
|
62 |
|
sl@0
|
63 |
private:
|
sl@0
|
64 |
CTestHandler(RFs& aFs, MTestSpec& aTestSpec, CConsoleBase* aConsole,
|
sl@0
|
65 |
Output* aOut);
|
sl@0
|
66 |
void ConstructL(CTestHandlerSettings& aSettings);
|
sl@0
|
67 |
|
sl@0
|
68 |
public:
|
sl@0
|
69 |
// API for test programs
|
sl@0
|
70 |
|
sl@0
|
71 |
/// Run the test sequence
|
sl@0
|
72 |
IMPORT_C void RunTestsL();
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* Set the test runner to use. This object takes ownership. Passing NULL
|
sl@0
|
76 |
* means use the default test runner.
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
IMPORT_C void SetTestRunnerL(CTestRunner *aTestRunner);
|
sl@0
|
79 |
|
sl@0
|
80 |
public:
|
sl@0
|
81 |
// API for test actions
|
sl@0
|
82 |
|
sl@0
|
83 |
/// Access to shared data
|
sl@0
|
84 |
CBase* SharedData() const;
|
sl@0
|
85 |
void SetSharedData(CBase* aData);
|
sl@0
|
86 |
|
sl@0
|
87 |
/// Set the heap mark
|
sl@0
|
88 |
void SetHeapMark(TInt aAllocCount);
|
sl@0
|
89 |
|
sl@0
|
90 |
/// Get the heap mark
|
sl@0
|
91 |
TInt HeapMark();
|
sl@0
|
92 |
|
sl@0
|
93 |
/// Get the count of tests run/failed
|
sl@0
|
94 |
TTestSummary Summary();
|
sl@0
|
95 |
|
sl@0
|
96 |
private:
|
sl@0
|
97 |
/// The different possible locations a test can fail in.
|
sl@0
|
98 |
enum TTestFailLocation
|
sl@0
|
99 |
{
|
sl@0
|
100 |
EFailInTestHandler,
|
sl@0
|
101 |
EFailInPrerequisite,
|
sl@0
|
102 |
EFailInAction
|
sl@0
|
103 |
};
|
sl@0
|
104 |
|
sl@0
|
105 |
/// Get the human readable name for a fail location
|
sl@0
|
106 |
const TDesC& GetFailLocationName(TTestFailLocation aLoc);
|
sl@0
|
107 |
|
sl@0
|
108 |
private:
|
sl@0
|
109 |
/**
|
sl@0
|
110 |
* Run one test. Called repeatedly by RunTestsL().
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
void RunTestL(CTestAction* aAction);
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* Record a test failure.
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
void FailTestL(CTestAction* aAction, TTestFailLocation aLoc, TInt aErr);
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
* Add a test to the list of failed tests.
|
sl@0
|
119 |
*/
|
sl@0
|
120 |
void AppendFailedTestL(TInt aIndex, const TDesC8& aName);
|
sl@0
|
121 |
|
sl@0
|
122 |
private:
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
* This function prints the number of tests passed, failed, etc at the end of
|
sl@0
|
125 |
* the test series.
|
sl@0
|
126 |
*/
|
sl@0
|
127 |
void DisplaySummary();
|
sl@0
|
128 |
|
sl@0
|
129 |
private:
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
* Used by the test handler itself and the iManager
|
sl@0
|
132 |
*/
|
sl@0
|
133 |
RFs& iFs;
|
sl@0
|
134 |
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
* The settings that define the behaviour of the handler.
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
CTestHandlerSettings *iSettings;
|
sl@0
|
139 |
|
sl@0
|
140 |
CConsoleBase* iConsole;
|
sl@0
|
141 |
Output* iOut;
|
sl@0
|
142 |
|
sl@0
|
143 |
CTestSetup* iTestSetup;
|
sl@0
|
144 |
CActiveScheduler* iScheduler;
|
sl@0
|
145 |
|
sl@0
|
146 |
MTestSpec& iTestSpec;
|
sl@0
|
147 |
|
sl@0
|
148 |
TInt iActionNumber;
|
sl@0
|
149 |
TInt iActionCount;
|
sl@0
|
150 |
|
sl@0
|
151 |
/**
|
sl@0
|
152 |
* After completion of the series of tests, this array contains the numbers of
|
sl@0
|
153 |
* the failed tests.
|
sl@0
|
154 |
*/
|
sl@0
|
155 |
RArray<TInt> iFailedTests;
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
* After completion of the series of tests, this array contains the names of
|
sl@0
|
158 |
* the failed tests.
|
sl@0
|
159 |
*/
|
sl@0
|
160 |
RPointerArray<HBufC> iFailedTestNames;
|
sl@0
|
161 |
/**
|
sl@0
|
162 |
* After completion of the series of tests, this array contains the names
|
sl@0
|
163 |
* of tests that failed because of known defects */
|
sl@0
|
164 |
|
sl@0
|
165 |
RPointerArray<HBufC> iKnownDefects;
|
sl@0
|
166 |
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
* Pointer to shared data. This is initially NULL. It can be accessed by
|
sl@0
|
169 |
* any of the test actions. If it is not NULL when this class is destroyed,
|
sl@0
|
170 |
* it is deleted.
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
CBase* iSharedData;
|
sl@0
|
173 |
|
sl@0
|
174 |
/// Pointer to the current test runner. We own this.
|
sl@0
|
175 |
CTestRunner* iTestRunner;
|
sl@0
|
176 |
|
sl@0
|
177 |
/// Pointer to the test runner to install when we've finished the current
|
sl@0
|
178 |
/// test. We own this.
|
sl@0
|
179 |
CTestRunner* iNextTestRunner;
|
sl@0
|
180 |
|
sl@0
|
181 |
/// The heap mark, used by heap mark actions
|
sl@0
|
182 |
TInt iHeapMark;
|
sl@0
|
183 |
};
|
sl@0
|
184 |
|
sl@0
|
185 |
#endif
|