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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 |
|
24 #include "tsifnotifierteststep.h" |
|
25 #include "tsifsuitedefs.h" |
|
26 #include <usif/sif/sifcommon.h> |
|
27 #include <usif/sif/sif.h> |
|
28 #include <scs/cleanuputils.h> |
|
29 #include <ct/rcpointerarray.h> |
|
30 |
|
31 using namespace Usif; |
|
32 |
|
33 _LIT(KOperationCount, "OperationCount"); |
|
34 _LIT(KOperation, "Operation"); |
|
35 _LIT(KGlobalCompId, "GlobalCompId"); |
|
36 _LIT(KComponentName, "ComponentName"); |
|
37 _LIT(KComponentIcon, "ComponentIcon"); |
|
38 _LIT(KAppNameCount, "AppNameCount"); |
|
39 _LIT(KAppName, "AppName"); |
|
40 _LIT(KAppIconCount, "AppIconCount"); |
|
41 _LIT(KAppIcon, "AppIcon"); |
|
42 _LIT(KComponentSize, "ComponentSize"); |
|
43 _LIT(KIconPath, "IconPath"); |
|
44 _LIT(KSoftwareType, "SoftwareType"); |
|
45 _LIT(KErrMsg, "ErrMsg"); |
|
46 _LIT(KErrMsgDetails, "ErrMsgDetails"); |
|
47 _LIT(KErrCategory, "ErrCategory"); |
|
48 _LIT(KErrCode, "ErrCode"); |
|
49 _LIT(KPhase, "Phase"); |
|
50 _LIT(KSubPhase, "SubPhase"); |
|
51 _LIT(KCurrentProgress, "CurrentProgress"); |
|
52 _LIT(KTotal, "Total"); |
|
53 _LIT(KSubscriberNumber, "SubscriberNumber"); |
|
54 _LIT(KKeyNumber, "KeyNumber"); |
|
55 _LIT (KSubscribeKey, "SubscribeKey"); |
|
56 _LIT (KSubscribeForProgress, "SubscribeForProgress"); |
|
57 _LIT (KEndData, "EndData"); |
|
58 _LIT (KProgressData, "ProgressData"); |
|
59 _LIT (KDelay, "Delay"); |
|
60 _LIT (KTotalStartCount, "StartCount"); |
|
61 _LIT (KTotalProgressCount, "ProgressCount"); |
|
62 _LIT (KTotalEndCount, "EndCount"); |
|
63 _LIT (KSubscribeShutdownTimer, "SubscribeShutdownTimer"); |
|
64 _LIT (KPublisherDelay, "PublisherDelay"); |
|
65 _LIT (KPrintDetails, "PrintDetails"); |
|
66 CSifSubscribeTestStep::~CSifSubscribeTestStep() |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 { |
|
71 INFO_PRINTF1(_L("Cleanup in CSifSubscribeTestStep::~CSifSubscribeTestStep()")); |
|
72 } |
|
73 |
|
74 CSifSubscribeTestStep::CSifSubscribeTestStep() |
|
75 /** |
|
76 * Constructor |
|
77 */ |
|
78 { |
|
79 SetTestStepName(KSifSubscribeTestStep); |
|
80 } |
|
81 |
|
82 void CSifSubscribeTestStep::ImplTestStepPreambleL() |
|
83 /** |
|
84 * @return - TVerdict code |
|
85 * Override of base class virtual |
|
86 */ |
|
87 { |
|
88 INFO_PRINTF1(_L("I am in CSifSubscribeTestStep::ImplTestStepPreambleL().")); |
|
89 iSched=new(ELeave) CActiveScheduler; |
|
90 CActiveScheduler::Install(iSched); |
|
91 SetTestStepResult(EPass); |
|
92 } |
|
93 |
|
94 |
|
95 void CSifSubscribeTestStep::ImplTestStepL() |
|
96 /** |
|
97 * @return - TVerdict code |
|
98 * Override of base class pure virtual |
|
99 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
100 * not leave. That being the case, the current test result value will be EPass. |
|
101 */ |
|
102 { |
|
103 //Get the Subscriber number |
|
104 GetIntFromConfig(ConfigSection(),KSubscriberNumber, iSubscriberNum); |
|
105 |
|
106 // Delay the Startup ? |
|
107 TInt delay(0); |
|
108 //Get the delay value if present |
|
109 GetIntFromConfig(ConfigSection(),KDelay, delay); |
|
110 if(delay !=0) |
|
111 { |
|
112 User::After(delay * 1000000); |
|
113 } |
|
114 |
|
115 |
|
116 iNotifier = CSifOperationsNotifier::NewL(*this); |
|
117 TInt shutdownTimer(0); |
|
118 GetIntFromConfig(ConfigSection(), KSubscribeShutdownTimer, shutdownTimer); |
|
119 if(shutdownTimer ==0) |
|
120 { |
|
121 shutdownTimer = 10; //default value |
|
122 } |
|
123 iTimer = CStopTimer::NewL(iNotifier, shutdownTimer* 1000000); |
|
124 CActiveScheduler::Start(); |
|
125 |
|
126 //Verify Counts |
|
127 TInt startCount(0); |
|
128 GetIntFromConfig(ConfigSection(), KTotalStartCount, startCount); |
|
129 |
|
130 if(startCount != iStartMessageCounter) |
|
131 { |
|
132 INFO_PRINTF1(_L("Total number of start handler notifications received does not match expected value")); |
|
133 SetTestStepResult(EFail); |
|
134 } |
|
135 |
|
136 TInt progressCount(0); |
|
137 GetIntFromConfig(ConfigSection(), KTotalProgressCount, progressCount); |
|
138 |
|
139 if(progressCount != iProgressMessageCounter) |
|
140 { |
|
141 INFO_PRINTF1(_L("Total number of progress handler notifications received does not match expected value")); |
|
142 SetTestStepResult(EFail); |
|
143 } |
|
144 |
|
145 TInt endCount(0); |
|
146 GetIntFromConfig(ConfigSection(), KTotalEndCount, endCount); |
|
147 |
|
148 if(endCount != iEndMessageCounter) |
|
149 { |
|
150 INFO_PRINTF1(_L("Total number of end handler notifications received does not match expected value")); |
|
151 SetTestStepResult(EFail); |
|
152 } |
|
153 |
|
154 } |
|
155 |
|
156 void CSifSubscribeTestStep::ImplTestStepPostambleL() |
|
157 /** |
|
158 * @return - TVerdict code |
|
159 * Override of base class virtual |
|
160 */ |
|
161 { |
|
162 INFO_PRINTF1(_L("I am in CSifPublishTestStep::ImplTestStepPostambleL().")); |
|
163 delete iNotifier; |
|
164 delete iSched; |
|
165 delete iTimer; |
|
166 } |
|
167 |
|
168 void CSifSubscribeTestStep::StartOperationHandler(TUint aKey, const CSifOperationStartData& aStartData) |
|
169 { |
|
170 TBuf<20> Key; |
|
171 Key = KKeyNumber; |
|
172 GenerateIndexedAttributeNameL(Key, ++iStartMessageCounter); |
|
173 TPtrC keyFromIni; |
|
174 GetStringFromConfig(ConfigSection(), Key, keyFromIni); |
|
175 HBufC* retrievedKeyFromIni = keyFromIni.AllocLC(); |
|
176 |
|
177 //Received Key |
|
178 HBufC* receivedKey = HBufC::NewLC(20); |
|
179 receivedKey->Des().Format(_L("%d"), aKey ); |
|
180 |
|
181 if(*receivedKey != *retrievedKeyFromIni) |
|
182 { |
|
183 INFO_PRINTF1(_L("Key Mismatch !") ); |
|
184 SetTestStepResult(EFail); |
|
185 } |
|
186 else |
|
187 { |
|
188 INFO_PRINTF1(_L("Received Correct Key!") ); |
|
189 } |
|
190 |
|
191 |
|
192 //Subscribe to key ? |
|
193 TBuf<20> SubscribeKey; |
|
194 SubscribeKey = KSubscribeKey; |
|
195 GenerateIndexedAttributeNameL(SubscribeKey, ++iSubscribeCounter); |
|
196 |
|
197 TPtrC SubscribeKeyFromIni; |
|
198 if(GetStringFromConfig(ConfigSection(),SubscribeKey, SubscribeKeyFromIni)) |
|
199 { |
|
200 HBufC* retrievedSubscribeKeyFromIni = SubscribeKeyFromIni.AllocLC(); |
|
201 |
|
202 |
|
203 if(*retrievedSubscribeKeyFromIni == *receivedKey) |
|
204 { |
|
205 INFO_PRINTF3(_L("Subscribing to Key %d from Subscriber%d ."), aKey, iSubscriberNum); |
|
206 |
|
207 TBuf<35> progressNotifier; |
|
208 progressNotifier = KSubscribeForProgress; |
|
209 GenerateIndexedAttributeNameL(progressNotifier, iSubscribeCounter); |
|
210 |
|
211 TBool progressNotifierVal; |
|
212 GetBoolFromConfig(ConfigSection(),progressNotifier, progressNotifierVal); |
|
213 iNotifier->SubscribeL(aKey, progressNotifierVal); |
|
214 } |
|
215 |
|
216 CleanupStack::PopAndDestroy(retrievedSubscribeKeyFromIni); |
|
217 } |
|
218 |
|
219 CleanupStack::PopAndDestroy(2, retrievedKeyFromIni); |
|
220 //Global Component Id check |
|
221 TBuf<20> GlobalId; |
|
222 GlobalId = KGlobalCompId; |
|
223 GenerateIndexedAttributeNameL(GlobalId, iStartMessageCounter); |
|
224 |
|
225 TPtrC globalIdFromIni; |
|
226 GetStringFromConfig(ConfigSection(),GlobalId, globalIdFromIni); |
|
227 |
|
228 HBufC* retrievedGlobalIdFromIni = globalIdFromIni.AllocLC(); |
|
229 |
|
230 |
|
231 if(*retrievedGlobalIdFromIni != aStartData.GlobalComponentId()) |
|
232 { |
|
233 INFO_PRINTF1(_L("Global Component Id mismatch !") ); |
|
234 SetTestStepResult(EFail); |
|
235 } |
|
236 else |
|
237 { |
|
238 INFO_PRINTF1(_L("Received Correct Global Component Id !") ); |
|
239 } |
|
240 CleanupStack::PopAndDestroy(retrievedGlobalIdFromIni); |
|
241 |
|
242 //Print received data ? |
|
243 TBool print; |
|
244 if(GetBoolFromConfig(ConfigSection(),KPrintDetails, print)) |
|
245 { |
|
246 INFO_PRINTF2(_L("Global Component Id : %S"), &aStartData.GlobalComponentId()); |
|
247 INFO_PRINTF2(_L("Component Name: %S"), &aStartData.ComponentName()); |
|
248 |
|
249 for(TInt i=0; i<aStartData.ApplicationNames().Count(); ++i) |
|
250 { |
|
251 INFO_PRINTF3(_L("Application name %d : %S"), i, aStartData.ApplicationNames()[i]); |
|
252 } |
|
253 for(TInt i=0; i<aStartData.ApplicationIcons().Count(); ++i) |
|
254 { |
|
255 INFO_PRINTF3(_L("Application icons %d : %S"), i, aStartData.ApplicationIcons()[i]); |
|
256 } |
|
257 INFO_PRINTF2(_L("Component Size : %d"), aStartData.ComponentSize()); |
|
258 INFO_PRINTF2(_L("Icon Path : %S"), &aStartData.IconPath()); |
|
259 INFO_PRINTF2(_L("Component Icon : %S"), &aStartData.ComponentIcon()); |
|
260 INFO_PRINTF2(_L("Software Type: %S"), &aStartData.SoftwareType()); |
|
261 INFO_PRINTF2(_L("Operation Phase : %d"), (TInt)aStartData.OperationPhase()); |
|
262 |
|
263 } |
|
264 } |
|
265 |
|
266 |
|
267 void CSifSubscribeTestStep::EndOperationHandler(const CSifOperationEndData& aEndData) |
|
268 { |
|
269 TBuf<20> endData; |
|
270 endData = KEndData; |
|
271 GenerateIndexedAttributeNameL(endData, ++iEndMessageCounter); |
|
272 |
|
273 TPtrC endDataFromIni; |
|
274 if(GetStringFromConfig(ConfigSection(),endData, endDataFromIni)) |
|
275 { |
|
276 HBufC* retrievedEndDataFromIni = endDataFromIni.AllocLC(); |
|
277 |
|
278 if(*retrievedEndDataFromIni != aEndData.GlobalComponentId()) |
|
279 { |
|
280 SetTestStepResult(EFail); |
|
281 INFO_PRINTF1(_L("End Data Mismatch !") ); |
|
282 } |
|
283 else |
|
284 { |
|
285 INFO_PRINTF1(_L("Correct end data received !") ); |
|
286 } |
|
287 CleanupStack::PopAndDestroy(retrievedEndDataFromIni); |
|
288 } |
|
289 else |
|
290 { |
|
291 SetTestStepResult(EFail); |
|
292 INFO_PRINTF1(_L("End Data Mismatch !") ); |
|
293 } |
|
294 |
|
295 //Print received data ? |
|
296 TBool print; |
|
297 if(GetBoolFromConfig(ConfigSection(),KPrintDetails, print)) |
|
298 { |
|
299 INFO_PRINTF2(_L("Global Component Id : %S"), &aEndData.GlobalComponentId()); |
|
300 INFO_PRINTF2(_L("Error Category : %d"), (TInt)aEndData.ErrorCategory()); |
|
301 INFO_PRINTF2(_L("Error code : %d"), aEndData.ErrorCode()); |
|
302 INFO_PRINTF2(_L("Error message : %S"), &aEndData.ErrorMessage()); |
|
303 INFO_PRINTF2(_L("Error message details : %S"), &aEndData.ErrorMessageDetails()); |
|
304 } |
|
305 } |
|
306 |
|
307 void CSifSubscribeTestStep::ProgressOperationHandler(const CSifOperationProgressData& aProgressData) |
|
308 { |
|
309 TBuf<20> progressData; |
|
310 progressData = KProgressData; |
|
311 GenerateIndexedAttributeNameL(progressData, ++iProgressMessageCounter); |
|
312 |
|
313 TPtrC progressDataFromIni; |
|
314 if(GetStringFromConfig(ConfigSection(),progressData, progressDataFromIni)) |
|
315 { |
|
316 HBufC* retrievedprogressDataFromIni = progressDataFromIni.AllocLC(); |
|
317 |
|
318 if(*retrievedprogressDataFromIni != aProgressData.GlobalComponentId()) |
|
319 { |
|
320 SetTestStepResult(EFail); |
|
321 INFO_PRINTF1(_L("Progress Data Mismatch !") ); |
|
322 } |
|
323 else |
|
324 { |
|
325 INFO_PRINTF1(_L("Correct progress data received !") ); |
|
326 } |
|
327 |
|
328 CleanupStack::PopAndDestroy(retrievedprogressDataFromIni); |
|
329 } |
|
330 else |
|
331 { |
|
332 SetTestStepResult(EFail); |
|
333 INFO_PRINTF1(_L("Progress Data Mismatch !") ); |
|
334 } |
|
335 |
|
336 //Print received data ? |
|
337 TBool print; |
|
338 if(GetBoolFromConfig(ConfigSection(),KPrintDetails, print)) |
|
339 { |
|
340 INFO_PRINTF2(_L("Global Component Id : %S"), &aProgressData.GlobalComponentId()); |
|
341 INFO_PRINTF2(_L("Phase : %d"), (TInt)aProgressData.Phase()); |
|
342 INFO_PRINTF2(_L("Sub Phase : %d"), (TInt)aProgressData.SubPhase()); |
|
343 INFO_PRINTF2(_L("Current Progress : %d"), aProgressData.CurrentProgress()); |
|
344 INFO_PRINTF2(_L("Total Value : %d"), aProgressData.Total()); |
|
345 |
|
346 } |
|
347 } |
|
348 |
|
349 void CSifSubscribeTestStep::GenerateIndexedAttributeNameL(TDes& aInitialAttributeName, TInt aIndex) |
|
350 { |
|
351 const TInt MAX_INT_STR_LEN = 8; |
|
352 TBuf<MAX_INT_STR_LEN> integerAppendStr; |
|
353 integerAppendStr.Format(_L("%d"), aIndex); |
|
354 aInitialAttributeName.Append(integerAppendStr); |
|
355 } |
|
356 |
|
357 CSifPublishTestStep::~CSifPublishTestStep() |
|
358 /** |
|
359 * Destructor |
|
360 */ |
|
361 { |
|
362 INFO_PRINTF1(_L("Cleanup in CSifPublishTestStep::~CSifPublishTestStep()")); |
|
363 delete iTimer; |
|
364 delete iPublisher; |
|
365 delete iSched; |
|
366 } |
|
367 |
|
368 CSifPublishTestStep::CSifPublishTestStep() |
|
369 /** |
|
370 * Constructor |
|
371 */ |
|
372 { |
|
373 SetTestStepName(KSifPublishTestStep); |
|
374 } |
|
375 |
|
376 void CSifPublishTestStep::ImplTestStepPreambleL() |
|
377 /** |
|
378 * @return - TVerdict code |
|
379 * Override of base class virtual |
|
380 */ |
|
381 { |
|
382 INFO_PRINTF1(_L("I am in CSifPublishTestStep::ImplTestStepPreambleL().")); |
|
383 |
|
384 TInt delay(0); |
|
385 //Get the delay value if present |
|
386 GetIntFromConfig(ConfigSection(),KDelay, delay); |
|
387 if(delay !=0) |
|
388 { |
|
389 User::After(delay * 1000000); |
|
390 } |
|
391 |
|
392 iSched=new(ELeave) CActiveScheduler; |
|
393 CActiveScheduler::Install(iSched); |
|
394 iPublisher = CPublishSifOperationInfo::NewL(); |
|
395 } |
|
396 |
|
397 void CSifPublishTestStep::GenerateIndexedAttributeNameL(TDes& aInitialAttributeName, TInt aIndex) |
|
398 { |
|
399 const TInt MAX_INT_STR_LEN = 8; |
|
400 TBuf<MAX_INT_STR_LEN> integerAppendStr; |
|
401 integerAppendStr.Format(_L("%d"), aIndex); |
|
402 aInitialAttributeName.Append(integerAppendStr); |
|
403 } |
|
404 |
|
405 void CSifPublishTestStep::PublishDataL(HBufC* aConfigSection) |
|
406 { |
|
407 HBufC* configsection; |
|
408 if(aConfigSection == NULL) |
|
409 configsection = ConfigSection().AllocLC(); |
|
410 else |
|
411 configsection = aConfigSection->AllocLC(); |
|
412 |
|
413 TPtrC op; |
|
414 GetStringFromConfig(*configsection,KOperation, op); |
|
415 if(op.Compare(_L("start")) == 0) |
|
416 { |
|
417 TPtrC globalCompId, compName, compIcon, appName, appIcon, iconPath, softwareType; |
|
418 TInt appNameCount =0; |
|
419 TInt appIconCount =0; |
|
420 TInt compSize = 0; |
|
421 TInt phase = 0; |
|
422 GetStringFromConfig(*configsection,KGlobalCompId, globalCompId); |
|
423 GetStringFromConfig(*configsection,KComponentName, compName); |
|
424 GetStringFromConfig(*configsection,KComponentIcon, compIcon); |
|
425 GetIntFromConfig(*configsection, KAppNameCount, appNameCount); |
|
426 RPointerArray<HBufC> appNameArray; |
|
427 CleanupResetAndDestroyPushL(appNameArray); |
|
428 for (TUint i = 0; i < appNameCount; ++i) |
|
429 { |
|
430 TPtrC tAppName; |
|
431 TBuf<20> appName; |
|
432 appName = KAppName; |
|
433 GenerateIndexedAttributeNameL(appName, i); |
|
434 GetStringFromConfig(*configsection, appName, tAppName); |
|
435 HBufC* applicationName = tAppName.AllocLC(); |
|
436 appNameArray.AppendL(applicationName); |
|
437 CleanupStack::Pop(applicationName); |
|
438 } |
|
439 GetIntFromConfig(*configsection, KAppIconCount, appIconCount); |
|
440 RPointerArray<HBufC> appIconArray; |
|
441 CleanupResetAndDestroyPushL(appIconArray); |
|
442 for (TUint i = 0; i < appIconCount; ++i) |
|
443 { |
|
444 TPtrC tAppIcon; |
|
445 TBuf<20> appIcon; |
|
446 appIcon = KAppIcon; |
|
447 GenerateIndexedAttributeNameL(appIcon, i); |
|
448 GetStringFromConfig(*configsection, appIcon, tAppIcon); |
|
449 HBufC* applicationIcon = tAppIcon.AllocLC(); |
|
450 appIconArray.AppendL(applicationIcon); |
|
451 CleanupStack::Pop(applicationIcon); |
|
452 } |
|
453 |
|
454 GetIntFromConfig(*configsection, KComponentSize, compSize); |
|
455 GetStringFromConfig(*configsection, KIconPath, iconPath); |
|
456 GetStringFromConfig(*configsection, KSoftwareType, softwareType); |
|
457 GetIntFromConfig(*configsection, KPhase, phase); |
|
458 |
|
459 TSifOperationPhase enumPhase = static_cast<TSifOperationPhase>(phase); |
|
460 CSifOperationStartData* startdata = CSifOperationStartData::NewLC(globalCompId, compName, appNameArray, appIconArray, compSize, iconPath, compIcon, softwareType, enumPhase); |
|
461 iPublisher->PublishStartL(*startdata); |
|
462 CleanupStack::PopAndDestroy(3, &appNameArray); |
|
463 } |
|
464 else if(op.Compare(_L("progress")) == 0) |
|
465 { |
|
466 TInt phase=0, subPhase=0, curProgress=0, total=0; |
|
467 TPtrC globalCompIdProgress; |
|
468 GetStringFromConfig(*configsection,KGlobalCompId, globalCompIdProgress); |
|
469 GetIntFromConfig(*configsection, KPhase, phase); |
|
470 GetIntFromConfig(*configsection, KSubPhase, subPhase); |
|
471 GetIntFromConfig(*configsection, KCurrentProgress, curProgress); |
|
472 GetIntFromConfig(*configsection, KTotal, total); |
|
473 |
|
474 TSifOperationPhase enumPhase = static_cast<TSifOperationPhase>(phase); |
|
475 TSifOperationSubPhase enumSubPhase = static_cast<TSifOperationSubPhase>(subPhase); |
|
476 CSifOperationProgressData* progressdata = CSifOperationProgressData::NewLC(globalCompIdProgress, enumPhase, enumSubPhase, curProgress, total); |
|
477 iPublisher->PublishProgressL(*progressdata); |
|
478 CleanupStack::PopAndDestroy(progressdata); |
|
479 } |
|
480 else if(op.Compare(_L("end")) == 0) |
|
481 { |
|
482 TPtrC errMsg, errMsgDetails; |
|
483 TInt errCat, errCode; |
|
484 TPtrC globalCompIdEnd; |
|
485 GetStringFromConfig(*configsection,KGlobalCompId, globalCompIdEnd); |
|
486 GetStringFromConfig(*configsection, KErrMsg, errMsg); |
|
487 GetStringFromConfig(*configsection, KErrMsgDetails, errMsgDetails); |
|
488 GetIntFromConfig(*configsection, KErrCategory, errCat); |
|
489 GetIntFromConfig(*configsection, KErrCode, errCode); |
|
490 |
|
491 TErrorCategory enumErrCat = static_cast<TErrorCategory>(errCat); |
|
492 CSifOperationEndData* enddata = CSifOperationEndData::NewLC(globalCompIdEnd, enumErrCat, errCode, errMsg, errMsgDetails); |
|
493 iPublisher->PublishCompletionL(*enddata); |
|
494 CStopTimer* timer = CStopTimer::NewL(NULL, 5000000); |
|
495 CleanupStack::PushL(timer); |
|
496 CActiveScheduler::Start(); |
|
497 CleanupStack::PopAndDestroy(2, enddata); |
|
498 } |
|
499 else if (op.Compare(_L("delay")) == 0) |
|
500 { |
|
501 TInt delay(0); |
|
502 GetIntFromConfig(*configsection, KPublisherDelay, delay); |
|
503 User::After(delay*1000000); |
|
504 } |
|
505 |
|
506 |
|
507 CleanupStack::PopAndDestroy(configsection); |
|
508 } |
|
509 |
|
510 void CSifPublishTestStep::ImplTestStepL() |
|
511 /** |
|
512 * @return - TVerdict code |
|
513 * Override of base class pure virtual |
|
514 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
515 * not leave. That being the case, the current test result value will be EPass. |
|
516 */ |
|
517 { |
|
518 RSoftwareInstall sif; |
|
519 User::LeaveIfError(sif.Connect()); |
|
520 CleanupClosePushL(sif); |
|
521 |
|
522 TInt operationCount = 0; |
|
523 TPtrC configSectionName(ConfigSection()); |
|
524 HBufC* cnfSecName = NULL; |
|
525 |
|
526 GetIntFromConfig(ConfigSection(), KOperationCount, operationCount); |
|
527 for (TUint i = 0; i < operationCount; ++i) |
|
528 { |
|
529 TBuf<20> configSection = _L("configsection"); |
|
530 GenerateIndexedAttributeNameL(configSection, i); |
|
531 GetStringFromConfig(ConfigSection(),configSection, configSectionName); |
|
532 cnfSecName = configSectionName.AllocLC(); |
|
533 PublishDataL(cnfSecName); |
|
534 CleanupStack::PopAndDestroy(cnfSecName); |
|
535 } |
|
536 CStopTimer* timer = CStopTimer::NewL(NULL, 5000000); |
|
537 CleanupStack::PushL(timer); |
|
538 CActiveScheduler::Start(); |
|
539 CleanupStack::PopAndDestroy(2, &sif); |
|
540 } |
|
541 |
|
542 void CSifPublishTestStep::ImplTestStepPostambleL() |
|
543 /** |
|
544 * @return - TVerdict code |
|
545 * Override of base class virtual |
|
546 */ |
|
547 { |
|
548 delete iPublisher; |
|
549 iPublisher=0; |
|
550 delete iSched; |
|
551 iSched=0; |
|
552 } |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 CStopTimer::CStopTimer(CSifOperationsNotifier* aNotifier) : |
|
558 CTimer(-1), |
|
559 iNotifier(aNotifier) |
|
560 { |
|
561 CActiveScheduler::Add(this); |
|
562 } |
|
563 |
|
564 CStopTimer::~CStopTimer() |
|
565 { |
|
566 Cancel(); |
|
567 } |
|
568 |
|
569 void CStopTimer::ConstructL(TInt aSeconds) |
|
570 { |
|
571 CTimer::ConstructL(); |
|
572 iSeconds = aSeconds; |
|
573 Start(); |
|
574 } |
|
575 |
|
576 void CStopTimer::Start() |
|
577 { |
|
578 After(iSeconds); |
|
579 } |
|
580 CStopTimer* CStopTimer::NewL(CSifOperationsNotifier* aNotifier, TInt aSeconds) |
|
581 { |
|
582 CStopTimer* self = new(ELeave) CStopTimer(aNotifier); |
|
583 CleanupStack::PushL(self); |
|
584 self->ConstructL(aSeconds); |
|
585 CleanupStack::Pop(self); |
|
586 return self; |
|
587 } |
|
588 |
|
589 void CStopTimer::RunL() |
|
590 { |
|
591 if(iNotifier) |
|
592 { |
|
593 //To improve coverage, call cancel subscribe on a non existent key. |
|
594 iNotifier->CancelSubscribeL(123); |
|
595 |
|
596 //cancel all subscriptions. |
|
597 iNotifier->CancelSubscribeL(); |
|
598 } |
|
599 CActiveScheduler::Stop(); |
|
600 } |
|
601 |
|
602 |
|
603 TInt CStopTimer::RunError(TInt aError) |
|
604 { |
|
605 (void)aError; |
|
606 return KErrNone; |
|
607 } |
|