|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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: CWidgetRegistrySTIF class member functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <Stiftestinterface.h> |
|
21 #include "WidgetRegistrySTIF.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 |
|
25 // EXTERNAL FUNCTION PROTOTYPES |
|
26 |
|
27 // CONSTANTS |
|
28 _LIT( KPassed , "Test case passed"); |
|
29 _LIT( KFailed , "Test case failed"); |
|
30 _LIT( KDriveC, "C:"); |
|
31 _LIT( KBundleIdentifier, "BundleIdentifier" ); |
|
32 _LIT( KLong, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); |
|
33 _LIT( KValidBundle, "com.nokia.widget.sapi.landmarks"); |
|
34 const TInt KUidTestValue = 0x2000DEB9 - 50; |
|
35 const TUid KInvalidUid = TUid::Uid(0); |
|
36 |
|
37 |
|
38 // MACROS |
|
39 // Function pointer related internal definitions |
|
40 // Rounding known bug in GCC |
|
41 |
|
42 #ifdef __VC32__ |
|
43 #define GETPTR |
|
44 #else |
|
45 #define GETPTR & |
|
46 #endif |
|
47 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} |
|
48 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} |
|
49 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} |
|
50 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} |
|
51 |
|
52 // LOCAL CONSTANTS AND MACROS |
|
53 |
|
54 // MODULE DATA STRUCTURES |
|
55 |
|
56 // LOCAL FUNCTION PROTOTYPES |
|
57 |
|
58 // FORWARD DECLARATIONS |
|
59 |
|
60 // ============================= LOCAL FUNCTIONS =============================== |
|
61 |
|
62 |
|
63 // ============================ MEMBER FUNCTIONS =============================== |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CWidgetRegistrySTIF::CWidgetRegistrySTIF |
|
67 // C++ default constructor can NOT contain any code, that |
|
68 // might leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CWidgetRegistrySTIF::CWidgetRegistrySTIF() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CWidgetRegistrySTIF::ConstructL |
|
77 // Symbian 2nd phase constructor can leave. |
|
78 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created |
|
79 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger |
|
80 // allocates memory from heap and therefore causes error situations with OOM |
|
81 // testing. For more information about STIF Logger construction, see STIF Users |
|
82 // Guide. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CWidgetRegistrySTIF::ConstructL() |
|
86 { |
|
87 iLog = CStifLogger::NewL( KWidgetRegistrySTIFLogPath, |
|
88 KWidgetRegistrySTIFLogFile ); |
|
89 |
|
90 User::LeaveIfError( iFileSystem.Connect() ); |
|
91 |
|
92 RWidgetRegistryClientSession* registryClient; |
|
93 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
94 CleanupStack::PushL( registryClient ); |
|
95 TInt error = registryClient->Connect(); |
|
96 if ( KErrNone == error ) |
|
97 { |
|
98 RWidgetInfoArray widgetInfoArray; |
|
99 error = registryClient->InstalledWidgetsL( widgetInfoArray ); |
|
100 CWidgetInfo *myInfo = widgetInfoArray[0]; |
|
101 iValidUid = myInfo->iUid; |
|
102 } |
|
103 CleanupStack::PopAndDestroy( registryClient ); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CWidgetRegistrySTIF::NewL |
|
108 // Two-phased constructor. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CWidgetRegistrySTIF* CWidgetRegistrySTIF::NewL() |
|
112 { |
|
113 CWidgetRegistrySTIF* self = new (ELeave) CWidgetRegistrySTIF; |
|
114 CleanupStack::PushL( self ); |
|
115 self->ConstructL(); |
|
116 CleanupStack::Pop( self ); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // Destructor |
|
121 CWidgetRegistrySTIF::~CWidgetRegistrySTIF() |
|
122 { |
|
123 iFileSystem.Close(); |
|
124 delete iLog; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CWidgetRegistrySTIF::InitL |
|
129 // InitL is used to initialize the Test Module. |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CWidgetRegistrySTIF::InitL( TFileName& /*aIniFile*/, |
|
133 TBool /*aFirstTime*/ ) |
|
134 { |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 TInt CWidgetRegistrySTIF::ClientSessionCreateL( TTestResult& aResult ) |
|
139 { |
|
140 aResult.SetResult( KErrGeneral, KFailed ); |
|
141 RWidgetRegistryClientSession* registryClient; |
|
142 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
143 CleanupStack::PushL( registryClient ); |
|
144 aResult.SetResult( KErrNone, KPassed ); |
|
145 CleanupStack::PopAndDestroy( registryClient ); |
|
146 return KErrNone; |
|
147 } |
|
148 |
|
149 TInt CWidgetRegistrySTIF::ClientSessionDisconnectFirstL( TTestResult& aResult ) |
|
150 { |
|
151 aResult.SetResult( KErrGeneral, KFailed ); |
|
152 RWidgetRegistryClientSession* registryClient; |
|
153 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
154 CleanupStack::PushL( registryClient ); |
|
155 TInt error = registryClient->Disconnect(); |
|
156 if ( KErrNone == error ) |
|
157 { |
|
158 aResult.SetResult( KErrNone, KPassed ); |
|
159 } |
|
160 CleanupStack::PopAndDestroy( registryClient ); |
|
161 return KErrNone; |
|
162 } |
|
163 |
|
164 |
|
165 TInt CWidgetRegistrySTIF::ClientSessionConnectL( TTestResult& aResult ) |
|
166 { |
|
167 aResult.SetResult( KErrGeneral, KFailed ); |
|
168 RWidgetRegistryClientSession* registryClient; |
|
169 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
170 CleanupStack::PushL( registryClient ); |
|
171 TInt error = registryClient->Connect(); |
|
172 if ( KErrNone == error ) |
|
173 { |
|
174 aResult.SetResult( KErrNone, KPassed ); |
|
175 registryClient->Disconnect(); |
|
176 } |
|
177 CleanupStack::PopAndDestroy( registryClient ); |
|
178 return KErrNone; |
|
179 } |
|
180 |
|
181 TInt CWidgetRegistrySTIF::ClientSessionTwoConnectL( TTestResult& aResult ) |
|
182 { |
|
183 aResult.SetResult( KErrGeneral, KFailed ); |
|
184 RWidgetRegistryClientSession* registryClient; |
|
185 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
186 CleanupStack::PushL( registryClient ); |
|
187 registryClient->Connect(); |
|
188 RWidgetRegistryClientSession* registryClient2; |
|
189 registryClient2 = new (ELeave) RWidgetRegistryClientSession; |
|
190 CleanupStack::PushL( registryClient2 ); |
|
191 TInt error = registryClient2->Connect(); |
|
192 if ( KErrNone == error ) |
|
193 { |
|
194 aResult.SetResult( KErrNone, KPassed ); |
|
195 } |
|
196 registryClient2->Disconnect(); |
|
197 registryClient->Disconnect(); |
|
198 CleanupStack::PopAndDestroy( registryClient2 ); |
|
199 CleanupStack::PopAndDestroy( registryClient ); |
|
200 return KErrNone; |
|
201 } |
|
202 |
|
203 |
|
204 TInt CWidgetRegistrySTIF::ClientSessionDisconnectL( TTestResult& aResult ) |
|
205 { |
|
206 aResult.SetResult( KErrGeneral, KFailed ); |
|
207 RWidgetRegistryClientSession* registryClient; |
|
208 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
209 CleanupStack::PushL( registryClient ); |
|
210 TInt error = registryClient->Connect(); |
|
211 if ( KErrNone == error ) |
|
212 { |
|
213 error = registryClient->Disconnect(); |
|
214 if ( KErrNone == error ) |
|
215 { |
|
216 aResult.SetResult( KErrNone, KPassed ); |
|
217 } |
|
218 } |
|
219 CleanupStack::PopAndDestroy( registryClient ); |
|
220 return KErrNone; |
|
221 } |
|
222 |
|
223 TInt CWidgetRegistrySTIF::ClientSessionVersionL( TTestResult& aResult ) |
|
224 { |
|
225 aResult.SetResult( KErrGeneral, KFailed ); |
|
226 RWidgetRegistryClientSession* registryClient; |
|
227 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
228 CleanupStack::PushL( registryClient ); |
|
229 TInt error = registryClient->Connect(); |
|
230 if ( KErrNone == error ) |
|
231 { |
|
232 TVersion version = registryClient->Version(); |
|
233 if ( 0 < (version.iMajor + version.iMinor + version.iBuild) ) |
|
234 { |
|
235 aResult.SetResult( KErrNone, KPassed ); |
|
236 } |
|
237 registryClient->Disconnect(); |
|
238 } |
|
239 CleanupStack::PopAndDestroy( registryClient ); |
|
240 return KErrNone; |
|
241 } |
|
242 |
|
243 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetNullL( TTestResult& aResult ) |
|
244 { |
|
245 aResult.SetResult( KErrGeneral, KFailed ); |
|
246 RWidgetRegistryClientSession* registryClient; |
|
247 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
248 CleanupStack::PushL( registryClient ); |
|
249 TInt error = registryClient->Connect(); |
|
250 if ( KErrNone == error ) |
|
251 { |
|
252 TBool iswidget = registryClient->IsWidget( KNullUid ); |
|
253 if ( EFalse == iswidget ) |
|
254 { |
|
255 aResult.SetResult( KErrNone, KPassed ); |
|
256 } |
|
257 registryClient->Disconnect(); |
|
258 } |
|
259 CleanupStack::PopAndDestroy( registryClient ); |
|
260 return KErrNone; |
|
261 } |
|
262 |
|
263 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetValidL( TTestResult& aResult ) |
|
264 { |
|
265 aResult.SetResult( KErrGeneral, KFailed ); |
|
266 RWidgetRegistryClientSession* registryClient; |
|
267 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
268 CleanupStack::PushL( registryClient ); |
|
269 TInt error = registryClient->Connect(); |
|
270 if ( KErrNone == error ) |
|
271 { |
|
272 TBool iswidget = registryClient->IsWidget( iValidUid ); |
|
273 if ( iswidget == TRUE ) |
|
274 { |
|
275 aResult.SetResult( KErrNone, KPassed ); |
|
276 } |
|
277 registryClient->Disconnect(); |
|
278 } |
|
279 CleanupStack::PopAndDestroy( registryClient ); |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetInvalidL( TTestResult& aResult ) |
|
284 { |
|
285 aResult.SetResult( KErrGeneral, KFailed ); |
|
286 RWidgetRegistryClientSession* registryClient; |
|
287 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
288 CleanupStack::PushL( registryClient ); |
|
289 TInt error = registryClient->Connect(); |
|
290 if ( KErrNone == error ) |
|
291 { |
|
292 TBool iswidget = registryClient->IsWidget( KInvalidUid ); |
|
293 if ( EFalse == iswidget ) |
|
294 { |
|
295 aResult.SetResult( KErrNone, KPassed ); |
|
296 } |
|
297 registryClient->Disconnect(); |
|
298 } |
|
299 CleanupStack::PopAndDestroy( registryClient ); |
|
300 return KErrNone; |
|
301 } |
|
302 |
|
303 TInt CWidgetRegistrySTIF::ClientSessionWidgetExistsL( TTestResult& aResult ) |
|
304 { |
|
305 aResult.SetResult( KErrGeneral, KFailed ); |
|
306 RWidgetRegistryClientSession* registryClient; |
|
307 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
308 CleanupStack::PushL( registryClient ); |
|
309 TInt error = registryClient->Connect(); |
|
310 if ( KErrNone == error ) |
|
311 { |
|
312 TBool b = registryClient->WidgetExistsL( KNullDesC ); |
|
313 if ( EFalse == b ) |
|
314 { |
|
315 aResult.SetResult( KErrNone, KPassed ); |
|
316 } |
|
317 registryClient->Disconnect(); |
|
318 } |
|
319 CleanupStack::PopAndDestroy( registryClient ); |
|
320 return KErrNone; |
|
321 } |
|
322 |
|
323 TInt CWidgetRegistrySTIF::ClientSessionWidgetExistsOverflowL( TTestResult& aResult ) |
|
324 { |
|
325 aResult.SetResult( KErrGeneral, KFailed ); |
|
326 RWidgetRegistryClientSession* registryClient; |
|
327 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
328 CleanupStack::PushL( registryClient ); |
|
329 TInt error = registryClient->Connect(); |
|
330 if ( KErrNone == error ) |
|
331 { |
|
332 TBool b = registryClient->WidgetExistsL( KLong ); |
|
333 if ( EFalse == b ) |
|
334 { |
|
335 aResult.SetResult( KErrNone, KPassed ); |
|
336 } |
|
337 registryClient->Disconnect(); |
|
338 } |
|
339 CleanupStack::PopAndDestroy( registryClient ); |
|
340 return KErrNone; |
|
341 } |
|
342 |
|
343 TInt CWidgetRegistrySTIF::ClientSessionWidgetExistsValidL( TTestResult& aResult ) |
|
344 { |
|
345 aResult.SetResult( KErrGeneral, KFailed ); |
|
346 RWidgetRegistryClientSession* registryClient; |
|
347 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
348 CleanupStack::PushL( registryClient ); |
|
349 TInt error = registryClient->Connect(); |
|
350 if ( KErrNone == error ) |
|
351 { |
|
352 TBool b = registryClient->WidgetExistsL( KValidBundle ); |
|
353 if ( b != EFalse ) |
|
354 { |
|
355 aResult.SetResult( KErrNone, KPassed ); |
|
356 } |
|
357 registryClient->Disconnect(); |
|
358 } |
|
359 CleanupStack::PopAndDestroy( registryClient ); |
|
360 return KErrNone; |
|
361 } |
|
362 |
|
363 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetRunningNullL( TTestResult& aResult ) |
|
364 { |
|
365 aResult.SetResult( KErrGeneral, KFailed ); |
|
366 RWidgetRegistryClientSession* registryClient; |
|
367 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
368 CleanupStack::PushL( registryClient ); |
|
369 TInt error = registryClient->Connect(); |
|
370 if ( KErrNone == error ) |
|
371 { |
|
372 TBool b = registryClient->IsWidgetRunning( KNullUid ); |
|
373 if ( EFalse == b ) |
|
374 { |
|
375 aResult.SetResult( KErrNone, KPassed ); |
|
376 } |
|
377 registryClient->Disconnect(); |
|
378 } |
|
379 CleanupStack::PopAndDestroy( registryClient ); |
|
380 return KErrNone; |
|
381 } |
|
382 |
|
383 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetRunningValidL( TTestResult& aResult ) |
|
384 { |
|
385 aResult.SetResult( KErrGeneral, KFailed ); |
|
386 RWidgetRegistryClientSession* registryClient; |
|
387 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
388 CleanupStack::PushL( registryClient ); |
|
389 TInt error = registryClient->Connect(); |
|
390 if ( KErrNone == error ) |
|
391 { |
|
392 TBool b = registryClient->IsWidgetRunning( iValidUid ); |
|
393 if ( b == TRUE ) |
|
394 { |
|
395 aResult.SetResult( KErrNone, KPassed ); |
|
396 } |
|
397 registryClient->Disconnect(); |
|
398 } |
|
399 CleanupStack::PopAndDestroy( registryClient ); |
|
400 return KErrNone; |
|
401 } |
|
402 |
|
403 TInt CWidgetRegistrySTIF::ClientSessionIsWidgetRunningInvalidL( TTestResult& aResult ) |
|
404 { |
|
405 aResult.SetResult( KErrGeneral, KFailed ); |
|
406 RWidgetRegistryClientSession* registryClient; |
|
407 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
408 CleanupStack::PushL( registryClient ); |
|
409 TInt error = registryClient->Connect(); |
|
410 if ( KErrNone == error ) |
|
411 { |
|
412 TBool b = registryClient->IsWidgetRunning( KInvalidUid ); |
|
413 if ( b == EFalse ) |
|
414 { |
|
415 aResult.SetResult( KErrNone, KPassed ); |
|
416 } |
|
417 registryClient->Disconnect(); |
|
418 } |
|
419 CleanupStack::PopAndDestroy( registryClient ); |
|
420 return KErrNone; |
|
421 } |
|
422 |
|
423 |
|
424 TInt CWidgetRegistrySTIF::ClientSessionWidgetCountL( TTestResult& aResult ) |
|
425 { |
|
426 aResult.SetResult( KErrGeneral, KFailed ); |
|
427 RWidgetRegistryClientSession* registryClient; |
|
428 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
429 CleanupStack::PushL( registryClient ); |
|
430 TInt error = registryClient->Connect(); |
|
431 if ( KErrNone == error ) |
|
432 { |
|
433 TInt count = -1; |
|
434 TInt count2 = count - 1; |
|
435 count2 = registryClient->WidgetCount( count ); |
|
436 if ( -1 < count && count == count2 ) |
|
437 { |
|
438 aResult.SetResult( KErrNone, KPassed ); |
|
439 } |
|
440 registryClient->Disconnect(); |
|
441 } |
|
442 CleanupStack::PopAndDestroy( registryClient ); |
|
443 return KErrNone; |
|
444 } |
|
445 |
|
446 |
|
447 |
|
448 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetPathL( TTestResult& aResult ) |
|
449 { |
|
450 aResult.SetResult( KErrGeneral, KFailed ); |
|
451 RWidgetRegistryClientSession* registryClient; |
|
452 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
453 CleanupStack::PushL( registryClient ); |
|
454 TInt error = registryClient->Connect(); |
|
455 if ( KErrNone == error ) |
|
456 { |
|
457 TFileName fn; |
|
458 fn.SetLength( 0 ); |
|
459 registryClient->GetWidgetPath( iValidUid, fn ); |
|
460 if ( 0 < fn.Length() ) |
|
461 { |
|
462 aResult.SetResult( KErrNone, KPassed ); |
|
463 } |
|
464 registryClient->Disconnect(); |
|
465 } |
|
466 CleanupStack::PopAndDestroy( registryClient ); |
|
467 return KErrNone; |
|
468 } |
|
469 |
|
470 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetUidL( TTestResult& aResult ) |
|
471 { |
|
472 aResult.SetResult( KErrGeneral, KFailed ); |
|
473 RWidgetRegistryClientSession* registryClient; |
|
474 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
475 CleanupStack::PushL( registryClient ); |
|
476 TInt error = registryClient->Connect(); |
|
477 if ( KErrNone == error ) |
|
478 { |
|
479 TInt uid = registryClient->GetWidgetUidL( KNullDesC ); |
|
480 if ( KNullUid == TUid::Uid( uid ) ) |
|
481 { |
|
482 aResult.SetResult( KErrNone, KPassed ); |
|
483 } |
|
484 registryClient->Disconnect(); |
|
485 } |
|
486 CleanupStack::PopAndDestroy( registryClient ); |
|
487 return KErrNone; |
|
488 } |
|
489 |
|
490 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetUidValidL( TTestResult& aResult ) |
|
491 { |
|
492 aResult.SetResult( KErrGeneral, KFailed ); |
|
493 RWidgetRegistryClientSession* registryClient; |
|
494 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
495 CleanupStack::PushL( registryClient ); |
|
496 TInt error = registryClient->Connect(); |
|
497 if ( KErrNone == error ) |
|
498 { |
|
499 TInt uid = registryClient->GetWidgetUidL( KValidBundle ); |
|
500 if ( iValidUid == TUid::Uid( uid ) ) |
|
501 { |
|
502 aResult.SetResult( KErrNone, KPassed ); |
|
503 } |
|
504 registryClient->Disconnect(); |
|
505 } |
|
506 CleanupStack::PopAndDestroy( registryClient ); |
|
507 return KErrNone; |
|
508 } |
|
509 |
|
510 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetUidForUrlL( TTestResult& aResult ) |
|
511 { |
|
512 aResult.SetResult( KErrGeneral, KFailed ); |
|
513 RWidgetRegistryClientSession* registryClient; |
|
514 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
515 CleanupStack::PushL( registryClient ); |
|
516 TInt error = registryClient->Connect(); |
|
517 if ( KErrNone == error ) |
|
518 { |
|
519 TInt uid = registryClient->GetWidgetUidForUrl( KNullDesC ); |
|
520 if ( KNullUid == TUid::Uid( uid ) ) |
|
521 { |
|
522 aResult.SetResult( KErrNone, KPassed ); |
|
523 } |
|
524 registryClient->Disconnect(); |
|
525 } |
|
526 CleanupStack::PopAndDestroy( registryClient ); |
|
527 return KErrNone; |
|
528 } |
|
529 |
|
530 TInt CWidgetRegistrySTIF::ClientSessionGetAvailableUidL( TTestResult& aResult ) |
|
531 { |
|
532 aResult.SetResult( KErrGeneral, KFailed ); |
|
533 RWidgetRegistryClientSession* registryClient; |
|
534 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
535 CleanupStack::PushL( registryClient ); |
|
536 TInt error = registryClient->Connect(); |
|
537 if ( KErrNone == error ) |
|
538 { |
|
539 TRAP( error, |
|
540 TUid uid = registryClient->GetAvailableUidL( 'C' ); |
|
541 if ( KNullUid != uid ) |
|
542 { |
|
543 aResult.SetResult( KErrNone, KPassed ); |
|
544 } |
|
545 ) |
|
546 registryClient->Disconnect(); |
|
547 } |
|
548 CleanupStack::PopAndDestroy( registryClient ); |
|
549 return KErrNone; |
|
550 } |
|
551 |
|
552 TInt CWidgetRegistrySTIF::ClientSessionGetAvailableUidNullL( TTestResult& aResult ) |
|
553 { |
|
554 aResult.SetResult( KErrGeneral, KFailed ); |
|
555 RWidgetRegistryClientSession* registryClient; |
|
556 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
557 CleanupStack::PushL( registryClient ); |
|
558 TInt error = registryClient->Connect(); |
|
559 if ( KErrNone == error ) |
|
560 { |
|
561 TRAP(error, |
|
562 TUid uid = registryClient->GetAvailableUidL( 'Q' ) ); |
|
563 if ( error == KErrNone ) |
|
564 { |
|
565 aResult.SetResult( KErrNone, KPassed ); |
|
566 } |
|
567 registryClient->Disconnect(); |
|
568 } |
|
569 CleanupStack::PopAndDestroy( registryClient ); |
|
570 return KErrNone; |
|
571 } |
|
572 |
|
573 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetBundleIdL( TTestResult& aResult ) |
|
574 { |
|
575 aResult.SetResult( KErrGeneral, KFailed ); |
|
576 RWidgetRegistryClientSession* registryClient; |
|
577 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
578 CleanupStack::PushL( registryClient ); |
|
579 TInt error = registryClient->Connect(); |
|
580 if ( KErrNone == error ) |
|
581 { |
|
582 TFileName fn; |
|
583 fn.SetLength( 0 ); |
|
584 registryClient->GetWidgetBundleId( KNullUid, fn ); |
|
585 |
|
586 { |
|
587 aResult.SetResult( KErrNone, KPassed ); |
|
588 } |
|
589 registryClient->Disconnect(); |
|
590 } |
|
591 CleanupStack::PopAndDestroy( registryClient ); |
|
592 return KErrNone; |
|
593 } |
|
594 |
|
595 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetBundleNameL( TTestResult& aResult ) |
|
596 { |
|
597 aResult.SetResult( KErrGeneral, KFailed ); |
|
598 RWidgetRegistryClientSession* registryClient; |
|
599 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
600 CleanupStack::PushL( registryClient ); |
|
601 TInt error = registryClient->Connect(); |
|
602 if ( KErrNone == error ) |
|
603 { |
|
604 TFileName fn; |
|
605 fn.SetLength( 0 ); |
|
606 registryClient->GetWidgetBundleName( KNullUid, fn ); |
|
607 if ( 0 == fn.Length() ) |
|
608 { |
|
609 aResult.SetResult( KErrNone, KPassed ); |
|
610 } |
|
611 registryClient->Disconnect(); |
|
612 } |
|
613 CleanupStack::PopAndDestroy( registryClient ); |
|
614 return KErrNone; |
|
615 } |
|
616 |
|
617 TInt CWidgetRegistrySTIF::ClientSessionGetWidgetPropertyValueL( TTestResult& aResult ) |
|
618 { |
|
619 aResult.SetResult( KErrGeneral, KFailed ); |
|
620 RWidgetRegistryClientSession* registryClient; |
|
621 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
622 CleanupStack::PushL( registryClient ); |
|
623 TInt error = registryClient->Connect(); |
|
624 if ( KErrNone == error ) |
|
625 { |
|
626 CWidgetPropertyValue* value = NULL; |
|
627 TRAP( error, |
|
628 value = registryClient->GetWidgetPropertyValueL( iValidUid, EUid ) ); |
|
629 if ( KErrNone == error ) |
|
630 { |
|
631 aResult.SetResult( KErrNone, KPassed ); |
|
632 } |
|
633 delete value; |
|
634 registryClient->Disconnect(); |
|
635 } |
|
636 CleanupStack::PopAndDestroy( registryClient ); |
|
637 return KErrNone; |
|
638 } |
|
639 |
|
640 |
|
641 TInt CWidgetRegistrySTIF::ClientSessionInstalledWidgetsL( TTestResult& aResult ) |
|
642 { |
|
643 aResult.SetResult( KErrGeneral, KFailed ); |
|
644 RWidgetRegistryClientSession* registryClient; |
|
645 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
646 CleanupStack::PushL( registryClient ); |
|
647 TInt error = registryClient->Connect(); |
|
648 if ( KErrNone == error ) |
|
649 { |
|
650 RWidgetInfoArray widgetInfoArray; |
|
651 error = registryClient->InstalledWidgetsL( widgetInfoArray ); |
|
652 CWidgetInfo *myInfo = widgetInfoArray[0]; |
|
653 if ( KErrNone == error ) |
|
654 { |
|
655 aResult.SetResult( KErrNone, KPassed ); |
|
656 } |
|
657 registryClient->Disconnect(); |
|
658 } |
|
659 CleanupStack::PopAndDestroy( registryClient ); |
|
660 return KErrNone; |
|
661 } |
|
662 |
|
663 TInt CWidgetRegistrySTIF::ClientSessionRunningWidgetsL( TTestResult& aResult ) |
|
664 { |
|
665 aResult.SetResult( KErrGeneral, KFailed ); |
|
666 RWidgetRegistryClientSession* registryClient; |
|
667 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
668 CleanupStack::PushL( registryClient ); |
|
669 TInt error = registryClient->Connect(); |
|
670 if ( KErrNone == error ) |
|
671 { |
|
672 RWidgetInfoArray widgetInfoArray; |
|
673 error = registryClient->RunningWidgetsL( widgetInfoArray ); |
|
674 if ( KErrNone == error ) |
|
675 { |
|
676 aResult.SetResult( KErrNone, KPassed ); |
|
677 } |
|
678 registryClient->Disconnect(); |
|
679 } |
|
680 CleanupStack::PopAndDestroy( registryClient ); |
|
681 return KErrNone; |
|
682 } |
|
683 |
|
684 TInt CWidgetRegistrySTIF::ClientSessionRegisterWidgetL( TTestResult& aResult ) |
|
685 { |
|
686 aResult.SetResult( KErrGeneral, KFailed ); |
|
687 RWidgetRegistryClientSession* registryClient; |
|
688 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
689 CleanupStack::PushL( registryClient ); |
|
690 TInt error = registryClient->Connect(); |
|
691 if ( KErrNone == error ) |
|
692 { |
|
693 RPointerArray<CWidgetPropertyValue> propertyValues; |
|
694 TInt i = 0; |
|
695 // empty values |
|
696 for ( ; i < EWidgetPropertyIdCount; ++i ) |
|
697 { |
|
698 CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); |
|
699 CleanupStack::PushL( value ); |
|
700 User::LeaveIfError( propertyValues.Insert( value, i ) ); |
|
701 CleanupStack::Pop( value ); |
|
702 } |
|
703 *(propertyValues[EWidgetPropertyListVersion]) = WIDGETPROPERTYLISTVERSION; |
|
704 TFileName buf; |
|
705 buf.Copy( KDriveC ); |
|
706 *(propertyValues[EDriveName]) = buf; |
|
707 buf.Copy( KBundleIdentifier ); |
|
708 *(propertyValues[EBundleIdentifier]) = buf; |
|
709 *(propertyValues[EUid]) = KUidTestValue /* arbitrary value */; |
|
710 TRAP( error, |
|
711 registryClient->RegisterWidgetL( propertyValues ) ); |
|
712 if ( KErrNone == error ) |
|
713 { |
|
714 aResult.SetResult( KErrNone, KPassed ); |
|
715 } |
|
716 registryClient->Disconnect(); |
|
717 } |
|
718 CleanupStack::PopAndDestroy( registryClient ); |
|
719 return KErrNone; |
|
720 } |
|
721 |
|
722 TInt CWidgetRegistrySTIF::ClientSessionDeRegisterWidgetL( TTestResult& aResult ) |
|
723 { |
|
724 aResult.SetResult( KErrGeneral, KFailed ); |
|
725 RWidgetRegistryClientSession* registryClient; |
|
726 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
727 CleanupStack::PushL( registryClient ); |
|
728 TInt error = registryClient->Connect(); |
|
729 if ( KErrNone == error ) |
|
730 { |
|
731 TRAP( error, |
|
732 registryClient->DeRegisterWidgetL( iValidUid )); |
|
733 if ( KErrNone == error ) |
|
734 { |
|
735 aResult.SetResult( KErrNone, KPassed ); |
|
736 } |
|
737 registryClient->Disconnect(); |
|
738 } |
|
739 CleanupStack::PopAndDestroy( registryClient ); |
|
740 return KErrNone; |
|
741 } |
|
742 |
|
743 TInt CWidgetRegistrySTIF::ClientSessionSetActiveL( TTestResult& aResult ) |
|
744 { |
|
745 aResult.SetResult( KErrGeneral, KFailed ); |
|
746 RWidgetRegistryClientSession* registryClient; |
|
747 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
748 CleanupStack::PushL( registryClient ); |
|
749 TInt error = registryClient->Connect(); |
|
750 if ( KErrNone == error ) |
|
751 { |
|
752 registryClient->SetActive( KNullUid, 0 ); |
|
753 aResult.SetResult( KErrNone, KPassed ); |
|
754 registryClient->Disconnect(); |
|
755 } |
|
756 CleanupStack::PopAndDestroy( registryClient ); |
|
757 return KErrNone; |
|
758 } |
|
759 |
|
760 TInt CWidgetRegistrySTIF::ClientSessionGetLprojNameL( TTestResult& aResult ) |
|
761 { |
|
762 aResult.SetResult( KErrGeneral, KFailed ); |
|
763 RWidgetRegistryClientSession* registryClient; |
|
764 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
765 CleanupStack::PushL( registryClient ); |
|
766 TInt error = registryClient->Connect(); |
|
767 if ( KErrNone == error ) |
|
768 { |
|
769 TFileName buf; |
|
770 registryClient->GetLprojName( buf ); |
|
771 aResult.SetResult( KErrNone, KPassed ); |
|
772 registryClient->Disconnect(); |
|
773 } |
|
774 CleanupStack::PopAndDestroy( registryClient ); |
|
775 return KErrNone; |
|
776 } |
|
777 |
|
778 TInt CWidgetRegistrySTIF::ClientSessionSecurityPolicyId( TTestResult& aResult ) |
|
779 { |
|
780 aResult.SetResult( KErrGeneral, KFailed ); |
|
781 RWidgetRegistryClientSession* registryClient; |
|
782 registryClient = new (ELeave) RWidgetRegistryClientSession; |
|
783 CleanupStack::PushL( registryClient ); |
|
784 TInt error = registryClient->Connect(); |
|
785 if ( KErrNone == error ) |
|
786 { |
|
787 TInt SecurityPolicyId = registryClient->SecurityPolicyId(); |
|
788 if( 0 != SecurityPolicyId ) |
|
789 { |
|
790 aResult.SetResult( KErrNone, KPassed ); |
|
791 } |
|
792 registryClient->Disconnect(); |
|
793 } |
|
794 CleanupStack::PopAndDestroy( registryClient ); |
|
795 return KErrNone; |
|
796 } |
|
797 |
|
798 |
|
799 const TCaseInfo CWidgetRegistrySTIF::Case ( const TInt aCaseNumber ) const |
|
800 { |
|
801 static TCaseInfoInternal const KCases[] = |
|
802 { |
|
803 // To add new test cases, add new items to this array |
|
804 |
|
805 // NOTE: When compiled to GCCE, there must be Classname:: |
|
806 // declaration in front of the method name, e.g. |
|
807 // CDemoModule::PrintTest. Otherwise the compiler |
|
808 // gives errors. |
|
809 |
|
810 ENTRY( "ClientSession New", |
|
811 CWidgetRegistrySTIF::ClientSessionCreateL ), |
|
812 ENTRY( "ClientSession DisconnectFirst", |
|
813 CWidgetRegistrySTIF::ClientSessionDisconnectFirstL ), |
|
814 ENTRY( "ClientSession Connect", |
|
815 CWidgetRegistrySTIF::ClientSessionConnectL ), |
|
816 ENTRY( "ClientSession ConnectAgain", |
|
817 CWidgetRegistrySTIF::ClientSessionTwoConnectL ), |
|
818 ENTRY( "ClientSession Disconnect", |
|
819 CWidgetRegistrySTIF::ClientSessionDisconnectL ), |
|
820 ENTRY( "ClientSession Version", |
|
821 CWidgetRegistrySTIF::ClientSessionVersionL ), |
|
822 ENTRY( "ClientSession IsWidgetNull", |
|
823 CWidgetRegistrySTIF::ClientSessionIsWidgetNullL ), |
|
824 ENTRY( "ClientSession IsWidgetInvalid", |
|
825 CWidgetRegistrySTIF::ClientSessionIsWidgetInvalidL ), |
|
826 ENTRY( "ClientSession IsWidgetValid", |
|
827 CWidgetRegistrySTIF::ClientSessionIsWidgetValidL ), |
|
828 ENTRY( "ClientSession WidgetExists", |
|
829 CWidgetRegistrySTIF::ClientSessionWidgetExistsL ), |
|
830 ENTRY( "ClientSession WidgetExistsOverflow", |
|
831 CWidgetRegistrySTIF::ClientSessionWidgetExistsOverflowL), |
|
832 ENTRY( "ClientSession WidgetExistsValid", |
|
833 CWidgetRegistrySTIF::ClientSessionWidgetExistsValidL), |
|
834 ENTRY( "ClientSession IsWidgetRunningNull", |
|
835 CWidgetRegistrySTIF::ClientSessionIsWidgetRunningNullL ), |
|
836 ENTRY( "ClientSession IsWidgetRunningValid", |
|
837 CWidgetRegistrySTIF::ClientSessionIsWidgetRunningValidL ), |
|
838 ENTRY( "ClientSession IsWidgetRunningInvalid", |
|
839 CWidgetRegistrySTIF::ClientSessionIsWidgetRunningInvalidL ), |
|
840 ENTRY( "ClientSession WidgetCount", |
|
841 CWidgetRegistrySTIF::ClientSessionWidgetCountL ), |
|
842 ENTRY( "ClientSession GetWidgetPath", |
|
843 CWidgetRegistrySTIF::ClientSessionGetWidgetPathL ), |
|
844 ENTRY( "ClientSession GetWidgetUid", |
|
845 CWidgetRegistrySTIF::ClientSessionGetWidgetUidL ), |
|
846 ENTRY( "ClientSession GetWidgetUidValid", |
|
847 CWidgetRegistrySTIF::ClientSessionGetWidgetUidValidL ), |
|
848 ENTRY( "ClientSession GetWidgetUidForUrl", |
|
849 CWidgetRegistrySTIF::ClientSessionGetWidgetUidForUrlL ), |
|
850 ENTRY( "ClientSession GetAvailableUid", |
|
851 CWidgetRegistrySTIF::ClientSessionGetAvailableUidL ), |
|
852 ENTRY( "ClientSession GetAvailableUidNull", |
|
853 CWidgetRegistrySTIF::ClientSessionGetAvailableUidNullL ), |
|
854 ENTRY( "ClientSession GetWidgetBundleId", |
|
855 CWidgetRegistrySTIF::ClientSessionGetWidgetBundleIdL ), |
|
856 ENTRY( "ClientSession GetWidgetBundleName", |
|
857 CWidgetRegistrySTIF::ClientSessionGetWidgetBundleNameL ), |
|
858 ENTRY( "ClientSession GetWidgetPropertyValue", |
|
859 CWidgetRegistrySTIF::ClientSessionGetWidgetPropertyValueL ), |
|
860 ENTRY( "ClientSession InstalledWidgets", |
|
861 CWidgetRegistrySTIF::ClientSessionInstalledWidgetsL ), |
|
862 ENTRY( "ClientSession RunningWidgets", |
|
863 CWidgetRegistrySTIF::ClientSessionRunningWidgetsL ), |
|
864 ENTRY( "ClientSession RegisterWidget", |
|
865 CWidgetRegistrySTIF::ClientSessionRegisterWidgetL ), |
|
866 ENTRY( "ClientSession DeRegisterWidget", |
|
867 CWidgetRegistrySTIF::ClientSessionDeRegisterWidgetL ), |
|
868 ENTRY( "ClientSession SetActive", |
|
869 CWidgetRegistrySTIF::ClientSessionSetActiveL ), |
|
870 ENTRY( "ClientSession GetLprojName", |
|
871 CWidgetRegistrySTIF::ClientSessionGetLprojNameL ), |
|
872 ENTRY( "ClientSession SecurityPolicyId", |
|
873 CWidgetRegistrySTIF::ClientSessionSecurityPolicyId ), |
|
874 |
|
875 }; |
|
876 /* |
|
877 * To add new test cases, implement new test case function and add new |
|
878 * line to KCases array specify the name of the case and the function |
|
879 * doing the test case |
|
880 * In practice, do following |
|
881 * |
|
882 * 1) Make copy of existing test case function and change its name |
|
883 * and functionality. Note that the function must be added to |
|
884 * OOMHard.cpp file and to OOMHard.h |
|
885 * header file. |
|
886 * |
|
887 * 2) Add entry to following KCases array either by using: |
|
888 * |
|
889 * 2.1: FUNCENTRY or ENTRY macro |
|
890 * ENTRY macro takes two parameters: test case name and test case |
|
891 * function name. |
|
892 * |
|
893 * FUNCENTRY macro takes only test case function name as a parameter and |
|
894 * uses that as a test case name and test case function name. |
|
895 * |
|
896 * Or |
|
897 * |
|
898 * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used |
|
899 * only with OOM (Out-Of-Memory) testing! |
|
900 * |
|
901 * OOM_ENTRY macro takes five parameters: test case name, test case |
|
902 * function name, TBool which specifies is method supposed to be run using |
|
903 * OOM conditions, TInt value for first heap memory allocation failure and |
|
904 * TInt value for last heap memory allocation failure. |
|
905 * |
|
906 * OOM_FUNCENTRY macro takes test case function name as a parameter and uses |
|
907 * that as a test case name, TBool which specifies is method supposed to be |
|
908 * run using OOM conditions, TInt value for first heap memory allocation |
|
909 * failure and TInt value for last heap memory allocation failure. |
|
910 */ |
|
911 |
|
912 // Verify that case number is valid |
|
913 if( (TUint) aCaseNumber >= sizeof( KCases ) / |
|
914 sizeof( TCaseInfoInternal ) ) |
|
915 { |
|
916 |
|
917 // Invalid case, construct empty object |
|
918 TCaseInfo null( (const TText*) L"" ); |
|
919 null.iMethod = NULL; |
|
920 null.iIsOOMTest = EFalse; |
|
921 null.iFirstMemoryAllocation = 0; |
|
922 null.iLastMemoryAllocation = 0; |
|
923 return null; |
|
924 } |
|
925 |
|
926 // Construct TCaseInfo object and return it |
|
927 TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); |
|
928 tmp.iMethod = KCases[ aCaseNumber ].iMethod; |
|
929 tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; |
|
930 tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; |
|
931 tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; |
|
932 return tmp; |
|
933 } |
|
934 |
|
935 // ----------------------------------------------------------------------------- |
|
936 // CWidgetRegistrySTIF::GetTestCasesL |
|
937 // GetTestCases is used to aquire test cases from the Test Module. Test |
|
938 // cases are stored to array of test cases. The Test Framework will be |
|
939 // the owner of the data in the RPointerArray after GetTestCases return |
|
940 // and it does the memory deallocation. |
|
941 // ----------------------------------------------------------------------------- |
|
942 // |
|
943 TInt |
|
944 CWidgetRegistrySTIF::GetTestCasesL( const TFileName& /*aConfig*/, |
|
945 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
946 { |
|
947 // copy name and number for all the tests--to be used in UI |
|
948 for( TInt i = 0; Case(i).iMethod; i++ ) |
|
949 { |
|
950 TTestCaseInfo* newCase = new (ELeave) TTestCaseInfo(); |
|
951 CleanupStack::PushL( newCase ); |
|
952 newCase->iCaseNumber = i; // will be a parameter to RunTestCaseL |
|
953 newCase->iTitle.Copy( Case(i).iCaseName ); // for display |
|
954 // transfer ownership |
|
955 User::LeaveIfError( aTestCases.Append( newCase ) ); |
|
956 CleanupStack::Pop( newCase ); |
|
957 } |
|
958 return KErrNone; |
|
959 } |
|
960 |
|
961 // ----------------------------------------------------------------------------- |
|
962 // CWidgetRegistrySTIF::RunTestCaseL |
|
963 // RunTestCaseL is used to run an individual test case specified |
|
964 // by aTestCase. Test cases that can be run may be requested from |
|
965 // Test Module by GetTestCases method before calling RunTestCase. |
|
966 // ----------------------------------------------------------------------------- |
|
967 // |
|
968 TInt CWidgetRegistrySTIF::RunTestCaseL( const TInt aCaseNumber, |
|
969 const TFileName& /*aConfig*/, |
|
970 TTestResult& aResult ) |
|
971 { |
|
972 TInt result = KErrNotFound; |
|
973 TCaseInfo tmp = Case( aCaseNumber ); |
|
974 if ( NULL != tmp.iMethod ) |
|
975 { |
|
976 _LIT( KLogInfo, "Starting testcase [%S]" ); |
|
977 iLog->Log( KLogInfo, &tmp.iCaseName ); |
|
978 result = (this->*tmp.iMethod)( aResult ); |
|
979 } |
|
980 return result; |
|
981 } |
|
982 |
|
983 // ----------------------------------------------------------------------------- |
|
984 // CWidgetRegistrySTIF::OOMTestQueryL |
|
985 // Used to check if a particular test case should be run in OOM conditions and |
|
986 // which memory allocations should fail. |
|
987 // |
|
988 // NOTE: This method is virtual and must be implemented only if test case |
|
989 // should be executed using OOM conditions. |
|
990 // ----------------------------------------------------------------------------- |
|
991 // |
|
992 TBool CWidgetRegistrySTIF::OOMTestQueryL( const TFileName& /* aTestCaseFile */, |
|
993 const TInt /* aCaseNumber */, |
|
994 TOOMFailureType& /* aFailureType */, |
|
995 TInt& /* aFirstMemFailure */, |
|
996 TInt& /* aLastMemFailure */ ) |
|
997 { |
|
998 _LIT( KOOMTestQueryL, "CWidgetRegistrySTIF::OOMTestQueryL" ); |
|
999 iLog->Log( KOOMTestQueryL ); |
|
1000 return EFalse; |
|
1001 } |
|
1002 |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // CWidgetRegistrySTIF::OOMTestInitializeL |
|
1005 // Used to perform the test environment setup for a particular OOM test case. |
|
1006 // Test Modules may use the initialization file to read parameters for Test |
|
1007 // Module initialization but they can also have their own configure file or |
|
1008 // some other routine to initialize themselves. |
|
1009 // |
|
1010 // NOTE: This method is virtual and must be implemented only if test case |
|
1011 // should be executed using OOM conditions. |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // |
|
1014 void CWidgetRegistrySTIF::OOMTestInitializeL( |
|
1015 const TFileName& /* aTestCaseFile */, |
|
1016 const TInt /* aCaseNumber */ ) |
|
1017 { |
|
1018 } |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CWidgetRegistrySTIF::OOMHandleWarningL |
|
1022 // In some cases the heap memory allocation should be skipped, either due to |
|
1023 // problems in the OS code or components used by the code being tested, or even |
|
1024 // inside the tested components which are implemented this way on purpose (by |
|
1025 // design), so it is important to give the tester a way to bypass allocation |
|
1026 // failures. |
|
1027 // |
|
1028 // NOTE: This method is virtual and must be implemented only if test case |
|
1029 // should be executed using OOM conditions. |
|
1030 // ----------------------------------------------------------------------------- |
|
1031 // |
|
1032 void CWidgetRegistrySTIF::OOMHandleWarningL( |
|
1033 const TFileName& /* aTestCaseFile */, |
|
1034 const TInt /* aCaseNumber */, |
|
1035 TInt& /* aFailNextValue */ ) |
|
1036 { |
|
1037 } |
|
1038 |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // CWidgetRegistrySTIF::OOMTestFinalizeL |
|
1041 // Used to perform the test environment cleanup for a particular OOM test case. |
|
1042 // |
|
1043 // NOTE: This method is virtual and must be implemented only if test case |
|
1044 // should be executed using OOM conditions. |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // |
|
1047 void CWidgetRegistrySTIF::OOMTestFinalizeL( |
|
1048 const TFileName& /* aTestCaseFile */, |
|
1049 const TInt /* aCaseNumber */ ) |
|
1050 { |
|
1051 } |
|
1052 |
|
1053 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1054 |
|
1055 // ----------------------------------------------------------------------------- |
|
1056 // LibEntryL is a polymorphic Dll entry point |
|
1057 // Returns: CTestModuleBase*: Pointer to Test Module object |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // |
|
1060 EXPORT_C CTestModuleBase* LibEntryL() |
|
1061 { |
|
1062 return CWidgetRegistrySTIF::NewL(); |
|
1063 } |
|
1064 |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // SetRequirements handles test module parameters(implements evolution |
|
1067 // version 1 for test module's heap and stack sizes configuring). |
|
1068 // Returns: TInt: Symbian error code. |
|
1069 // ----------------------------------------------------------------------------- |
|
1070 // |
|
1071 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, |
|
1072 TUint32& /*aParameterValid*/ ) |
|
1073 { |
|
1074 /* --------------------------------- NOTE --------------------------------- |
|
1075 USER PANICS occurs in test thread creation when: |
|
1076 1) "The panic occurs when the value of the stack size is negative." |
|
1077 2) "The panic occurs if the minimum heap size specified is less |
|
1078 than KMinHeapSize". |
|
1079 KMinHeapSize: "Functions that require a new heap to be allocated will |
|
1080 either panic, or will reset the required heap size to this value if |
|
1081 a smaller heap size is specified". |
|
1082 3) "The panic occurs if the minimum heap size specified is greater than |
|
1083 the maximum size to which the heap can grow". |
|
1084 Other: |
|
1085 1) Make sure that your hardware or Symbian OS is supporting given sizes. |
|
1086 e.g. Hardware might support only sizes that are divisible by four. |
|
1087 ------------------------------- NOTE end ------------------------------- */ |
|
1088 |
|
1089 // Normally STIF uses default heap and stack sizes for test thread, see: |
|
1090 // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. |
|
1091 // If needed heap and stack sizes can be configured here by user. Remove |
|
1092 // comments and define sizes. |
|
1093 |
|
1094 /* |
|
1095 aParameterValid = KStifTestModuleParameterChanged; |
|
1096 |
|
1097 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
1098 // Stack size |
|
1099 param->iTestThreadStackSize= 16384; // 16K stack |
|
1100 // Heap sizes |
|
1101 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
1102 param->iTestThreadMaxHeap = 1048576;// 1M heap max |
|
1103 |
|
1104 aTestModuleParam = param; |
|
1105 */ |
|
1106 return KErrNone; |
|
1107 } |
|
1108 |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // E32Dll is a DLL entry point function |
|
1111 // Returns: KErrNone: No error |
|
1112 // ----------------------------------------------------------------------------- |
|
1113 // |
|
1114 #ifndef EKA2 // Hide Dll entry point to EKA2 |
|
1115 GLDEF_C TInt E32Dll( |
|
1116 TDllReason /*aReason*/) // Reason |
|
1117 { |
|
1118 return(KErrNone); |
|
1119 } |
|
1120 #endif // EKA2 |
|
1121 |
|
1122 // End of File |