|
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 * 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 #include <usif/sif/sifutils.h> |
|
26 |
|
27 using namespace Usif; |
|
28 |
|
29 |
|
30 CScrTestStep::CScrTestStep(CScrTestServer& aParent) |
|
31 // Constructor. |
|
32 : iParent(aParent) |
|
33 { |
|
34 } |
|
35 |
|
36 CScrTestStep::~CScrTestStep() |
|
37 // Destructor. |
|
38 { |
|
39 iScrSession.Close(); |
|
40 } |
|
41 |
|
42 void CScrTestStep:: MarkAsPerformanceStep() |
|
43 { |
|
44 iIsPerformanceTest = ETrue; |
|
45 } |
|
46 |
|
47 void CScrTestStep::PrintPerformanceLog(TTime aTime) |
|
48 { |
|
49 TDateTime timer = aTime.DateTime(); |
|
50 INFO_PRINTF6(_L("%S,%d:%d:%d:%d"), &KPerformanceTestInfo(), timer.Hour(), timer.Minute(), timer.Second(), timer.MicroSecond()); |
|
51 } |
|
52 |
|
53 void CScrTestStep::StartTimer() |
|
54 { |
|
55 iStartTime.HomeTime(); |
|
56 PrintPerformanceLog(iStartTime); |
|
57 } |
|
58 |
|
59 void CScrTestStep::StopTimerAndPrintResultL() |
|
60 { |
|
61 TTime endTime; |
|
62 endTime.HomeTime(); |
|
63 PrintPerformanceLog(endTime); |
|
64 |
|
65 TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(iStartTime); |
|
66 TInt actualDuration = I64INT(duration.Int64())/1000; // in millisecond |
|
67 |
|
68 if(iTimeMeasuredExternally) |
|
69 { // if the time is measured by the scr accessor, update the actual time with the external time. |
|
70 actualDuration = iTimeMeasuredExternally; |
|
71 } |
|
72 |
|
73 TInt maxDuration = 0; |
|
74 if(!GetIntFromConfig(ConfigSection(), KMaxDurationName, maxDuration)) |
|
75 { |
|
76 ERR_PRINTF2(_L("%S could not be found in configuration."), &KMaxDurationName()); |
|
77 User::Leave(KErrNotFound); |
|
78 } |
|
79 else |
|
80 { |
|
81 INFO_PRINTF3(_L("%S,%d"), &KMaxTestCaseDuration(), maxDuration); |
|
82 INFO_PRINTF3(_L("%S,%d"), &KActualTestCaseDuration(), actualDuration); |
|
83 } |
|
84 |
|
85 if(actualDuration <= maxDuration) |
|
86 { |
|
87 INFO_PRINTF2(_L("This test meets performance requirement (Duration=%d)."), actualDuration); |
|
88 } |
|
89 else |
|
90 { |
|
91 ERR_PRINTF2(_L("This test does not meet performance requirement (Duration=%d)."), actualDuration); |
|
92 SetTestStepResult(EFail); |
|
93 } |
|
94 } |
|
95 |
|
96 void CScrTestStep::ImplTestStepPreambleL() |
|
97 /** |
|
98 From COomTestStep. |
|
99 */ |
|
100 { |
|
101 User::LeaveIfError(iScrSession.Connect()); |
|
102 if(iIsPerformanceTest) |
|
103 { |
|
104 StartTimer(); |
|
105 } |
|
106 } |
|
107 |
|
108 void CScrTestStep::ImplTestStepL() |
|
109 /** |
|
110 From COomTestStep. |
|
111 */ |
|
112 { |
|
113 // empty |
|
114 } |
|
115 |
|
116 |
|
117 void CScrTestStep::ImplTestStepPostambleL() |
|
118 /** |
|
119 From COomTestStep. |
|
120 */ |
|
121 { |
|
122 if(iIsPerformanceTest) |
|
123 { |
|
124 StopTimerAndPrintResultL(); |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 RScsClientBase* CScrTestStep::ClientHandle() |
|
130 /** |
|
131 From COomTestStep. |
|
132 */ |
|
133 { |
|
134 return &iScrSession; |
|
135 } |
|
136 |
|
137 void CScrTestStep::PrintErrorL(const TDesC& aMsg, TInt aErrNum,...) |
|
138 { |
|
139 VA_LIST list; |
|
140 VA_START(list, aErrNum); |
|
141 |
|
142 RBuf msgBuf; |
|
143 msgBuf.CreateL(MAX_SCR_ERROR_MESSAGE_LENGTH); |
|
144 msgBuf.CleanupClosePushL(); |
|
145 msgBuf.AppendFormatList(aMsg, list); |
|
146 |
|
147 ERR_PRINTF1(msgBuf); |
|
148 SetTestStepResult(EFail); |
|
149 |
|
150 CleanupStack::PopAndDestroy(&msgBuf); |
|
151 User::Leave(aErrNum); |
|
152 } |
|
153 |
|
154 //--------------------Code for properties' comparison |
|
155 |
|
156 TBool operator ==(const TDriveList& aLhsEntry, const TDriveList& aRhsEntry) |
|
157 { |
|
158 // If two drives are equal, each byte of them must be zero or non-zero together. |
|
159 // Otherwise, the drive lists are different. |
|
160 for(TInt driveNumber=EDriveA; driveNumber<=EDriveZ; ++driveNumber) |
|
161 { |
|
162 if((aLhsEntry[driveNumber] || aRhsEntry[driveNumber]) && !(aLhsEntry[driveNumber] && aRhsEntry[driveNumber])) |
|
163 return EFalse; |
|
164 } |
|
165 return ETrue; |
|
166 } |
|
167 |
|
168 TBool operator ==(const CComponentEntry& aLhsEntry, const CComponentEntry& aRhsEntry) |
|
169 { |
|
170 return (aLhsEntry.ComponentId() == aRhsEntry.ComponentId() && |
|
171 aLhsEntry.Name() == aRhsEntry.Name()&& |
|
172 aLhsEntry.Vendor() == aRhsEntry.Vendor() && |
|
173 aLhsEntry.SoftwareType() == aRhsEntry.SoftwareType() && |
|
174 aLhsEntry.GlobalId() == aRhsEntry.GlobalId() && |
|
175 aLhsEntry.IsRemovable() == aRhsEntry.IsRemovable() && |
|
176 aLhsEntry.IsDrmProtected() == aRhsEntry.IsDrmProtected() && |
|
177 aLhsEntry.IsHidden() == aRhsEntry.IsHidden() && |
|
178 aLhsEntry.IsKnownRevoked() == aRhsEntry.IsKnownRevoked() && |
|
179 aLhsEntry.IsOriginVerified() == aRhsEntry.IsOriginVerified() && |
|
180 aLhsEntry.ComponentSize() == aRhsEntry.ComponentSize() && |
|
181 aLhsEntry.ScomoState() == aRhsEntry.ScomoState() && |
|
182 aLhsEntry.InstalledDrives() == aRhsEntry.InstalledDrives() && |
|
183 aLhsEntry.Version() == aRhsEntry.Version()); |
|
184 } |
|
185 |
|
186 TBool operator !=(const CComponentEntry& aLhsEntry, const CComponentEntry& aRhsEntry) |
|
187 { |
|
188 return !operator ==(aLhsEntry, aRhsEntry); |
|
189 } |
|
190 |
|
191 TBool operator ==(CLocalizablePropertyEntry& lhsEntry, CLocalizablePropertyEntry& rhsEntry) |
|
192 { |
|
193 return lhsEntry.StrValue() == rhsEntry.StrValue(); |
|
194 } |
|
195 |
|
196 TBool operator ==(CBinaryPropertyEntry& lhsEntry, CBinaryPropertyEntry& rhsEntry) |
|
197 { |
|
198 return lhsEntry.BinaryValue() == rhsEntry.BinaryValue(); |
|
199 } |
|
200 |
|
201 TBool operator ==(CIntPropertyEntry& lhsEntry, CIntPropertyEntry& rhsEntry) |
|
202 { |
|
203 return lhsEntry.Int64Value() == rhsEntry.Int64Value(); |
|
204 } |
|
205 |
|
206 template <class T> TBool CompareProperty(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
207 { |
|
208 // Cannot use reference dynamic_cast - Symbian does not support std::bad_cast or any other exception |
|
209 T& lhsSubclassEntry = static_cast<T &>(lhsEntry); |
|
210 T& rhsSubclassEntry = static_cast<T &>(rhsEntry); |
|
211 return (lhsSubclassEntry == rhsSubclassEntry); |
|
212 } |
|
213 |
|
214 TBool operator ==(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
215 { |
|
216 CPropertyEntry::TPropertyType lhsPropertyType = lhsEntry.PropertyType(); |
|
217 CPropertyEntry::TPropertyType rhsPropertyType = rhsEntry.PropertyType(); |
|
218 if (lhsPropertyType != rhsPropertyType) |
|
219 return EFalse; |
|
220 |
|
221 switch (rhsPropertyType) |
|
222 { |
|
223 case CPropertyEntry::EBinaryProperty: |
|
224 { |
|
225 return CompareProperty<CBinaryPropertyEntry>(lhsEntry, rhsEntry); |
|
226 } |
|
227 case CPropertyEntry::ELocalizedProperty: |
|
228 { |
|
229 return CompareProperty<CLocalizablePropertyEntry>(lhsEntry, rhsEntry); |
|
230 } |
|
231 case CPropertyEntry::EIntProperty: |
|
232 { |
|
233 return CompareProperty<CIntPropertyEntry>(lhsEntry, rhsEntry); |
|
234 } |
|
235 default: |
|
236 ASSERT(0); |
|
237 } |
|
238 ASSERT(0); |
|
239 return ETrue; // Should not reach here |
|
240 } |
|
241 |
|
242 TBool operator !=(CPropertyEntry& lhsEntry, CPropertyEntry& rhsEntry) |
|
243 { |
|
244 return !operator ==(lhsEntry, rhsEntry); |
|
245 } |
|
246 |
|
247 |
|
248 TBool CScrTestStep::ComparePropertiesL(RPointerArray<CPropertyEntry>& aFoundProperties, RPointerArray<CPropertyEntry>& aExpectedProperties) |
|
249 { |
|
250 TInt foundPropertiesCount = aFoundProperties.Count(); |
|
251 |
|
252 if (aExpectedProperties.Count() != foundPropertiesCount) |
|
253 { |
|
254 ERR_PRINTF3(_L("The number of expected properties %d did not match the number of found properties %d."), aExpectedProperties.Count(), foundPropertiesCount); |
|
255 return EFalse; |
|
256 } |
|
257 |
|
258 for (TInt i = 0; i < foundPropertiesCount; ++i) |
|
259 { |
|
260 if (*aFoundProperties[i] != *aExpectedProperties[i]) |
|
261 { |
|
262 ERR_PRINTF2(_L("Property %d did not match."), i); |
|
263 return EFalse; |
|
264 } |
|
265 } |
|
266 return ETrue; |
|
267 } |
|
268 |
|
269 TBool operator ==(const CGlobalComponentId& lhsEntry, const CGlobalComponentId& rhsEntry) |
|
270 { |
|
271 return (lhsEntry.GlobalIdName() == rhsEntry.GlobalIdName()) && |
|
272 (lhsEntry.SoftwareTypeName() == rhsEntry.SoftwareTypeName()); |
|
273 } |
|
274 |
|
275 TBool operator !=(const CGlobalComponentId& lhsEntry, const CGlobalComponentId& rhsEntry) |
|
276 { |
|
277 return !operator==(lhsEntry,rhsEntry); |
|
278 } |
|
279 |
|
280 TBool operator ==(const CVersionedComponentId& lhsEntry, const CVersionedComponentId& rhsEntry) |
|
281 { |
|
282 return (lhsEntry.GlobalId() == rhsEntry.GlobalId()) && |
|
283 ((lhsEntry.VersionFrom()?*lhsEntry.VersionFrom():KNullDesC()) == (rhsEntry.VersionFrom()?*rhsEntry.VersionFrom():KNullDesC())) && |
|
284 ((lhsEntry.VersionTo()?*lhsEntry.VersionTo():KNullDesC()) == (rhsEntry.VersionTo()?*rhsEntry.VersionTo():KNullDesC())); |
|
285 } |
|
286 |
|
287 TBool operator !=(CVersionedComponentId& lhsEntry, CVersionedComponentId& rhsEntry) |
|
288 { |
|
289 return !operator==(lhsEntry,rhsEntry); |
|
290 } |
|
291 |
|
292 TBool CScrTestStep::CompareVersionedComponentIdsL(RPointerArray<CVersionedComponentId>& aFoundVerCompIdList, RPointerArray<CVersionedComponentId>& aExpectedVerCompIdList) |
|
293 { |
|
294 TInt foundVerCompIdsCount = aFoundVerCompIdList.Count(); |
|
295 TInt expectedVerCompIdsCount = aExpectedVerCompIdList.Count(); |
|
296 |
|
297 if (foundVerCompIdsCount != expectedVerCompIdsCount) |
|
298 { |
|
299 ERR_PRINTF3(_L("The number of expected versioned component Ids %d did not match the number of found ones %d."), expectedVerCompIdsCount, foundVerCompIdsCount); |
|
300 return EFalse; |
|
301 } |
|
302 |
|
303 for (TInt i = 0; i < foundVerCompIdsCount; ++i) |
|
304 { |
|
305 if (*aFoundVerCompIdList[i] != *aExpectedVerCompIdList[i]) |
|
306 { |
|
307 ERR_PRINTF2(_L("Versioned Component Id %d did not match."), i); |
|
308 return EFalse; |
|
309 } |
|
310 } |
|
311 |
|
312 return ETrue; |
|
313 } |
|
314 |
|
315 void CScrTestStep::CompareComponentIdsL(RArray<TComponentId>& aFoundComponents, RArray<TComponentId>& aExpectedComponents) |
|
316 { |
|
317 TInt foundComponentsCount = aFoundComponents.Count(); |
|
318 if (foundComponentsCount != aExpectedComponents.Count()) |
|
319 { |
|
320 ERR_PRINTF3(_L("The number of expected components %d did not match the number of found components %d."), aExpectedComponents.Count(), foundComponentsCount); |
|
321 SetTestStepResult(EFail); |
|
322 return; |
|
323 } |
|
324 |
|
325 aFoundComponents.Sort(); |
|
326 aExpectedComponents.Sort(); |
|
327 for (TInt i = 0; i < foundComponentsCount; ++i) |
|
328 { |
|
329 if (aFoundComponents[i] < aExpectedComponents[i]) |
|
330 { |
|
331 ERR_PRINTF2(_L("Component %d was not expected in the test."), aFoundComponents[i]); |
|
332 SetTestStepResult(EFail); |
|
333 break; |
|
334 } |
|
335 else if (aExpectedComponents[i] < aFoundComponents[i]) |
|
336 { |
|
337 ERR_PRINTF2(_L("Component %d was expected, but not found."), aExpectedComponents[i]); |
|
338 SetTestStepResult(EFail); |
|
339 break; |
|
340 } |
|
341 } |
|
342 } |
|
343 |
|
344 |
|
345 // Helper functions for getting commong attributes from configuration |
|
346 |
|
347 void CScrTestStep::GetSoftwareTypeNameL(TPtrC& aSwTypeName) |
|
348 { |
|
349 if (!GetStringFromConfig(ConfigSection(), KSoftwareTypeName, aSwTypeName)) |
|
350 PrintErrorL(_L("Software Type was not found!"), KErrNotFound); |
|
351 } |
|
352 |
|
353 TBool CScrTestStep::GetGlobalIdNameL(TPtrC& aGlobalIdName) |
|
354 { |
|
355 if (!GetStringFromConfig(ConfigSection(), KGlobalIdName, aGlobalIdName)) |
|
356 return EFalse; |
|
357 return ETrue; |
|
358 } |
|
359 |
|
360 Usif::CGlobalComponentId* CScrTestStep::GetGlobalComponentIdLC() |
|
361 { |
|
362 TPtrC globalIdName; |
|
363 if (!GetGlobalIdNameL(globalIdName)) |
|
364 PrintErrorL(_L("Global Id Name was not found!"), KErrNotFound); |
|
365 |
|
366 TPtrC swTypeName; |
|
367 GetSoftwareTypeNameL(swTypeName); |
|
368 |
|
369 return CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
370 } |
|
371 |
|
372 Usif::CGlobalComponentId* CScrTestStep::GetGlobalComponentIdLC(const TDesC& aGlobalIdName, const TDesC& aSwTypeName) |
|
373 { |
|
374 TPtrC globalIdName; |
|
375 if (!GetStringFromConfig(ConfigSection(), aGlobalIdName, globalIdName)) |
|
376 PrintErrorL(_L("Global Id Name was not found!"), KErrNotFound); |
|
377 |
|
378 TPtrC swTypeName; |
|
379 if (!GetStringFromConfig(ConfigSection(), aSwTypeName, swTypeName)) |
|
380 PrintErrorL(_L("Software Type Name was not found!"), KErrNotFound); |
|
381 |
|
382 return CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
383 } |
|
384 |
|
385 HBufC* CScrTestStep::GetVersionFromConfigL(const TDesC& aVersionName) |
|
386 { |
|
387 TPtrC version(KNullDesC()); |
|
388 if(!GetStringFromConfig(ConfigSection(), aVersionName, version)) |
|
389 return NULL; |
|
390 return version.AllocL(); |
|
391 } |
|
392 |
|
393 void CScrTestStep::GetExpectedVersionedComponentIdListL(RPointerArray<CVersionedComponentId>& aVerCompIdList) |
|
394 { |
|
395 TInt globalIdCount(0); |
|
396 if(!GetIntFromConfig(ConfigSection(), KGlobalIdCount, globalIdCount)) |
|
397 PrintErrorL(_L("Global Id count was not found!"), KErrNotFound); |
|
398 |
|
399 TBuf<MAX_SCR_PARAM_LENGTH> paramGlobalIdName, paramSwTypeName, paramVersionFrom, paramVersionTo; |
|
400 |
|
401 for(TInt i=0; i<globalIdCount; ++i) |
|
402 { |
|
403 paramGlobalIdName = KGlobalIdName; |
|
404 paramSwTypeName = KSoftwareTypeName; |
|
405 paramVersionFrom = KVersionFrom; |
|
406 paramVersionTo = KVersionTo; |
|
407 |
|
408 GenerateIndexedAttributeNameL(paramGlobalIdName, i); |
|
409 GenerateIndexedAttributeNameL(paramSwTypeName, i); |
|
410 GenerateIndexedAttributeNameL(paramVersionFrom, i); |
|
411 GenerateIndexedAttributeNameL(paramVersionTo, i); |
|
412 |
|
413 TPtrC globalIdName; |
|
414 if (!GetStringFromConfig(ConfigSection(), paramGlobalIdName, globalIdName)) |
|
415 { |
|
416 ERR_PRINTF2(_L("The %S param could not be found in configuration."), ¶mGlobalIdName); |
|
417 User::Leave(KErrNotFound); |
|
418 } |
|
419 |
|
420 TPtrC swTypeName; |
|
421 if (!GetStringFromConfig(ConfigSection(), paramSwTypeName, swTypeName)) |
|
422 { |
|
423 ERR_PRINTF2(_L("The %S param could not be found in configuration."), ¶mSwTypeName); |
|
424 User::Leave(KErrNotFound); |
|
425 } |
|
426 |
|
427 HBufC *versionFrom = GetVersionFromConfigL(paramVersionFrom); |
|
428 if(versionFrom) |
|
429 CleanupStack::PushL(versionFrom); |
|
430 HBufC *versionTo = GetVersionFromConfigL(paramVersionTo); |
|
431 if(versionTo) |
|
432 CleanupStack::PushL(versionTo); |
|
433 |
|
434 CGlobalComponentId *globalId = CGlobalComponentId::NewLC(globalIdName, swTypeName); |
|
435 CVersionedComponentId *verCompId = CVersionedComponentId::NewLC(*globalId, versionFrom, versionTo); |
|
436 aVerCompIdList.AppendL(verCompId); |
|
437 CleanupStack::Pop(verCompId); // owned by the array |
|
438 CleanupStack::PopAndDestroy(globalId); |
|
439 if(versionTo) |
|
440 CleanupStack::PopAndDestroy(versionTo); |
|
441 if(versionFrom) |
|
442 CleanupStack::PopAndDestroy(versionFrom); |
|
443 } |
|
444 } |
|
445 |
|
446 void CScrTestStep::AppendSharedComponentIdL(Usif::TComponentId aComponentId) |
|
447 { |
|
448 TBuf<MAX_SCR_BUFFER_LENGTH> componentIdBuf; |
|
449 ReadSharedDataL(KComponentIdName, componentIdBuf); |
|
450 componentIdBuf.AppendNum(aComponentId); |
|
451 componentIdBuf.Append(KComponentIdDelimeter); |
|
452 WriteSharedDataL(KComponentIdName, componentIdBuf, ESetText); |
|
453 } |
|
454 |
|
455 void CScrTestStep::ReadAllSharedComponentIdsL(RArray<TInt>& aComponentList) |
|
456 { |
|
457 TBuf<MAX_SCR_BUFFER_LENGTH> componentIdBuf; |
|
458 ReadSharedDataL(KComponentIdName, componentIdBuf); |
|
459 |
|
460 TLex parser(componentIdBuf); |
|
461 TChar currentChar; |
|
462 |
|
463 parser.Mark(); |
|
464 while(!parser.Eos()) |
|
465 { |
|
466 currentChar = parser.Get(); |
|
467 if(KComponentIdDelimeter == currentChar) |
|
468 { |
|
469 TPtrC token = parser.MarkedToken(); |
|
470 TLex tokenLex(token); |
|
471 TInt componentId; |
|
472 tokenLex.Val(componentId); |
|
473 aComponentList.AppendL(componentId); |
|
474 parser.Mark(); |
|
475 } |
|
476 } |
|
477 } |
|
478 |
|
479 TInt CScrTestStep::ReadSharedComponentIdL(TInt aOffset) |
|
480 { |
|
481 RArray<TInt> componentList; |
|
482 CleanupClosePushL(componentList); |
|
483 ReadAllSharedComponentIdsL(componentList); |
|
484 |
|
485 TInt maxListIndex = componentList.Count() - 1; |
|
486 if(aOffset<0 || aOffset>maxListIndex) |
|
487 PrintErrorL(_L("Component Id offset is not valid!"), KErrArgument); |
|
488 |
|
489 TInt componentId = componentList[maxListIndex - aOffset]; |
|
490 CleanupStack::PopAndDestroy(&componentList); |
|
491 return componentId; |
|
492 } |
|
493 |
|
494 TBool CScrTestStep::GetLocaleFromConfigL(const TDesC& aParamName, TLanguage &aLocale) |
|
495 { |
|
496 TInt localeParam; |
|
497 if (!GetIntFromConfig(ConfigSection(), aParamName, localeParam)) |
|
498 return EFalse; |
|
499 aLocale = static_cast<TLanguage>(localeParam); |
|
500 return ETrue; |
|
501 } |
|
502 |
|
503 TBool CScrTestStep::GetLocaleFromConfigL(TLanguage &aLocale) |
|
504 { |
|
505 return GetLocaleFromConfigL(KPropertyLocaleParam, aLocale); |
|
506 } |
|
507 |
|
508 TInt CScrTestStep::GetComponentIdL() |
|
509 { |
|
510 TInt componentId(0); |
|
511 if(GetIntFromConfig(ConfigSection(), KComponentIdName, componentId)) |
|
512 return componentId; |
|
513 |
|
514 TInt componentIdOffset; |
|
515 if (!GetIntFromConfig(ConfigSection(), KComponentIdOffsetName, componentIdOffset)) |
|
516 PrintErrorL(_L("ComponentId Offset was not found!"), KErrNotFound); |
|
517 |
|
518 componentId = ReadSharedComponentIdL(componentIdOffset); |
|
519 INFO_PRINTF2(_L("Component Id %d"), componentId); |
|
520 return componentId; |
|
521 } |
|
522 |
|
523 void CScrTestStep::GetFileNameFromConfigL(TPtrC& aFileName) |
|
524 { |
|
525 if (!GetStringFromConfig(ConfigSection(), KFileName, aFileName)) |
|
526 PrintErrorL(_L("FileName was not found!"), KErrNotFound); |
|
527 } |
|
528 |
|
529 void CScrTestStep::GetFileNameListFromConfigL(RPointerArray<HBufC>& aFileList) |
|
530 { |
|
531 TInt fileCount(0); |
|
532 if(!GetIntFromConfig(ConfigSection(), KFileCount, fileCount)) |
|
533 PrintErrorL(_L("File count was not found!"), KErrNotFound); |
|
534 |
|
535 TBuf<MAX_SCR_PARAM_LENGTH> paramName; |
|
536 for(TInt i=0; i<fileCount; ++i) |
|
537 { |
|
538 paramName = KFileName; |
|
539 GenerateIndexedAttributeNameL(paramName, i); |
|
540 TPtrC fileName; |
|
541 if (!GetStringFromConfig(ConfigSection(), paramName, fileName)) |
|
542 { |
|
543 ERR_PRINTF2(_L("The File Name param %S could not be found in configuration."), ¶mName); |
|
544 User::Leave(KErrNotFound); |
|
545 } |
|
546 HBufC* fileNameBuf = fileName.AllocLC(); |
|
547 aFileList.AppendL(fileNameBuf); |
|
548 CleanupStack::Pop(fileNameBuf); |
|
549 } |
|
550 } |
|
551 |
|
552 void CScrTestStep::GetComponentNameFromConfigL(TPtrC& aComponentName) |
|
553 { |
|
554 if(!GetStringFromConfig(ConfigSection(), KComponentName, aComponentName)) |
|
555 PrintErrorL(_L("Component name was not found!"), KErrNotFound); |
|
556 } |
|
557 |
|
558 void CScrTestStep::GetVendorNameFromConfigL(TPtrC& aVendorName) |
|
559 { |
|
560 if(!GetStringFromConfig(ConfigSection(), KVendorName, aVendorName)) |
|
561 PrintErrorL(_L("Vendor name was not found!"), KErrNotFound); |
|
562 } |
|
563 |
|
564 CComponentEntry* CScrTestStep::GetComponentEntryFromConfigLC(TBool aIsSingle, TInt aIndex) |
|
565 { |
|
566 // First, we need to generate the property name |
|
567 TBuf<MAX_SCR_PARAM_LENGTH> componentIdParam, componentIdOffsetParam, componentNameParam, componentVendorParam, softwareTypeNameParam; |
|
568 TBuf<MAX_SCR_PARAM_LENGTH> globalIdParam, installedDrivesParam, isRemovableParam, componentSizeParam, scomoStateParam, versionParam; |
|
569 TBuf<MAX_SCR_PARAM_LENGTH> isDrmProtectedParam, isHiddenParam, isKnownRevokedParam, isOriginVerifiedParam; |
|
570 |
|
571 componentIdParam = KComponentIdName; |
|
572 componentIdOffsetParam = KComponentIdOffsetName; |
|
573 componentNameParam = KComponentName; |
|
574 componentVendorParam = KVendorName; |
|
575 softwareTypeNameParam = KSoftwareTypeName; |
|
576 globalIdParam = KGlobalIdName; |
|
577 isRemovableParam = KRemovableName; |
|
578 isDrmProtectedParam = KDrmProtectedName; |
|
579 isHiddenParam = KHiddenName; |
|
580 isKnownRevokedParam = KKnownRevokedName; |
|
581 isOriginVerifiedParam = KOriginVerifiedName; |
|
582 componentSizeParam = KComponentSizeName; |
|
583 scomoStateParam = KComponentScomoStateName; |
|
584 installedDrivesParam = KInstalledDrivesName; |
|
585 versionParam = KVersionName; |
|
586 |
|
587 if (!aIsSingle) |
|
588 { |
|
589 GenerateIndexedAttributeNameL(componentIdParam, aIndex); |
|
590 GenerateIndexedAttributeNameL(componentIdOffsetParam, aIndex); |
|
591 GenerateIndexedAttributeNameL(componentNameParam, aIndex); |
|
592 GenerateIndexedAttributeNameL(componentVendorParam, aIndex); |
|
593 GenerateIndexedAttributeNameL(softwareTypeNameParam, aIndex); |
|
594 GenerateIndexedAttributeNameL(globalIdParam, aIndex); |
|
595 GenerateIndexedAttributeNameL(isRemovableParam, aIndex); |
|
596 GenerateIndexedAttributeNameL(isDrmProtectedParam, aIndex); |
|
597 GenerateIndexedAttributeNameL(isHiddenParam, aIndex); |
|
598 GenerateIndexedAttributeNameL(isKnownRevokedParam, aIndex); |
|
599 GenerateIndexedAttributeNameL(isOriginVerifiedParam, aIndex); |
|
600 GenerateIndexedAttributeNameL(componentSizeParam, aIndex); |
|
601 GenerateIndexedAttributeNameL(scomoStateParam, aIndex); |
|
602 GenerateIndexedAttributeNameL(installedDrivesParam, aIndex); |
|
603 GenerateIndexedAttributeNameL(versionParam, aIndex); |
|
604 } |
|
605 |
|
606 TComponentId componentId(0); |
|
607 if (!GetIntFromConfig(ConfigSection(), componentIdParam, componentId)) |
|
608 { |
|
609 TInt componentIdOffset; |
|
610 if (!GetIntFromConfig(ConfigSection(), componentIdOffsetParam, componentIdOffset)) |
|
611 PrintErrorL(_L("The component entry params %S and %S could not be found in configuration."), KErrNotFound, &componentIdParam, &componentIdOffsetParam); |
|
612 |
|
613 componentId = ReadSharedComponentIdL(componentIdOffset); |
|
614 INFO_PRINTF2(_L("Component Id %d"), componentId); |
|
615 } |
|
616 |
|
617 TPtrC componentName; |
|
618 if (!GetStringFromConfig(ConfigSection(), componentNameParam, componentName)) |
|
619 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentNameParam); |
|
620 |
|
621 TPtrC componentVendor; |
|
622 if (!GetStringFromConfig(ConfigSection(), componentVendorParam, componentVendor)) |
|
623 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentVendorParam); |
|
624 |
|
625 TPtrC softwareTypeName; |
|
626 if (!GetStringFromConfig(ConfigSection(), softwareTypeNameParam, softwareTypeName)) |
|
627 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &softwareTypeNameParam); |
|
628 |
|
629 TPtrC globalId(KNullDesC); |
|
630 (void)GetStringFromConfig(ConfigSection(), globalIdParam, globalId); // This is an optional attribute. It is not crucial even if it is not provided. |
|
631 |
|
632 TBool isRemovable; |
|
633 if (!GetBoolFromConfig(ConfigSection(), isRemovableParam, isRemovable)) |
|
634 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &isRemovableParam); |
|
635 |
|
636 TInt64 componentSize; |
|
637 if (!Get64BitIntegerFromConfigL(componentSizeParam, componentSize)) |
|
638 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &componentSizeParam); |
|
639 |
|
640 TInt scomoStateValue; |
|
641 if (!GetIntFromConfig(ConfigSection(), scomoStateParam, scomoStateValue)) |
|
642 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &scomoStateParam); |
|
643 TScomoState scomoState = static_cast<TScomoState>(scomoStateValue); |
|
644 |
|
645 TDriveList driveList; |
|
646 if(!GetInstalledDrivesFromConfigL(driveList, installedDrivesParam)) |
|
647 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &installedDrivesParam); |
|
648 |
|
649 TPtrC version; |
|
650 if (!GetStringFromConfig(ConfigSection(), versionParam, version)) |
|
651 PrintErrorL(_L("The component entry param %S could not be found in configuration."), KErrNotFound, &versionParam); |
|
652 |
|
653 TBool isDrmProtected = EFalse; |
|
654 (void)GetBoolFromConfig(ConfigSection(), isDrmProtectedParam, isDrmProtected); // This is an optional attribute. It is not crucial even if it is not provided. |
|
655 |
|
656 TBool isHidden = EFalse; |
|
657 (void)GetBoolFromConfig(ConfigSection(), isHiddenParam, isHidden); // This is an optional attribute. It is not crucial even if it is not provided. |
|
658 |
|
659 TBool isKnownRevoked = EFalse; |
|
660 (void)GetBoolFromConfig(ConfigSection(), isKnownRevokedParam, isKnownRevoked); // This is an optional attribute. It is not crucial even if it is not provided. |
|
661 |
|
662 TBool isOriginVerified = EFalse; |
|
663 (void)GetBoolFromConfig(ConfigSection(), isOriginVerifiedParam, isOriginVerified); // This is an optional attribute. It is not crucial even if it is not provided. |
|
664 |
|
665 _LIT(KInstallTime, "20080706:112000"); |
|
666 |
|
667 return CComponentEntry::NewLC(componentId, componentName, componentVendor, softwareTypeName, globalId, isRemovable, componentSize, scomoState, driveList, version, KInstallTime, isDrmProtected, isHidden, isKnownRevoked, isOriginVerified); |
|
668 } |
|
669 |
|
670 void CScrTestStep::GenerateIndexedAttributeNameL(TDes& aInitialAttributeName, TInt aIndex) |
|
671 { |
|
672 const TInt MAX_INT_STR_LEN = 8; |
|
673 TBuf<MAX_INT_STR_LEN> integerAppendStr; |
|
674 integerAppendStr.Format(_L("%d"), aIndex); |
|
675 aInitialAttributeName.Append(integerAppendStr); |
|
676 } |
|
677 |
|
678 TBool CScrTestStep::Get64BitIntegerFromConfigL(const TDesC& aConfigKeyName, TInt64& aRetVal) |
|
679 { |
|
680 TPtrC int64Str; |
|
681 if (!GetStringFromConfig(ConfigSection(), aConfigKeyName, int64Str)) |
|
682 return EFalse; |
|
683 |
|
684 TLex lex(int64Str); |
|
685 User::LeaveIfError(lex.Val(aRetVal)); |
|
686 return ETrue; |
|
687 } |
|
688 |
|
689 CPropertyEntry* CScrTestStep::GetPropertyFromConfigLC(TBool aIsSingle, TInt aIndex, TBool aSupportLocalized) |
|
690 { |
|
691 // This function can be used for getting a single property, which is defined by attributes such as PropertyName etc. |
|
692 // or a property in a set - in this case the properties would be PropertyType0, PropertyName0 etc. |
|
693 // aIsSingle defines the working mode. aIndex applies only if aIsSingle is false |
|
694 |
|
695 // First, we need to generate the property name |
|
696 TBuf<MAX_SCR_PARAM_LENGTH> propertyTypeParam, propertyNameParam, propertyValueParam, propertyLocaleParam; |
|
697 propertyTypeParam = KPropertyTypeParam; |
|
698 propertyNameParam = KPropertyNameParam; |
|
699 propertyValueParam = KPropertyValueParam; |
|
700 propertyLocaleParam = KPropertyLocaleParam; |
|
701 if (!aIsSingle) |
|
702 { |
|
703 GenerateIndexedAttributeNameL(propertyTypeParam, aIndex); |
|
704 GenerateIndexedAttributeNameL(propertyNameParam, aIndex); |
|
705 GenerateIndexedAttributeNameL(propertyValueParam, aIndex); |
|
706 GenerateIndexedAttributeNameL(propertyLocaleParam, aIndex); |
|
707 } |
|
708 |
|
709 TPtrC propertyName; |
|
710 if (!GetStringFromConfig(ConfigSection(), propertyNameParam, propertyName)) |
|
711 { |
|
712 ERR_PRINTF2(_L("The property name param %S could not be found in configuration."), &propertyNameParam); |
|
713 User::Leave(KErrNotFound); |
|
714 } |
|
715 |
|
716 TInt propertyTypeInt; |
|
717 if (!GetIntFromConfig(ConfigSection(), propertyTypeParam, propertyTypeInt)) |
|
718 { |
|
719 ERR_PRINTF2(_L("The property type param %S could not be found in configuration."), &propertyTypeParam); |
|
720 User::Leave(KErrNotFound); |
|
721 } |
|
722 |
|
723 CPropertyEntry::TPropertyType propertyType = static_cast<CPropertyEntry::TPropertyType>(propertyTypeInt); |
|
724 |
|
725 CPropertyEntry* propertyEntry(NULL); |
|
726 switch (propertyType) |
|
727 { |
|
728 case CPropertyEntry::EBinaryProperty: |
|
729 case CPropertyEntry::ELocalizedProperty: |
|
730 { |
|
731 TPtrC propertyStrValue; |
|
732 if (!GetStringFromConfig(ConfigSection(), propertyValueParam, propertyStrValue)) |
|
733 { |
|
734 ERR_PRINTF2(_L("The property value param %S could not be found in configuration."), &propertyValueParam); |
|
735 User::Leave(KErrNotFound); |
|
736 } |
|
737 if(!aSupportLocalized || propertyType == CPropertyEntry::EBinaryProperty) |
|
738 { |
|
739 HBufC8* buffer8Bit = ConvertBufferTo8bitL(propertyStrValue); |
|
740 CleanupStack::PushL(buffer8Bit); |
|
741 propertyEntry = CBinaryPropertyEntry::NewL(propertyName, *buffer8Bit); |
|
742 CleanupStack::PopAndDestroy(buffer8Bit); |
|
743 break; |
|
744 } |
|
745 // Handle ELocalProperty case |
|
746 TLanguage locale; |
|
747 if (!GetLocaleFromConfigL(propertyLocaleParam, locale)) |
|
748 { |
|
749 ERR_PRINTF2(_L("The property locale param %S could not be found in configuration."), &propertyLocaleParam); |
|
750 User::Leave(KErrNotFound); |
|
751 } |
|
752 propertyEntry = CLocalizablePropertyEntry::NewL(propertyName, propertyStrValue, locale); |
|
753 break; |
|
754 } |
|
755 case CPropertyEntry::EIntProperty: |
|
756 { |
|
757 TInt64 int64Value; |
|
758 if (!Get64BitIntegerFromConfigL(propertyValueParam, int64Value)) |
|
759 { |
|
760 ERR_PRINTF2(_L("The integer param %S could not be found in configuration."), &propertyValueParam); |
|
761 User::Leave(KErrNotFound); |
|
762 } |
|
763 propertyEntry = CIntPropertyEntry::NewL(propertyName, int64Value); |
|
764 break; |
|
765 } |
|
766 } |
|
767 CleanupStack::PushL(propertyEntry); |
|
768 return propertyEntry; |
|
769 } |
|
770 |
|
771 void CScrTestStep::GetPropertiesFromConfigL(RPointerArray<CPropertyEntry>& aProperties, TBool aSupportLocalized) |
|
772 { |
|
773 TInt propertiesCount = 0; |
|
774 if (!GetIntFromConfig(ConfigSection(), KPropertiesCountParamName, propertiesCount)) |
|
775 { |
|
776 INFO_PRINTF1(_L("Properties count was not found!")); |
|
777 return; |
|
778 } |
|
779 |
|
780 if (propertiesCount < 0) |
|
781 { |
|
782 INFO_PRINTF1(_L("Properties count was negative !")); |
|
783 return; |
|
784 } |
|
785 |
|
786 for (TInt i = 0; i < propertiesCount; ++i) |
|
787 { |
|
788 CPropertyEntry *propertyEntry = GetPropertyFromConfigLC(EFalse, i, aSupportLocalized); |
|
789 User::LeaveIfError(aProperties.Append(propertyEntry)); |
|
790 CleanupStack::Pop(propertyEntry); |
|
791 } |
|
792 } |
|
793 |
|
794 void CScrTestStep::GetComponentIdsFromConfigL(RArray<TComponentId>& aComponentIds) |
|
795 { |
|
796 TInt componentsCount = 0; |
|
797 if (!GetIntFromConfig(ConfigSection(), KComponentsCountName, componentsCount)) |
|
798 PrintErrorL(_L("Components count was not found!"), KErrNotFound); |
|
799 |
|
800 TBuf<MAX_SCR_PARAM_LENGTH> paramName; |
|
801 |
|
802 for (TInt i = 0; i < componentsCount; ++i) |
|
803 { |
|
804 paramName = KComponentIdOffsetName; |
|
805 GenerateIndexedAttributeNameL(paramName, i); |
|
806 TInt componentIdOffset(0); |
|
807 if (!GetIntFromConfig(ConfigSection(), paramName, componentIdOffset)) |
|
808 { |
|
809 ERR_PRINTF2(_L("The component id param %S could not be found in configuration."), ¶mName); |
|
810 User::Leave(KErrNotFound); |
|
811 } |
|
812 TInt componentId = ReadSharedComponentIdL(componentIdOffset); |
|
813 aComponentIds.AppendL(componentId); |
|
814 } |
|
815 } |
|
816 |
|
817 void CScrTestStep::GetComponentLocalizablesFromConfigL(TInt aIndex, TPtrC& aName, TPtrC& aVendor, TLanguage& aLocale) |
|
818 { |
|
819 TBuf<20> vendorParamName, componentParamName, localeParamName; |
|
820 vendorParamName = KVendorName; |
|
821 GenerateIndexedAttributeNameL(vendorParamName, aIndex); |
|
822 |
|
823 componentParamName = KComponentName; |
|
824 GenerateIndexedAttributeNameL(componentParamName, aIndex); |
|
825 |
|
826 localeParamName = KComponentLocaleName; |
|
827 GenerateIndexedAttributeNameL(localeParamName, aIndex); |
|
828 |
|
829 if (!GetStringFromConfig(ConfigSection(), componentParamName, aName)) |
|
830 PrintErrorL(_L("Localised component name was not found!"), KErrNotFound); |
|
831 if (!GetStringFromConfig(ConfigSection(), vendorParamName, aVendor)) |
|
832 PrintErrorL(_L("Localised vendor name was not found!"), KErrNotFound); |
|
833 if (!GetLocaleFromConfigL(localeParamName, aLocale)) |
|
834 PrintErrorL(_L("Locale was not found!"), KErrNotFound); |
|
835 } |
|
836 |
|
837 void CScrTestStep::GetLocalisedComponentsFromConfigL(RPointerArray<Usif::CLocalizableComponentInfo>& aComponentInfo) |
|
838 { |
|
839 TInt localesCount = 0; |
|
840 if (!GetIntFromConfig(ConfigSection(), _L("LocalesCount"), localesCount)) |
|
841 PrintErrorL(_L("Locales count was not found!"), KErrNotFound); |
|
842 |
|
843 for (TUint i = 0; i < localesCount; ++i) |
|
844 { |
|
845 TPtrC componentName, vendorName; |
|
846 TLanguage locale; |
|
847 GetComponentLocalizablesFromConfigL(i, componentName, vendorName, locale); |
|
848 |
|
849 CLocalizableComponentInfo* localisableComponentInfo(0); |
|
850 // If-condition is used for the sake of coverage |
|
851 if(i) |
|
852 { |
|
853 localisableComponentInfo = CLocalizableComponentInfo::NewLC(componentName, vendorName, locale); |
|
854 } |
|
855 else |
|
856 { |
|
857 localisableComponentInfo = CLocalizableComponentInfo::NewL(componentName, vendorName, locale); |
|
858 CleanupStack::PushL(localisableComponentInfo); |
|
859 } |
|
860 aComponentInfo.AppendL(localisableComponentInfo); |
|
861 CleanupStack::Pop(localisableComponentInfo); |
|
862 } |
|
863 } |
|
864 |
|
865 TBool CScrTestStep::GetInstalledDrivesFromConfigL(TDriveList& aDriveList, const TDesC& aAttributeName) |
|
866 { |
|
867 TPtrC installedDrives; |
|
868 if (!GetStringFromConfig(ConfigSection(), aAttributeName, installedDrives)) |
|
869 { |
|
870 return EFalse; |
|
871 } |
|
872 |
|
873 TLex parser(installedDrives); |
|
874 TChar currentChar; |
|
875 aDriveList.FillZ(KMaxDrives); |
|
876 |
|
877 parser.Mark(); |
|
878 while(!parser.Eos()) |
|
879 { |
|
880 currentChar = parser.Get(); |
|
881 if(KComponentIdDelimeter == currentChar || parser.Eos()) |
|
882 { |
|
883 TPtrC token = parser.MarkedToken(); |
|
884 TLex tokenLex(token); |
|
885 TInt driveNumber(0); |
|
886 driveNumber = token[0] - 'A'; |
|
887 if(driveNumber < EDriveA || driveNumber > EDriveZ) |
|
888 { |
|
889 ERR_PRINTF3(_L("%S contains an unexpected token(%S)."), &aAttributeName, &token); |
|
890 User::Leave(KErrArgument); |
|
891 } |
|
892 ++aDriveList[driveNumber]; |
|
893 parser.Mark(); |
|
894 } |
|
895 } |
|
896 return ETrue; |
|
897 } |
|
898 |
|
899 TBool CScrTestStep::GetScomoStateFromConfigL(TScomoState& aScomoState, const TDesC& aAttributeName) |
|
900 { |
|
901 TInt tempScomoState(0); |
|
902 if (!GetIntFromConfig(ConfigSection(), aAttributeName, tempScomoState)) |
|
903 return EFalse; |
|
904 |
|
905 aScomoState = static_cast<TScomoState>(tempScomoState); |
|
906 return ETrue; |
|
907 } |
|
908 |
|
909 |
|
910 TInt CScrTestStep::GetSetSizeFromConfigL() |
|
911 { |
|
912 TInt setSize(1); |
|
913 GetIntFromConfig(ConfigSection(), KSetSizeName, setSize); |
|
914 if (setSize < 1) |
|
915 PrintErrorL(_L("Invalid set size in component filter definition"), KErrArgument); |
|
916 return setSize; |
|
917 } |
|
918 |
|
919 Usif::TComponentId CScrTestStep::AddNonLocalisableComponentL(Usif::RSoftwareComponentRegistry& aScrSession) |
|
920 { |
|
921 TPtrC componentName; |
|
922 GetComponentNameFromConfigL(componentName); |
|
923 TPtrC vendorName;; |
|
924 GetVendorNameFromConfigL(vendorName); |
|
925 TPtrC swTypeName; |
|
926 GetSoftwareTypeNameL(swTypeName); |
|
927 |
|
928 TScrComponentOperationType operationType(EScrCompInstall); |
|
929 |
|
930 TInt opTypeInt(0); |
|
931 if(GetIntFromConfig(ConfigSection(), KOperationType, opTypeInt)) |
|
932 { |
|
933 operationType = static_cast<TScrComponentOperationType>(opTypeInt); |
|
934 } |
|
935 |
|
936 Usif::TComponentId componentId; |
|
937 TPtrC globalIdName; |
|
938 if(GetGlobalIdNameL(globalIdName)) |
|
939 componentId = aScrSession.AddComponentL(componentName, vendorName, swTypeName, &globalIdName, operationType); |
|
940 else |
|
941 componentId = aScrSession.AddComponentL(componentName, vendorName, swTypeName, NULL, operationType); |
|
942 |
|
943 return componentId; |
|
944 } |
|
945 |
|
946 void CScrTestStep::ReadFilterPropertiesL(CComponentFilter* aFilter, TInt aPropertiesCount) |
|
947 { |
|
948 for (TInt i = 0; i < aPropertiesCount; ++i) |
|
949 { |
|
950 TBuf<MAX_SCR_PARAM_LENGTH> propertyNameParam, intAttributeParam, strAttributeParam, localeAttributeParam; |
|
951 |
|
952 propertyNameParam = _L("FilterPropertyName"); |
|
953 GenerateIndexedAttributeNameL(propertyNameParam, i); |
|
954 |
|
955 TPtrC propertyName; |
|
956 if (!GetStringFromConfig(ConfigSection(), propertyNameParam, propertyName)) |
|
957 { |
|
958 PrintErrorL(_L("Property name for property was not found in filter"), KErrNotFound); |
|
959 } |
|
960 |
|
961 intAttributeParam = _L("FilterIntProperty"); |
|
962 GenerateIndexedAttributeNameL(intAttributeParam, i); |
|
963 |
|
964 strAttributeParam = _L("FilterStringProperty"); |
|
965 GenerateIndexedAttributeNameL(strAttributeParam, i); |
|
966 |
|
967 localeAttributeParam = _L("FilterPropertyLocale"); |
|
968 GenerateIndexedAttributeNameL(localeAttributeParam, i); |
|
969 |
|
970 TPtrC propertyStrValue; |
|
971 TInt64 int64Value; |
|
972 |
|
973 if (Get64BitIntegerFromConfigL(intAttributeParam, int64Value)) |
|
974 { |
|
975 aFilter->AddPropertyL(propertyName, int64Value); |
|
976 continue; |
|
977 } |
|
978 |
|
979 if (!GetStringFromConfig(ConfigSection(), strAttributeParam, propertyStrValue)) |
|
980 continue; |
|
981 |
|
982 TLanguage locale; |
|
983 if (GetLocaleFromConfigL(localeAttributeParam, locale)) |
|
984 { |
|
985 aFilter->AddPropertyL(propertyName, propertyStrValue, locale); |
|
986 } |
|
987 else |
|
988 { |
|
989 HBufC8* buffer8bit = ConvertBufferTo8bitL(propertyStrValue); |
|
990 CleanupStack::PushL(buffer8bit); |
|
991 aFilter->AddPropertyL(propertyName, *buffer8bit); |
|
992 CleanupStack::PopAndDestroy(buffer8bit); |
|
993 } |
|
994 } |
|
995 } |
|
996 |
|
997 CComponentFilter* CScrTestStep::ReadComponentFilterFromConfigLC() |
|
998 { |
|
999 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
|
1000 |
|
1001 TPtrC filterName; |
|
1002 if (GetStringFromConfig(ConfigSection(), _L("FilterName"), filterName)) |
|
1003 componentFilter->SetNameL(filterName); |
|
1004 |
|
1005 TPtrC filterVendor; |
|
1006 if (GetStringFromConfig(ConfigSection(), _L("FilterVendor"), filterVendor)) |
|
1007 componentFilter->SetVendorL(filterVendor); |
|
1008 |
|
1009 TPtrC filterSwType; |
|
1010 if (GetStringFromConfig(ConfigSection(), _L("FilterSoftwareType"), filterSwType)) |
|
1011 componentFilter->SetSoftwareTypeL(filterSwType); |
|
1012 |
|
1013 TScomoState scomoState; |
|
1014 if (GetScomoStateFromConfigL(scomoState, _L("FilterScomoState"))) |
|
1015 componentFilter->SetScomoStateL(scomoState); |
|
1016 |
|
1017 TDriveList filterInstalledDrives; |
|
1018 _LIT(KFilterInstalledDrives, "FilterDrivesList"); |
|
1019 if (GetInstalledDrivesFromConfigL(filterInstalledDrives, KFilterInstalledDrives())) |
|
1020 componentFilter->SetInstalledDrivesL(filterInstalledDrives); |
|
1021 |
|
1022 TBool filterIsRemovable(EFalse); |
|
1023 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsRemovable"), filterIsRemovable)) |
|
1024 componentFilter->SetRemovable(filterIsRemovable); |
|
1025 |
|
1026 TInt propertiesCount(0); |
|
1027 if (GetIntFromConfig(ConfigSection(), _L("FilterPropertiesCount"), propertiesCount)) |
|
1028 { |
|
1029 ReadFilterPropertiesL(componentFilter, propertiesCount); |
|
1030 } |
|
1031 |
|
1032 TPtrC filterFile; |
|
1033 if (GetStringFromConfig(ConfigSection(), _L("FilterFile"), filterFile)) |
|
1034 componentFilter->SetFileL(filterFile); |
|
1035 |
|
1036 TBool filterIsDrmProtected(EFalse); |
|
1037 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsDrmProtected"), filterIsDrmProtected)) |
|
1038 componentFilter->SetDrmProtected(filterIsDrmProtected); |
|
1039 |
|
1040 TBool filterIsHidden(EFalse); |
|
1041 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsHidden"), filterIsHidden)) |
|
1042 componentFilter->SetHidden(filterIsHidden); |
|
1043 |
|
1044 TBool filterIsKnownRevoked(EFalse); |
|
1045 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsKnownRevoked"), filterIsKnownRevoked)) |
|
1046 componentFilter->SetKnownRevoked(filterIsKnownRevoked); |
|
1047 |
|
1048 TBool filterIsOriginVerified(EFalse); |
|
1049 if (GetBoolFromConfig(ConfigSection(), _L("FilterIsOriginVerified"), filterIsOriginVerified)) |
|
1050 componentFilter->SetOriginVerified(filterIsOriginVerified); |
|
1051 |
|
1052 return componentFilter; |
|
1053 } |
|
1054 |
|
1055 void CScrTestStep::GetAppOwnedFilesL(RPointerArray<HBufC>& aOwnedFileArray) |
|
1056 { |
|
1057 TInt ownedFileCount = 0; |
|
1058 GetIntFromConfig(ConfigSection(), _L("OwnedFileCount"), ownedFileCount); |
|
1059 for (TUint i = 0; i < ownedFileCount; ++i) |
|
1060 { |
|
1061 TPtrC tOwnedFileName; |
|
1062 TBuf<20> fileName; |
|
1063 fileName = KOwnedFileName; |
|
1064 GenerateIndexedAttributeNameL(fileName, i); |
|
1065 GetStringFromConfig(ConfigSection(), fileName, tOwnedFileName); |
|
1066 HBufC* ownedFileName = tOwnedFileName.AllocLC(); |
|
1067 aOwnedFileArray.AppendL(ownedFileName); |
|
1068 CleanupStack::Pop(ownedFileName); |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 void CScrTestStep::GetAppServiceInfoL(RPointerArray<CServiceInfo>& aServiceInfoArray) |
|
1073 { |
|
1074 TInt serviceInfoCount = 0; |
|
1075 TInt totalOpaqueDataCount = 0; |
|
1076 TInt totalServiceDataTypeCount = 0; |
|
1077 GetIntFromConfig(ConfigSection(), _L("ServiceInfoCount"), serviceInfoCount); |
|
1078 for (TUint i = 0; i < serviceInfoCount; ++i) |
|
1079 { |
|
1080 // service Uid |
|
1081 TBuf<20> uid; |
|
1082 TUid serviceUid; |
|
1083 uid = KServiceUid; |
|
1084 GenerateIndexedAttributeNameL(uid, i); |
|
1085 GetUidFromConfig(ConfigSection(), uid, serviceUid); |
|
1086 |
|
1087 // service opaque data |
|
1088 RPointerArray<COpaqueData> serviceOpaqueDataInfoArray; |
|
1089 TBuf<27> servOpaqueDataCountStr; |
|
1090 servOpaqueDataCountStr = KServiceOpaqueDataInfoCount; |
|
1091 GenerateIndexedAttributeNameL(servOpaqueDataCountStr, i); |
|
1092 TInt serviceOpaqueDataInfoCount = 0; |
|
1093 GetIntFromConfig(ConfigSection(), servOpaqueDataCountStr, serviceOpaqueDataInfoCount); |
|
1094 GetServiceOpaqueDataInfoL(serviceOpaqueDataInfoArray, serviceOpaqueDataInfoCount, totalOpaqueDataCount); |
|
1095 totalOpaqueDataCount += serviceOpaqueDataInfoCount; |
|
1096 //CleanupStack::PushL(&serviceOpaqueDataInfoArray); |
|
1097 |
|
1098 // service data type |
|
1099 TBuf<21> serviceDataTypeCountString; |
|
1100 serviceDataTypeCountString = KServiceDataTypeCount; |
|
1101 GenerateIndexedAttributeNameL(serviceDataTypeCountString, i); |
|
1102 TInt serviceDataTypeCount = 0; |
|
1103 GetIntFromConfig(ConfigSection(), serviceDataTypeCountString, serviceDataTypeCount); |
|
1104 totalServiceDataTypeCount+=serviceDataTypeCount; |
|
1105 RPointerArray<CDataType> serviceDataTypeArray; |
|
1106 for (TUint j = 0; j < serviceDataTypeCount; ++j) |
|
1107 { |
|
1108 TInt indexToRead = totalServiceDataTypeCount-serviceDataTypeCount+j; |
|
1109 TInt serviceDataTypePriority; |
|
1110 TPtrC serviceType; |
|
1111 TBuf<25> priority, type; |
|
1112 priority = KServiceDataTypePriority; |
|
1113 GenerateIndexedAttributeNameL(priority, indexToRead); |
|
1114 GetIntFromConfig(ConfigSection(), priority, serviceDataTypePriority); |
|
1115 type = KServiceDataType; |
|
1116 GenerateIndexedAttributeNameL(type, indexToRead); |
|
1117 GetStringFromConfig(ConfigSection(), type, serviceType); |
|
1118 CDataType* serviceDataType = CDataType::NewLC(serviceDataTypePriority,serviceType); |
|
1119 serviceDataTypeArray.AppendL(serviceDataType); |
|
1120 CleanupStack::Pop(serviceDataType); |
|
1121 } |
|
1122 |
|
1123 CServiceInfo* serviceInfo = CServiceInfo::NewLC(serviceUid, serviceOpaqueDataInfoArray, serviceDataTypeArray); |
|
1124 aServiceInfoArray.AppendL(serviceInfo); |
|
1125 CleanupStack::Pop(serviceInfo); |
|
1126 } |
|
1127 } |
|
1128 |
|
1129 void CScrTestStep::GetAppLocalizableInfoL(RPointerArray<CLocalizableAppInfo>& aLocalizableAppInfoArray) |
|
1130 { |
|
1131 TInt localizableAppInfoCount = 0; |
|
1132 TInt totalViewDataCount=0; |
|
1133 GetIntFromConfig(ConfigSection(), _L("LocalizableAppInfoCount"), localizableAppInfoCount); |
|
1134 for (TUint i = 0; i < localizableAppInfoCount; ++i) |
|
1135 { |
|
1136 TPtrC locShortCaption; |
|
1137 TLanguage locLanguage; |
|
1138 TInt lang; |
|
1139 TPtrC locGroupName; |
|
1140 TBuf<20> shortCaption, language, groupName, viewDataCount; |
|
1141 shortCaption = KLocShortCaption; |
|
1142 GenerateIndexedAttributeNameL(shortCaption, i); |
|
1143 GetStringFromConfig(ConfigSection(), shortCaption, locShortCaption); |
|
1144 language = KLocAppLanguage; |
|
1145 GenerateIndexedAttributeNameL(language, i); |
|
1146 GetIntFromConfig(ConfigSection(), language, lang); |
|
1147 |
|
1148 locLanguage = static_cast<TLanguage>(lang); |
|
1149 groupName = KLocGroupName; |
|
1150 GenerateIndexedAttributeNameL(groupName, i); |
|
1151 GetStringFromConfig(ConfigSection(), groupName, locGroupName); |
|
1152 |
|
1153 TPtrC locCaption; |
|
1154 TPtrC locIconFileName; |
|
1155 TInt locNoOfAppIcons = 0; |
|
1156 TBuf<20> caption, iconFileName, noOfAppIcons; |
|
1157 caption = KLocCaption; |
|
1158 GenerateIndexedAttributeNameL(caption, i); |
|
1159 GetStringFromConfig(ConfigSection(), caption, locCaption); |
|
1160 iconFileName = KLocIconFileName; |
|
1161 GenerateIndexedAttributeNameL(iconFileName, i); |
|
1162 GetStringFromConfig(ConfigSection(), iconFileName, locIconFileName); |
|
1163 noOfAppIcons = KLocNumberOfAppIcons; |
|
1164 GenerateIndexedAttributeNameL(noOfAppIcons, i); |
|
1165 GetIntFromConfig(ConfigSection(), noOfAppIcons, locNoOfAppIcons); |
|
1166 CCaptionAndIconInfo* captionAndIconInfo = NULL; |
|
1167 if(locCaption.Length() != 0 || locIconFileName.Length() !=0 || locNoOfAppIcons != 0) |
|
1168 { |
|
1169 captionAndIconInfo = CCaptionAndIconInfo::NewLC(locCaption,locIconFileName,locNoOfAppIcons); |
|
1170 } |
|
1171 else |
|
1172 CleanupStack::PushL(captionAndIconInfo); |
|
1173 |
|
1174 TInt viewDataCountForLocale = 0; |
|
1175 viewDataCount=KViewDataCount; |
|
1176 GenerateIndexedAttributeNameL(viewDataCount, i); |
|
1177 GetIntFromConfig(ConfigSection(), viewDataCount , viewDataCountForLocale); |
|
1178 totalViewDataCount+=viewDataCountForLocale; |
|
1179 RPointerArray<CAppViewData> viewDataArray; |
|
1180 for (TUint i = 0; i < viewDataCountForLocale; ++i) |
|
1181 { |
|
1182 TInt viewScreenMode,vUid,indexToRead; |
|
1183 TBuf<20> uid, screenMode; |
|
1184 uid = KVwUid; |
|
1185 indexToRead=totalViewDataCount-viewDataCountForLocale+i; |
|
1186 GenerateIndexedAttributeNameL(uid, indexToRead); |
|
1187 GetIntFromConfig(ConfigSection(), uid, vUid); |
|
1188 TUid viewUid = TUid::Uid(vUid); |
|
1189 screenMode = KVwScreenMode; |
|
1190 GenerateIndexedAttributeNameL(screenMode, indexToRead); |
|
1191 GetIntFromConfig(ConfigSection(), screenMode, viewScreenMode); |
|
1192 |
|
1193 TPtrC viewCaption; |
|
1194 TPtrC viewIconFileName; |
|
1195 TInt viewNoOfAppIcons = 0; |
|
1196 TBuf<20> caption, iconFileName, noOfAppIcons; |
|
1197 caption = KVwCaption; |
|
1198 GenerateIndexedAttributeNameL(caption, indexToRead); |
|
1199 GetStringFromConfig(ConfigSection(), caption, viewCaption); |
|
1200 iconFileName = KVwIconFileName; |
|
1201 GenerateIndexedAttributeNameL(iconFileName, indexToRead); |
|
1202 GetStringFromConfig(ConfigSection(), iconFileName, viewIconFileName); |
|
1203 noOfAppIcons = KVwNumberOfAppIcons; |
|
1204 GenerateIndexedAttributeNameL(noOfAppIcons, indexToRead); |
|
1205 GetIntFromConfig(ConfigSection(), noOfAppIcons, viewNoOfAppIcons); |
|
1206 CCaptionAndIconInfo* viewCaptionAndIconInfo = NULL; |
|
1207 if(viewCaption.Length() != 0 || viewIconFileName.Length() !=0 || viewNoOfAppIcons != 0) |
|
1208 { |
|
1209 viewCaptionAndIconInfo = CCaptionAndIconInfo::NewLC(viewCaption,viewIconFileName,viewNoOfAppIcons); |
|
1210 } |
|
1211 else |
|
1212 CleanupStack::PushL(viewCaptionAndIconInfo); |
|
1213 |
|
1214 CAppViewData* viewData = CAppViewData::NewLC(viewUid,viewScreenMode,viewCaptionAndIconInfo); |
|
1215 viewDataArray.AppendL(viewData); |
|
1216 CleanupStack::Pop(2, viewCaptionAndIconInfo); |
|
1217 } |
|
1218 |
|
1219 CLocalizableAppInfo* localizableAppInfo = CLocalizableAppInfo::NewLC(locShortCaption,locLanguage,locGroupName,captionAndIconInfo,viewDataArray); |
|
1220 aLocalizableAppInfoArray.AppendL(localizableAppInfo); |
|
1221 CleanupStack::Pop(localizableAppInfo); |
|
1222 CleanupStack::Pop(captionAndIconInfo); |
|
1223 } |
|
1224 } |
|
1225 |
|
1226 void CScrTestStep::GetAppOpaqueDataInfoL(RPointerArray<Usif::COpaqueData>& aAppOpaqueDataInfoArray) |
|
1227 { |
|
1228 TInt appOpaqueDataInfoCount = 0; |
|
1229 |
|
1230 GetIntFromConfig(ConfigSection(), _L("AppOpaqueDataInfoCount"), appOpaqueDataInfoCount); |
|
1231 for (TUint i = 0; i < appOpaqueDataInfoCount; ++i) |
|
1232 { |
|
1233 TBuf<16> localeAttr; |
|
1234 localeAttr = KAppOpaqueDataLocale; |
|
1235 TInt locale = 0; |
|
1236 GenerateIndexedAttributeNameL(localeAttr, i); |
|
1237 GetIntFromConfig(ConfigSection(), localeAttr, locale); |
|
1238 |
|
1239 |
|
1240 |
|
1241 TBuf<14> opaqueDataAttr; |
|
1242 opaqueDataAttr = KAppOpaqueData; |
|
1243 TPtrC opaqueData; |
|
1244 GenerateIndexedAttributeNameL(opaqueDataAttr, i); |
|
1245 GetStringFromConfig(ConfigSection(), opaqueDataAttr, opaqueData); |
|
1246 |
|
1247 TPtrC8 blobOpaqueData((TUint8*)opaqueData.Ptr(), opaqueData.Length()*2); |
|
1248 |
|
1249 COpaqueData* appOpaqueData = COpaqueData::NewLC(blobOpaqueData, (TLanguage) locale); |
|
1250 aAppOpaqueDataInfoArray.AppendL(appOpaqueData); |
|
1251 CleanupStack::Pop(appOpaqueData); |
|
1252 } |
|
1253 } |
|
1254 |
|
1255 void CScrTestStep::GetServiceOpaqueDataInfoL(RPointerArray<Usif::COpaqueData>& aServiceOpaqueDataInfoArray, TInt aServiceOpaqueDataInfoCount, TInt aStartingIndex) |
|
1256 { |
|
1257 for (TUint i = 0; i < aServiceOpaqueDataInfoCount; ++i) |
|
1258 { |
|
1259 TBuf<20> localeAttr; |
|
1260 localeAttr = KServiceOpaqueLocale; |
|
1261 TInt locale = 0; |
|
1262 TInt indexToRead = i + aStartingIndex; |
|
1263 GenerateIndexedAttributeNameL(localeAttr, indexToRead); |
|
1264 GetIntFromConfig(ConfigSection(), localeAttr, locale); |
|
1265 |
|
1266 TBuf<18> opaqueDataAttr; |
|
1267 opaqueDataAttr = KServiceOpaqueData; |
|
1268 TPtrC opaqueData; |
|
1269 GenerateIndexedAttributeNameL(opaqueDataAttr, indexToRead); |
|
1270 GetStringFromConfig(ConfigSection(), opaqueDataAttr, opaqueData); |
|
1271 |
|
1272 TPtrC8 blobOpaqueData((TUint8*)opaqueData.Ptr(), opaqueData.Length()*2); |
|
1273 |
|
1274 COpaqueData* serviceOpaqueData = COpaqueData::NewLC(blobOpaqueData, (TLanguage) locale); |
|
1275 aServiceOpaqueDataInfoArray.AppendL(serviceOpaqueData); |
|
1276 CleanupStack::Pop(serviceOpaqueData); |
|
1277 } |
|
1278 } |
|
1279 |
|
1280 CApplicationRegistrationData* CScrTestStep::GetAppRegInfoFromConfigLC() |
|
1281 { |
|
1282 TUid appUid; |
|
1283 GetAppUidL(appUid); |
|
1284 |
|
1285 TPtrC appFile; |
|
1286 TBuf<128> appFileBuf; |
|
1287 _LIT(KAppFileName, "appName%d"); |
|
1288 if(!GetStringFromConfig(ConfigSection(), _L("AppFile"), appFile)) |
|
1289 { |
|
1290 TBool generateNewUid(EFalse); |
|
1291 //Generate appFile Name from the appUid. |
|
1292 if (GetBoolFromConfig(ConfigSection(), _L("GenerateNewUid"), generateNewUid)) |
|
1293 { |
|
1294 appFileBuf.Format(KAppFileName, appUid); |
|
1295 appFile.Set(appFileBuf); |
|
1296 } |
|
1297 } |
|
1298 |
|
1299 TInt attributes, hidden, embeddability, newFile, launch, defScreenNo; |
|
1300 GetIntFromConfig(ConfigSection(), _L("Attributes"), attributes); |
|
1301 GetIntFromConfig(ConfigSection(), _L("Hidden"), hidden); |
|
1302 GetIntFromConfig(ConfigSection(), _L("Embeddability"), embeddability); |
|
1303 GetIntFromConfig(ConfigSection(), _L("NewFile"), newFile); |
|
1304 GetIntFromConfig(ConfigSection(), _L("Launch"), launch); |
|
1305 |
|
1306 TPtrC groupName; |
|
1307 GetStringFromConfig(ConfigSection(), _L("GroupName"), groupName); |
|
1308 |
|
1309 GetIntFromConfig(ConfigSection(), _L("DefaultScreenNumber"), defScreenNo); |
|
1310 |
|
1311 RPointerArray<HBufC> ownedFileArray; |
|
1312 GetAppOwnedFilesL(ownedFileArray); |
|
1313 CleanupStack::PushL(&ownedFileArray); |
|
1314 RPointerArray<CServiceInfo> serviceInfoArray; |
|
1315 GetAppServiceInfoL(serviceInfoArray); |
|
1316 CleanupStack::PushL(&serviceInfoArray); |
|
1317 RPointerArray<CLocalizableAppInfo> localizableAppInfoArray; |
|
1318 GetAppLocalizableInfoL(localizableAppInfoArray); |
|
1319 CleanupStack::PushL(&localizableAppInfoArray); |
|
1320 |
|
1321 RPointerArray<COpaqueData> appOpaqueDataInfoArray; |
|
1322 GetAppOpaqueDataInfoL(appOpaqueDataInfoArray); |
|
1323 CleanupStack::PushL(&appOpaqueDataInfoArray); |
|
1324 |
|
1325 RPointerArray<CPropertyEntry> appPropertyArray; |
|
1326 GetPropertiesFromConfigL(appPropertyArray, ETrue); |
|
1327 CleanupStack::PushL(&appPropertyArray); |
|
1328 INFO_PRINTF1(_L("Going to create CApplicationRegistrationData obj.")); |
|
1329 |
|
1330 TBool ObjectWithoutOptionalFields = EFalse; |
|
1331 GetBoolFromConfig(ConfigSection(), _L("ObjectWithoutOptionalFields"), ObjectWithoutOptionalFields); |
|
1332 CApplicationRegistrationData* appRegData = NULL; |
|
1333 if(ObjectWithoutOptionalFields) |
|
1334 { |
|
1335 appRegData = CApplicationRegistrationData::NewLC(ownedFileArray, serviceInfoArray, localizableAppInfoArray, appPropertyArray, appUid, appFile); |
|
1336 } |
|
1337 else |
|
1338 { |
|
1339 TApplicationCharacteristics appCharacteristics; |
|
1340 appCharacteristics.iAttributes = attributes; |
|
1341 appCharacteristics.iAppIsHidden = hidden; |
|
1342 appCharacteristics.iEmbeddability = TApplicationCharacteristics::TAppEmbeddability(embeddability); |
|
1343 appCharacteristics.iGroupName = groupName; |
|
1344 appCharacteristics.iLaunchInBackground = launch; |
|
1345 |
|
1346 appRegData = CApplicationRegistrationData::NewLC(ownedFileArray, serviceInfoArray, localizableAppInfoArray, appPropertyArray, appOpaqueDataInfoArray, appUid, appFile, appCharacteristics, defScreenNo); |
|
1347 } |
|
1348 |
|
1349 INFO_PRINTF1(_L("Created CApplicationRegistrationData obj.")); |
|
1350 CleanupStack::Pop(6); |
|
1351 CleanupStack::PushL(appRegData); |
|
1352 return appRegData; |
|
1353 } |
|
1354 |
|
1355 TComponentId CScrTestStep::GetCompIdFromConfigL() |
|
1356 { |
|
1357 TInt cId; |
|
1358 GetIntFromConfig(ConfigSection(), _L("ComponentId"), cId); |
|
1359 INFO_PRINTF1(_L("returning compid value from CScrTestStep::GetCompIdFromConfigL.")); |
|
1360 return static_cast<TComponentId>(cId); |
|
1361 } |
|
1362 |
|
1363 void CScrTestStep::GetAppUidL(TUid& aAppUid) |
|
1364 { |
|
1365 TBool generateNewUid(EFalse); |
|
1366 if (!GetUidFromConfig(ConfigSection(), _L("AppUid"), aAppUid)) |
|
1367 { |
|
1368 if (GetBoolFromConfig(ConfigSection(), _L("GenerateNewUid"), generateNewUid)) |
|
1369 { |
|
1370 INFO_PRINTF1(_L("Generating new UID")); |
|
1371 //Find an unused UID and return it. |
|
1372 aAppUid = GenerateNewAppUidL(); |
|
1373 } |
|
1374 else |
|
1375 { |
|
1376 PrintErrorL(_L("AppUid was not found!"), KErrNotFound); |
|
1377 } |
|
1378 } |
|
1379 INFO_PRINTF2(_L("AppUid is 0x%x"), aAppUid.iUid); |
|
1380 } |
|
1381 |
|
1382 TUid CScrTestStep::GetServiceUidL() |
|
1383 { |
|
1384 TUid serviceUid; |
|
1385 TInt tmpuid=0, i=0; |
|
1386 TBuf<25> uid; |
|
1387 |
|
1388 uid = KServiceUid; |
|
1389 GenerateIndexedAttributeNameL(uid, i); |
|
1390 if(!GetIntFromConfig(ConfigSection(), uid, tmpuid)) |
|
1391 PrintErrorL(_L("Service Uid was not found!"), KErrNotFound); |
|
1392 serviceUid.iUid=tmpuid; |
|
1393 INFO_PRINTF2(_L("Service Uid %d"), serviceUid.iUid); |
|
1394 return serviceUid; |
|
1395 } |
|
1396 |
|
1397 TBool CScrTestStep::GetUidFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUid& aUid) |
|
1398 { |
|
1399 TInt val; |
|
1400 if(GetHexFromConfig(aSectName, aKeyName, val)) |
|
1401 { |
|
1402 aUid = TUid::Uid(val); |
|
1403 return ETrue; |
|
1404 } |
|
1405 else |
|
1406 { |
|
1407 return EFalse; |
|
1408 } |
|
1409 } |
|
1410 |
|
1411 Usif::TAppRegInfo* CScrTestStep::GetAppInfoFromConfigL(TBool aIsSingle , TInt aIndex ) |
|
1412 { |
|
1413 Usif::TAppRegInfo *appinfo=NULL; |
|
1414 |
|
1415 TBuf<MAX_SCR_PARAM_LENGTH> applicationUidParam, applicationFileNameParam, applicationCaptionParam, applicationShortCaptionParam; |
|
1416 applicationUidParam = KIntTAppInfoUID; |
|
1417 applicationFileNameParam = KStringTAppInfoFileName; |
|
1418 applicationCaptionParam = KStringTAppInfoCaption; |
|
1419 applicationShortCaptionParam = KStringTAppInfoShortCaption; |
|
1420 |
|
1421 if (!aIsSingle) |
|
1422 { |
|
1423 INFO_PRINTF1(_L("Preparing Index ")); |
|
1424 GenerateIndexedAttributeNameL(applicationUidParam, aIndex); |
|
1425 GenerateIndexedAttributeNameL(applicationFileNameParam, aIndex); |
|
1426 GenerateIndexedAttributeNameL(applicationCaptionParam, aIndex); |
|
1427 GenerateIndexedAttributeNameL(applicationShortCaptionParam, aIndex); |
|
1428 } |
|
1429 |
|
1430 TUid applicationUid; |
|
1431 if (!GetUidFromConfig(ConfigSection(), applicationUidParam, applicationUid)) |
|
1432 { |
|
1433 ERR_PRINTF2(_L("The application Uid type param %S could not be found in configuration."), &applicationUidParam); |
|
1434 User::Leave(KErrNotFound); |
|
1435 } |
|
1436 |
|
1437 TPtrC applicationFileName; |
|
1438 if (!GetStringFromConfig(ConfigSection(), applicationFileNameParam, applicationFileName)) |
|
1439 { |
|
1440 ERR_PRINTF2(_L("The application file name param %S could not be found in configuration."), &applicationFileNameParam); |
|
1441 User::Leave(KErrNotFound); |
|
1442 } |
|
1443 TPtrC applicationCaption; |
|
1444 if (!GetStringFromConfig(ConfigSection(), applicationCaptionParam, applicationCaption)) |
|
1445 { |
|
1446 INFO_PRINTF2(_L("The application caption param %S could not be found in configuration."), &applicationCaptionParam); |
|
1447 |
|
1448 } |
|
1449 TPtrC applicationShortCaption; |
|
1450 if (!GetStringFromConfig(ConfigSection(), applicationShortCaptionParam, applicationShortCaption)) |
|
1451 { |
|
1452 appinfo = new TAppRegInfo(applicationUid , applicationFileName, applicationCaption); |
|
1453 INFO_PRINTF2(_L("The application short caption param %S could not be found in configuration."), &applicationShortCaptionParam); |
|
1454 } |
|
1455 else |
|
1456 appinfo = new TAppRegInfo(applicationUid , applicationFileName, applicationCaption,applicationShortCaption); |
|
1457 |
|
1458 return appinfo; |
|
1459 } |
|
1460 |
|
1461 void CScrTestStep::ReadAppInfoFilterFromConfigL(Usif::CAppInfoFilter** aFilter) |
|
1462 { |
|
1463 *aFilter=CAppInfoFilter::NewL(); |
|
1464 Usif::CAppInfoFilter *aAppInfoFilter=*aFilter; |
|
1465 |
|
1466 TBool filterToSet(EFalse); |
|
1467 TInt screenMode(0); |
|
1468 if (GetBoolFromConfig(ConfigSection(), _L("AIFAllApps"), filterToSet)) |
|
1469 { |
|
1470 if (filterToSet) |
|
1471 aAppInfoFilter->SetAllApps(); |
|
1472 if (GetIntFromConfig(ConfigSection(), _L("AIFAllAppsScreenMode"), screenMode )) |
|
1473 aAppInfoFilter->SetAllApps(screenMode); |
|
1474 return ; |
|
1475 } |
|
1476 if (GetBoolFromConfig(ConfigSection(), _L("AIFEmbApps"), filterToSet)) |
|
1477 { |
|
1478 if (filterToSet) |
|
1479 aAppInfoFilter->SetEmbeddableApps(); |
|
1480 if (GetIntFromConfig(ConfigSection(), _L("AIFEmbAppScreanMode"), screenMode )) |
|
1481 aAppInfoFilter->SetEmbeddableApps(screenMode); |
|
1482 return ; |
|
1483 } |
|
1484 TInt filterValue(0); |
|
1485 if (GetIntFromConfig(ConfigSection(), _L("AIFFilEmbAppsEmbedabilityFilter"), filterValue)) |
|
1486 { |
|
1487 TInt readFilterVal(0); |
|
1488 Usif::TEmbeddableFilter embadibilityFilter ; |
|
1489 for (TInt i=0 ; i <filterValue;i++) |
|
1490 { |
|
1491 TBuf<20> filterName=_L("EFilterVal"); |
|
1492 GenerateIndexedAttributeNameL(filterName, i); |
|
1493 if(GetIntFromConfig(ConfigSection(), filterName, readFilterVal)) |
|
1494 embadibilityFilter.AddEmbeddability(TApplicationCharacteristics::TAppEmbeddability(readFilterVal)); |
|
1495 } |
|
1496 if (GetIntFromConfig(ConfigSection(), _L("AIFFilEmbAppsEmbedableScreenMode"), screenMode )) |
|
1497 aAppInfoFilter->SetEmbeddabilityFilterWithScreenMode(embadibilityFilter,screenMode); |
|
1498 else |
|
1499 aAppInfoFilter->SetEmbeddabilityFilter(embadibilityFilter); |
|
1500 return ; |
|
1501 } |
|
1502 if (GetIntFromConfig(ConfigSection(), _L("AIFFilAppsWithCapMask"), filterValue)) |
|
1503 { |
|
1504 TInt capValue(0); |
|
1505 if (GetIntFromConfig(ConfigSection(), _L("AIFFilAppsWithCapValue"), capValue)) |
|
1506 { |
|
1507 if (GetIntFromConfig(ConfigSection(), _L("AIFFilAppsWithCapScreenMode"), screenMode )) |
|
1508 aAppInfoFilter->SetCapabilityAttributeMaskAndValue(filterValue,capValue,screenMode); |
|
1509 else |
|
1510 aAppInfoFilter->SetCapabilityAttributeMaskAndValue(filterValue,capValue); |
|
1511 } |
|
1512 return ; |
|
1513 } |
|
1514 TUid filterUId; |
|
1515 if (GetUidFromConfig(ConfigSection(), _L("AIFServerApps"), filterUId)) |
|
1516 { |
|
1517 if (GetIntFromConfig(ConfigSection(), _L("AIFServerAppsScreenMode"), screenMode )) |
|
1518 aAppInfoFilter->SetServerApps(filterUId,screenMode); |
|
1519 else |
|
1520 aAppInfoFilter->SetServerApps(filterUId); |
|
1521 return ; |
|
1522 } |
|
1523 User::Leave(KErrNotFound); |
|
1524 } |
|
1525 |
|
1526 void CScrTestStep::GetViewDataInfoFromConfigL(RPointerArray<CAppViewData>& aAppViewInfoArray) |
|
1527 { |
|
1528 TInt viewDataCount=0; |
|
1529 GetIntFromConfig(ConfigSection(), _L("ViewDataCount"), viewDataCount); |
|
1530 for (TUint i = 0; i < viewDataCount; ++i) |
|
1531 { |
|
1532 TInt viewScreenMode,vUid; |
|
1533 TBuf<20> uid, screenMode; |
|
1534 uid = KVwUid; |
|
1535 GenerateIndexedAttributeNameL(uid, i); |
|
1536 GetIntFromConfig(ConfigSection(), uid, vUid); |
|
1537 TUid viewUid = TUid::Uid(vUid); |
|
1538 screenMode = KVwScreenMode; |
|
1539 GenerateIndexedAttributeNameL(screenMode, i); |
|
1540 GetIntFromConfig(ConfigSection(), screenMode, viewScreenMode); |
|
1541 |
|
1542 TPtrC viewCaption; |
|
1543 TPtrC viewIconFileName; |
|
1544 TInt viewNoOfAppIcons = 0; |
|
1545 TBuf<20> caption, iconFileName, noOfAppIcons; |
|
1546 caption = KVwCaption; |
|
1547 GenerateIndexedAttributeNameL(caption, i); |
|
1548 GetStringFromConfig(ConfigSection(), caption, viewCaption); |
|
1549 iconFileName = KVwIconFileName; |
|
1550 GenerateIndexedAttributeNameL(iconFileName, i); |
|
1551 GetStringFromConfig(ConfigSection(), iconFileName, viewIconFileName); |
|
1552 noOfAppIcons = KVwNumberOfAppIcons; |
|
1553 GenerateIndexedAttributeNameL(noOfAppIcons, i); |
|
1554 GetIntFromConfig(ConfigSection(), noOfAppIcons, viewNoOfAppIcons); |
|
1555 CCaptionAndIconInfo* viewCaptionAndIconInfo = NULL; |
|
1556 if(viewCaption.Length() != 0 || viewIconFileName.Length() !=0 || viewNoOfAppIcons != 0) |
|
1557 { |
|
1558 viewCaptionAndIconInfo = CCaptionAndIconInfo::NewLC(viewCaption,viewIconFileName,viewNoOfAppIcons); |
|
1559 } |
|
1560 else |
|
1561 { |
|
1562 CleanupStack::PushL(viewCaptionAndIconInfo); |
|
1563 } |
|
1564 CAppViewData* viewData = CAppViewData::NewLC(viewUid,viewScreenMode,viewCaptionAndIconInfo); |
|
1565 aAppViewInfoArray.AppendL(viewData); |
|
1566 CleanupStack::Pop(2, viewCaptionAndIconInfo); |
|
1567 } |
|
1568 } |
|
1569 |
|
1570 TBool CScrTestStep::NotEqual(const Usif::CCaptionAndIconInfo *aLhsEntry, const Usif::CCaptionAndIconInfo *aRhsEntry) const |
|
1571 { |
|
1572 if(aLhsEntry != NULL && aRhsEntry != NULL ) |
|
1573 { |
|
1574 if ((aLhsEntry->Caption() != aRhsEntry->Caption())||(aLhsEntry->IconFileName() != aRhsEntry->IconFileName() )||(aLhsEntry->NumOfAppIcons() != aRhsEntry->NumOfAppIcons())) |
|
1575 return ETrue; |
|
1576 else |
|
1577 return EFalse; |
|
1578 } |
|
1579 else |
|
1580 { |
|
1581 if(aLhsEntry == NULL && aRhsEntry == NULL) |
|
1582 return EFalse; |
|
1583 else return ETrue; |
|
1584 } |
|
1585 } |
|
1586 |
|
1587 TBool CScrTestStep::NotEqualL( |
|
1588 const RPointerArray<Usif::CServiceInfo>& aLhsEntry, |
|
1589 const RPointerArray<Usif::CServiceInfo>& aRhsEntry) const |
|
1590 { |
|
1591 TInt result(EFalse); |
|
1592 if (aLhsEntry.Count() != aRhsEntry.Count()) |
|
1593 result = ETrue; |
|
1594 |
|
1595 else |
|
1596 { |
|
1597 for (TInt i = 0; i < aLhsEntry.Count(); i++) |
|
1598 { |
|
1599 // Compare Uids |
|
1600 if (aLhsEntry[i]->Uid() != aRhsEntry[i]->Uid()) |
|
1601 { |
|
1602 result = ETrue; |
|
1603 break; |
|
1604 } |
|
1605 |
|
1606 // Compare Opaque Data Array |
|
1607 RPointerArray<Usif::COpaqueData> lhsOpaqueData = |
|
1608 aLhsEntry[i]->OpaqueData(); |
|
1609 CleanupResetAndDestroyPushL(lhsOpaqueData); |
|
1610 RPointerArray<Usif::COpaqueData> rhsOpaqueData = |
|
1611 aRhsEntry[i]->OpaqueData(); |
|
1612 CleanupResetAndDestroyPushL(rhsOpaqueData); |
|
1613 if (lhsOpaqueData.Count() != rhsOpaqueData.Count()) |
|
1614 { |
|
1615 CleanupStack::Pop(2, &lhsOpaqueData); |
|
1616 result = ETrue; |
|
1617 break; |
|
1618 } |
|
1619 else |
|
1620 { |
|
1621 for (TInt j = 0; j < rhsOpaqueData.Count(); j++) |
|
1622 { |
|
1623 if (lhsOpaqueData[j]->Language() |
|
1624 != rhsOpaqueData[j]->Language() |
|
1625 || lhsOpaqueData[j]->OpaqueData() |
|
1626 != rhsOpaqueData[j]->OpaqueData()) |
|
1627 { |
|
1628 CleanupStack::Pop(2, &lhsOpaqueData); |
|
1629 result = ETrue; |
|
1630 break; |
|
1631 } |
|
1632 } |
|
1633 } |
|
1634 CleanupStack::Pop(2, &lhsOpaqueData); |
|
1635 |
|
1636 // Data Entry |
|
1637 RPointerArray<Usif::CDataType> aLhsDataEntry = |
|
1638 aLhsEntry[i]->DataTypes(); |
|
1639 CleanupResetAndDestroyPushL(aLhsDataEntry); |
|
1640 RPointerArray<Usif::CDataType> aRhsDataEntry = |
|
1641 aRhsEntry[i]->DataTypes(); |
|
1642 CleanupResetAndDestroyPushL(aRhsDataEntry); |
|
1643 if (aLhsDataEntry.Count() != aRhsDataEntry.Count()) |
|
1644 { |
|
1645 CleanupStack::Pop(2, &aLhsDataEntry); |
|
1646 result = ETrue; |
|
1647 break; |
|
1648 } |
|
1649 else |
|
1650 { |
|
1651 for (TInt j = 0; j < aLhsDataEntry.Count(); j++) |
|
1652 { |
|
1653 if (aLhsDataEntry[j]->Priority() |
|
1654 != aRhsDataEntry[j]->Priority() |
|
1655 || aLhsDataEntry[j]->Type() |
|
1656 != aRhsDataEntry[j]->Type()) |
|
1657 { |
|
1658 CleanupStack::Pop(2, &aLhsDataEntry); |
|
1659 result = ETrue; |
|
1660 break; |
|
1661 } |
|
1662 } |
|
1663 } |
|
1664 CleanupStack::Pop(2, &aLhsDataEntry); |
|
1665 } |
|
1666 } |
|
1667 return result; |
|
1668 } |