installationservices/swi/test/tsisregistrytest_legacy/sessionstep.cpp
changeset 5 3eebb1e54d3a
parent 0 ba25891c3a9e
child 25 98b66e4fb0be
child 65 7333d7932ef7
equal deleted inserted replaced
3:127731b7107d 5:3eebb1e54d3a
    21  @test
    21  @test
    22  @internalTechnology
    22  @internalTechnology
    23 */
    23 */
    24  
    24  
    25 #include <test/testexecutelog.h>
    25 #include <test/testexecutelog.h>
    26 
    26 #include <test/testexecutestepbase.h>
    27 #include "sessionstep.h"
    27 #include "sessionstep.h"
    28 #include "sisregistrysession.h"
    28 #include "sisregistrysession.h"
    29 #include "sisregistryentry.h"
    29 #include "sisregistryentry.h"
    30 #include "sisregistrypackage.h"
    30 #include "sisregistrypackage.h"
    31 #include "installtypes.h"
    31 #include "installtypes.h"
    58 _LIT(KRootCertTag, "rootcert");
    58 _LIT(KRootCertTag, "rootcert");
    59 _LIT(KResultTag, "expectedresult");
    59 _LIT(KResultTag, "expectedresult");
    60 _LIT(KDateTime, "datetime"); //YYYYMMDD:HHMMSS.MMMMMM
    60 _LIT(KDateTime, "datetime"); //YYYYMMDD:HHMMSS.MMMMMM
    61 _LIT(KPkgCount, "embeddingpkgcount");
    61 _LIT(KPkgCount, "embeddingpkgcount");
    62 _LIT(KLanguage, "language");
    62 _LIT(KLanguage, "language");
    63 
    63 _LIT(KRegFileName, "regfilename");
       
    64 _LIT(KCtlCount, "ctlcount");
       
    65 _LIT(KHashCount, "hashcount");
       
    66 _LIT(KIndex, "index");
    64 _LIT(KSisRegistryPath, "\\sys\\install\\sisregistry\\");
    67 _LIT(KSisRegistryPath, "\\sys\\install\\sisregistry\\");
    65 _LIT(KCacheBackupFile, "\\sys\\install\\sisregistry\\backup.lst");
    68 _LIT(KCacheBackupFile, "\\sys\\install\\sisregistry\\backup.lst");
    66 _LIT(KCorruptCacheBackupFile, "z:\\tswi\\tsisregistrytest\\data\\hashforlang_txt.dat");
    69 _LIT(KCorruptCacheBackupFile, "z:\\tswi\\tsisregistrytest\\data\\hashforlang_txt.dat");
    67 _LIT(KSysBackupFileBackup, "\\sys\\install\\sisregistry\\backup.bak");
    70 _LIT(KSysBackupFileBackup, "\\sys\\install\\sisregistry\\backup.bak");
    68 
    71 
  1882 
  1885 
  1883     return TestStepResult();
  1886     return TestStepResult();
  1884     }
  1887     }
  1885 
  1888 
  1886 
  1889 
  1887 
  1890 /////////////////////////////////////////////////////////////////////
       
  1891 // CRegistryFilesStep - obtain a list of RegistryFiles
       
  1892 /////////////////////////////////////////////////////////////////////
       
  1893 CRegistryFilesStep::CRegistryFilesStep()
       
  1894     {    
       
  1895     }
       
  1896 
       
  1897 TVerdict CRegistryFilesStep::doTestStepL()
       
  1898     {
       
  1899     TPtrC package;
       
  1900     TPtrC vendor;
       
  1901     TUid packageUid;
       
  1902     TInt index;
       
  1903 
       
  1904     if(!GetStringFromConfig(ConfigSection(), KPackage, package))
       
  1905         {
       
  1906         ERR_PRINTF1(_L("Failed to find the package name in the ini"));
       
  1907         SetTestStepResult(EFail);    
       
  1908         return TestStepResult();
       
  1909         }
       
  1910     
       
  1911     if(! GetStringFromConfig(ConfigSection(), KVendor, vendor))
       
  1912         {
       
  1913         ERR_PRINTF1(_L("Failed to find the vedor name in the ini"));
       
  1914         SetTestStepResult(EFail);    
       
  1915         return TestStepResult();
       
  1916         }
       
  1917    
       
  1918     if(!GetIntFromConfig(ConfigSection(), KIndex, index))
       
  1919         {
       
  1920         ERR_PRINTF1(_L("Failed to find the registry index in the ini"));
       
  1921         SetTestStepResult(EFail);    
       
  1922         return TestStepResult();
       
  1923         }
       
  1924     
       
  1925     if(!GetUidFromConfig(ConfigSection(), KUid, packageUid))
       
  1926         {
       
  1927         ERR_PRINTF1(_L("Failed to find the package Uid in the ini"));
       
  1928         SetTestStepResult(EFail);    
       
  1929         return TestStepResult();
       
  1930         }        
       
  1931     // Read the expected reg file name for the package uid and append it to the expected files array
       
  1932     TPtrC regFileName;
       
  1933     RPointerArray<HBufC> expectedFilesArray;
       
  1934     CleanupResetAndDestroyPushL(expectedFilesArray);
       
  1935     GetStringFromConfig(ConfigSection(), KRegFileName, regFileName);    
       
  1936     expectedFilesArray.AppendL(regFileName.AllocLC());   
       
  1937     CleanupStack::Pop();
       
  1938     
       
  1939     // Read the registry files for the package uid
       
  1940     TInt ctlcount = 0;
       
  1941     TPtrC ctlName;
       
  1942     TInt expectedFileCount(0);
       
  1943     GetIntFromConfig(ConfigSection(), KCtlCount, ctlcount);
       
  1944     _LIT(KCtlName,"ctlName");
       
  1945     
       
  1946     for(TInt i=0 ; i < ctlcount ; i++)
       
  1947         {            
       
  1948             TBuf<20> integerAppendStr;
       
  1949             TPtrC name;
       
  1950             integerAppendStr.Format(_L("%S%d"), KCtlName().AllocLC(),i);            
       
  1951             GetStringFromConfig(ConfigSection(), integerAppendStr, name);
       
  1952             CleanupStack::PopAndDestroy();
       
  1953             expectedFilesArray.AppendL(name.AllocLC());   
       
  1954             CleanupStack::Pop();
       
  1955         }    
       
  1956     
       
  1957     // Read the expected hash file name(2) for the package uid and append it to the expected files array
       
  1958     TInt hashcount(0);
       
  1959     _LIT(KHashFileName,"hashfilename");
       
  1960     GetIntFromConfig(ConfigSection(), KHashCount, hashcount);
       
  1961     for(TInt i=0 ; i < hashcount ; i++)
       
  1962            {            
       
  1963                TBuf<20> integerAppendStr;
       
  1964                TPtrC hashFileName;
       
  1965                integerAppendStr.Format(_L("%S%d"), KHashFileName().AllocLC(),i);            
       
  1966                GetStringFromConfig(ConfigSection(), integerAppendStr, hashFileName);
       
  1967                CleanupStack::PopAndDestroy();
       
  1968                expectedFilesArray.AppendL(hashFileName.AllocLC()); 
       
  1969                CleanupStack::Pop();
       
  1970            }
       
  1971             
       
  1972     //Call the RegistryFiles API    
       
  1973     RPointerArray<HBufC> obtainedRegistryFiles;
       
  1974     CleanupResetAndDestroyPushL(obtainedRegistryFiles);  
       
  1975     CSisRegistryPackage* registryPackage = NULL;
       
  1976     Swi::RSisRegistryEntry entry;
       
  1977     registryPackage = CSisRegistryPackage::NewLC(packageUid, package, vendor);
       
  1978     registryPackage->SetIndex(index);
       
  1979     
       
  1980     //open the registry entry
       
  1981     TRAPD(err, entry.OpenL(iSisRegistry,*registryPackage));    
       
  1982     if(err != KErrNone)
       
  1983         {
       
  1984         SetTestStepResult(EFail); 
       
  1985         User::Leave(err);
       
  1986         }
       
  1987     
       
  1988     //Get the Regisrty files(.reg, .ctl and hash) for ythe registry entry
       
  1989     TRAP(err, entry.RegistryFilesL(obtainedRegistryFiles));
       
  1990     if(err != KErrNone)
       
  1991         {
       
  1992         SetTestStepResult(EFail); 
       
  1993         User::Leave(err);
       
  1994         }
       
  1995     
       
  1996     // Total no of expected files        
       
  1997     expectedFileCount = ctlcount + hashcount + 1;     //ctl + hash + reg     
       
  1998     
       
  1999     if(obtainedRegistryFiles.Count() != expectedFileCount)  
       
  2000         {
       
  2001         ERR_PRINTF1(_L("Number of obtained files not same as the expected files"));
       
  2002         SetTestStepResult(EFail);    
       
  2003         }                
       
  2004    
       
  2005    //Compare the obtained Registry files with the expected files in the order(.reg, , .ctls and hash).  
       
  2006    for (TInt i = 0 ; i < expectedFileCount ; i++)
       
  2007        {      
       
  2008        if (KErrNone != obtainedRegistryFiles[i]->Compare(*expectedFilesArray[i]))
       
  2009            {                     
       
  2010            ERR_PRINTF1(_L("Obtained Registry files does not match with the exptected Registry Files"));
       
  2011            SetTestStepResult(EFail);    
       
  2012            break;
       
  2013            }
       
  2014     }
       
  2015 
       
  2016     entry.Close();    
       
  2017     CleanupStack::PopAndDestroy(registryPackage);  
       
  2018     CleanupStack::Pop(&obtainedRegistryFiles);
       
  2019     obtainedRegistryFiles.ResetAndDestroy();
       
  2020     obtainedRegistryFiles.Close();    
       
  2021     CleanupStack::Pop(&expectedFilesArray);
       
  2022     expectedFilesArray.ResetAndDestroy();
       
  2023     expectedFilesArray.Close();
       
  2024     return TestStepResult();
       
  2025     }
       
  2026