|
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 * Implements the basic test step for the Software Component Registry test harness |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "tscrstep.h" |
|
21 #include "tscrserver.h" |
|
22 #include "tscrdefs.h" |
|
23 #include <f32file.h> |
|
24 #include <scs/cleanuputils.h> |
|
25 |
|
26 using namespace Usif; |
|
27 |
|
28 CScrTestStep::CScrTestStep(CScrTestServer& aParent) |
|
29 // Constructor. |
|
30 : iParent(aParent) |
|
31 { |
|
32 } |
|
33 |
|
34 CScrTestStep::~CScrTestStep() |
|
35 // Destructor. |
|
36 { |
|
37 iScrSession.Close(); |
|
38 } |
|
39 |
|
40 void CScrTestStep:: MarkAsPerformanceStep() |
|
41 { |
|
42 iIsPerformanceTest = ETrue; |
|
43 } |
|
44 |
|
45 void CScrTestStep::PrintPerformanceLog(TTime aTime) |
|
46 { |
|
47 TDateTime timer = aTime.DateTime(); |
|
48 INFO_PRINTF6(_L("%S,%d:%d:%d:%d"), &KPerformanceTestInfo(), timer.Hour(), timer.Minute(), timer.Second(), timer.MicroSecond()); |
|
49 } |
|
50 |
|
51 void CScrTestStep::StartTimer() |
|
52 { |
|
53 iStartTime.HomeTime(); |
|
54 PrintPerformanceLog(iStartTime); |
|
55 } |
|
56 |
|
57 void CScrTestStep::StopTimerAndPrintResultL() |
|
58 { |
|
59 TTime endTime; |
|
60 endTime.HomeTime(); |
|
61 PrintPerformanceLog(endTime); |
|
62 |
|
63 TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(iStartTime); |
|
64 TInt actualDuration = I64INT(duration.Int64())/1000; // in millisecond |
|
65 |
|
66 if(iTimeMeasuredExternally) |
|
67 { // if the time is measured by the scr accessor, update the actual time with the external time. |
|
68 actualDuration = iTimeMeasuredExternally; |
|
69 } |
|
70 |
|
71 TInt maxDuration = 0; |
|
72 if(!GetIntFromConfig(ConfigSection(), KMaxDurationName, maxDuration)) |
|
73 { |
|
74 ERR_PRINTF2(_L("%S could not be found in configuration."), &KMaxDurationName()); |
|
75 User::Leave(KErrNotFound); |
|
76 } |
|
77 else |
|
78 { |
|
79 INFO_PRINTF3(_L("%S,%d"), &KMaxTestCaseDuration(), maxDuration); |
|
80 INFO_PRINTF3(_L("%S,%d"), &KActualTestCaseDuration(), actualDuration); |
|
81 } |
|
82 |
|
83 if(actualDuration <= maxDuration) |
|
84 { |
|
85 INFO_PRINTF2(_L("This test meets performance requirement (Duration=%d)."), actualDuration); |
|
86 } |
|
87 else |
|
88 { |
|
89 ERR_PRINTF2(_L("This test does not meet performance requirement (Duration=%d)."), actualDuration); |
|
90 SetTestStepResult(EFail); |
|
91 } |
|
92 } |
|
93 |
|
94 void CScrTestStep::ImplTestStepPreambleL() |
|
95 /** |
|
96 From COomTestStep. |
|
97 */ |
|
98 { |
|
99 User::LeaveIfError(iScrSession.Connect()); |
|
100 if(iIsPerformanceTest) |
|
101 { |
|
102 StartTimer(); |
|
103 } |
|
104 } |
|
105 |
|
106 void CScrTestStep::ImplTestStepL() |
|
107 /** |
|
108 From COomTestStep. |
|
109 */ |
|
110 { |
|
111 // empty |
|
112 } |
|
113 |
|
114 |
|
115 void CScrTestStep::ImplTestStepPostambleL() |
|
116 /** |
|
117 From COomTestStep. |
|
118 */ |
|
119 { |
|
120 if(iIsPerformanceTest) |
|
121 { |
|
122 StopTimerAndPrintResultL(); |
|
123 } |
|
124 } |
|
125 |
|
126 |
|
127 RScsClientBase* CScrTestStep::ClientHandle() |
|
128 /** |
|
129 From COomTestStep. |
|
130 */ |
|
131 { |
|
132 return &iScrSession; |
|
133 } |
|
134 |
|
135 void CScrTestStep::PrintErrorL(const TDesC& aMsg, TInt aErrNum,...) |
|
136 { |
|
137 VA_LIST list; |
|
138 VA_START(list, aErrNum); |
|
139 |
|
140 RBuf msgBuf; |
|
141 msgBuf.CreateL(MAX_SCR_ERROR_MESSAGE_LENGTH); |
|
142 msgBuf.CleanupClosePushL(); |
|
143 msgBuf.AppendFormatList(aMsg, list); |
|
144 |
|
145 ERR_PRINTF1(msgBuf); |
|
146 SetTestStepResult(EFail); |
|
147 |
|
148 CleanupStack::PopAndDestroy(&msgBuf); |
|
149 User::Leave(aErrNum); |
|
150 } |
|
151 |
|
152 //--------------------Code for properties' comparison |
|
153 |
|
154 TBool operator ==(const TDriveList& aLhsEntry, const TDriveList& aRhsEntry) |
|
155 { |
|
156 // If two drives are equal, each byte of them must be zero or non-zero together. |
|
157 // Otherwise, the drive lists are different. |
|
158 for(TInt driveNumber=EDriveA; driveNumber<=EDriveZ; ++driveNumber) |
|
159 { |
|
160 if((aLhsEntry[driveNumber] || aRhsEntry[driveNumber]) && !(aLhsEntry[driveNumber] && aRhsEntry[driveNumber])) |
|
161 return EFalse; |
|
162 } |
|
163 return ETrue; |
|
164 } |
|
165 |
|
166 TBool operator ==(const CComponentEntry& aLhsEntry, const CComponentEntry& aRhsEntry) |
|
167 { |
|
168 return (aLhsEntry.ComponentId() == aRhsEntry.ComponentId() && |
|
169 aLhsEntry.Name() == aRhsEntry.Name()&& |
|
170 aLhsEntry.Vendor() == aRhsEntry.Vendor() && |
|
171 aLhsEntry.SoftwareType() == aRhsEntry.SoftwareType() && |
|
172 aLhsEntry.GlobalId() == aRhsEntry.GlobalId() && |
|
173 aLhsEntry.IsRemovable() == aRhsEntry.IsRemovable() && |
|
174 aLhsEntry.IsDrmProtected() == aRhsEntry.IsDrmProtected() && |
|
175 aLhsEntry.IsHidden() == aRhsEntry.IsHidden() && |
|
176 aLhsEntry.IsKnownRevoked() == aRhsEntry.IsKnownRevoked() && |
|
177 aLhsEntry.IsOriginVerified() == aRhsEntry.IsOriginVerified() && |
|
178 aLhsEntry.ComponentSize() == aRhsEntry.ComponentSize() && |
|
179 aLhsEntry.ScomoState() == aRhsEntry.ScomoState() && |
|
180 aLhsEntry.InstalledDrives() == aRhsEntry.InstalledDrives() && |
|
181 aLhsEntry.Version() == aRhsEntry.Version()); |
|
182 } |
|
183 |
|
184 TBool operator !=(const CComponentEntry& aLhsEntry, const CComponentEntry& aRhsEntry) |
|
185 { |
|
186 return !operator ==(aLhsEntry, aRhsEntry); |
|
187 } |
|
188 |
|
189 TBool operator ==(CLocalizablePropertyEntry& lhsEntry, CLocalizablePropertyEntry& rhsEntry) |
|
190 { |
|
191 return lhsEntry.StrValue() == rhsEntry.StrValue(); |
|
192 } |
|
193 |
|
194 TBool operator ==(CBinaryPropertyEntry& lhsEntry, CBinaryPropertyEntry& rhsEntry) |
|
195 { |
|
196 return lhsEntry.BinaryValue() == rhsEntry.BinaryValue(); |
|
197 } |
|
198 |
|
199 TBool operator ==(CIntPropertyEntry& lhsEntry, CIntPropertyEntry& rhsEntry) |
|
200 { |
|
201 return lhsEntry.Int64Value() == rhsEntry.Int64Value(); |
|
202 } |
|
203 |
|
204 template <class T> TBool CompareProperty(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
205 { |
|
206 // Cannot use reference dynamic_cast - Symbian does not support std::bad_cast or any other exception |
|
207 T& lhsSubclassEntry = static_cast<T &>(lhsEntry); |
|
208 T& rhsSubclassEntry = static_cast<T &>(rhsEntry); |
|
209 return (lhsSubclassEntry == rhsSubclassEntry); |
|
210 } |
|
211 |
|
212 TBool operator ==(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
213 { |
|
214 CPropertyEntry::TPropertyType lhsPropertyType = lhsEntry.PropertyType(); |
|
215 CPropertyEntry::TPropertyType rhsPropertyType = rhsEntry.PropertyType(); |
|
216 if (lhsPropertyType != rhsPropertyType) |
|
217 return EFalse; |
|
218 |
|
219 switch (rhsPropertyType) |
|
220 { |
|
221 case CPropertyEntry::EBinaryProperty: |
|
222 { |
|
223 return CompareProperty<CBinaryPropertyEntry>(lhsEntry, rhsEntry); |
|
224 } |
|
225 case CPropertyEntry::ELocalizedProperty: |
|
226 { |
|
227 return CompareProperty<CLocalizablePropertyEntry>(lhsEntry, rhsEntry); |
|
228 } |
|
229 case CPropertyEntry::EIntProperty: |
|
230 { |
|
231 return CompareProperty<CIntPropertyEntry>(lhsEntry, rhsEntry); |
|
232 } |
|
233 default: |
|
234 ASSERT(0); |
|
235 } |
|
236 ASSERT(0); |
|
237 return ETrue; // Should not reach here |
|
238 } |
|
239 |
|
240 TBool operator !=(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
241 { |
|
242 return !operator ==(lhsEntry, rhsEntry); |
|
243 } |
|
244 |
|
245 |
|
246 TBool CScrTestStep::ComparePropertiesL(RPointerArray<CPropertyEntry>& aFoundProperties, RPointerArray<CPropertyEntry>& aExpectedProperties) |
|
247 { |
|
248 TInt foundPropertiesCount = aFoundProperties.Count(); |
|
249 |
|
250 if (aExpectedProperties.Count() != foundPropertiesCount) |
|
251 { |
|
252 ERR_PRINTF3(_L("The number of expected properties %d did not match the number of found properties %d."), aExpectedProperties.Count(), foundPropertiesCount); |
|
253 return EFalse; |
|
254 } |
|
255 |
|
256 for (TInt i = 0; i < foundPropertiesCount; ++i) |
|
257 { |
|
258 if (*aFoundProperties[i] != *aExpectedProperties[i]) |
|
259 { |
|
260 ERR_PRINTF2(_L("Property %d did not match."), i); |
|
261 return EFalse; |
|
262 } |
|
263 } |
|
264 return ETrue; |
|
265 } |
|
266 |
|
267 TBool operator ==(const CGlobalComponentId& lhsEntry, const CGlobalComponentId& rhsEntry) |
|
268 { |
|
269 return (lhsEntry.GlobalIdName() == rhsEntry.GlobalIdName()) && |
|
270 (lhsEntry.SoftwareTypeName() == rhsEntry.SoftwareTypeName()); |
|
271 } |
|
272 |
|
273 TBool operator !=(const CGlobalComponentId& lhsEntry, const CGlobalComponentId& rhsEntry) |
|
274 { |
|
275 return !operator==(lhsEntry,rhsEntry); |
|
276 } |
|
277 |
|
278 TBool operator ==(const CVersionedComponentId& lhsEntry, const CVersionedComponentId& rhsEntry) |
|
279 { |
|
280 return (lhsEntry.GlobalId() == rhsEntry.GlobalId()) && |
|
281 ((lhsEntry.VersionFrom()?*lhsEntry.VersionFrom():KNullDesC()) == (rhsEntry.VersionFrom()?*rhsEntry.VersionFrom():KNullDesC())) && |
|
282 ((lhsEntry.VersionTo()?*lhsEntry.VersionTo():KNullDesC()) == (rhsEntry.VersionTo()?*rhsEntry.VersionTo():KNullDesC())); |
|
283 } |
|
284 |
|
285 TBool operator !=(CVersionedComponentId& lhsEntry, CVersionedComponentId& rhsEntry) |
|
286 { |
|
287 return !operator==(lhsEntry,rhsEntry); |
|
288 } |
|
289 |
|
290 TBool CScrTestStep::CompareVersionedComponentIdsL(RPointerArray<CVersionedComponentId>& aFoundVerCompIdList, RPointerArray<CVersionedComponentId>& aExpectedVerCompIdList) |
|
291 { |
|
292 TInt foundVerCompIdsCount = aFoundVerCompIdList.Count(); |
|
293 TInt expectedVerCompIdsCount = aExpectedVerCompIdList.Count(); |
|
294 |
|
295 if (foundVerCompIdsCount != expectedVerCompIdsCount) |
|
296 { |
|
297 ERR_PRINTF3(_L("The number of expected versioned component Ids %d did not match the number of found ones %d."), expectedVerCompIdsCount, foundVerCompIdsCount); |
|
298 return EFalse; |
|
299 } |
|
300 |
|
301 for (TInt i = 0; i < foundVerCompIdsCount; ++i) |
|
302 { |
|
303 if (*aFoundVerCompIdList[i] != *aExpectedVerCompIdList[i]) |
|
304 { |
|
305 ERR_PRINTF2(_L("Versioned Component Id %d did not match."), i); |
|
306 return EFalse; |
|
307 } |
|
308 } |
|
309 |
|
310 return ETrue; |
|
311 } |
|
312 |
|
313 void CScrTestStep::CompareComponentIdsL(RArray<TComponentId>& aFoundComponents, RArray<TComponentId>& aExpectedComponents) |
|
314 { |
|
315 TInt foundComponentsCount = aFoundComponents.Count(); |
|
316 if (foundComponentsCount != aExpectedComponents.Count()) |
|
317 { |
|
318 ERR_PRINTF3(_L("The number of expected components %d did not match the number of found components %d."), aExpectedComponents.Count(), foundComponentsCount); |
|
319 SetTestStepResult(EFail); |
|
320 return; |
|
321 } |
|
322 |
|
323 aFoundComponents.Sort(); |
|
324 aExpectedComponents.Sort(); |
|
325 for (TInt i = 0; i < foundComponentsCount; ++i) |
|
326 { |
|
327 if (aFoundComponents[i] < aExpectedComponents[i]) |
|
328 { |
|
329 ERR_PRINTF2(_L("Component %d was not expected in the test."), aFoundComponents[i]); |
|
330 SetTestStepResult(EFail); |
|
331 break; |
|
332 } |
|
333 else if (aExpectedComponents[i] < aFoundComponents[i]) |
|
334 { |
|
335 ERR_PRINTF2(_L("Component %d was expected, but not found."), aExpectedComponents[i]); |
|
336 SetTestStepResult(EFail); |
|
337 break; |
|
338 } |
|
339 } |
|
340 } |
|
341 |
|
342 |
|
343 // Helper functions for getting commong attributes from configuration |
|
344 |
|
345 void CScrTestStep::GetSoftwareTypeNameL(TPtrC& aSwTypeName) |
|
346 { |
|
347 if (!GetStringFromConfig(ConfigSection(), KSoftwareTypeName, aSwTypeName)) |
|
348 PrintErrorL(_L("Software Type was not found!"), KErrNotFound); |
|
349 } |
|
350 |
|
351 TBool CScrTestStep::GetGlobalIdNameL(TPtrC& aGlobalIdName) |
|
352 { |
|
353 if (!GetStringFromConfig(ConfigSection(), KGlobalIdName, aGlobalIdName)) |
|
354 return EFalse; |
|
355 return ETrue; |
|
356 } |
|
357 |
|
358 Usif::CGlobalComponentId* CScrTestStep::GetGlobalComponentIdLC() |
|
359 { |
|
360 TPtrC globalIdName; |
|
361 if (!GetGlobalIdNameL(globalIdName)) |
|
362 PrintErrorL(_L("Global Id Name was not found!"), KErrNotFound); |
|
363 |
|
364 TPtrC swTypeName; |
|
365 GetSoftwareTypeNameL(swTypeName); |
|
366 |
|
367 return CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
368 } |
|
369 |
|
370 Usif::CGlobalComponentId* CScrTestStep::GetGlobalComponentIdLC(const TDesC& aGlobalIdName, const TDesC& aSwTypeName) |
|
371 { |
|
372 TPtrC globalIdName; |
|
373 if (!GetStringFromConfig(ConfigSection(), aGlobalIdName, globalIdName)) |
|
374 PrintErrorL(_L("Global Id Name was not found!"), KErrNotFound); |
|
375 |
|
376 TPtrC swTypeName; |
|
377 if (!GetStringFromConfig(ConfigSection(), aSwTypeName, swTypeName)) |
|
378 PrintErrorL(_L("Software Type Name was not found!"), KErrNotFound); |
|
379 |
|
380 return CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
381 } |
|
382 |
|
383 HBufC* CScrTestStep::GetVersionFromConfigL(const TDesC& aVersionName) |
|
384 { |
|
385 TPtrC version(KNullDesC()); |
|
386 if(!GetStringFromConfig(ConfigSection(), aVersionName, version)) |
|
387 return NULL; |
|
388 return version.AllocL(); |
|
389 } |
|
390 |
|
391 void CScrTestStep::GetExpectedVersionedComponentIdListL(RPointerArray<CVersionedComponentId>& aVerCompIdList) |
|
392 { |
|
393 TInt globalIdCount(0); |
|
394 if(!GetIntFromConfig(ConfigSection(), KGlobalIdCount, globalIdCount)) |
|
395 PrintErrorL(_L("Global Id count was not found!"), KErrNotFound); |
|
396 |
|
397 TBuf<MAX_SCR_PARAM_LENGTH> paramGlobalIdName, paramSwTypeName, paramVersionFrom, paramVersionTo; |
|
398 |
|
399 for(TInt i=0; i<globalIdCount; ++i) |
|
400 { |
|
401 paramGlobalIdName = KGlobalIdName; |
|
402 paramSwTypeName = KSoftwareTypeName; |
|
403 paramVersionFrom = KVersionFrom; |
|
404 paramVersionTo = KVersionTo; |
|
405 |
|
406 GenerateIndexedAttributeNameL(paramGlobalIdName, i); |
|
407 GenerateIndexedAttributeNameL(paramSwTypeName, i); |
|
408 GenerateIndexedAttributeNameL(paramVersionFrom, i); |
|
409 GenerateIndexedAttributeNameL(paramVersionTo, i); |
|
410 |
|
411 TPtrC globalIdName; |
|
412 if (!GetStringFromConfig(ConfigSection(), paramGlobalIdName, globalIdName)) |
|
413 { |
|
414 ERR_PRINTF2(_L("The %S param could not be found in configuration."), ¶mGlobalIdName); |
|
415 User::Leave(KErrNotFound); |
|
416 } |
|
417 |
|
418 TPtrC swTypeName; |
|
419 if (!GetStringFromConfig(ConfigSection(), paramSwTypeName, swTypeName)) |
|
420 { |
|
421 ERR_PRINTF2(_L("The %S param could not be found in configuration."), ¶mSwTypeName); |
|
422 User::Leave(KErrNotFound); |
|
423 } |
|
424 |
|
425 HBufC *versionFrom = GetVersionFromConfigL(paramVersionFrom); |
|
426 if(versionFrom) |
|
427 CleanupStack::PushL(versionFrom); |
|
428 HBufC *versionTo = GetVersionFromConfigL(paramVersionTo); |
|
429 if(versionTo) |
|
430 CleanupStack::PushL(versionTo); |
|
431 |
|
432 CGlobalComponentId *globalId = CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
433 CVersionedComponentId *verCompId = CVersionedComponentId::NewLC(*globalId, versionFrom, versionTo); |
|
434 aVerCompIdList.AppendL(verCompId); |
|
435 CleanupStack::Pop(verCompId); // owned by the array |
|
436 CleanupStack::PopAndDestroy(globalId); |
|
437 if(versionTo) |
|
438 CleanupStack::PopAndDestroy(versionTo); |
|
439 if(versionFrom) |
|
440 CleanupStack::PopAndDestroy(versionFrom); |
|
441 } |
|
442 } |
|
443 |
|
444 void CScrTestStep::AppendSharedComponentIdL(Usif::TComponentId aComponentId) |
|
445 { |
|
446 TBuf<MAX_SCR_BUFFER_LENGTH> componentIdBuf; |
|
447 ReadSharedDataL(KComponentIdName, componentIdBuf); |
|
448 componentIdBuf.AppendNum(aComponentId); |
|
449 componentIdBuf.Append(KComponentIdDelimeter); |
|
450 WriteSharedDataL(KComponentIdName, componentIdBuf, ESetText); |
|
451 } |
|
452 |
|
453 void CScrTestStep::ReadAllSharedComponentIdsL(RArray<TInt>& aComponentList) |
|
454 { |
|
455 TBuf<MAX_SCR_BUFFER_LENGTH> componentIdBuf; |
|
456 ReadSharedDataL(KComponentIdName, componentIdBuf); |
|
457 |
|
458 TLex parser(componentIdBuf); |
|
459 TChar currentChar; |
|
460 |
|
461 parser.Mark(); |
|
462 while(!parser.Eos()) |
|
463 { |
|
464 currentChar = parser.Get(); |
|
465 if(KComponentIdDelimeter == currentChar) |
|
466 { |
|
467 TPtrC token = parser.MarkedToken(); |
|
468 TLex tokenLex(token); |
|
469 TInt componentId; |
|
470 tokenLex.Val(componentId); |
|
471 aComponentList.AppendL(componentId); |
|
472 parser.Mark(); |
|
473 } |
|
474 } |
|
475 } |
|
476 |
|
477 TInt CScrTestStep::ReadSharedComponentIdL(TInt aOffset) |
|
478 { |
|
479 RArray<TInt> componentList; |
|
480 CleanupClosePushL(componentList); |
|
481 ReadAllSharedComponentIdsL(componentList); |
|
482 |
|
483 TInt maxListIndex = componentList.Count() - 1; |
|
484 if(aOffset<0 || aOffset>maxListIndex) |
|
485 PrintErrorL(_L("Component Id offset is not valid!"), KErrArgument); |
|
486 |
|
487 TInt componentId = componentList[maxListIndex - aOffset]; |
|
488 CleanupStack::PopAndDestroy(&componentList); |
|
489 return componentId; |
|
490 } |
|
491 |
|
492 TBool CScrTestStep::GetLocaleFromConfigL(const TDesC& aParamName, TLanguage &aLocale) |
|
493 { |
|
494 TInt localeParam; |
|
495 if (!GetIntFromConfig(ConfigSection(), aParamName, localeParam)) |
|
496 return EFalse; |
|
497 aLocale = static_cast<TLanguage>(localeParam); |
|
498 return ETrue; |
|
499 } |
|
500 |
|
501 TBool CScrTestStep::GetLocaleFromConfigL(TLanguage &aLocale) |
|
502 { |
|
503 return GetLocaleFromConfigL(KPropertyLocaleParam, aLocale); |
|
504 } |
|
505 |
|
506 TInt CScrTestStep::GetComponentIdL() |
|
507 { |
|
508 TInt componentId(0); |
|
509 if(GetIntFromConfig(ConfigSection(), KComponentIdName, componentId)) |
|
510 return componentId; |
|
511 |
|
512 TInt componentIdOffset; |
|
513 if (!GetIntFromConfig(ConfigSection(), KComponentIdOffsetName, componentIdOffset)) |
|
514 PrintErrorL(_L("ComponentId Offset was not found!"), KErrNotFound); |
|
515 |
|
516 componentId = ReadSharedComponentIdL(componentIdOffset); |
|
517 INFO_PRINTF2(_L("Component Id %d"), componentId); |
|
518 return componentId; |
|
519 } |
|
520 |
|
521 void CScrTestStep::GetFileNameFromConfigL(TPtrC& aFileName) |
|
522 { |
|
523 if (!GetStringFromConfig(ConfigSection(), KFileName, aFileName)) |
|
524 PrintErrorL(_L("FileName was not found!"), KErrNotFound); |
|
525 } |
|
526 |
|
527 void CScrTestStep::GetFileNameListFromConfigL(RPointerArray<HBufC>& aFileList) |
|
528 { |
|
529 TInt fileCount(0); |
|
530 if(!GetIntFromConfig(ConfigSection(), KFileCount, fileCount)) |
|
531 PrintErrorL(_L("File count was not found!"), KErrNotFound); |
|
532 |
|
533 TBuf<MAX_SCR_PARAM_LENGTH> paramName; |
|
534 for(TInt i=0; i<fileCount; ++i) |
|
535 { |
|
536 paramName = KFileName; |
|
537 GenerateIndexedAttributeNameL(paramName, i); |
|
538 TPtrC fileName; |
|
539 if (!GetStringFromConfig(ConfigSection(), paramName, fileName)) |
|
540 { |
|
541 ERR_PRINTF2(_L("The File Name param %S could not be found in configuration."), ¶mName); |
|
542 User::Leave(KErrNotFound); |
|
543 } |
|
544 HBufC* fileNameBuf = fileName.AllocLC(); |
|
545 aFileList.AppendL(fileNameBuf); |
|
546 CleanupStack::Pop(fileNameBuf); |
|
547 } |
|
548 } |
|
549 |
|
550 void CScrTestStep::GetComponentNameFromConfigL(TPtrC& aComponentName) |
|
551 { |
|
552 if(!GetStringFromConfig(ConfigSection(), KComponentName, aComponentName)) |
|
553 PrintErrorL(_L("Component name was not found!"), KErrNotFound); |
|
554 } |
|
555 |
|
556 void CScrTestStep::GetVendorNameFromConfigL(TPtrC& aVendorName) |
|
557 { |
|
558 if(!GetStringFromConfig(ConfigSection(), KVendorName, aVendorName)) |
|
559 PrintErrorL(_L("Vendor name was not found!"), KErrNotFound); |
|
560 } |
|
561 |
|
562 CComponentEntry* CScrTestStep::GetComponentEntryFromConfigLC(TBool aIsSingle, TInt aIndex) |
|
563 { |
|
564 // First, we need to generate the property name |
|
565 TBuf<MAX_SCR_PARAM_LENGTH> componentIdParam, componentIdOffsetParam, componentNameParam, componentVendorParam, softwareTypeNameParam; |
|
566 TBuf<MAX_SCR_PARAM_LENGTH> globalIdParam, installedDrivesParam, isRemovableParam, componentSizeParam, scomoStateParam, versionParam; |
|
567 TBuf<MAX_SCR_PARAM_LENGTH> isDrmProtectedParam, isHiddenParam, isKnownRevokedParam, isOriginVerifiedParam; |
|
568 |
|
569 componentIdParam = KComponentIdName; |
|
570 componentIdOffsetParam = KComponentIdOffsetName; |
|
571 componentNameParam = KComponentName; |
|
572 componentVendorParam = KVendorName; |
|
573 softwareTypeNameParam = KSoftwareTypeName; |
|
574 globalIdParam = KGlobalIdName; |
|
575 isRemovableParam = KRemovableName; |
|
576 isDrmProtectedParam = KDrmProtectedName; |
|
577 isHiddenParam = KHiddenName; |
|
578 isKnownRevokedParam = KKnownRevokedName; |
|
579 isOriginVerifiedParam = KOriginVerifiedName; |
|
580 componentSizeParam = KComponentSizeName; |
|
581 scomoStateParam = KComponentScomoStateName; |
|
582 installedDrivesParam = KInstalledDrivesName; |
|
583 versionParam = KVersionName; |
|
584 |
|
585 if (!aIsSingle) |
|
586 { |
|
587 GenerateIndexedAttributeNameL(componentIdParam, aIndex); |
|
588 GenerateIndexedAttributeNameL(componentIdOffsetParam, aIndex); |
|
589 GenerateIndexedAttributeNameL(componentNameParam, aIndex); |
|
590 GenerateIndexedAttributeNameL(componentVendorParam, aIndex); |
|
591 GenerateIndexedAttributeNameL(softwareTypeNameParam, aIndex); |
|
592 GenerateIndexedAttributeNameL(globalIdParam, aIndex); |
|
593 GenerateIndexedAttributeNameL(isRemovableParam, aIndex); |
|
594 GenerateIndexedAttributeNameL(isDrmProtectedParam, aIndex); |
|
595 GenerateIndexedAttributeNameL(isHiddenParam, aIndex); |
|
596 GenerateIndexedAttributeNameL(isKnownRevokedParam, aIndex); |
|
597 GenerateIndexedAttributeNameL(isOriginVerifiedParam, aIndex); |
|
598 GenerateIndexedAttributeNameL(componentSizeParam, aIndex); |
|
599 GenerateIndexedAttributeNameL(scomoStateParam, aIndex); |
|
600 GenerateIndexedAttributeNameL(installedDrivesParam, aIndex); |
|
601 GenerateIndexedAttributeNameL(versionParam, aIndex); |
|
602 } |
|
603 |
|
604 TComponentId componentId(0); |
|
605 if (!GetIntFromConfig(ConfigSection(), componentIdParam, componentId)) |
|
606 { |
|
607 TInt componentIdOffset; |
|
608 if (!GetIntFromConfig(ConfigSection(), componentIdOffsetParam, componentIdOffset)) |
|
609 PrintErrorL(_L("The component entry params %S and %S could not be found in configuration."), KErrNotFound, &componentIdParam, &componentIdOffsetParam); |
|
610 |
|
611 componentId = ReadSharedComponentIdL(componentIdOffset); |
|
612 INFO_PRINTF2(_L("Component Id %d"), componentId); |
|
613 } |
|
614 |
|
615 TPtrC componentName; |
|
616 if (!GetStringFromConfig(ConfigSection(), componentNameParam, componentName)) |
|
617 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentNameParam); |
|
618 |
|
619 TPtrC componentVendor; |
|
620 if (!GetStringFromConfig(ConfigSection(), componentVendorParam, componentVendor)) |
|
621 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentVendorParam); |
|
622 |
|
623 TPtrC softwareTypeName; |
|
624 if (!GetStringFromConfig(ConfigSection(), softwareTypeNameParam, softwareTypeName)) |
|
625 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &softwareTypeNameParam); |
|
626 |
|
627 TPtrC globalId(KNullDesC); |
|
628 (void)GetStringFromConfig(ConfigSection(), globalIdParam, globalId); // This is an optional attribute. It is not crucial even if it is not provided. |
|
629 |
|
630 TBool isRemovable; |
|
631 if (!GetBoolFromConfig(ConfigSection(), isRemovableParam, isRemovable)) |
|
632 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &isRemovableParam); |
|
633 |
|
634 TInt64 componentSize; |
|
635 if (!Get64BitIntegerFromConfigL(componentSizeParam, componentSize)) |
|
636 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentSizeParam); |
|
637 |
|
638 TInt scomoStateValue; |
|
639 if (!GetIntFromConfig(ConfigSection(), scomoStateParam, scomoStateValue)) |
|
640 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &scomoStateParam); |
|
641 TScomoState scomoState = static_cast<TScomoState>(scomoStateValue); |
|
642 |
|
643 TDriveList driveList; |
|
644 if(!GetInstalledDrivesFromConfigL(driveList, installedDrivesParam)) |
|
645 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &installedDrivesParam); |
|
646 |
|
647 TPtrC version; |
|
648 if (!GetStringFromConfig(ConfigSection(), versionParam, version)) |
|
649 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &versionParam); |
|
650 |
|
651 TBool isDrmProtected = EFalse; |
|
652 (void)GetBoolFromConfig(ConfigSection(), isDrmProtectedParam, isDrmProtected); // This is an optional attribute. It is not crucial even if it is not provided. |
|
653 |
|
654 TBool isHidden = EFalse; |
|
655 (void)GetBoolFromConfig(ConfigSection(), isHiddenParam, isHidden); // This is an optional attribute. It is not crucial even if it is not provided. |
|
656 |
|
657 TBool isKnownRevoked = EFalse; |
|
658 (void)GetBoolFromConfig(ConfigSection(), isKnownRevokedParam, isKnownRevoked); // This is an optional attribute. It is not crucial even if it is not provided. |
|
659 |
|
660 TBool isOriginVerified = EFalse; |
|
661 (void)GetBoolFromConfig(ConfigSection(), isOriginVerifiedParam, isOriginVerified); // This is an optional attribute. It is not crucial even if it is not provided. |
|
662 |
|
663 _LIT(KInstallTime, "20080706:112000"); |
|
664 |
|
665 return CComponentEntry::NewLC(componentId, componentName, componentVendor, softwareTypeName, globalId, isRemovable, componentSize, scomoState, driveList, version, KInstallTime, isDrmProtected, isHidden, isKnownRevoked, isOriginVerified); |
|
666 } |
|
667 |
|
668 void CScrTestStep::GenerateIndexedAttributeNameL(TDes& aInitialAttributeName, TInt aIndex) |
|
669 { |
|
670 const TInt MAX_INT_STR_LEN = 8; |
|
671 TBuf<MAX_INT_STR_LEN> integerAppendStr; |
|
672 integerAppendStr.Format(_L("%d"), aIndex); |
|
673 aInitialAttributeName.Append(integerAppendStr); |
|
674 } |
|
675 |
|
676 TBool CScrTestStep::Get64BitIntegerFromConfigL(const TDesC& aConfigKeyName, TInt64& aRetVal) |
|
677 { |
|
678 TPtrC int64Str; |
|
679 if (!GetStringFromConfig(ConfigSection(), aConfigKeyName, int64Str)) |
|
680 return EFalse; |
|
681 |
|
682 TLex lex(int64Str); |
|
683 User::LeaveIfError(lex.Val(aRetVal)); |
|
684 return ETrue; |
|
685 } |
|
686 |
|
687 CPropertyEntry* CScrTestStep::GetPropertyFromConfigLC(TBool aIsSingle, TInt aIndex, TBool aSupportLocalized) |
|
688 { |
|
689 // This function can be used for getting a single property, which is defined by attributes such as PropertyName etc. |
|
690 // or a property in a set - in this case the properties would be PropertyType0, PropertyName0 etc. |
|
691 // aIsSingle defines the working mode. aIndex applies only if aIsSingle is false |
|
692 |
|
693 // First, we need to generate the property name |
|
694 TBuf<MAX_SCR_PARAM_LENGTH> propertyTypeParam, propertyNameParam, propertyValueParam, propertyLocaleParam; |
|
695 propertyTypeParam = KPropertyTypeParam; |
|
696 propertyNameParam = KPropertyNameParam; |
|
697 propertyValueParam = KPropertyValueParam; |
|
698 propertyLocaleParam = KPropertyLocaleParam; |
|
699 if (!aIsSingle) |
|
700 { |
|
701 GenerateIndexedAttributeNameL(propertyTypeParam, aIndex); |
|
702 GenerateIndexedAttributeNameL(propertyNameParam, aIndex); |
|
703 GenerateIndexedAttributeNameL(propertyValueParam, aIndex); |
|
704 GenerateIndexedAttributeNameL(propertyLocaleParam, aIndex); |
|
705 } |
|
706 |
|
707 TPtrC propertyName; |
|
708 if (!GetStringFromConfig(ConfigSection(), propertyNameParam, propertyName)) |
|
709 { |
|
710 ERR_PRINTF2(_L("The property name param %S could not be found in configuration."), &propertyNameParam); |
|
711 User::Leave(KErrNotFound); |
|
712 } |
|
713 |
|
714 TInt propertyTypeInt; |
|
715 if (!GetIntFromConfig(ConfigSection(), propertyTypeParam, propertyTypeInt)) |
|
716 { |
|
717 ERR_PRINTF2(_L("The property type param %S could not be found in configuration."), &propertyTypeParam); |
|
718 User::Leave(KErrNotFound); |
|
719 } |
|
720 |
|
721 CPropertyEntry::TPropertyType propertyType = static_cast<CPropertyEntry::TPropertyType>(propertyTypeInt); |
|
722 |
|
723 CPropertyEntry* propertyEntry(NULL); |
|
724 switch (propertyType) |
|
725 { |
|
726 case CPropertyEntry::EBinaryProperty: |
|
727 case CPropertyEntry::ELocalizedProperty: |
|
728 { |
|
729 TPtrC propertyStrValue; |
|
730 if (!GetStringFromConfig(ConfigSection(), propertyValueParam, propertyStrValue)) |
|
731 { |
|
732 ERR_PRINTF2(_L("The property value param %S could not be found in configuration."), &propertyValueParam); |
|
733 User::Leave(KErrNotFound); |
|
734 } |
|
735 if(!aSupportLocalized || propertyType == CPropertyEntry::EBinaryProperty) |
|
736 { |
|
737 HBufC8* buffer8Bit = ConvertBufferTo8bitL(propertyStrValue); |
|
738 CleanupStack::PushL(buffer8Bit); |
|
739 propertyEntry = CBinaryPropertyEntry::NewL(propertyName, *buffer8Bit); |
|
740 CleanupStack::PopAndDestroy(buffer8Bit); |
|
741 break; |
|
742 } |
|
743 // Handle ELocalProperty case |
|
744 TLanguage locale; |
|
745 if (!GetLocaleFromConfigL(propertyLocaleParam, locale)) |
|
746 { |
|
747 ERR_PRINTF2(_L("The property locale param %S could not be found in configuration."), &propertyLocaleParam); |
|
748 User::Leave(KErrNotFound); |
|
749 } |
|
750 propertyEntry = CLocalizablePropertyEntry::NewL(propertyName, propertyStrValue, locale); |
|
751 break; |
|
752 } |
|
753 case CPropertyEntry::EIntProperty: |
|
754 { |
|
755 TInt64 int64Value; |
|
756 if (!Get64BitIntegerFromConfigL(propertyValueParam, int64Value)) |
|
757 { |
|
758 ERR_PRINTF2(_L("The integer param %S could not be found in configuration."), &propertyValueParam); |
|
759 User::Leave(KErrNotFound); |
|
760 } |
|
761 propertyEntry = CIntPropertyEntry::NewL(propertyName, int64Value); |
|
762 break; |
|
763 } |
|
764 } |
|
765 CleanupStack::PushL(propertyEntry); |
|
766 return propertyEntry; |
|
767 } |
|
768 |
|
769 void CScrTestStep::GetPropertiesFromConfigL(RPointerArray<CPropertyEntry>& aProperties, TBool aSupportLocalized) |
|
770 { |
|
771 TInt propertiesCount = 0; |
|
772 if (!GetIntFromConfig(ConfigSection(), KPropertiesCountParamName, propertiesCount)) |
|
773 PrintErrorL(_L("Properties count was not found!"), KErrNotFound); |
|
774 |
|
775 if (propertiesCount < 0) |
|
776 PrintErrorL(_L("Properties count is negative!"), KErrNotFound); |
|
777 |
|
778 for (TInt i = 0; i < propertiesCount; ++i) |
|
779 { |
|
780 CPropertyEntry *propertyEntry = GetPropertyFromConfigLC(EFalse, i, aSupportLocalized); |
|
781 User::LeaveIfError(aProperties.Append(propertyEntry)); |
|
782 CleanupStack::Pop(propertyEntry); |
|
783 } |
|
784 } |
|
785 |
|
786 void CScrTestStep::GetComponentIdsFromConfigL(RArray<TComponentId>& aComponentIds) |
|
787 { |
|
788 TInt componentsCount = 0; |
|
789 if (!GetIntFromConfig(ConfigSection(), KComponentsCountName, componentsCount)) |
|
790 PrintErrorL(_L("Components count was not found!"), KErrNotFound); |
|
791 |
|
792 TBuf<MAX_SCR_PARAM_LENGTH> paramName; |
|
793 |
|
794 for (TInt i = 0; i < componentsCount; ++i) |
|
795 { |
|
796 paramName = KComponentIdOffsetName; |
|
797 GenerateIndexedAttributeNameL(paramName, i); |
|
798 TInt componentIdOffset(0); |
|
799 if (!GetIntFromConfig(ConfigSection(), paramName, componentIdOffset)) |
|
800 { |
|
801 ERR_PRINTF2(_L("The component id param %S could not be found in configuration."), ¶mName); |
|
802 User::Leave(KErrNotFound); |
|
803 } |
|
804 TInt componentId = ReadSharedComponentIdL(componentIdOffset); |
|
805 aComponentIds.AppendL(componentId); |
|
806 } |
|
807 } |
|
808 |
|
809 void CScrTestStep::GetComponentLocalizablesFromConfigL(TInt aIndex, TPtrC& aName, TPtrC& aVendor, TLanguage& aLocale) |
|
810 { |
|
811 TBuf<20> vendorParamName, componentParamName, localeParamName; |
|
812 vendorParamName = KVendorName; |
|
813 GenerateIndexedAttributeNameL(vendorParamName, aIndex); |
|
814 |
|
815 componentParamName = KComponentName; |
|
816 GenerateIndexedAttributeNameL(componentParamName, aIndex); |
|
817 |
|
818 localeParamName = KComponentLocaleName; |
|
819 GenerateIndexedAttributeNameL(localeParamName, aIndex); |
|
820 |
|
821 if (!GetStringFromConfig(ConfigSection(), componentParamName, aName)) |
|
822 PrintErrorL(_L("Localised component name was not found!"), KErrNotFound); |
|
823 if (!GetStringFromConfig(ConfigSection(), vendorParamName, aVendor)) |
|
824 PrintErrorL(_L("Localised vendor name was not found!"), KErrNotFound); |
|
825 if (!GetLocaleFromConfigL(localeParamName, aLocale)) |
|
826 PrintErrorL(_L("Locale was not found!"), KErrNotFound); |
|
827 } |
|
828 |
|
829 void CScrTestStep::GetLocalisedComponentsFromConfigL(RPointerArray<Usif::CLocalizableComponentInfo>& aComponentInfo) |
|
830 { |
|
831 TInt localesCount = 0; |
|
832 if (!GetIntFromConfig(ConfigSection(), _L("LocalesCount"), localesCount)) |
|
833 PrintErrorL(_L("Locales count was not found!"), KErrNotFound); |
|
834 |
|
835 for (TUint i = 0; i < localesCount; ++i) |
|
836 { |
|
837 TPtrC componentName, vendorName; |
|
838 TLanguage locale; |
|
839 GetComponentLocalizablesFromConfigL(i, componentName, vendorName, locale); |
|
840 |
|
841 CLocalizableComponentInfo* localisableComponentInfo(0); |
|
842 // If-condition is used for the sake of coverage |
|
843 if(i) |
|
844 { |
|
845 localisableComponentInfo = CLocalizableComponentInfo::NewLC(componentName, vendorName, locale); |
|
846 } |
|
847 else |
|
848 { |
|
849 localisableComponentInfo = CLocalizableComponentInfo::NewL(componentName, vendorName, locale); |
|
850 CleanupStack::PushL(localisableComponentInfo); |
|
851 } |
|
852 aComponentInfo.AppendL(localisableComponentInfo); |
|
853 CleanupStack::Pop(localisableComponentInfo); |
|
854 } |
|
855 } |
|
856 |
|
857 TBool CScrTestStep::GetInstalledDrivesFromConfigL(TDriveList& aDriveList, const TDesC& aAttributeName) |
|
858 { |
|
859 TPtrC installedDrives; |
|
860 if (!GetStringFromConfig(ConfigSection(), aAttributeName, installedDrives)) |
|
861 { |
|
862 return EFalse; |
|
863 } |
|
864 |
|
865 TLex parser(installedDrives); |
|
866 TChar currentChar; |
|
867 aDriveList.FillZ(KMaxDrives); |
|
868 |
|
869 parser.Mark(); |
|
870 while(!parser.Eos()) |
|
871 { |
|
872 currentChar = parser.Get(); |
|
873 if(KComponentIdDelimeter == currentChar || parser.Eos()) |
|
874 { |
|
875 TPtrC token = parser.MarkedToken(); |
|
876 TLex tokenLex(token); |
|
877 TInt driveNumber(0); |
|
878 driveNumber = token[0] - 'A'; |
|
879 if(driveNumber < EDriveA || driveNumber > EDriveZ) |
|
880 { |
|
881 ERR_PRINTF3(_L("%S contains an unexpected token(%S)."), &aAttributeName, &token); |
|
882 User::Leave(KErrArgument); |
|
883 } |
|
884 ++aDriveList[driveNumber]; |
|
885 parser.Mark(); |
|
886 } |
|
887 } |
|
888 return ETrue; |
|
889 } |
|
890 |
|
891 TBool CScrTestStep::GetScomoStateFromConfigL(TScomoState& aScomoState, const TDesC& aAttributeName) |
|
892 { |
|
893 TInt tempScomoState(0); |
|
894 if (!GetIntFromConfig(ConfigSection(), aAttributeName, tempScomoState)) |
|
895 return EFalse; |
|
896 |
|
897 aScomoState = static_cast<TScomoState>(tempScomoState); |
|
898 return ETrue; |
|
899 } |
|
900 |
|
901 |
|
902 TInt CScrTestStep::GetSetSizeFromConfigL() |
|
903 { |
|
904 TInt setSize(1); |
|
905 GetIntFromConfig(ConfigSection(), KSetSizeName, setSize); |
|
906 if (setSize < 1) |
|
907 PrintErrorL(_L("Invalid set size in component filter definition"), KErrArgument); |
|
908 return setSize; |
|
909 } |
|
910 |
|
911 Usif::TComponentId CScrTestStep::AddNonLocalisableComponentL() |
|
912 { |
|
913 TPtrC componentName; |
|
914 GetComponentNameFromConfigL(componentName); |
|
915 TPtrC vendorName;; |
|
916 GetVendorNameFromConfigL(vendorName); |
|
917 TPtrC swTypeName; |
|
918 GetSoftwareTypeNameL(swTypeName); |
|
919 |
|
920 TScrComponentOperationType operationType(EScrCompInstall); |
|
921 TInt opTypeInt(0); |
|
922 if(GetIntFromConfig(ConfigSection(), KOperationType, opTypeInt)) |
|
923 { |
|
924 operationType = static_cast<TScrComponentOperationType>(opTypeInt); |
|
925 } |
|
926 |
|
927 Usif::TComponentId componentId; |
|
928 TPtrC globalIdName; |
|
929 if(GetGlobalIdNameL(globalIdName)) |
|
930 componentId = iScrSession.AddComponentL(componentName, vendorName, swTypeName, &globalIdName, operationType); |
|
931 else |
|
932 componentId = iScrSession.AddComponentL(componentName, vendorName, swTypeName, NULL, operationType); |
|
933 |
|
934 return componentId; |
|
935 } |
|
936 |
|
937 void CScrTestStep::ReadFilterPropertiesL(CComponentFilter* aFilter, TInt aPropertiesCount) |
|
938 { |
|
939 for (TInt i = 0; i < aPropertiesCount; ++i) |
|
940 { |
|
941 TBuf<MAX_SCR_PARAM_LENGTH> propertyNameParam, intAttributeParam, strAttributeParam, localeAttributeParam; |
|
942 |
|
943 propertyNameParam = _L("FilterPropertyName"); |
|
944 GenerateIndexedAttributeNameL(propertyNameParam, i); |
|
945 |
|
946 TPtrC propertyName; |
|
947 if (!GetStringFromConfig(ConfigSection(), propertyNameParam, propertyName)) |
|
948 { |
|
949 PrintErrorL(_L("Property name for property was not found in filter"), KErrNotFound); |
|
950 } |
|
951 |
|
952 intAttributeParam = _L("FilterIntProperty"); |
|
953 GenerateIndexedAttributeNameL(intAttributeParam, i); |
|
954 |
|
955 strAttributeParam = _L("FilterStringProperty"); |
|
956 GenerateIndexedAttributeNameL(strAttributeParam, i); |
|
957 |
|
958 localeAttributeParam = _L("FilterPropertyLocale"); |
|
959 GenerateIndexedAttributeNameL(localeAttributeParam, i); |
|
960 |
|
961 TPtrC propertyStrValue; |
|
962 TInt64 int64Value; |
|
963 |
|
964 if (Get64BitIntegerFromConfigL(intAttributeParam, int64Value)) |
|
965 { |
|
966 aFilter->AddPropertyL(propertyName, int64Value); |
|
967 continue; |
|
968 } |
|
969 |
|
970 if (!GetStringFromConfig(ConfigSection(), strAttributeParam, propertyStrValue)) |
|
971 continue; |
|
972 |
|
973 TLanguage locale; |
|
974 if (GetLocaleFromConfigL(localeAttributeParam, locale)) |
|
975 { |
|
976 aFilter->AddPropertyL(propertyName, propertyStrValue, locale); |
|
977 } |
|
978 else |
|
979 { |
|
980 HBufC8* buffer8bit = ConvertBufferTo8bitL(propertyStrValue); |
|
981 CleanupStack::PushL(buffer8bit); |
|
982 aFilter->AddPropertyL(propertyName, *buffer8bit); |
|
983 CleanupStack::PopAndDestroy(buffer8bit); |
|
984 } |
|
985 } |
|
986 } |
|
987 |
|
988 CComponentFilter* CScrTestStep::ReadComponentFilterFromConfigLC() |
|
989 { |
|
990 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
|
991 |
|
992 TPtrC filterName; |
|
993 if (GetStringFromConfig(ConfigSection(), _L("FilterName"), filterName)) |
|
994 componentFilter->SetNameL(filterName); |
|
995 |
|
996 TPtrC filterVendor; |
|
997 if (GetStringFromConfig(ConfigSection(), _L("FilterVendor"), filterVendor)) |
|
998 componentFilter->SetVendorL(filterVendor); |
|
999 |
|
1000 TPtrC filterSwType; |
|
1001 if (GetStringFromConfig(ConfigSection(), _L("FilterSoftwareType"), filterSwType)) |
|
1002 componentFilter->SetSoftwareTypeL(filterSwType); |
|
1003 |
|
1004 TScomoState scomoState; |
|
1005 if (GetScomoStateFromConfigL(scomoState, _L("FilterScomoState"))) |
|
1006 componentFilter->SetScomoStateL(scomoState); |
|
1007 |
|
1008 TDriveList filterInstalledDrives; |
|
1009 _LIT(KFilterInstalledDrives, "FilterDrivesList"); |
|
1010 if (GetInstalledDrivesFromConfigL(filterInstalledDrives, KFilterInstalledDrives())) |
|
1011 componentFilter->SetInstalledDrivesL(filterInstalledDrives); |
|
1012 |
|
1013 TBool filterIsRemovable(EFalse); |
|
1014 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsRemovable"), filterIsRemovable)) |
|
1015 componentFilter->SetRemovable(filterIsRemovable); |
|
1016 |
|
1017 TInt propertiesCount(0); |
|
1018 if (GetIntFromConfig(ConfigSection(), _L("FilterPropertiesCount"), propertiesCount)) |
|
1019 { |
|
1020 ReadFilterPropertiesL(componentFilter, propertiesCount); |
|
1021 } |
|
1022 |
|
1023 TPtrC filterFile; |
|
1024 if (GetStringFromConfig(ConfigSection(), _L("FilterFile"), filterFile)) |
|
1025 componentFilter->SetFileL(filterFile); |
|
1026 |
|
1027 TBool filterIsDrmProtected(EFalse); |
|
1028 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsDrmProtected"), filterIsDrmProtected)) |
|
1029 componentFilter->SetDrmProtected(filterIsDrmProtected); |
|
1030 |
|
1031 TBool filterIsHidden(EFalse); |
|
1032 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsHidden"), filterIsHidden)) |
|
1033 componentFilter->SetHidden(filterIsHidden); |
|
1034 |
|
1035 TBool filterIsKnownRevoked(EFalse); |
|
1036 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsKnownRevoked"), filterIsKnownRevoked)) |
|
1037 componentFilter->SetKnownRevoked(filterIsKnownRevoked); |
|
1038 |
|
1039 TBool filterIsOriginVerified(EFalse); |
|
1040 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsOriginVerified"), filterIsOriginVerified)) |
|
1041 componentFilter->SetOriginVerified(filterIsOriginVerified); |
|
1042 |
|
1043 return componentFilter; |
|
1044 } |