|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Tests CApaAppRegFinder APIs. |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 |
|
25 #include <apgicnfl.h> |
|
26 #include <e32property.h> |
|
27 #include "T_File3Step.h" |
|
28 #include "..\apfile\aprfndr.h" |
|
29 #include "TSidChecker\TestSidChecker.h" |
|
30 |
|
31 #include <e32test.h> |
|
32 #include <f32file.h> |
|
33 |
|
34 _LIT(KCallBackAppRsc,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\10281fe0_reg.rsc"); |
|
35 _LIT(KCallBackAppIst,"\\TestSidCheckerCallBackApp.ist"); |
|
36 _LIT(KBadAppRsc,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\10281fdc_reg.rsc"); |
|
37 _LIT(KBadAppIst,"\\TestSidCheckerBadApp.ist"); |
|
38 _LIT(KGoodAppRsc,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\10281fdd_reg.rsc"); |
|
39 _LIT(KGoodAppIst,"\\TestSidCheckerGoodApp.ist"); |
|
40 _LIT(KForcedAppRsc, "\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102825b5_reg.rsc"); |
|
41 _LIT(KForcedAppIst, "\\TestSidCheckerForcedApp.ist"); |
|
42 _LIT(KTriggerRescanRsc,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102825b6_reg.rsc"); |
|
43 _LIT(KTriggerRescanIst,"\\TestSidCheckerTriggerRescan.ist"); |
|
44 _LIT(KMmcPrivateDir,"\\private\\10003a3f\\"); |
|
45 _LIT(KAppRsc1,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\A000D107_reg.rsc"); |
|
46 _LIT(KAppRsc2,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\A000D107_r02.rsc"); |
|
47 _LIT(KAppRsc3,"\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\A000D107_r03.rsc"); |
|
48 _LIT(KAppIst, "\\TestSidCheckerMultipleRegistrationFilesApp.ist"); |
|
49 |
|
50 CT_File3Step::CT_File3Step() |
|
51 /** |
|
52 Constructor |
|
53 */ |
|
54 { |
|
55 // Call base class method to set up the human readable name for logging |
|
56 SetTestStepName(KT_File3Step); |
|
57 } |
|
58 |
|
59 _LIT(KLitNativeExecutable, "z:\\sys\\bin\\SidCheckerTestDummy.exe"); |
|
60 |
|
61 /** |
|
62 @return - TVerdict code |
|
63 Override of base class virtual |
|
64 */ |
|
65 TVerdict CT_File3Step::doTestStepPreambleL() |
|
66 { |
|
67 SetTestStepResult(EPass); |
|
68 TInt err = iSession.Connect(); |
|
69 TEST(err==KErrNone); |
|
70 err = iUtils.Connect(); |
|
71 TEST(err==KErrNone); |
|
72 return TestStepResult(); |
|
73 } |
|
74 |
|
75 TVerdict CT_File3Step::doTestStepL() |
|
76 /** |
|
77 @return - TVerdict code |
|
78 Override of base class virtual |
|
79 */ |
|
80 { |
|
81 INFO_PRINTF1(_L("Testing the CAppSidChecker api")); |
|
82 FindRemovableDriveAndSetPathL(); |
|
83 // Must be first, since the plugin must not be loaded when this is started. |
|
84 //DONT_CHECK since changes on file system changes the heap |
|
85 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRescanCallBackL(), REComSession::FinalClose() ); |
|
86 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestAppPresenceL(), REComSession::FinalClose() ); |
|
87 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestForceRegistrationL(), REComSession::FinalClose() ); |
|
88 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestCorruptedRegFileL(), NO_CLEANUP ); |
|
89 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestMultipleRegistrationFilesForSameAppL(), REComSession::FinalClose() ); |
|
90 |
|
91 INFO_PRINTF1(_L("Test completed!")); |
|
92 return TestStepResult(); |
|
93 } |
|
94 |
|
95 |
|
96 /** |
|
97 @SYMTestCaseID UIFRAMEWORKS-APPARC-0047 |
|
98 |
|
99 @SYMDEF INC069526 |
|
100 |
|
101 @SYMTestCaseDesc When an implementation of the ApSidChecker interface invokes the rescan callback that was passed to it, |
|
102 the App list server should scan for application registration files. This tests that it does so. |
|
103 |
|
104 @SYMTestPriority High |
|
105 |
|
106 @SYMTestStatus Implemented |
|
107 |
|
108 @SYMTestActions Trigger the loading of a special plugin implementing the ApSidChecker interface |
|
109 Tell the loaded instance of the aforementioned implementation to trigger a rescan via pub&sub |
|
110 -> The plugin will invoke its callback |
|
111 -> The plugin will start a timer |
|
112 -> The timer will publish a result when either: |
|
113 a) it recieves an AppRegisteredAt() call -- this is part of the scan we tried to trigger. (success) |
|
114 b) the timer completes (failure) |
|
115 Retrieve the results from the plugin, again via pub & sub |
|
116 |
|
117 @SYMTestExpectedResults The Apparc App list server scans for new/removed apps when a plugins requests it |
|
118 */ |
|
119 void CT_File3Step::TestRescanCallBackL() |
|
120 { |
|
121 INFO_PRINTF1(_L("Testing CApaAppRegFinder::TestRescanCallBackL()")); |
|
122 |
|
123 CleanupRegFilesL(); |
|
124 |
|
125 User::LeaveIfError(RProperty::Define(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, RProperty::EInt)); |
|
126 User::LeaveIfError(RProperty::Set(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, CTestSidChecker::EPluginLoad)); |
|
127 |
|
128 TProcessPriority oldPriority = RProcess().Priority(); |
|
129 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
130 |
|
131 iSession.RegisterNonNativeApplicationTypeL(KApFileTestAppType, KLitNativeExecutable); |
|
132 TRAPD(err, PrepareRegFileL(KApFileTestCallBackApp, iCallBackAppRsc, iCallBackAppIst)); |
|
133 TEST(err==KErrNone); |
|
134 User::After(20 * 1000000); |
|
135 |
|
136 TRequestStatus status; |
|
137 RProperty property; |
|
138 CleanupClosePushL(property); |
|
139 User::LeaveIfError(RProperty::Set(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, CTestSidChecker::ETriggerScan)); |
|
140 User::LeaveIfError(property.Attach(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey)); |
|
141 property.Subscribe(status); |
|
142 |
|
143 RTimer timer; |
|
144 CleanupClosePushL(timer); |
|
145 User::LeaveIfError(timer.CreateLocal()); |
|
146 TRequestStatus timerStatus; |
|
147 timer.After(timerStatus,30 * 1000000); |
|
148 |
|
149 User::WaitForRequest(status,timerStatus); |
|
150 TEST(status != KRequestPending); |
|
151 if(status != KRequestPending) |
|
152 { |
|
153 timer.Cancel(); |
|
154 User::WaitForRequest(timerStatus); |
|
155 TInt result; |
|
156 User::LeaveIfError(RProperty::Get(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, result)); |
|
157 TEST(result == CTestSidChecker::EScanOccurred); |
|
158 } |
|
159 else |
|
160 { |
|
161 property.Cancel(); |
|
162 User::WaitForRequest(status); |
|
163 ASSERT(timerStatus != KRequestPending); |
|
164 INFO_PRINTF1(_L("Timeout exceeded")); |
|
165 } |
|
166 |
|
167 CleanupStack::PopAndDestroy(2,&property); |
|
168 |
|
169 RProcess().SetPriority(oldPriority); |
|
170 |
|
171 CleanupRegFilesL(); |
|
172 } |
|
173 |
|
174 /** |
|
175 @SYMTestCaseID UIFRAMEWORKS-APPARC-0048 |
|
176 |
|
177 @SYMDEF INC069526 |
|
178 |
|
179 @SYMTestCaseDesc Test that the results of the AppRegisteredAt() function in the ApSidChecker ECOM interface are handled correctly |
|
180 |
|
181 @SYMTestPriority High |
|
182 |
|
183 @SYMTestStatus Implemented |
|
184 |
|
185 @SYMTestActions Create application registration files on a removable drive |
|
186 Iterate over all registration files with an instance of CApaAppRegFinder |
|
187 |
|
188 @SYMTestExpectedResults CApaAppRegFinder's list of entries contains KApFileTestGoodApp but not KApFileTestBadApp |
|
189 */ |
|
190 void CT_File3Step::TestAppPresenceL() |
|
191 { |
|
192 INFO_PRINTF1(_L("Testing CApaAppRegFinder::TestAppPresenceL()")); |
|
193 |
|
194 /* |
|
195 * Prepare registration files |
|
196 */ |
|
197 |
|
198 CleanupRegFilesL(); |
|
199 |
|
200 iSession.RegisterNonNativeApplicationTypeL(KApFileTestAppType, KLitNativeExecutable); |
|
201 TRAPD(err, PrepareRegFileL(KApFileTestBadApp, iBadAppRsc, iBadAppIst)); |
|
202 TEST(err==KErrNone); |
|
203 TRAP(err, PrepareRegFileL(KApFileTestGoodApp, iGoodAppRsc, iGoodAppIst)); |
|
204 TEST(err==KErrNone); |
|
205 |
|
206 /* |
|
207 * Manually scan files |
|
208 */ |
|
209 RFs fSession; |
|
210 User::LeaveIfError(fSession.Connect()); |
|
211 CleanupClosePushL(fSession); |
|
212 CApaAppRegFinder* regFinder=CApaAppRegFinder::NewLC(fSession); |
|
213 |
|
214 TRAPD(ret, regFinder->FindAllAppsL() ); |
|
215 TEST(ret==KErrNone); |
|
216 |
|
217 TBool more = ETrue; |
|
218 TBool foundGoodApp = EFalse; |
|
219 TBool foundBadApp = EFalse; |
|
220 while (more) |
|
221 { |
|
222 TApaAppEntry entry; |
|
223 RPointerArray<HBufC> dummy; |
|
224 TRAPD(ret, more=regFinder->NextL(entry, dummy) ); |
|
225 TEST(ret==KErrNone); |
|
226 if(entry.iUidType[2] == KApFileTestBadApp) |
|
227 foundBadApp = ETrue; |
|
228 if(entry.iUidType[2] == KApFileTestGoodApp) |
|
229 foundGoodApp = ETrue; |
|
230 } |
|
231 TEST(foundGoodApp); |
|
232 TEST(!foundBadApp); |
|
233 |
|
234 CleanupStack::PopAndDestroy(2,&fSession); |
|
235 |
|
236 /* |
|
237 * Cleanup |
|
238 */ |
|
239 CleanupRegFilesL(); |
|
240 } |
|
241 |
|
242 /** |
|
243 @SYMTestCaseID UIFRAMEWORKS-APPARC-0051 |
|
244 |
|
245 @SYMDEF INC084770 |
|
246 |
|
247 @SYMTestCaseDesc Test that the AppRegisteredAt check can be overridden |
|
248 |
|
249 @SYMTestPriority High |
|
250 |
|
251 @SYMTestStatus Implemented |
|
252 |
|
253 @SYMTestActions Installs an application for which AppRegisteredAt returns EFalse. Then adds this |
|
254 application to a list of applications for which the results of AppRegisteredAt will be ignored and |
|
255 tests that the application appears in the list of apps. |
|
256 |
|
257 @SYMTestExpectedResults CApaAppList contains the application. |
|
258 */ |
|
259 void CT_File3Step::TestForceRegistrationL() |
|
260 { |
|
261 INFO_PRINTF1(_L("Testing RApaLsSession::ForceRegistrationL()")); |
|
262 |
|
263 /* |
|
264 * Prepare registration files |
|
265 */ |
|
266 CleanupRegFilesL(); |
|
267 |
|
268 // Install the test application |
|
269 iSession.RegisterNonNativeApplicationTypeL(KApFileTestAppType, KLitNativeExecutable); |
|
270 TRAPD(err, PrepareRegFileL(KApFileTestForcedRegistration, iForcedAppRsc, iForcedAppIst)); |
|
271 TEST(err==KErrNone); |
|
272 |
|
273 // Wait for a rescan and check that the application is not in the list |
|
274 RPointerArray<TDesC> dummy; |
|
275 err = iSession.ForceRegistration(dummy); |
|
276 TApaAppInfo info; |
|
277 err = iSession.GetAppInfo(info,KApFileTestForcedRegistration); |
|
278 TEST(err==KErrNotFound); |
|
279 |
|
280 // Add the application to the list of applications that ignore the AppRegisteredAt test |
|
281 RPointerArray<TDesC> regFiles; |
|
282 _LIT(KRegFile2, "test2"); // Add a second dummy registration file just to check that this works |
|
283 regFiles.Append(iForcedAppRsc.AllocL()); |
|
284 regFiles.Append(KRegFile2().AllocL()); |
|
285 err = iSession.ForceRegistration(regFiles); |
|
286 TEST(err==KErrNone); |
|
287 regFiles.ResetAndDestroy(); |
|
288 err = iSession.GetAppInfo(info,KApFileTestForcedRegistration); |
|
289 TEST(err==KErrNone); |
|
290 |
|
291 // triggers a rescan from the sid checker, this will cause the |
|
292 // list to be emptied |
|
293 TRAP(err, PrepareRegFileL(KApTriggerRescan, iTriggerRescanRsc, iTriggerRescanIst)); |
|
294 TEST(err==KErrNone); |
|
295 |
|
296 // Now the app should not be listed anymore as we have removed it from the "force" list |
|
297 err = iSession.ForceRegistration(dummy); |
|
298 err = iSession.GetAppInfo(info,KApFileTestForcedRegistration); |
|
299 TEST(err==KErrNotFound); |
|
300 |
|
301 /* |
|
302 * Cleanup |
|
303 */ |
|
304 CleanupRegFilesL(); |
|
305 } |
|
306 |
|
307 void CT_File3Step::PrepareRegFileL(const TUid& aUid, const TDesC& aRscFile, const TDesC& aLogicalExecutable) |
|
308 { |
|
309 CApaRegistrationResourceFileWriter* const registrationResourceFileWriter = |
|
310 CApaRegistrationResourceFileWriter::NewL(aUid, |
|
311 aLogicalExecutable, |
|
312 TApaAppCapability::ENonNative); |
|
313 CleanupStack::PushL(registrationResourceFileWriter); |
|
314 |
|
315 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
316 iSession.RegisterNonNativeApplicationL(KApFileTestAppType, iDrive, *registrationResourceFileWriter, NULL, NULL); |
|
317 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
318 TBool present = EFalse; |
|
319 User::LeaveIfError(iUtils.IsFilePresent(aRscFile, present)); |
|
320 TEST(present); |
|
321 |
|
322 CleanupStack::PopAndDestroy(registrationResourceFileWriter); |
|
323 } |
|
324 |
|
325 void CT_File3Step::CleanupRegFilesL() |
|
326 { |
|
327 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
328 iSession.DeregisterNonNativeApplicationL(KApFileTestBadApp); |
|
329 iSession.DeregisterNonNativeApplicationL(KApFileTestGoodApp); |
|
330 iSession.DeregisterNonNativeApplicationL(KApFileTestCallBackApp); |
|
331 iSession.DeregisterNonNativeApplicationL(KApFileTestForcedRegistration); |
|
332 iSession.DeregisterNonNativeApplicationL(KApTriggerRescan); |
|
333 iSession.DeregisterNonNativeApplicationL(KApFileTestAppWithMultipleRegistrationFiles); |
|
334 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
335 iSession.DeregisterNonNativeApplicationTypeL(KApFileTestAppType); |
|
336 RFs fSession; |
|
337 User::LeaveIfError(fSession.Connect()); |
|
338 CleanupClosePushL(fSession); |
|
339 CFileMan* fMan = CFileMan::NewL(fSession); |
|
340 CleanupStack::PushL(fMan); |
|
341 TInt err = fMan->Delete(iMmcPrivateDir, CFileMan::ERecurse); |
|
342 if(err != KErrNone && err != KErrNotFound && err != KErrPathNotFound) |
|
343 { |
|
344 User::Leave(err); |
|
345 } |
|
346 CleanupStack::PopAndDestroy(2,&fSession); |
|
347 } |
|
348 |
|
349 /** |
|
350 @SYMTestCaseID UIFRAMEWORKS-APPARC-0052 |
|
351 |
|
352 @SYMDEF INC87806 |
|
353 |
|
354 @SYMTestCaseDesc Test that apparc does not stop scanning its list of registration files after scanning a corrupted registration file. |
|
355 |
|
356 @SYMTestPriority High |
|
357 |
|
358 @SYMTestStatus Implemented |
|
359 |
|
360 @SYMTestActions Copy a corrupted registration file into C:\\Private\\10003a3f\\import\\apps\\. Register a non-native application. Force apparc to rescan. Since non-native applications |
|
361 are scanned after native ones, we eliminate the risk that the corrupted registration file is scanned after the non-native one. Call GetAppInfo on non-native application. |
|
362 |
|
363 @SYMTestExpectedResults Apparc successfully scans the non-native app. Calling GetAppInfo on the non-native app returns KErrNone. |
|
364 */ |
|
365 void CT_File3Step::TestCorruptedRegFileL() |
|
366 { |
|
367 INFO_PRINTF1(_L("TestCorruptedRegFileL about to start...")); |
|
368 _LIT(KCorruptedSourceFileName, "Z:\\ApparcTest\\Corrupted_reg.RSC"); // corrupted_reg.rsc file is pre-built. |
|
369 _LIT(KCorruptedTargetFileName, "C:\\Private\\10003a3f\\import\\apps\\Corrupted_reg.RSC"); |
|
370 _LIT(KDir, "C:\\private\\10003a3f\\import\\apps\\"); |
|
371 _LIT(KNonNativeFileName,"C:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\NonCorrupted_reg.rsc"); |
|
372 _LIT(KLitNoncorruptedExe, "z:\\sys\\bin\\NonCorrupted.exe"); |
|
373 const TUid KNonCorruptedAppUid = {0x102826DE}; |
|
374 |
|
375 RFs fs; |
|
376 User::LeaveIfError(fs.Connect()); |
|
377 CleanupClosePushL(fs); |
|
378 TInt ret = fs.MkDirAll(KDir); |
|
379 if (ret != KErrAlreadyExists) |
|
380 { |
|
381 User::LeaveIfError(ret); |
|
382 } |
|
383 CFileMan* fileManager = CFileMan::NewL(fs); |
|
384 CleanupStack::PushL(fileManager); |
|
385 ret = fileManager->Copy(KCorruptedSourceFileName, KCorruptedTargetFileName, CFileMan::EOverWrite); |
|
386 TEST(ret==KErrNone); |
|
387 |
|
388 CApaRegistrationResourceFileWriter* const registrationResourceFileWriter=CApaRegistrationResourceFileWriter::NewL(KNonCorruptedAppUid,KNonNativeFileName,TApaAppCapability::ENonNative); |
|
389 CleanupStack::PushL(registrationResourceFileWriter); |
|
390 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
391 iSession.RegisterNonNativeApplicationTypeL(KApFileTestAppType,KLitNoncorruptedExe); |
|
392 iSession.RegisterNonNativeApplicationL(KApFileTestAppType, EDriveC, *registrationResourceFileWriter, NULL, NULL); |
|
393 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
394 |
|
395 RPointerArray<TDesC> empty; |
|
396 ret = iSession.ForceRegistration(empty); |
|
397 TEST(ret==KErrNone); |
|
398 TApaAppInfo appInfo; |
|
399 ret = iSession.GetAppInfo(appInfo,KNonCorruptedAppUid); |
|
400 TEST(ret==KErrNone); |
|
401 |
|
402 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
403 iSession.DeregisterNonNativeApplicationL(KNonCorruptedAppUid); |
|
404 iSession.DeregisterNonNativeApplicationTypeL(KApFileTestAppType); |
|
405 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
406 fileManager->RmDir(KDir); |
|
407 |
|
408 CleanupStack::PopAndDestroy(registrationResourceFileWriter); |
|
409 CleanupStack::PopAndDestroy(fileManager); |
|
410 CleanupStack::PopAndDestroy(&fs); |
|
411 } |
|
412 |
|
413 /** |
|
414 @SYMTestCaseID UIFRAMEWORKS-APPARC-0102 |
|
415 |
|
416 @SYMDEF PDEF139147 |
|
417 |
|
418 @SYMTestCaseDesc Test that apparc calls sid checker only once for multiple registration resource file for same application. |
|
419 |
|
420 @SYMTestPriority High |
|
421 |
|
422 @SYMTestStatus Implemented |
|
423 |
|
424 @SYMTestActions Make copies of a registration resource file in the removable drive. Plugin implementing the ApSidChecker |
|
425 interface will set a Pub&Sub value everytime it is called. Check that it has been called only once. |
|
426 |
|
427 @SYMTestExpectedResults Pub&Sub value has been set only once by the SidChecker plugin. |
|
428 */ |
|
429 void CT_File3Step::TestMultipleRegistrationFilesForSameAppL() |
|
430 { |
|
431 INFO_PRINTF1(_L("Testing Multiple registration files for same application")); |
|
432 |
|
433 //Cleanup registration files |
|
434 CleanupRegFilesL(); |
|
435 |
|
436 // Install the test application |
|
437 iSession.RegisterNonNativeApplicationTypeL(KApFileTestAppType, KLitNativeExecutable); |
|
438 TRAPD(err, PrepareRegFileL(KApFileTestAppWithMultipleRegistrationFiles, iAppRsc1, iAppIst)); |
|
439 TEST(err==KErrNone); |
|
440 INFO_PRINTF1(_L("Reg File 1 commited")); |
|
441 |
|
442 RFs fs; |
|
443 User::LeaveIfError(fs.Connect()); |
|
444 CleanupClosePushL(fs); |
|
445 TInt ret = fs.MkDirAll(KMmcPrivateDir); |
|
446 if (ret != KErrAlreadyExists) |
|
447 { |
|
448 User::LeaveIfError(ret); |
|
449 } |
|
450 CFileMan* fileManager = CFileMan::NewL(fs); |
|
451 CleanupStack::PushL(fileManager); |
|
452 //Make copies of the registration resource files. |
|
453 ret = fileManager->Copy(iAppRsc1, iAppRsc2, CFileMan::EOverWrite); |
|
454 TEST(ret==KErrNone); |
|
455 TBool present = EFalse; |
|
456 User::LeaveIfError(iUtils.IsFilePresent(iAppRsc2, present)); |
|
457 TEST(present); |
|
458 INFO_PRINTF1(_L("Reg File 2 created")); |
|
459 |
|
460 ret = fileManager->Copy(iAppRsc1, iAppRsc3, CFileMan::EOverWrite); |
|
461 TEST(ret==KErrNone); |
|
462 present = EFalse; |
|
463 User::LeaveIfError(iUtils.IsFilePresent(iAppRsc3, present)); |
|
464 TEST(present); |
|
465 INFO_PRINTF1(_L("Reg File 3 created")); |
|
466 |
|
467 TProcessPriority oldPriority = RProcess().Priority(); |
|
468 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
469 |
|
470 TRequestStatus status; |
|
471 RProperty property; |
|
472 CleanupClosePushL(property); |
|
473 User::LeaveIfError(RProperty::Set(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, CTestSidChecker::EPropertyDefault)); |
|
474 User::LeaveIfError(property.Attach(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey)); |
|
475 property.Subscribe(status); |
|
476 |
|
477 RTimer timer; |
|
478 CleanupClosePushL(timer); |
|
479 User::LeaveIfError(timer.CreateLocal()); |
|
480 TRequestStatus timerStatus; |
|
481 timer.After(timerStatus,50 * 1000000); |
|
482 |
|
483 RPointerArray<TDesC> empty; |
|
484 ret = iSession.ForceRegistration(empty); |
|
485 TEST(ret==KErrNone); |
|
486 |
|
487 // Wait for a rescan |
|
488 User::WaitForRequest(status,timerStatus); |
|
489 TEST(status != KRequestPending); |
|
490 if(status != KRequestPending) |
|
491 { |
|
492 timer.Cancel(); |
|
493 User::WaitForRequest(timerStatus); |
|
494 TInt result; |
|
495 User::LeaveIfError(RProperty::Get(KApFileTestPubSubCategory, KApFileTestPubSubCallBackKey, result)); |
|
496 TEST(result == CTestSidChecker::ECheckedOnce); |
|
497 } |
|
498 else |
|
499 { |
|
500 property.Cancel(); |
|
501 User::WaitForRequest(status); |
|
502 TEST(timerStatus != KRequestPending); |
|
503 INFO_PRINTF1(_L("Timeout exceeded")); |
|
504 } |
|
505 |
|
506 RProcess().SetPriority(oldPriority); |
|
507 |
|
508 INFO_PRINTF1(_L("Removing duplicate reg files")); |
|
509 TTime tempTime(0); // added tempTime to avoid asynch CFileMan::Attribs request completing with KErrArgument |
|
510 |
|
511 TEST(fileManager->Attribs(iAppRsc2,0,KEntryAttReadOnly,tempTime,CFileMan::ERecurse,status)==KErrNone); |
|
512 User::WaitForRequest(status); |
|
513 TEST(status.Int()==KErrNone); |
|
514 TEST(KErrNone==fileManager->Delete(iAppRsc2,CFileMan::ERecurse)); |
|
515 |
|
516 TEST(fileManager->Attribs(iAppRsc3,0,KEntryAttReadOnly,tempTime,CFileMan::ERecurse,status)==KErrNone); |
|
517 User::WaitForRequest(status); |
|
518 TEST(status.Int()==KErrNone); |
|
519 TEST(KErrNone==fileManager->Delete(iAppRsc3,CFileMan::ERecurse)); |
|
520 |
|
521 CleanupStack::PopAndDestroy(4,&fs); |
|
522 CleanupRegFilesL(); |
|
523 } |
|
524 |
|
525 void CT_File3Step::FindRemovableDriveAndSetPathL() |
|
526 { |
|
527 #if defined(__WINS__) |
|
528 // The removable media is expected at X: on emulator. |
|
529 iDrive = EDriveX; |
|
530 #else |
|
531 |
|
532 RFs fs; |
|
533 User::LeaveIfError(fs.Connect()); |
|
534 |
|
535 // The removable media is expected at D: on NAND ROM and at E: on normal ROMs. |
|
536 //The following code works on techview but not guaranteed to work on all platforms. |
|
537 TDriveInfo driveInfo; |
|
538 TInt err = fs.Drive(driveInfo, EDriveD); |
|
539 if(err == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0)) |
|
540 { |
|
541 // Use drive D |
|
542 iDrive = EDriveD; |
|
543 } |
|
544 else |
|
545 { |
|
546 err = fs.Drive(driveInfo, EDriveE); |
|
547 if(err == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0)) |
|
548 { |
|
549 // Use drive E |
|
550 iDrive = EDriveE; |
|
551 } |
|
552 } |
|
553 fs.Close(); |
|
554 #endif |
|
555 iCallBackAppRsc = iDrive.Name(); |
|
556 iCallBackAppIst = iDrive.Name(); |
|
557 iBadAppRsc = iDrive.Name(); |
|
558 iBadAppIst = iDrive.Name(); |
|
559 iGoodAppRsc = iDrive.Name(); |
|
560 iGoodAppIst = iDrive.Name(); |
|
561 iForcedAppRsc = iDrive.Name(); |
|
562 iForcedAppIst = iDrive.Name(); |
|
563 iTriggerRescanRsc = iDrive.Name(); |
|
564 iTriggerRescanIst = iDrive.Name(); |
|
565 iMmcPrivateDir = iDrive.Name(); |
|
566 iAppRsc1 = iDrive.Name(); |
|
567 iAppRsc2 = iDrive.Name(); |
|
568 iAppRsc3 = iDrive.Name(); |
|
569 iAppIst = iDrive.Name(); |
|
570 |
|
571 iCallBackAppRsc.Append(KCallBackAppRsc); |
|
572 iCallBackAppIst.Append(KCallBackAppIst); |
|
573 iBadAppRsc.Append(KBadAppRsc); |
|
574 iBadAppIst.Append(KBadAppIst); |
|
575 iGoodAppRsc.Append(KGoodAppRsc); |
|
576 iGoodAppIst.Append(KGoodAppIst); |
|
577 iForcedAppRsc.Append(KForcedAppRsc); |
|
578 iForcedAppIst.Append(KForcedAppIst); |
|
579 iTriggerRescanRsc.Append(KTriggerRescanRsc); |
|
580 iTriggerRescanIst.Append(KTriggerRescanIst); |
|
581 iMmcPrivateDir.Append(KMmcPrivateDir); |
|
582 iAppRsc1.Append(KAppRsc1); |
|
583 iAppRsc2.Append(KAppRsc2); |
|
584 iAppRsc3.Append(KAppRsc3); |
|
585 iAppIst.Append(KAppIst); |
|
586 } |
|
587 |
|
588 TVerdict CT_File3Step::doTestStepPostambleL() |
|
589 /** |
|
590 @return - TVerdict code |
|
591 Override of base class virtual |
|
592 */ |
|
593 { |
|
594 iSession.Close(); |
|
595 iUtils.Close(); |
|
596 return TestStepResult(); |
|
597 } |
|
598 |
|
599 CT_File3Step::~CT_File3Step() |
|
600 /** |
|
601 Destructor |
|
602 */ |
|
603 { |
|
604 } |