|
1 // Copyright (c) 1997-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 // This file contains the definition of the class CTestController |
|
15 // This file comment is for DOxygen only and is ignored by EDoc. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @test |
|
21 */ |
|
22 |
|
23 #ifndef __TESTCONTROLLER_H__ |
|
24 #define __TESTCONTROLLER_H__ |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32test.h> |
|
28 |
|
29 #include <ecom/test_bed/componentinfo.h> |
|
30 #include <ecom/test_bed/testmanager.h> |
|
31 #include <ecom/test_bed/transitionobserver.h> |
|
32 #include <ecom/test_bed/transition.h> |
|
33 #include <ecom/test_bed/managerobserver.h> |
|
34 |
|
35 class CComponentTester; |
|
36 class CDataLogger; |
|
37 |
|
38 // Global function typedef declaration of function provided by a test module of the component |
|
39 // under test and is used as an entry point to kick start test bed. Provided as argument to CTestController. |
|
40 typedef CComponentTester* (*ComponentTesterInitialiserLC)(CDataLogger&, MComponentTestObserver&); |
|
41 |
|
42 /** |
|
43 @internalAll |
|
44 Comments : Manages the whole test procedure. |
|
45 */ |
|
46 |
|
47 class CTestController : public CBase, private MManagerObserver |
|
48 { |
|
49 public: |
|
50 /** |
|
51 @fn static IMPORT_C CTestController* NewL(CActiveScheduler* aScheduler, |
|
52 ComponentTesterInitialiserLC aEntryPoint, |
|
53 RTest* aRTest = NULL, |
|
54 TLoggingInfo* aLogInfo = NULL) |
|
55 Intended Usage : Standardized safe construction which leaves nothing on the cleanup stack. |
|
56 @leave KErrNoMemory. |
|
57 @since 7.0 |
|
58 @param aScheduler The active scheduler to use, pass NULL if no scheduler exists |
|
59 @param aEntryPoint The global function used to create the derived CComponentTester object. |
|
60 @param aRTest Optional RTest object to use in check unit test results |
|
61 @param aLogInfo The logging info to use, defaults to NULL |
|
62 @return CTestController* A pointer to the newly created class. |
|
63 @pre None |
|
64 @post Nothing is on the CleanupStack |
|
65 */ |
|
66 |
|
67 static IMPORT_C CTestController* NewL(CActiveScheduler* aScheduler, |
|
68 ComponentTesterInitialiserLC aEntryPoint, |
|
69 RTest* aRTest = NULL, |
|
70 TLoggingInfo* aLogInfo = NULL); |
|
71 |
|
72 /** |
|
73 @fn static IMPORT_C CTestController* NewLC(CActiveScheduler* aScheduler, |
|
74 ComponentTesterInitialiserLC aEntryPoint, |
|
75 RTest* aRTest = NULL, |
|
76 TLoggingInfo* aLogInfo = NULL) |
|
77 Intended Usage : Standardized safe construction which leaves CTestController* on the cleanup stack. |
|
78 @leave KErrNoMemory. |
|
79 @since 7.0 |
|
80 @param aScheduler The active scheduler, if one exists, otherwise NULL |
|
81 @param aEntryPoint The global function used to create the derived CComponentTester object. |
|
82 @param aRTest Optional RTest object to use in check unit test results |
|
83 @param aLogInfo The logging configuration information |
|
84 @return CTestController* A pointer to the newly created class. |
|
85 @pre None |
|
86 @post CTestController is on the CleanupStack |
|
87 */ |
|
88 |
|
89 static IMPORT_C CTestController* NewLC(CActiveScheduler* aScheduler, |
|
90 ComponentTesterInitialiserLC aEntryPoint, |
|
91 RTest* aRTest = NULL, |
|
92 TLoggingInfo* aLogInfo = NULL); |
|
93 |
|
94 /** |
|
95 @fn ~CTestController() |
|
96 Intended Usage : Standardized virtual destruction method |
|
97 @since 7.0 |
|
98 */ |
|
99 |
|
100 virtual IMPORT_C ~CTestController(); |
|
101 |
|
102 /** |
|
103 @fn Start() |
|
104 Intended Usage : Starts the testbed and runs all tests on all components. This |
|
105 function runs synchronously and does not return until all tests |
|
106 are complete. |
|
107 @since 7.0 |
|
108 @pre This object is constructed |
|
109 @post Starts the active scheduler and therefore doesn't complete until the |
|
110 active scheduler is stopped. |
|
111 */ |
|
112 IMPORT_C void Start(); |
|
113 |
|
114 /** |
|
115 @fn Start(RPointerArray<TTestInfo>* aTests) |
|
116 Intended Usage : Starts the specified tests.This function runs |
|
117 synchronously and does not return until all tests are complete. |
|
118 @since 7.0 |
|
119 @param aTests The list of tests to be run. |
|
120 @pre This object is constructed |
|
121 @post Starts the active scheduler and therefore doesn't complete until the |
|
122 active scheduler is stopped. |
|
123 */ |
|
124 |
|
125 IMPORT_C void Start(RPointerArray<TTestInfo>* aTests); |
|
126 |
|
127 /** |
|
128 @fn Start(TRequestStatus* aStatus) |
|
129 Intended Usage : Starts the testbed and runs all tests on all components. This |
|
130 function runs asynchronously and completes aStatus when all tests |
|
131 are complete. |
|
132 @since 7.0 |
|
133 @param aStatus Status word for the calling function. Is completed when all |
|
134 tests are complete. |
|
135 @pre This object is constructed |
|
136 @post An asynchronous request is issued to run all tests. |
|
137 */ |
|
138 IMPORT_C void Start(TRequestStatus* aStatus); |
|
139 |
|
140 /** |
|
141 @fn Start(TRequestStatus* aStatus, RPointerArray<TTestInfo>* aTests) |
|
142 Intended Usage : Starts the specified tests. If the default for aTest is used |
|
143 then all tests are run on all components. This function runs |
|
144 asynchronously and completes aStatus when all tests are complete. |
|
145 @since 7.0 |
|
146 @param aStatus Status word for the calling function. Is completed when all |
|
147 tests are complete. |
|
148 @param aTests The list of tests to be run. |
|
149 @pre This object is constructed. |
|
150 @post An asynchronous request is issued to run the specified tests. |
|
151 */ |
|
152 IMPORT_C void Start(TRequestStatus* aStatus, RPointerArray<TTestInfo>* aTests); |
|
153 |
|
154 /** |
|
155 @fn RPointerArray<CComponentInfo>& FindComponents() const |
|
156 Intended Usage : Returns an array of the components available for testing |
|
157 Error Condition : |
|
158 @since 7.0 |
|
159 @return RPointerArray<CComponentInfo>& Information on the components which |
|
160 are available for testing. |
|
161 @pre The object is fully constructed |
|
162 @post Returns an array of the available components which can be used to select |
|
163 which test to run. |
|
164 */ |
|
165 |
|
166 IMPORT_C const RPointerArray<CComponentInfo>& FindComponents() const; |
|
167 |
|
168 /** |
|
169 @fn IMPORT_C CDataLogger& DataLogger() |
|
170 Intended Usage : Returns a reference to the file logging functionality for use |
|
171 by the user interface component. |
|
172 @since 7.0 |
|
173 @return CDataLogger& The current data logger to allow external logging |
|
174 @pre The CTestController has been created so that the data logger exists |
|
175 @post Unspecified |
|
176 */ |
|
177 |
|
178 static IMPORT_C CDataLogger& DataLogger(); |
|
179 |
|
180 /** |
|
181 @fn Cancel() |
|
182 Intended Usage : Cancels any outstanding tests. |
|
183 @since 7.0 |
|
184 @pre This object has been created and the asynchronous version of |
|
185 Start has been called. |
|
186 @post Any outstanding tests have been cancelled. |
|
187 */ |
|
188 IMPORT_C void Cancel(); |
|
189 |
|
190 friend class TTestController_StateAccessor; |
|
191 |
|
192 private: |
|
193 /** |
|
194 @fn CTestController(CActiveScheduler* aScheduler) |
|
195 Intended Usage : Constructor |
|
196 @since 7.0 |
|
197 @param aScheduler The existing active scheduler or NULL |
|
198 @param aRTest Optional RTest object to use in check unit test results |
|
199 */ |
|
200 |
|
201 CTestController(CActiveScheduler* aScheduler, RTest* aRTest = NULL); |
|
202 |
|
203 /** |
|
204 @fn void ConstructL(TLoggingInfo* aLogInfo, ComponentTesterInitialiserLC aEntryPoint) |
|
205 Intended Usage : Completes the safe construction of the CTestController object |
|
206 @leave KErrNoMemory. |
|
207 @since 7.0 |
|
208 @param aLogInfo The logging configuration information |
|
209 @param aEntryPoint The global function used to create the derived CComponentTester object. |
|
210 @pre First phase of construction is complete |
|
211 @post Object is fully constructed |
|
212 */ |
|
213 |
|
214 void ConstructL(TLoggingInfo* aLogInfo, ComponentTesterInitialiserLC aEntryPoint); |
|
215 |
|
216 /** |
|
217 @fn void InitialiseComponentTesterL(ComponentTesterInitialiserLC aEntryPointLC) |
|
218 @leave KErrNoMemory. |
|
219 Intended Usage : Called during construction to find all test modules |
|
220 Error Condition : |
|
221 @since 7.0 |
|
222 @param aEntryPointLC The global function used to create the derived CComponentTester object. |
|
223 @pre None |
|
224 @post A list of all tests is available |
|
225 */ |
|
226 void InitialiseComponentTesterL(ComponentTesterInitialiserLC aEntryPointLC); |
|
227 |
|
228 /** |
|
229 @fn TestsComplete() |
|
230 Intended Usage : Called by the CTestManager to indicate that all tests |
|
231 are complete. Either stops the active scheduler if in |
|
232 synchronous mode or completes the client if in async mode. |
|
233 @since 7.0 |
|
234 @pre This object is constructed |
|
235 @post Appropriate action is taken to complete the tests. |
|
236 */ |
|
237 void TestsComplete(); |
|
238 |
|
239 private: |
|
240 /** Starts the tests and stops the active scheduler when finished*/ |
|
241 |
|
242 CTestManager* iTestManager; |
|
243 /** A list of the available tests*/ |
|
244 |
|
245 RPointerArray<CComponentInfo> iTestList; |
|
246 /** Placeholder for an active scheduler if one is passed in on creation */ |
|
247 |
|
248 CActiveScheduler* iScheduler; |
|
249 /** Flag indicating if we own the active scheduler in iScheduler */ |
|
250 |
|
251 TBool iOwnScheduler; |
|
252 /** Provides the file logging capability */ |
|
253 |
|
254 CDataLogger* iDataLogger; |
|
255 /** The status word of the client (if tests were run asynchronously). Will be completed |
|
256 when all tests have finished running. */ |
|
257 TRequestStatus* iClientStatus; |
|
258 /** Optional reference to the RTest object used in the EXE test harness code which |
|
259 kicked off this test framework */ |
|
260 RTest* iRTest; |
|
261 }; // End of CTestController definition |
|
262 |
|
263 |
|
264 #endif // _INC_TESTCONTROLLER_3A34E468034A_INCLUDED |