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: This file contains the header file of the |
|
15 * RTestServer, RTestModule and RTestExecution. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef TEST_SERVER_CLIENT_H |
|
20 #define TEST_SERVER_CLIENT_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 #include "TestEngineClient.h" |
|
27 #include "StifTestEventInterface.h" |
|
28 #include "StifTFwIfProt.h" |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KDefaultExeName, "testserverstarter.exe" ); |
|
32 _LIT( KDefaultUiExeName, "uitestserverstarter.exe" ); |
|
33 |
|
34 // TestScripter related informations |
|
35 const TInt KTestScripterNameLength = 12; // In STIF are two same name |
|
36 _LIT( KTestScripterName, "testscripter" ); // constants, change both when |
|
37 // needed !!! |
|
38 |
|
39 // TestCombiner related information |
|
40 _LIT( KTestCombinerName, "testcombiner" ); |
|
41 |
|
42 // Test module thread heap and stack sizes |
|
43 const TUint32 KTestThreadMinHeap = 4096; // 4K heap min |
|
44 const TUint32 KTestThreadMaxHeap = 1048576; // 1M heap max |
|
45 const TUint32 KStackSize = 16384; // 16K stack |
|
46 |
|
47 // MACROS |
|
48 |
|
49 // DATA TYPES |
|
50 // Opcodes used in message passing between client and server |
|
51 enum TTestServerRequests |
|
52 { |
|
53 // RTestServer requests |
|
54 ETestServerCloseSession, |
|
55 ETestServerGetServerThreadId, |
|
56 |
|
57 // RTestModule requests |
|
58 ETestModuleCreateSubSession, |
|
59 ETestModuleCloseSubSession, |
|
60 ETestModuleEnumerateTestCases, |
|
61 ETestModuleGetTestCases, |
|
62 ETestModuleCancelAsyncRequest, |
|
63 ETestModuleErrorNotification, |
|
64 |
|
65 // RTestExecution requests |
|
66 ETestExecutionCreateSubSession, |
|
67 ETestExecutionCloseSubSession, |
|
68 ETestExecutionRunTestCase, |
|
69 ETestExecutionPause, |
|
70 ETestExecutionResume, |
|
71 ETestExecutionNotifyProgress, |
|
72 ETestExecutionNotifyData, |
|
73 ETestExecutionCancelAsyncRequest, |
|
74 ETestExecutionNotifyEvent, |
|
75 ETestExecutionNotifyRemoteCmd, |
|
76 ETestExecutionReadRemoteCmdInfo, |
|
77 ETestExecutionNotifyCommand, |
|
78 }; |
|
79 |
|
80 // |
|
81 typedef TPckgBuf<TInt> TCaseSize; |
|
82 |
|
83 // FORWARD DECLARATIONS |
|
84 class CTestThreadContainerRunnerFactory; |
|
85 // FUNCTION PROTOTYPES |
|
86 |
|
87 // Function for starting the TestServer Server. |
|
88 IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, |
|
89 TFileName& aServerName |
|
90 ); |
|
91 |
|
92 // Function for starting the TestServer Server in either in |
|
93 // current thread or in new thread |
|
94 IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, |
|
95 TFileName& aServerName, |
|
96 const TBool aInNewThread, |
|
97 RSemaphore aSynchronisation |
|
98 ); |
|
99 |
|
100 IMPORT_C TInt StartNewServer( const TFileName& aModuleFileName, |
|
101 TFileName& aServerName, |
|
102 const TBool aInNewThread, |
|
103 RSemaphore aSynchronisation, |
|
104 TBool aUiTestingServer, |
|
105 CTestThreadContainerRunnerFactory* aTestThreadContainerRunnerFactory |
|
106 ); |
|
107 |
|
108 // CLASS DECLARATION |
|
109 |
|
110 // DESCRIPTION |
|
111 // RTestServer is a client class of Test Server |
|
112 // The connect function starts the server, if it not already running. |
|
113 // An RSessionBase sends messages to the server with the function |
|
114 // RSessionBase::SendReceive(); |
|
115 // specifying an opcode( TTestServerReq ) and array of argument pointers. |
|
116 |
|
117 class RTestServer |
|
118 :public RSessionBase |
|
119 { |
|
120 public: // Enumerations |
|
121 // None |
|
122 |
|
123 private: // Enumerations |
|
124 // None |
|
125 |
|
126 public: // Constructors and destructor |
|
127 |
|
128 /** |
|
129 * Constructor. |
|
130 */ |
|
131 IMPORT_C RTestServer(); |
|
132 |
|
133 /** |
|
134 * Closes the RTestServer session. |
|
135 */ |
|
136 IMPORT_C void Close(); |
|
137 |
|
138 public: // New functions |
|
139 |
|
140 /** |
|
141 * Connect method creates new RTestServer session that is used to manage |
|
142 * the test case execution. |
|
143 */ |
|
144 IMPORT_C TInt Connect( const TFileName& aModuleName, |
|
145 const TDesC& aConfigFile); |
|
146 |
|
147 /** |
|
148 * Version returns the client side version number from the RTestServer. |
|
149 */ |
|
150 IMPORT_C TVersion Version() const; |
|
151 |
|
152 /** |
|
153 * GetServerThreadId returns the server thread id from the RTestServer. |
|
154 */ |
|
155 IMPORT_C TInt GetServerThreadId( TThreadId& aId ); |
|
156 public: // Functions from base classes |
|
157 // None |
|
158 |
|
159 protected: // New functions |
|
160 // None |
|
161 |
|
162 protected: // Functions from base classes |
|
163 // None |
|
164 |
|
165 private: // Functions from base classes |
|
166 // None |
|
167 |
|
168 /** |
|
169 * Find exe(CapsModifier) from file system |
|
170 */ |
|
171 TInt FindExeL( TFileName aModuleName, TFileName& aPathAndExeModule ); |
|
172 |
|
173 /** |
|
174 * Get caps modifier module name from TestScripter's test case(config) |
|
175 * file. |
|
176 */ |
|
177 TInt GetCapsModifier( const TDesC& aConfigFile, |
|
178 TFileName& aCapsModifierName ); |
|
179 |
|
180 public: // Data |
|
181 // None |
|
182 |
|
183 protected: // Data |
|
184 // None |
|
185 |
|
186 private: // Data |
|
187 // None |
|
188 |
|
189 public: // Friend classes |
|
190 // None |
|
191 |
|
192 protected: // Friend classes |
|
193 // None |
|
194 |
|
195 private: // Friend classes |
|
196 // None |
|
197 |
|
198 }; |
|
199 |
|
200 |
|
201 // DESCRIPTION |
|
202 |
|
203 // RTestModule class represents a subsession with the RTestServer. |
|
204 // Each RTestModule corresponds to a specific CTestModule( a CObject derived |
|
205 // class ) in the server. Messages are passed via the RTestServer. |
|
206 // A RTestModule stores a handle from it's server side CTestModule, and uses |
|
207 // this to identify the CTestModule during communication. |
|
208 |
|
209 class RTestModule |
|
210 :public RSubSessionBase |
|
211 { |
|
212 public: // Enumerations |
|
213 // None |
|
214 |
|
215 private: // Enumerations |
|
216 // None |
|
217 |
|
218 public: // Constructors and destructor |
|
219 // None |
|
220 |
|
221 public: // New functions |
|
222 |
|
223 /** |
|
224 * Open creates a subsession to Test Server and opens handle. |
|
225 * The RTestServer server session shall be created by calling |
|
226 * RTestServer::Connect before calling this function to create new |
|
227 * RTestModule subsession. |
|
228 */ |
|
229 IMPORT_C TInt Open( RTestServer& aServer, TFileName& aIniFile ); |
|
230 |
|
231 /** |
|
232 * Closes the RTestModule subsession. |
|
233 */ |
|
234 IMPORT_C void Close(); |
|
235 |
|
236 /** |
|
237 * EnumerateTestCases requests the needed array size for test cases that |
|
238 * will be inquired by GetTestCases method. The aConfigFile specifies the |
|
239 *( optional ) config file where test cases are defined for this query. |
|
240 * When the EnumerateTestCases is completed succesfully the GetTestCases |
|
241 * method is called to retrieve test cases to |
|
242 * CArrayFixFlat<RTestEngine::TTestInfo> list object. |
|
243 */ |
|
244 IMPORT_C void EnumerateTestCases( TDesC& aConfigFile, |
|
245 TCaseSize& aCount, |
|
246 TRequestStatus& aStatus ); |
|
247 |
|
248 /** |
|
249 * GetTestCases is used to synchronously get test cases from Test Server. |
|
250 * The list of test cases is retrieved to aTestCaseBuffer. Test Engine |
|
251 * allocates needed memory for the test case array by calling |
|
252 * EnumerateTestCases to inquire needed size of aTestCaseBuffer. |
|
253 * |
|
254 * If this method is called without previously succesfully called |
|
255 * EnumerateTestCases the Test Server shall return KErrNotReady. |
|
256 */ |
|
257 IMPORT_C TInt GetTestCases( CFixedFlatArray<TTestCaseInfo>& aTestCaseBuffer ); |
|
258 |
|
259 |
|
260 /** |
|
261 * |
|
262 */ |
|
263 IMPORT_C void ErrorNotification( TErrorNotificationPckg& aError, |
|
264 TRequestStatus& aStatus ); |
|
265 |
|
266 /** |
|
267 * Asynchronous request can be canceled with CancelAsyncRequest method. |
|
268 * The aReqToCancel parameter defines the request that will be canceled. |
|
269 */ |
|
270 IMPORT_C TInt CancelAsyncRequest( TInt aReqToCancel ); |
|
271 |
|
272 public: // Functions from base classes |
|
273 // None |
|
274 |
|
275 protected: // New functions |
|
276 // None |
|
277 |
|
278 protected: // Functions from base classes |
|
279 // None |
|
280 |
|
281 private: // Functions from base classes |
|
282 // None |
|
283 |
|
284 public: // Data |
|
285 // None |
|
286 |
|
287 protected: // Data |
|
288 // None |
|
289 |
|
290 private: // Data |
|
291 // None |
|
292 |
|
293 public: // Friend classes |
|
294 // None |
|
295 |
|
296 protected: // Friend classes |
|
297 // None |
|
298 |
|
299 private: // Friend classes |
|
300 // None |
|
301 |
|
302 }; |
|
303 |
|
304 |
|
305 // DESCRIPTION |
|
306 |
|
307 // RTestExecution class represents a subsession with the RTestServer. |
|
308 // Each RTestExecution corresponds to a specific CTestExecution( a CObject |
|
309 // derived class ) in the server. Messages are passed via the RTestServer. |
|
310 // A RTestExecution stores a handle from it's server side CTestExecution, |
|
311 // and uses this to identify the CTestExecution during communication. |
|
312 |
|
313 class RTestExecution |
|
314 :public RSubSessionBase |
|
315 { |
|
316 public: // Enumerations |
|
317 // None |
|
318 |
|
319 private: // Enumerations |
|
320 // None |
|
321 |
|
322 public: // Constructors and destructor |
|
323 // None |
|
324 |
|
325 public: // New functions |
|
326 |
|
327 /** |
|
328 * Open creates a subsession for new test case. Test case to be executed |
|
329 * is specified by aTestCaseNumber. The aConfig specifies the optional |
|
330 * config file where the test case is defined. Test cases that can be |
|
331 * executed are retrieved from the Test Server by calling two-phased |
|
332 * RTestModule::GetTestCases operation. |
|
333 */ |
|
334 IMPORT_C TInt Open( RTestServer& aServer, |
|
335 const TInt aCaseNumber, |
|
336 const TFileName& aConfig ); |
|
337 |
|
338 /** |
|
339 * Closes the RTestExecution subsession. Test case is normally closed |
|
340 * immediately after the test case was completed. |
|
341 */ |
|
342 IMPORT_C void Close(); |
|
343 |
|
344 /** |
|
345 * RunTestCase is used to execute the test case previously initialized by |
|
346 * Open method. RunTestCase is asynchronous method and it is completed |
|
347 * when the test case is completed. |
|
348 * The result of the test case is returned to aStatus. |
|
349 */ |
|
350 IMPORT_C void RunTestCase( TFullTestResultPckg& aResult, |
|
351 TRequestStatus& aStatus ); |
|
352 |
|
353 /** |
|
354 * RunTestCase is used to execute the test case previously initialized by |
|
355 * Open method. RunTestCase is asynchronous method and it is completed |
|
356 * when the test case is completed. |
|
357 * The result of the test case is returned to aStatus. |
|
358 */ |
|
359 IMPORT_C void RunTestCase( TFullTestResultPckg& aResult, |
|
360 const TDesC& aTestCaseArgs, |
|
361 TRequestStatus& aStatus ); |
|
362 |
|
363 /** |
|
364 * Pause suspends the execution of the test case. The subsession where |
|
365 * the test case is run will be suspended and thus the test case |
|
366 * execution is suspended. The test case execution can be later resumed |
|
367 * by calling Resume. |
|
368 */ |
|
369 IMPORT_C TInt Pause(); |
|
370 |
|
371 /** |
|
372 * Resume is used to resume the test case suspended by previously called |
|
373 * Pause method. The test case execution should be continued immediately |
|
374 * after the Resume is called. |
|
375 */ |
|
376 IMPORT_C TInt Resume(); |
|
377 |
|
378 /** |
|
379 * NotifyProgress requests different progress information from the Test |
|
380 * DLL. This information can be e.g. printed to UI. Progress information |
|
381 * is returned to aProgress. The aProgress is TTestProgressPckg that is |
|
382 * a packaged TTestProgress. |
|
383 */ |
|
384 IMPORT_C TInt NotifyProgress( TTestProgressPckg& aProgress, |
|
385 TRequestStatus& aStatus ); |
|
386 |
|
387 /** |
|
388 * NotifyData is used to receive different data from the Test Server, |
|
389 * e.g. images or web pages which can be then viewed to tester or |
|
390 * forwarded to some kind of comparison tool. |
|
391 */ |
|
392 IMPORT_C TInt NotifyData( TDes8& aData, TRequestStatus& aStatus ); |
|
393 |
|
394 /** |
|
395 * Asynchronous request can be canceled with CancelAsyncRequest method. |
|
396 * The aReqToCancel parameter defines the request that will be canceled. |
|
397 */ |
|
398 IMPORT_C TInt CancelAsyncRequest( TInt aReqToCancel ); |
|
399 |
|
400 /** |
|
401 * NotifyEvent is used to control event system. |
|
402 */ |
|
403 IMPORT_C TInt NotifyEvent( TEventIfPckg& aEvent, |
|
404 TRequestStatus& aStatus, |
|
405 TInt aError=KErrNone ); |
|
406 |
|
407 /** |
|
408 * NotifyRemoteCmd is used to get notify. |
|
409 */ |
|
410 IMPORT_C TInt NotifyRemoteCmd( TStifCommandPckg& aRemoteCommand, |
|
411 TPckg<TInt>& aMsgSizePckg, |
|
412 TRequestStatus& aStatus ); |
|
413 |
|
414 /** |
|
415 * ReadRemoteCmdInfo for remote message. |
|
416 */ |
|
417 IMPORT_C TInt ReadRemoteCmdInfo( TDes8& aRemoteMsg, |
|
418 TStifCommand aType, |
|
419 TInt aError = KErrNone ); |
|
420 |
|
421 /** |
|
422 * NotifyCommand is used to control commands from the test case. |
|
423 * It was created to allow test case to kill itself. DEPRECATED !! |
|
424 * Use NotifyCommand2 instead. |
|
425 */ |
|
426 IMPORT_C TInt NotifyCommand(TCommandPckg& aCommandPckg, |
|
427 TBuf8<KMaxCommandParamsLength>& aParamsPckg, |
|
428 TRequestStatus& aStatus, |
|
429 TInt aError = KErrNone); |
|
430 |
|
431 /** |
|
432 * NotifyCommand is used to control commands from the test case. |
|
433 * It was created to allow test case to kill itself. |
|
434 */ |
|
435 IMPORT_C TInt NotifyCommand2(TCommandPckg& aCommandPckg, |
|
436 TDes8& aParamsPckg, |
|
437 TRequestStatus& aStatus, |
|
438 TInt aError = KErrNone); |
|
439 |
|
440 public: // Functions from base classes |
|
441 // None |
|
442 |
|
443 protected: // New functions |
|
444 // None |
|
445 |
|
446 protected: // Functions from base classes |
|
447 // None |
|
448 |
|
449 private: // Functions from base classes |
|
450 // None |
|
451 |
|
452 public: // Data |
|
453 // None |
|
454 |
|
455 protected: // Data |
|
456 // None |
|
457 |
|
458 private: // Data |
|
459 // None |
|
460 |
|
461 public: // Friend classes |
|
462 // None |
|
463 |
|
464 protected: // Friend classes |
|
465 // None |
|
466 |
|
467 private: // Friend classes |
|
468 // None |
|
469 }; |
|
470 |
|
471 |
|
472 #endif // TEST_SERVER_CLIENT_H |
|
473 |
|
474 // End of File |
|