installationservices/swi/test/tsisregistrytest/sessionstep.cpp
changeset 60 245df5276b97
parent 42 d17dc5398051
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    44 #include "controllerinfo.h"
    44 #include "controllerinfo.h"
    45 #include "hashcontainer.h"
    45 #include "hashcontainer.h"
    46 #include "sisregistryproperty.h"
    46 #include "sisregistryproperty.h"
    47 
    47 
    48 #include <centralrepository.h>
    48 #include <centralrepository.h>
    49 
    49 #include "sisregistryaccess_client.h"
    50 const TInt KDefaultBufferSize		= 2048;
    50 const TInt KDefaultBufferSize		= 2048;
    51 /////////////////////////////////////////////////////////////////////
    51 /////////////////////////////////////////////////////////////////////
    52 // defs, Constants used by test steps
    52 // defs, Constants used by test steps
    53 /////////////////////////////////////////////////////////////////////
    53 /////////////////////////////////////////////////////////////////////
    54 
    54 
   241 	SetTestStepName(KModifiableFile);
   241 	SetTestStepName(KModifiableFile);
   242 	}
   242 	}
   243 
   243 
   244 TVerdict CModifiableFileStep::doTestStepL()
   244 TVerdict CModifiableFileStep::doTestStepL()
   245 	{
   245 	{
       
   246 
       
   247     
   246 	RArray<TPtrC> theFileNames;
   248 	RArray<TPtrC> theFileNames;
   247 	CleanupClosePushL(theFileNames);
   249 	CleanupClosePushL(theFileNames);
   248 	GetStringArrayFromConfigL(ConfigSection(), KModFileName, theFileNames);
   250 	GetStringArrayFromConfigL(ConfigSection(), KModFileName, theFileNames);
   249 		
   251 		
   250 	RArray<TInt> expectedModifiableTags;
   252 	RArray<TInt> expectedModifiableTags;
  2774 		}	
  2776 		}	
  2775 	CleanupStack::PopAndDestroy(&packages);
  2777 	CleanupStack::PopAndDestroy(&packages);
  2776 	SetTestStepResult(EPass);
  2778 	SetTestStepResult(EPass);
  2777 	return TestStepResult();	
  2779 	return TestStepResult();	
  2778 	}
  2780 	}
       
  2781 
       
  2782 ////////////////////////////////////////////////////////////////////////////
       
  2783 // CAddAppRegInfoStep 
       
  2784 ////////////////////////////////////////////////////////////////////////////
       
  2785 CAddAppRegInfoStep::CAddAppRegInfoStep()
       
  2786     {
       
  2787     SetTestStepName(KIsFileRegisteredStep);
       
  2788     }
       
  2789 
       
  2790 TVerdict CAddAppRegInfoStep::doTestStepL()
       
  2791     {
       
  2792     TPtrC regFileName;
       
  2793     if(!GetStringFromConfig(ConfigSection(), _L("regFileName"), regFileName))
       
  2794         {
       
  2795         ERR_PRINTF1(_L("Reg File Name was not found in ini"));
       
  2796         User::Leave(KErrNotFound);
       
  2797         }
       
  2798     
       
  2799     RSisRegistryAccessSession sisRegistryAccessSessionSession;
       
  2800     User::LeaveIfError(sisRegistryAccessSessionSession.Connect());
       
  2801     CleanupClosePushL(sisRegistryAccessSessionSession);
       
  2802     
       
  2803     TInt res = sisRegistryAccessSessionSession.AddAppRegInfoL(regFileName, iTimeMeasuredExternally );
       
  2804    
       
  2805     if(res != KErrNone)
       
  2806         {
       
  2807         ERR_PRINTF2(_L("Application Registration data not added successfuly , error %d"),res);
       
  2808         User::Leave(res);
       
  2809         }
       
  2810     CleanupStack::Pop(&sisRegistryAccessSessionSession);
       
  2811     SetTestStepResult(EPass);
       
  2812     return TestStepResult();
       
  2813     }
       
  2814 
       
  2815 ////////////////////////////////////////////////////////////////////////////
       
  2816 // CRemoveAppRegInfoStep 
       
  2817 ////////////////////////////////////////////////////////////////////////////
       
  2818 
       
  2819 CRemoveAppRegInfoStep::CRemoveAppRegInfoStep()
       
  2820     {
       
  2821     SetTestStepName(KIsFileRegisteredStep);
       
  2822     }
       
  2823 
       
  2824 TVerdict CRemoveAppRegInfoStep::doTestStepL()
       
  2825     {
       
  2826     TPtrC regFileName;
       
  2827     if(!GetStringFromConfig(ConfigSection(), _L("regFileName"), regFileName))
       
  2828         {
       
  2829         ERR_PRINTF1(_L("Reg File Name was not found in ini"));
       
  2830         User::Leave(KErrNotFound);
       
  2831         }
       
  2832     
       
  2833     RSisRegistryAccessSession sisRegistryAccessSessionSession;
       
  2834     User::LeaveIfError(sisRegistryAccessSessionSession.Connect());
       
  2835     CleanupClosePushL(sisRegistryAccessSessionSession);
       
  2836     
       
  2837     TInt res = sisRegistryAccessSessionSession.RemoveAppRegInfoL(regFileName, iTimeMeasuredExternally );
       
  2838     
       
  2839     if(res != KErrNone)
       
  2840         {
       
  2841         ERR_PRINTF2(_L("Application Registration data not added successfuly , error %d"),res);
       
  2842         User::Leave(res);
       
  2843         }
       
  2844     CleanupStack::PopAndDestroy(&sisRegistryAccessSessionSession);
       
  2845     SetTestStepResult(EPass);
       
  2846     return TestStepResult();
       
  2847     }
       
  2848 
       
  2849 //////////////////////
       
  2850 //////CheckAppRegData
       
  2851 /////////////////////
       
  2852 
       
  2853 CheckAppRegData::CheckAppRegData()
       
  2854     {
       
  2855     SetTestStepName(KIsFileRegisteredStep);
       
  2856     }
       
  2857 
       
  2858 TVerdict CheckAppRegData::doTestStepL()
       
  2859     {
       
  2860     SetTestStepResult(EPass);
       
  2861     // Verify if the reg data is removed properly or not
       
  2862     TBool isAppDataExists(EFalse);
       
  2863     Usif::RSoftwareComponentRegistry scrSession;            
       
  2864     User::LeaveIfError(scrSession.Connect());
       
  2865     CleanupClosePushL(scrSession);
       
  2866     GetBoolFromConfig(ConfigSection(), _L("appDataExists"), isAppDataExists);
       
  2867     if(isAppDataExists)
       
  2868         {
       
  2869         TPtrC appFileName;
       
  2870         if(GetStringFromConfig(ConfigSection(), _L("appFileName"), appFileName))
       
  2871             {
       
  2872             TUid appUid;
       
  2873             TInt intAppUid(0);
       
  2874             if(!GetHexFromConfig(ConfigSection(), _L("appUid"), intAppUid))
       
  2875                 {
       
  2876                 User::Leave(KErrNotFound);
       
  2877                 }
       
  2878             
       
  2879             appUid = TUid::Uid(intAppUid);
       
  2880             RArray<TUid> appUidArray;
       
  2881             CleanupClosePushL(appUidArray);
       
  2882             appUidArray.AppendL(appUid);
       
  2883             
       
  2884             //check if we have rolled back to the reg in rom after removal            
       
  2885             Usif::RApplicationInfoView appRegistryView;
       
  2886             CleanupClosePushL(appRegistryView);
       
  2887             Usif::CAppInfoFilter* appInfoFilter = Usif::CAppInfoFilter::NewLC();
       
  2888             appInfoFilter->SetAllApps();
       
  2889             appRegistryView.OpenViewL(scrSession, appInfoFilter);
       
  2890             RPointerArray<Usif::TAppRegInfo> appInfo;
       
  2891             CleanupClosePushL(appInfo);
       
  2892             appRegistryView.GetNextAppInfoL(5, appInfo);
       
  2893         
       
  2894             for(TInt i = 0; i < 5 ; ++i)
       
  2895                 {
       
  2896                 if(appInfo[i]->Uid() == appUid)
       
  2897                     {
       
  2898                     if(appInfo[i]->FullName().Compare(appFileName) != 0)
       
  2899                         {
       
  2900                         SetTestStepResult(EFail);
       
  2901                         CleanupStack::Pop(&appInfo);
       
  2902                         appInfo.ResetAndDestroy();
       
  2903                         CleanupStack::PopAndDestroy(4, &scrSession); // appInfoFilter, appRegistryView, appUid, scrSession
       
  2904                         return TestStepResult();
       
  2905                         }
       
  2906                     break;
       
  2907                     }
       
  2908                 }
       
  2909             CleanupStack::Pop(&appInfo);
       
  2910             appInfo.ResetAndDestroy();
       
  2911             CleanupStack::PopAndDestroy(3, &appUidArray); // appInfoFilter, appRegistryView, 
       
  2912             }  
       
  2913         }
       
  2914     else
       
  2915         {
       
  2916         TUid appUid = TUid::Uid(0);
       
  2917         TInt intAppUid(0);
       
  2918         if(!GetHexFromConfig(ConfigSection(), _L("appUid"), intAppUid))
       
  2919             {
       
  2920             User::Leave(KErrNotFound);
       
  2921             }
       
  2922         appUid = TUid::Uid(intAppUid);
       
  2923         
       
  2924         TRAPD(err, scrSession.GetComponentIdForAppL(appUid));
       
  2925         if(err != KErrNotFound)
       
  2926             {
       
  2927             SetTestStepResult(EFail);
       
  2928             CleanupStack::PopAndDestroy(&scrSession);
       
  2929             return TestStepResult();
       
  2930             }
       
  2931         }
       
  2932 
       
  2933     CleanupStack::PopAndDestroy(&scrSession);
       
  2934     return TestStepResult();
       
  2935     }