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