265 INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL")); |
277 INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL")); |
266 RSmlTestUtils fs; |
278 RSmlTestUtils fs; |
267 CleanupClosePushL(fs); |
279 CleanupClosePushL(fs); |
268 User::LeaveIfError(fs.Connect()); |
280 User::LeaveIfError(fs.Connect()); |
269 |
281 |
270 _LIT(KImportAppsDir,"c:\\private\\10003a3f\\import\\apps\\"); |
|
271 |
|
272 TInt err = fs.CreateDirectoryL(KImportAppsDir); |
282 TInt err = fs.CreateDirectoryL(KImportAppsDir); |
273 TESTEL((err == KErrNone || err == KErrAlreadyExists), err); |
283 TESTEL((err == KErrNone || err == KErrAlreadyExists), err); |
274 INFO_PRINTF1(_L("c:\\private\\10003a3f\\import\\apps is created successfully or already exists")); |
284 INFO_PRINTF1(_L("c:\\private\\10003a3f\\import\\apps is created successfully or already exists")); |
275 |
285 |
276 |
286 //Make sure that the target file does not exist. |
|
287 DeleteFileL(fs, KAppRscTargetPath); |
|
288 |
277 // Copy TestUpdRegAppUninstallation_reg.rsc from z:\ to c:\private\10003a3f\import\apps\. |
289 // Copy TestUpdRegAppUninstallation_reg.rsc from z:\ to c:\private\10003a3f\import\apps\. |
278 _LIT(KAppRscSourcePath,"z:\\system\\data\\TestUpdRegAppUninstallation_reg.rsc"); |
|
279 _LIT(KAppRscTargetPath,"c:\\private\\10003a3f\\import\\apps\\TestUpdRegAppUninstallation_reg.rsc"); |
|
280 |
|
281 err = fs.CopyFileL(KAppRscSourcePath, KAppRscTargetPath); |
290 err = fs.CopyFileL(KAppRscSourcePath, KAppRscTargetPath); |
282 TEST(err == KErrNone); |
291 TEST(err == KErrNone); |
283 INFO_PRINTF1(_L("Successfully copied TestUpdRegAppUninstallati on_reg.rsc from Z:\\system\\data to c:\\private\\10003a3f\\import\\apps")); |
292 INFO_PRINTF1(_L("Successfully copied TestUpdRegAppUninstallation_reg.rsc from Z:\\system\\data to c:\\private\\10003a3f\\import\\apps")); |
|
293 |
|
294 //Wait till the applist is updated. |
|
295 WaitForAppListUpdateL(); |
284 |
296 |
285 CServiceRegistry* registry = CServiceRegistry::NewL(); |
297 CServiceRegistry* registry = CServiceRegistry::NewL(); |
286 CleanupStack::PushL(registry); |
298 CleanupStack::PushL(registry); |
287 |
299 |
288 //Wait till the application scanning is completed. |
300 TUid appUid = {0x10207f80}; |
|
301 TUid resultUid={KNullUidValue}; |
|
302 TDataType dataType (KLitMimeType); |
|
303 |
|
304 //Test whether 0x10207f80 application is in application list. |
|
305 TApaAppInfo appInfo; |
|
306 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
|
307 |
|
308 //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type. |
|
309 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
|
310 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
|
311 TEST(appUid==resultUid); |
|
312 |
|
313 //Delete file c:\\private\\10003a3f\\import\\apps\\TestUpdRegAppUninstallation_reg.rsc |
|
314 DeleteFileL(fs, KAppRscTargetPath); |
|
315 |
|
316 //Wait till the application list is updated. |
|
317 WaitForAppListUpdateL(); |
|
318 |
|
319 //Check the application is removed from the application list |
|
320 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNotFound); |
|
321 |
|
322 //Check data mappings related to uninstalled applicaiton is also removed. |
|
323 TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNotFound); |
|
324 |
|
325 CleanupStack::PopAndDestroy(registry); |
|
326 CleanupStack::PopAndDestroy(&fs); |
|
327 } |
|
328 |
|
329 void CTestApplistChangeObserver::HandleAppListEvent(TInt /*aEvent*/) |
|
330 { |
|
331 CActiveScheduler::Stop(); |
|
332 } |
|
333 |
|
334 /** |
|
335 @SYMTestCaseID APPFWK-APPARC-0105 |
|
336 |
|
337 @SYMDEF INC138417 |
|
338 |
|
339 @SYMTestCaseDesc Tests whether a data mapping of an applicaiton is not changed in |
|
340 service registry if that applicaiton is upgraded. |
|
341 |
|
342 @SYMTestPriority |
|
343 |
|
344 @SYMTestStatus Implemented |
|
345 |
|
346 @SYMTestActions Inserts data mapping for an applicaion and upgrades that application with newer version. |
|
347 Tests the existence of inserted data mapping in the service registry. |
|
348 |
|
349 @SYMTestExpectedResults Inserted data mapping is not removed from the service registry. |
|
350 */ |
|
351 |
|
352 void CT_ServiceRegistryTestStep::TestServiceRegistryOnAppUpgradeL(RApaLsSession& aLs) |
|
353 { |
|
354 INFO_PRINTF1(_L("TestServiceRegistryOnAppUpgrade")); |
|
355 |
|
356 RSmlTestUtils fs; |
|
357 CleanupClosePushL(fs); |
|
358 User::LeaveIfError(fs.Connect()); |
|
359 |
|
360 TInt err = fs.CreateDirectoryL(KImportAppsDir); |
|
361 TESTEL((err == KErrNone || err == KErrAlreadyExists), err); |
|
362 INFO_PRINTF1(_L("c:\\private\\10003a3f\\import\\apps is created successfully or already exists")); |
|
363 |
|
364 //Make sure that the target file does not exist. |
|
365 DeleteFileL(fs, KAppRscTargetPath); |
|
366 |
|
367 // Copy TestUpdRegAppUninstallation_reg.rsc from z:\ to c:\private\10003a3f\import\apps\. |
|
368 err = fs.CopyFileL(KAppRscSourcePath, KAppRscTargetPath); |
|
369 TEST(err == KErrNone); |
|
370 INFO_PRINTF1(_L("Successfully copied TestUpdRegAppUninstallation_reg.rsc from Z:\\system\\data to c:\\private\\10003a3f\\import\\apps")); |
|
371 |
|
372 //Wait till the applist is updated. |
|
373 WaitForAppListUpdateL(); |
|
374 |
|
375 CServiceRegistry* registry = CServiceRegistry::NewL(); |
|
376 CleanupStack::PushL(registry); |
|
377 |
|
378 TUid appUid = {0x10207f80}; |
|
379 TUid resultUid={KNullUidValue}; |
|
380 TDataType dataType (KLitMimeType); |
|
381 |
|
382 //Test whether 0x10207f80 application is in application list. |
|
383 TApaAppInfo appInfo; |
|
384 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
|
385 |
|
386 //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type. |
|
387 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
|
388 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
|
389 TEST(appUid==resultUid); |
|
390 |
|
391 TDataType upgDataType(KLitUpgradeAppMimeType); |
|
392 err=aLs.AppForDataType(upgDataType,resultUid); |
|
393 TEST(resultUid.iUid==KNullUidValue); |
|
394 |
|
395 DeleteFileL(fs, KAppRscTargetPath); |
|
396 |
|
397 err = fs.CopyFileL(KUpgradeAppRscSourcePath, KAppRscTargetPath); |
|
398 TEST(err == KErrNone); |
|
399 INFO_PRINTF1(_L("Successfully copied TestUpgradeUpdRegAppUninstallation_reg.rsc from Z:\\system\\data to c:\\private\\10003a3f\\import\\apps")); |
|
400 |
|
401 //Change the modified time of the file to current time |
|
402 RFs aFs; |
|
403 TEST(aFs.Connect()==KErrNone); |
|
404 TTime modifiedTime(0); |
|
405 modifiedTime.HomeTime(); |
|
406 TEST(aFs.SetModified(KAppRscTargetPath, modifiedTime)==KErrNone); |
|
407 aFs.Close(); |
|
408 |
|
409 //Wait till the applist is updated. |
|
410 WaitForAppListUpdateL(); |
|
411 |
|
412 //Check the application is not removed from the application list |
|
413 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
|
414 |
|
415 //Check data mappings related to upgraded applicaiton is not removed. |
|
416 TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNone); |
|
417 TEST(resultUid==appUid); |
|
418 |
|
419 err=aLs.AppForDataType(upgDataType,resultUid); |
|
420 TEST((err==KErrNone) && (resultUid==appUid)); |
|
421 |
|
422 DeleteFileL(fs,KAppRscTargetPath); |
|
423 |
|
424 CleanupStack::PopAndDestroy(registry); |
|
425 CleanupStack::PopAndDestroy(&fs); |
|
426 } |
|
427 |
|
428 |
|
429 //Deletes the file if it exists. |
|
430 TInt CT_ServiceRegistryTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName) |
|
431 { |
|
432 TInt fileExists = EFalse; |
|
433 TInt err; |
|
434 aFs.IsFilePresent(aFileName, fileExists); |
|
435 if (fileExists) |
|
436 { |
|
437 aFs.ChangeFilePermissionL(aFileName); |
|
438 err=aFs.DeleteFileL(aFileName); |
|
439 if(err==KErrNone) |
|
440 INFO_PRINTF2(_L("Removed file %S"), &aFileName); |
|
441 else |
|
442 INFO_PRINTF2(_L("Failed to remove file %S"), &aFileName); |
|
443 } |
|
444 else |
|
445 { |
|
446 err=KErrNotFound; |
|
447 } |
|
448 |
|
449 return(err); |
|
450 } |
|
451 |
|
452 //Wait till the application list is updated. |
|
453 void CT_ServiceRegistryTestStep::WaitForAppListUpdateL() |
|
454 { |
289 CTestApplistChangeObserver* obs = new(ELeave) CTestApplistChangeObserver(); |
455 CTestApplistChangeObserver* obs = new(ELeave) CTestApplistChangeObserver(); |
290 CleanupStack::PushL(obs); |
456 CleanupStack::PushL(obs); |
291 CApaAppListNotifier* notif = CApaAppListNotifier::NewL(obs, CActive::EPriorityHigh); |
457 CApaAppListNotifier* notif = CApaAppListNotifier::NewL(obs, CActive::EPriorityHigh); |
292 CleanupStack::PushL(notif); |
458 CleanupStack::PushL(notif); |
293 obs->iNotifier = notif; |
459 obs->iNotifier = notif; |
294 CActiveScheduler::Start(); |
460 CActiveScheduler::Start(); |
295 INFO_PRINTF1(_L("Applicaiton scanning is completed.")); |
461 |
296 CleanupStack::PopAndDestroy(notif); |
462 CleanupStack::PopAndDestroy(notif); |
297 |
463 CleanupStack::PopAndDestroy(obs); |
298 TUid uid1 = {0x10207f80}; |
464 INFO_PRINTF1(_L("Applicaiton list is updated.")); |
299 TUid resultUid={KNullUidValue}; |
|
300 _LIT8(KLitMimeType,"mime/updregappuninstall"); |
|
301 TDataType dataType (KLitMimeType); |
|
302 |
|
303 //Test whether 0x10207f80 application is in application list. |
|
304 TApaAppInfo appInfo; |
|
305 TEST(aLs.GetAppInfo(appInfo,uid1)==KErrNone); |
|
306 |
|
307 //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type. |
|
308 registry->SetDefault(KOpenServiceUid,dataType, uid1); |
|
309 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
|
310 TEST(uid1==resultUid); |
|
311 |
|
312 TInt fileExists = EFalse; |
|
313 fs.IsFilePresent(KAppRscTargetPath, fileExists); |
|
314 if (fileExists) |
|
315 { |
|
316 fs.ChangeFilePermissionL(KAppRscTargetPath); // clear readonly attribute inherited from z: |
|
317 err = fs.DeleteFileL(KAppRscTargetPath); |
|
318 if(err == KErrNone) |
|
319 INFO_PRINTF1(_L("Removed file TestUpdRegAppUninstallation_reg.rsc")); |
|
320 else |
|
321 INFO_PRINTF1(_L("Failed to remove TestUpdRegAppUninstallation_reg.rsc")); |
|
322 } |
|
323 |
|
324 //Wait till the application scanning is completed |
|
325 notif = CApaAppListNotifier::NewL(obs, CActive::EPriorityHigh); |
|
326 CleanupStack::PushL(notif); |
|
327 obs->iNotifier = notif; |
|
328 CActiveScheduler::Start(); |
|
329 INFO_PRINTF1(_L("Applicaiton scanning is completed.")); |
|
330 CleanupStack::PopAndDestroy(notif); |
|
331 CleanupStack::PopAndDestroy(obs); |
|
332 |
|
333 //Check the application is removed form the application list |
|
334 TEST(aLs.GetAppInfo(appInfo,uid1)==KErrNotFound); |
|
335 |
|
336 //Check data mappings related to uninstalled applicaiton is also removed. |
|
337 TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNotFound); |
|
338 |
|
339 CleanupStack::PopAndDestroy(registry); |
|
340 CleanupStack::PopAndDestroy(&fs); |
|
341 } |
465 } |
342 |
|
343 void CTestApplistChangeObserver::HandleAppListEvent(TInt /*aEvent*/) |
|
344 { |
|
345 CActiveScheduler::Stop(); |
|
346 } |
|