|
1 /* |
|
2 * Copyright (c) 2008-2009 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 } |
|
388 |
|
389 namespace |
|
390 { |
|
391 TInt PackCapabilitySet(const TCapabilitySet& aCapSet) |
|
392 { |
|
393 TInt caps=0; |
|
394 for (TInt c=0; c<ECapability_Limit; ++c) |
|
395 { |
|
396 if (aCapSet.HasCapability(TCapability(c))) |
|
397 { |
|
398 caps+=(1<<c); |
|
399 } |
|
400 } |
|
401 return caps; |
|
402 } |
|
403 |
|
404 void UnpackCapabilitySet(TInt aPackedCapSet, TCapabilitySet& aCapSet) |
|
405 { |
|
406 for (TInt c=0; c<ECapability_Limit; ++c) |
|
407 { |
|
408 const TInt cap = 1<<c; |
|
409 if (aPackedCapSet&cap) |
|
410 { |
|
411 aCapSet.AddCapability(TCapability(c)); |
|
412 } |
|
413 } |
|
414 } |
|
415 } |
|
416 |
|
417 void CSifGetComponentInfoStep::LoadComponentInfoL() |
|
418 { |
|
419 ASSERT(iComponentInfo == NULL); |
|
420 |
|
421 // Load the tree of CComponentInfo nodes |
|
422 CComponentInfo::CNode* rootNode = LoadCompInfoNodeLC(KTe_CompInfoRootNodePrefix); |
|
423 |
|
424 // Create an instance of CComponentInfo |
|
425 iComponentInfo = CComponentInfo::NewL(); |
|
426 iComponentInfo->SetRootNodeL(rootNode); |
|
427 CleanupStack::Pop(rootNode); |
|
428 } |
|
429 |
|
430 namespace |
|
431 { |
|
432 HBufC* CompInfoParamNameLC(const TDesC& aStr1, const TDesC& aStr2) |
|
433 { |
|
434 HBufC* conc = HBufC::NewLC(aStr1.Length()+aStr2.Length()+1); |
|
435 TPtr bufConc(conc->Des()); |
|
436 bufConc.Copy(aStr1); |
|
437 bufConc.Append(_L(".")); |
|
438 bufConc.Append(aStr2); |
|
439 return conc; |
|
440 } |
|
441 } |
|
442 |
|
443 TPtrC CSifGetComponentInfoStep::LoadCompInfoNodeStringParamL(const TDesC& aNodePrefix, const TDesC& aParamName) |
|
444 { |
|
445 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
446 |
|
447 TPtrC value; |
|
448 if (!GetStringFromConfig(ConfigSection(), *name, value)) |
|
449 { |
|
450 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
451 User::Leave(KErrNotFound); |
|
452 } |
|
453 |
|
454 CleanupStack::PopAndDestroy(name); |
|
455 return value; |
|
456 } |
|
457 |
|
458 TInt CSifGetComponentInfoStep::LoadCompInfoNodeIntParamL(const TDesC& aNodePrefix, const TDesC& aParamName, TBool aMandatory) |
|
459 { |
|
460 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
461 |
|
462 TInt value(0); |
|
463 if (!GetIntFromConfig(ConfigSection(), *name, value) && aMandatory) |
|
464 { |
|
465 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
466 User::Leave(KErrNotFound); |
|
467 } |
|
468 |
|
469 CleanupStack::PopAndDestroy(name); |
|
470 return value; |
|
471 } |
|
472 |
|
473 TBool CSifGetComponentInfoStep::LoadCompInfoNodeBoolParamL(const TDesC& aNodePrefix, const TDesC& aParamName, TBool aMandatory) |
|
474 { |
|
475 HBufC* name = CompInfoParamNameLC(aNodePrefix, aParamName); |
|
476 |
|
477 TBool value(EFalse); |
|
478 if (!GetBoolFromConfig(ConfigSection(), *name, value) && aMandatory) |
|
479 { |
|
480 INFO_PRINTF2(_L("ComponentInfo param: %S not found in the ini file"), name); |
|
481 User::Leave(KErrNotFound); |
|
482 } |
|
483 |
|
484 CleanupStack::PopAndDestroy(name); |
|
485 return value; |
|
486 } |
|
487 |
|
488 CComponentInfo::CNode* CSifGetComponentInfoStep::LoadCompInfoNodeLC(const TDesC& aNodeName) |
|
489 { |
|
490 TPtrC swType(LoadCompInfoNodeStringParamL(aNodeName, KTe_SoftwareTypeName)); |
|
491 TPtrC name(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentName)); |
|
492 TPtrC vendor(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentVendor)); |
|
493 TPtrC version(LoadCompInfoNodeStringParamL(aNodeName, KTe_ComponentVersion)); |
|
494 TPtrC globalId(LoadCompInfoNodeStringParamL(aNodeName, KTe_GlobalComponentId)); |
|
495 |
|
496 TInt scomoState(LoadCompInfoNodeIntParamL(aNodeName, KTe_ScomoState)); |
|
497 TInt installStatus(LoadCompInfoNodeIntParamL(aNodeName, KTe_InstallStatus)); |
|
498 TInt componentId(LoadCompInfoNodeIntParamL(aNodeName, KTe_ComponentId)); |
|
499 TInt authenticity(LoadCompInfoNodeIntParamL(aNodeName, KTe_Authenticity)); |
|
500 TInt size(LoadCompInfoNodeIntParamL(aNodeName, KTe_MaxInstalledSize)); |
|
501 TBool hasexe(LoadCompInfoNodeBoolParamL(aNodeName, KTe_HasExecutable)); |
|
502 |
|
503 TInt packedCaps(LoadCompInfoNodeIntParamL(aNodeName, KTe_UserGrantableCaps)); |
|
504 TCapabilitySet capSet; |
|
505 capSet.SetEmpty(); |
|
506 UnpackCapabilitySet(packedCaps, capSet); |
|
507 |
|
508 CComponentInfo::CNode* node = CComponentInfo::CNode::NewLC(swType, name, version, vendor, |
|
509 static_cast<TScomoState>(scomoState), static_cast<TInstallStatus>(installStatus), |
|
510 static_cast<TComponentId>(componentId), globalId, static_cast<TAuthenticity>(authenticity), |
|
511 capSet, size, hasexe); |
|
512 |
|
513 // Load children |
|
514 TInt numChildren(LoadCompInfoNodeIntParamL(aNodeName, KTe_CompInfoNumChildren, EFalse)); |
|
515 for (TInt i=0; i<numChildren; ++i) |
|
516 { |
|
517 HBufC* childNodeName = HBufC::NewLC(aNodeName.Length() + KTe_CompInfoChildNodePrefix.iTypeLength + KMaxIntDigits); |
|
518 TPtr childNodeNamePtr(childNodeName->Des()); |
|
519 childNodeNamePtr.Copy(aNodeName); |
|
520 childNodeNamePtr.Append(KTe_CompInfoChildNodePrefix); |
|
521 childNodeNamePtr.AppendNum(i); |
|
522 |
|
523 CComponentInfo::CNode* childNode = LoadCompInfoNodeLC(*childNodeName); |
|
524 node->AddChildL(childNode); |
|
525 CleanupStack::Pop(childNode); |
|
526 |
|
527 CleanupStack::PopAndDestroy(childNodeName); |
|
528 } |
|
529 |
|
530 return node; |
|
531 } |
|
532 |
|
533 TBool CSifGetComponentInfoStep::CompareCompInfoNodeL(const CComponentInfo::CNode& aExpectedNode, const CComponentInfo::CNode& aObtainedNode) |
|
534 { |
|
535 INFO_PRINTF2(_L("Checking CComponentInfo for component: '%S'"), &aExpectedNode.ComponentName()); |
|
536 if (aExpectedNode.SoftwareTypeName() != aObtainedNode.SoftwareTypeName()) |
|
537 { |
|
538 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained SoftwareTypeName: '%S'/'%S'"), &aExpectedNode.SoftwareTypeName(), &aObtainedNode.SoftwareTypeName()); |
|
539 return EFalse; |
|
540 } |
|
541 |
|
542 if (aExpectedNode.ComponentName() != aObtainedNode.ComponentName()) |
|
543 { |
|
544 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ComponentName: '%S'/'%S'"), &aExpectedNode.ComponentName(), &aObtainedNode.ComponentName()); |
|
545 return EFalse; |
|
546 } |
|
547 |
|
548 if (aExpectedNode.Version() != aObtainedNode.Version()) |
|
549 { |
|
550 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Version: '%S'/'%S'"), &aExpectedNode.Version(), &aObtainedNode.Version()); |
|
551 return EFalse; |
|
552 } |
|
553 |
|
554 if (aExpectedNode.Vendor() != aObtainedNode.Vendor()) |
|
555 { |
|
556 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Vendor: '%S'/'%S'"), &aExpectedNode.Vendor(), &aObtainedNode.Vendor()); |
|
557 return EFalse; |
|
558 } |
|
559 |
|
560 if (aExpectedNode.ScomoState() != aObtainedNode.ScomoState() && aObtainedNode.InstallStatus() != EInvalid && |
|
561 aObtainedNode.InstallStatus() != ENewComponent) // SCOMO status is meaningless on non-existing components |
|
562 { |
|
563 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ScomoState: %d/%d"), aExpectedNode.ScomoState(), aObtainedNode.ScomoState()); |
|
564 return EFalse; |
|
565 } |
|
566 |
|
567 if (aExpectedNode.InstallStatus() != aObtainedNode.InstallStatus()) |
|
568 { |
|
569 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained InstallStatus: %d/%d"), aExpectedNode.InstallStatus(), aObtainedNode.InstallStatus()); |
|
570 return EFalse; |
|
571 } |
|
572 |
|
573 if (aExpectedNode.ComponentId() != aObtainedNode.ComponentId()) |
|
574 { |
|
575 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained ComponentId: %d/%d"), aExpectedNode.ComponentId(), aObtainedNode.ComponentId()); |
|
576 return EFalse; |
|
577 } |
|
578 |
|
579 if (aExpectedNode.GlobalComponentId() != aObtainedNode.GlobalComponentId()) |
|
580 { |
|
581 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained GlobalComponentId: '%S'/'%S'"), &aExpectedNode.GlobalComponentId(), &aObtainedNode.GlobalComponentId()); |
|
582 return EFalse; |
|
583 } |
|
584 |
|
585 if (aExpectedNode.Authenticity() != aObtainedNode.Authenticity()) |
|
586 { |
|
587 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Authenticity: %d/%d"), aExpectedNode.Authenticity(), aObtainedNode.Authenticity()); |
|
588 return EFalse; |
|
589 } |
|
590 |
|
591 if (PackCapabilitySet(aExpectedNode.UserGrantableCaps()) != PackCapabilitySet(aObtainedNode.UserGrantableCaps())) |
|
592 { |
|
593 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained UserGrantableCaps: %d/%d"), PackCapabilitySet(aExpectedNode.UserGrantableCaps()), PackCapabilitySet(aObtainedNode.UserGrantableCaps())); |
|
594 return EFalse; |
|
595 } |
|
596 |
|
597 if (iCompareMaxInstalledSize && aExpectedNode.MaxInstalledSize() != aObtainedNode.MaxInstalledSize()) |
|
598 { |
|
599 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained MaxInstalledSize: %d/%d"), aExpectedNode.MaxInstalledSize(), aObtainedNode.MaxInstalledSize()); |
|
600 return EFalse; |
|
601 } |
|
602 if (aExpectedNode.HasExecutable() != aObtainedNode.HasExecutable()) |
|
603 { |
|
604 INFO_PRINTF3(_L("CComponentInfo doesn't match: expected/obtained Has Executable Flag: %d/%d"), aExpectedNode.HasExecutable(), aObtainedNode.HasExecutable()); |
|
605 return EFalse; |
|
606 } |
|
607 |
|
608 const RPointerArray<CComponentInfo::CNode>& expectedChildren = aExpectedNode.Children(); |
|
609 const RPointerArray<CComponentInfo::CNode>& obtainedChildren = aObtainedNode.Children(); |
|
610 if (expectedChildren.Count() != obtainedChildren.Count()) |
|
611 { |
|
612 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()); |
|
613 return EFalse; |
|
614 } |
|
615 |
|
616 for (TInt i=0; i<expectedChildren.Count(); ++i) |
|
617 { |
|
618 const CComponentInfo::CNode& expectedChild = *expectedChildren[i]; |
|
619 const CComponentInfo::CNode& obtainedChild = *obtainedChildren[i]; |
|
620 if (!CompareCompInfoNodeL(expectedChild, obtainedChild)) |
|
621 { |
|
622 INFO_PRINTF3(_L("CComponentInfo tree comparison failed at component: %S, vendor: %S"), &aExpectedNode.ComponentName(), &aExpectedNode.Vendor()); |
|
623 return EFalse; |
|
624 } |
|
625 } |
|
626 |
|
627 return ETrue; |
|
628 } |
|
629 |
|
630 void CSifGetComponentInfoStep::ImplTestStepPreambleL() |
|
631 /** |
|
632 * @return - TVerdict code |
|
633 * Override of base class virtual |
|
634 */ |
|
635 { |
|
636 CSifOperationStep::ImplTestStepPreambleL(); |
|
637 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifGetComponentInfoStep")); |
|
638 |
|
639 if (TestStepResult()==EPass) |
|
640 { |
|
641 LoadFileNameFromConfigL(); |
|
642 |
|
643 LoadComponentInfoL(); |
|
644 |
|
645 GetBoolFromConfig(ConfigSection(),KTe_OperationByFileHandle, iOperationByFileHandle); |
|
646 |
|
647 GetBoolFromConfig(ConfigSection(),KTe_CompareMaxInstalledSize, iCompareMaxInstalledSize); |
|
648 } |
|
649 } |
|
650 |
|
651 |
|
652 void CSifGetComponentInfoStep::ImplTestStepL() |
|
653 /** |
|
654 * @return - TVerdict code |
|
655 * Override of base class pure virtual |
|
656 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
657 * not leave. That being the case, the current test result value will be EPass. |
|
658 */ |
|
659 { |
|
660 if (TestStepResult()!=EPass) |
|
661 { |
|
662 INFO_PRINTF1(_L("CSifGetComponentInfoStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
663 return; |
|
664 } |
|
665 |
|
666 INFO_PRINTF1(_L("In the file CSifGetComponentInfoStep::ImplTestStepL()")); |
|
667 |
|
668 CComponentInfo* compInfo = CComponentInfo::NewLC(); |
|
669 |
|
670 RFs fs; |
|
671 RFile file; |
|
672 if (iOperationByFileHandle) |
|
673 { |
|
674 User::LeaveIfError(fs.Connect()); |
|
675 fs.ShareProtected(); |
|
676 CleanupClosePushL(fs); |
|
677 User::LeaveIfError(file.Open(fs, iFileName, EFileShareReadersOnly)); |
|
678 CleanupClosePushL(file); |
|
679 |
|
680 iSif.GetComponentInfo(file, *compInfo, iStatus); |
|
681 } |
|
682 else |
|
683 { |
|
684 iSif.GetComponentInfo(iFileName, *compInfo, iStatus); |
|
685 } |
|
686 |
|
687 CancelableWait(); |
|
688 |
|
689 if (iOperationByFileHandle) |
|
690 { |
|
691 CleanupStack::PopAndDestroy(2, &fs); |
|
692 } |
|
693 |
|
694 User::LeaveIfError(iStatus.Int()); |
|
695 |
|
696 SetTestStepResult(CompareCompInfoNodeL(iComponentInfo->RootNodeL(), compInfo->RootNodeL()) ? EPass : EFail); |
|
697 |
|
698 CleanupStack::PopAndDestroy(compInfo); |
|
699 } |
|
700 |
|
701 // ***************************************************************************************************** |
|
702 |
|
703 |
|
704 CSifInstallStep::~CSifInstallStep() |
|
705 /** |
|
706 * Destructor |
|
707 */ |
|
708 { |
|
709 } |
|
710 |
|
711 CSifInstallStep::CSifInstallStep() |
|
712 /** |
|
713 * Constructor |
|
714 */ |
|
715 { |
|
716 SetTestStepName(KSifInstallStep); |
|
717 } |
|
718 |
|
719 void CSifInstallStep::ImplTestStepPreambleL() |
|
720 /** |
|
721 * @return - TVerdict code |
|
722 * Override of base class virtual |
|
723 */ |
|
724 { |
|
725 CSifOperationStep::ImplTestStepPreambleL(); |
|
726 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifInstallStep")); |
|
727 } |
|
728 |
|
729 |
|
730 void CSifInstallStep::ImplTestStepL() |
|
731 /** |
|
732 * @return - TVerdict code |
|
733 * Override of base class pure virtual |
|
734 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
735 * not leave. That being the case, the current test result value will be EPass. |
|
736 */ |
|
737 { |
|
738 if (TestStepResult()!=EPass) |
|
739 { |
|
740 INFO_PRINTF1(_L("CSifInstallStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
741 return; |
|
742 } |
|
743 |
|
744 INFO_PRINTF1(_L("In the file CSifInstallStep::ImplTestStepL()")); |
|
745 |
|
746 LoadOpaqueParamsL(); |
|
747 CleanupStack::PushL(TCleanupItem(ClearOpaqueParamsCleanup, this)); |
|
748 |
|
749 LoadFileNameFromConfigL(); |
|
750 |
|
751 GetBoolFromConfig(ConfigSection(),KTe_OperationByFileHandle, iInstallByFileHandle); |
|
752 |
|
753 RFs fs; |
|
754 RFile file; |
|
755 if (iInstallByFileHandle) |
|
756 { |
|
757 User::LeaveIfError(fs.Connect()); |
|
758 fs.ShareProtected(); |
|
759 CleanupClosePushL(fs); |
|
760 User::LeaveIfError(file.Open(fs, iFileName, EFileRead | EFileShareReadersOnly)); |
|
761 CleanupClosePushL(file); |
|
762 |
|
763 if (iUseEnhancedApi) |
|
764 { |
|
765 iSif.Install(file, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
766 } |
|
767 else |
|
768 { |
|
769 iSif.Install(file, iStatus, iExclusiveOperation); |
|
770 } |
|
771 } |
|
772 else |
|
773 { |
|
774 if (iUseEnhancedApi) |
|
775 { |
|
776 iSif.Install(iFileName, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
777 } |
|
778 else |
|
779 { |
|
780 iSif.Install(iFileName, iStatus, iExclusiveOperation); |
|
781 } |
|
782 } |
|
783 |
|
784 CancelableWait(); |
|
785 |
|
786 if (iInstallByFileHandle) |
|
787 { |
|
788 CleanupStack::PopAndDestroy(2, &fs); |
|
789 } |
|
790 |
|
791 TInt err = iStatus.Int(); |
|
792 if (err != KErrNone) |
|
793 { |
|
794 INFO_PRINTF2(_L("CSifInstallStep::ImplTestStepL failed with error code = %d"), err); |
|
795 User::LeaveIfError(err); |
|
796 } |
|
797 |
|
798 TBool res = EFalse; |
|
799 TRAP(err, res = CompareOpaqueResultsL()); |
|
800 if (err != KErrNoMemory) |
|
801 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 |
|
802 |
|
803 if (err == KErrNoMemory) // Handling KErrNoMemory as it is done purposefully as part of OOM Test |
|
804 SetTestStepResult(EPass); |
|
805 else if (!res) |
|
806 { |
|
807 SetTestStepResult(EFail); |
|
808 INFO_PRINTF1(_L("CSifInstallStep::ImplTestStepL failed because of CompareOpaqueResultsL")); |
|
809 INFO_PRINTF1(_L("=================== Begin of Received Opaque Results ===================")); |
|
810 PrintOpaqueParamsL(*iPluginOpaqueResults); |
|
811 INFO_PRINTF1(_L("=================== End of Received Opaque Results ===================")); |
|
812 INFO_PRINTF1(_L("=================== Begin of Expected Opaque Results ===================")); |
|
813 PrintOpaqueParamsL(*iPluginRefOpaqueResults); |
|
814 INFO_PRINTF1(_L("=================== End of Expected Opaque Results ===================")); |
|
815 } |
|
816 CleanupStack::PopAndDestroy(); //ClearOpaqueParamsCleanup |
|
817 } |
|
818 |
|
819 // ***************************************************************************************************** |
|
820 |
|
821 |
|
822 CSifUninstallStep::~CSifUninstallStep() |
|
823 /** |
|
824 * Destructor |
|
825 */ |
|
826 { |
|
827 } |
|
828 |
|
829 CSifUninstallStep::CSifUninstallStep() |
|
830 /** |
|
831 * Constructor |
|
832 */ |
|
833 { |
|
834 SetTestStepName(KSifUninstallStep); |
|
835 } |
|
836 |
|
837 void CSifUninstallStep::ImplTestStepPreambleL() |
|
838 /** |
|
839 * @return - TVerdict code |
|
840 * Override of base class virtual |
|
841 */ |
|
842 { |
|
843 CSifOperationStep::ImplTestStepPreambleL(); |
|
844 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifUninstallStep")); |
|
845 |
|
846 LoadComponentIdFromConfigL(); |
|
847 } |
|
848 |
|
849 void CSifUninstallStep::ImplTestStepL() |
|
850 /** |
|
851 * @return - TVerdict code |
|
852 * Override of base class pure virtual |
|
853 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
854 * not leave. That being the case, the current test result value will be EPass. |
|
855 */ |
|
856 { |
|
857 INFO_PRINTF1(_L("In the file CSifUninstallStep::ImplTestStepL()")); //Block start |
|
858 LoadOpaqueParamsL(); |
|
859 CleanupStack::PushL(TCleanupItem(ClearOpaqueParamsCleanup, this)); |
|
860 |
|
861 if (iUseEnhancedApi) |
|
862 { |
|
863 iSif.Uninstall(iComponentId, *iPluginOpaqueArguments, *iPluginOpaqueResults, iStatus, iExclusiveOperation); |
|
864 } |
|
865 else |
|
866 { |
|
867 iSif.Uninstall(iComponentId, iStatus, iExclusiveOperation); |
|
868 } |
|
869 |
|
870 CancelableWait(); |
|
871 |
|
872 User::LeaveIfError(iStatus.Int()); |
|
873 |
|
874 TBool res = EFalse; |
|
875 TRAPD(err, res = CompareOpaqueResultsL()); |
|
876 if (err != KErrNoMemory) |
|
877 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 |
|
878 |
|
879 if (err == KErrNoMemory) // Handling KErrNoMemory as it is done purposefully as part of OOM Test |
|
880 SetTestStepResult(EPass); |
|
881 else if (!res) |
|
882 SetTestStepResult(EFail); |
|
883 |
|
884 CleanupStack::PopAndDestroy(); //ClearOpaqueParamsCleanup |
|
885 } |
|
886 |
|
887 // ***************************************************************************************************** |
|
888 |
|
889 |
|
890 CSifActivateStep::CSifActivateStep(TBool aActivate): iActivate(aActivate) |
|
891 { |
|
892 SetTestStepName(KSifActivateStep); |
|
893 } |
|
894 |
|
895 CSifActivateStep::~CSifActivateStep() |
|
896 { |
|
897 } |
|
898 |
|
899 void CSifActivateStep::ImplTestStepPreambleL() |
|
900 /** |
|
901 * @return - TVerdict code |
|
902 * Override of base class virtual |
|
903 */ |
|
904 { |
|
905 CSifOperationStep::ImplTestStepPreambleL(); |
|
906 INFO_PRINTF1(_L("I am in Test Step Preamble in Class CSifActivateStep")); |
|
907 |
|
908 if (TestStepResult()==EPass) |
|
909 { |
|
910 LoadComponentIdFromConfigL(); |
|
911 } |
|
912 |
|
913 } |
|
914 |
|
915 void CSifActivateStep::ImplTestStepL() |
|
916 /** |
|
917 * @return - TVerdict code |
|
918 * Override of base class pure virtual |
|
919 * Our implementation only gets called if the base class ImplTestStepPreambleL() did |
|
920 * not leave. That being the case, the current test result value will be EPass. |
|
921 */ |
|
922 { |
|
923 INFO_PRINTF1(_L("In the file CSifActivateStep::ImplTestStepL()")); |
|
924 |
|
925 if (iActivate) |
|
926 { |
|
927 iSif.Activate(iComponentId, iStatus); |
|
928 } |
|
929 else |
|
930 { |
|
931 iSif.Deactivate(iComponentId, iStatus); |
|
932 } |
|
933 |
|
934 CancelableWait(); |
|
935 |
|
936 User::LeaveIfError(iStatus.Int()); |
|
937 |
|
938 if (!CompareOpaqueResultsL()) |
|
939 SetTestStepResult(EFail); |
|
940 } |
|
941 |
|
942 /** |
|
943 * This test step implements verification of concurrent operations. |
|
944 */ |
|
945 |
|
946 CSifMultipleInstallStep::~CSifMultipleInstallStep() |
|
947 /** |
|
948 * Destructor |
|
949 */ |
|
950 { |
|
951 } |
|
952 |
|
953 CSifMultipleInstallStep::CSifMultipleInstallStep() |
|
954 /** |
|
955 * Constructor |
|
956 */ |
|
957 { |
|
958 SetTestStepName(KSifMultipleInstallStep); |
|
959 } |
|
960 |
|
961 void CSifMultipleInstallStep::ImplTestStepPreambleL() |
|
962 /** |
|
963 * @return - TVerdict code |
|
964 * Override of base class virtual |
|
965 */ |
|
966 { |
|
967 INFO_PRINTF1(_L("This is TestStepPreamble method of class CSifMultipleInstallStep")); |
|
968 |
|
969 LoadFileNameFromConfigL(); |
|
970 LoadExclusiveOperationFlagFromConfigL(); |
|
971 } |
|
972 |
|
973 void CSifMultipleInstallStep::ImplTestStepL() |
|
974 { |
|
975 INFO_PRINTF1(_L("In the file CSifMultipleInstallStep::ImplTestStepL()")); |
|
976 LoadOpaqueParamsL(); |
|
977 |
|
978 if (TestStepResult()!=EPass) |
|
979 { |
|
980 INFO_PRINTF1(_L("CSifMultipleInstallStep::ImplTestStepL() called with TestStepResult()!=EPass")); |
|
981 return; |
|
982 } |
|
983 |
|
984 TInt expectedConcurrentResult = 0; |
|
985 TInt overlapRequest = EFalse; |
|
986 if (!GetIntFromConfig(ConfigSection(), KTe_ExpectedConcurrentResult, expectedConcurrentResult) || |
|
987 !GetBoolFromConfig(ConfigSection(), KTe_OverlapRequest, overlapRequest)) |
|
988 { |
|
989 INFO_PRINTF3(_L("Expected test parameters: %S or %S not found "), &KTe_ExpectedConcurrentResult, &KTe_OverlapRequest); |
|
990 User::Leave(KErrNotFound); |
|
991 } |
|
992 |
|
993 /* First installation request */ |
|
994 RSoftwareInstall sif1; |
|
995 TInt error = sif1.Connect(); |
|
996 if (error != KErrNone) |
|
997 { |
|
998 INFO_PRINTF2(_L("Failed to connect to the SIF server, error code: %d"), error); |
|
999 User::Leave(error); |
|
1000 } |
|
1001 CleanupClosePushL(sif1); |
|
1002 |
|
1003 TRequestStatus status1; |
|
1004 sif1.Install(iFileName, status1); |
|
1005 |
|
1006 if (!overlapRequest) |
|
1007 { |
|
1008 User::WaitForRequest(status1); |
|
1009 } |
|
1010 |
|
1011 /* Second installation request */ |
|
1012 |
|
1013 // Use different file name if provided |
|
1014 TPtrC fileName2; |
|
1015 if (!GetStringFromConfig(ConfigSection(), _L("packageFile2"), fileName2)) |
|
1016 { |
|
1017 fileName2.Set(iFileName); |
|
1018 } |
|
1019 |
|
1020 RSoftwareInstall sif2; |
|
1021 error = sif2.Connect(); |
|
1022 if (error != KErrNone) |
|
1023 { |
|
1024 INFO_PRINTF2(_L("Failed to connect to the SIF server, error code: %d"), error); |
|
1025 User::Leave(error); |
|
1026 } |
|
1027 CleanupClosePushL(sif2); |
|
1028 |
|
1029 TRequestStatus status2; |
|
1030 |
|
1031 if (iUseEnhancedApi) |
|
1032 { |
|
1033 sif2.Install(fileName2, *iPluginOpaqueArguments, *iPluginOpaqueResults, status2, iExclusiveOperation); |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 sif2.Install(fileName2, status2, iExclusiveOperation); |
|
1038 } |
|
1039 |
|
1040 if (overlapRequest) |
|
1041 { |
|
1042 User::WaitForRequest(status1); |
|
1043 } |
|
1044 |
|
1045 User::WaitForRequest(status2); |
|
1046 |
|
1047 //close both the sessions at the end. |
|
1048 CleanupStack::PopAndDestroy(2, &sif1); |
|
1049 |
|
1050 if(status2 != expectedConcurrentResult) |
|
1051 { |
|
1052 INFO_PRINTF3(_L("status2: %d expectedResult1: %d"), status2.Int(), expectedConcurrentResult); |
|
1053 SetTestStepResult(EFail); |
|
1054 } |
|
1055 User::LeaveIfError(status1.Int()); |
|
1056 } |