|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @test |
|
22 @internalTechnology |
|
23 */ |
|
24 #include <test/testexecutelog.h> |
|
25 #include <hash.h> |
|
26 |
|
27 #include "sessionstep.h" |
|
28 #include "sisregistrysession.h" |
|
29 #include "sisregistryentry.h" |
|
30 #include "sisregistrypackage.h" |
|
31 #include "installtypes.h" |
|
32 #include "cleanuputils.h" |
|
33 #include "hashcontainer.h" |
|
34 #include "testutilclientswi.h" |
|
35 #include "arrayutils.h" |
|
36 #include "sisregistrytoken.h" |
|
37 #include "sisregistrylog.h" |
|
38 #include "s32file.h" |
|
39 #include "sishelperclient.h" |
|
40 #include "sisregistrywritableentry.h" |
|
41 #include "sisregistryfiledescription.h" |
|
42 #include "sisregistrydependency.h" |
|
43 #include "sisregistryobject.h" |
|
44 #include "controllerinfo.h" |
|
45 #include "hashcontainer.h" |
|
46 #include "sisregistryproperty.h" |
|
47 |
|
48 const TInt KDefaultBufferSize = 2048; |
|
49 ///////////////////////////////////////////////////////////////////// |
|
50 // defs, Constants used by test steps |
|
51 ///////////////////////////////////////////////////////////////////// |
|
52 |
|
53 _LIT(KNoUid, "nouid"); |
|
54 _LIT(KUid, "uid"); |
|
55 _LIT(KDrivebitmapcount, "drivebitmapcout"); |
|
56 _LIT(KSid, "sid"); |
|
57 _LIT(KPackage, "package"); |
|
58 _LIT(KVendor, "vendor"); |
|
59 _LIT(KSisFile, "sis"); |
|
60 _LIT(KKeyFormat, "-%02d"); |
|
61 _LIT(KSidFileNameSec, "file"); |
|
62 _LIT(KModFileName, "file"); |
|
63 _LIT(KModTag, "modtag"); |
|
64 _LIT(KHashFileName, "file"); |
|
65 _LIT(KHashFileValue, "hashvalue"); |
|
66 _LIT(KRootCertTag, "rootcert"); |
|
67 _LIT(KResultTag, "expectedresult"); |
|
68 _LIT(KDateTime, "datetime"); //YYYYMMDD:HHMMSS.MMMMMM |
|
69 _LIT(KPkgCount, "embeddingpkgcount"); |
|
70 _LIT(KCertChainCount, "certChainCount"); |
|
71 _LIT(KLanguage, "language"); |
|
72 |
|
73 _LIT(KSisRegistryPath, "\\sys\\install\\sisregistry\\"); |
|
74 _LIT(KCacheBackupFile, "\\sys\\install\\sisregistry\\backup.lst"); |
|
75 _LIT(KCorruptCacheBackupFile, "z:\\tswi\\tsisregistrytest\\data\\hashforlang_txt.dat"); |
|
76 _LIT(KSysBackupFileBackup, "\\sys\\install\\sisregistry\\backup.bak"); |
|
77 |
|
78 ///////////////////////////////////////////////////////////////////// |
|
79 // Tags used by test steps |
|
80 ///////////////////////////////////////////////////////////////////// |
|
81 using namespace Swi; |
|
82 |
|
83 ///////////////////////////////////////////////////////////////////// |
|
84 // CSisRegistrySessionStep |
|
85 ///////////////////////////////////////////////////////////////////// |
|
86 TVerdict CSisRegistrySessionStep::doTestStepPreambleL() |
|
87 { |
|
88 __UHEAP_MARK; |
|
89 |
|
90 // Install an active scheduler |
|
91 CActiveScheduler* s = new (ELeave) CActiveScheduler; |
|
92 s->Install(s); |
|
93 |
|
94 INFO_PRINTF1(_L("Connecting to SisRegistry..")); |
|
95 User::LeaveIfError(iSisRegistry.Connect()); |
|
96 INFO_PRINTF1(_L("Connected!")); |
|
97 |
|
98 StartTimer(); |
|
99 return TestStepResult(); |
|
100 } |
|
101 |
|
102 TVerdict CSisRegistrySessionStep::doTestStepPostambleL() |
|
103 { |
|
104 StopTimerAndPrintResultL(); |
|
105 // Remove the installed active scheduler |
|
106 CActiveScheduler* s = CActiveScheduler::Current(); |
|
107 s->Install(NULL); |
|
108 delete s; |
|
109 INFO_PRINTF1(_L("Disconnecting from SisRegistry..")); |
|
110 iSisRegistry.Close(); |
|
111 |
|
112 __UHEAP_MARKEND; |
|
113 |
|
114 return TestStepResult(); |
|
115 } |
|
116 |
|
117 ///////////////////////////////////////////////////////////////////// |
|
118 // CRegistryEntryStep |
|
119 ///////////////////////////////////////////////////////////////////// |
|
120 TVerdict CRegistryEntryStep::doTestStepPreambleL() |
|
121 { |
|
122 CSisRegistrySessionStep::doTestStepPreambleL(); |
|
123 TUid pckgUid; |
|
124 if(!GetUidFromConfig(ConfigSection(), KUid, pckgUid)) |
|
125 { |
|
126 ERR_PRINTF1(_L("Package UID is missing in the configuration file!")); |
|
127 SetTestStepResult(EFail); |
|
128 return TestStepResult(); |
|
129 } |
|
130 |
|
131 TInt err = iRegistryEntry.Open(iSisRegistry, pckgUid); |
|
132 if (KErrNone != err) |
|
133 { |
|
134 ERR_PRINTF2(_L("Registry entry couldn't be opened (Error code=%d)!"), err); |
|
135 SetTestStepResult(EFail); |
|
136 return TestStepResult(); |
|
137 } |
|
138 StartTimer(); // Start timer again to ignore the time taken to open the registry entry |
|
139 return TestStepResult(); |
|
140 } |
|
141 |
|
142 TVerdict CRegistryEntryStep::doTestStepPostambleL() |
|
143 { |
|
144 iRegistryEntry.Close(); |
|
145 CSisRegistrySessionStep::doTestStepPostambleL(); |
|
146 return TestStepResult(); |
|
147 } |
|
148 |
|
149 ///////////////////////////////////////////////////////////////////// |
|
150 // CEmbeddingPackageStep - Checks the embedding packages for a given package |
|
151 ///////////////////////////////////////////////////////////////////// |
|
152 CEmbeddingPackageStep::CEmbeddingPackageStep() |
|
153 { |
|
154 SetTestStepName(KEmbeddingPackageStep); |
|
155 } |
|
156 |
|
157 TVerdict CEmbeddingPackageStep::doTestStepL() |
|
158 { |
|
159 SetTestStepResult(EPass); |
|
160 |
|
161 TInt embeddingPkgCount; |
|
162 if(!GetIntFromConfig(ConfigSection(), KPkgCount, embeddingPkgCount)) |
|
163 { |
|
164 ERR_PRINTF1(_L("Missing expected package count")); |
|
165 SetTestStepResult(EFail); |
|
166 return TestStepResult(); |
|
167 } |
|
168 |
|
169 RPointerArray<Swi::CSisRegistryPackage> packages; |
|
170 //StartTimer again to ignore time taken to read from config file |
|
171 StartTimer(); |
|
172 iRegistryEntry.EmbeddingPackagesL(packages); |
|
173 CleanupResetAndDestroyPushL(packages); |
|
174 |
|
175 if(packages.Count() != embeddingPkgCount) |
|
176 { |
|
177 ERR_PRINTF3(_L("The actual number of embedding packages does not meet expected. Expected: %d Actual: %d"), embeddingPkgCount, packages.Count()); |
|
178 SetTestStepResult(EFail); |
|
179 } |
|
180 CleanupStack::PopAndDestroy(&packages); |
|
181 return TestStepResult(); |
|
182 } |
|
183 |
|
184 ///////////////////////////////////////////////////////////////////// |
|
185 // CSidFileStep - Checks the filename to sid mapping |
|
186 ///////////////////////////////////////////////////////////////////// |
|
187 CSidFileStep::CSidFileStep() |
|
188 { |
|
189 SetTestStepName(KSidFileName); |
|
190 } |
|
191 |
|
192 TVerdict CSidFileStep::doTestStepL() |
|
193 { |
|
194 RArray<TUid> theSids; |
|
195 CleanupClosePushL(theSids); |
|
196 GetUidArrayFromConfigL(ConfigSection(), KSid, theSids); |
|
197 |
|
198 //RArray<TUid> thePackageUids; |
|
199 //CleanupClosePushL(thePackageUids); |
|
200 //GetUidArrayFromConfigL(ConfigSection(), KUid, thePackageUids); |
|
201 |
|
202 RArray<TPtrC> expectedSidNames; |
|
203 CleanupClosePushL(expectedSidNames); |
|
204 GetStringArrayFromConfigL(ConfigSection(), KSidFileNameSec, expectedSidNames); |
|
205 |
|
206 SetTestStepResult(EPass); |
|
207 |
|
208 if (theSids.Count() != expectedSidNames.Count()) |
|
209 { |
|
210 User::LeaveIfError(KErrCorrupt); |
|
211 } |
|
212 |
|
213 TBuf<KMaxFileName> fileName; |
|
214 //StartTimer again to ignore time taken to read from config file |
|
215 StartTimer(); |
|
216 for (TInt sidCount(0); sidCount<theSids.Count(); sidCount++) |
|
217 { |
|
218 iSisRegistry.SidToFileNameL(theSids[sidCount],fileName); |
|
219 if (expectedSidNames[sidCount].Compare(fileName) != 0) |
|
220 { |
|
221 SetTestStepResult(EFail); |
|
222 break; |
|
223 } |
|
224 } |
|
225 |
|
226 CleanupStack::PopAndDestroy(&expectedSidNames); |
|
227 //CleanupStack::PopAndDestroy(&thePackageUids); |
|
228 CleanupStack::PopAndDestroy(&theSids); |
|
229 return TestStepResult(); |
|
230 } |
|
231 |
|
232 //////////////////////////////////////////////////////////////////////// |
|
233 // CModifiableFileStep - Checks whether the file is tagged as modifiable |
|
234 //////////////////////////////////////////////////////////////////////// |
|
235 CModifiableFileStep::CModifiableFileStep() |
|
236 { |
|
237 SetTestStepName(KModifiableFile); |
|
238 } |
|
239 |
|
240 TVerdict CModifiableFileStep::doTestStepL() |
|
241 { |
|
242 RArray<TPtrC> theFileNames; |
|
243 CleanupClosePushL(theFileNames); |
|
244 GetStringArrayFromConfigL(ConfigSection(), KModFileName, theFileNames); |
|
245 |
|
246 RArray<TInt> expectedModifiableTags; |
|
247 CleanupClosePushL(expectedModifiableTags); |
|
248 GetIntArrayFromConfigL(ConfigSection(), KModTag, expectedModifiableTags); |
|
249 |
|
250 SetTestStepResult(EPass); |
|
251 |
|
252 if (theFileNames.Count() != expectedModifiableTags.Count()) |
|
253 { |
|
254 User::LeaveIfError(KErrCorrupt); |
|
255 } |
|
256 |
|
257 TInt numModFiles = theFileNames.Count(); |
|
258 |
|
259 //StartTimer again to ignore time taken to read from config file |
|
260 StartTimer(); |
|
261 |
|
262 for (TInt i=0; i<numModFiles; i++) |
|
263 { |
|
264 TBool isFileModifiable = iSisRegistry.ModifiableL(theFileNames[i]); |
|
265 |
|
266 INFO_PRINTF2(_L("File '%d':"), i); |
|
267 INFO_PRINTF2(_L(" expected modifiable tag = %d"), expectedModifiableTags[i]); |
|
268 INFO_PRINTF2(_L(" calculated modifiable tag = %d"), isFileModifiable); |
|
269 |
|
270 if (expectedModifiableTags[i] != isFileModifiable) |
|
271 { |
|
272 SetTestStepResult(EFail); |
|
273 break; |
|
274 } |
|
275 } |
|
276 |
|
277 // Items popped and cleaned up from the stack (in this order): |
|
278 // &expectedModifiableTags and &theFileNames. |
|
279 CleanupStack::PopAndDestroy(2, &theFileNames); |
|
280 |
|
281 return TestStepResult(); |
|
282 } |
|
283 |
|
284 //////////////////////////////////////////////////////////////////////// |
|
285 // CFileHashStep - Checks the hash of a file |
|
286 //////////////////////////////////////////////////////////////////////// |
|
287 CFileHashStep::CFileHashStep() |
|
288 { |
|
289 SetTestStepName(KFileHash); |
|
290 } |
|
291 |
|
292 TVerdict CFileHashStep::doTestStepL() |
|
293 { |
|
294 // Get the filenames (for which the hash will be calculated) |
|
295 // from the test section. |
|
296 RArray<TPtrC> theFileNames; |
|
297 CleanupClosePushL(theFileNames); |
|
298 GetStringArrayFromConfigL(ConfigSection(), KHashFileName, theFileNames); |
|
299 |
|
300 // Get the filenames that contain the expected hash values, |
|
301 // from the test section. |
|
302 RArray<TPtrC> expectedHashFiles; |
|
303 CleanupClosePushL(expectedHashFiles); |
|
304 GetStringArrayFromConfigL(ConfigSection(), KHashFileValue, expectedHashFiles); |
|
305 |
|
306 // Initialise the test step result to pass. |
|
307 SetTestStepResult(EPass); |
|
308 |
|
309 // Ensure that there are as many filenames whose hash will be calculated, |
|
310 // as there are files with expected hash values. |
|
311 TInt numModFiles = theFileNames.Count(); |
|
312 if (numModFiles != expectedHashFiles.Count()) |
|
313 { |
|
314 User::LeaveIfError(KErrCorrupt); |
|
315 } |
|
316 |
|
317 //StartTimer again to ignore time taken to read from config file |
|
318 StartTimer(); |
|
319 |
|
320 // For each file in config section KHashFileName, calculate its hash |
|
321 // value and compare it with the corresponding expected hash value. |
|
322 // Fail the test case if they don't match. |
|
323 for (TInt i=0; i<numModFiles; i++) |
|
324 { |
|
325 INFO_PRINTF2(_L("Using SisRegistry to calculate hash for: %S"), &theFileNames[i]); |
|
326 // Use SisRegistry to calculate the hash value for this file. |
|
327 CHashContainer* hashContainer = iSisRegistry.HashL(theFileNames[i]); |
|
328 CleanupStack::PushL(hashContainer); |
|
329 |
|
330 const TDesC8& calcHashValue = hashContainer->Data(); |
|
331 INFO_PRINTF2(_L("Received hash with length %d"), calcHashValue.Length()); |
|
332 |
|
333 // Open for reading the file that has the expected hash value. |
|
334 INFO_PRINTF2(_L("Reading Expected hash value from: %S"), &expectedHashFiles[i]); |
|
335 RFs fs; |
|
336 User::LeaveIfError(fs.Connect()); |
|
337 CleanupClosePushL(fs); |
|
338 |
|
339 RFile fileToRead; |
|
340 User::LeaveIfError(fileToRead.Open(fs, expectedHashFiles[i], |
|
341 EFileRead | EFileShareReadersOnly | EFileStream)); |
|
342 CleanupClosePushL(fileToRead); |
|
343 |
|
344 // Create a block of memory to store the expected hash value. |
|
345 TInt fileSize = 0; |
|
346 User::LeaveIfError(fileToRead.Size(fileSize)); |
|
347 HBufC8* memForExpectedHashValue = HBufC8::NewLC(fileSize); |
|
348 |
|
349 // Read the expected hash value into the previously created memory block. |
|
350 TPtr8 expectedHashValue(memForExpectedHashValue->Des()); |
|
351 User::LeaveIfError(fileToRead.Read(0, expectedHashValue, fileSize)); |
|
352 |
|
353 INFO_PRINTF2(_L("Expecting hash with length %d"), expectedHashValue.Length()); |
|
354 |
|
355 INFO_PRINTF1(_L("Comparing hash values")); |
|
356 |
|
357 // Compare the calculated has value against its expected value. |
|
358 if (calcHashValue.Compare(expectedHashValue) != KErrNone) |
|
359 { |
|
360 SetTestStepResult(EFail); |
|
361 |
|
362 // Items popped and cleaned up from the stack (in this order): |
|
363 // memForExpectedHashValue, &fileToRead, &fs and hashContainer. |
|
364 CleanupStack::PopAndDestroy(4, hashContainer); |
|
365 |
|
366 break; |
|
367 } |
|
368 |
|
369 // Items popped and cleaned up from the stack (in this order): |
|
370 // memForExpectedHashValue, &fileToRead, &fs and hashContainer. |
|
371 CleanupStack::PopAndDestroy(4, hashContainer); |
|
372 } |
|
373 |
|
374 // Items popped and cleaned up from the stack (in this order): |
|
375 // &expectedHashFiles and &theFileNames. |
|
376 CleanupStack::PopAndDestroy(2, &theFileNames); |
|
377 |
|
378 return TestStepResult(); |
|
379 } |
|
380 |
|
381 ///////////////////////////////////////////////////////////////////// |
|
382 // CInstalledUidsStep - checks installed packages Uids list |
|
383 ///////////////////////////////////////////////////////////////////// |
|
384 CInstalledUidsStep::CInstalledUidsStep() |
|
385 { |
|
386 SetTestStepName(KInstalledUids); |
|
387 } |
|
388 |
|
389 TVerdict CInstalledUidsStep::doTestStepL() |
|
390 { |
|
391 RArray<TUid> expectedUids; |
|
392 CleanupClosePushL(expectedUids); |
|
393 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
394 |
|
395 RArray<TUid> actualUids; |
|
396 CleanupClosePushL(actualUids); |
|
397 |
|
398 //StartTimer again to ignore time taken to read from config file |
|
399 StartTimer(); |
|
400 iSisRegistry.InstalledUidsL(actualUids); |
|
401 |
|
402 SetTestStepResult(EPass); |
|
403 |
|
404 for (TInt index=0; index < expectedUids.Count(); index++) |
|
405 { |
|
406 if(actualUids.Find(expectedUids[index]) != KErrNotFound) |
|
407 { |
|
408 INFO_PRINTF2(_L("Uid: 0x%08x was found!"), expectedUids[index]); |
|
409 } |
|
410 else |
|
411 { |
|
412 SetTestStepResult(EFail); |
|
413 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[index]); |
|
414 } |
|
415 } |
|
416 |
|
417 CleanupStack::PopAndDestroy(2, &expectedUids); //actualUids |
|
418 |
|
419 return TestStepResult(); |
|
420 } |
|
421 |
|
422 ///////////////////////////////////////////////////////////////////// |
|
423 // CInstalledPackagesStep - checks installed packages names and vendor list |
|
424 ///////////////////////////////////////////////////////////////////// |
|
425 CInstalledPackagesStep::CInstalledPackagesStep() |
|
426 { |
|
427 SetTestStepName(KInstalledPackages); |
|
428 } |
|
429 |
|
430 TVerdict CInstalledPackagesStep::doTestStepL() |
|
431 { |
|
432 RArray<TUid> expectedUids; |
|
433 CleanupClosePushL(expectedUids); |
|
434 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
435 |
|
436 RArray<TPtrC> expectedPackageNames; |
|
437 CleanupClosePushL(expectedPackageNames); |
|
438 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
439 |
|
440 RArray<TPtrC> expectedVendorNames; |
|
441 CleanupClosePushL(expectedVendorNames); |
|
442 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
443 |
|
444 RPointerArray<CSisRegistryPackage> packages; |
|
445 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
446 |
|
447 //StartTimer again to ignore time taken to read from config file |
|
448 StartTimer(); |
|
449 iSisRegistry.InstalledPackagesL(packages); |
|
450 |
|
451 SetTestStepResult(EPass); |
|
452 |
|
453 for (TInt expected = 0; expected < expectedPackageNames.Count(); expected++) |
|
454 { |
|
455 TBool result = EFalse; |
|
456 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
457 { |
|
458 if (packages[actual]->Uid() == expectedUids[expected] && |
|
459 !packages[actual]->Name().CompareF(expectedPackageNames[expected]) && |
|
460 !packages[actual]->Vendor().CompareF(expectedVendorNames[expected])) |
|
461 { |
|
462 result = ETrue; |
|
463 break; |
|
464 } |
|
465 } |
|
466 |
|
467 if(result) |
|
468 { |
|
469 INFO_PRINTF3(_L("Package %S by Vendor %S was found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
470 } |
|
471 else |
|
472 { |
|
473 SetTestStepResult(EFail); |
|
474 ERR_PRINTF3(_L("Package %S by Vendor %S was not found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
475 } |
|
476 } |
|
477 |
|
478 CleanupStack::PopAndDestroy(4, &expectedUids); //packages, expectedVendorNames, expectedPackageNames |
|
479 |
|
480 return TestStepResult(); |
|
481 } |
|
482 |
|
483 ///////////////////////////////////////////////////////////////////// |
|
484 // CRemovablePackagesStep - checks removable packages names and vendor list |
|
485 ///////////////////////////////////////////////////////////////////// |
|
486 CRemovablePackagesStep::CRemovablePackagesStep() |
|
487 { |
|
488 SetTestStepName(KRemovablePackages); |
|
489 } |
|
490 |
|
491 TVerdict CRemovablePackagesStep::doTestStepL() |
|
492 { |
|
493 RArray<TUid> expectedNoUids; |
|
494 CleanupClosePushL(expectedNoUids); |
|
495 GetUidArrayFromConfigL(ConfigSection(), KNoUid, expectedNoUids); |
|
496 |
|
497 RArray<TUid> expectedUids; |
|
498 CleanupClosePushL(expectedUids); |
|
499 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
500 |
|
501 RArray<TPtrC> expectedPackageNames; |
|
502 CleanupClosePushL(expectedPackageNames); |
|
503 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
504 |
|
505 RArray<TPtrC> expectedVendorNames; |
|
506 CleanupClosePushL(expectedVendorNames); |
|
507 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
508 |
|
509 RPointerArray<CSisRegistryPackage> packages; |
|
510 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
511 |
|
512 //StartTimer again to ignore time taken to read from config file |
|
513 StartTimer(); |
|
514 |
|
515 iSisRegistry.RemovablePackagesL(packages); |
|
516 |
|
517 TInt expected = 0; |
|
518 for (expected = 0; expected < expectedPackageNames.Count(); expected++) |
|
519 { |
|
520 TBool result = EFalse; |
|
521 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
522 { |
|
523 if (packages[actual]->Uid() == expectedUids[expected] && |
|
524 !packages[actual]->Name().CompareF(expectedPackageNames[expected]) && |
|
525 !packages[actual]->Vendor().CompareF(expectedVendorNames[expected])) |
|
526 { |
|
527 result = ETrue; |
|
528 break; |
|
529 } |
|
530 } |
|
531 |
|
532 if(result) |
|
533 { |
|
534 INFO_PRINTF3(_L("Package %S by Vendor %S was found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
535 } |
|
536 else |
|
537 { |
|
538 SetTestStepResult(EFail); |
|
539 ERR_PRINTF3(_L("Package %S by Vendor %S was not found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
540 } |
|
541 } |
|
542 |
|
543 for (expected = 0; expected < expectedNoUids.Count(); expected++) |
|
544 { |
|
545 TBool result = ETrue; |
|
546 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
547 { |
|
548 if (packages[actual]->Uid() == expectedNoUids[expected]) |
|
549 { |
|
550 result = EFalse; |
|
551 break; |
|
552 } |
|
553 } |
|
554 |
|
555 if(result) |
|
556 { |
|
557 INFO_PRINTF2(_L("Non-Removable Package %d was not found!"), &expectedNoUids[expected]); |
|
558 } |
|
559 else |
|
560 { |
|
561 SetTestStepResult(EFail); |
|
562 ERR_PRINTF2(_L("Non-Removable Package %d was found!"), &expectedNoUids[expected]); |
|
563 } |
|
564 } |
|
565 |
|
566 CleanupStack::PopAndDestroy(5, &expectedNoUids); //packages, expectedVendorNames, expectedPackageNames |
|
567 |
|
568 return TestStepResult(); |
|
569 } |
|
570 |
|
571 ///////////////////////////////////////////////////////////////////// |
|
572 // CNonRemovablePackagesStep - checks Non-removable packages in rom |
|
573 ///////////////////////////////////////////////////////////////////// |
|
574 CInRomNonRemovablePackage::CInRomNonRemovablePackage() |
|
575 { |
|
576 SetTestStepName(KInRomNonRemovablePackages); |
|
577 } |
|
578 |
|
579 TVerdict CInRomNonRemovablePackage::doTestStepL() |
|
580 { |
|
581 RPointerArray<CSisRegistryPackage> packages; |
|
582 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
583 |
|
584 iSisRegistry.RemovablePackagesL(packages); |
|
585 |
|
586 RSisRegistryEntry entry; |
|
587 TBool inrom = EFalse; |
|
588 for (TInt i = 0; i < packages.Count(); ++i) |
|
589 { |
|
590 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[i])); |
|
591 inrom = entry.IsInRomL(); |
|
592 |
|
593 if(inrom) |
|
594 { |
|
595 SetTestStepResult(EFail); |
|
596 } |
|
597 } |
|
598 INFO_PRINTF1(_L("Packages which are removable are not in ROM")); |
|
599 CleanupStack::PopAndDestroy(&packages); |
|
600 |
|
601 return TestStepResult(); |
|
602 } |
|
603 |
|
604 ////////////////////////////////////////////////////////////////////////////// |
|
605 // CInstalledDrives - check all the drives where files are installed from SIS |
|
606 ////////////////////////////////////////////////////////////////////////////// |
|
607 CInstalledDrives::CInstalledDrives() |
|
608 { |
|
609 SetTestStepName(KInstalledDrives); |
|
610 } |
|
611 |
|
612 TVerdict CInstalledDrives::doTestStepL() |
|
613 { |
|
614 TInt drivebitmapcount=0; |
|
615 TUid expectedUid; |
|
616 GetUidFromConfig(ConfigSection(), KUid, expectedUid); |
|
617 GetIntFromConfig(ConfigSection(), KDrivebitmapcount, drivebitmapcount); |
|
618 |
|
619 RSisRegistryEntry entry; |
|
620 CleanupClosePushL(entry); |
|
621 |
|
622 //StartTimer again to ignore time taken to read from config file |
|
623 StartTimer(); |
|
624 |
|
625 User::LeaveIfError(entry.Open(iSisRegistry, expectedUid)); |
|
626 |
|
627 TUint drives = entry.InstalledDrivesL(); |
|
628 if (drives != drivebitmapcount) |
|
629 { |
|
630 SetTestStepResult(EFail); |
|
631 INFO_PRINTF3(_L("Drive bitmask count is not correct, expected %d but received %d"), drivebitmapcount, drives); |
|
632 } |
|
633 else |
|
634 { |
|
635 INFO_PRINTF1(_L("Drive bitmask count is OK...")); |
|
636 } |
|
637 |
|
638 CleanupStack::PopAndDestroy(&entry); |
|
639 |
|
640 return TestStepResult(); |
|
641 } |
|
642 |
|
643 |
|
644 ///////////////////////////////////////////////////////////////////// |
|
645 // CIsUidInstalledStep - checks whether an Uid is registered |
|
646 ///////////////////////////////////////////////////////////////////// |
|
647 CIsUidInstalledStep::CIsUidInstalledStep() |
|
648 { |
|
649 SetTestStepName(KIsUidInstalled); |
|
650 } |
|
651 |
|
652 TVerdict CIsUidInstalledStep::doTestStepL() |
|
653 { |
|
654 RArray<TUid> expectedUids; |
|
655 CleanupClosePushL(expectedUids); |
|
656 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
657 |
|
658 SetTestStepResult(EPass); |
|
659 |
|
660 //StartTimer again to ignore time taken to read from config file |
|
661 StartTimer(); |
|
662 |
|
663 for (TInt index = 0; index < expectedUids.Count(); index++) |
|
664 { |
|
665 if(iSisRegistry.IsInstalledL(expectedUids[index])) |
|
666 { |
|
667 INFO_PRINTF2(_L("Uid: 0x%08x was found!"), expectedUids[index]); |
|
668 } |
|
669 else |
|
670 { |
|
671 SetTestStepResult(EFail); |
|
672 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[index]); |
|
673 } |
|
674 } |
|
675 CleanupStack::PopAndDestroy(&expectedUids); |
|
676 |
|
677 return TestStepResult(); |
|
678 } |
|
679 |
|
680 ///////////////////////////////////////////////////////////////////// |
|
681 // CIsPackageInstalledStep - checks if packages are registered |
|
682 ///////////////////////////////////////////////////////////////////// |
|
683 |
|
684 CIsPackageInstalledStep::CIsPackageInstalledStep() |
|
685 { |
|
686 SetTestStepName(KIsPackageInstalled); |
|
687 } |
|
688 |
|
689 TVerdict CIsPackageInstalledStep::doTestStepL() |
|
690 { |
|
691 RArray<TUid> expectedUids; |
|
692 CleanupClosePushL(expectedUids); |
|
693 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
694 |
|
695 RArray<TPtrC> expectedPackageNames; |
|
696 CleanupClosePushL(expectedPackageNames); |
|
697 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
698 |
|
699 RArray<TPtrC> expectedVendorNames; |
|
700 CleanupClosePushL(expectedVendorNames); |
|
701 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
702 |
|
703 RPointerArray<CSisRegistryPackage> packages; |
|
704 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
705 |
|
706 SetTestStepResult(EPass); |
|
707 |
|
708 //StartTimer again to ignore time taken to read from config file |
|
709 StartTimer(); |
|
710 |
|
711 for (TInt i = 0; i < expectedUids.Count(); ++i) |
|
712 { |
|
713 CSisRegistryPackage* package = CSisRegistryPackage::NewLC(expectedUids[i], |
|
714 expectedPackageNames[i], expectedVendorNames[i]); |
|
715 package->SetIndex(0); |
|
716 |
|
717 RSisRegistryEntry entry; |
|
718 CleanupClosePushL(entry); |
|
719 |
|
720 TInt err = entry.Open(iSisRegistry, package->Name(), package->Vendor()); |
|
721 if (err != KErrNone) |
|
722 { |
|
723 SetTestStepResult(EFail); |
|
724 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[i]); |
|
725 } |
|
726 |
|
727 CleanupStack::PopAndDestroy(2, package); //entry |
|
728 } |
|
729 |
|
730 CleanupStack::PopAndDestroy(4, &expectedUids); // expectedVendorNames, expectedPackageNames |
|
731 |
|
732 return TestStepResult(); |
|
733 } |
|
734 |
|
735 ///////////////////////////////////////////////////////////////////// |
|
736 // CIsControllerInstalledStep - checks whether a Controller is present |
|
737 ///////////////////////////////////////////////////////////////////// |
|
738 CIsControllerInstalledStep::CIsControllerInstalledStep() |
|
739 { |
|
740 SetTestStepName(KIsControllerInstalled); |
|
741 } |
|
742 |
|
743 TVerdict CIsControllerInstalledStep::doTestStepL() |
|
744 { |
|
745 RArray<TPtrC> expectedControllersSisFiles; |
|
746 CleanupClosePushL(expectedControllersSisFiles); |
|
747 GetStringArrayFromConfigL(ConfigSection(), KSisFile, expectedControllersSisFiles); |
|
748 |
|
749 SetTestStepResult(EPass); |
|
750 RFs fs; |
|
751 User::LeaveIfError(fs.Connect()); |
|
752 CleanupClosePushL(fs); |
|
753 |
|
754 //StartTimer again to ignore time taken to read from config file |
|
755 StartTimer(); |
|
756 |
|
757 for (TInt index = 0; index < expectedControllersSisFiles.Count(); index++) |
|
758 { |
|
759 HBufC8* controllerData = GetControllerFromSisLC(expectedControllersSisFiles[index]); |
|
760 const TInt controllerOffset = 4; |
|
761 // The registry does not store the first 4 bytes of the controller - see CInstallationProcessor |
|
762 TPtrC8 controllerDataPtr = controllerData->Mid(controllerOffset); |
|
763 |
|
764 if(iSisRegistry.IsInstalledL(controllerDataPtr)) |
|
765 { |
|
766 INFO_PRINTF2(_L("%S matching controller was found!"), &expectedControllersSisFiles[index]); |
|
767 } |
|
768 else |
|
769 { |
|
770 SetTestStepResult(EFail); |
|
771 INFO_PRINTF2(_L("%S controller did not match expected!"), &expectedControllersSisFiles[index]); |
|
772 } |
|
773 CleanupStack::PopAndDestroy(controllerData); |
|
774 } |
|
775 CleanupStack::PopAndDestroy(2, &expectedControllersSisFiles); //fs., |
|
776 |
|
777 return TestStepResult(); |
|
778 } |
|
779 |
|
780 ///////////////////////////////////////////////////////////////////// |
|
781 // CGetControllersStep - checks whether one can get the binary version |
|
782 // of entry controllers present |
|
783 ///////////////////////////////////////////////////////////////////// |
|
784 CGetControllersStep::CGetControllersStep() |
|
785 { |
|
786 SetTestStepName(KGetControllers); |
|
787 } |
|
788 |
|
789 TVerdict CGetControllersStep::doTestStepL() |
|
790 { |
|
791 SetTestStepResult(EPass); |
|
792 RArray<TUid> expectedUids; |
|
793 CleanupClosePushL(expectedUids); |
|
794 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
795 RFs fs; |
|
796 CleanupClosePushL(fs); |
|
797 User::LeaveIfError(fs.Connect()); |
|
798 |
|
799 //StartTimer again to ignore time taken to read from config file |
|
800 StartTimer(); |
|
801 |
|
802 for (TInt index = 0; index < expectedUids.Count(); index++) |
|
803 { |
|
804 TInt res; |
|
805 RSisRegistryEntry entry; |
|
806 CleanupClosePushL(entry); |
|
807 INFO_PRINTF3(_L("Open: %08x %d entry!"), expectedUids[index],index); |
|
808 res = entry.Open(iSisRegistry, expectedUids[index]); |
|
809 if (res != KErrNone) |
|
810 { |
|
811 SetTestStepResult(EFail); |
|
812 INFO_PRINTF2(_L("Failed Open Uid: %08x entry!"), expectedUids[index]); |
|
813 User::Leave(res); |
|
814 } |
|
815 |
|
816 RPointerArray<HBufC8> actualControllers; |
|
817 CleanupResetAndDestroy<RPointerArray<HBufC8> >::PushL(actualControllers); |
|
818 TRAP(res, entry.ControllersL(actualControllers)); |
|
819 if (res != KErrNone) |
|
820 { |
|
821 INFO_PRINTF3(_L("Accessing controllers for uid: %08x left with %d!"), expectedUids[index], res); |
|
822 SetTestStepResult(EFail); |
|
823 User::Leave(res); |
|
824 } |
|
825 |
|
826 // In the test, we exctract the controllers from the SIS files in order to compare them with the ones stored in the registry |
|
827 HBufC* keyName = HBufC::NewLC(KUid().Length() + KKeyFormat().Length() |
|
828 + KSisFile().Length() + KKeyFormat().Length()); |
|
829 TPtr ptr(keyName->Des()); |
|
830 ptr = KUid(); |
|
831 ptr.AppendFormat(KKeyFormat(), index + 1); |
|
832 ptr.Append(KSisFile); |
|
833 |
|
834 RArray<TPtrC> sisFilenames; |
|
835 CleanupClosePushL(sisFilenames); |
|
836 GetStringArrayFromConfigL(ConfigSection(), ptr, sisFilenames); |
|
837 |
|
838 if (sisFilenames.Count() != actualControllers.Count()) |
|
839 { |
|
840 ERR_PRINTF3(_L("Actual Controllers = %d, Expected Controllers = %d"), actualControllers.Count(), sisFilenames.Count()); |
|
841 SetTestStepResult(EFail); |
|
842 } |
|
843 |
|
844 for (TInt filenameIndex = 0; filenameIndex < sisFilenames.Count(); filenameIndex++) |
|
845 { |
|
846 HBufC8* controllerData = GetControllerFromSisLC(sisFilenames[filenameIndex]); |
|
847 const TInt controllerOffset = 4; |
|
848 // The registry does not store the first 4 bytes of the controller - see CInstallationProcessor |
|
849 TPtrC8 controllerDataPtr = controllerData->Mid(controllerOffset); |
|
850 TBool found = EFalse; |
|
851 for (TInt controller = 0; controller < actualControllers.Count(); controller++) |
|
852 { |
|
853 if(*actualControllers[controller] == controllerDataPtr) |
|
854 { |
|
855 found = ETrue; |
|
856 break; |
|
857 } |
|
858 } |
|
859 |
|
860 if(found) |
|
861 { |
|
862 INFO_PRINTF3(_L("Matching controller #%d found for Uid: %08x!"), filenameIndex, expectedUids[index]); |
|
863 } |
|
864 else |
|
865 { |
|
866 SetTestStepResult(EFail); |
|
867 ERR_PRINTF3(_L("Matching controller #%d not found for Uid: %08x!"), filenameIndex, expectedUids[index]); |
|
868 } |
|
869 |
|
870 CleanupStack::PopAndDestroy(controllerData); |
|
871 } |
|
872 |
|
873 CleanupStack::PopAndDestroy(4, &entry); // actualControllers, sisFilenames, keyNames |
|
874 } |
|
875 |
|
876 CleanupStack::PopAndDestroy(2, &expectedUids); // fs |
|
877 |
|
878 return TestStepResult(); |
|
879 } |
|
880 |
|
881 ///////////////////////////////////////////////////////////////////// |
|
882 // CEntryUidOpenCloseStep |
|
883 ///////////////////////////////////////////////////////////////////// |
|
884 CEntryUidOpenCloseStep::CEntryUidOpenCloseStep() |
|
885 { |
|
886 SetTestStepName(KEntryUidOpenClose); |
|
887 } |
|
888 |
|
889 TVerdict CEntryUidOpenCloseStep::doTestStepL() |
|
890 { |
|
891 RArray<TUid> uids; |
|
892 CleanupClosePushL(uids); |
|
893 TBool isUidGiven(EFalse); |
|
894 (void)GetBoolFromConfig(ConfigSection(), _L("UidGiven"), isUidGiven); // if not specified, the UidGiven is false. |
|
895 |
|
896 if(!isUidGiven) |
|
897 iSisRegistry.InstalledUidsL(uids); |
|
898 else |
|
899 GetUidArrayFromConfigL(ConfigSection(), KUid, uids); |
|
900 |
|
901 SetTestStepResult(EPass); |
|
902 |
|
903 //StartTimer again to ignore time taken to read from config file |
|
904 StartTimer(); |
|
905 |
|
906 for(TInt index = 0; index < uids.Count(); index++) |
|
907 { |
|
908 Swi::RSisRegistryEntry entry; |
|
909 CleanupClosePushL(entry); |
|
910 TInt result = entry.Open(iSisRegistry, uids[index]); |
|
911 if (result == KErrNone) |
|
912 { |
|
913 INFO_PRINTF2(_L("Uid: 0x%08x was opened successfully!"), uids[index]); |
|
914 entry.Close(); |
|
915 INFO_PRINTF2(_L("Uid: 0x%08x was closed successfully!"), uids[index]); |
|
916 } |
|
917 else |
|
918 { |
|
919 SetTestStepResult(EFail); |
|
920 ERR_PRINTF3(_L("Uid: 0x%08x not opened, error %d!"), uids[index], result); |
|
921 } |
|
922 CleanupStack::PopAndDestroy(&entry); |
|
923 } |
|
924 |
|
925 CleanupStack::PopAndDestroy(&uids); |
|
926 |
|
927 return TestStepResult(); |
|
928 } |
|
929 |
|
930 ///////////////////////////////////////////////////////////////////// |
|
931 // CEntryPackageOpenCloseStep |
|
932 ///////////////////////////////////////////////////////////////////// |
|
933 CEntryPackageOpenCloseStep::CEntryPackageOpenCloseStep() |
|
934 { |
|
935 SetTestStepName(KEntryPackageOpenClose); |
|
936 } |
|
937 |
|
938 TVerdict CEntryPackageOpenCloseStep::doTestStepL() |
|
939 { |
|
940 RPointerArray<CSisRegistryPackage> packages; |
|
941 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
942 |
|
943 iSisRegistry.InstalledPackagesL(packages); |
|
944 |
|
945 SetTestStepResult(EPass); |
|
946 |
|
947 //StartTimer again to ignore time taken to read from config file |
|
948 StartTimer(); |
|
949 |
|
950 for(TInt index = 0; index < packages.Count(); index++) |
|
951 { |
|
952 TPtrC package = packages[index]->Name(); |
|
953 TPtrC vendor = packages[index]->Vendor(); |
|
954 |
|
955 Swi::RSisRegistryEntry entry; |
|
956 |
|
957 TInt result = entry.OpenL(iSisRegistry, *packages[index]); |
|
958 if (result == KErrNone) |
|
959 { |
|
960 CleanupClosePushL(entry); |
|
961 INFO_PRINTF3(_L("Package %S by Vendor %S was opened successfully!"), &package, &vendor); |
|
962 CleanupStack::PopAndDestroy(&entry); |
|
963 INFO_PRINTF3(_L("Package %S by Vendor %S was closed successfully!"), &package, &vendor); |
|
964 } |
|
965 else |
|
966 { |
|
967 SetTestStepResult(EFail); |
|
968 ERR_PRINTF4(_L("Package %S by Vendor %S not opened, error %d!"), &package, &vendor, result); |
|
969 } |
|
970 } |
|
971 |
|
972 CleanupStack::PopAndDestroy(&packages); |
|
973 |
|
974 return TestStepResult(); |
|
975 } |
|
976 |
|
977 ///////////////////////////////////////////////////////////////////// |
|
978 // CEntryNameOpenCloseStep |
|
979 ///////////////////////////////////////////////////////////////////// |
|
980 CEntryNameOpenCloseStep::CEntryNameOpenCloseStep() |
|
981 { |
|
982 SetTestStepName(KEntryNameOpenClose); |
|
983 } |
|
984 |
|
985 TVerdict CEntryNameOpenCloseStep::doTestStepL() |
|
986 { |
|
987 RPointerArray<CSisRegistryPackage> packages; |
|
988 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
989 |
|
990 iSisRegistry.InstalledPackagesL(packages); |
|
991 |
|
992 SetTestStepResult(EPass); |
|
993 for(TInt index = 0; index < packages.Count(); index++) |
|
994 { |
|
995 TPtrC package = packages[index]->Name(); |
|
996 TPtrC vendor = packages[index]->Vendor(); |
|
997 |
|
998 Swi::RSisRegistryEntry entry; |
|
999 |
|
1000 TInt result = entry.Open(iSisRegistry, package, vendor); |
|
1001 if (result == KErrNone) |
|
1002 { |
|
1003 CleanupClosePushL(entry); |
|
1004 INFO_PRINTF3(_L("Package %S by Vendor %S was opened successfully!"), &package, &vendor); |
|
1005 CleanupStack::PopAndDestroy(&entry); |
|
1006 INFO_PRINTF3(_L("Package %S by Vendor %S was closed successfully!"), &package, &vendor); |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 SetTestStepResult(EFail); |
|
1011 ERR_PRINTF4(_L("Package %S by Vendor %S not opened, error %d!"), &package, &vendor, result); |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 CleanupStack::PopAndDestroy(&packages); |
|
1016 |
|
1017 return TestStepResult(); |
|
1018 } |
|
1019 |
|
1020 ///////////////////////////////////////////////////////////////////// |
|
1021 // CEntryMethodsTestStep - tests specific to entry methods |
|
1022 ///////////////////////////////////////////////////////////////////// |
|
1023 CEntryMethodsStep::CEntryMethodsStep() |
|
1024 { |
|
1025 SetTestStepName(KEntryMethods); |
|
1026 } |
|
1027 |
|
1028 TVerdict CEntryMethodsStep::doTestStepL() |
|
1029 { |
|
1030 RPointerArray<CSisRegistryPackage> packages; |
|
1031 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
1032 |
|
1033 iSisRegistry.InstalledPackagesL(packages); |
|
1034 |
|
1035 SetTestStepResult(EPass); |
|
1036 for(TInt index = 0; index < packages.Count(); index++) |
|
1037 { |
|
1038 TPtrC package = packages[index]->Name(); |
|
1039 TPtrC vendor = packages[index]->Vendor(); |
|
1040 |
|
1041 Swi::RSisRegistryEntry entry; |
|
1042 |
|
1043 INFO_PRINTF3(_L("Opening Package %S by Vendor %S..."), &package, &vendor); |
|
1044 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[index])); |
|
1045 CleanupClosePushL(entry); |
|
1046 // get the version |
|
1047 TVersion packageVersion = entry.VersionL(); |
|
1048 INFO_PRINTF4(_L("Version %d %d %d"), packageVersion.iMajor, packageVersion.iMinor, packageVersion.iBuild ); |
|
1049 |
|
1050 // get sids |
|
1051 RArray<TUid> sids; |
|
1052 CleanupClosePushL(sids); |
|
1053 entry.SidsL(sids); |
|
1054 if (sids.Count() <= 0) |
|
1055 { |
|
1056 INFO_PRINTF1(_L("No sids installed!")); |
|
1057 } |
|
1058 else |
|
1059 { |
|
1060 for (TInt sid = 0; sid < sids.Count(); sid++) |
|
1061 { |
|
1062 INFO_PRINTF2(_L("Sid: 0x%08x was found!"), sids[sid]); |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 CleanupStack::PopAndDestroy(&sids); |
|
1067 |
|
1068 // get the vendor; package name |
|
1069 HBufC* reportedVendor = entry.UniqueVendorNameL(); |
|
1070 CleanupStack::PushL(reportedVendor); |
|
1071 HBufC* reportedPackage = entry.PackageNameL(); |
|
1072 CleanupStack::PushL(reportedPackage); |
|
1073 |
|
1074 INFO_PRINTF3(_L("Package: %S from Vendor: %S"), reportedPackage, reportedVendor); |
|
1075 |
|
1076 CleanupStack::PopAndDestroy(reportedPackage); |
|
1077 CleanupStack::PopAndDestroy(reportedVendor); |
|
1078 |
|
1079 // get the localised vendor name |
|
1080 HBufC* vendorLocal = entry.LocalizedVendorNameL(); |
|
1081 CleanupStack::PushL(vendorLocal); |
|
1082 INFO_PRINTF2(_L("Localised Vendor Name: %S"), vendorLocal); |
|
1083 |
|
1084 CleanupStack::PopAndDestroy(vendorLocal); |
|
1085 |
|
1086 // get uid |
|
1087 TUid uid = entry.UidL(); |
|
1088 INFO_PRINTF3(_L("Package Uid: %d 0x%08x"), uid.iUid, uid.iUid); |
|
1089 |
|
1090 // get language |
|
1091 TLanguage language = entry.LanguageL(); |
|
1092 INFO_PRINTF3(_L("Package Language: %d 0x%08x"), language, language); |
|
1093 |
|
1094 // get property |
|
1095 TInt32 propertyKey = 10; |
|
1096 TInt32 propertyValue = entry.PropertyL(propertyKey); |
|
1097 INFO_PRINTF3(_L("Package property: key %d value %d"), propertyKey, propertyValue); |
|
1098 |
|
1099 // is present - currenty relies on default value |
|
1100 TBool isPresent = entry.IsPresentL(); |
|
1101 INFO_PRINTF2(_L("Package present is %d"), isPresent); |
|
1102 |
|
1103 // is signed |
|
1104 TBool isSigned = entry.IsSignedL(); |
|
1105 INFO_PRINTF2(_L("Package signed is %d"), isSigned); |
|
1106 |
|
1107 |
|
1108 // check Trust |
|
1109 switch(entry.TrustL()) |
|
1110 { |
|
1111 case ESisPackageUnsignedOrSelfSigned: |
|
1112 INFO_PRINTF1(_L("Packaged Trust: Unsigned or self signed")); |
|
1113 break; |
|
1114 case ESisPackageCertificateChainNoTrustAnchor: |
|
1115 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain has no trust anchor in Cert store")); |
|
1116 break; |
|
1117 case ESisPackageCertificateChainValidatedToTrustAnchor: |
|
1118 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated to Trust Anchor in Cert store")); |
|
1119 break; |
|
1120 case ESisPackageChainValidatedToTrustAnchorOCSPTransientError: |
|
1121 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Transient Error")); |
|
1122 break; |
|
1123 case ESisPackageChainValidatedToTrustAnchorAndOCSPValid: |
|
1124 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Valid")); |
|
1125 break; |
|
1126 case ESisPackageBuiltIntoRom: |
|
1127 INFO_PRINTF1(_L("Packaged Trust: Built into ROM")); |
|
1128 break; |
|
1129 case ESisPackageValidationFailed: |
|
1130 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validation Failed")); |
|
1131 break; |
|
1132 default: |
|
1133 INFO_PRINTF1(_L("Packaged Trust: Unknown")); |
|
1134 break; |
|
1135 }; |
|
1136 |
|
1137 // Time at which the trust was established |
|
1138 TTime timeStamp = entry.TrustTimeStampL(); |
|
1139 TBuf <32> dateTimeText; |
|
1140 TRAP_IGNORE(timeStamp.FormatL(dateTimeText, _L("%H%:1%T%:2%S on %1%/1%2%/2%3"))); |
|
1141 INFO_PRINTF2(_L("Package Trust Established: %S"), &dateTimeText); |
|
1142 |
|
1143 // is in rom |
|
1144 TBool inRom = entry.IsInRomL(); |
|
1145 INFO_PRINTF2(_L("Package inRom is %d"), inRom); |
|
1146 |
|
1147 // is an augmentation |
|
1148 TBool isAug = entry.IsAugmentationL(); |
|
1149 INFO_PRINTF2(_L("Package isAug is %d"), isAug); |
|
1150 |
|
1151 // installation size |
|
1152 TInt64 size = entry.SizeL(); |
|
1153 INFO_PRINTF3(_L("Package size is %d %d"), I64HIGH(size), I64LOW(size)); |
|
1154 |
|
1155 // get list of files |
|
1156 RPointerArray<HBufC> files; |
|
1157 CleanupResetAndDestroy<RPointerArray<HBufC> >::PushL(files); |
|
1158 entry.FilesL(files); |
|
1159 INFO_PRINTF2(_L("Package has %d files"), files.Count()); |
|
1160 for (TInt file = 0; file < files.Count(); file++) |
|
1161 { |
|
1162 // INFO_PRINTF3(_L("File %d file path %S"),file + 1, files[file]); |
|
1163 } |
|
1164 CleanupStack::PopAndDestroy(&files); |
|
1165 |
|
1166 CleanupStack::PopAndDestroy(&entry); |
|
1167 } |
|
1168 |
|
1169 CleanupStack::PopAndDestroy(&packages); |
|
1170 |
|
1171 return TestStepResult(); |
|
1172 } |
|
1173 |
|
1174 |
|
1175 ///////////////////////////////////////////////////////////////////// |
|
1176 // CEntrySidsStep - obtain a list of Sids from an entry |
|
1177 ///////////////////////////////////////////////////////////////////// |
|
1178 CEntrySidsStep::CEntrySidsStep() |
|
1179 { |
|
1180 SetTestStepName(KEntrySids); |
|
1181 } |
|
1182 |
|
1183 TVerdict CEntrySidsStep::doTestStepL() |
|
1184 { |
|
1185 SetTestStepResult(EFail); |
|
1186 |
|
1187 RArray<TUid> expectedSids; |
|
1188 GetUidArrayFromConfigL(ConfigSection(), KSid, expectedSids); |
|
1189 CleanupClosePushL(expectedSids); |
|
1190 |
|
1191 Swi::RSisRegistryEntry entry; |
|
1192 |
|
1193 TPtrC package; |
|
1194 TPtrC vendor; |
|
1195 if(GetStringFromConfig(ConfigSection(), KPackage, package) |
|
1196 && GetStringFromConfig(ConfigSection(), KVendor, vendor)) |
|
1197 { |
|
1198 //StartTimer again to ignore time taken to read from config file |
|
1199 StartTimer(); |
|
1200 User::LeaveIfError(entry.Open(iSisRegistry, package, vendor)); |
|
1201 } |
|
1202 else |
|
1203 { |
|
1204 TUid packageUid; |
|
1205 if(!GetUidFromConfig(ConfigSection(), KUid, packageUid)) |
|
1206 { |
|
1207 ERR_PRINTF1(_L("Neither package-vendor name nor UID found!")); |
|
1208 User::Leave(KErrNotFound); |
|
1209 } |
|
1210 //StartTimer again to ignore time taken to read from config file |
|
1211 StartTimer(); |
|
1212 User::LeaveIfError(entry.Open(iSisRegistry, packageUid)); |
|
1213 } |
|
1214 CleanupClosePushL(entry); |
|
1215 |
|
1216 RArray<TUid> sids; |
|
1217 entry.SidsL(sids); |
|
1218 CleanupClosePushL(sids); |
|
1219 |
|
1220 if (sids.Count() != expectedSids.Count()) |
|
1221 { |
|
1222 ERR_PRINTF3(_L("Actual Sids = %d, Expected Sids = %d"), sids.Count(), expectedSids.Count()); |
|
1223 } |
|
1224 else |
|
1225 { |
|
1226 SetTestStepResult(EPass); |
|
1227 for (TInt index=0; index < expectedSids.Count(); index++) |
|
1228 { |
|
1229 if(sids.Find(expectedSids[index]) != KErrNotFound) |
|
1230 { |
|
1231 INFO_PRINTF2(_L("Sid: 0x%08x was found!"), expectedSids[index]); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 SetTestStepResult(EFail); |
|
1236 ERR_PRINTF2(_L("Sid: 0x%08x not found!"), expectedSids[index]); |
|
1237 } |
|
1238 } |
|
1239 } |
|
1240 |
|
1241 CleanupStack::PopAndDestroy(3, &expectedSids); // expectedSids, entry, sids |
|
1242 return TestStepResult(); |
|
1243 } |
|
1244 |
|
1245 ///////////////////////////////////////////////////////////////////// |
|
1246 // CIsSidPresentStep - test package SIDs are reported as present. |
|
1247 ///////////////////////////////////////////////////////////////////// |
|
1248 |
|
1249 CIsSidPresentStep::CIsSidPresentStep() |
|
1250 { |
|
1251 SetTestStepName(KIsSidPresentStep); |
|
1252 } |
|
1253 |
|
1254 TVerdict CIsSidPresentStep::doTestStepL() |
|
1255 { |
|
1256 // iterate through every sid which is installed in a package |
|
1257 RPointerArray<CSisRegistryPackage> packages; |
|
1258 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
1259 |
|
1260 iSisRegistry.InstalledPackagesL(packages); |
|
1261 |
|
1262 TInt32 minSid = KMaxTInt32; |
|
1263 TInt32 maxSid = KMinTInt32; |
|
1264 |
|
1265 for (TInt i = packages.Count() - 1; i >= 0; --i) |
|
1266 { |
|
1267 const CSisRegistryPackage& pkg = *packages[i]; |
|
1268 |
|
1269 Swi::RSisRegistryEntry e; |
|
1270 TInt r = e.Open(iSisRegistry, pkg.Uid()); |
|
1271 User::LeaveIfError(r); |
|
1272 CleanupClosePushL(e); |
|
1273 |
|
1274 RArray<TUid> sids; |
|
1275 e.SidsL(sids); |
|
1276 CleanupClosePushL(sids); |
|
1277 |
|
1278 for (TInt j = sids.Count() - 1; j >= 0; --j) |
|
1279 { |
|
1280 TUid sid = sids[j]; |
|
1281 minSid = Min(minSid, sid.iUid); |
|
1282 maxSid = Max(maxSid, sid.iUid); |
|
1283 |
|
1284 TBool sidPresent = iSisRegistry.IsSidPresentL(sid); |
|
1285 TESTL(sidPresent); |
|
1286 } |
|
1287 |
|
1288 CleanupStack::PopAndDestroy(2, &e); |
|
1289 } |
|
1290 |
|
1291 TUid minSidM1(TUid::Uid(minSid - 1)); |
|
1292 TESTL(! iSisRegistry.IsSidPresentL(minSidM1)); |
|
1293 TUid maxSidP1(TUid::Uid(minSid + 1)); |
|
1294 TESTL(! iSisRegistry.IsSidPresentL(maxSidP1)); |
|
1295 |
|
1296 CleanupStack::PopAndDestroy(&packages); |
|
1297 |
|
1298 SetTestStepResult(EPass); |
|
1299 return TestStepResult(); |
|
1300 } |
|
1301 |
|
1302 ///////////////////////////////////////////////////////////////////// |
|
1303 // CIsPackagePresentStep - Test the IsPresent method |
|
1304 ///////////////////////////////////////////////////////////////////// |
|
1305 |
|
1306 CIsPackagePresentStep::CIsPackagePresentStep() |
|
1307 { |
|
1308 SetTestStepName(KIsPackagePresentStep); |
|
1309 } |
|
1310 |
|
1311 TVerdict CIsPackagePresentStep::doTestStepL() |
|
1312 { |
|
1313 SetTestStepResult(EPass); |
|
1314 |
|
1315 RArray<TUid> pUids; |
|
1316 CleanupClosePushL(pUids); |
|
1317 GetUidArrayFromConfigL(ConfigSection(), KUid, pUids); |
|
1318 |
|
1319 //StartTimer again to ignore time taken to read from config file |
|
1320 StartTimer(); |
|
1321 |
|
1322 // Create a session with the SCR |
|
1323 Usif::RSoftwareComponentRegistry scrSession; |
|
1324 User::LeaveIfError(scrSession.Connect()); |
|
1325 CleanupClosePushL(scrSession); |
|
1326 |
|
1327 TInt count(pUids.Count()); |
|
1328 for (TInt i = 0; i < count; ++i) |
|
1329 { |
|
1330 // query the registry to see if this entry is present |
|
1331 RSisRegistryEntry entry; |
|
1332 //Since the SisRegistry is inconsistent from hardware and emulator, we won't check |
|
1333 //whether a package is presented on device if it's not installed at all thus no registry entry (e.g. MIDP) |
|
1334 #ifdef __WINS__ |
|
1335 User::LeaveIfError(entry.Open(iSisRegistry, pUids[i])); |
|
1336 #else |
|
1337 TInt err = entry.Open(iSisRegistry, pUids[i]); |
|
1338 if(KErrNotFound == err) |
|
1339 { |
|
1340 INFO_PRINTF2(_L("Package with UID 0x%08x is not installed on HW. IsPresent test skipped"), |
|
1341 pUids[i]); |
|
1342 continue; |
|
1343 } |
|
1344 User::LeaveIfError(err); |
|
1345 #endif |
|
1346 CleanupClosePushL(entry); |
|
1347 |
|
1348 if (!entry.IsPresentL()) |
|
1349 { |
|
1350 INFO_PRINTF2(_L("Package with UID 0x%08x is marked as not present!"), |
|
1351 pUids[i]); |
|
1352 SetTestStepResult(EFail); |
|
1353 CleanupStack::PopAndDestroy(&entry); |
|
1354 // Since package is not present in SWI Registry, we are not checking again in SCR |
|
1355 continue; |
|
1356 } |
|
1357 |
|
1358 // Convert the Uid to ComponentId |
|
1359 Usif::TComponentId componentId = iSisRegistry.GetComponentIdForUidL(pUids[i]); |
|
1360 |
|
1361 // Check if the component is present in SCR |
|
1362 if (!scrSession.IsComponentPresentL(componentId)) |
|
1363 { |
|
1364 INFO_PRINTF2(_L("Package with UID 0x%08x is present in SWI Registry, but not in SCR"), pUids[i]); |
|
1365 SetTestStepResult(EFail); |
|
1366 } |
|
1367 |
|
1368 CleanupStack::PopAndDestroy(&entry); |
|
1369 } |
|
1370 CleanupStack::PopAndDestroy(2, &pUids); // scrSession, pUids |
|
1371 return TestStepResult(); |
|
1372 } |
|
1373 CIntegrityCheckStep::CIntegrityCheckStep() |
|
1374 { |
|
1375 SetTestStepName(KIntegrityCheckStep); |
|
1376 } |
|
1377 CIntegrityCheckStep::~CIntegrityCheckStep() |
|
1378 { |
|
1379 } |
|
1380 |
|
1381 TVerdict CIntegrityCheckStep::doTestStepL() |
|
1382 { |
|
1383 TInt result=0; |
|
1384 |
|
1385 CleanupResetAndDestroy<RPointerArray<CX509Certificate> >::PushL(iCertArray); |
|
1386 |
|
1387 InitializeL(); |
|
1388 TUid pUid; |
|
1389 GetUidFromConfig(ConfigSection(), KUid, pUid); |
|
1390 GetIntFromConfig(ConfigSection(),KResultTag,result); |
|
1391 |
|
1392 RSisRegistryEntry entry; |
|
1393 |
|
1394 SetTestStepResult(EFail); |
|
1395 |
|
1396 //StartTimer again to ignore time taken to read from config file |
|
1397 StartTimer(); |
|
1398 |
|
1399 // query the registry to see if this entry is present |
|
1400 User::LeaveIfError (entry.Open(iSisRegistry, pUid)); |
|
1401 |
|
1402 //Call the controller |
|
1403 TBool check = entry.VerifyControllerSignatureL(iCertArray); |
|
1404 |
|
1405 if(check!=result) |
|
1406 { |
|
1407 ERR_PRINTF3(_L("ERROR: Received result: %d. Expected Result: %d"), check, result); |
|
1408 SetTestStepResult(EFail); |
|
1409 } |
|
1410 else |
|
1411 { |
|
1412 SetTestStepResult(EPass); |
|
1413 } |
|
1414 entry.Close(); |
|
1415 CleanupStack::PopAndDestroy(&iCertArray); |
|
1416 return TestStepResult(); |
|
1417 } |
|
1418 |
|
1419 void CIntegrityCheckStep::InitializeL() |
|
1420 { |
|
1421 CX509Certificate* cert = NULL; |
|
1422 RArray<TPtrC> rootCertificates; |
|
1423 CleanupClosePushL(rootCertificates); |
|
1424 GetStringArrayFromConfigL(ConfigSection(), KRootCertTag, rootCertificates); |
|
1425 |
|
1426 User::LeaveIfError (fs.Connect()); |
|
1427 //opens the data file |
|
1428 CleanupClosePushL(fs); |
|
1429 |
|
1430 //Loop through all the X509 root certificates and load them |
|
1431 for (TInt i=0; i<rootCertificates.Count(); i++) |
|
1432 { |
|
1433 HBufC8* rawData = ReadFileLC(rootCertificates[i]); |
|
1434 cert = CX509Certificate::NewL(*rawData); |
|
1435 CleanupStack::PopAndDestroy(rawData); |
|
1436 CleanupStack::PushL(cert); |
|
1437 iCertArray.AppendL(cert); |
|
1438 CleanupStack::Pop(); |
|
1439 } |
|
1440 |
|
1441 //closes the file session |
|
1442 CleanupStack::PopAndDestroy(&fs); |
|
1443 CleanupStack::PopAndDestroy(&rootCertificates); |
|
1444 } |
|
1445 |
|
1446 HBufC8* CIntegrityCheckStep::ReadFileLC(const TDesC& aDatapath) |
|
1447 { |
|
1448 RFile file; |
|
1449 User::LeaveIfError(file.Open(fs, aDatapath, EFileRead)) ; |
|
1450 |
|
1451 TInt fileSize = 0; |
|
1452 User::LeaveIfError(file.Size(fileSize)); |
|
1453 |
|
1454 HBufC8* rawData = HBufC8::NewLC(fileSize); |
|
1455 TPtr8 rawDataPtr(rawData->Des()); |
|
1456 rawDataPtr.SetLength(fileSize); |
|
1457 file.Read (rawDataPtr); |
|
1458 |
|
1459 file.Close(); |
|
1460 |
|
1461 return rawData; |
|
1462 } |
|
1463 |
|
1464 ///////////////////////////////////////////////////////////////////// |
|
1465 // CIntegrityDateAndTimeCheckStep - |
|
1466 ///////////////////////////////////////////////////////////////////// |
|
1467 |
|
1468 |
|
1469 CIntegrityDateAndTimeCheckStep::CIntegrityDateAndTimeCheckStep() |
|
1470 { |
|
1471 SetTestStepName(KDateAndTimeIntegrityCheckStep); |
|
1472 } |
|
1473 |
|
1474 |
|
1475 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepPreambleL() |
|
1476 { |
|
1477 CIntegrityCheckStep::doTestStepPreambleL(); |
|
1478 |
|
1479 GetUidFromConfig(ConfigSection(), KUid, iPackageUid); |
|
1480 GetIntFromConfig(ConfigSection(),KResultTag,iExpectedResult); |
|
1481 |
|
1482 TPtrC dateAndTime; |
|
1483 GetStringFromConfig(ConfigSection(), KDateTime, dateAndTime); |
|
1484 iTime = TTime(dateAndTime); |
|
1485 |
|
1486 iOriginalTime.UniversalTime(); |
|
1487 User::SetUTCTime(iTime); |
|
1488 |
|
1489 return EPass; |
|
1490 } |
|
1491 |
|
1492 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepPostambleL() |
|
1493 { |
|
1494 TTime timeNow; |
|
1495 timeNow.UniversalTime(); |
|
1496 |
|
1497 TTimeIntervalMicroSeconds timeInterval = timeNow.MicroSecondsFrom(iTime); |
|
1498 timeNow = iOriginalTime + timeInterval; |
|
1499 |
|
1500 User::SetUTCTime(timeNow); |
|
1501 |
|
1502 return TestStepResult(); |
|
1503 } |
|
1504 |
|
1505 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepL() |
|
1506 { |
|
1507 CleanupResetAndDestroy<RPointerArray<CX509Certificate> >::PushL(iCertArray); |
|
1508 |
|
1509 InitializeL(); |
|
1510 |
|
1511 RSisRegistryEntry entry; |
|
1512 |
|
1513 SetTestStepResult(EPass); |
|
1514 |
|
1515 //StartTimer again to ignore time taken to read from config file |
|
1516 StartTimer(); |
|
1517 |
|
1518 // query the registry to see if this entry is present |
|
1519 User::LeaveIfError(entry.Open(iSisRegistry, iPackageUid)); |
|
1520 CleanupClosePushL(entry); |
|
1521 |
|
1522 //Call the controller |
|
1523 TBool check = EFalse; |
|
1524 |
|
1525 check = entry.VerifyControllerSignatureL(iCertArray, ETrue); |
|
1526 if(check!=iExpectedResult) |
|
1527 { |
|
1528 ERR_PRINTF3(_L("ERROR: First call to verify failed. Result: %d. Expected Result: %d"), check, iExpectedResult); |
|
1529 SetTestStepResult(EFail); |
|
1530 } |
|
1531 |
|
1532 check = entry.VerifyControllerSignatureL(iCertArray, EFalse); |
|
1533 if(check==EFalse) |
|
1534 { |
|
1535 ERR_PRINTF2(_L("ERROR: Second call to verify failed. Result: %d. Expected Result: ETrue"), check); |
|
1536 SetTestStepResult(EFail); |
|
1537 } |
|
1538 |
|
1539 check = entry.VerifyControllerSignatureL(iCertArray, ETrue); |
|
1540 if(check!=iExpectedResult) |
|
1541 { |
|
1542 ERR_PRINTF3(_L("ERROR: Third call to verify failed. Result: %d. Expected Result: %d"), check, iExpectedResult); |
|
1543 SetTestStepResult(EFail); |
|
1544 } |
|
1545 |
|
1546 CleanupStack::PopAndDestroy(2, &iCertArray); |
|
1547 |
|
1548 return TestStepResult(); |
|
1549 } |
|
1550 |
|
1551 |
|
1552 ///////////////////////////////////////////////////////////////////// |
|
1553 // CLoggingFileInfoStep - |
|
1554 ///////////////////////////////////////////////////////////////////// |
|
1555 |
|
1556 CLoggingFileInfoStep::CLoggingFileInfoStep() |
|
1557 { |
|
1558 SetTestStepName(KLoggingFileInfo); |
|
1559 } |
|
1560 |
|
1561 TVerdict CLoggingFileInfoStep::doTestStepL() |
|
1562 { |
|
1563 SetTestStepResult(EPass); |
|
1564 __UHEAP_MARK; |
|
1565 RPointerArray<CLogEntry> fileInfo; |
|
1566 CleanupResetAndDestroy<RPointerArray<CLogEntry> >::PushL(fileInfo); |
|
1567 iSisRegistry.RetrieveLogFileL(fileInfo); |
|
1568 |
|
1569 if (fileInfo.Count()>0) |
|
1570 { |
|
1571 for (TInt i = 0; i < 5; i++) |
|
1572 { |
|
1573 TInt var = 1; |
|
1574 TBuf<16> entry; |
|
1575 entry.Format(_L("LOGENTRY%d.%d"),i,var); |
|
1576 TPtrC text0; |
|
1577 GetStringFromConfig(ConfigSection(), entry, text0); |
|
1578 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1579 TPtrC text1; |
|
1580 GetStringFromConfig(ConfigSection(), entry, text1); |
|
1581 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1582 TPtrC text2; |
|
1583 GetStringFromConfig(ConfigSection(), entry, text2); |
|
1584 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1585 TPtrC text3; |
|
1586 GetStringFromConfig(ConfigSection(), entry, text3); |
|
1587 |
|
1588 TBuf<16> pkgName = fileInfo[0]->GetPkgName(); |
|
1589 TBuf<20> versiontext; |
|
1590 versiontext.Format(_L("%d.%d.%d"),fileInfo[i]->GetMajorVersion(),fileInfo[i]->GetMinorVersion(),fileInfo[i]->GetBuildVersion()); |
|
1591 |
|
1592 enum Swi::TSwiLogTypes s = fileInfo[i]->GetInstallType(); |
|
1593 TBuf<16> installType ; |
|
1594 switch (s) |
|
1595 { |
|
1596 case 0: // Swi::TSwiLogTypes::ESwiLogInstall : |
|
1597 installType.Format(_L("Install")); |
|
1598 break; |
|
1599 case 1: |
|
1600 installType.Format(_L("UnInstall")); |
|
1601 |
|
1602 break; |
|
1603 case 2: // Swi::TSwiLogTypes::ESwiLogUpgrade : |
|
1604 installType.Format(_L("Upgrade")); |
|
1605 |
|
1606 break; |
|
1607 default: |
|
1608 installType.Format(_L("Error unknown value")); |
|
1609 |
|
1610 break; |
|
1611 } |
|
1612 |
|
1613 TBuf<16> uidOfPkg; |
|
1614 uidOfPkg.Format(_L("%x"),fileInfo[i]->GetUid()); |
|
1615 |
|
1616 if(pkgName == text0 && versiontext == text1 |
|
1617 && installType ==text2 && uidOfPkg ==text3) |
|
1618 { |
|
1619 SetTestStepResult(EPass); |
|
1620 } |
|
1621 else |
|
1622 { |
|
1623 SetTestStepResult(EFail); |
|
1624 } |
|
1625 } |
|
1626 } |
|
1627 else |
|
1628 { |
|
1629 SetTestStepResult(EPass); |
|
1630 } |
|
1631 CleanupStack::PopAndDestroy(&fileInfo); |
|
1632 __UHEAP_MARKEND; |
|
1633 return TestStepResult(); |
|
1634 } |
|
1635 |
|
1636 CRomStubPerformanceStep::CRomStubPerformanceStep() |
|
1637 { |
|
1638 SetTestStepName(KRomStubPerformanceStep); |
|
1639 } |
|
1640 |
|
1641 TVerdict CRomStubPerformanceStep::doTestStepL() |
|
1642 { |
|
1643 // Simple test step to determine how long it takes to |
|
1644 // regenerate the cache. |
|
1645 |
|
1646 // Make sure the sisregistry is deleted before regenerating the cache. This |
|
1647 // will ensure that the registry entries are created from the ROM stub, instead |
|
1648 // of being read from the harddisk |
|
1649 RTestUtilSessionSwi util; |
|
1650 User::LeaveIfError(util.Connect()); |
|
1651 CleanupClosePushL(util); |
|
1652 |
|
1653 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1654 TBuf<128> sisRegistryPath (sysDrive.Name()); |
|
1655 sisRegistryPath.Append(KSisRegistryPath); |
|
1656 |
|
1657 TInt err = util.RmDir(sisRegistryPath); |
|
1658 if(err != KErrNone && err != KErrPathNotFound && err != KErrNotFound) |
|
1659 { |
|
1660 User::Leave(err); |
|
1661 } |
|
1662 else |
|
1663 { |
|
1664 INFO_PRINTF1(_L("Sis Registry Deleted!")); |
|
1665 } |
|
1666 |
|
1667 INFO_PRINTF1(_L("Regenerate the cache. Starting the timer...")); |
|
1668 TTime startTime; |
|
1669 startTime.UniversalTime(); |
|
1670 |
|
1671 // Stop the timer |
|
1672 TTime endTime; |
|
1673 endTime.UniversalTime(); |
|
1674 INFO_PRINTF1(_L("Cache regenerated. Timer stopped.")); |
|
1675 |
|
1676 TInt64 durationMicro=endTime.MicroSecondsFrom(startTime).Int64(); |
|
1677 TInt durationMilli=durationMicro/1000; |
|
1678 |
|
1679 INFO_PRINTF2(_L("Duration (milliseconds): %d"),durationMilli); |
|
1680 CleanupStack::PopAndDestroy(&util); |
|
1681 |
|
1682 SetTestStepResult(EPass); |
|
1683 |
|
1684 return TestStepResult(); |
|
1685 } |
|
1686 |
|
1687 ////////////////////////////////////////////////////////////// |
|
1688 // CCorruptCacheStep - The Sis Registry will leave backup.bak |
|
1689 // around when it encounters a corrupt cache file |
|
1690 ////////////////////////////////////////////////////////////// |
|
1691 |
|
1692 CCorruptCacheStep::CCorruptCacheStep() |
|
1693 { |
|
1694 SetTestStepName(KCorruptCacheStep); |
|
1695 } |
|
1696 |
|
1697 TVerdict CCorruptCacheStep::doTestStepL() |
|
1698 { |
|
1699 SetTestStepResult(EFail); |
|
1700 |
|
1701 __UHEAP_MARK; |
|
1702 |
|
1703 RTestUtilSessionSwi util; |
|
1704 User::LeaveIfError(util.Connect()); |
|
1705 CleanupClosePushL(util); |
|
1706 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1707 TDriveName sysDriveName (sysDrive.Name()); |
|
1708 |
|
1709 // Close the Sis Registry and wait for 3 secs for |
|
1710 // server to shut down |
|
1711 iSisRegistry.Close(); |
|
1712 |
|
1713 INFO_PRINTF1(_L("Sis Registry shut down")); |
|
1714 User::After(3000000); |
|
1715 |
|
1716 // Delete the "good" backup.lst (if present) |
|
1717 TInt err = util.Delete(KCacheBackupFile); |
|
1718 |
|
1719 if (err == KErrNone) |
|
1720 { |
|
1721 INFO_PRINTF2(_L("Deleted '%S'"), &KCacheBackupFile); |
|
1722 } |
|
1723 |
|
1724 // Use hashforlang_txt.dat as a corrupt backup.lst and connect to the |
|
1725 // Sis Registry. |
|
1726 util.Copy(KCorruptCacheBackupFile, KCacheBackupFile); |
|
1727 |
|
1728 INFO_PRINTF3(_L("Copied '%S' to '%S'"), &KCorruptCacheBackupFile, &KCacheBackupFile); |
|
1729 |
|
1730 INFO_PRINTF1(_L("Connecting to SisRegistry...")); |
|
1731 |
|
1732 RProcess sisRegistryServer; |
|
1733 TInt retVal = sisRegistryServer.Create(_L("SisRegistryServer"),KNullDesC); |
|
1734 |
|
1735 if (retVal == KErrNone) |
|
1736 { |
|
1737 TRequestStatus status; |
|
1738 sisRegistryServer.Logon(status); |
|
1739 sisRegistryServer.Resume(); |
|
1740 User::WaitForRequest(status); |
|
1741 |
|
1742 TExitCategoryName panicName = sisRegistryServer.ExitCategory(); |
|
1743 TPtrC name(panicName); |
|
1744 TInt reasonNumber = sisRegistryServer.ExitReason(); |
|
1745 |
|
1746 if (reasonNumber == 0 && name.Compare(_L("Kill")) == KErrNone) |
|
1747 { |
|
1748 if (util.FileExistsL(KSysBackupFileBackup)) |
|
1749 { |
|
1750 if (util.FileExistsL(KCacheBackupFile)) |
|
1751 { |
|
1752 INFO_PRINTF4(_L("'%S' and '%S' exist in System Drive: %S\\"), |
|
1753 &KSysBackupFileBackup, &KCacheBackupFile, &sysDriveName); |
|
1754 SetTestStepResult(EPass); |
|
1755 } |
|
1756 else |
|
1757 { |
|
1758 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1759 &KCacheBackupFile, &sysDriveName); |
|
1760 } |
|
1761 } |
|
1762 else |
|
1763 { |
|
1764 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1765 &KSysBackupFileBackup, &sysDriveName); |
|
1766 } |
|
1767 } |
|
1768 |
|
1769 INFO_PRINTF3(_L("CCorruptCacheStep - Exit Reason Number: %d Exit Reason Code: %S"), |
|
1770 reasonNumber, &name); |
|
1771 } |
|
1772 |
|
1773 sisRegistryServer.Terminate(0); |
|
1774 sisRegistryServer.Close(); |
|
1775 |
|
1776 CleanupStack::PopAndDestroy(&util); |
|
1777 |
|
1778 __UHEAP_MARKEND; |
|
1779 |
|
1780 return TestStepResult(); |
|
1781 } |
|
1782 |
|
1783 //////////////////////////////////////////////////////////////// |
|
1784 // CCorruptCacheRecoverStep - Checks to see if the Sis Registry |
|
1785 // recovers from a corrupt token cache file |
|
1786 //////////////////////////////////////////////////////////////// |
|
1787 |
|
1788 CCorruptCacheRecoverStep::CCorruptCacheRecoverStep() |
|
1789 { |
|
1790 SetTestStepName(KCorruptCacheRecoverStep); |
|
1791 } |
|
1792 |
|
1793 TVerdict CCorruptCacheRecoverStep::doTestStepL() |
|
1794 { |
|
1795 SetTestStepResult(EFail); |
|
1796 |
|
1797 RTestUtilSessionSwi util; |
|
1798 User::LeaveIfError(util.Connect()); |
|
1799 CleanupClosePushL(util); |
|
1800 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1801 TDriveName sysDriveName (sysDrive.Name()); |
|
1802 |
|
1803 // Close the Sis Registry and wait for 3 secs for |
|
1804 // the server to shut down |
|
1805 iSisRegistry.Close(); |
|
1806 INFO_PRINTF1(_L("Sis Registry shut down")); |
|
1807 User::After(3000000); |
|
1808 |
|
1809 // Attempt to read from the token cache file |
|
1810 RFs fs; |
|
1811 User::LeaveIfError(fs.Connect()); |
|
1812 CleanupClosePushL(fs); |
|
1813 |
|
1814 RFileReadStream stream; |
|
1815 User::LeaveIfError(stream.Open(fs, KCacheBackupFile, EFileRead | EFileShareReadersOnly)); |
|
1816 CleanupClosePushL(stream); |
|
1817 |
|
1818 INFO_PRINTF2(_L("'%S' regenerated successfully. Check by reading and internalizing..."), &KCacheBackupFile); |
|
1819 |
|
1820 RPointerArray<CSisRegistryToken> tokens; |
|
1821 CleanupResetAndDestroy<RPointerArray<CSisRegistryToken> >::PushL(tokens); |
|
1822 |
|
1823 // Will not catch a panic, but still a worthwhile check to make |
|
1824 TRAPD(err, stream.ReadUint32L()); |
|
1825 TRAP(err, InternalizePointerArrayL(tokens, stream)); |
|
1826 |
|
1827 if (err == KErrNone) |
|
1828 { |
|
1829 INFO_PRINTF2(_L("'%S' successfully read!"), &KCacheBackupFile); |
|
1830 |
|
1831 if (!util.FileExistsL(KSysBackupFileBackup)) |
|
1832 { |
|
1833 if (util.FileExistsL(KCacheBackupFile)) |
|
1834 { |
|
1835 INFO_PRINTF3(_L("'%S' exist in System Drive: %S\\"), |
|
1836 &KCacheBackupFile, &sysDriveName); |
|
1837 |
|
1838 SetTestStepResult(EPass); |
|
1839 } |
|
1840 else |
|
1841 { |
|
1842 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1843 &KCacheBackupFile, &sysDriveName); |
|
1844 } |
|
1845 } |
|
1846 else |
|
1847 { |
|
1848 INFO_PRINTF3(_L("'%S' exist in System Drive: %S\\ but shouldn't"), |
|
1849 &KSysBackupFileBackup, &sysDriveName); |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 CleanupStack::PopAndDestroy(4, &util); |
|
1854 |
|
1855 return TestStepResult(); |
|
1856 } |
|
1857 |
|
1858 ///////////////////////////////////////////////////////////////////// |
|
1859 // CChangeLocaleStep - Changes the locale |
|
1860 ///////////////////////////////////////////////////////////////////// |
|
1861 |
|
1862 CChangeLocaleStep::CChangeLocaleStep() |
|
1863 { |
|
1864 SetTestStepName(KChangeLocale); |
|
1865 } |
|
1866 |
|
1867 TVerdict CChangeLocaleStep::doTestStepL() |
|
1868 { |
|
1869 SetTestStepResult(EFail); |
|
1870 |
|
1871 TInt language=0; |
|
1872 if (!GetIntFromConfig(ConfigSection(), KLanguage, language)) |
|
1873 { |
|
1874 INFO_PRINTF1(_L("Missing language in config section")); |
|
1875 return EFail; |
|
1876 } |
|
1877 |
|
1878 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
1879 _LIT(KLitLanguageLocaleDllNameBase, "elocl_lan"); |
|
1880 //Region and collation code values are hard coded, as the check, after changing the locale is made for the language only. |
|
1881 _LIT(KLitRegionLocaleDllNameBase, "elocl_reg.826"); |
|
1882 _LIT(KLitCollationLocaleDllNameBase, "elocl_col.001"); |
|
1883 _LIT(ThreeDigExt,".%03d"); |
|
1884 |
|
1885 TExtendedLocale localeDll; |
|
1886 const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); |
|
1887 TBuf<16> languageLocaleDllName(KLitLanguageLocaleDllNameBase); |
|
1888 languageLocaleDllName.AppendFormat(ThreeDigExt, language); |
|
1889 TBuf<16> regionLocaleDllName(KLitRegionLocaleDllNameBase); |
|
1890 TBuf<16> collationLocaleDllName(KLitCollationLocaleDllNameBase); |
|
1891 // Try to load the locale dll |
|
1892 TInt error=localeDll.LoadLocale(languageLocaleDllName, regionLocaleDllName, collationLocaleDllName); |
|
1893 |
|
1894 if (error==KErrNotFound) |
|
1895 { |
|
1896 // Locale dll is not found for the asked language. |
|
1897 ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language); |
|
1898 } |
|
1899 |
|
1900 User::LeaveIfError(error); |
|
1901 localeDll.SaveSystemSettings(); |
|
1902 |
|
1903 #else |
|
1904 _LIT(KLitLocaleDllNameBase, "ELOCL"); |
|
1905 _LIT(TwoDigExt,".%02d"); |
|
1906 |
|
1907 RLibrary localeDll; |
|
1908 CleanupClosePushL(localeDll); |
|
1909 |
|
1910 const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); |
|
1911 TBuf<16> localeDllName(KLitLocaleDllNameBase); |
|
1912 localeDllName.AppendFormat(TwoDigExt, language); |
|
1913 |
|
1914 // Try to load the locale dll |
|
1915 TInt error=localeDll.Load(localeDllName, uidType); |
|
1916 if (error==KErrNotFound) |
|
1917 { |
|
1918 // Locale dll is not found for the asked language. |
|
1919 ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language); |
|
1920 } |
|
1921 |
|
1922 User::LeaveIfError(error); |
|
1923 User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); |
|
1924 CleanupStack::PopAndDestroy(); // localeDll |
|
1925 #endif |
|
1926 |
|
1927 // Check if the device locale has changed |
|
1928 if (language == User::Language()) |
|
1929 { |
|
1930 SetTestStepResult(EPass); |
|
1931 } |
|
1932 else |
|
1933 { |
|
1934 ERR_PRINTF3(_L("Failed to change the locale to %d whereas the current locale is"), language, User::Language()); |
|
1935 } |
|
1936 |
|
1937 return TestStepResult(); |
|
1938 } |
|
1939 |
|
1940 // Creates an dummy token object used in further steps. |
|
1941 void CreateTokenObjectL(RBufWriteStream& aWriteStream) |
|
1942 { |
|
1943 // Package details |
|
1944 aWriteStream.WriteInt32L(732875480); //Uid |
|
1945 aWriteStream << _L("DummyPkg"); // Name |
|
1946 aWriteStream << _L("Vendor"); // Vendor |
|
1947 aWriteStream.WriteInt32L(0); // Index |
|
1948 |
|
1949 aWriteStream.WriteUint32L(0); // Drives |
|
1950 |
|
1951 aWriteStream.WriteInt32L(0); // SID array count |
|
1952 aWriteStream.WriteInt32L(0); // Controller array count |
|
1953 |
|
1954 // Version |
|
1955 aWriteStream.WriteInt32L(1); // Major |
|
1956 aWriteStream.WriteInt32L(1); // Minor |
|
1957 aWriteStream.WriteInt32L(1); // Build |
|
1958 |
|
1959 // user selected options |
|
1960 aWriteStream.WriteInt32L(static_cast<TInt32>(1)); // Selected Language |
|
1961 aWriteStream.WriteUint32L(static_cast<TUint32>(25)); // Selected Drive |
|
1962 } |
|
1963 |
|
1964 |
|
1965 // These tests are added to improve the coverage. |
|
1966 CCreateTokenByCopy::CCreateTokenByCopy() |
|
1967 { |
|
1968 SetTestStepName(KCreateTokenByCopy); |
|
1969 } |
|
1970 |
|
1971 TVerdict CCreateTokenByCopy::doTestStepL() |
|
1972 { |
|
1973 SetTestStepResult(EFail); |
|
1974 |
|
1975 CSisRegistryToken* registryToken = CSisRegistryToken::NewL(); |
|
1976 CleanupStack::PushL(registryToken); |
|
1977 |
|
1978 // Create a buffer |
|
1979 CBufFlat* tokenBuf = CBufFlat::NewL(KDefaultBufferSize); |
|
1980 CleanupStack::PushL(tokenBuf); |
|
1981 |
|
1982 // create write stream |
|
1983 RBufWriteStream writeStream(*tokenBuf); |
|
1984 CleanupClosePushL(writeStream); |
|
1985 |
|
1986 // Create the dummy token object |
|
1987 CreateTokenObjectL(writeStream); |
|
1988 |
|
1989 // create read stream |
|
1990 RBufReadStream readStream(*tokenBuf); |
|
1991 CleanupClosePushL(readStream); |
|
1992 |
|
1993 registryToken->InternalizeL(readStream); |
|
1994 |
|
1995 CSisRegistryToken* copyRegistryToken = CSisRegistryToken::NewL(*registryToken); |
|
1996 CleanupStack::PushL(copyRegistryToken); |
|
1997 |
|
1998 CleanupStack::PopAndDestroy(5, registryToken); //registryToken, tokenBuf, writeStream, readStream, copyRegistryToken |
|
1999 |
|
2000 SetTestStepResult(EPass); |
|
2001 |
|
2002 return TestStepResult(); |
|
2003 } |
|
2004 |
|
2005 CCreateTokenFromStream::CCreateTokenFromStream() |
|
2006 { |
|
2007 SetTestStepName(KCreateTokenFromStream); |
|
2008 } |
|
2009 |
|
2010 TVerdict CCreateTokenFromStream::doTestStepL() |
|
2011 { |
|
2012 SetTestStepResult(EFail); |
|
2013 |
|
2014 // Create a buffer |
|
2015 CBufFlat* tokenBuf = CBufFlat::NewL(KDefaultBufferSize); |
|
2016 CleanupStack::PushL(tokenBuf); |
|
2017 |
|
2018 // create write stream |
|
2019 RBufWriteStream writeStream(*tokenBuf); |
|
2020 CleanupClosePushL(writeStream); |
|
2021 |
|
2022 // create read stream |
|
2023 RBufReadStream readStream(*tokenBuf); |
|
2024 CleanupClosePushL(readStream); |
|
2025 |
|
2026 // Create the dummy token object |
|
2027 CreateTokenObjectL(writeStream); |
|
2028 |
|
2029 //Ignore the error as we try to read the object an empty stream. |
|
2030 CSisRegistryToken* tokenFromStream = CSisRegistryToken::NewL(readStream); |
|
2031 CleanupStack::PushL(tokenFromStream); |
|
2032 |
|
2033 CleanupStack::PopAndDestroy(4, tokenBuf); // tokenBuf, writeStream, readStream, tokenFromStream |
|
2034 |
|
2035 SetTestStepResult(EPass); |
|
2036 |
|
2037 return TestStepResult(); |
|
2038 } |
|
2039 |
|
2040 |
|
2041 |
|
2042 ///////////////////////////////////////////////////////////////////// |
|
2043 // CCertificateChainListStep - Checks the certificate chain count for a given package. |
|
2044 ///////////////////////////////////////////////////////////////////// |
|
2045 CCertificateChainListStep::CCertificateChainListStep() |
|
2046 { |
|
2047 SetTestStepName(KCertificateChainListStep); |
|
2048 } |
|
2049 |
|
2050 TVerdict CCertificateChainListStep::doTestStepL() |
|
2051 { |
|
2052 SetTestStepResult(EPass); |
|
2053 |
|
2054 TUid uidOpen; |
|
2055 TInt certChainCount; |
|
2056 RSisRegistryEntry entry; |
|
2057 |
|
2058 if(!GetUidFromConfig(ConfigSection(), KUid, uidOpen) || !GetIntFromConfig(ConfigSection(), KCertChainCount, certChainCount)) |
|
2059 { |
|
2060 ERR_PRINTF1(_L("Missing package Uid or expected certificate chain count")); |
|
2061 SetTestStepResult(EFail); |
|
2062 return TestStepResult(); |
|
2063 } |
|
2064 |
|
2065 //StartTimer again to ignore time taken to read from config file |
|
2066 StartTimer(); |
|
2067 |
|
2068 if (KErrNone != entry.Open(iSisRegistry, uidOpen)) |
|
2069 { |
|
2070 SetTestStepResult(EFail); |
|
2071 return TestStepResult(); |
|
2072 } |
|
2073 CleanupClosePushL(entry); |
|
2074 |
|
2075 RPointerArray<HBufC8> chains; |
|
2076 CleanupResetAndDestroyPushL(chains); |
|
2077 TRAP_IGNORE(entry.CertificateChainsL(chains)); |
|
2078 |
|
2079 if(chains.Count() != certChainCount) |
|
2080 { |
|
2081 ERR_PRINTF3(_L("The actual certificate chain count does not meet expected. Expected: %d Actual: %d"), certChainCount, chains.Count()); |
|
2082 SetTestStepResult(EFail); |
|
2083 } |
|
2084 |
|
2085 CleanupStack::PopAndDestroy(2, &entry); //chains and entry. |
|
2086 return TestStepResult(); |
|
2087 } |
|
2088 |
|
2089 |
|
2090 //////////////////////////////////////////////////////////////////////////// |
|
2091 // CSidToPackageStep - Returns a pointer to package containing the Sid given |
|
2092 //////////////////////////////////////////////////////////////////////////// |
|
2093 CSidToPackageStep::CSidToPackageStep() |
|
2094 { |
|
2095 SetTestStepName(KSidToPackage); |
|
2096 } |
|
2097 |
|
2098 TVerdict CSidToPackageStep::doTestStepL() |
|
2099 { |
|
2100 TUid sid; |
|
2101 if(!GetUidFromConfig(ConfigSection(), KSid, sid)) |
|
2102 { |
|
2103 ERR_PRINTF1(_L("Sid is missing in the configuration file!")); |
|
2104 SetTestStepResult(EFail); |
|
2105 return TestStepResult(); |
|
2106 } |
|
2107 |
|
2108 //StartTimer again to ignore time taken to read from config file |
|
2109 StartTimer(); |
|
2110 |
|
2111 CSisRegistryPackage *pckg = iSisRegistry.SidToPackageL(sid); |
|
2112 if(!pckg) |
|
2113 { |
|
2114 ERR_PRINTF1(_L("NULL package returned!")); |
|
2115 SetTestStepResult(EFail); |
|
2116 } |
|
2117 else |
|
2118 { |
|
2119 delete pckg; |
|
2120 } |
|
2121 return TestStepResult(); |
|
2122 } |
|
2123 |
|
2124 //////////////////////////////////////////////////////////////////////////// |
|
2125 // CIsSidPresentSingleStep - test package SIDs are reported as present. |
|
2126 //////////////////////////////////////////////////////////////////////////// |
|
2127 CIsSidPresentSingleStep::CIsSidPresentSingleStep() |
|
2128 { |
|
2129 SetTestStepName(KIsSidPresentSingleStep); |
|
2130 } |
|
2131 |
|
2132 TVerdict CIsSidPresentSingleStep::doTestStepL() |
|
2133 { |
|
2134 TUid sid; |
|
2135 if(!GetUidFromConfig(ConfigSection(), KSid, sid)) |
|
2136 { |
|
2137 ERR_PRINTF1(_L("Sid is missing in the configuration file!")); |
|
2138 SetTestStepResult(EFail); |
|
2139 return TestStepResult(); |
|
2140 } |
|
2141 |
|
2142 TBool expectedresult(EFalse); |
|
2143 (void)GetBoolFromConfig(ConfigSection(), KResultTag, expectedresult); // if not specified, expected result is false. |
|
2144 |
|
2145 //StartTimer again to ignore time taken to read from config file |
|
2146 StartTimer(); |
|
2147 |
|
2148 TBool result = iSisRegistry.IsSidPresentL(sid); |
|
2149 if(result != expectedresult) |
|
2150 { |
|
2151 ERR_PRINTF2(_L("The result is different from the expected one!"), sid); |
|
2152 SetTestStepResult(EFail); |
|
2153 } |
|
2154 return TestStepResult(); |
|
2155 } |
|
2156 |
|
2157 //////////////////////////////////////////////////////////////////////////// |
|
2158 // CFileDescriptionsStep - Return the file descriptions associated with the given package |
|
2159 //////////////////////////////////////////////////////////////////////////// |
|
2160 CFileDescriptionsStep::CFileDescriptionsStep() |
|
2161 { |
|
2162 SetTestStepName(KFileDescriptionsStep); |
|
2163 } |
|
2164 |
|
2165 TVerdict CFileDescriptionsStep::doTestStepL() |
|
2166 { |
|
2167 TUid pckgUid; |
|
2168 if(!GetUidFromConfig(ConfigSection(), KUid, pckgUid)) |
|
2169 { |
|
2170 ERR_PRINTF1(_L("Package UID is missing in the configuration file!")); |
|
2171 SetTestStepResult(EFail); |
|
2172 return TestStepResult(); |
|
2173 } |
|
2174 |
|
2175 RSisRegistryWritableEntry writableEntry; |
|
2176 |
|
2177 //StartTimer again to ignore time taken to read from config file |
|
2178 StartTimer(); |
|
2179 |
|
2180 TInt err = writableEntry.Open(iSisRegistry, pckgUid); |
|
2181 if (KErrNone != err) |
|
2182 { |
|
2183 ERR_PRINTF2(_L("Writable entry couldn't be opened (Error code=%d)!"), err); |
|
2184 SetTestStepResult(EFail); |
|
2185 return TestStepResult(); |
|
2186 } |
|
2187 CleanupClosePushL(writableEntry); |
|
2188 |
|
2189 RPointerArray<CSisRegistryFileDescription> fileDescriptions; |
|
2190 CleanupResetAndDestroyPushL(fileDescriptions); |
|
2191 writableEntry.FileDescriptionsL(fileDescriptions); |
|
2192 TInt fileCount = fileDescriptions.Count(); |
|
2193 CleanupStack::PopAndDestroy(2, &writableEntry); // writableEntry, fileDescriptions |
|
2194 if(!fileCount) |
|
2195 return PrintErrorAndReturnFailL(_L("No file returned!")); |
|
2196 return TestStepResult(); |
|
2197 } |
|
2198 |
|
2199 //////////////////////////////////////////////////////////////////////////// |
|
2200 // CIsAugmentationStep - whether or not the given package augments another package |
|
2201 //////////////////////////////////////////////////////////////////////////// |
|
2202 CIsAugmentationStep::CIsAugmentationStep() |
|
2203 { |
|
2204 SetTestStepName(KIsAugmentationStep); |
|
2205 } |
|
2206 |
|
2207 TVerdict CIsAugmentationStep::doTestStepL() |
|
2208 { |
|
2209 TBool expectedresult(EFalse); |
|
2210 (void)GetBoolFromConfig(ConfigSection(), KResultTag, expectedresult); // if not specified, expected result is false. |
|
2211 |
|
2212 //StartTimer again to ignore time taken to read from config file |
|
2213 StartTimer(); |
|
2214 |
|
2215 TBool result = iRegistryEntry.IsAugmentationL(); |
|
2216 if(result != expectedresult) |
|
2217 { |
|
2218 ERR_PRINTF1(_L("The result is different from the expected one!")); |
|
2219 SetTestStepResult(EFail); |
|
2220 } |
|
2221 |
|
2222 return TestStepResult(); |
|
2223 } |
|
2224 |
|
2225 //////////////////////////////////////////////////////////////////////////// |
|
2226 // CFilesStep - Provides a list of files installed by the given package |
|
2227 //////////////////////////////////////////////////////////////////////////// |
|
2228 CFilesStep::CFilesStep() |
|
2229 { |
|
2230 SetTestStepName(KFilesStep); |
|
2231 } |
|
2232 |
|
2233 TVerdict CFilesStep::doTestStepL() |
|
2234 { |
|
2235 RPointerArray<HBufC> files; |
|
2236 CleanupResetAndDestroyPushL(files); |
|
2237 iRegistryEntry.FilesL(files); |
|
2238 if(!files.Count()) |
|
2239 { |
|
2240 ERR_PRINTF1(_L("The package files couldn't be retrieved!")); |
|
2241 SetTestStepResult(EFail); |
|
2242 } |
|
2243 CleanupStack::PopAndDestroy(&files); |
|
2244 |
|
2245 return TestStepResult(); |
|
2246 } |
|
2247 |
|
2248 //////////////////////////////////////////////////////////////////////////// |
|
2249 // CAugmentationsStep - Returns all augmentations to the given package. |
|
2250 //////////////////////////////////////////////////////////////////////////// |
|
2251 CAugmentationsStep::CAugmentationsStep() |
|
2252 { |
|
2253 SetTestStepName(KAugmentationsStep); |
|
2254 } |
|
2255 |
|
2256 TVerdict CAugmentationsStep::doTestStepL() |
|
2257 { |
|
2258 RPointerArray<CSisRegistryPackage> packages; |
|
2259 CleanupResetAndDestroyPushL(packages); |
|
2260 iRegistryEntry.AugmentationsL(packages); |
|
2261 if(!packages.Count()) |
|
2262 { |
|
2263 ERR_PRINTF1(_L("The augmentation package couldn't be retrieved!")); |
|
2264 SetTestStepResult(EFail); |
|
2265 } |
|
2266 CleanupStack::PopAndDestroy(&packages); |
|
2267 |
|
2268 return TestStepResult(); |
|
2269 } |
|
2270 |
|
2271 //////////////////////////////////////////////////////////////////////////// |
|
2272 // CPackageStep - Returns the package of a current entry |
|
2273 //////////////////////////////////////////////////////////////////////////// |
|
2274 CPackageStep::CPackageStep() |
|
2275 { |
|
2276 SetTestStepName(KPackageStep); |
|
2277 } |
|
2278 |
|
2279 TVerdict CPackageStep::doTestStepL() |
|
2280 { |
|
2281 CSisRegistryPackage* package=iRegistryEntry.PackageL(); |
|
2282 if(!package) |
|
2283 { |
|
2284 ERR_PRINTF1(_L("The package couldn't be retrieved!")); |
|
2285 SetTestStepResult(EFail); |
|
2286 } |
|
2287 delete package; |
|
2288 return TestStepResult(); |
|
2289 } |
|
2290 |
|
2291 //////////////////////////////////////////////////////////////////////////// |
|
2292 // CDependentPackagesStep - Returns the array of packages dependent on the given package. |
|
2293 //////////////////////////////////////////////////////////////////////////// |
|
2294 CDependentPackagesStep::CDependentPackagesStep() |
|
2295 { |
|
2296 SetTestStepName(KDependentPackagesStep); |
|
2297 } |
|
2298 |
|
2299 TVerdict CDependentPackagesStep::doTestStepL() |
|
2300 { |
|
2301 RPointerArray<CSisRegistryPackage> dependents; |
|
2302 CleanupResetAndDestroyPushL(dependents); |
|
2303 iRegistryEntry.DependentPackagesL(dependents); |
|
2304 if(!dependents.Count()) |
|
2305 { |
|
2306 ERR_PRINTF1(_L("The dependant package couldn't be retrieved!")); |
|
2307 SetTestStepResult(EFail); |
|
2308 } |
|
2309 CleanupStack::PopAndDestroy(&dependents);; |
|
2310 return TestStepResult(); |
|
2311 } |
|
2312 |
|
2313 //////////////////////////////////////////////////////////////////////////// |
|
2314 // CDependenciesStep - Returns the dependency array for the given package |
|
2315 //////////////////////////////////////////////////////////////////////////// |
|
2316 CDependenciesStep::CDependenciesStep() |
|
2317 { |
|
2318 SetTestStepName(KDependenciesStep); |
|
2319 } |
|
2320 |
|
2321 TVerdict CDependenciesStep::doTestStepL() |
|
2322 { |
|
2323 RPointerArray<CSisRegistryDependency> dependencies; |
|
2324 CleanupResetAndDestroyPushL(dependencies); |
|
2325 iRegistryEntry.DependenciesL(dependencies); |
|
2326 if(!dependencies.Count()) |
|
2327 { |
|
2328 ERR_PRINTF1(_L("The dependency package couldn't be retrieved!")); |
|
2329 SetTestStepResult(EFail); |
|
2330 } |
|
2331 CleanupStack::PopAndDestroy(&dependencies);; |
|
2332 return TestStepResult(); |
|
2333 } |
|
2334 |
|
2335 //////////////////////////////////////////////////////////////////////////// |
|
2336 // CEmbeddedPackagesStep - return a array of packages that were embedded within the given package. |
|
2337 //////////////////////////////////////////////////////////////////////////// |
|
2338 CEmbeddedPackagesStep::CEmbeddedPackagesStep() |
|
2339 { |
|
2340 SetTestStepName(KEmbeddedPackagesStep); |
|
2341 } |
|
2342 |
|
2343 TVerdict CEmbeddedPackagesStep::doTestStepL() |
|
2344 { |
|
2345 RPointerArray<CSisRegistryPackage> embedded; |
|
2346 CleanupResetAndDestroyPushL(embedded); |
|
2347 iRegistryEntry.EmbeddedPackagesL(embedded); |
|
2348 if(!embedded.Count()) |
|
2349 { |
|
2350 ERR_PRINTF1(_L("The embedded package couldn't be retrieved!")); |
|
2351 SetTestStepResult(EFail); |
|
2352 } |
|
2353 CleanupStack::PopAndDestroy(&embedded);; |
|
2354 return TestStepResult(); |
|
2355 } |
|
2356 |
|
2357 |
|
2358 // Test creation of SisRegistryObject. |
|
2359 |
|
2360 CCreateSisRegistryObject::CCreateSisRegistryObject() |
|
2361 { |
|
2362 SetTestStepName(KCreateSisRegistryObject); |
|
2363 } |
|
2364 |
|
2365 TVerdict CCreateSisRegistryObject::doTestStepL() |
|
2366 { |
|
2367 SetTestStepResult(EFail); |
|
2368 |
|
2369 CSisRegistryObject* registryObject = CSisRegistryObject::NewL(); |
|
2370 delete registryObject; |
|
2371 |
|
2372 SetTestStepResult(EPass); |
|
2373 return TestStepResult(); |
|
2374 } |
|
2375 |
|
2376 //////////////////////////////////////////////////////////////////////////// |
|
2377 // CIsFileRegisteredStep - Tests IsFileRegisteredL API in SWI Registry |
|
2378 //////////////////////////////////////////////////////////////////////////// |
|
2379 CIsFileRegisteredStep::CIsFileRegisteredStep() |
|
2380 { |
|
2381 SetTestStepName(KIsFileRegisteredStep); |
|
2382 } |
|
2383 |
|
2384 TVerdict CIsFileRegisteredStep::doTestStepL() |
|
2385 { |
|
2386 TBool expectedResult(EFalse); |
|
2387 GetBoolFromConfig(ConfigSection(), _L("expectedResult"), expectedResult); |
|
2388 TPtrC testedFilename; |
|
2389 if (!GetStringFromConfig(ConfigSection(), _L("testedFilename"), testedFilename)) |
|
2390 { |
|
2391 ERR_PRINTF1(_L("testedFilename property was not found in IsFileRegistered test step!")); |
|
2392 SetTestStepResult(EFail); |
|
2393 return TestStepResult(); |
|
2394 } |
|
2395 INFO_PRINTF2(_L("Testing presence of file %S in the registry"), &testedFilename); |
|
2396 |
|
2397 //StartTimer again to ignore time taken to read from config file |
|
2398 StartTimer(); |
|
2399 |
|
2400 TBool foundResult = iSisRegistry.IsFileRegisteredL(testedFilename); |
|
2401 if (foundResult != expectedResult) |
|
2402 { |
|
2403 ERR_PRINTF3(_L("File presence test failed! Expected %d, but received %d"), expectedResult, foundResult); |
|
2404 SetTestStepResult(EFail); |
|
2405 } |
|
2406 return TestStepResult(); |
|
2407 } |
|
2408 |
|
2409 CGetComponentIdForUidStep::CGetComponentIdForUidStep() |
|
2410 { |
|
2411 } |
|
2412 |
|
2413 TVerdict CGetComponentIdForUidStep::doTestStepL() |
|
2414 { |
|
2415 TUid uid; |
|
2416 if (!GetUidFromConfig(ConfigSection(), _L("uid"), uid)) |
|
2417 { |
|
2418 ERR_PRINTF1(_L("uid property was not found in GetComponentIdForUid test step!")); |
|
2419 SetTestStepResult(EFail); |
|
2420 return TestStepResult(); |
|
2421 } |
|
2422 INFO_PRINTF2(_L("Retrieving component id for UID %d"), uid.iUid); |
|
2423 |
|
2424 //StartTimer again to ignore time taken to read from config file |
|
2425 StartTimer(); |
|
2426 |
|
2427 Usif::TComponentId componentId = iSisRegistry.GetComponentIdForUidL(uid); |
|
2428 INFO_PRINTF3(_L("Retrieved component id %d for UID %d"), componentId, uid.iUid); |
|
2429 return TestStepResult(); |
|
2430 } |
|
2431 |
|
2432 // Test creation of CSisRegistryDependency objects. |
|
2433 |
|
2434 // Creates a dummy CSisRegistryDependency object. |
|
2435 void CreateSisRegDependencyObjectL(RBufWriteStream& aWriteStream) |
|
2436 { |
|
2437 // Package Uid |
|
2438 aWriteStream.WriteInt32L(732875480); //Uid |
|
2439 |
|
2440 // From Version |
|
2441 aWriteStream.WriteInt32L(1); // Major |
|
2442 aWriteStream.WriteInt32L(0); // Minor |
|
2443 aWriteStream.WriteInt32L(0); // Build |
|
2444 |
|
2445 // To Version |
|
2446 aWriteStream.WriteInt32L(2); // Major |
|
2447 aWriteStream.WriteInt32L(0); // Minor |
|
2448 aWriteStream.WriteInt32L(0); // Build |
|
2449 } |
|
2450 |
|
2451 CSisRegistryDependencyStep::CSisRegistryDependencyStep() |
|
2452 { |
|
2453 SetTestStepName(KSisRegistryDependencyStep); |
|
2454 } |
|
2455 |
|
2456 TVerdict CSisRegistryDependencyStep::doTestStepL() |
|
2457 { |
|
2458 SetTestStepResult(EFail); |
|
2459 |
|
2460 // Create a buffer |
|
2461 CBufFlat* buffer = CBufFlat::NewL(KDefaultBufferSize); |
|
2462 CleanupStack::PushL(buffer); |
|
2463 |
|
2464 // create write stream |
|
2465 RBufWriteStream writeStream(*buffer); |
|
2466 CleanupClosePushL(writeStream); |
|
2467 |
|
2468 // create read stream |
|
2469 RBufReadStream readStream(*buffer); |
|
2470 CleanupClosePushL(readStream); |
|
2471 |
|
2472 CreateSisRegDependencyObjectL(writeStream); |
|
2473 |
|
2474 CSisRegistryDependency* objFromStream = CSisRegistryDependency::NewL(readStream); |
|
2475 CleanupStack::PushL(objFromStream); |
|
2476 |
|
2477 CSisRegistryDependency* objectByCopy = CSisRegistryDependency::NewL(*objFromStream); |
|
2478 CleanupStack::PushL(objectByCopy); |
|
2479 |
|
2480 _LIT(KPkgMajor, "pkgMajor"); |
|
2481 TInt pkgMajor = 0; |
|
2482 if(!GetIntFromConfig(ConfigSection(), KPkgMajor, pkgMajor)) |
|
2483 { |
|
2484 ERR_PRINTF1(_L("Missing major version!")); |
|
2485 SetTestStepResult(EFail); |
|
2486 return TestStepResult(); |
|
2487 } |
|
2488 |
|
2489 _LIT(KPkgMinor, "pkgMinor"); |
|
2490 TInt pkgMinor = 0; |
|
2491 if(!GetIntFromConfig(ConfigSection(), KPkgMinor, pkgMinor)) |
|
2492 { |
|
2493 ERR_PRINTF1(_L("Missing minor version!")); |
|
2494 SetTestStepResult(EFail); |
|
2495 return TestStepResult(); |
|
2496 } |
|
2497 |
|
2498 _LIT(KPkgBuild, "pkgBuild"); |
|
2499 TInt pkgBuild = 0; |
|
2500 if(!GetIntFromConfig(ConfigSection(), KPkgBuild, pkgBuild)) |
|
2501 { |
|
2502 ERR_PRINTF1(_L("Missing build!")); |
|
2503 SetTestStepResult(EFail); |
|
2504 return TestStepResult(); |
|
2505 } |
|
2506 |
|
2507 TVersion version(pkgMajor, pkgMinor, pkgBuild); |
|
2508 |
|
2509 if(!(objectByCopy->IsCompatible(version))) |
|
2510 { |
|
2511 SetTestStepResult(EFail); |
|
2512 } |
|
2513 |
|
2514 CleanupStack::PopAndDestroy(5, buffer); // buffer, writeStream, readStream, objFromStream and objByCopy. |
|
2515 SetTestStepResult(EPass); |
|
2516 |
|
2517 return TestStepResult(); |
|
2518 } |
|
2519 |
|
2520 // Test creation of CSisRegistryFileDescription object. |
|
2521 |
|
2522 CSisRegistryFileDescStep::CSisRegistryFileDescStep() |
|
2523 { |
|
2524 SetTestStepName(KSisRegistryFileDescStep); |
|
2525 } |
|
2526 |
|
2527 void CSisRegistryFileDescStep::CreateSisRegFileDescObjectL(RBufWriteStream& aWriteStream, TDesC8& aHashData, TDesC& aTarget, TDesC& aMimeType) |
|
2528 { |
|
2529 aWriteStream << aTarget; //file name |
|
2530 aWriteStream << aMimeType; // file mime type |
|
2531 aWriteStream.WriteInt32L(1); //operation |
|
2532 aWriteStream.WriteInt32L(1); //operation options |
|
2533 aWriteStream.WriteInt32L(2); //hash algorithm |
|
2534 aWriteStream << aHashData; //hash data |
|
2535 aWriteStream.WriteInt32L(1200); //uncompressed length |
|
2536 aWriteStream.WriteInt32L(1400); //uncompressed length |
|
2537 aWriteStream.WriteInt32L(0); //index |
|
2538 aWriteStream.WriteInt32L(12341212); //SID. |
|
2539 } |
|
2540 |
|
2541 TVerdict CSisRegistryFileDescStep::doTestStepL() |
|
2542 { |
|
2543 SetTestStepResult(EFail); |
|
2544 |
|
2545 CSisRegistryFileDescription* object = CSisRegistryFileDescription::NewL(); |
|
2546 delete object; |
|
2547 |
|
2548 // Create a buffer |
|
2549 CBufFlat* buffer = CBufFlat::NewL(KDefaultBufferSize); |
|
2550 CleanupStack::PushL(buffer); |
|
2551 |
|
2552 // create write stream |
|
2553 RBufWriteStream writeStream(*buffer); |
|
2554 CleanupClosePushL(writeStream); |
|
2555 |
|
2556 // create read stream |
|
2557 RBufReadStream readStream(*buffer); |
|
2558 CleanupClosePushL(readStream); |
|
2559 |
|
2560 _LIT8(KHashData, "kshfashgkghsrewiturtugit"); |
|
2561 TInt dataLen = 24; |
|
2562 HBufC8* hashData = HBufC8::NewLC(dataLen); |
|
2563 *hashData = KHashData; |
|
2564 |
|
2565 _LIT(KTargetName, "c:\\sys\\bin\\test.exe"); |
|
2566 HBufC* target = HBufC::NewLC(dataLen); |
|
2567 *target = KTargetName; |
|
2568 |
|
2569 HBufC* mimeType = HBufC::NewLC(dataLen); |
|
2570 |
|
2571 CreateSisRegFileDescObjectL(writeStream, *hashData, *target, *mimeType); |
|
2572 |
|
2573 CSisRegistryFileDescription* obj = CSisRegistryFileDescription::NewL(readStream); |
|
2574 delete obj; |
|
2575 |
|
2576 CleanupStack::PopAndDestroy(6, buffer); //mime type, target, hashData, readStream, writeStream and buffer. |
|
2577 |
|
2578 SetTestStepResult(EPass); |
|
2579 return TestStepResult(); |
|
2580 } |
|
2581 |
|
2582 // Test creation of CControllerInfo object. |
|
2583 |
|
2584 CControllerInfoStep::CControllerInfoStep() |
|
2585 { |
|
2586 SetTestStepName(KControllerInfoStep); |
|
2587 } |
|
2588 |
|
2589 |
|
2590 // Creates an dummy CControllerInfo object. |
|
2591 void CControllerInfoStep::CreateCControllerInfoObjectL(RBufWriteStream& aWriteStream, TDesC8& aHashData) |
|
2592 { |
|
2593 aWriteStream.WriteInt32L(1); //major version |
|
2594 aWriteStream.WriteInt32L(0); //minor version |
|
2595 aWriteStream.WriteInt32L(1); //build version |
|
2596 aWriteStream.WriteInt32L(0); //offset |
|
2597 aWriteStream.WriteInt32L(2); //hash algorithm |
|
2598 aWriteStream << aHashData; //hashdata |
|
2599 } |
|
2600 |
|
2601 TVerdict CControllerInfoStep::doTestStepL() |
|
2602 { |
|
2603 SetTestStepResult(EFail); |
|
2604 |
|
2605 // Create a buffer |
|
2606 CBufFlat* buffer = CBufFlat::NewL(KDefaultBufferSize); |
|
2607 CleanupStack::PushL(buffer); |
|
2608 |
|
2609 // create write stream |
|
2610 RBufWriteStream writeStream(*buffer); |
|
2611 CleanupClosePushL(writeStream); |
|
2612 |
|
2613 // create read stream |
|
2614 RBufReadStream readStream(*buffer); |
|
2615 CleanupClosePushL(readStream); |
|
2616 |
|
2617 _LIT8(KHashData, "kshfashgkghs"); |
|
2618 TInt dataLen = 12; |
|
2619 HBufC8* hashData = HBufC8::NewLC(dataLen); |
|
2620 *hashData = KHashData; |
|
2621 |
|
2622 CreateCControllerInfoObjectL(writeStream, *hashData); |
|
2623 |
|
2624 CControllerInfo* objFromStream = CControllerInfo::NewL(readStream); |
|
2625 CleanupStack::PushL(objFromStream); |
|
2626 |
|
2627 CControllerInfo* object = CControllerInfo::NewL(*objFromStream); |
|
2628 delete object; |
|
2629 |
|
2630 TVersion version(1, 5, 9); |
|
2631 CHashContainer* hashContainer = CHashContainer::NewLC(CMessageDigest::ESHA1, *hashData); |
|
2632 |
|
2633 CControllerInfo* controllerObj = CControllerInfo::NewL(version, *hashContainer); |
|
2634 CleanupStack::PushL(controllerObj); |
|
2635 |
|
2636 TVersion controllerVersion = controllerObj->Version(); |
|
2637 if((controllerVersion.iMajor!= version.iMajor) || (controllerVersion.iMinor!= version.iMinor) || (controllerVersion.iBuild!= version.iBuild)) |
|
2638 { |
|
2639 SetTestStepResult(EFail); |
|
2640 } |
|
2641 |
|
2642 CleanupStack::PopAndDestroy(7, buffer); //controllerObj, hashContainer, objFromStream, hashData, readStream, writeStream and buffer. |
|
2643 |
|
2644 SetTestStepResult(EPass); |
|
2645 return TestStepResult(); |
|
2646 } |
|
2647 |
|
2648 // Test creation of CSisRegistryProperty object. |
|
2649 |
|
2650 CSisRegistryPropertyStep::CSisRegistryPropertyStep() |
|
2651 { |
|
2652 SetTestStepName(KSisRegistryPropertyStep); |
|
2653 } |
|
2654 |
|
2655 |
|
2656 // Creates an dummy CSisRegistryProperty object. |
|
2657 void CSisRegistryPropertyStep::CreateCSisRegPropertyObjectL(RBufWriteStream& aWriteStream) |
|
2658 { |
|
2659 aWriteStream.WriteInt32L(1); //key |
|
2660 aWriteStream.WriteInt32L(-1); //value |
|
2661 } |
|
2662 |
|
2663 TVerdict CSisRegistryPropertyStep::doTestStepL() |
|
2664 { |
|
2665 SetTestStepResult(EFail); |
|
2666 |
|
2667 // Create a buffer |
|
2668 CBufFlat* buffer = CBufFlat::NewL(KDefaultBufferSize); |
|
2669 CleanupStack::PushL(buffer); |
|
2670 |
|
2671 // create write stream |
|
2672 RBufWriteStream writeStream(*buffer); |
|
2673 CleanupClosePushL(writeStream); |
|
2674 |
|
2675 // create read stream |
|
2676 RBufReadStream readStream(*buffer); |
|
2677 CleanupClosePushL(readStream); |
|
2678 |
|
2679 CreateCSisRegPropertyObjectL(writeStream); |
|
2680 |
|
2681 CSisRegistryProperty* object = CSisRegistryProperty::NewL(readStream); |
|
2682 delete object; |
|
2683 |
|
2684 CleanupStack::PopAndDestroy(3, buffer); //readStream, writeStream and buffer. |
|
2685 |
|
2686 SetTestStepResult(EPass); |
|
2687 return TestStepResult(); |
|
2688 } |
|
2689 |
|
2690 //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
2691 |
|
2692 // This test case is used only for performance measurement to check that a typical UI app. manager performs well with the SWI Registry |
|
2693 CSisApplicationManagerStep::CSisApplicationManagerStep() |
|
2694 { |
|
2695 SetTestStepName(KApplicationManagerStep); |
|
2696 } |
|
2697 |
|
2698 TVerdict CSisApplicationManagerStep::doTestStepL() |
|
2699 { |
|
2700 RPointerArray<CSisRegistryPackage> packages; |
|
2701 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
2702 // First get the list of removable packages |
|
2703 iSisRegistry.RemovablePackagesL(packages); |
|
2704 for (TInt i = 0; i < packages.Count(); ++i) |
|
2705 { |
|
2706 Swi::RSisRegistryEntry entry; |
|
2707 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[i])); |
|
2708 CleanupClosePushL(entry); |
|
2709 TBool isPresent = entry.IsPresentL(); |
|
2710 TSisPackageTrust trust = entry.TrustL(); |
|
2711 TInt64 size = entry.SizeL(); |
|
2712 TVersion version = entry.VersionL(); |
|
2713 // Disable compiler warnings |
|
2714 while (isPresent && trust && size && version.iMajor) |
|
2715 break; |
|
2716 CleanupStack::PopAndDestroy(&entry); |
|
2717 } |
|
2718 CleanupStack::PopAndDestroy(&packages); |
|
2719 SetTestStepResult(EPass); |
|
2720 return TestStepResult(); |
|
2721 } |