authorisation/userpromptservice/test/tups_install/tupsstep.h
changeset 98 7355aab40bca
parent 91 a675745f8b2e
equal deleted inserted replaced
91:a675745f8b2e 98:7355aab40bca
     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 * tswisstep.h
       
    16 * SWIS test step declaration
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 /**
       
    24  @file
       
    25 */
       
    26 
       
    27 #ifndef __TSWISSTEP_H__
       
    28 #define __TSWISSTEP_H__
       
    29 
       
    30 #include <test/testexecutestepbase.h>
       
    31 #include "../../testutil/client/testutilclient.h"
       
    32 #include "tupsserver.h"
       
    33 #include "tuiscriptadaptors.h"
       
    34 
       
    35 #include "e32base.h"
       
    36 
       
    37 namespace Swi
       
    38 	{
       
    39 	class CInstallPrefs;
       
    40 	}
       
    41 
       
    42 /**
       
    43  * Base test step class containing handy functions
       
    44  * @test
       
    45  * @internalComponent
       
    46  */
       
    47 class CUpsTestStep : public CTestStep
       
    48 	{
       
    49 protected:
       
    50 
       
    51 	enum TReadType
       
    52 		{
       
    53 		ESimpleType,		//to read "numexist" and "numnonexist" value from INI.
       
    54 		ECancelType,		//to read "numexistcancel" and "numnonexistcancel" value from INI.
       
    55 		ERegisteredType		//to read "numregistered" value from INI.
       
    56 		};
       
    57 		
       
    58 	/**
       
    59 	 * Get the file names for checking if present or missing.
       
    60 	 * The test step's INI file must contain entry "numexistcancel=<n>" and one or more entries
       
    61 	 * "existcancel<i>=<fname>". 
       
    62 	 * The test step's INI file must contain entry "numnonexistcancel=<n>" and one or more entries 
       
    63 	 * "nonexistcancel<i>=<fname>".
       
    64 	 * The test step's INI file must contain entry "numexist=<n>" and one or more entries 
       
    65 	 * "exist<i>=<fname>".
       
    66 	 * The test step's INI file must contain entry "numnonexist=<n>" and one or more entries 
       
    67 	 * "nonexist<i>=<fname>".
       
    68 	 * 
       
    69 	 * @param aFileNumExist     this array contains the name of the files which must exist after
       
    70 	 *						    installation/un-installation/cancellation.
       
    71 	 * @param aFileNumNonExist	this array contains the name of the files which must not exist after
       
    72 	 * 							installation/un-installation/cancellation.
       
    73 	 * @param aDoCancelTest     Used to make decision for reading from the INI file.
       
    74 	 *                          ETrue  Cancel Testing is enabled, so read entries "numexistcancel" and "numnonexistcancel".
       
    75 	 *                          EFalse Read entries "numexist" and "numnonexist".
       
    76 	 */
       
    77 	void GetFileNamesForCheck(RArray<TPtrC>& aFileNumExist,RArray<TPtrC>& aFileNumNonExist, TReadType aReadType);
       
    78 	 
       
    79 	/**
       
    80 	 * Extract the file names from the INI file. 
       
    81 	 * @param aEntries     Number of file name entries. 
       
    82 	 * @param aEntryBase   Base name of the keys specifying names of files to 
       
    83 	 *                     check; an index (0..n-1) is appended to the base 
       
    84 	 *                     name to get the actual key name.
       
    85 	 * @param aFileArray   Contains all the file names to check for missing or present. 
       
    86 	 */ 
       
    87 	void ExtractFileName(TInt aEntries, const TDesC& aEntryBase, RArray<TPtrC>& aFileArray);
       
    88 	 
       
    89 	/** 
       
    90 	 * Checks for files that should exist if the installation was successful,
       
    91 	 * and which shouldn't exist if the installation was cancelled. 
       
    92 	 * @param aCheckExist  Controls the kind of testing done
       
    93 	 *                     ETrue  Files must exist
       
    94 	 *                     EFalse Files must not exist
       
    95 	 * @param aFileArray   Contains all the file names to check for missing or present depending
       
    96 	 *					   on the aCheckExist. If ETrue, this contains the names of files that must exist
       
    97 	 *					   else if EFalse contains the names of files that must not be present.
       
    98 	 * @param aTestUtil    Contains reference to the testutilserver session.
       
    99 	 * @param aMsecTimeout Timeout to wait for file to be created, if not already existing
       
   100      */
       
   101 	void CheckIfFilesExist(TBool aCheckExist, const RArray<TPtrC>& aFileArray, RTestUtilSession& aTestUtil, TInt aMsecTimeout=0);
       
   102 	 
       
   103 	/**
       
   104 	 * Checks whether certain files do or do not exist by checking the registry entry and
       
   105 	 * sets test step result accordingly.
       
   106 	 * @param aFileArray   Contains all the file names to check for missing/present.
       
   107 	 */ 
       
   108 	void CheckRegistryEntry(RArray<TPtrC>& aFileArray);
       
   109 
       
   110 	/**
       
   111 	 * Checks that the correct dialogs have been called during the installation.
       
   112 	 */
       
   113 	void CheckDialogsCalled(const Swi::Test::CUIScriptAdaptor& ui);
       
   114 	
       
   115 	/**
       
   116 	 * Checks whether a fatal OCSP response was encountered during the installation.
       
   117 	 */
       
   118 	void CheckFatalOcspResponse(const Swi::Test::CUIScriptAdaptor& ui);
       
   119 	
       
   120 	/**
       
   121 	 * Checks whether the values of ocsp outcomes in the ini file matches with that of 
       
   122 	 * the DisplayOcspResultL function.
       
   123 	 */
       
   124     void  CheckExpectedOcspOutcomes(const Swi::Test::CUIScriptAdaptor& ui);	
       
   125 
       
   126    /**
       
   127 	 * Copy files from one place to another.
       
   128 	 *
       
   129 	 * @param aNumEntries Name of the key that specifies number of file name 
       
   130 	 *                    entries
       
   131 	 * @param aFrom  Base name of the keys specifying names of files to 
       
   132 	 *                    copy from; an index (0..n-1) is appended to the base 
       
   133 	 *                    name to get the actual key name
       
   134 	 * @param aTo    Base name of the keys specifying names of files to 
       
   135 	 *                    copy to; an index (0..n-1) is appended to the base 
       
   136 	 *                    name to get the actual key name
       
   137 	 */
       
   138 	void CopyFilesL(const TDesC& aNumEntries, const TDesC& aFrom, const TDesC& aTo);
       
   139 	
       
   140 	/**
       
   141  	 * Delete files.
       
   142  	 *
       
   143  	 * @param aNumEntries     Name of the key that specifies number of file name 
       
   144  	 *                        entries
       
   145  	 * @param aDeleteKeyBase  Base name of the keys specifying names of files
       
   146  	 *                        to delete; an index (0..n-1) is appended to the
       
   147  	 *                        base name to get the actual key name
       
   148  	 */
       
   149  	void DeleteFilesL(const TDesC& aNumEntries, const TDesC& aDeleteKeyBase);
       
   150 	
       
   151 	/**
       
   152 	 * Stores all the values of expected install sizes as indicated in the test
       
   153 	 * step's INI file.
       
   154 	 * @param aNumExpectedSizeEntries Name of key that specifies the number of
       
   155 	 *                                expected install sizes.
       
   156 	 * @param aExpectedInstallSize    A reference to the array of install sizes.
       
   157 	 */
       
   158 	void StoreExpectedInstallSizesL(TInt aNumExpectedSizeEntries, RArray<TTableOfInstallSizes>& aExpectedValue);
       
   159 	
       
   160 	/** Verify the Pub and Sub value of the current installation/uninstallation */
       
   161 	void CheckPubSubStatus(TDesC& aPubSubStatus);
       
   162 
       
   163 	/**
       
   164 	 * Check that the pub and sub status returns to KErrNone after a test.
       
   165 	 * This check should typically be last, whereas the previous method should
       
   166 	 * be done ASAP after an install/uninstall since there's a race condition.
       
   167 	 */
       
   168 	void CheckPubSubStatusIdle();
       
   169 	
       
   170    /**
       
   171 	 * Set or clear read only bit on files.
       
   172 	 *
       
   173 	 * @param aNumEntries     Name of the key that specifies number of file name 
       
   174 	 *                        entries
       
   175 	 * @param aFileKeyBase    Base name of the keys specifying names of files
       
   176 	 *                        to set; an index (0..n-1) is appended to the
       
   177 	 *                        base name to get the actual key name
       
   178 	 * @param aFileKeyBase    Base name of the keys specifying operation on files
       
   179 	 *                        ; an index (0..n-1) is appended to the
       
   180 	 *                        base name to get the actual key name.
       
   181 	 */
       
   182 	void SetClearReadOnlyFilesL(const TDesC& aNumEntries,
       
   183 								const TDesC& aFileKeyBase,
       
   184 								const TDesC& aSetClearOpBase);
       
   185 	
       
   186    /**
       
   187 	 * Check current step result against list of expected result codes.
       
   188 	 */
       
   189 	void CheckExpectedResultCodesL();
       
   190 
       
   191 	/**
       
   192 	 * Compares hashes for pairs of files read from config section, sets the
       
   193 	 * test step result to fail if any pair does not match or if there is an
       
   194 	 * error attempting to get a hash.
       
   195 	 */
       
   196 	void CompareFilesL();
       
   197 
       
   198 	/**
       
   199 	 * Compares file contents with buffer. Sets test step result to fail if
       
   200 	 * the contents do not match or there is an error in performing the
       
   201 	 * operation.
       
   202 	 */
       
   203 	void CompareFileWithBufferL(const Swi::Test::CUIScriptAdaptor& ui);
       
   204 	};
       
   205 
       
   206 /**
       
   207  * Installation test step class
       
   208  * @test
       
   209  * @internalComponent
       
   210  */
       
   211 class CUpsInstallStep : public CUpsTestStep
       
   212 	{
       
   213 public:
       
   214 	enum TInstallType { EUseFileName };
       
   215 
       
   216 	CUpsInstallStep(TInstallType aInstallType);
       
   217 	~CUpsInstallStep();
       
   218 	virtual TVerdict doTestStepPreambleL();
       
   219 	virtual TVerdict doTestStepPostambleL();
       
   220 	virtual TVerdict doTestStepL();
       
   221 private:
       
   222 	TInt DoInstallL(Swi::CInstallPrefs& aInstallPrefs);
       
   223 	void GetFilesToHoldOpenL();
       
   224 
       
   225 private:
       
   226 	TFileName iSisFileName; // name of the file to install
       
   227 	TFileName iXmlFileName; // name of the file containing dialog data
       
   228 	Swi::Test::CUIScriptAdaptor* iUi; // XML script-based UI implementation
       
   229 	TInstallType iInstallType; // use file handle to install
       
   230 	RArray<TTableOfInstallSizes> iExpectedValue; // array of expected install sizes
       
   231 	TBool iDoCancelTest;
       
   232 	TPtrC iExpectedHash;
       
   233 	TInt iExpectedDialog;
       
   234 	TInt  iKErrCode;
       
   235 	TPtrC Outcomes;// outcomes as received from ini file
       
   236 	TUid iUid;
       
   237 	TInt iExpectedUserDrive; // -1 if not checked
       
   238 	TPtrC iPubSubStatus;
       
   239 	TBool iExpectFileChange;
       
   240 	};
       
   241 
       
   242 /**
       
   243  * Uninstallation test step class
       
   244  * @test
       
   245  * @internalComponent
       
   246  */
       
   247 class CUpsUninstallStep : public CUpsTestStep
       
   248 	{
       
   249 public:
       
   250 	enum TUninstallType { EByUid, EByPackage };
       
   251 	
       
   252 	CUpsUninstallStep(TUninstallType aType);
       
   253 	~CUpsUninstallStep();
       
   254 	virtual TVerdict doTestStepPreambleL();
       
   255 	virtual TVerdict doTestStepPostambleL();
       
   256 	virtual TVerdict doTestStepL();
       
   257 private:
       
   258 	TInt DoUninstallL();
       
   259 
       
   260 private:
       
   261 	TUid iUid;
       
   262 	TFileName iXmlFileName; // name of the file containing dialog data
       
   263 	TPtrC iVendorName;
       
   264 	TInt iKErrCode;
       
   265 	Swi::Test::CUIScriptAdaptor* iUi; // XML script-based UI implementation
       
   266 	TPtrC iPackageName;
       
   267 	TUninstallType iType;
       
   268 	};
       
   269 
       
   270 
       
   271 _LIT(KUpsInstallStep, "InstallStep");
       
   272 
       
   273 _LIT(KUpsUnInstallAugStep, "UninstallAugStep");
       
   274 
       
   275 _LIT(KUpsUnInstallStep, "UninstallStep");
       
   276 
       
   277 #endif // __TSWISSTEP_H__