author | Johnson Ma <johnson.ma@nokia.com> |
Mon, 29 Mar 2010 14:46:27 +0800 | |
changeset 1 | bbd31066657e |
parent 0 | 3e07fef1e154 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
#ifndef SYMBIANUNITTEST_H |
|
18 |
#define SYMBIANUNITTEST_H |
|
19 |
||
20 |
// INCLUDES |
|
21 |
#include <symbianunittestinterface.h> |
|
22 |
#include <symbianunittestmacros.h> |
|
23 |
#include <e32base.h> |
|
24 |
||
25 |
// FORWARD DECLARATIONS |
|
26 |
class CSymbianUnitTestResult; |
|
27 |
||
28 |
// CLASS DECLARATION |
|
29 |
/** |
|
30 |
* The base class for unit test classes. |
|
31 |
* The classes inheriting from this class should call |
|
32 |
* CSymbianUnitTest::ConstructL from their ConstructL. |
|
33 |
* Although the functions implemented in this class |
|
34 |
* for unit test assertions and adding test cases |
|
35 |
* can be called directly from the subclasses, |
|
36 |
* the macros defined in symbianunittestmacros.h should be used instead. |
|
37 |
* |
|
38 |
* @lib symbianunittestfw.lib |
|
39 |
*/ |
|
40 |
class CSymbianUnitTest : public CBase, public MSymbianUnitTestInterface |
|
41 |
{ |
|
42 |
public: // Typedefs |
|
43 |
||
44 |
typedef void ( CSymbianUnitTest::*FunctionPtr )(); |
|
45 |
||
46 |
public: // Destructor |
|
47 |
||
48 |
/** |
|
49 |
* Destructor |
|
50 |
*/ |
|
51 |
IMPORT_C ~CSymbianUnitTest(); |
|
52 |
||
53 |
public: // From MSymbianUnitTestInterface |
|
54 |
||
55 |
/** |
|
56 |
* Function called by the framework to execute |
|
57 |
* the unit tests in the subclass. |
|
58 |
* There is no need to call this function directly |
|
59 |
* from the unit test classes. |
|
60 |
* |
|
61 |
* @param aObserver an observer for the test progress |
|
62 |
* @param aResult the test result |
|
63 |
* @param aFailureSimulation the type of failure simulation to be used |
|
64 |
* @param aTestCaseNames the test cases to run |
|
65 |
* @param aTimeout the time out value for test execution |
|
66 |
*/ |
|
67 |
IMPORT_C void ExecuteL( |
|
68 |
MSymbianUnitTestObserver& aObserver, |
|
69 |
CSymbianUnitTestResult& aResult, |
|
70 |
MSymbianUnitTestInterface::TFailureSimulation aFailureSimulation, |
|
71 |
const CDesCArray& aTestCaseNamesi, |
|
72 |
TInt aTimeout ); |
|
73 |
||
74 |
/** |
|
75 |
* Returns the number of unit test cases contained in this object. |
|
76 |
* @return The number of unit test cases in this object |
|
77 |
*/ |
|
78 |
IMPORT_C TInt TestCaseCount(); |
|
79 |
||
80 |
/** |
|
81 |
* @return The name of this unit test class |
|
82 |
*/ |
|
83 |
IMPORT_C const TDesC& Name() const; |
|
84 |
||
85 |
||
86 |
protected: // Constructors |
|
87 |
||
88 |
/** |
|
89 |
* Constructor |
|
90 |
*/ |
|
91 |
IMPORT_C CSymbianUnitTest(); |
|
92 |
||
93 |
/** |
|
94 |
* This function should be called |
|
95 |
* from the ConstructL of the subclass |
|
96 |
* |
|
97 |
* @param aName the name of the unit test class |
|
98 |
*/ |
|
99 |
IMPORT_C void ConstructL( const TDesC8& aName ); |
|
100 |
||
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
101 |
public: // New functions |
0 | 102 |
|
103 |
/** |
|
104 |
* This function should be overidden in the actual unit test classes. |
|
105 |
* It is the default setup function that gets executed |
|
106 |
* by the framework before each unit test case. |
|
107 |
*/ |
|
108 |
IMPORT_C virtual void SetupL(); |
|
109 |
||
110 |
/** |
|
111 |
* This function should be overidden in the actual unit test classes. |
|
112 |
* It is the default teardown function that gets executed |
|
113 |
* by the framework after each unit test case. |
|
114 |
*/ |
|
115 |
IMPORT_C virtual void Teardown(); |
|
116 |
||
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
117 |
protected: // New functions |
0 | 118 |
/** |
119 |
* Checks whteher the test case is being run using memory |
|
120 |
* allocation failure simulation. |
|
121 |
* @return ETrue if the test case is being run using memory |
|
122 |
* allocation failure simulation, EFalse if not |
|
123 |
*/ |
|
124 |
IMPORT_C TBool IsMemoryAllocationFailureSimulationUsed() const; |
|
125 |
||
126 |
/** |
|
127 |
* Adds a new unit test case to this unit test. |
|
128 |
* Use macro ADD_SYMBIAN_UT in symbianunittestmacros.h |
|
129 |
* instead to avoid the need to pass |
|
130 |
* the name of the unit test case as a parameter. |
|
131 |
* |
|
132 |
* @param aName the name of the unit test case |
|
133 |
* @param aSetupFunction a function pointer to the setup function |
|
134 |
* that will be executed before the actual unit test case |
|
135 |
* @param aTestFunction a function pointer to the unit test case |
|
136 |
* @param aTeardownFunction a function pointer to the teardown function |
|
137 |
* that will be executed after the actual unit test case |
|
138 |
*/ |
|
139 |
IMPORT_C void AddTestCaseL( |
|
140 |
const TDesC& aName, |
|
141 |
CSymbianUnitTest::FunctionPtr aSetupFunction, |
|
142 |
CSymbianUnitTest::FunctionPtr aTestFunction, |
|
143 |
CSymbianUnitTest::FunctionPtr aTeardownFunction ); |
|
144 |
||
145 |
/** |
|
146 |
* Asserts that two TInt values are equal. |
|
147 |
* Leaves with a Symbian unit test framework specific error code |
|
148 |
* if the values are not equal. |
|
149 |
* In case of a failed assertion, the framework records |
|
150 |
* the failure reason, line number and file name to the test results. |
|
151 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
|
152 |
* instead to avoid the need to pass the other parameters |
|
153 |
* than the actual asserted values. |
|
154 |
* |
|
155 |
* @param aExpectedValue the expected value |
|
156 |
* @param aActualValue the actual value |
|
157 |
* @param aLineNumber the line number of the assertion |
|
158 |
* @param aFileName the name of the file where the assertion is located |
|
159 |
*/ |
|
160 |
IMPORT_C void AssertEqualsL( |
|
161 |
TInt aExpectedValue, |
|
162 |
TInt aActualValue, |
|
163 |
TInt aLineNumber, |
|
164 |
const TDesC8& aFileName ); |
|
165 |
||
166 |
/** |
|
167 |
* Asserts that two TDesC8 values are equal. |
|
168 |
* Leaves with a Symbian unit test framework specific error code |
|
169 |
* if the values are not equal. |
|
170 |
* In case of a failed assertion, the framework records |
|
171 |
* the failure reason, line number and file name to the test results. |
|
172 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
|
173 |
* instead to avoid the need to pass the other parameters |
|
174 |
* than the actual asserted values. |
|
175 |
* |
|
176 |
* @param aExpectedValue the expected value |
|
177 |
* @param aActualValue the actual value |
|
178 |
* @param aLineNumber the line number of the assertion |
|
179 |
* @param aFileName the name of the file where the assertion is located |
|
180 |
*/ |
|
181 |
IMPORT_C void AssertEqualsL( |
|
182 |
const TDesC8& aExpectedValue, |
|
183 |
const TDesC8& aActualValue, |
|
184 |
TInt aLineNumber, |
|
185 |
const TDesC8& aFileName ); |
|
186 |
||
187 |
/** |
|
188 |
* Asserts that two TDesC16 values are equal. |
|
189 |
* Leaves with a Symbian unit test framework specific error code |
|
190 |
* if the values are not equal. |
|
191 |
* In case of a failed assertion, the framework records |
|
192 |
* the failure reason, line number and file name to the test results. |
|
193 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
|
194 |
* instead to avoid the need to pass the other parameters |
|
195 |
* than the actual asserted values. |
|
196 |
* |
|
197 |
* @param aExpectedValue the expected value |
|
198 |
* @param aActualValue the actual value |
|
199 |
* @param aLineNumber the line number of the assertion |
|
200 |
* @param aFileName the name of the file where the assertion is located |
|
201 |
*/ |
|
202 |
IMPORT_C void AssertEqualsL( |
|
203 |
const TDesC16& aExpectedValue, |
|
204 |
const TDesC16& aActualValue, |
|
205 |
TInt aLineNumber, |
|
206 |
const TDesC8& aFileName ); |
|
207 |
||
208 |
/** |
|
209 |
* Asserts that a statement leaves an expected value. |
|
210 |
* Leaves with a Symbian unit test framework specific error code |
|
211 |
* if the leave code is not the expected one. |
|
212 |
* In case of a failed assertion, the framework records |
|
213 |
* the failure reason, line number and file name to the test results. |
|
214 |
* Use macro SYMBIAN_UT_ASSERT_LEAVE in symbianunittestmacros.h |
|
215 |
* instead to avoid the need to pass the other parameters |
|
216 |
* than the actual statement that is checked for the leave. |
|
217 |
* |
|
218 |
* @param aStatement textual presentation of the statement |
|
219 |
* @param aActualLeaveCode the actual leave code from the statement |
|
220 |
* @param aExpectedLeaveCode the expected leave code |
|
221 |
* @param aLineNumber the line number of the assertion |
|
222 |
* @param aFileName the name of the file where the assertion is located |
|
223 |
*/ |
|
224 |
IMPORT_C void AssertLeaveL( |
|
225 |
const TDesC8& aStatement, |
|
226 |
TInt aActualLeaveCode, |
|
227 |
TInt aExpectedLeaveCode, |
|
228 |
TInt aLineNumber, |
|
229 |
const TDesC8& aFileName ); |
|
230 |
||
231 |
/** |
|
232 |
* Records a failed assertion to the test results and |
|
233 |
* leaves with a Symbian unit test framework specific error code |
|
234 |
* to quit the execution of the test function. |
|
235 |
* Use macro SYMBIAN_UT_ASSERT in symbianunittestmacros.h |
|
236 |
* to perform the actual assertion. |
|
237 |
* |
|
238 |
* @param aFailureMessage the failed assertion as text |
|
239 |
* @param aLineNumber the line number of the assertion |
|
240 |
* @param aFileName the name of the file where the assertion is located |
|
241 |
*/ |
|
242 |
IMPORT_C void AssertionFailedL( |
|
243 |
const TDesC8& aFailureMessage, |
|
244 |
TInt aLineNumber, |
|
245 |
const TDesC8& aFileName ); |
|
246 |
||
247 |
/** |
|
248 |
* Records a non-leaving statement to the test results and |
|
249 |
* leaves with a Symbian unit test framework specific error code |
|
250 |
* to quit the execution of the test function. |
|
251 |
* This function is called from macro SYMBIAN_UT_ASSERT_LEAVE |
|
252 |
* in symbianunittestmacros.h to record the result of a failed assertion. |
|
253 |
* There is usually no need to call this function directly. |
|
254 |
* |
|
255 |
* @param aStatement textual presentation of the statement |
|
256 |
* @param aLineNumber the line number of the assertion |
|
257 |
* @param aFileName the name of the file where the assertion is located |
|
258 |
*/ |
|
259 |
IMPORT_C void RecordNoLeaveFromStatementL( |
|
260 |
const TDesC8& aStatement, |
|
261 |
TInt aLineNumber, |
|
262 |
const TDesC8& aFileName ); |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
263 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
264 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
265 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
266 |
/** |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
267 |
* Asserts that two TInt values are equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
268 |
* Leaves with a Symbian unit test framework specific error code |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
269 |
* if the values are not equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
270 |
* In case of a failed assertion, the framework records |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
271 |
* the failure reason, line number and file name to the test results. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
272 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
273 |
* instead to avoid the need to pass the other parameters |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
274 |
* than the actual asserted values. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
275 |
* |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
276 |
* @param aExpectedValue the expected value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
277 |
* @param aActualValue the actual value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
278 |
* @param aLineNumber the line number of the assertion |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
279 |
* @param aFileName the name of the file where the assertion is located |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
280 |
* @param aFailureMessage the error message |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
281 |
*/ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
282 |
IMPORT_C void AssertEqualsL( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
283 |
TInt aExpectedValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
284 |
TInt aActualValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
285 |
TInt aLineNumber, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
286 |
const TDesC8& aFileName, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
287 |
const TDesC8& aFailureMessage ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
288 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
289 |
/** |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
290 |
* Asserts that two TDesC8 values are equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
291 |
* Leaves with a Symbian unit test framework specific error code |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
292 |
* if the values are not equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
293 |
* In case of a failed assertion, the framework records |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
294 |
* the failure reason, line number and file name to the test results. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
295 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
296 |
* instead to avoid the need to pass the other parameters |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
297 |
* than the actual asserted values. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
298 |
* |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
299 |
* @param aExpectedValue the expected value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
300 |
* @param aActualValue the actual value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
301 |
* @param aLineNumber the line number of the assertion |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
302 |
* @param aFileName the name of the file where the assertion is located |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
303 |
* @param aFailureMessage the error message |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
304 |
*/ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
305 |
IMPORT_C void AssertEqualsL( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
306 |
const TDesC8& aExpectedValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
307 |
const TDesC8& aActualValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
308 |
TInt aLineNumber, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
309 |
const TDesC8& aFileName, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
310 |
const TDesC8& aFailureMessage ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
311 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
312 |
/** |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
313 |
* Asserts that two TDesC16 values are equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
314 |
* Leaves with a Symbian unit test framework specific error code |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
315 |
* if the values are not equal. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
316 |
* In case of a failed assertion, the framework records |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
317 |
* the failure reason, line number and file name to the test results. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
318 |
* Use macro SYMBIAN_UT_ASSERT_EQUALS in symbianunittestmacros.h |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
319 |
* instead to avoid the need to pass the other parameters |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
320 |
* than the actual asserted values. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
321 |
* |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
322 |
* @param aExpectedValue the expected value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
323 |
* @param aActualValue the actual value |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
324 |
* @param aLineNumber the line number of the assertion |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
325 |
* @param aFileName the name of the file where the assertion is located |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
326 |
* @param aFailureMessage the error message |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
327 |
*/ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
328 |
IMPORT_C void AssertEqualsL( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
329 |
const TDesC16& aExpectedValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
330 |
const TDesC16& aActualValue, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
331 |
TInt aLineNumber, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
332 |
const TDesC8& aFileName, |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
333 |
const TDesC8& aFailureMessage ); |
0 | 334 |
|
335 |
private: // Internal class for a unit test function's data |
|
336 |
||
337 |
class CSymbianUnitTestCase : public CBase |
|
338 |
{ |
|
339 |
public: // Constructors and destructor |
|
340 |
||
341 |
static CSymbianUnitTestCase* NewL( |
|
342 |
const TDesC& aName, |
|
343 |
CSymbianUnitTest::FunctionPtr aSetupFunction, |
|
344 |
CSymbianUnitTest::FunctionPtr aTestFunction, |
|
345 |
CSymbianUnitTest::FunctionPtr aTeardownFunction ); |
|
346 |
||
347 |
~CSymbianUnitTestCase(); |
|
348 |
||
349 |
public: // New functions |
|
350 |
||
351 |
const TDesC& Name() const; |
|
352 |
||
353 |
public: // Data |
|
354 |
||
355 |
CSymbianUnitTest::FunctionPtr iSetupFunction; |
|
356 |
CSymbianUnitTest::FunctionPtr iTestFunction; |
|
357 |
CSymbianUnitTest::FunctionPtr iTeardownFunction; |
|
358 |
||
359 |
private: // Constructors |
|
360 |
||
361 |
CSymbianUnitTestCase( |
|
362 |
CSymbianUnitTest::FunctionPtr aSetupFunction, |
|
363 |
CSymbianUnitTest::FunctionPtr aTestFunction, |
|
364 |
CSymbianUnitTest::FunctionPtr aTeardownFunction ); |
|
365 |
void ConstructL( const TDesC& aName ); |
|
366 |
||
367 |
private: // Data |
|
368 |
||
369 |
HBufC* iName; |
|
370 |
}; |
|
371 |
||
372 |
private: // New functions |
|
373 |
||
374 |
HBufC8* NotEqualsMessageLC( const TDesC16& aExpected, |
|
375 |
const TDesC16& aActual ); |
|
376 |
||
377 |
void ExecuteTestCaseInThreadL( |
|
378 |
CSymbianUnitTestCase& aTestCase, |
|
379 |
CSymbianUnitTestResult& aResult, |
|
380 |
TInt aTimeout); |
|
381 |
||
382 |
static TInt TestThreadEntryFunction( TAny* aPtr ); |
|
383 |
||
384 |
void ExecuteTestCaseL(); |
|
385 |
||
386 |
void DoExecuteTestCaseL( TInt& aLeaveCodeFromTest ); |
|
387 |
||
388 |
void StartAllocFailureSimulation(); |
|
389 |
||
390 |
void StopAllocFailureSimulation(); |
|
391 |
||
392 |
static TInt TimerThreadEntryFunction( TAny* aPtr); |
|
393 |
||
394 |
private: // Data |
|
395 |
||
396 |
HBufC* iName; |
|
397 |
RHeap::TAllocFail iAllocFailureType; |
|
398 |
TUint iAllocFailureRate; |
|
399 |
TInt iLeakedMemory; |
|
400 |
TInt iHeapCellsReservedByAssertFailure; |
|
401 |
RPointerArray< CSymbianUnitTestCase > iTestCases; |
|
402 |
CSymbianUnitTestResult* iTestResult; // Not owned |
|
403 |
CSymbianUnitTestCase* iCurrentTestCase; // Not owned |
|
404 |
||
405 |
private: // Test |
|
406 |
||
407 |
SYMBIAN_UNIT_TEST_CLASS( UT_CSymbianUnitTest ) |
|
408 |
}; |
|
409 |
||
410 |
#endif // SYMBIANUNITTEST_H |