23 #include <serviceregistry.h> |
23 #include <serviceregistry.h> |
24 #include "testableapalssession.h" |
24 #include "testableapalssession.h" |
25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
26 #include <apaidpartner.h> |
26 #include <apaidpartner.h> |
27 #endif |
27 #endif |
28 #include "T_SisFileInstaller.h" |
28 |
29 |
29 |
30 _LIT(KTstAppStandAloneSisFile, "z:\\apparctest\\apparctestsisfiles\\TSTAPP_standalone.sis"); |
30 |
31 _LIT(KTstAppStandAloneComponent, "TSTAPP_standalone"); |
31 _LIT(KImportAppsDir,"c:\\private\\10003a3f\\import\\apps\\"); |
32 |
32 _LIT(KAppRscSourcePath,"z:\\system\\data\\TestUpdRegAppUninstallation_reg.rsc"); |
33 _LIT(KServerApp2SisFile, "z:\\apparctest\\apparctestsisfiles\\serverapp2.sis"); |
33 _LIT(KUpgradeAppRscSourcePath,"z:\\system\\data\\TestUpgradeUpdRegAppUninstallation_reg.rsc"); |
34 _LIT(KServerApp2Component, "serverapp2"); |
34 _LIT(KAppRscTargetPath,"c:\\private\\10003a3f\\import\\apps\\TestUpdRegAppUninstallation_reg.rsc"); |
35 |
|
36 _LIT(KApparcTestAppSisFile, "z:\\apparctest\\apparctestsisfiles\\TApparcTestApp.sis"); |
|
37 _LIT(KApparcTestAppComponent, "TApparcTestApp"); |
|
38 |
35 |
39 _LIT8(KLitMimeType,"mime/updregappuninstall"); |
36 _LIT8(KLitMimeType,"mime/updregappuninstall"); |
|
37 _LIT8(KLitUpgradeAppMimeType,"mime/upgradeupdregappuninstall"); |
40 |
38 |
41 /** |
39 /** |
42 * Constructor |
40 * Constructor |
43 */ |
41 */ |
44 CT_ServiceRegistryTestStep::CT_ServiceRegistryTestStep() |
42 CT_ServiceRegistryTestStep::CT_ServiceRegistryTestStep() |
58 * @return - TVerdict code |
56 * @return - TVerdict code |
59 * Override of base class virtual |
57 * Override of base class virtual |
60 */ |
58 */ |
61 TVerdict CT_ServiceRegistryTestStep::doTestStepPreambleL() |
59 TVerdict CT_ServiceRegistryTestStep::doTestStepPreambleL() |
62 { |
60 { |
63 CSisFileInstaller sisFileInstaller; |
|
64 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KServerApp2SisFile); |
|
65 sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KServerApp2SisFile); |
|
66 |
|
67 SetTestStepResult(EPass); |
61 SetTestStepResult(EPass); |
68 return TestStepResult(); |
62 return TestStepResult(); |
69 } |
63 } |
70 |
64 |
71 /** |
65 /** |
72 * @return - TVerdict code |
66 * @return - TVerdict code |
73 * Override of base class virtual |
67 * Override of base class virtual |
74 */ |
68 */ |
75 TVerdict CT_ServiceRegistryTestStep::doTestStepPostambleL() |
69 TVerdict CT_ServiceRegistryTestStep::doTestStepPostambleL() |
76 { |
70 { |
77 CSisFileInstaller sisFileInstaller; |
|
78 sisFileInstaller.UninstallSisL(KServerApp2Component); |
|
79 |
|
80 return TestStepResult(); |
71 return TestStepResult(); |
81 } |
72 } |
82 |
73 |
83 TVerdict CT_ServiceRegistryTestStep::doTestStepL() |
74 TVerdict CT_ServiceRegistryTestStep::doTestStepL() |
84 { |
75 { |
102 TInt CT_ServiceRegistryTestStep::RunTestCasesL() |
93 TInt CT_ServiceRegistryTestStep::RunTestCasesL() |
103 { |
94 { |
104 RTestableApaLsSession ls; |
95 RTestableApaLsSession ls; |
105 TEST(KErrNone == ls.Connect()); |
96 TEST(KErrNone == ls.Connect()); |
106 CleanupClosePushL(ls); |
97 CleanupClosePushL(ls); |
107 |
|
108 TApaAppInfo info; |
|
109 TUid uid = {0x100048F3}; |
|
110 TInt err = ls.GetAppInfo(info, uid); |
|
111 if(err == KErrNone) |
|
112 { |
|
113 CSisFileInstaller sisFileInstaller; |
|
114 sisFileInstaller.UninstallSisL(KApparcTestAppComponent); |
|
115 } |
|
116 |
98 |
117 // Use DONT_CHECK because it complaints of heap unbalance (a CTypeStoreManager object, althought it is not actually leaked, |
99 // Use DONT_CHECK because it complaints of heap unbalance (a CTypeStoreManager object, althought it is not actually leaked, |
118 // but reallocated in CApaAppListServer::DoUpdateTypeStoreL(void)). |
100 // but reallocated in CApaAppListServer::DoUpdateTypeStoreL(void)). |
119 // This unbalance happens 'randonmly', possibly a timing issue, as the TypeStore refresh is performed in response to a callback from |
101 // This unbalance happens 'randonmly', possibly a timing issue, as the TypeStore refresh is performed in response to a callback from |
120 // a CApaFsMonitor object, which introduces an extra 0.25 second delay before invoking the callback. |
102 // a CApaFsMonitor object, which introduces an extra 0.25 second delay before invoking the callback. |
121 // *** See DEF101056 **** |
103 // *** See DEF101056 **** |
122 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAssociation1L(), NO_CLEANUP); |
104 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAssociation1L(), NO_CLEANUP); |
123 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
124 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAppForDataTypeAndServiceL(ls), NO_CLEANUP); |
105 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAppForDataTypeAndServiceL(ls), NO_CLEANUP); |
125 #endif |
|
126 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestUpdateOfServiceRegistryOnAppUninstallationL(ls), NO_CLEANUP); |
106 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestUpdateOfServiceRegistryOnAppUninstallationL(ls), NO_CLEANUP); |
127 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestServiceRegistryOnAppUpgradeL(ls), NO_CLEANUP); |
107 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestServiceRegistryOnAppUpgradeL(ls), NO_CLEANUP); |
128 |
108 |
129 CleanupStack::PopAndDestroy(&ls); |
109 CleanupStack::PopAndDestroy(&ls); |
130 return KErrNone; |
110 return KErrNone; |
297 INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL")); |
277 INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL")); |
298 RSmlTestUtils fs; |
278 RSmlTestUtils fs; |
299 CleanupClosePushL(fs); |
279 CleanupClosePushL(fs); |
300 User::LeaveIfError(fs.Connect()); |
280 User::LeaveIfError(fs.Connect()); |
301 |
281 |
302 CSisFileInstaller sisFileInstaller; |
282 TInt err = fs.CreateDirectoryL(KImportAppsDir); |
303 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KApparcTestAppSisFile); |
283 TESTEL((err == KErrNone || err == KErrAlreadyExists), err); |
304 sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KApparcTestAppSisFile); |
284 INFO_PRINTF1(_L("c:\\private\\10003a3f\\import\\apps is created successfully or already exists")); |
305 |
285 |
|
286 //Make sure that the target file does not exist. |
|
287 DeleteFileL(fs, KAppRscTargetPath); |
|
288 |
|
289 // Copy TestUpdRegAppUninstallation_reg.rsc from z:\ to c:\private\10003a3f\import\apps\. |
|
290 err = fs.CopyFileL(KAppRscSourcePath, KAppRscTargetPath); |
|
291 TEST(err == KErrNone); |
|
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(); |
|
296 |
306 CServiceRegistry* registry = CServiceRegistry::NewL(); |
297 CServiceRegistry* registry = CServiceRegistry::NewL(); |
307 CleanupStack::PushL(registry); |
298 CleanupStack::PushL(registry); |
308 |
299 |
309 TUid appUid = {0x100048f3}; |
300 TUid appUid = {0x10207f80}; |
310 TUid resultUid={KNullUidValue}; |
301 TUid resultUid={KNullUidValue}; |
311 TDataType dataType (KLitMimeType); |
302 TDataType dataType (KLitMimeType); |
312 |
303 |
313 //Test whether 0x100048f3 application is in application list. |
304 //Test whether 0x10207f80 application is in application list. |
314 TApaAppInfo appInfo; |
305 TApaAppInfo appInfo; |
315 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
306 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
316 |
307 |
317 //Set 0x100048f3 as default application for "mime/updregappuninstall" MIME type. |
308 //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type. |
318 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
309 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
319 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
310 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
320 TEST(appUid==resultUid); |
311 TEST(appUid==resultUid); |
321 |
312 |
322 sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KApparcTestAppComponent); |
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(); |
323 |
318 |
324 //Check the application is removed from the application list |
319 //Check the application is removed from the application list |
325 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNotFound); |
320 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNotFound); |
326 |
321 |
327 //Check data mappings related to uninstalled applicaiton is also removed. |
322 //Check data mappings related to uninstalled applicaiton is also removed. |
356 |
351 |
357 void CT_ServiceRegistryTestStep::TestServiceRegistryOnAppUpgradeL(RApaLsSession& aLs) |
352 void CT_ServiceRegistryTestStep::TestServiceRegistryOnAppUpgradeL(RApaLsSession& aLs) |
358 { |
353 { |
359 INFO_PRINTF1(_L("TestServiceRegistryOnAppUpgrade")); |
354 INFO_PRINTF1(_L("TestServiceRegistryOnAppUpgrade")); |
360 |
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 |
361 CServiceRegistry* registry = CServiceRegistry::NewL(); |
375 CServiceRegistry* registry = CServiceRegistry::NewL(); |
362 CleanupStack::PushL(registry); |
376 CleanupStack::PushL(registry); |
363 |
377 |
364 TUid appUid = {0xA}; |
378 TUid appUid = {0x10207f80}; |
365 TUid resultUid={KNullUidValue}; |
379 TUid resultUid={KNullUidValue}; |
366 TDataType dataType (KLitMimeType); |
380 TDataType dataType (KLitMimeType); |
367 |
381 |
368 //Test whether 0xA application is in application list. |
382 //Test whether 0x10207f80 application is in application list. |
369 TApaAppInfo appInfo; |
383 TApaAppInfo appInfo; |
370 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
384 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
371 |
385 |
372 //Set 0xA as default application for "mime/updregappuninstall" MIME type. |
386 //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type. |
373 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
387 registry->SetDefault(KOpenServiceUid,dataType, appUid); |
374 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
388 registry->GetDefault(KOpenServiceUid,dataType, resultUid); |
375 TEST(appUid==resultUid); |
389 TEST(appUid==resultUid); |
376 |
390 |
377 CSisFileInstaller sisFIleInstaller; |
391 TDataType upgDataType(KLitUpgradeAppMimeType); |
378 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppStandAloneSisFile); |
392 err=aLs.AppForDataType(upgDataType,resultUid); |
379 sisFIleInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppStandAloneSisFile); |
393 TEST(resultUid.iUid==KNullUidValue); |
380 |
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 |
381 //Check the application is not removed from the application list |
412 //Check the application is not removed from the application list |
382 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
413 TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone); |
383 |
414 |
384 //Check data mappings related to upgraded applicaiton is not removed. |
415 //Check data mappings related to upgraded applicaiton is not removed. |
385 TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNone); |
416 TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNone); |
386 TEST(resultUid==appUid); |
417 TEST(resultUid==appUid); |
387 |
418 |
388 sisFIleInstaller.UninstallSisL(KTstAppStandAloneComponent); |
419 err=aLs.AppForDataType(upgDataType,resultUid); |
|
420 TEST((err==KErrNone) && (resultUid==appUid)); |
|
421 |
|
422 DeleteFileL(fs,KAppRscTargetPath); |
389 |
423 |
390 CleanupStack::PopAndDestroy(registry); |
424 CleanupStack::PopAndDestroy(registry); |
|
425 CleanupStack::PopAndDestroy(&fs); |
391 } |
426 } |
392 |
427 |
393 |
428 |
394 //Deletes the file if it exists. |
429 //Deletes the file if it exists. |
395 TInt CT_ServiceRegistryTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName) |
430 TInt CT_ServiceRegistryTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName) |