|
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 __GMXMLTESTSETUP_H__ |
|
17 #define __GMXMLTESTSETUP_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "GmxmlTestUtils.h" |
|
21 |
|
22 // The following must be defined by the test exe |
|
23 GLREF_D RTest test; |
|
24 LOCAL_C void doTestsL(); |
|
25 |
|
26 // Globals |
|
27 CTrapCleanup* theCleanup = NULL; |
|
28 |
|
29 TInt TestNum = 0; |
|
30 class CGenericTestUtils; |
|
31 CGenericTestUtils* theUtils = NULL; |
|
32 |
|
33 // Constants |
|
34 |
|
35 // Useful macros |
|
36 TInt theError; |
|
37 |
|
38 |
|
39 //********************************** |
|
40 // CGenericTestUtils |
|
41 //********************************** |
|
42 |
|
43 class CGenericTestUtils : public CTestUtils |
|
44 { |
|
45 public: |
|
46 static CGenericTestUtils* NewL(RTest& aTest); |
|
47 CGenericTestUtils(RTest& aTest); |
|
48 void Panic(TInt aPanic); |
|
49 // |
|
50 public: |
|
51 static void CreateDataFilesL(const TDesC& aFilename, const TDesC& aMtmName, TUid aUid); |
|
52 static TBool WaitForKeyL(TTimeIntervalMicroSeconds32 aDelay, TKeyCode* aKeyCode = NULL); |
|
53 static void Start(const TDesC& aDes); |
|
54 static void Next(const TDesC& aDes); |
|
55 static void Complete(); |
|
56 static void End(); |
|
57 }; |
|
58 |
|
59 CGenericTestUtils* CGenericTestUtils::NewL(RTest& aTest) |
|
60 { |
|
61 CGenericTestUtils* self = new(ELeave)CGenericTestUtils(aTest); |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(); // self |
|
65 return self; |
|
66 } |
|
67 |
|
68 CGenericTestUtils::CGenericTestUtils(RTest& aTest) |
|
69 : CTestUtils(aTest) |
|
70 { |
|
71 } |
|
72 |
|
73 void CGenericTestUtils::Panic(TInt) |
|
74 { |
|
75 test(EFalse); |
|
76 } |
|
77 |
|
78 void CGenericTestUtils::Start(const TDesC& aDes) |
|
79 { |
|
80 test.Start(aDes); |
|
81 theUtils->TestStart(++TestNum, aDes); |
|
82 } |
|
83 |
|
84 void CGenericTestUtils::Next(const TDesC& aDes) |
|
85 { |
|
86 test.Next(aDes); |
|
87 theUtils->TestStart(++TestNum, aDes); |
|
88 } |
|
89 |
|
90 void CGenericTestUtils::Complete() |
|
91 { |
|
92 theUtils->TestFinish(TestNum, KErrNone); |
|
93 } |
|
94 |
|
95 void CGenericTestUtils::End() |
|
96 { |
|
97 test.End(); |
|
98 } |
|
99 |
|
100 //********************************** |
|
101 // Global |
|
102 //********************************** |
|
103 |
|
104 LOCAL_C void SetupL() |
|
105 { |
|
106 // CActiveScheduler::Install(theScheduler = new(ELeave)CTestScheduler); |
|
107 |
|
108 // Create test class |
|
109 theUtils = CGenericTestUtils::NewL(test); |
|
110 |
|
111 // test.Printf(_L("Cleaning Message Folder\n")); |
|
112 // CGenericTestUtils::CleanMessageFolderL(); |
|
113 // CGenericTestUtils::SetDriveL(EDriveC); |
|
114 // CGenericTestUtils::SetDebugL(ETrue); |
|
115 |
|
116 } |
|
117 |
|
118 LOCAL_C void Close(TInt aRet) |
|
119 { |
|
120 if (theUtils) |
|
121 { |
|
122 if (!aRet) |
|
123 theUtils->TestHarnessCompleted(); |
|
124 else |
|
125 theUtils->TestHarnessFailed(aRet); |
|
126 } |
|
127 delete theUtils; |
|
128 } |
|
129 |
|
130 LOCAL_C void doMainL() |
|
131 { |
|
132 SetupL(); |
|
133 doTestsL(); |
|
134 } |
|
135 |
|
136 GLDEF_C TInt E32Main() |
|
137 { |
|
138 __UHEAP_MARK; |
|
139 theCleanup=CTrapCleanup::New(); |
|
140 TRAPD(ret,doMainL()); |
|
141 Close(ret); |
|
142 delete theCleanup; |
|
143 test.Console()->SetPos(0, 13); |
|
144 test.End(); |
|
145 test.Close(); |
|
146 __UHEAP_MARKEND; |
|
147 return(KErrNone); |
|
148 } |
|
149 |
|
150 #endif |