1 /** |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TMSERVERTEST_H |
|
20 #define TMSERVERTEST_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "StifTestModule.h" |
|
24 #include "testtimer.h" |
|
25 #include "discoverytesttimer.h" |
|
26 |
|
27 #include <StifLogger.h> |
|
28 #include <NormalHardcodedAssert.h> |
|
29 #include <upnptmserver.h> |
|
30 #include <upnptmserverdeviceinfo.h> |
|
31 #include <upnpcontrolpoint.h> |
|
32 #include <upnpremotableapp.h> |
|
33 #include <upnpterminalmodeicon.h> |
|
34 #include <terminalmodeconsts.h> |
|
35 #include <upnptmserverobserver.h> |
|
36 |
|
37 // MACROS |
|
38 #define TEST_MODULE_VERSION_MAJOR 0 |
|
39 #define TEST_MODULE_VERSION_MINOR 0 |
|
40 #define TEST_MODULE_VERSION_BUILD 0 |
|
41 |
|
42 // Logging path |
|
43 _LIT( KTmServerTestLogPath, "\\logs\\testframework\\upnptmservertest\\" ); |
|
44 // Log file |
|
45 _LIT(KTmServerTestLogFile, "upnptmservertest.txt" ); |
|
46 _LIT(KTmServerTestLogFileWithTitle, "upnptmservertest_[%S].txt" ); |
|
47 |
|
48 const TInt KIconWidth = 21; |
|
49 const TInt KIconHeight = 21; |
|
50 const TInt KIconDepth = 24; |
|
51 const TInt KIconWidth1 = 88; |
|
52 const TInt KIconHeight1 = 88; |
|
53 const TInt KIconWidth2 = 36; |
|
54 const TInt KIconHeight2 = 44; |
|
55 const TInt KIconWidth3 = 60; |
|
56 const TInt KIconHeight3 = 60; |
|
57 const TInt KIconDepth1 = 12; |
|
58 const TUint KProfileIdValue = 0; |
|
59 const TUint KAppIdValue = 1; |
|
60 const TUint KAppId1Value = 2; |
|
61 const TUint KAppId2Value = 3; |
|
62 const TUint KAppId3Value = 4; |
|
63 const TUint KAppId4Value = 5; |
|
64 const TUint KAppId5Value = 6; |
|
65 const TUint KNonExistentAppIdValue = 7; |
|
66 const TUint KNonExistentAppId1Value = 8; |
|
67 const TUint KInvalidProfileIdValue = 9; |
|
68 const TInt KInvalidAppIdValue = -1; |
|
69 |
|
70 |
|
71 #define GETPTR & |
|
72 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} |
|
73 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} |
|
74 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} |
|
75 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} |
|
76 |
|
77 // FORWARD DECLARATIONS |
|
78 class CTmServerTest; |
|
79 |
|
80 // DATA TYPES |
|
81 // A typedef for function that does the actual testing, |
|
82 // function is a type |
|
83 typedef TInt (CTmServerTest::* TestFunction)(TTestResult&); |
|
84 |
|
85 // CLASS DECLARATION |
|
86 /** |
|
87 * An internal structure containing a test case name and |
|
88 * the pointer to function doing the test |
|
89 * |
|
90 * @lib ?library |
|
91 * @since ?Series60_version |
|
92 */ |
|
93 class TCaseInfoInternal |
|
94 { |
|
95 public: |
|
96 const TText* iCaseName; |
|
97 TestFunction iMethod; |
|
98 TBool iIsOOMTest; |
|
99 TInt iFirstMemoryAllocation; |
|
100 TInt iLastMemoryAllocation; |
|
101 }; |
|
102 |
|
103 // CLASS DECLARATION |
|
104 |
|
105 /** |
|
106 * A structure containing a test case name and |
|
107 * the pointer to function doing the test |
|
108 * |
|
109 * @lib ?library |
|
110 * @since ?Series60_version |
|
111 */ |
|
112 class TCaseInfo |
|
113 { |
|
114 public: |
|
115 TPtrC iCaseName; |
|
116 TestFunction iMethod; |
|
117 TBool iIsOOMTest; |
|
118 TInt iFirstMemoryAllocation; |
|
119 TInt iLastMemoryAllocation; |
|
120 |
|
121 TCaseInfo( const TText* a ) : iCaseName( (TText*) a ) |
|
122 { |
|
123 }; |
|
124 |
|
125 }; |
|
126 |
|
127 |
|
128 class CDiscoverDevice : public CUpnpControlPoint |
|
129 { |
|
130 public: |
|
131 // Constructors and destructor |
|
132 |
|
133 /** |
|
134 * Two-phased constructor. |
|
135 */ |
|
136 static CDiscoverDevice* NewL(CTmServerTest& aTmServerTest); |
|
137 |
|
138 /** |
|
139 * Destructor. |
|
140 */ |
|
141 virtual ~CDiscoverDevice(); |
|
142 |
|
143 protected: |
|
144 // Functions from base classes |
|
145 |
|
146 /** |
|
147 * From CUpnpControlPoint State update handler. |
|
148 */ |
|
149 void StateUpdatedL( CUpnpService* aService ); |
|
150 |
|
151 /** |
|
152 * From CUpnpControlPoint Device discovery handler. |
|
153 */ |
|
154 void DeviceDiscoveredL( CUpnpDevice* aDevice ); |
|
155 |
|
156 /** |
|
157 * From CUpnpControlPoint Device dissappear handler. |
|
158 */ |
|
159 void DeviceDisappearedL( CUpnpDevice* aDevice ); |
|
160 |
|
161 /** |
|
162 * From CUpnpControlPoint Action response handler function. |
|
163 */ |
|
164 void ActionResponseReceivedL( CUpnpAction* aAction ); |
|
165 |
|
166 /** |
|
167 * From CUpnpControlPoint HTTP message handler function. |
|
168 */ |
|
169 void HttpResponseReceivedL( CUpnpHttpMessage* aMessage ); |
|
170 |
|
171 |
|
172 TInt TmServerStateUpdated( CUpnpDevice& aDevice, CUpnpService*& aService ); |
|
173 |
|
174 |
|
175 public: |
|
176 |
|
177 /** |
|
178 * C++ default constructor. |
|
179 */ |
|
180 CDiscoverDevice(CTmServerTest& aTmServerTest ); |
|
181 |
|
182 void ConstructL(); |
|
183 TInt LaunchAppActionL( TInt aAppId, TInt aProfileId ); |
|
184 TInt TerminateAppActionL( TInt aAppId, TInt aProfileId ); |
|
185 TInt GetAppStatusActionL( TInt aAppId ); |
|
186 TInt GetAppListActionL(const TDesC8& aAppListFilter ,TInt aProfileId ); |
|
187 TInt SetClientProfileActionL(TInt aProfileId, const TDesC8& aClientInfoValue ); |
|
188 TInt GetClientProfileActionL(TInt aProfileId ); |
|
189 TInt GetMaxNumProfilesActionL(); |
|
190 void SubscribeToServiceL(); |
|
191 |
|
192 public: |
|
193 CTmServerTest& iTmServerTest; |
|
194 }; |
|
195 |
|
196 // CLASS DECLARATION |
|
197 |
|
198 /** |
|
199 * This a TmServerTest class. |
|
200 * ?other_description_lines |
|
201 * |
|
202 * @lib ?library |
|
203 * @since ?Series60_version |
|
204 */ |
|
205 NONSHARABLE_CLASS(CTmServerTest) : public CTestModuleBase, |
|
206 public MUpnpTmServerObserver |
|
207 { |
|
208 public: // Constructors and destructor |
|
209 |
|
210 |
|
211 /** |
|
212 * Two-phased constructor. |
|
213 */ |
|
214 static CTmServerTest* NewL(); |
|
215 |
|
216 /** |
|
217 * Destructor. |
|
218 */ |
|
219 virtual ~CTmServerTest(); |
|
220 |
|
221 public: // New functions |
|
222 |
|
223 /** |
|
224 * ?member_description. |
|
225 * @since ?Series60_version |
|
226 * @param ?arg1 ?description |
|
227 * @return ?description |
|
228 */ |
|
229 //?type ?member_function( ?type ?arg1 ); |
|
230 TInt StartTmServerDeviceL ( TTestResult& aResult ); |
|
231 TInt PublishTmServerServiceL ( TTestResult& aResult ); |
|
232 TInt StopTmServerDeviceL ( TTestResult& aResult ); |
|
233 TInt ReStartTmServerDeviceL( TTestResult& aResult ); |
|
234 TInt UnRegisterAppL( TTestResult& aResult ); |
|
235 TInt UnRegisterAppsL( TTestResult& aResult ); |
|
236 TInt RegisterDuplicateAppL( TTestResult& aResult ); |
|
237 TInt RegisterDuplicateAppsL( TTestResult& aResult ); |
|
238 TInt UnRegisterUnRegisteredAppL ( TTestResult& aResult ); |
|
239 TInt UnRegisterUnRegisteredAppsL ( TTestResult& aResult ); |
|
240 TInt HandleLaunchAppActionL ( TTestResult& aResult ); |
|
241 TInt HandleInvalidAppIdLaunchAppActionL(TTestResult& aResult ); |
|
242 TInt HandleInvalidProfileIdLaunchAppActionL(TTestResult& aResult ); |
|
243 TInt HandleNonExistentLaunchAppActionL (TTestResult& aResult); |
|
244 TInt HandleUnauthorizedLaunchAppActionL (TTestResult& aResult); |
|
245 TInt HandleDeviceLockedLaunchAppActionL (TTestResult& aResult); |
|
246 TInt HandleTerminateAppActionL ( TTestResult& aResult ); |
|
247 TInt HandleNonExistentTerminateAppActionL( TTestResult& aResult ); |
|
248 TInt HandleInvalidAppIdTerminateAppActionL( TTestResult& aResult ); |
|
249 TInt HandleInvalidProfileIdTerminateAppActionL( TTestResult& aResult ); |
|
250 TInt HandleUnauthorizedTerminateAppActionL ( TTestResult& aResult ); |
|
251 TInt HandleDeviceLockedTerminateAppActionL ( TTestResult& aResult ); |
|
252 TInt HandleGetAppListActionFilter1L(TTestResult& aResult ); |
|
253 TInt HandleGetAppListActionFilter2L(TTestResult& aResult ); |
|
254 TInt HandleGetAppListActionFilter3L(TTestResult& aResult ); |
|
255 TInt HandleGetAppListActionFilter4L(TTestResult& aResult ); |
|
256 TInt HandleGetAppListActionInvalidArg1L(TTestResult& aResult ); |
|
257 TInt HandleGetAppListActionInvalidArg2L(TTestResult& aResult ); |
|
258 TInt HandleGetAppListActionInvalidArg3L(TTestResult& aResult ); |
|
259 TInt HandleGetAppListActionInvalidArg4L(TTestResult& aResult ); |
|
260 TInt HandleGetAppListActionInvalidArg5L(TTestResult& aResult ); |
|
261 TInt HandleInvalidProfileIdGetAppListActionL ( TTestResult& aResult ); |
|
262 TInt HandleGetAppListActionOperationRejectedL ( TTestResult& aResult ); |
|
263 TInt HandleGetAppListActionNoFilterL ( TTestResult& aResult ); |
|
264 TInt HandleGetAppStatusActionL( TTestResult& aResult ); |
|
265 TInt HandleWildcardGetAppStatusActionL( TTestResult& aResult ); |
|
266 TInt HandleInvalidAppIdGetAppStatusActionL ( TTestResult& aResult ); |
|
267 TInt HandleNonExistentGetAppStatusActionL ( TTestResult& aResult ); |
|
268 TInt HandleSetClientProfileActionL( TTestResult& aResult ); |
|
269 TInt HandleInvalidProfileIdSetClientProfileActionL (TTestResult& aResult ); |
|
270 TInt HandleInvalidProfileSetClientProfileActionL (TTestResult& aResult ); |
|
271 TInt HandleDeviceLockedSetClientProfileActionL (TTestResult& aResult ); |
|
272 TInt HandleResourceBusySetClientProfileActionL (TTestResult& aResult ); |
|
273 TInt HandleGetClientProfileActionL( TTestResult& aResult ); |
|
274 TInt HandleInvalidProfileIdGetClientProfileActionL (TTestResult& aResult ); |
|
275 TInt HandleGetMaxNumProfilesActionL( TTestResult& aResult ); |
|
276 TInt HandleGetMaxNumProfilesOperationRejectedL ( TTestResult& aResult ); |
|
277 TInt HandleEventAppStatusUpdateL ( TTestResult& aResult ); |
|
278 TInt HandleEventAppListUpdateL ( TTestResult& aResult ); |
|
279 TInt HandleEventDuplicateAppStatusUpdateL( TTestResult& aResult ); |
|
280 TInt HandleEventProfileIdListStatusUpdateL( TTestResult& aResult ); |
|
281 |
|
282 void RegisterApplicationsL(CUpnpTmServer& aTmServer ); |
|
283 void SetTmServerSettingsL(); |
|
284 void TestTimerTimedOutL(); |
|
285 void TestTimerDiscoveryTimedOut(); |
|
286 void DeviceVerified(); |
|
287 void DeviceLostVerified(); |
|
288 void ServiceVerified(); |
|
289 |
|
290 public: // methods from MUpnpTmServerObserver |
|
291 TTerminalModeErrorCode OnGetApplicationList( TUint aProfileId ); |
|
292 TTerminalModeErrorCode OnLaunchApp( TUint aAppId, RBuf8& aUrl, TUint aProfileId ); |
|
293 TTerminalModeErrorCode OnTerminateApp( TUint aAppId, TUint aProfileId ); |
|
294 TTerminalModeErrorCode OnGetAppStatus( TUint aAppId, TUint& aProfileId ,RBuf8& aStatusType ); |
|
295 TTerminalModeErrorCode OnGetMaxNumProfiles( TUint& aProfileIdCount ); |
|
296 TTerminalModeErrorCode OnSetClientProfile( TUint aProfileId, const TDesC8& aClientProfile,RBuf8& aResultProfile ); |
|
297 TTerminalModeErrorCode OnGetClientProfile( TUint aProfileId, RBuf8& aClientProfile ); |
|
298 const CUpnpTmClientIconPref& GetClientIconPrefsL( TUint aProfileId ); |
|
299 |
|
300 public: // Functions from base classes |
|
301 |
|
302 /** |
|
303 * From CTestModuleBase InitL is used to initialize the |
|
304 * TmServerTest. It is called once for every instance of |
|
305 * TestModuleTmServerTest after its creation. |
|
306 * @since ?Series60_version |
|
307 * @param aIniFile Initialization file for the test module (optional) |
|
308 * @param aFirstTime Flag is true when InitL is executed for first |
|
309 * created instance of TmServerTest. |
|
310 * @return Symbian OS error code |
|
311 */ |
|
312 TInt InitL( TFileName& aIniFile, TBool aFirstTime ); |
|
313 |
|
314 /** |
|
315 * From CTestModuleBase GetTestCasesL is used to inquiry test cases |
|
316 * from TmServerTest. |
|
317 * @since ?Series60_version |
|
318 * @param aTestCaseFile Test case file (optional) |
|
319 * @param aTestCases Array of TestCases returned to test framework |
|
320 * @return Symbian OS error code |
|
321 */ |
|
322 TInt GetTestCasesL( const TFileName& aTestCaseFile, |
|
323 RPointerArray<TTestCaseInfo>& aTestCases ); |
|
324 |
|
325 /** |
|
326 * From CTestModuleBase RunTestCaseL is used to run an individual |
|
327 * test case. |
|
328 * @since ?Series60_version |
|
329 * @param aCaseNumber Test case number |
|
330 * @param aTestCaseFile Test case file (optional) |
|
331 * @param aResult Test case result returned to test framework (PASS/FAIL) |
|
332 * @return Symbian OS error code (test case execution error, which is |
|
333 * not reported in aResult parameter as test case failure). |
|
334 */ |
|
335 TInt RunTestCaseL( const TInt aCaseNumber, |
|
336 const TFileName& aTestCaseFile, |
|
337 TTestResult& aResult ); |
|
338 |
|
339 /** |
|
340 * From CTestModuleBase; OOMTestQueryL is used to specify is particular |
|
341 * test case going to be executed using OOM conditions |
|
342 * @param aTestCaseFile Test case file (optional) |
|
343 * @param aCaseNumber Test case number (optional) |
|
344 * @param aFailureType OOM failure type (optional) |
|
345 * @param aFirstMemFailure The first heap memory allocation failure value (optional) |
|
346 * @param aLastMemFailure The last heap memory allocation failure value (optional) |
|
347 * @return TBool |
|
348 */ |
|
349 virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, |
|
350 const TInt /* aCaseNumber */, |
|
351 TOOMFailureType& aFailureType, |
|
352 TInt& /* aFirstMemFailure */, |
|
353 TInt& /* aLastMemFailure */ ); |
|
354 |
|
355 /** |
|
356 * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM |
|
357 * test environment |
|
358 * @param aTestCaseFile Test case file (optional) |
|
359 * @param aCaseNumber Test case number (optional) |
|
360 * @return None |
|
361 */ |
|
362 virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, |
|
363 const TInt /* aCaseNumber */ ); |
|
364 |
|
365 /** |
|
366 * From CTestModuleBase; OOMHandleWarningL |
|
367 * @param aTestCaseFile Test case file (optional) |
|
368 * @param aCaseNumber Test case number (optional) |
|
369 * @param aFailNextValue FailNextValue for OOM test execution (optional) |
|
370 * @return None |
|
371 * |
|
372 * User may add implementation for OOM test warning handling. Usually no |
|
373 * implementation is required. |
|
374 */ |
|
375 virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, |
|
376 const TInt /* aCaseNumber */, |
|
377 TInt& /* aFailNextValue */); |
|
378 |
|
379 /** |
|
380 * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM |
|
381 * test environment |
|
382 * @param aTestCaseFile Test case file (optional) |
|
383 * @param aCaseNumber Test case number (optional) |
|
384 * @return None |
|
385 * |
|
386 */ |
|
387 virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, |
|
388 const TInt /* aCaseNumber */ ); |
|
389 |
|
390 /** |
|
391 * Method used to log version of test module |
|
392 */ |
|
393 void SendTestModuleVersion(); |
|
394 |
|
395 protected: // New functions |
|
396 |
|
397 /** |
|
398 * ?member_description. |
|
399 * @since ?Series60_version |
|
400 * @param ?arg1 ?description |
|
401 * @return ?description |
|
402 */ |
|
403 |
|
404 private: |
|
405 |
|
406 /** |
|
407 * C++ default constructor. |
|
408 */ |
|
409 CTmServerTest(); |
|
410 |
|
411 /** |
|
412 * By default Symbian 2nd phase constructor is private. |
|
413 */ |
|
414 void ConstructL(); |
|
415 |
|
416 // Prohibit copy constructor if not deriving from CBase. |
|
417 // ?classname( const ?classname& ); |
|
418 // Prohibit assigment operator if not deriving from CBase. |
|
419 // ?classname& operator=( const ?classname& ); |
|
420 |
|
421 /** |
|
422 * Function returning test case name and pointer to test case function. |
|
423 * @since ?Series60_version |
|
424 * @param aCaseNumber test case number |
|
425 * @return TCaseInfo |
|
426 */ |
|
427 const TCaseInfo Case ( const TInt aCaseNumber ) const; |
|
428 |
|
429 /** |
|
430 * [test case declarations] - do not remove |
|
431 */ |
|
432 //ADD NEW METHOD DEC HERE" |
|
433 |
|
434 /** |
|
435 * Printing test case. |
|
436 * @since ?Series60_version |
|
437 * @param aResult Test case result (PASS/FAIL) |
|
438 * @return Symbian OS error code (test case execution error |
|
439 * that is not returned as test case result in aResult) |
|
440 */ |
|
441 TInt PrintTest( TTestResult& aResult ); |
|
442 |
|
443 /** |
|
444 * Printing loop test case. |
|
445 * @since ?Series60_version |
|
446 * @param aResult Test case result (PASS/FAIL) |
|
447 * @return Symbian OS error code (test case execution error |
|
448 * that is not returned as test case result in aResult) |
|
449 */ |
|
450 TInt LoopTest( TTestResult& aResult ); |
|
451 |
|
452 |
|
453 |
|
454 public: // Data |
|
455 // ?one_line_short_description_of_data |
|
456 //?data_declaration; |
|
457 TBool iTmServerDeviceType; |
|
458 TBool iTmServerServiceType; |
|
459 |
|
460 protected: // Data |
|
461 // ?one_line_short_description_of_data |
|
462 //?data_declaration; |
|
463 |
|
464 public: |
|
465 TBool iGetAppList; |
|
466 TBool iStartApp; |
|
467 TBool iStopApp; |
|
468 TBool iSetClientProfile; |
|
469 TBool iGetClientProfile; |
|
470 TBool iGetMaxNumProfiles; |
|
471 TBool iGetAppStatus; |
|
472 TBool iStatusNotified; |
|
473 TBool iOperationRejected; |
|
474 TBool iResourceBusy; |
|
475 |
|
476 |
|
477 private: // Data |
|
478 // Pointer to test (function) to be executed |
|
479 TestFunction iMethod; |
|
480 |
|
481 // Pointer to logger |
|
482 CStifLogger * iLog; |
|
483 |
|
484 // Normal logger |
|
485 CStifLogger* iStdLog; |
|
486 |
|
487 // Test case logger |
|
488 CStifLogger* iTCLog; |
|
489 |
|
490 // Flag saying if test case title should be added to log file name |
|
491 TBool iAddTestCaseTitleToLogName; |
|
492 |
|
493 // Flag saying if version of test module was already sent |
|
494 TBool iVersionLogged; |
|
495 |
|
496 private: |
|
497 CUpnpTmServer* iTmServer; |
|
498 CDiscoverDevice* iSearchDevice; |
|
499 CTestTimer* iTestTimer; |
|
500 CDiscoveryTestTimer* iDiscoveryTestTimer; |
|
501 CUpnpRemotableApp* iRemotableApp; |
|
502 CUpnpTerminalModeIcon* iTerminalModeIcon; |
|
503 CUpnpRemotableApp* iRemotableApp1; |
|
504 CUpnpRemotableApp* iRemotableApp2; |
|
505 CUpnpRemotableApp* iRemotableApp3; |
|
506 CUpnpRemotableApp* iRemotableApp4; |
|
507 CUpnpRemotableApp* iRemotableApp5; |
|
508 CUpnpTmServerDeviceInfo* iTmServerDeviceInfo; |
|
509 RPointerArray<CUpnpRemotableApp> iRemotableAppArray; |
|
510 TBool iDeviceVerified; |
|
511 TBool iDeviceLostVerified; |
|
512 TBool iServiceVerified; |
|
513 RPointerArray<CUpnpTmClientIconPref> iClientIconPrefArray; |
|
514 }; |
|
515 |
|
516 #endif // TMSERVERTEST_H |
|
517 |
|
518 // End of File |
|