networkingtestandutils/networkingintegrationtest/inc/TestStep.h
changeset 0 af10295192d8
child 16 6d5320894977
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 /**
       
     2 * Copyright (c) 2003-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 CTestCase which is the base class for all the Testcases
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file TestStep.h
       
    24 */
       
    25 
       
    26 #if (!defined __TESTSTEP_H__)
       
    27 #define __TESTSTEP_H__
       
    28 
       
    29 #include "cinidata.h"
       
    30 #include "networking/log.h"
       
    31 
       
    32 class CTestSuite;
       
    33 
       
    34 /**
       
    35 Maximum length for test step name
       
    36 @internalComponent
       
    37 */
       
    38 #define MAX_LEN_TEST_STEP_NAME 55
       
    39 
       
    40 class CTestStep : public CBase
       
    41 /**
       
    42 CtestStep is an abstract base class for all test steps. Each test step 
       
    43 consists of a class derived from CTestStep, which implements doTestStepL.  
       
    44 Common test step functionality, which is required for a particular suite, 
       
    45 can be implemented using an intermediate class.
       
    46 @internalComponent
       
    47 */
       
    48 {
       
    49 public:
       
    50 
       
    51 	// Constructor 
       
    52 	IMPORT_C CTestStep(const TDesC &aName); 
       
    53 	IMPORT_C CTestStep();
       
    54 
       
    55 	/** destructor */
       
    56 	IMPORT_C virtual ~CTestStep();
       
    57 
       
    58 	/** 
       
    59 	Every test step must implement one of these.
       
    60 	This function contains the main code for a test step 
       
    61 	and returns a test result.
       
    62 	*/
       
    63 	virtual enum TVerdict doTestStepL( void ) = 0;
       
    64 	
       
    65 	/** Tests may optionaly implement pre amble. */
       
    66 	IMPORT_C virtual enum TVerdict doTestStepPreambleL( void );
       
    67 
       
    68 	/** Tests may optionaly implement post amble. */
       
    69 	IMPORT_C virtual enum TVerdict doTestStepPostambleL( void );
       
    70 
       
    71 	/** the name of the test step */
       
    72 	TBuf<MAX_LEN_TEST_STEP_NAME> iTestStepName;
       
    73 
       
    74 	/** Pointer to test suite which owns this test. */
       
    75 	CTestSuite * iSuite;
       
    76 
       
    77 	/** The current test step verdict. */
       
    78 	TVerdict iTestStepResult;
       
    79 
       
    80 	/** initialise the config parameter system. */
       
    81 	IMPORT_C void LoadConfig( TDesC &config );
       
    82 
       
    83 	IMPORT_C void UnLoadConfig( void );
       
    84 
       
    85 
       
    86 protected:
       
    87 
       
    88 	/** read bool value from the Config file functions */
       
    89 	IMPORT_C TBool GetBoolFromConfig(const TDesC &aSectName,const TDesC &aKeyName,TBool &aResult);
       
    90 
       
    91 	/** read int value from the Config file functions */
       
    92 	IMPORT_C TBool GetIntFromConfig(const TDesC &aSectName,const TDesC &aKeyName,TInt &aResult);
       
    93 
       
    94 	/** read string value from the Config file functions */
       
    95 	IMPORT_C TBool GetStringFromConfig(const TDesC &aSectName,const TDesC &aKeyName,TPtrC &aResult);
       
    96 
       
    97 	/** test function */
       
    98 	IMPORT_C void testBooleanTrue( TBool aCondition, char* aFile, TInt aLine );
       
    99 
       
   100 	/** test function */
       
   101 	IMPORT_C void testBooleanTrueL( TBool aCondition, char* aFile, TInt aLine );
       
   102 
       
   103 	/** test function */
       
   104 	IMPORT_C void testBooleanTrueWithErrorCode( TBool aCondition, TInt errorCode  , char* aFile, TInt aLine );
       
   105 
       
   106 	/** test function */
       
   107 	IMPORT_C void testBooleanTrueWithErrorCodeL( TBool aCondition, TInt errorCode  , char* aFile, TInt aLine );
       
   108 
       
   109 	/** test function */
       
   110 	IMPORT_C void teste( TBool aCondition, TInt value2 );
       
   111 
       
   112 	/** test function */
       
   113 	IMPORT_C void TestCheckPointCompareL(TInt aVal,TInt aExpectedVal, 
       
   114 										 const TDesC& aText, char* aFile,TInt aLine);
       
   115 
       
   116 	/** printf format log */
       
   117 	IMPORT_C void Log( TRefByValue<const TDesC16> format, ... );
       
   118 
       
   119 	/** printf format log */
       
   120 	IMPORT_C void Log( TInt aSeverity, TRefByValue<const TDesC16> format, ... );
       
   121 
       
   122 	/** printf format log */
       
   123 	IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,
       
   124 		TRefByValue<const TDesC> aFmt,...);
       
   125 
       
   126 	IMPORT_C TPtrC EpocErrorToText(TInt aError);
       
   127 
       
   128 	/** Config file data. */
       
   129 	CIniData *	iConfigData;
       
   130 
       
   131 	/** Print buffer used by ErrorToText. */
       
   132 	TBuf <20> iPrnBuf;
       
   133 
       
   134 private:
       
   135 	/** True if ConfigData has been loaded. */
       
   136 	TBool   iConfigDataAvailable;
       
   137 };
       
   138 
       
   139 class MControlNotify
       
   140 /**
       
   141 @internalComponent
       
   142 */
       
   143 {
       
   144 public:
       
   145 	virtual TInt CallStateMachine() = 0;
       
   146 };
       
   147 
       
   148 class CActiveControl : public CActive
       
   149 /**
       
   150 @internalComponent
       
   151 */
       
   152 {
       
   153 public:
       
   154 	static CActiveControl* NewL(MControlNotify* aControl);
       
   155 	CActiveControl(MControlNotify* aControl);
       
   156 	~CActiveControl();
       
   157 	void ConstructL();
       
   158 	virtual void RunL();
       
   159 	virtual void DoCancel();
       
   160 	IMPORT_C void ReStart();
       
   161 	inline TRequestStatus* Status() {return &iStatus;}
       
   162 private:
       
   163 	MControlNotify* iControl;
       
   164 };
       
   165 
       
   166 class CTestActiveStep : public CTestStep, public MControlNotify
       
   167 /**
       
   168 @internalComponent
       
   169 */
       
   170 {
       
   171 public:
       
   172 	// Constructor 
       
   173 	IMPORT_C CTestActiveStep(const TDesC &aName); 
       
   174 	IMPORT_C CTestActiveStep();
       
   175 
       
   176 	/** destructor */
       
   177 	IMPORT_C virtual ~CTestActiveStep();
       
   178 
       
   179 	IMPORT_C virtual enum TVerdict doTestStepPreambleL( void );
       
   180 	IMPORT_C virtual enum TVerdict doTestStepPostambleL( void );
       
   181 
       
   182 protected:
       
   183 	CActiveControl* iControl;
       
   184 	TRequestStatus* iStatus;
       
   185 
       
   186 private:
       
   187 	CActiveScheduler* iScheduler;
       
   188 
       
   189 };
       
   190 
       
   191 
       
   192 /**
       
   193 Checks the expression (a) is true, if not, 
       
   194 then displays error information, records a test verdict of fail and leaves.
       
   195 @internalAll
       
   196 */
       
   197 #define TESTL(a) testBooleanTrueL((a), __FILE__, __LINE__) 
       
   198 
       
   199 /**
       
   200 Checks the expression (a) is true, if not, 
       
   201 then display error information and records a test verdict of fail.
       
   202 @internalAll
       
   203 */
       
   204 #define TEST(a)  testBooleanTrue((a), __FILE__, __LINE__) 
       
   205 
       
   206 /**
       
   207 Checks the expression (a) is true, if not, 
       
   208 then displays error code b, and records a fail verdict.
       
   209 @internalAll
       
   210 */
       
   211 #define TESTE(a, b) testBooleanTrueWithErrorCode((a), (b), __FILE__, __LINE__) 
       
   212 
       
   213 /**
       
   214 Checks the expression (a) is true, if not, 
       
   215 then displays error code b, and records a fail verdict and leaves.
       
   216 @internalAll
       
   217 */
       
   218 #define TESTEL(a, b) testBooleanTrueWithErrorCodeL((a), (b), __FILE__, __LINE__)  
       
   219 
       
   220 /**
       
   221 Check the value against an expected value.
       
   222 If not record error and error code.
       
   223 @internalComponent
       
   224 */
       
   225 #define TEST_CHECKL(p1, p2, p3) TestCheckPointCompareL((p1), (p2), (p3), __FILE__, __LINE__)	
       
   226 
       
   227 /**
       
   228 leave error code
       
   229 @internalComponent
       
   230 */
       
   231 #define TEST_ERROR_CODE 84	
       
   232 
       
   233 
       
   234 #endif /* __TESTSTEP_H__ */