|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of MT_CHSPS class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32cmn.h> |
|
21 #include <bautils.h> |
|
22 #include <centralrepository.h> |
|
23 #include <hspsthememanagement.h> |
|
24 #include <hspsclient.h> |
|
25 #include <eunitmacros.h> |
|
26 #include <eunitdecorators.h> |
|
27 |
|
28 #include "mt_hsps.h" |
|
29 #include "mt_hspsteststep.h" |
|
30 #include "hspsserviceutilities.h" |
|
31 #include "hspspersonalisationservice.h" |
|
32 #include "mt_hspsinstallationservice.h" |
|
33 |
|
34 // ======== LOCAL CONSTANTS ==================================================== |
|
35 // LIW variant names |
|
36 _LIT8( KHspsAppUid, "appUid" ); |
|
37 |
|
38 // Heap size for test step thread |
|
39 const TUint KDefaultHeapSize = 0x10000; |
|
40 |
|
41 // Test step data |
|
42 typedef struct |
|
43 { |
|
44 TUint8* iMethod; |
|
45 TUint8* iInParams; |
|
46 TUint8* iExpOutParams; |
|
47 TInt iTriggerCase; |
|
48 TBool iAsync; |
|
49 MT_CHSPS* iBaseObject; |
|
50 }TTestStepDataStr; |
|
51 |
|
52 // ======== LOCAL FUNCTIONS ==================================================== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Calls asynchronous service method |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void HSPSCallServiceL( TAny* aPointer ) |
|
59 { |
|
60 TTestStepDataStr* testStepData = (TTestStepDataStr*)aPointer; |
|
61 |
|
62 // Create test step |
|
63 MT_CHSPSTeststep* ts = MT_CHSPSTeststep::NewL( |
|
64 *(testStepData->iBaseObject->Interface()), |
|
65 testStepData->iMethod, |
|
66 testStepData->iInParams, |
|
67 testStepData->iExpOutParams, |
|
68 testStepData->iAsync ); |
|
69 CleanupStack::PushL( ts ); |
|
70 |
|
71 // Call service method |
|
72 ts->CallServiceL(); |
|
73 |
|
74 // Start wait loop for test step execution |
|
75 CActiveScheduler::Start(); |
|
76 |
|
77 // Check test step result |
|
78 User::LeaveIfError( ts->CheckOutParams() ); |
|
79 |
|
80 // Clean test step. |
|
81 CleanupStack::PopAndDestroy( ts ); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Test step thread |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 TInt HSPSTestStepThread( TAny* aPointer ) |
|
89 { |
|
90 TTestStepDataStr* testStepData = (TTestStepDataStr*)aPointer; |
|
91 |
|
92 // Create cleanup stack for the test step thread |
|
93 CTrapCleanup* theCleanupStack = CTrapCleanup::New(); |
|
94 |
|
95 // Create active scheduler. Do not start yet. |
|
96 CActiveScheduler* scheduler = new( ELeave ) CActiveScheduler; |
|
97 CActiveScheduler::Install( scheduler ); |
|
98 |
|
99 // Attach to service. |
|
100 TInt err = KErrNone; |
|
101 TRAP( err, |
|
102 testStepData->iBaseObject->AttachServiceL( KHSPS, |
|
103 KHSPSConfigurationIf, |
|
104 KHSPSTestAppUid, |
|
105 EFalse ); ); // No timing since it crashed |
|
106 // (we are in separate thread than EUnit now) |
|
107 |
|
108 if( err == KErrNone ) |
|
109 { |
|
110 // Call asychronous service method |
|
111 TRAP( err, HSPSCallServiceL( aPointer ) ); |
|
112 |
|
113 // Detach |
|
114 TRAP_IGNORE( testStepData->iBaseObject->DetachServiceL() ); |
|
115 } |
|
116 |
|
117 // Remove active scheduler. |
|
118 CActiveScheduler::Install( NULL ); |
|
119 delete scheduler; |
|
120 scheduler = NULL; |
|
121 |
|
122 // Clean clean up stack. |
|
123 delete theCleanupStack; |
|
124 |
|
125 // Signal EUnit thread that asynchronous service request is completed |
|
126 RThread::Rendezvous( err ); |
|
127 |
|
128 // And finally exit. |
|
129 return err; |
|
130 } |
|
131 |
|
132 // ======== MEMBER FUNCTIONS =================================================== |
|
133 |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // Constructor |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 MT_CHSPSResource::MT_CHSPSResource( |
|
140 const TDesC& aPath, |
|
141 TInt aExpectedSize ) |
|
142 { |
|
143 iPath.Copy( aPath ); |
|
144 iSize = aExpectedSize; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // Destructor. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 MT_CHSPSResource::~MT_CHSPSResource() |
|
152 { |
|
153 } |
|
154 |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // Constructor |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 MT_CHSPS::MT_CHSPS() |
|
161 { |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // Destructor. |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 MT_CHSPS::~MT_CHSPS() |
|
169 { |
|
170 if ( iInterface ) |
|
171 { |
|
172 iInterface->Close(); |
|
173 } |
|
174 if ( iServiceHandler ) |
|
175 { |
|
176 delete iServiceHandler; |
|
177 } |
|
178 if ( iService ) |
|
179 { |
|
180 delete iService; |
|
181 } |
|
182 iResourceArray.ResetAndDestroy(); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // Attach to defined service providers interface |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void MT_CHSPS::AttachServiceL( |
|
190 const TDesC8& aSapi, |
|
191 const TDesC8& aInterface, |
|
192 const TDesC8& aAppUid, |
|
193 const TBool aUseTiming ) |
|
194 { |
|
195 iServiceHandler = CLiwServiceHandler::NewL(); |
|
196 |
|
197 iService = CLiwCriteriaItem::NewL( 1, aInterface, aSapi ); |
|
198 iService->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
|
199 |
|
200 RCriteriaArray interestList; |
|
201 interestList.AppendL( iService ); |
|
202 iServiceHandler->AttachL( interestList ); |
|
203 interestList.Reset(); |
|
204 |
|
205 CLiwGenericParamList* inParamList = &( iServiceHandler->InParamListL() ); |
|
206 CLiwGenericParamList* outParamList = &( iServiceHandler->OutParamListL() ); |
|
207 |
|
208 TLiwGenericParam appUid; |
|
209 TLiwVariant uidVar; |
|
210 uidVar.Set( aAppUid ); |
|
211 appUid.SetNameAndValueL( KHspsAppUid, uidVar ); |
|
212 inParamList->AppendL( appUid ); |
|
213 appUid.Reset(); |
|
214 |
|
215 if( aUseTiming ) |
|
216 { |
|
217 TPtrC8 method; |
|
218 method.Set( _L8( "Attach" ) ); |
|
219 StartTiming( method ); |
|
220 } |
|
221 |
|
222 iServiceHandler->ExecuteServiceCmdL( |
|
223 *iService, |
|
224 *inParamList, |
|
225 *outParamList ); |
|
226 |
|
227 if( aUseTiming ) |
|
228 { |
|
229 StopTiming(); |
|
230 } |
|
231 |
|
232 TInt pos = 0; |
|
233 outParamList->FindFirst( pos, aInterface ); |
|
234 if( pos != KErrNotFound ) |
|
235 { |
|
236 iInterface = ( *outParamList )[ pos ].Value().AsInterface(); |
|
237 inParamList->Reset(); |
|
238 outParamList->Reset(); |
|
239 } |
|
240 else |
|
241 { |
|
242 inParamList->Reset(); |
|
243 outParamList->Reset(); |
|
244 User::Leave( KErrNotFound ); |
|
245 } |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // Detach from attached interface |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void MT_CHSPS::DetachServiceL( ) |
|
253 { |
|
254 if ( iInterface ) |
|
255 { |
|
256 iInterface->Close(); |
|
257 iInterface = NULL; |
|
258 } |
|
259 if ( iService && iServiceHandler ) |
|
260 { |
|
261 RCriteriaArray interestList; |
|
262 interestList.AppendL( iService ); |
|
263 iServiceHandler->DetachL( interestList ); |
|
264 interestList.Reset(); |
|
265 } |
|
266 if ( iServiceHandler ) |
|
267 { |
|
268 delete iServiceHandler; |
|
269 iServiceHandler = NULL; |
|
270 } |
|
271 if ( iService ) |
|
272 { |
|
273 delete iService; |
|
274 iService = NULL; |
|
275 } |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // Runs synchronous test step |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void MT_CHSPS::RunTestStepSyncL( |
|
283 TUint8* aMethod, |
|
284 TUint8* aInParams, |
|
285 TUint8* aExpOutParams, |
|
286 TBool aMeasureExecTime ) |
|
287 { |
|
288 // AttachServiceL not done? |
|
289 ASSERT ( iInterface ); |
|
290 |
|
291 // Create test step |
|
292 MT_CHSPSTeststep* ts = MT_CHSPSTeststep::NewL( |
|
293 *iInterface, |
|
294 aMethod, |
|
295 aInParams, |
|
296 aExpOutParams, |
|
297 EFalse, |
|
298 aMeasureExecTime ); |
|
299 CleanupStack::PushL( ts ); |
|
300 |
|
301 // Call synchronous service method |
|
302 ts->CallServiceL(); |
|
303 |
|
304 User::LeaveIfError( ts->CheckOutParams() ); |
|
305 |
|
306 CleanupStack::PopAndDestroy( ts ); |
|
307 } |
|
308 // ----------------------------------------------------------------------------- |
|
309 // Runs request notification triggerer |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void MT_CHSPS::RunNotificationTriggerL( TInt aTriggerCase ) |
|
313 { |
|
314 switch( MT_THSPSTrigger(aTriggerCase) ) |
|
315 { |
|
316 case EHspsTriggerRunRemovePluginCase: |
|
317 { |
|
318 RunRemovePluginCase(); |
|
319 } |
|
320 break; |
|
321 case EHspsTriggerRunAddPluginCase: |
|
322 { |
|
323 RunAddPluginCase(); |
|
324 } |
|
325 break; |
|
326 case EHspsTriggerRunInstallationCase: |
|
327 { |
|
328 RunInstallationCase(); |
|
329 } |
|
330 break; |
|
331 case EHspsTriggerRunSetActivePluginCase: |
|
332 { |
|
333 RunSetActivePluginCase(); |
|
334 } |
|
335 break; |
|
336 case EHspsTriggerRunReplacePluginCase: |
|
337 { |
|
338 RunReplacePluginCase(); |
|
339 } |
|
340 break; |
|
341 case EHspsTriggerRunUpdateInstallationCase: |
|
342 { |
|
343 RunUpdateInstallationCase(); |
|
344 } |
|
345 break; |
|
346 case EHspsTriggerRunUninstallationCase: |
|
347 { |
|
348 RunUninstallationCase(); |
|
349 } |
|
350 break; |
|
351 default: |
|
352 break; |
|
353 } |
|
354 } |
|
355 // ----------------------------------------------------------------------------- |
|
356 // Runs Remove Plugin for request notification tests |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 void MT_CHSPS::RunRemovePluginCase() |
|
360 { |
|
361 _LIT8(KPluginId, "8"); |
|
362 TBuf8<8> removedPluginId(KPluginId); |
|
363 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
364 CleanupStack::PushL( hspsPersonalisationService ); |
|
365 hspsPersonalisationService->RemovePluginL(536874929, removedPluginId); |
|
366 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
367 } |
|
368 // ----------------------------------------------------------------------------- |
|
369 // Runs Remove Plugin for request notification tests |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void MT_CHSPS::RunAddPluginCase() |
|
373 { |
|
374 _LIT8(KViewConfId, "1"); |
|
375 _LIT8(KPluginUid, "0x2000b120"); |
|
376 _LIT8(KPluginposition, "-1"); |
|
377 TBuf8<10> viewConfId(KViewConfId); |
|
378 TBuf8<10> addedPluginUid(KPluginUid); |
|
379 TBuf8<10> addedPluginposition(KPluginposition); |
|
380 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
381 CleanupStack::PushL( hspsPersonalisationService ); |
|
382 |
|
383 |
|
384 TInt pluginId; |
|
385 hspsPersonalisationService->AddPluginL(536874929, viewConfId, addedPluginUid, addedPluginposition, pluginId ); |
|
386 iAddedPluginId = pluginId; |
|
387 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
388 |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // Installs a plugin |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void MT_CHSPS::RunInstallationCase() |
|
396 { |
|
397 // Triggers a "PluginInstalled" notification to clients when finnished |
|
398 MT_CHspsInstallationService* hspsInstallationService = MT_CHspsInstallationService::NewL(); |
|
399 CleanupStack::PushL( hspsInstallationService ); |
|
400 hspsInstallationService->InstallConfigurationL( KHSPSInstallInstalledWidgetConf ); |
|
401 CleanupStack::PopAndDestroy( hspsInstallationService ); |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // Installs an update for the plugin |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 void MT_CHSPS::RunUpdateInstallationCase() |
|
409 { |
|
410 // Triggers a "PluginUpdated" notification to clients when finnished |
|
411 MT_CHspsInstallationService* hspsInstallationService = MT_CHspsInstallationService::NewL(); |
|
412 CleanupStack::PushL( hspsInstallationService ); |
|
413 hspsInstallationService->InstallConfigurationL( KHSPSInstallInstalledWidgetConfV2 ); |
|
414 CleanupStack::PopAndDestroy( hspsInstallationService ); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // Uninstalls a plugin |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void MT_CHSPS::RunUninstallationCase() |
|
422 { |
|
423 // Triggers a "PluginUninstalled" notification to clients when finnished |
|
424 MT_CHspsInstallationService* hspsInstallationService = MT_CHspsInstallationService::NewL(); |
|
425 CleanupStack::PushL( hspsInstallationService ); |
|
426 hspsInstallationService->UninstallConfigurationL( |
|
427 KHSPSMTInterfaceUid, |
|
428 (TInt)KHSPSInstalledWidgetConf); |
|
429 CleanupStack::PopAndDestroy( hspsInstallationService ); |
|
430 } |
|
431 |
|
432 void MT_CHSPS::RestoreTestDataL( TInt aTriggerCase ) |
|
433 { |
|
434 switch(aTriggerCase) |
|
435 { |
|
436 case 1: |
|
437 { |
|
438 RestoreRemovedPluginCase(); |
|
439 } |
|
440 break; |
|
441 case 2: |
|
442 { |
|
443 RestoreAddedPluginCase(); |
|
444 } |
|
445 break; |
|
446 default: |
|
447 break; |
|
448 } |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // Runs Remove Plugin for request notification tests |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void MT_CHSPS::RestoreRemovedPluginCase() |
|
456 { |
|
457 _LIT8(KViewConfId, "6"); |
|
458 _LIT8(KPluginUid, "0x2000b120"); |
|
459 _LIT8(KPluginposition, "-1"); |
|
460 TBuf8<10> viewConfId(KViewConfId); |
|
461 TBuf8<10> addedPluginUid(KPluginUid); |
|
462 TBuf8<10> addedPluginposition(KPluginposition); |
|
463 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
464 CleanupStack::PushL( hspsPersonalisationService ); |
|
465 |
|
466 TInt pluginId; |
|
467 hspsPersonalisationService->AddPluginL(536874929, viewConfId, addedPluginUid, addedPluginposition, pluginId ); |
|
468 |
|
469 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
470 |
|
471 } |
|
472 // ----------------------------------------------------------------------------- |
|
473 // Runs Remove Plugin for request notification tests |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void MT_CHSPS::RestoreAddedPluginCase() |
|
477 { |
|
478 //_LIT8(KPluginId, "9"); |
|
479 //iAddedPluginId |
|
480 TBuf8<10> removedPluginId; |
|
481 removedPluginId.AppendNum(iAddedPluginId); |
|
482 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
483 CleanupStack::PushL( hspsPersonalisationService ); |
|
484 hspsPersonalisationService->RemovePluginL(536874929, removedPluginId); |
|
485 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
486 |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // Runs Remove Plugin for request notification tests |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 void MT_CHSPS::RunSetActivePluginCase() |
|
494 { |
|
495 _LIT8(KPluginId, "5"); |
|
496 TBuf8<10> pluginId( KPluginId ); |
|
497 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
498 CleanupStack::PushL( hspsPersonalisationService ); |
|
499 |
|
500 hspsPersonalisationService->SetActivePluginL( 536874929, pluginId ); |
|
501 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
502 |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // Runs Replace Plugin for request notification tests |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void MT_CHSPS::RunReplacePluginCase() |
|
510 { |
|
511 _LIT8(KPluginId, "1"); |
|
512 _LIT8(KPluginUid, "0x2000b102"); |
|
513 TBuf8<10> replacePluginUid( KPluginUid ); |
|
514 TBuf8<1> replacePluginId( KPluginId ); |
|
515 CHspsPersonalisationService* hspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
516 CleanupStack::PushL( hspsPersonalisationService ); |
|
517 |
|
518 hspsPersonalisationService->ReplacePluginL( 536874929, replacePluginId, replacePluginUid ); |
|
519 |
|
520 CleanupStack::PopAndDestroy( hspsPersonalisationService ); |
|
521 |
|
522 } |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // Accessor to iInterface |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 MLiwInterface* MT_CHSPS::Interface() |
|
529 { |
|
530 return iInterface; |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // Runs synchronous test step |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void MT_CHSPS::RunTestStepAsyncL( |
|
538 TUint8* aMethod, |
|
539 TUint8* aInParams, |
|
540 TUint8* aExpOutParams, |
|
541 TInt aTriggerCase) |
|
542 { |
|
543 |
|
544 // Create test step data |
|
545 TTestStepDataStr data; |
|
546 data.iMethod = aMethod; |
|
547 data.iInParams = aInParams; |
|
548 data.iExpOutParams = aExpOutParams; |
|
549 data.iTriggerCase = aTriggerCase; |
|
550 data.iAsync = ETrue; |
|
551 data.iBaseObject = this; |
|
552 |
|
553 // Create thread for the asynchronous test step |
|
554 RThread testThread; |
|
555 TInt err = testThread.Create( |
|
556 _L( "TestStep" ), |
|
557 HSPSTestStepThread, |
|
558 0x5000, // 20kB |
|
559 KDefaultHeapSize, |
|
560 KDefaultHeapSize, |
|
561 ( TAny* )&data, |
|
562 EOwnerProcess ); |
|
563 |
|
564 if ( err == KErrNone ) |
|
565 { |
|
566 // This must be done before resume is called to get correct error code. |
|
567 TRequestStatus status; |
|
568 |
|
569 // Request signal from test step thread when test step is completed |
|
570 testThread.Rendezvous( status ); |
|
571 |
|
572 // Start test step thread |
|
573 testThread.Resume(); |
|
574 |
|
575 // Give test thread some time to initialize so that triggers are not ran before |
|
576 // test thread is connected to server. |
|
577 User::After( 2000000 ); |
|
578 |
|
579 // change application configuration |
|
580 TRAP( err, RunNotificationTriggerL(aTriggerCase) ); |
|
581 if( err != KErrNone ) |
|
582 { |
|
583 // Shutdown thread and close handle. Then leave and |
|
584 // do not wait for event that is never triggered. |
|
585 if( testThread.ExitReason() == EExitPending ) // Check that process is alive. |
|
586 { |
|
587 testThread.Kill( KErrUnknown ); |
|
588 } |
|
589 |
|
590 testThread.Close(); |
|
591 User::Leave( err ); |
|
592 } |
|
593 |
|
594 // Wait test step to be completed |
|
595 User::WaitForRequest( status ); |
|
596 err = status.Int(); |
|
597 |
|
598 testThread.Close(); |
|
599 |
|
600 // Give test thread some time to close |
|
601 User::After( 2000000 ); |
|
602 |
|
603 } |
|
604 |
|
605 User::LeaveIfError( err ); |
|
606 |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // Set active configuration |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 void MT_CHSPS::SetActiveConfigurationL( |
|
614 const TDesC8& aAppUid, |
|
615 TInt aConfId ) |
|
616 { |
|
617 |
|
618 TInt appUid = HspsServiceUtilities::DecString2Int( aAppUid ); |
|
619 |
|
620 // Set application configuration active |
|
621 SetCentralRepositoryKeyL( appUid, aConfId ); |
|
622 |
|
623 } |
|
624 |
|
625 void MT_CHSPS::AddResourceL( |
|
626 const TDesC& aFileName, |
|
627 const TInt aExpectedSize ) |
|
628 { |
|
629 iResourceArray.AppendL( new MT_CHSPSResource(aFileName, aExpectedSize) ); |
|
630 } |
|
631 |
|
632 void MT_CHSPS::ResetResources() |
|
633 { |
|
634 iResourceArray.ResetAndDestroy(); |
|
635 } |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // Check if all given files exist |
|
639 // ----------------------------------------------------------------------------- |
|
640 // |
|
641 void MT_CHSPS::CheckResourcesL() |
|
642 { |
|
643 RFs rFs; |
|
644 rFs.Connect(); |
|
645 CleanupClosePushL( rFs ); |
|
646 |
|
647 RFile file; |
|
648 CleanupClosePushL( file ); |
|
649 |
|
650 TInt err = KErrNone; |
|
651 TInt actualSize = 0; |
|
652 for( TInt i = 0; i < iResourceArray.Count() && !err; i++ ) |
|
653 { |
|
654 MT_CHSPSResource* r = iResourceArray[ i ]; |
|
655 |
|
656 if ( !r || !r->iPath.Length() ) |
|
657 { |
|
658 err = KErrArgument; |
|
659 } |
|
660 if ( !err ) |
|
661 { |
|
662 err = file.Open( rFs, r->iPath, EFileRead ); |
|
663 } |
|
664 if ( !err ) |
|
665 { |
|
666 file.Size( actualSize ); |
|
667 file.Close(); |
|
668 if ( r->iSize >= 0 && actualSize != r->iSize ) |
|
669 { |
|
670 err = KErrCorrupt; |
|
671 } |
|
672 } |
|
673 |
|
674 if ( err ) |
|
675 { |
|
676 EUNIT_PRINT( r->iPath ); |
|
677 User::Leave( err ); |
|
678 } |
|
679 } |
|
680 |
|
681 CleanupStack::PopAndDestroy(2, &rFs); // file, rFs |
|
682 |
|
683 ResetResources(); |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // Starts timing of SAPI method execution |
|
688 // ----------------------------------------------------------------------------- |
|
689 // |
|
690 void MT_CHSPS::StartTiming( |
|
691 TDesC8& aMethod ) |
|
692 { |
|
693 iStartTime.HomeTime(); |
|
694 EUNIT_PRINT( aMethod ); |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // Calculates SAPI method execution time |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 void MT_CHSPS::StopTiming() |
|
702 { |
|
703 TTime readyTime; |
|
704 readyTime.HomeTime(); |
|
705 TTimeIntervalMicroSeconds delay = readyTime.MicroSecondsFrom( iStartTime ); |
|
706 TTime transferTime( delay.Int64() ); |
|
707 TBuf<64> timeString; |
|
708 transferTime.FormatL( timeString,_L( "Execution time: %S%C microseconds" ) ); |
|
709 |
|
710 EUNIT_PRINT( timeString ); |
|
711 |
|
712 } |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // Sets Central Repository key value |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void MT_CHSPS::SetCentralRepositoryKeyL( |
|
719 TInt aKey, |
|
720 TInt aValue ) |
|
721 { |
|
722 CRepository* cr = CRepository::NewL( KhspsThemeStatusRepositoryUid ); |
|
723 CleanupStack::PushL( cr ); |
|
724 User::LeaveIfError( cr->Set( aKey, aValue ) ); |
|
725 |
|
726 CleanupStack::PopAndDestroy( cr ); |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // Removes test configuration resource files |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 void MT_CHSPS::RemoveResourceFilesL( |
|
734 RFs& aFileSession ) |
|
735 { |
|
736 |
|
737 CFileMan* fileManager = CFileMan::NewL( aFileSession ); |
|
738 CleanupStack::PushL( fileManager ); |
|
739 fileManager->RmDir( _L( "c:\\private\\20000fb1\\2456\\" ) ); |
|
740 fileManager->RmDir( _L( "c:\\private\\20000fb1\\536874929\\" ) ); |
|
741 CleanupStack::PopAndDestroy( fileManager ); |
|
742 |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // Hsps client service observer |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 void MT_CHSPS::HandlehspsClientMessage( ThspsServiceCompletedMessage /*aMessage*/ ) |
|
750 { |
|
751 // Asynchronous service handling |
|
752 |
|
753 } |
|
754 |
|
755 // END OF FILE |