installationservices/swi/test/tuiscriptadaptors/tswisstep.h
changeset 0 ba25891c3a9e
child 19 7ca52d38f8c3
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * SWIS test step declaration
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 #ifndef __TSWISSTEP_H__
       
    25 #define __TSWISSTEP_H__
       
    26 
       
    27 #include <test/testexecutestepbase.h>
       
    28 #include <swi/asynclauncher.h>
       
    29 #include "testutilclientswi.h"
       
    30 #include "tswisserver.h"
       
    31 #include "tuiscriptadaptors.h"
       
    32 #include <swi/sistruststatus.h>
       
    33 
       
    34 #include <e32base.h>
       
    35 #ifndef SWI_TEXTSHELL_ROM		
       
    36 #include <apsidchecker.h>
       
    37 #else
       
    38 class CAppSidChecker;
       
    39 #endif
       
    40 
       
    41 namespace Swi
       
    42 	{
       
    43 	class CInstallPrefs;
       
    44 	}
       
    45 
       
    46 /**
       
    47  * Base test step class containing handy functions
       
    48  * @test
       
    49  * @internalComponent
       
    50  */
       
    51 class CSwisTestStep : public CTestStep
       
    52 	{
       
    53 protected:
       
    54 
       
    55 	enum TReadType
       
    56 		{
       
    57 		ESimpleType,		//to read "numexist" and "numnonexist" value from INI.
       
    58 		ECancelType,		//to read "numexistcancel" and "numnonexistcancel" value from INI.
       
    59 		ERegisteredType		//to read "numregistered" value from INI.
       
    60 		};
       
    61 		
       
    62 	/**
       
    63 	 * Get the file names for checking if present or missing.
       
    64 	 * The test step's INI file must contain entry "numexistcancel=<n>" and one or more entries
       
    65 	 * "existcancel<i>=<fname>". 
       
    66 	 * The test step's INI file must contain entry "numnonexistcancel=<n>" and one or more entries 
       
    67 	 * "nonexistcancel<i>=<fname>".
       
    68 	 * The test step's INI file must contain entry "numexist=<n>" and one or more entries 
       
    69 	 * "exist<i>=<fname>".
       
    70 	 * The test step's INI file must contain entry "numnonexist=<n>" and one or more entries 
       
    71 	 * "nonexist<i>=<fname>".
       
    72 	 * 
       
    73 	 * @param aFileNumExist     this array contains the name of the files which must exist after
       
    74 	 *						    installation/un-installation/cancellation.
       
    75 	 * @param aFileNumNonExist	this array contains the name of the files which must not exist after
       
    76 	 * 							installation/un-installation/cancellation.
       
    77 	 * @param aDoCancelTest     Used to make decision for reading from the INI file.
       
    78 	 *                          ETrue  Cancel Testing is enabled, so read entries "numexistcancel" and "numnonexistcancel".
       
    79 	 *                          EFalse Read entries "numexist" and "numnonexist".
       
    80 	 */
       
    81 	void GetFileNamesForCheck(RArray<TPtrC>& aFileNumExist,RArray<TPtrC>& aFileNumNonExist, TReadType aReadType);
       
    82 	 
       
    83 	/**
       
    84 	 * Extract the file names from the INI file. 
       
    85 	 * @param aEntries     Number of file name entries. 
       
    86 	 * @param aEntryBase   Base name of the keys specifying names of files to 
       
    87 	 *                     check; an index (0..n-1) is appended to the base 
       
    88 	 *                     name to get the actual key name.
       
    89 	 * @param aFileArray   Contains all the file names to check for missing or present. 
       
    90 	 */ 
       
    91 	void ExtractFileName(TInt aEntries, const TDesC& aEntryBase, RArray<TPtrC>& aFileArray);
       
    92 	 
       
    93 	/** 
       
    94 	 * Checks for files that should exist if the installation was successful,
       
    95 	 * and which shouldn't exist if the installation was cancelled. 
       
    96 	 * @param aCheckExist  Controls the kind of testing done
       
    97 	 *                     ETrue  Files must exist
       
    98 	 *                     EFalse Files must not exist
       
    99 	 * @param aFileArray   Contains all the file names to check for missing or present depending
       
   100 	 *					   on the aCheckExist. If ETrue, this contains the names of files that must exist
       
   101 	 *					   else if EFalse contains the names of files that must not be present.
       
   102 	 * @param aTestUtil    Contains reference to the testutilserver session.
       
   103 	 * @param aMsecTimeout Timeout to wait for file to be created, if not already existing
       
   104      */
       
   105 	void CheckIfFilesExist(TBool aCheckExist, const RArray<TPtrC>& aFileArray, RTestUtilSessionSwi& aTestUtil, TInt aMsecTimeout=0);
       
   106 	 
       
   107 	/**
       
   108 	 * Checks whether certain files do or do not exist by checking the registry entry and
       
   109 	 * sets test step result accordingly.
       
   110 	 * @param aFileArray   Contains all the file names to check for missing/present.
       
   111 	 */ 
       
   112 	void CheckRegistryEntry(RArray<TPtrC>& aFileArray);
       
   113 
       
   114 	/**
       
   115 	 * Checks that the correct dialogs have been called during the installation.
       
   116 	 */
       
   117 	void CheckDialogsCalled(const Swi::Test::CUIScriptAdaptor& ui);
       
   118 	
       
   119 	/**
       
   120 	 * Checks whether a fatal OCSP response was encountered during the installation.
       
   121 	 */
       
   122 	void CheckFatalOcspResponse(const Swi::Test::CUIScriptAdaptor& ui);
       
   123 	
       
   124 	/**
       
   125 	 * Checks whether the values of ocsp outcomes in the ini file matches with that of 
       
   126 	 * the DisplayOcspResultL function.
       
   127 	 */
       
   128     void  CheckExpectedOcspOutcomes(const Swi::Test::CUIScriptAdaptor& ui);	
       
   129 
       
   130    /**
       
   131 	 * Copy files from one place to another.
       
   132 	 *
       
   133 	 * @param aNumEntries Name of the key that specifies number of file name 
       
   134 	 *                    entries
       
   135 	 * @param aFrom  Base name of the keys specifying names of files to 
       
   136 	 *                    copy from; an index (0..n-1) is appended to the base 
       
   137 	 *                    name to get the actual key name
       
   138 	 * @param aTo    Base name of the keys specifying names of files to 
       
   139 	 *                    copy to; an index (0..n-1) is appended to the base 
       
   140 	 *                    name to get the actual key name
       
   141 	 */
       
   142 	void CopyFilesL(const TDesC& aNumEntries, const TDesC& aFrom, const TDesC& aTo);
       
   143 	
       
   144 	/**
       
   145  	 * Delete files.
       
   146  	 *
       
   147  	 * @param aNumEntries     Name of the key that specifies number of file name 
       
   148  	 *                        entries
       
   149  	 * @param aDeleteKeyBase  Base name of the keys specifying names of files
       
   150  	 *                        to delete; an index (0..n-1) is appended to the
       
   151  	 *                        base name to get the actual key name
       
   152  	 */
       
   153  	void DeleteFilesL(const TDesC& aNumEntries, const TDesC& aDeleteKeyBase);
       
   154 	
       
   155 	/**
       
   156 	 * Stores all the values of expected install sizes as indicated in the test
       
   157 	 * step's INI file.
       
   158 	 * @param aNumExpectedSizeEntries Name of key that specifies the number of
       
   159 	 *                                expected install sizes.
       
   160 	 * @param aExpectedInstallSize    A reference to the array of install sizes.
       
   161 	 */
       
   162 	void StoreExpectedInstallSizesL(TInt aNumExpectedSizeEntries, RArray<TTableOfInstallSizes>& aExpectedValue);
       
   163 	
       
   164 	/** Verify the Pub and Sub value of the current installation/uninstallation */
       
   165 	void CheckPubSubStatus(TDesC& aPubSubStatus);
       
   166 
       
   167 	/**
       
   168 	 * Check that the pub and sub status returns to KErrNone after a test.
       
   169 	 * This check should typically be last, whereas the previous method should
       
   170 	 * be done ASAP after an install/uninstall since there's a race condition.
       
   171 	 */
       
   172 	void CheckPubSubStatusIdle();
       
   173 	
       
   174    /**
       
   175 	 * Set or clear read only bit on files.
       
   176 	 *
       
   177 	 * @param aNumEntries     Name of the key that specifies number of file name 
       
   178 	 *                        entries
       
   179 	 * @param aFileKeyBase    Base name of the keys specifying names of files
       
   180 	 *                        to set; an index (0..n-1) is appended to the
       
   181 	 *                        base name to get the actual key name
       
   182 	 * @param aFileKeyBase    Base name of the keys specifying operation on files
       
   183 	 *                        ; an index (0..n-1) is appended to the
       
   184 	 *                        base name to get the actual key name.
       
   185 	 */
       
   186 	void SetClearReadOnlyFilesL(const TDesC& aNumEntries,
       
   187 								const TDesC& aFileKeyBase,
       
   188 								const TDesC& aSetClearOpBase);
       
   189 	
       
   190    /**
       
   191 	 * Check current step result against list of expected result codes.
       
   192 	 */
       
   193 	void CheckExpectedResultCodesL();
       
   194 
       
   195 	/**
       
   196 	 * Compares hashes for pairs of files read from config section, sets the
       
   197 	 * test step result to fail if any pair does not match or if there is an
       
   198 	 * error attempting to get a hash.
       
   199 	 */
       
   200 	void CompareFilesL();
       
   201 
       
   202 	/**
       
   203 	 * Compares file contents with buffer. Sets test step result to fail if
       
   204 	 * the contents do not match or there is an error in performing the
       
   205 	 * operation.
       
   206 	 */
       
   207 	void CompareFileWithBufferL(const Swi::Test::CUIScriptAdaptor& ui);
       
   208 
       
   209 	/**
       
   210 	 * Get the device supported languages from the config section.
       
   211 	 */
       
   212 	void GetDevSupportedLanguagesL(RArray<TInt>& aDeviceLanguages);
       
   213 
       
   214 	};
       
   215 
       
   216 /**
       
   217  * Installation test step class
       
   218  * @test
       
   219  * @internalComponent
       
   220  */
       
   221 class CSwisInstallStep : public CSwisTestStep
       
   222 	{
       
   223 public:
       
   224 	enum TInstallType { EUseFileHandle, EUseMemory, EUseFileName, EUseCAF, EUseOpenFileName, ECheckExitValue};
       
   225 
       
   226 	CSwisInstallStep(TInstallType aInstallType, TBool aDoCancelTest = EFalse);
       
   227 	~CSwisInstallStep();
       
   228 	virtual TVerdict doTestStepPreambleL();
       
   229 	virtual TVerdict doTestStepPostambleL();
       
   230 	virtual TVerdict doTestStepL();
       
   231 private:
       
   232 	TInt DoInstallL(Swi::CInstallPrefs& aInstallPrefs);
       
   233 	void GetFilesToHoldOpenL();
       
   234 
       
   235 private:
       
   236 	TFileName iSisFileName; // name of the file to install
       
   237 	TFileName iXmlFileName; // name of the file containing dialog data
       
   238 	Swi::Test::CUIScriptAdaptor* iUi; // XML script-based UI implementation
       
   239 	TInstallType iInstallType; // use file handle to install
       
   240 	RArray<TTableOfInstallSizes> iExpectedValue; // array of expected install sizes
       
   241 	TBool iDoCancelTest;
       
   242 	TPtrC iExpectedHash;
       
   243 	TInt iExpectedDialog;
       
   244 	TInt  iKErrCode;
       
   245 	TPtrC Outcomes;// outcomes as received from ini file
       
   246 	TUid iUid;
       
   247 	TInt iExpectedUserDrive; // -1 if not checked
       
   248 	TPtrC iPubSubStatus;
       
   249 	HBufC* iFileToWatch;
       
   250 	TBool iExpectFileChange;
       
   251 	RPointerArray<RFile> iFilesHeldOpen;
       
   252 	TBool iUseDeviceLanguages;
       
   253 	RArray<TInt> iDeviceLanguages;
       
   254 	};
       
   255 
       
   256 /**
       
   257  * Uninstallation test step class
       
   258  * @test
       
   259  * @internalComponent
       
   260  */
       
   261 class CSwisUninstallStep : public CSwisTestStep
       
   262 	{
       
   263 public:
       
   264 	enum TUninstallType { EByUid, EByPackage };
       
   265 	
       
   266 	CSwisUninstallStep(TUninstallType aType, TBool aDoCancelTest = EFalse);
       
   267 	~CSwisUninstallStep();
       
   268 	virtual TVerdict doTestStepPreambleL();
       
   269 	virtual TVerdict doTestStepPostambleL();
       
   270 	virtual TVerdict doTestStepL();
       
   271 private:
       
   272 	TInt DoUninstallL();
       
   273 
       
   274 private:
       
   275 	TUid iUid;
       
   276 	TFileName iXmlFileName; // name of the file containing dialog data
       
   277 	TPtrC iVendorName;
       
   278 	TInt iExpectedDialog;
       
   279 	TInt iKErrCode;
       
   280 	Swi::Test::CUIScriptAdaptor* iUi; // XML script-based UI implementation
       
   281 	TPtrC iPackageName;
       
   282 	TUninstallType iType;
       
   283 	TBool iDoCancelTest;
       
   284 	TPtrC iPubSubStatus;
       
   285 	TBool iIsSafeMode;
       
   286 	};
       
   287 
       
   288 
       
   289 /**
       
   290  * CTrustStatusStep 
       
   291  * @test
       
   292  * @internalComponent
       
   293  */
       
   294 class CTrustStatusStep : public CSwisTestStep
       
   295 	{
       
   296 public:
       
   297 	CTrustStatusStep();
       
   298 	virtual TVerdict doTestStepL();
       
   299 	TPtrC* GetRevocationName(Swi::TRevocationStatus t);
       
   300 	TPtrC* GetValidationName(Swi::TValidationStatus t);
       
   301 	};
       
   302 
       
   303 /**
       
   304  * CPostInstallRevocationCheckStep 
       
   305  * @test
       
   306  * @internalComponent
       
   307  */
       
   308 class CPostInstallRevocationCheckStep : public CSwisTestStep
       
   309 	{
       
   310 public:
       
   311 	CPostInstallRevocationCheckStep();
       
   312 	virtual TVerdict doTestStepL();
       
   313 	};
       
   314 	
       
   315 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   316 /**
       
   317  * CheckSCRField test step class
       
   318  * @test
       
   319  * @internalComponent
       
   320  */
       
   321 class CCheckScrFieldStep : public CSwisTestStep
       
   322 	{
       
   323 public:	
       
   324 	virtual TVerdict doTestStepL();
       
   325 	};
       
   326 	
       
   327 class CCheckScrCompPropertyStep : public CSwisTestStep
       
   328 	{
       
   329 public:	
       
   330 	virtual TVerdict doTestStepL();
       
   331 	};
       
   332 #endif
       
   333 
       
   334 _LIT(KSwisInstallStep, "InstallStep");
       
   335 _LIT(KSwisInstallFHStep, "InstallFHStep"); // install using file handles
       
   336 _LIT(KSwisInstallMemStep, "InstallMemStep"); // install from memory
       
   337 _LIT(KSwisInstallCAFStep, "InstallCAFStep"); // install from CAF
       
   338 _LIT(KSwisInstallOpenFileStep, "InstallOpenFileStep"); // install with already opened file
       
   339 _LIT(KSwisCheckedInstallStep, "CheckedInstallStep");
       
   340 
       
   341 // Cancel testing 
       
   342 _LIT(KSwisInstallCancelStep, "InstallStepCancel");
       
   343 _LIT(KSwisInstallFHCancelStep, "InstallFHStepCancel"); // install using file handles
       
   344 _LIT(KSwisInstallMemCancelStep, "InstallMemStepCancel"); // install from memory
       
   345 _LIT(KSwisInstallCAFCancelStep, "InstallCAFStepCancel"); // install from CAF
       
   346 
       
   347 _LIT(KSwisUninstallStep, "UninstallStep");
       
   348 _LIT(KSwisUninstallAugStep, "UninstallAugStep"); // uninstall of augmentation
       
   349 _LIT(KTrustStatus, "TrustStatus");
       
   350 _LIT(KPirCheck, "PostInstallRevocationCheck");
       
   351 
       
   352 _LIT(KSwisUninstallCancelStep, "UninstallStepCancel");
       
   353 _LIT(KSwisUninstallAugCancelStep, "UninstallAugStepCancel"); // uninstall of augmentation
       
   354 _LIT(KNumExpectedSizes, "numExpectedSizes"); // This specifies that the test section
       
   355 											 // has values for installation size(s).
       
   356 
       
   357 _LIT(KSwisMmcFormatStep, "MmcFormatStep");
       
   358 _LIT(KSwisMmcMountStep, "MmcMountStep");
       
   359 _LIT(KSwisMmcUnMountStep, "MmcUnMountStep");
       
   360 _LIT(KSwisMmcCopyFiles, "MmcCopyFilesStep");
       
   361 _LIT(KSwisMmcCheckFiles, "MmcCheckFilesStep");
       
   362 _LIT(KSwisMmcResetTags, "MmcResetTagsStep");
       
   363 _LIT(KSwisMmcDeleteFiles, "MmcDeleteFilesStep");
       
   364 _LIT(KSwisMmcGetNumFilesFiles, "MmcGetNumFilesStep");
       
   365 _LIT(KAskRegistry, "MmcAskRegistry");
       
   366 _LIT(KSetClearReadOnly, "SetClearReadOnlyStep");
       
   367 _LIT(KQuerySidViaApparcPlugin, "QuerySidViaApparcPlugin");
       
   368 
       
   369 _LIT(KSwisListUninstallPkgsStep, "ListUninstallPkgsStep");
       
   370 _LIT(KSwisRemoveUninstallPkgsStep, "RemoveUninstallPkgsStep");
       
   371 _LIT(KSwisGetPackageDetails, "GetPackageDetails");
       
   372 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   373 _LIT(KCheckSCRFieldStep, "CheckSCRFieldStep");
       
   374 _LIT(KCheckSCRCompPropertyStep, "CheckSCRCompPropertyStep");
       
   375 #endif
       
   376 
       
   377 /**
       
   378  * Listing and Removing Uninslled Pkgs test step class
       
   379  * @test
       
   380  * @internalComponent
       
   381  */
       
   382 class CSwisUninstallPkgsStep : public CSwisTestStep
       
   383 	{
       
   384 public:
       
   385 	enum TUnInstallAppType { EListPkgs, ERemovePkgs, EPkgDetails};
       
   386 
       
   387 	CSwisUninstallPkgsStep(TUnInstallAppType aInstallType);
       
   388 	~CSwisUninstallPkgsStep();
       
   389 	virtual TVerdict doTestStepPreambleL();
       
   390 	virtual TVerdict doTestStepPostambleL();
       
   391 	virtual TVerdict doTestStepL();
       
   392 
       
   393 private:
       
   394 	TUnInstallAppType iUnInstallAppType; // use file handle to install
       
   395 	TUid iUid;
       
   396 	TInt iDrive;
       
   397 	TChar iDriveChar;
       
   398 	};
       
   399 
       
   400 /**
       
   401  * MMC emulation test step class
       
   402  * @test
       
   403  * @internalComponent
       
   404  */
       
   405 class CSwisMmcStep : public CSwisTestStep
       
   406 	{
       
   407 public:
       
   408 	enum TMmcOperation { 
       
   409 		/**
       
   410 		 * EFormat - Format the specified drive
       
   411 		 *
       
   412 		 * If the drive is NOT mounted the format will fail with error -18 KErrNotReady
       
   413 		 *
       
   414 		 * nb. Formating a drive looks like an MMC insertion to the SWI
       
   415 		 * daemon (it does NOT look like a remove followed by an insert).
       
   416 		 */
       
   417 		EFormat,
       
   418 		/**
       
   419 		 * EMount - Mount the specified drive
       
   420 		 *
       
   421 		 * Mounting an already mounted drive fails with error -21 KErrAccessDenied
       
   422 		 * 
       
   423 		 * Mounting an unmounted drive looks exactly like a MMC card
       
   424 		 * insertion to the SWI daemon.
       
   425 		 *
       
   426 		 * [The SWI daemon detects MMC insertion by registering with the
       
   427 		 * FS server using NotifyChange(ENotifyEntry,,) for a non-existent
       
   428 		 * file on the drive being watched. It then checks if it can read
       
   429 		 * the Volume info to decide if media has been inserted or
       
   430 		 * removed.]
       
   431 		 */
       
   432 		EMount,
       
   433 		/**
       
   434 		 * EUnMount - UnMount the specified drive
       
   435 		 *
       
   436 		 * Un-mounting an already un-mounted drive fails with error -18 KErrNotReady
       
   437 		 *
       
   438 		 * Unmounting an mounted drive looks exactly like a MMC card
       
   439 		 * removal to the SWI daemon.
       
   440 		 *
       
   441 		 * Will fail if there are any open file descriptors on the drive.
       
   442 		 */
       
   443 		EUnMount,
       
   444 		
       
   445 		/**
       
   446 		 * ECopyFiles - Copy some files to the MMC
       
   447 		 */
       
   448 		ECopyFiles,
       
   449 		/**
       
   450 		 * ECheckFiles - Check set of files specified by
       
   451 		 * numexist/existX and numnonexist/nonexistX are present/absent as specified.
       
   452 		 */
       
   453 		ECheckFiles,
       
   454 		/**
       
   455 		 * EResetTags - Delete the tags directory for a new test
       
   456 		 */
       
   457 		EResetTags,
       
   458 		/**
       
   459  		 * EDeleteFiles - Delete some files which may be in private directories
       
   460  		 */
       
   461 		EDeleteFiles,
       
   462 		/**
       
   463  		 * EGetNumFiles - Get the number of files in a given directory
       
   464  		 */
       
   465 		EGetNumFiles,
       
   466 		EAskReg,
       
   467 		ESetClearReadOnly,
       
   468 		/**
       
   469 		 * Query if the specified SID is installed
       
   470 		 */
       
   471 		EQuerySidViaApparcPlugin
       
   472 	};
       
   473 	CSwisMmcStep(TMmcOperation aOperation);
       
   474 	~CSwisMmcStep();
       
   475 
       
   476 
       
   477 
       
   478 
       
   479 	virtual TVerdict doTestStepPreambleL();
       
   480 	virtual TVerdict doTestStepPostambleL();
       
   481 	virtual TVerdict doTestStepL();
       
   482 
       
   483 private:
       
   484 	TMmcOperation iOperation;
       
   485 	TInt iDrive;
       
   486 	TInt iBootMode;
       
   487 	TChar iDriveChar;
       
   488 #ifndef SWI_TEXTSHELL_ROM
       
   489 	CAppSidChecker *iSwiSidChecker;
       
   490 #endif
       
   491 	};
       
   492 	
       
   493 #endif // __TSWISSTEP_H__