0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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 "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 |
* This contains CTestStep which is the base class for all test steps.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file TestExecuteStepBase.h
|
|
23 |
*/
|
|
24 |
#if (!defined __TESTEXECUTE_STEP_BASE_H__)
|
|
25 |
#define __TESTEXECUTE_STEP_BASE_H__
|
|
26 |
|
|
27 |
#include <e32base.h>
|
|
28 |
#include <f32file.h>
|
|
29 |
#include <iniparser.h>
|
|
30 |
#include <test/testexecutelogger.h>
|
|
31 |
#include <test/testexecuteclient.h>
|
|
32 |
#include <test/tefshareddata.h>
|
|
33 |
#include <test/testshareddata.h>
|
|
34 |
|
|
35 |
class CTestStep : public CBase
|
|
36 |
/**
|
|
37 |
@publishedPartner
|
|
38 |
@test
|
|
39 |
*/
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
// Destructor
|
|
43 |
IMPORT_C virtual ~CTestStep();
|
|
44 |
|
|
45 |
// Get methods to read values from the ini file
|
|
46 |
IMPORT_C TBool GetBoolFromConfig(const TDesC& aSectName,const TDesC& aKeyName,TBool& aResult);
|
|
47 |
IMPORT_C TBool GetIntFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
|
|
48 |
IMPORT_C TBool GetStringFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult);
|
|
49 |
|
|
50 |
// Set a user-friendly test step name referred for a test step object from the script file
|
|
51 |
IMPORT_C void SetTestStepName(const TDesC& aStepName);
|
|
52 |
|
|
53 |
IMPORT_C TBool GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
|
|
54 |
|
|
55 |
// Set the actual test step error obtained to execution of test step to compare the expected error with the actual
|
|
56 |
IMPORT_C void SetTestStepError(const TInt& aErrorCode);
|
|
57 |
|
|
58 |
// Write methods to write values into ini file
|
|
59 |
IMPORT_C TBool WriteIntToConfig(const TDesC& aSectName, const TDesC& aKeyName, const TInt& aValue);
|
|
60 |
IMPORT_C TBool WriteStringToConfig(const TDesC& aSectName, const TDesC& aKeyName, const TPtrC& aValue);
|
|
61 |
IMPORT_C TBool WriteBoolToConfig(const TDesC& aSectName, const TDesC& aKeyName, const TBool& aValue);
|
|
62 |
IMPORT_C TBool WriteHexToConfig(const TDesC& aSectName, const TDesC& aKeyName, const TInt& aValue);
|
|
63 |
|
|
64 |
//Updates the data to the shared data name passed either in Copy Mode/Append Mode
|
|
65 |
IMPORT_C void WriteSharedDataL(const TDesC& aShareName, TDesC& aSharedDataVal, TModeCopy aModeCopy = ESetText);
|
|
66 |
//Reads the data from the specified shared data object
|
|
67 |
IMPORT_C void ReadSharedDataL(const TDesC& aShareName, TDes& aSharedDataVal);
|
|
68 |
|
|
69 |
// Initialise the test step during cnstruction
|
|
70 |
void InitialiseL(const TDesC& aStepArgs, const TDesC& aServerName, TBool& aSharedDataMode);
|
|
71 |
|
|
72 |
// Initialises logger instance for the test step
|
|
73 |
void SetLoggerL();
|
|
74 |
|
|
75 |
// Closes the logger instance for the test step
|
|
76 |
void CloseLogger();
|
|
77 |
|
|
78 |
// Returns the section name specified in the script file for the current test step execution
|
|
79 |
inline TDes& ConfigSection() {return iSection;};
|
|
80 |
|
|
81 |
// Set the result of test step execution to one of the TVerdict enum codes
|
|
82 |
inline void SetTestStepResult(TVerdict aVerdict) {iTestStepResult = aVerdict;};
|
|
83 |
|
|
84 |
// Returns the test step result at any point during execution of test step
|
|
85 |
inline TVerdict TestStepResult() const {return iTestStepResult;};
|
|
86 |
|
|
87 |
// Logger interface used for constructing result strings to be fed for the logger instance
|
|
88 |
inline CTestExecuteLogger& Logger() {return *iLogger;};
|
|
89 |
|
|
90 |
// Returns the user-friendly test step name
|
|
91 |
inline const TDesC& TestStepName() const {return iTestStepName;};
|
|
92 |
|
|
93 |
// Returns any error code set during the test step execution
|
|
94 |
inline const TInt& TestStepError() const {return iTestStepError;};
|
|
95 |
|
|
96 |
// Returns the boolean true of !OOM option is set from the script file, false otherwise
|
|
97 |
inline TBool& ShouldRunOOMTest() {return iOOMRequestStatus;};
|
|
98 |
|
|
99 |
// Returns true if test server is loaded using -SharedData mode from the script file
|
|
100 |
inline TBool& IsSharedDataMode() {return iSharedDataMode;};
|
|
101 |
|
|
102 |
// Returns the loop index of the current loop if the test runs within a START_REPEAT/EN_REPEAT block
|
|
103 |
// Returns -1 if test is not within a loop
|
|
104 |
inline TInt GetLoopIndex() {return iLoopIndex;};
|
|
105 |
|
|
106 |
// Returns the setup value set using !Setup TEF parameter within the script file
|
|
107 |
// Returns a value 0 if !Setup TEF parameter is not used
|
|
108 |
inline TInt GetSetupState() {return iSetupParamValue;};
|
|
109 |
|
|
110 |
// Returns the drive name from which the current script file is executed
|
|
111 |
inline TDriveName ScriptDriveName() { return iScriptDriveName;};
|
|
112 |
|
|
113 |
// Returns reference to the iEnableIniAccessLog bool which can be used by tests to switch off ini access logging on the run
|
|
114 |
inline TBool& IniAccessLog() { return iEnableIniAccessLog; };
|
|
115 |
|
|
116 |
// Returns the default system drive letter provided by call to RFs::GetSystemDrive()
|
|
117 |
inline TDriveName GetSystemDrive() { return iSystemDriveForTest; };
|
|
118 |
|
|
119 |
// Test Step virtuals - Test Implementation methods
|
|
120 |
IMPORT_C virtual enum TVerdict doTestStepL() = 0;
|
|
121 |
IMPORT_C virtual enum TVerdict doTestStepPreambleL();
|
|
122 |
IMPORT_C virtual enum TVerdict doTestStepPostambleL();
|
|
123 |
|
|
124 |
// Setting simulated OOM and testing whether the code under test reached the simulated failure
|
|
125 |
IMPORT_C virtual void SetHeapFailNext(TInt aFailureIndex);
|
|
126 |
IMPORT_C virtual void ResetHeapFailNext();
|
|
127 |
IMPORT_C virtual TBool CheckForHeapFailNext();
|
|
128 |
|
|
129 |
// LEGACY methods
|
|
130 |
IMPORT_C void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
|
|
131 |
IMPORT_C void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine, TBool IgnoreStepResult);
|
|
132 |
IMPORT_C void testBooleanTrueL(TBool aCondition, const TText8* aFile, TInt aLine);
|
|
133 |
IMPORT_C void testBooleanTrueL(TBool aCondition, const TText8* aFile, TInt aLine, TBool IgnoreStepResult);
|
|
134 |
IMPORT_C void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine );
|
|
135 |
IMPORT_C void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine, TBool IgnoreStepResult);
|
|
136 |
IMPORT_C void testBooleanTrueWithErrorCodeL(TBool aCondition, TInt aErrorCode,
|
|
137 |
const TText8* aFile, TInt aLine );
|
|
138 |
IMPORT_C void testBooleanTrueWithErrorCodeL(TBool aCondition, TInt aErrorCode,
|
|
139 |
const TText8* aFile, TInt aLine, TBool IgnoreStepResult );
|
|
140 |
IMPORT_C void TestCheckPointCompareL(TInt aVal, TInt aExpectedVal, const TDesC& aText, const TText8* aFile, TInt aLine);
|
|
141 |
|
|
142 |
// Retrieve the server name
|
|
143 |
IMPORT_C const TDesC& GetServerName() const;
|
|
144 |
|
|
145 |
// Retrieve the test case name/id
|
|
146 |
IMPORT_C TBool TestCaseName(TDes& aTestCaseName);
|
|
147 |
|
|
148 |
protected:
|
|
149 |
IMPORT_C CTestStep();
|
|
150 |
public:
|
|
151 |
IMPORT_C TBool GetIntFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt64& aResult);
|
|
152 |
IMPORT_C TBool WriteIntToConfig(const TDesC& aSectName, const TDesC& aKeyName, const TInt64& aValue);
|
|
153 |
private:
|
|
154 |
void LoadConfigFileL(const TDesC& aFilePath);
|
|
155 |
private:
|
|
156 |
CTestExecuteLogger* iLogger;
|
|
157 |
TVerdict iTestStepResult;
|
|
158 |
TBuf<KMaxTestExecuteNameLength> iSection;
|
|
159 |
CIniData* iConfigData;
|
|
160 |
TBuf<KMaxTestStepNameLength> iTestStepName; // Name of the test step
|
|
161 |
TBuf<KMaxTestExecuteNameLength> iServerName; // Name of the test server
|
|
162 |
TInt iTestStepError; // Expected Test step Error
|
|
163 |
HBufC* iIniFileName; // Name of the inifile to be use for logging.
|
|
164 |
TBool iOOMRequestStatus; // Status of OOM request from user
|
|
165 |
TBool iEnableIniAccessLog;// Testexecute.ini entry for logging INI access
|
|
166 |
TBool iSharedDataMode; // Flag representing -SharedData server mode
|
|
167 |
TInt iSetupParamValue; // TEFParameter !Setup value set in the script
|
|
168 |
TInt iLoopIndex; // Loop index of the current loop if test runs within a START_REPEAT
|
|
169 |
TBuf<KMaxTestExecuteNameLength> iTestCaseID; // Name/ID of the test case in which the current test step executes
|
|
170 |
TDriveName iScriptDriveName; // Drive name from where the script file is executed
|
|
171 |
TDriveName iSystemDrive; // Default System Drive name
|
|
172 |
TDriveName iSystemDriveForTest;// System Drive name for Test artifacts
|
|
173 |
|
|
174 |
// Use this buffer when allocating additional memory for the class in future
|
|
175 |
// To avoid breaks with other depdenant comps
|
|
176 |
TBuf<KMaxTestStepNameLength> iReserved4Future1;
|
|
177 |
TBuf<KMaxTestStepNameLength> iReserved4Future2;
|
|
178 |
TBuf<KMaxTestStepNameLength> iReserved4Future3;
|
|
179 |
TBuf<KMaxTestStepNameLength> iReserved4Future4;
|
|
180 |
};
|
|
181 |
|
|
182 |
// LEGACY
|
|
183 |
// Autotest macros mapped to CTestStep functions
|
|
184 |
|
|
185 |
// Check a boolean is true
|
|
186 |
#define TESTL(a) testBooleanTrueL((a), (TText8*)__FILE__, __LINE__)
|
|
187 |
#define TEST(a) testBooleanTrue((a), (TText8*)__FILE__, __LINE__)
|
|
188 |
|
|
189 |
// Versions that will always log irrespective of testcase pass
|
|
190 |
#define TEST1L(a, b) testBooleanTrueL((a), (TText8*)__FILE__, __LINE__, (b) )
|
|
191 |
#define TEST1(a, b) testBooleanTrue((a), (TText8*)__FILE__, __LINE__, (b) )
|
|
192 |
|
|
193 |
// Check a boolean is true if not return error code b
|
|
194 |
#define TESTE(a, b) testBooleanTrueWithErrorCode((a), (b), (TText8*)__FILE__, __LINE__)
|
|
195 |
#define TESTEL(a, b) testBooleanTrueWithErrorCodeL((a), (b), (TText8*)__FILE__, __LINE__)
|
|
196 |
|
|
197 |
// Versions that will always log irrespective of testcase pass
|
|
198 |
#define TESTE1(a, b, c) testBooleanTrueWithErrorCode((a), (b), (TText8*)__FILE__, __LINE__, (c) )
|
|
199 |
#define TESTE1L(a, b, c) testBooleanTrueWithErrorCodeL((a), (b), (TText8*)__FILE__, __LINE__, (c) )
|
|
200 |
|
|
201 |
#define TEST_CHECKL(p1, p2, p3) TestCheckPointCompareL((p1), (p2), (p3), (TText8*)__FILE__, __LINE__)
|
|
202 |
// Leave error code
|
|
203 |
#define TEST_ERROR_CODE 84
|
|
204 |
|
|
205 |
|
|
206 |
#endif
|