|
1 // Copyright (c) 2005-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 // A few utils for assisting testing |
|
15 // @internalComponent |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __TESTUTILS_H__ |
|
20 #define __TESTUTILS_H__ |
|
21 |
|
22 #include <e32test.h> |
|
23 |
|
24 #define TEST(arg) Test((arg), __LINE__) |
|
25 #define TESTE(arg, error) Test((arg), (error), __LINE__) |
|
26 |
|
27 const TInt KTestTitleLength = 128; |
|
28 /** |
|
29 CTestWrapper is a simple testing class that wraps RTest. |
|
30 The problem with RTest is that it panics on the first failure. All CTestWrapper does is |
|
31 note failed tests and summerise failures at the end. |
|
32 @internalComponent |
|
33 */ |
|
34 class CTestWrapper: public CBase |
|
35 { |
|
36 private: |
|
37 class TFailedTest |
|
38 { |
|
39 public: |
|
40 TUint iTestNumber; |
|
41 TUint iCheckNumber; |
|
42 }; |
|
43 public: |
|
44 static CTestWrapper* NewLC(RTest& aTester); |
|
45 ~CTestWrapper(); |
|
46 |
|
47 void Start(const TDesC &aHeading); |
|
48 void Next(const TDesC &aHeading); |
|
49 void End(); |
|
50 void Test(TInt aResult, TInt aLineNum); |
|
51 void Test(TInt aResult, TInt aError, TInt aLineNum); |
|
52 |
|
53 void SetFile(const TDesC& aFilename); |
|
54 |
|
55 RTest& Tester(); |
|
56 |
|
57 private: |
|
58 CTestWrapper(RTest& aTester); |
|
59 |
|
60 private: |
|
61 TUint iTestCount; |
|
62 TUint iCheckCount; |
|
63 TUint iTotalCount; |
|
64 RTest& iTester; |
|
65 RArray<TFailedTest> iFailedTests; |
|
66 TFileName iFilename; |
|
67 }; |
|
68 |
|
69 #endif //__TESTUTILS_H__ |