appfw/apparchitecture/tef/T_ServiceRegistryStep.cpp
branchRCL_3
changeset 19 924385140d98
parent 0 2e3d3ce01487
child 20 c2c61fdca848
equal deleted inserted replaced
18:0818dd463d41 19:924385140d98
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    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 
    28 #include "T_SisFileInstaller.h" 
    29 
    29  
    30 
    30 _LIT(KTstAppStandAloneSisFile, "z:\\apparctest\\apparctestsisfiles\\TSTAPP_standalone.sis");
    31 _LIT(KImportAppsDir,"c:\\private\\10003a3f\\import\\apps\\");
    31 _LIT(KTstAppStandAloneComponent, "TSTAPP_standalone");
    32 _LIT(KAppRscSourcePath,"z:\\system\\data\\TestUpdRegAppUninstallation_reg.rsc");
    32 
    33 _LIT(KUpgradeAppRscSourcePath,"z:\\system\\data\\TestUpgradeUpdRegAppUninstallation_reg.rsc");
    33 _LIT(KServerApp2SisFile, "z:\\apparctest\\apparctestsisfiles\\serverapp2.sis");
    34 _LIT(KAppRscTargetPath,"c:\\private\\10003a3f\\import\\apps\\TestUpdRegAppUninstallation_reg.rsc");
    34 _LIT(KServerApp2Component, "serverapp2");
       
    35 
       
    36 _LIT(KApparcTestAppSisFile, "z:\\apparctest\\apparctestsisfiles\\TApparcTestApp.sis");
       
    37 _LIT(KApparcTestAppComponent, "TApparcTestApp");
    35 
    38 
    36 _LIT8(KLitMimeType,"mime/updregappuninstall");
    39 _LIT8(KLitMimeType,"mime/updregappuninstall");
    37 _LIT8(KLitUpgradeAppMimeType,"mime/upgradeupdregappuninstall");
       
    38 
    40 
    39 /**
    41 /**
    40  * Constructor
    42  * Constructor
    41  */	
    43  */	
    42 CT_ServiceRegistryTestStep::CT_ServiceRegistryTestStep()
    44 CT_ServiceRegistryTestStep::CT_ServiceRegistryTestStep()
    56  * @return - TVerdict code
    58  * @return - TVerdict code
    57  * Override of base class virtual
    59  * Override of base class virtual
    58  */	
    60  */	
    59 TVerdict CT_ServiceRegistryTestStep::doTestStepPreambleL()
    61 TVerdict CT_ServiceRegistryTestStep::doTestStepPreambleL()
    60 	{
    62 	{
       
    63     CSisFileInstaller sisFileInstaller;
       
    64     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KServerApp2SisFile);
       
    65     sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KServerApp2SisFile);
       
    66     
    61 	SetTestStepResult(EPass);
    67 	SetTestStepResult(EPass);
    62 	return TestStepResult();
    68 	return TestStepResult();
    63 	}
    69 	}
    64 
    70 
    65 /**
    71 /**
    66  * @return - TVerdict code
    72  * @return - TVerdict code
    67  * Override of base class virtual
    73  * Override of base class virtual
    68  */
    74  */
    69 TVerdict CT_ServiceRegistryTestStep::doTestStepPostambleL()
    75 TVerdict CT_ServiceRegistryTestStep::doTestStepPostambleL()
    70 	{
    76 	{
       
    77     CSisFileInstaller sisFileInstaller;
       
    78     sisFileInstaller.UninstallSisL(KServerApp2Component);
       
    79     
    71 	return TestStepResult();
    80 	return TestStepResult();
    72 	}
    81 	}
    73 
    82 
    74 TVerdict CT_ServiceRegistryTestStep::doTestStepL()
    83 TVerdict CT_ServiceRegistryTestStep::doTestStepL()
    75 	{
    84 	{
    93 TInt CT_ServiceRegistryTestStep::RunTestCasesL()
   102 TInt CT_ServiceRegistryTestStep::RunTestCasesL()
    94 	{
   103 	{
    95 	RTestableApaLsSession ls;
   104 	RTestableApaLsSession ls;
    96 	TEST(KErrNone == ls.Connect());
   105 	TEST(KErrNone == ls.Connect());
    97 	CleanupClosePushL(ls);
   106 	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         } 
    98 
   116 
    99 	// Use DONT_CHECK because it complaints of heap unbalance (a CTypeStoreManager object, althought it is not actually leaked,
   117 	// Use DONT_CHECK because it complaints of heap unbalance (a CTypeStoreManager object, althought it is not actually leaked,
   100 	//   but reallocated in CApaAppListServer::DoUpdateTypeStoreL(void)). 
   118 	//   but reallocated in CApaAppListServer::DoUpdateTypeStoreL(void)). 
   101 	//   This unbalance happens 'randonmly', possibly a timing issue, as the TypeStore refresh is performed in response to a callback from 
   119 	//   This unbalance happens 'randonmly', possibly a timing issue, as the TypeStore refresh is performed in response to a callback from 
   102 	//	 a CApaFsMonitor object, which introduces an extra 0.25 second delay before invoking the callback.
   120 	//	 a CApaFsMonitor object, which introduces an extra 0.25 second delay before invoking the callback.
   103 	//	 *** See DEF101056 ****
   121 	//	 *** See DEF101056 ****
   104 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAssociation1L(), NO_CLEANUP);
   122 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAssociation1L(), NO_CLEANUP);
       
   123 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   105 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAppForDataTypeAndServiceL(ls), NO_CLEANUP);
   124 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestAppForDataTypeAndServiceL(ls), NO_CLEANUP);
       
   125 #endif	
   106     HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestUpdateOfServiceRegistryOnAppUninstallationL(ls), NO_CLEANUP);
   126     HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestUpdateOfServiceRegistryOnAppUninstallationL(ls), NO_CLEANUP);
   107     HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestServiceRegistryOnAppUpgradeL(ls), NO_CLEANUP);    
   127     HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestServiceRegistryOnAppUpgradeL(ls), NO_CLEANUP);    
   108     
   128     
   109 	CleanupStack::PopAndDestroy(&ls);	
   129 	CleanupStack::PopAndDestroy(&ls);	
   110 	return KErrNone;
   130 	return KErrNone;
   277     INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL"));
   297     INFO_PRINTF1(_L("TestUpdateOfServiceRegistryOnAppUninstallationL"));
   278     RSmlTestUtils fs;
   298     RSmlTestUtils fs;
   279     CleanupClosePushL(fs);
   299     CleanupClosePushL(fs);
   280     User::LeaveIfError(fs.Connect());
   300     User::LeaveIfError(fs.Connect());
   281 
   301 
   282      TInt err = fs.CreateDirectoryL(KImportAppsDir);
   302     CSisFileInstaller sisFileInstaller;
   283      TESTEL((err == KErrNone || err == KErrAlreadyExists), err);
   303     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KApparcTestAppSisFile);
   284      INFO_PRINTF1(_L("c:\\private\\10003a3f\\import\\apps is created successfully or already exists"));
   304     sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KApparcTestAppSisFile);
   285      
   305     
   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 
       
   297      CServiceRegistry* registry = CServiceRegistry::NewL();
   306      CServiceRegistry* registry = CServiceRegistry::NewL();
   298      CleanupStack::PushL(registry);
   307      CleanupStack::PushL(registry);
   299      
   308      
   300      TUid appUid = {0x10207f80};
   309      TUid appUid = {0x100048f3};
   301      TUid resultUid={KNullUidValue};    
   310      TUid resultUid={KNullUidValue};    
   302      TDataType dataType (KLitMimeType);
   311      TDataType dataType (KLitMimeType);
   303      
   312      
   304      //Test whether 0x10207f80 application is in application list.
   313      //Test whether 0x100048f3 application is in application list.
   305      TApaAppInfo appInfo;
   314      TApaAppInfo appInfo;
   306      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   315      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   307 
   316 
   308      //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type.
   317      //Set 0x100048f3 as default application for "mime/updregappuninstall" MIME type.
   309      registry->SetDefault(KOpenServiceUid,dataType, appUid);
   318      registry->SetDefault(KOpenServiceUid,dataType, appUid);
   310      registry->GetDefault(KOpenServiceUid,dataType, resultUid);
   319      registry->GetDefault(KOpenServiceUid,dataType, resultUid);
   311      TEST(appUid==resultUid);
   320      TEST(appUid==resultUid);
   312  
   321  
   313      //Delete file c:\\private\\10003a3f\\import\\apps\\TestUpdRegAppUninstallation_reg.rsc 
   322      sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KApparcTestAppComponent);
   314      DeleteFileL(fs, KAppRscTargetPath);
       
   315      
       
   316      //Wait till the application list is updated.
       
   317      WaitForAppListUpdateL();  
       
   318      
   323      
   319      //Check the application is removed from the application list
   324      //Check the application is removed from the application list
   320      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNotFound);
   325      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNotFound);
   321      
   326      
   322      //Check data mappings related to uninstalled applicaiton is also removed.
   327      //Check data mappings related to uninstalled applicaiton is also removed.
   351 
   356 
   352 void CT_ServiceRegistryTestStep::TestServiceRegistryOnAppUpgradeL(RApaLsSession& aLs)   
   357 void CT_ServiceRegistryTestStep::TestServiceRegistryOnAppUpgradeL(RApaLsSession& aLs)   
   353     {
   358     {
   354     INFO_PRINTF1(_L("TestServiceRegistryOnAppUpgrade"));
   359     INFO_PRINTF1(_L("TestServiceRegistryOnAppUpgrade"));
   355  
   360  
   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();
   361      CServiceRegistry* registry = CServiceRegistry::NewL();
   376      CleanupStack::PushL(registry);
   362      CleanupStack::PushL(registry);
   377      
   363      
   378      TUid appUid = {0x10207f80};
   364      TUid appUid = {0xA};
   379      TUid resultUid={KNullUidValue};    
   365      TUid resultUid={KNullUidValue};    
   380      TDataType dataType (KLitMimeType);
   366      TDataType dataType (KLitMimeType);
   381      
   367      
   382      //Test whether 0x10207f80 application is in application list.
   368      //Test whether 0xA application is in application list.
   383      TApaAppInfo appInfo;
   369      TApaAppInfo appInfo;
   384      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   370      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   385 
   371 
   386      //Set 0x10207f80 as default application for "mime/updregappuninstall" MIME type.
   372      //Set 0xA as default application for "mime/updregappuninstall" MIME type.
   387      registry->SetDefault(KOpenServiceUid,dataType, appUid);
   373      registry->SetDefault(KOpenServiceUid,dataType, appUid);
   388      registry->GetDefault(KOpenServiceUid,dataType, resultUid);
   374      registry->GetDefault(KOpenServiceUid,dataType, resultUid);
   389      TEST(appUid==resultUid);
   375      TEST(appUid==resultUid);
   390      
   376      
   391      TDataType upgDataType(KLitUpgradeAppMimeType);
   377      CSisFileInstaller sisFIleInstaller;
   392      err=aLs.AppForDataType(upgDataType,resultUid);
   378      INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppStandAloneSisFile);
   393      TEST(resultUid.iUid==KNullUidValue);
   379      sisFIleInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppStandAloneSisFile);
   394  
   380      
   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
   381      //Check the application is not removed from the application list
   413      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   382      TEST(aLs.GetAppInfo(appInfo,appUid)==KErrNone);
   414      
   383      
   415      //Check data mappings related to upgraded applicaiton is not removed.
   384      //Check data mappings related to upgraded applicaiton is not removed.
   416      TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNone);
   385      TEST(registry->GetDefault(KOpenServiceUid,dataType, resultUid)==KErrNone);
   417      TEST(resultUid==appUid);
   386      TEST(resultUid==appUid);
   418      
   387      
   419      err=aLs.AppForDataType(upgDataType,resultUid);
   388      sisFIleInstaller.UninstallSisL(KTstAppStandAloneComponent);
   420      TEST((err==KErrNone) && (resultUid==appUid));
       
   421      
       
   422      DeleteFileL(fs,KAppRscTargetPath);
       
   423 
   389 
   424      CleanupStack::PopAndDestroy(registry);
   390      CleanupStack::PopAndDestroy(registry);
   425      CleanupStack::PopAndDestroy(&fs);  
       
   426     }
   391     }
   427 
   392 
   428 
   393 
   429 //Deletes the file if it exists.
   394 //Deletes the file if it exists.
   430 TInt CT_ServiceRegistryTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName)
   395 TInt CT_ServiceRegistryTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName)