|
1 /* |
|
2 * Copyright (c) 2008-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 "tsifoperationstep.h" |
|
25 #include "tsifsuitedefs.h" |
|
26 #include <ct/rcpointerarray.h> |
|
27 |
|
28 using namespace Usif; |
|
29 |
|
30 CSifOperationStep::~CSifOperationStep() |
|
31 /** |
|
32 * Destructor |
|
33 */ |
|
34 { |
|
35 } |
|
36 |
|
37 CSifOperationStep::CSifOperationStep() : iExclusiveOperation(ETrue) |
|
38 /** |
|
39 * Constructor |
|
40 */ |
|
41 { |
|
42 } |
|
43 |
|
44 void CSifOperationStep::ImplTestStepPreambleL() |
|
45 /** |
|
46 * @return - TVerdict code |
|
47 * Override of base class virtual |
|
48 */ |
|
49 { |
|
50 CSifSuiteStepBase::ImplTestStepPreambleL(); |
|
51 INFO_PRINTF1(_L("I am in CSifOperationStep::ImplTestStepPreambleL().")); |
|
52 if (TestStepResult()!=EPass) |
|
53 { |
|
54 return; |
|
55 } |
|
56 |
|
57 if (!GetIntFromConfig(ConfigSection(),KTe_CancelAfter, iCancelAfter)) |
|
58 { |
|
59 iCancelAfter = -1; |
|
60 } |
|
61 |
|
62 TInt err = iSif.Connect(); |
|
63 if (err != KErrNone) |
|
64 { |
|
65 SetTestStepResult(EFail); |
|
66 INFO_PRINTF2(_L("Failed to connect to the SIF server, error code: %d"), err); |
|
67 } |
|
68 else |
|
69 { |
|
70 SetTestStepResult(EPass); |
|
71 } |
|
72 |
|
73 LoadExclusiveOperationFlagFromConfigL(); |
|
74 } |
|
75 |
|
76 void CSifOperationStep::ImplTestStepPostambleL() |
|
77 /** |
|
78 * @return - TVerdict code |
|
79 * Override of base class virtual |
|
80 */ |
|
81 { |
|
82 INFO_PRINTF1(_L("Cleanup in CSifOperationStep::~CSifOperationStep()")); |
|
83 |
|
84 iSif.Close(); |
|
85 |
|
86 delete iComponentInfo; |
|
87 iComponentInfo = NULL; |
|
88 ClearOpaqueParams(); |
|
89 } |
|
90 |
|
91 void CSifOperationStep::ClearOpaqueParams() |
|
92 { |
|
93 delete iPluginOpaqueArguments; |
|
94 iPluginOpaqueArguments = NULL; |
|
95 delete iPluginOpaqueResults; |
|
96 iPluginOpaqueResults = NULL; |
|
97 delete iPluginRefOpaqueResults; |
|
98 iPluginRefOpaqueResults = NULL; |
|
99 } |
|
100 |
|
101 void CSifOperationStep::CancelableWait() |
|
102 { |
|
103 if (iCancelAfter >= 0) |
|
104 { |
|
105 User::After(iCancelAfter); |
|
106 iSif.CancelOperation(); |
|
107 } |
|
108 else |
|
109 { |
|
110 User::WaitForRequest(iStatus); |
|
111 } |
|
112 } |
|
113 |
|
114 |
|
115 void CSifOperationStep::LoadFileNameFromConfigL() |
|
116 { |
|
117 if(!GetStringFromConfig(ConfigSection(),KTe_PackageFile, iFileName)) |
|
118 { |
|
119 INFO_PRINTF2(_L("Parameter %S not found in the ini file"), &KTe_PackageFile); |
|
120 User::Leave(KErrNotFound); |
|
121 } |
|
122 } |
|
123 |
|
124 void CSifOperationStep::LoadComponentIdFromConfigL() |
|
125 { |
|
126 TPtrC componentName, componentVendor; |
|
127 if (GetStringFromConfig(ConfigSection(), KTe_ComponentName, componentName) && |
|
128 GetStringFromConfig(ConfigSection(), KTe_ComponentVendor, componentVendor)) |
|
129 { |
|
130 iComponentId = FindComponentInScrL(componentName, componentVendor); |
|
131 if (iComponentId != 0) |
|
132 { |
|
133 return; |
|
134 } |
|
135 INFO_PRINTF3(_L("Component name = %S, vendor = %S not found in SCR"), &componentName, &componentVendor); |
|
136 User::Leave(KErrNotFound); |
|
137 } |
|
138 |
|
139 |
|
140 if(!GetIntFromConfig(ConfigSection(), KTe_ComponentId, iComponentId)) |
|
141 { |
|
142 User::Leave(KErrNotFound); |
|
143 } |
|
144 } |
|
145 |
|
146 void CSifOperationStep::LoadComponentInfoFromConfigL() |
|
147 { |
|
148 } |
|
149 |
|
150 void CSifOperationStep::LoadExclusiveOperationFlagFromConfigL() |
|
151 { |
|
152 GetBoolFromConfig(ConfigSection(),KTe_ExclusiveOperation, iExclusiveOperation); |
|
153 } |
|
154 |
|
155 void CSifOperationStep::LoadPluginOpaqueParamsFromConfigL(const TDesC& aNamePattern, const TDesC& aTypePattern, const TDesC& aValuePattern, COpaqueNamedParams& aOpaqueParams) |
|
156 { |
|
157 // name pattern |
|
158 HBufC* namePattern = HBufC::NewLC(aNamePattern.Length()+KMaxIntDigits); |
|
159 TPtr bufNamePattern(namePattern->Des()); |
|
160 // value pattern |
|
161 HBufC* valuePattern = HBufC::NewLC(aValuePattern.Length()+KMaxIntDigits); |
|
162 TPtr bufValuePattern(valuePattern->Des()); |
|
163 // value type pattern |
|
164 HBufC* typePattern = HBufC::NewLC(aTypePattern.Length()+KMaxIntDigits); |
|
165 TPtr bufTypePattern(typePattern->Des()); |
|
166 |
|
167 const TInt maxNumParams = 16; |
|
168 for (TInt i=0; i<maxNumParams; ++i) |
|
169 { |
|
170 // param name |
|
171 bufNamePattern.Copy(aNamePattern); |
|
172 bufNamePattern.AppendNum(i); |
|
173 TPtrC name; |
|
174 if (!GetStringFromConfig(ConfigSection(), *namePattern, name)) |
|
175 { |
|
176 break; |
|
177 } |
|
178 |
|
179 //param type |
|
180 bufTypePattern.Copy(aTypePattern); |
|
181 bufTypePattern.AppendNum(i); |
|
182 TPtrC type; |
|
183 if (!GetStringFromConfig(ConfigSection(), *typePattern, type)) |
|
184 { |
|
185 INFO_PRINTF2(_L("Expected opaque param type: %S not found "), typePattern); |
|
186 User::Leave(KErrNotFound); |
|
187 } |
|
188 |
|
189 //param value |
|
190 bufValuePattern.Copy(aValuePattern); |
|
191 bufValuePattern.AppendNum(i); |
|
192 if (type.Compare(KTe_PluginOpaqueValueTypeString) == 0) |
|
193 { |
|
194 TPtrC value; |
|
195 if (GetStringFromConfig(ConfigSection(), *valuePattern, value)) |
|
196 { |
|
197 aOpaqueParams.AddStringL(name, value); |
|
198 } |
|
199 else |
|
200 { |
|
201 INFO_PRINTF2(_L("Expected opaque param value: %S not found "), valuePattern); |
|
202 User::Leave(KErrNotFound); |
|
203 } |
|
204 } |
|
205 else if (type.Compare(KTe_PluginOpaqueValueTypeInt) == 0) |
|
206 { |
|
207 TInt value = 0; |
|
208 if(GetIntFromConfig(ConfigSection(), *valuePattern, value)) |
|
209 { |
|
210 aOpaqueParams.AddIntL(name, value); |
|
211 } |
|
212 else |
|
213 { |
|
214 INFO_PRINTF2(_L("Expected opaque param value: %S not found "), valuePattern); |
|
215 User::Leave(KErrNotFound); |
|
216 } |
|
217 } |
|
218 else |
|
219 { |
|
220 INFO_PRINTF2(_L("Unknow type of opaque param value: %S "), &type); |
|
221 User::Leave(KErrUnknown); |
|
222 } |
|
223 |
|
224 } |
|
225 CleanupStack::PopAndDestroy(3, namePattern); |
|
226 } |
|
227 |
|
228 void ClearOpaqueParamsCleanup(TAny* aParam) |
|
229 { |
|
230 static_cast<CSifOperationStep*>(aParam)->ClearOpaqueParams(); |
|
231 } |
|
232 |
|
233 void CSifOperationStep::LoadOpaqueParamsL() |
|
234 { |
|
235 GetBoolFromConfig(ConfigSection(),KTe_UseEnhancedApi, iUseEnhancedApi); |
|
236 |
|
237 CleanupStack::PushL(TCleanupItem(ClearOpaqueParamsCleanup, this)); |
|
238 if (iUseEnhancedApi) |
|
239 { |
|
240 delete iPluginOpaqueArguments; |
|
241 iPluginOpaqueArguments = NULL; |
|
242 iPluginOpaqueArguments = COpaqueNamedParams::NewL(); |
|
243 delete iPluginOpaqueResults; |
|
244 iPluginOpaqueResults = NULL; |
|
245 iPluginOpaqueResults = COpaqueNamedParams::NewL(); |
|
246 delete iPluginRefOpaqueResults; |
|
247 iPluginRefOpaqueResults = NULL; |
|
248 iPluginRefOpaqueResults = COpaqueNamedParams::NewL(); |
|
249 |
|
250 LoadPluginOpaqueParamsFromConfigL(KTe_PluginOpaqueArgumentName, KTe_PluginOpaqueArgumentType, KTe_PluginOpaqueArgumentValue, *iPluginOpaqueArguments); |
|
251 LoadPluginOpaqueParamsFromConfigL(KTe_PluginRefOpaqueResultName, KTe_PluginRefOpaqueResultType, KTe_PluginRefOpaqueResultValue, *iPluginRefOpaqueResults); |
|
252 } |
|
253 CleanupStack::Pop(); // ClearOpaqueParams |
|
254 } |
|
255 |
|
256 TBool CSifOperationStep::CompareOpaqueResultsL() |
|
257 { |
|
258 if (iPluginOpaqueResults == NULL && iPluginRefOpaqueResults == NULL) |
|
259 { |
|
260 return ETrue; |
|
261 } |
|
262 else if (iPluginOpaqueResults == NULL || iPluginRefOpaqueResults == NULL) |
|
263 { |
|
264 return EFalse; |
|
265 } |
|
266 |
|
267 const TInt llen = iPluginOpaqueResults->CountL(); |
|
268 const TInt rlen = iPluginRefOpaqueResults->CountL(); |
|
269 if (llen != rlen) |
|
270 { |
|
271 INFO_PRINTF3(_L("The number of expected and returned opaque params differs. Expected: %d, returned: %d "), rlen, llen); |
|
272 return EFalse; |
|
273 } |
|
274 |
|
275 RCPointerArray<HBufC> names; |
|
276 CleanupClosePushL(names); |
|
277 iPluginOpaqueResults->GetNamesL(names); |
|
278 |
|
279 for (TInt i=0; i<llen; ++i) |
|
280 { |
|
281 const TDesC& lName = *names[i]; |
|
282 const TDesC& lValue = iPluginOpaqueResults->StringByNameL(lName); |
|
283 const TDesC& rValue = iPluginRefOpaqueResults->StringByNameL(lName); |
|
284 |
|
285 if (rValue == KTe_AnyValuePermitted && rValue != KNullDesC) |
|
286 { |
|
287 continue; |
|
288 } |
|
289 |
|
290 if (lValue.Size() != rValue.Size()) |
|
291 { |
|
292 INFO_PRINTF4(_L("Mismatch on param sizes for param %S. Expected size %d, returned size %d"), &lName, rValue.Size(), lValue.Size()); |
|
293 CleanupStack::PopAndDestroy(&names); |
|
294 return EFalse; |
|
295 } |
|
296 if (lValue.Size() != sizeof(TInt) && lValue != rValue) |
|
297 { |
|
298 INFO_PRINTF4(_L("Mismatch for string param %S. Expected %S, returned %S"), &lName, &rValue, &lValue); |
|
299 CleanupStack::PopAndDestroy(&names); |
|
300 return EFalse; |
|
301 } |
|
302 if (lValue.Size() == sizeof(TInt)) |
|
303 { |
|
304 TInt lIntValue = iPluginOpaqueResults->IntByNameL(lName); |
|
305 TInt rIntValue = iPluginRefOpaqueResults->IntByNameL(lName); |
|
306 if (lIntValue != rIntValue) |
|
307 { |
|
308 INFO_PRINTF4(_L("Mismatch for integer param %S. Expected %d, returned %d"), &lName, rIntValue, lIntValue); |
|
309 CleanupStack::PopAndDestroy(&names); |
|
310 return EFalse; |
|
311 } |
|
312 } |
|
313 } |
|
314 |
|
315 CleanupStack::PopAndDestroy(&names); |
|
316 return ETrue; |
|
317 } |
|
318 |
|
319 void CSifOperationStep::PrintOpaqueParamsL(const COpaqueNamedParams& aOpaqueParams) |
|
320 { |
|
321 RCPointerArray<HBufC> names; |
|
322 CleanupClosePushL(names); |
|
323 aOpaqueParams.GetNamesL(names); |
|
324 for (TInt i=0; i<names.Count(); ++i) |
|
325 { |
|
326 const TDesC& name = *names[i]; |
|
327 const TDesC& value = aOpaqueParams.StringByNameL(name); |
|
328 if (value.Size() == sizeof(TInt)) |
|
329 { |
|
330 const TInt intValue = aOpaqueParams.IntByNameL(name); |
|
331 INFO_PRINTF4(_L("Param: %d, Name: %S, IntValue: %d"), i, &name, intValue); |
|
332 } |
|
333 else |
|
334 { |
|
335 INFO_PRINTF4(_L("Param: %d, Name: %S, Value: %S"), i, &name, &value); |
|
336 } |
|
337 } |
|
338 CleanupStack::PopAndDestroy(&names); |
|
339 } |
|
340 |
|
341 TBool CSifOperationStep::CheckOpaqueResultsL() |
|
342 { |
|
343 if (CompareOpaqueResultsL()) |
|
344 { |
|
345 return ETrue; |
|
346 } |
|
347 |
|
348 INFO_PRINTF1(_L("==================== Begin of opaque results ====================")); |
|
349 |
|
350 if (iPluginOpaqueResults) |
|
351 { |
|
352 INFO_PRINTF1(_L("Expected opaque results:")); |
|
353 PrintOpaqueParamsL(*iPluginOpaqueResults); |
|
354 } |
|
355 |
|
356 INFO_PRINTF1(_L("-----------------------------------------------------------------")); |
|
357 |
|
358 if (iPluginRefOpaqueResults) |
|
359 { |
|
360 INFO_PRINTF1(_L("Returned opaque results:")); |
|
361 PrintOpaqueParamsL(*iPluginRefOpaqueResults); |
|
362 } |
|
363 |
|
364 INFO_PRINTF1(_L("===================== End of opaque results =====================")); |
|
365 |
|
366 return EFalse; |
|
367 } |
|
368 |
|
369 |
|
370 // ***************************************************************************************************** |
|
371 |
|
372 |
|
373 CSifGetComponentInfoStep::~CSifGetComponentInfoStep() |
|
374 /** |
|
375 * Destructor |
|
376 */ |
|
377 { |
|
378 delete iComponentInfo; |
|
379 } |
|
380 |
|
381 CSifGetComponentInfoStep::CSifGetComponentInfoStep() : iCompareMaxInstalledSize(ETrue) |
|
382 /** |
|
383 * Constructor |
|
384 */ |
|
385 { |
|
386 SetTestStepName(KSifGetComponentInfoStep); |
|
387 iconIndex = 0; |
|
388 } |
|
389 |
|
390 namespace |
|
391 { |
|
392 TInt PackCapabilitySet(const TCapabilitySet& aCapSet) |
|
393 { |
|
394 TInt caps=0; |
|
395 for (TInt c=0; c<ECapability_Limit; ++c) |
|
396 { |
|
397 if (aCapSet.HasCapability(TCapability(c))) |
|
398 { |
|
399 caps+=(1<<c); |
|
400 } |
|
401 } |
|
402 return caps; |
|
403 } |
|
404 |
|
405 void UnpackCapabilitySet(TInt aPackedCapSet, TCapabilitySet& aCapSet) |
|
406 { |
|
407 for (TInt c=0; c<ECapability_Limit; ++c) |
|
408 { |
|
409 const TInt cap = 1<<c; |
|
410 if (aPackedCapSet&cap) |
|
411 { |
|
412 aCapSet.AddCapability(TCapability(c)); |
|
413 } |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 void CSifGetComponentInfoStep::LoadComponentInfoL() |
|
419 { |
|
420 ASSERT(iComponentInfo == NULL); |
|
421 |
|
422 // Load the tree of CComponentInfo nodes |
|
423 CComponentInfo::CNode* rootNode = LoadCompInfoNodeLC(KTe_CompInfoRootNodePrefix); |
|
424 |
|
425 // Create an instance of CComponentInfo |
|
426 iComponentInfo = CComponentInfo::NewL(); |
|
427 iComponentInfo->SetRootNodeL(rootNode); |
|
428 CleanupStack::Pop(rootNode); |
|
429 } |
|
430 |
|
431 namespace |
|
432 { |
|
433 HBufC* CompInfoParamNameLC(const TDesC& aStr1, const TDesC& aStr2) |
|
434 { |
|
435 HBufC* conc = HBufC::NewLC(aStr1.Length()+aStr2.Length()+1); |
|
436 TPtr bufConc(conc->Des()); |
|
437 bufConc.Copy(aStr1); |
|
438 bufConc.Append(_L(".")); |
|
439 bufConc.Append(aStr2); |
|
440 return conc; |
|
441 } |
|
442 } |
|
443 |
|
444 TPtrC CSifGetComponentInfoStep::LoadCompInfoNodeStringParamL(const TDesC& aNodePrefix, const TDesC& aParamName) |
|
445 { |
|
446 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
447 |
|
448 TPtrC value; |
|
449 if (!GetStringFromConfig(ConfigSection(), *name, value)) |
|
450 { |
|
451 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
452 User::Leave(KErrNotFound); |
|
453 } |
|
454 |
|
455 CleanupStack::PopAndDestroy(name); |
|
456 return value; |
|
457 } |
|
458 |
|
459 TInt CSifGetComponentInfoStep::LoadCompInfoNodeIntParamL(const TDesC& aNodePrefix, const TDesC& aParamName, TBool aMandatory) |
|
460 { |
|
461 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
462 |
|
463 TInt value(0); |
|
464 if (!GetIntFromConfig(ConfigSection(), *name, value) && aMandatory) |
|
465 { |
|
466 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
467 User::Leave(KErrNotFound); |
|
468 } |
|
469 |
|
470 CleanupStack::PopAndDestroy(name); |
|
471 return value; |
|
472 } |
|
473 |
|
474 TBool CSifGetComponentInfoStep::LoadCompInfoNodeBoolParamL(const TDesC& aNodePrefix, const TDesC& aParamName, TBool aMandatory) |
|
475 { |
|
476 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
477 |
|
478 TBool value(EFalse); |
|
479 if (!GetBoolFromConfig(ConfigSection(), *name, value) && aMandatory) |
|
480 { |
|
481 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
482 User::Leave(KErrNotFound); |
|
483 } |
|
484 |
|
485 CleanupStack::PopAndDestroy(name); |
|
486 return value; |
|
487 } |
|
488 |
|
489 CComponentInfo::CNode* CSifGetComponentInfoStep::LoadCompInfoNodeLC(const TDesC& aNodeName) |
|
490 { |
|
491 TPtrC swType(LoadCompInfoNodeStringParamL(aNodeName, KTe_SoftwareTypeName)); |
|
492 TPtrC name(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentName)); |
|
493 TPtrC vendor(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentVendor)); |
|
494 TPtrC version(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentVersion)); |
|
495 TPtrC globalId(LoadCompInfoNodeStringParamL(aNodeName, KTe_GlobalComponentId)); |
|
496 |
|
497 TInt scomoState(LoadCompInfoNodeIntParamL(aNodeName, KTe_ScomoState)); |
|
498 TInt installStatus(LoadCompInfoNodeIntParamL(aNodeName, KTe_InstallStatus)); |
|
499 TInt componentId(LoadCompInfoNodeIntParamL(aNodeName, KTe_ComponentId)); |
|
500 TInt authenticity(LoadCompInfoNodeIntParamL(aNodeName, KTe_Authenticity)); |
|
501 TInt size(LoadCompInfoNodeIntParamL(aNodeName, KTe_MaxInstalledSize)); |
|
502 TBool hasexe(LoadCompInfoNodeBoolParamL(aNodeName, KTe_HasExecutable)); |
|
503 TBool driveSelectionRequired(LoadCompInfoNodeBoolParamL(aNodeName, KTe_DriveSelectionRequired)); |
|
504 TInt noOfApps(LoadCompInfoNodeIntParamL(aNodeName,KTe_NumberOfApplications)); |
|
505 |
|
506 TBuf<20> appUidTxt; |
|
507 TBuf<20> appFileNameTxt; |
|
508 TBuf<20> appGroupNameTxt; |
|
509 TBuf<20> appIconFileNameTxt; |
|
510 TBuf<20> appIconFileSize; |
|
511 const TInt MAX_INT_STR_LEN = 8; |
|
512 TBuf<MAX_INT_STR_LEN> integerAppendStr; |
|
513 RPointerArray<Usif::CComponentInfo::CApplicationInfo> applications; |
|
514 |
|
515 for(TInt index = 0; index < noOfApps ; index++) |
|
516 { |
|
517 integerAppendStr.Format(_L("%d"), index); |
|
518 appUidTxt = KTe_ApplicationUid; |
|
519 appUidTxt.Append(integerAppendStr); |
|
520 TInt val = 0; |
|
521 HBufC* name = CompInfoParamNameLC(aNodeName, appUidTxt); |
|
522 GetHexFromConfig(ConfigSection(),*name, val); |
|
523 TUid appuid = TUid::Uid(val); |
|
524 CleanupStack::PopAndDestroy(name); |
|
525 |
|
526 appFileNameTxt=KTe_ApplicationName; |
|
527 appFileNameTxt.Append(integerAppendStr); |
|
528 TPtrC appFileName(LoadCompInfoNodeStringParamL(aNodeName,appFileNameTxt)); |
|
529 |
|
530 appGroupNameTxt=KTe_ApplicationGroupName; |
|
531 appGroupNameTxt.Append(integerAppendStr); |
|
532 TPtrC appGroupName(LoadCompInfoNodeStringParamL(aNodeName,appGroupNameTxt)); |
|
533 |
|
534 appIconFileNameTxt=KTe_ApplicationIconFileName; |
|
535 appIconFileNameTxt.Append(integerAppendStr); |
|
536 TPtrC appIconFileName(LoadCompInfoNodeStringParamL(aNodeName,appIconFileNameTxt)); |
|
537 |
|
538 Usif::CComponentInfo::CApplicationInfo* app = NULL; |
|
539 app = Usif::CComponentInfo::CApplicationInfo::NewLC(appuid, appFileName, appGroupName, appIconFileName); |
|
540 |
|
541 appIconFileSize = KTe_ApplicationIconFileSize; |
|
542 appIconFileSize.Append(integerAppendStr); |
|
543 TInt fileSize(LoadCompInfoNodeIntParamL(aNodeName,appIconFileSize)); |
|
544 iIconFileSizes.Append(fileSize); |
|
545 |
|
546 applications.AppendL(app); |
|
547 CleanupStack::Pop(app); |
|
548 } |
|
549 |
|
550 |
|
551 TInt packedCaps(LoadCompInfoNodeIntParamL(aNodeName, KTe_UserGrantableCaps)); |
|
552 TCapabilitySet capSet; |
|
553 capSet.SetEmpty(); |
|
554 UnpackCapabilitySet(packedCaps, capSet); |
|
555 |
|
556 CComponentInfo::CNode* node = CComponentInfo::CNode::NewLC(swType, name, version, vendor, |
|
557 static_cast<TScomoState>(scomoState), static_cast<TInstallStatus>(installStatus), |
|
558 static_cast<TComponentId>(componentId), globalId, static_cast<TAuthenticity>(authenticity), |
|
559 capSet, size, hasexe, driveSelectionRequired, &applications); |
|
560 |
|
561 |
|
562 // Load children |
|
563 TInt numChildren(LoadCompInfoNodeIntParamL(aNodeName, KTe_CompInfoNumChildren, EFalse)); |
|
564 for (TInt i=0; i<numChildren; ++i) |
|
565 { |
|
566 HBufC* childNodeName = HBufC::NewLC(aNodeName.Length() + KTe_CompInfoChildNodePrefix.iTypeLength + KMaxIntDigits); |
|
567 TPtr childNodeNamePtr(childNodeName->Des()); |
|
568 childNodeNamePtr.Copy(aNodeName); |
|
569 childNodeNamePtr.Append(KTe_CompInfoChildNodePrefix); |
|
570 childNodeNamePtr.AppendNum(i); |
|
571 |
|
572 CComponentInfo::CNode* childNode = LoadCompInfoNodeLC(*childNodeName); |
|
573 node->AddChildL(childNode); |
|
574 CleanupStack::Pop(childNode); |
|
575 |
|
576 CleanupStack::PopAndDestroy(childNodeName); |
|
577 } |
|
578 applications.Close(); |
|
579 return node; |
|
580 } |
|
581 |
|
582 |
|
583 TBool CSifGetComponentInfoStep::CompareAppInfoL(const CComponentInfo::CNode& aExpectedNode, const CComponentInfo::CNode& aObtainedNode) |
|
584 { |
|
585 RPointerArray<Usif::CComponentInfo::CApplicationInfo> obtainedApplicationInfo; |
|
586 RPointerArray<Usif::CComponentInfo::CApplicationInfo> expectedApplicationInfo; |
|
587 obtainedApplicationInfo = aObtainedNode.Applications(); |
|
588 expectedApplicationInfo = aExpectedNode.Applications(); |
|
589 TInt obtainedApplicationInfoCount = obtainedApplicationInfo.Count(); |
|
590 TInt expectedApplicationInfoCount = expectedApplicationInfo.Count(); |
|
591 |
|
592 if(obtainedApplicationInfoCount != expectedApplicationInfoCount) |
|
593 { |
|
594 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application Info Count: %d/%d"), expectedApplicationInfoCount, obtainedApplicationInfoCount); |
|
595 return EFalse; |
|
596 } |
|
597 if(0 != expectedApplicationInfoCount) |
|
598 { |
|
599 for(TInt i=0 ; i < expectedApplicationInfoCount ; i++) |
|
600 { |
|
601 |
|
602 if(expectedApplicationInfo[i]->AppUid() != obtainedApplicationInfo[i]->AppUid()) |
|
603 { |
|
604 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application UID: 0x%08x/0x%08x"), expectedApplicationInfo[i]->AppUid(), obtainedApplicationInfo[i]->AppUid()); |
|
605 return EFalse; |
|
606 } |
|
607 |
|
608 if(expectedApplicationInfo[i]->Name().Compare(obtainedApplicationInfo[i]->Name())) |
|
609 { |
|
610 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application Name: %S/%S"), &expectedApplicationInfo[i]->Name(), &obtainedApplicationInfo[i]->Name()); |
|
611 return EFalse; |
|
612 } |
|
613 |
|
614 if(expectedApplicationInfo[i]->GroupName().Compare(obtainedApplicationInfo[i]->GroupName())) |
|
615 { |
|
616 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application Group Name: %S/%S"), &expectedApplicationInfo[i]->GroupName(), &obtainedApplicationInfo[i]->GroupName()); |
|
617 return EFalse; |
|
618 } |
|
619 |
|
620 _LIT(emtyString,""); |
|
621 if(obtainedApplicationInfo[i]->IconFileName().Compare(emtyString)) |
|
622 { |
|
623 //Opening a file server session for icon file size comparison |
|
624 RFs fs; |
|
625 User::LeaveIfError(fs.Connect()); |
|
626 CleanupClosePushL(fs); |
|
627 TEntry entry; |
|
628 User::LeaveIfError(fs.Entry(obtainedApplicationInfo[i]->IconFileName(),entry)); |
|
629 CleanupStack::Pop(&fs); |
|
630 fs.Close(); |
|
631 |
|
632 if(iCompareIconFileSize && iIconFileSizes[iconIndex++] != entry.iSize) |
|
633 { |
|
634 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application Icon File Size: %d/%d"), iIconFileSizes[--iconIndex], entry.iSize); |
|
635 return EFalse; |
|
636 } |
|
637 } |
|
638 if(expectedApplicationInfo[i]->IconFileName().Compare(obtainedApplicationInfo[i]->IconFileName())) |
|
639 { |
|
640 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Application Icon File Name: %S/%S"), &expectedApplicationInfo[i]->IconFileName(), &obtainedApplicationInfo[i]->IconFileName()); |
|
641 return EFalse; |
|
642 } |
|
643 } |
|
644 } |
|
645 return ETrue; |
|
646 } |
|
647 |
|
648 |
|
649 TBool CSifGetComponentInfoStep::CompareCompInfoNodeL(const CComponentInfo::CNode& aExpectedNode, const CComponentInfo::CNode& aObtainedNode) |
|
650 { |
|
651 INFO_PRINTF2(_L("Checking CComponentInfo for component: '%S'"), &aExpectedNode.ComponentName()); |
|
652 if (aExpectedNode.SoftwareTypeName() != aObtainedNode.SoftwareTypeName()) |
|
653 { |
|
654 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained SoftwareTypeName: '%S'/'%S'"), &aExpectedNode.SoftwareTypeName(), &aObtainedNode.SoftwareTypeName()); |
|
655 return EFalse; |
|
656 } |
|
657 |
|
658 if (aExpectedNode.ComponentName() != aObtainedNode.ComponentName()) |
|
659 { |
|
660 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ComponentName: '%S'/'%S'"), &aExpectedNode.ComponentName(), &aObtainedNode.ComponentName()); |
|
661 return EFalse; |
|
662 } |
|
663 |
|
664 if (aExpectedNode.Version() != aObtainedNode.Version()) |
|
665 { |
|
666 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Version: '%S'/'%S'"), &aExpectedNode.Version(), &aObtainedNode.Version()); |
|
667 return EFalse; |
|
668 } |
|
669 |
|
670 if (aExpectedNode.Vendor() != aObtainedNode.Vendor()) |
|
671 { |
|
672 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Vendor: '%S'/'%S'"), &aExpectedNode.Vendor(), &aObtainedNode.Vendor()); |
|
673 return EFalse; |
|
674 } |
|
675 |
|
676 if (aExpectedNode.ScomoState() != aObtainedNode.ScomoState() && aObtainedNode.InstallStatus() != EInvalid && |
|
677 aObtainedNode.InstallStatus() != ENewComponent) // SCOMO status is meaningless on non-existing components |
|
678 { |
|
679 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ScomoState: %d/%d"), aExpectedNode.ScomoState(), aObtainedNode.ScomoState()); |
|
680 return EFalse; |
|
681 } |
|
682 |
|
683 if (aExpectedNode.InstallStatus() != aObtainedNode.InstallStatus()) |
|
684 { |
|
685 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained InstallStatus: %d/%d"), aExpectedNode.InstallStatus(), aObtainedNode.InstallStatus()); |
|
686 return EFalse; |
|
687 } |
|
688 |
|
689 if (aExpectedNode.ComponentId() != aObtainedNode.ComponentId()) |
|
690 { |
|
691 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ComponentId: %d/%d"), aExpectedNode.ComponentId(), aObtainedNode.ComponentId()); |
|
692 return EFalse; |
|
693 } |
|
694 |
|
695 if (aExpectedNode.GlobalComponentId() != aObtainedNode.GlobalComponentId()) |
|
696 { |
|
697 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained GlobalComponentId: '%S'/'%S'"), &aExpectedNode.GlobalComponentId(), &aObtainedNode.GlobalComponentId()); |
|
698 return EFalse; |
|
699 } |
|
700 |
|
701 if (aExpectedNode.Authenticity() != aObtainedNode.Authenticity()) |
|
702 { |
|
703 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Authenticity: %d/%d"), aExpectedNode.Authenticity(), aObtainedNode.Authenticity()); |
|
704 return EFalse; |
|
705 } |
|
706 |
|
707 if (PackCapabilitySet(aExpectedNode.UserGrantableCaps()) != PackCapabilitySet(aObtainedNode.UserGrantableCaps())) |
|
708 { |
|
709 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained UserGrantableCaps: %d/%d"), PackCapabilitySet(aExpectedNode.UserGrantableCaps()), PackCapabilitySet(aObtainedNode.UserGrantableCaps())); |
|
710 return EFalse; |
|
711 } |
|
712 |
|
713 if (iCompareMaxInstalledSize && aExpectedNode.MaxInstalledSize() != aObtainedNode.MaxInstalledSize()) |
|
714 { |
|
715 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained MaxInstalledSize: %d/%d"), aExpectedNode.MaxInstalledSize(), aObtainedNode.MaxInstalledSize()); |
|
716 return EFalse; |
|
717 } |
|
718 if (aExpectedNode.HasExecutable() != aObtainedNode.HasExecutable()) |
|
719 { |
|
720 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Has Executable Flag: %d/%d"), aExpectedNode.HasExecutable(), aObtainedNode.HasExecutable()); |
|
721 return EFalse; |
|
722 } |
|
723 |
|
724 if (aExpectedNode.DriveSeletionRequired() != aObtainedNode.DriveSeletionRequired()) |
|
725 { |
|
726 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Drive selection required: %d/%d"), aExpectedNode.DriveSeletionRequired(), aObtainedNode.DriveSeletionRequired()); |
|
727 return EFalse; |
|
728 } |
|
729 |
|
730 if(!CompareAppInfoL(aExpectedNode, aObtainedNode)) |
|
731 { |
|
732 iIconFileSizes.Close(); |
|
733 return EFalse; |
|
734 } |
|
735 |
|
736 const RPointerArray<CComponentInfo::CNode>& expectedChildren = aExpectedNode.Children(); |
|
737 const RPointerArray<CComponentInfo::CNode>& obtainedChildren = aObtainedNode.Children(); |
|
738 if (expectedChildren.Count() != obtainedChildren.Count()) |
|
739 { |
|
740 INFO_PRINTF4(_L("CComponentInfo doesn't match: component %S has different number of embedded components, expected/obtained: %d/%d"), &aExpectedNode.ComponentName(), expectedChildren.Count(), obtainedChildren.Count()); |
|
741 return EFalse; |
|
742 } |
|
743 |
|
744 for (TInt i=0; i<expectedChildren.Count(); ++i) |
|
745 { |
|
746 const CComponentInfo::CNode& expectedChild = *expectedChildren[i]; |
|
747 const CComponentInfo::CNode& obtainedChild = *obtainedChildren[i]; |
|
748 if (!CompareCompInfoNodeL(expectedChild, obtainedChild)) |
|
749 { |
|
750 INFO_PRINTF3(_L("CComponentInfo tree comparison failed at component: %S, vendor: %S"), &aExpectedNode.ComponentName(), &aExpectedNode.Vendor()); |
|
751 return EFalse; |
|
752 } |
|
753 } |
|
754 return ETrue; |
|
755 } |
|
756 |
|
757 void CSifGetComponentInfoStep::ImplTestStepPreambleL() |
|
758 /** |
|
759 * @return - TVerdict code |
|
760 * Override of base class virtual |
|
761 */ |
|
762 { |
|
763 CSifOperationStep::ImplTestStepPreambleL(); |
|
764 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifGetComponentInfoStep")); |
|
765 |
|
766 if (TestStepResult()==EPass) |
|
767 { |
|
768 LoadFileNameFromConfigL(); |
|
769 |
|
770 LoadComponentInfoL(); |
|
771 |
|
772 GetBoolFromConfig(ConfigSection(),KTe_OperationByFileHandle, iOperationByFileHandle); |
|
773 |
|
774 GetBoolFromConfig(ConfigSection(),KTe_CompareMaxInstalledSize, iCompareMaxInstalledSize); |
|
775 |
|
776 GetBoolFromConfig(ConfigSection(),KTe_CompareIconFileSize, iCompareIconFileSize); |
|
777 } |
|
778 } |
|
779 |
|
780 |
|
781 void CSifGetComponentInfoStep::ImplTestStepL() |
|
782 /** |
|
783 * @return - TVerdict code |
|
784 * Override of base class pure virtual |
|
785 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
786 * not leave. That being the case, the current test result value will be EPass. |
|
787 */ |
|
788 { |
|
789 if (TestStepResult()!=EPass) |
|
790 { |
|
791 INFO_PRINTF1(_L("CSifGetComponentInfoStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
792 return; |
|
793 } |
|
794 |
|
795 INFO_PRINTF1(_L("In the file CSifGetComponentInfoStep::ImplTestStepL()")); |
|
796 |
|
797 CComponentInfo* compInfo = CComponentInfo::NewLC(); |
|
798 |
|
799 RFs fs; |
|
800 RFile file; |
|
801 if (iOperationByFileHandle) |
|
802 { |
|
803 User::LeaveIfError(fs.Connect()); |
|
804 fs.ShareProtected(); |
|
805 CleanupClosePushL(fs); |
|
806 User::LeaveIfError(file.Open(fs, iFileName, EFileShareReadersOnly)); |
|
807 CleanupClosePushL(file); |
|
808 |
|
809 iSif.GetComponentInfo(file, *compInfo, iStatus); |
|
810 } |
|
811 else |
|
812 { |
|
813 iSif.GetComponentInfo(iFileName, *compInfo, iStatus); |
|
814 } |
|
815 |
|
816 CancelableWait(); |
|
817 |
|
818 if (iOperationByFileHandle) |
|
819 { |
|
820 CleanupStack::PopAndDestroy(2, &fs); |
|
821 } |
|
822 |
|
823 User::LeaveIfError(iStatus.Int()); |
|
824 |
|
825 TInt err = 0; |
|
826 TRAP(err, SetTestStepResult(CompareCompInfoNodeL(iComponentInfo->RootNodeL(), compInfo->RootNodeL()) ? EPass : EFail);); |
|
827 iIconFileSizes.Close(); |
|
828 CleanupStack::PopAndDestroy(compInfo); |
|
829 } |
|
830 |
|
831 // ***************************************************************************************************** |
|
832 |
|
833 |
|
834 CSifInstallStep::~CSifInstallStep() |
|
835 /** |
|
836 * Destructor |
|
837 */ |
|
838 { |
|
839 } |
|
840 |
|
841 CSifInstallStep::CSifInstallStep() |
|
842 /** |
|
843 * Constructor |
|
844 */ |
|
845 { |
|
846 SetTestStepName(KSifInstallStep); |
|
847 } |
|
848 |
|
849 void CSifInstallStep::ImplTestStepPreambleL() |
|
850 /** |
|
851 * @return - TVerdict code |
|
852 * Override of base class virtual |
|
853 */ |
|
854 { |
|
855 CSifOperationStep::ImplTestStepPreambleL(); |
|
856 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifInstallStep")); |
|
857 } |
|
858 |
|
859 |
|
860 void CSifInstallStep::ImplTestStepL() |
|
861 /** |
|
862 * @return - TVerdict code |
|
863 * Override of base class pure virtual |
|
864 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
865 * not leave. That being the case, the current test result value will be EPass. |
|
866 */ |
|
867 { |
|
868 if (TestStepResult()!=EPass) |
|
869 { |
|
870 INFO_PRINTF1(_L("CSifInstallStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
871 return; |
|
872 } |
|
873 |
|
874 INFO_PRINTF1(_L("In the file CSifInstallStep::ImplTestStepL()")); |
|
875 |
|
876 LoadOpaqueParamsL(); |
|
877 CleanupStack::PushL(TCleanupItem(ClearOpaqueParamsCleanup, this)); |
|
878 |
|
879 LoadFileNameFromConfigL(); |
|
880 |
|
881 GetBoolFromConfig(ConfigSection(),KTe_OperationByFileHandle, iInstallByFileHandle); |
|
882 |
|
883 RFs fs; |
|
884 RFile file; |
|
885 if (iInstallByFileHandle) |
|
886 { |
|
887 User::LeaveIfError(fs.Connect()); |
|
888 fs.ShareProtected(); |
|
889 CleanupClosePushL(fs); |
|
890 User::LeaveIfError(file.Open(fs, iFileName, EFileRead | EFileShareReadersOnly)); |
|
891 CleanupClosePushL(file); |
|
892 |
|
893 if (iUseEnhancedApi) |
|
894 { |
|
895 iSif.Install(file, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
896 } |
|
897 else |
|
898 { |
|
899 iSif.Install(file, iStatus, iExclusiveOperation); |
|
900 } |
|
901 } |
|
902 else |
|
903 { |
|
904 if (iUseEnhancedApi) |
|
905 { |
|
906 iSif.Install(iFileName, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
907 } |
|
908 else |
|
909 { |
|
910 iSif.Install(iFileName, iStatus, iExclusiveOperation); |
|
911 } |
|
912 } |
|
913 |
|
914 CancelableWait(); |
|
915 |
|
916 if (iInstallByFileHandle) |
|
917 { |
|
918 CleanupStack::PopAndDestroy(2, &fs); |
|
919 } |
|
920 |
|
921 TInt err = iStatus.Int(); |
|
922 if (err != KErrNone) |
|
923 { |
|
924 INFO_PRINTF2(_L("CSifInstallStep::ImplTestStepL failed with error code = %d"), err); |
|
925 User::LeaveIfError(err); |
|
926 } |
|
927 |
|
928 TBool res = EFalse; |
|
929 TRAP(err, res = CompareOpaqueResultsL()); |
|
930 if (err != KErrNoMemory) |
|
931 User::Leave(err); // Do not treat OOM errors as fatal by this point - otherwise OOM tests will atempt to uninstall the component again after uninstall has completed |
|
932 |
|
933 if (err == KErrNoMemory) // Handling KErrNoMemory as it is done purposefully as part of OOM Test |
|
934 SetTestStepResult(EPass); |
|
935 else if (!res) |
|
936 { |
|
937 SetTestStepResult(EFail); |
|
938 INFO_PRINTF1(_L("CSifInstallStep::ImplTestStepL failed because of CompareOpaqueResultsL")); |
|
939 INFO_PRINTF1(_L("=================== Begin of Received Opaque Results ===================")); |
|
940 PrintOpaqueParamsL(*iPluginOpaqueResults); |
|
941 INFO_PRINTF1(_L("=================== End of Received Opaque Results ===================")); |
|
942 INFO_PRINTF1(_L("=================== Begin of Expected Opaque Results ===================")); |
|
943 PrintOpaqueParamsL(*iPluginRefOpaqueResults); |
|
944 INFO_PRINTF1(_L("=================== End of Expected Opaque Results ===================")); |
|
945 } |
|
946 CleanupStack::PopAndDestroy(); //ClearOpaqueParamsCleanup |
|
947 } |
|
948 |
|
949 // ***************************************************************************************************** |
|
950 |
|
951 |
|
952 CSifUninstallStep::~CSifUninstallStep() |
|
953 /** |
|
954 * Destructor |
|
955 */ |
|
956 { |
|
957 } |
|
958 |
|
959 CSifUninstallStep::CSifUninstallStep() |
|
960 /** |
|
961 * Constructor |
|
962 */ |
|
963 { |
|
964 SetTestStepName(KSifUninstallStep); |
|
965 } |
|
966 |
|
967 void CSifUninstallStep::ImplTestStepPreambleL() |
|
968 /** |
|
969 * @return - TVerdict code |
|
970 * Override of base class virtual |
|
971 */ |
|
972 { |
|
973 CSifOperationStep::ImplTestStepPreambleL(); |
|
974 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifUninstallStep")); |
|
975 |
|
976 LoadComponentIdFromConfigL(); |
|
977 } |
|
978 |
|
979 void CSifUninstallStep::ImplTestStepL() |
|
980 /** |
|
981 * @return - TVerdict code |
|
982 * Override of base class pure virtual |
|
983 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
984 * not leave. That being the case, the current test result value will be EPass. |
|
985 */ |
|
986 { |
|
987 INFO_PRINTF1(_L("In the file CSifUninstallStep::ImplTestStepL()")); //Block start |
|
988 LoadOpaqueParamsL(); |
|
989 CleanupStack::PushL(TCleanupItem(ClearOpaqueParamsCleanup, this)); |
|
990 |
|
991 if (iUseEnhancedApi) |
|
992 { |
|
993 iSif.Uninstall(iComponentId, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
994 } |
|
995 else |
|
996 { |
|
997 iSif.Uninstall(iComponentId, iStatus, iExclusiveOperation); |
|
998 } |
|
999 |
|
1000 CancelableWait(); |
|
1001 |
|
1002 User::LeaveIfError(iStatus.Int()); |
|
1003 |
|
1004 TBool res = EFalse; |
|
1005 TRAPD(err, res = CompareOpaqueResultsL()); |
|
1006 if (err != KErrNoMemory) |
|
1007 User::Leave(err); // Do not treat OOM errors as fatal by this point - otherwise OOM tests will atempt to uninstall the component again after uninstall has completed |
|
1008 |
|
1009 if (err == KErrNoMemory) // Handling KErrNoMemory as it is done purposefully as part of OOM Test |
|
1010 SetTestStepResult(EPass); |
|
1011 else if (!res) |
|
1012 SetTestStepResult(EFail); |
|
1013 |
|
1014 CleanupStack::PopAndDestroy(); //ClearOpaqueParamsCleanup |
|
1015 } |
|
1016 |
|
1017 // ***************************************************************************************************** |
|
1018 |
|
1019 |
|
1020 CSifActivateStep::CSifActivateStep(TBool aActivate): iActivate(aActivate) |
|
1021 { |
|
1022 SetTestStepName(KSifActivateStep); |
|
1023 } |
|
1024 |
|
1025 CSifActivateStep::~CSifActivateStep() |
|
1026 { |
|
1027 } |
|
1028 |
|
1029 void CSifActivateStep::ImplTestStepPreambleL() |
|
1030 /** |
|
1031 * @return - TVerdict code |
|
1032 * Override of base class virtual |
|
1033 */ |
|
1034 { |
|
1035 CSifOperationStep::ImplTestStepPreambleL(); |
|
1036 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifActivateStep")); |
|
1037 |
|
1038 if (TestStepResult()==EPass) |
|
1039 { |
|
1040 LoadComponentIdFromConfigL(); |
|
1041 } |
|
1042 |
|
1043 } |
|
1044 |
|
1045 void CSifActivateStep::ImplTestStepL() |
|
1046 /** |
|
1047 * @return - TVerdict code |
|
1048 * Override of base class pure virtual |
|
1049 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
1050 * not leave. That being the case, the current test result value will be EPass. |
|
1051 */ |
|
1052 { |
|
1053 INFO_PRINTF1(_L("In the file CSifActivateStep::ImplTestStepL()")); |
|
1054 |
|
1055 if (iActivate) |
|
1056 { |
|
1057 iSif.Activate(iComponentId, iStatus); |
|
1058 } |
|
1059 else |
|
1060 { |
|
1061 iSif.Deactivate(iComponentId, iStatus); |
|
1062 } |
|
1063 |
|
1064 CancelableWait(); |
|
1065 |
|
1066 User::LeaveIfError(iStatus.Int()); |
|
1067 |
|
1068 if (!CompareOpaqueResultsL()) |
|
1069 SetTestStepResult(EFail); |
|
1070 } |
|
1071 |
|
1072 /** |
|
1073 * This test step implements verification of concurrent operations. |
|
1074 */ |
|
1075 |
|
1076 CSifMultipleInstallStep::~CSifMultipleInstallStep() |
|
1077 /** |
|
1078 * Destructor |
|
1079 */ |
|
1080 { |
|
1081 } |
|
1082 |
|
1083 CSifMultipleInstallStep::CSifMultipleInstallStep() |
|
1084 /** |
|
1085 * Constructor |
|
1086 */ |
|
1087 { |
|
1088 SetTestStepName(KSifMultipleInstallStep); |
|
1089 } |
|
1090 |
|
1091 void CSifMultipleInstallStep::ImplTestStepPreambleL() |
|
1092 /** |
|
1093 * @return - TVerdict code |
|
1094 * Override of base class virtual |
|
1095 */ |
|
1096 { |
|
1097 INFO_PRINTF1(_L("This is TestStepPreamble method of class CSifMultipleInstallStep")); |
|
1098 |
|
1099 LoadFileNameFromConfigL(); |
|
1100 LoadExclusiveOperationFlagFromConfigL(); |
|
1101 } |
|
1102 |
|
1103 void CSifMultipleInstallStep::ImplTestStepL() |
|
1104 { |
|
1105 INFO_PRINTF1(_L("In the file CSifMultipleInstallStep::ImplTestStepL()")); |
|
1106 LoadOpaqueParamsL(); |
|
1107 |
|
1108 if (TestStepResult()!=EPass) |
|
1109 { |
|
1110 INFO_PRINTF1(_L("CSifMultipleInstallStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
1111 return; |
|
1112 } |
|
1113 |
|
1114 TInt expectedConcurrentResult = 0; |
|
1115 TInt overlapRequest = EFalse; |
|
1116 if (!GetIntFromConfig(ConfigSection(), KTe_ExpectedConcurrentResult, expectedConcurrentResult) || |
|
1117 !GetBoolFromConfig(ConfigSection(), KTe_OverlapRequest, overlapRequest)) |
|
1118 { |
|
1119 INFO_PRINTF3(_L("Expected test parameters: %S or %S not found "), &KTe_ExpectedConcurrentResult, &KTe_OverlapRequest); |
|
1120 User::Leave(KErrNotFound); |
|
1121 } |
|
1122 |
|
1123 /* First installation request */ |
|
1124 RSoftwareInstall sif1; |
|
1125 TInt error = sif1.Connect(); |
|
1126 if (error != KErrNone) |
|
1127 { |
|
1128 INFO_PRINTF2(_L("Failed to connect to the SIF server, error code: %d"), error); |
|
1129 User::Leave(error); |
|
1130 } |
|
1131 CleanupClosePushL(sif1); |
|
1132 |
|
1133 TRequestStatus status1; |
|
1134 sif1.Install(iFileName, status1); |
|
1135 |
|
1136 if (!overlapRequest) |
|
1137 { |
|
1138 User::WaitForRequest(status1); |
|
1139 } |
|
1140 |
|
1141 /* Second installation request */ |
|
1142 |
|
1143 // Use different file name if provided |
|
1144 TPtrC fileName2; |
|
1145 if (!GetStringFromConfig(ConfigSection(), _L("packageFile2"), fileName2)) |
|
1146 { |
|
1147 fileName2.Set(iFileName); |
|
1148 } |
|
1149 |
|
1150 RSoftwareInstall sif2; |
|
1151 error = sif2.Connect(); |
|
1152 if (error != KErrNone) |
|
1153 { |
|
1154 INFO_PRINTF2(_L("Failed to connect to the SIF server, error code: %d"), error); |
|
1155 User::Leave(error); |
|
1156 } |
|
1157 CleanupClosePushL(sif2); |
|
1158 |
|
1159 TRequestStatus status2; |
|
1160 |
|
1161 if (iUseEnhancedApi) |
|
1162 { |
|
1163 sif2.Install(fileName2, *iPluginOpaqueArguments, *iPluginOpaqueResults, status2, iExclusiveOperation); |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 sif2.Install(fileName2, status2, iExclusiveOperation); |
|
1168 } |
|
1169 |
|
1170 if (overlapRequest) |
|
1171 { |
|
1172 User::WaitForRequest(status1); |
|
1173 } |
|
1174 |
|
1175 User::WaitForRequest(status2); |
|
1176 |
|
1177 //close both the sessions at the end. |
|
1178 CleanupStack::PopAndDestroy(2, &sif1); |
|
1179 |
|
1180 if(status2 != expectedConcurrentResult) |
|
1181 { |
|
1182 INFO_PRINTF3(_L("status2: %d expectedResult1: %d"), status2.Int(), expectedConcurrentResult); |
|
1183 SetTestStepResult(EFail); |
|
1184 } |
|
1185 User::LeaveIfError(status1.Int()); |
|
1186 } |