os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/inc/ComponentTester.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/inc/ComponentTester.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,250 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This file contains the definition of the class CComponentTester
    1.18 +// This file comment is for DOxygen only and is ignored by EDoc.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @test
    1.24 +*/
    1.25 +
    1.26 +#ifndef __COMPONENTTESTER_H__
    1.27 +#define __COMPONENTTESTER_H__
    1.28 +
    1.29 +#include <e32base.h>
    1.30 +#include <e32test.h>
    1.31 +
    1.32 +#include <ecom/test_bed/unittestinfo.h>
    1.33 +#include <ecom/test_bed/unittest.h>
    1.34 +#include <ecom/test_bed/datalogger.h>
    1.35 +#include <ecom/test_bed/componenttestobserver.h>
    1.36 +
    1.37 +class CDataLogger;
    1.38 +
    1.39 +/**
    1.40 +	@internalAll
    1.41 +	@struct TTestInfo
    1.42 +	Comments : Used by the UI component to pass in a list of the tests which are to run
    1.43 +	with information about each one.
    1.44 + */
    1.45 +
    1.46 +struct TTestInfo
    1.47 +	{
    1.48 +/** The zero-based component Id based on the list passed out from 
    1.49 +	CTestController::FindComponents */
    1.50 +	
    1.51 +	TInt	iComponentId;
    1.52 +/** The zero-based unit test Id within the above component */
    1.53 +	
    1.54 +	TInt	iUnitTestId;
    1.55 +/** The time at which this unit test should be scheduled to run */
    1.56 +	
    1.57 +	TTimeIntervalMicroSeconds32 iRunTime;
    1.58 +/** Parameter block which is to be passed to the unit test */
    1.59 +	
    1.60 +	TAny*	iParameters;
    1.61 +	};
    1.62 +
    1.63 +
    1.64 +// Global function typedef declaration of function provided by a test module of the component
    1.65 +// under test and is used as an entry point to kick start test bed. Provided as argument to CTestController.
    1.66 +typedef CComponentTester* (*ComponentTesterInitialiserLC)(CDataLogger&, MComponentTestObserver&);
    1.67 +
    1.68 +
    1.69 +/**
    1.70 +	@internalAll
    1.71 +	Comments : Abstract class from which developers can derive their own component testing
    1.72 +	classes.  To write a derived class just implement a NewLC() and a ConstructL() from 
    1.73 +	which ComponentTesterConstructL() should be the first thing called.
    1.74 + */
    1.75 +
    1.76 +class CComponentTester : public CActive, public MUnitTestObserver
    1.77 +	{
    1.78 +public:
    1.79 +/**
    1.80 +	@fn				 ~CComponentTester()
    1.81 +	Intended Usage	: Standardized virtual destruction method 
    1.82 +	@since			7.0
    1.83 + */
    1.84 +	
    1.85 +	IMPORT_C ~CComponentTester();
    1.86 +
    1.87 +/**
    1.88 +	@fn				IMPORT_C virtual void TestComponent(RPointerArray<TTestInfo>* aTests)
    1.89 +	Intended Usage	:	Called to perform a full test of the component. Runs the listed 
    1.90 +					tests or all unit tests if aTests == 0
    1.91 +	Error Condition	:	
    1.92 +	@since			7.0
    1.93 +	@param			aTests The list of tests to run, 0 means run all tests
    1.94 +	@pre 			This CComponentTester is fully initialized
    1.95 +	@post			All unit tests will be set up to run
    1.96 + */
    1.97 +	
    1.98 +	IMPORT_C virtual void TestComponent(RPointerArray<TTestInfo>* aTests);
    1.99 +
   1.100 +/**
   1.101 +	@fn				IMPORT_C RPointerArray<CUnitTestInfo>* TransitionSetsL() const
   1.102 +	Intended Usage	:	Called to provide a list of the transition sets in this component test.
   1.103 +						Ownership of the array is passed to the calling object.
   1.104 +	Error Condition	:	
   1.105 +	@since			7.0
   1.106 +	@return			RPointerArray<CUnitTestInfo>* Information on the unit tests contained
   1.107 +	in this component.  Ownership of the array is passed to the calling object.
   1.108 +	@pre 			None
   1.109 + */
   1.110 +	
   1.111 +	IMPORT_C RPointerArray<CUnitTestInfo>* TransitionSetsL() const;
   1.112 +
   1.113 +/**
   1.114 +	@fn				IMPORT_C void Complete(CUnitTest* aUnitTest)
   1.115 +	Intended Usage	:	Used, by the observed unit test, to indicate that the 
   1.116 +					test has completed
   1.117 +	Error Condition	:	
   1.118 +	@since			7.0
   1.119 +	@param			aUnitTest	The unit test which has completed.
   1.120 +	@pre 			None
   1.121 +	@post			If this was the last unit test then iObserver is informed that this 
   1.122 +	component is complete.
   1.123 + */
   1.124 +	
   1.125 +	IMPORT_C void Complete(CUnitTest* aUnitTest);
   1.126 +
   1.127 +/**
   1.128 +	@fn				IMPORT_C void SetRtest(RTest* aRTest)
   1.129 +	Intended Usage	:	Used by Controller or Manager to initialise the iRTest
   1.130 +					attribute of the component & unit test objects in t
   1.131 +	Error Condition	:	
   1.132 +	@since			7.0s
   1.133 +	@param			aRTest	Pointer to RTest object 
   1.134 +	@pre 			None
   1.135 +	@post			None
   1.136 + */
   1.137 +	IMPORT_C void SetRTest(RTest* aRTest);
   1.138 +
   1.139 +protected:
   1.140 +/**
   1.141 +	@fn				 IMPORT_C CComponentTester(CDataLogger&				aDataLogger, 
   1.142 +											   MComponentTestObserver&	aObserver)
   1.143 +	Intended Usage	: Default Constructor	
   1.144 +	@since			7.0
   1.145 +	@param 			aDataLogger Used for file logging capability
   1.146 +	@param 			aObserver To inform of completion of all tests
   1.147 + */
   1.148 +	IMPORT_C CComponentTester(CDataLogger& aDataLogger, MComponentTestObserver& aObserver);
   1.149 +
   1.150 +/**
   1.151 +	@fn				IMPORT_C void AddUnitTestL(const CUnitTest* aUnitTest)
   1.152 +	Intended Usage	:	Used by derived class to add UnitTests to the list
   1.153 +	Error Condition	:	
   1.154 +	@since			7.0
   1.155 +	@param			aUnitTest The UnitTest to be added
   1.156 +	@pre 			None
   1.157 +	@post			The specified unit test is added to the list of tests to be executed.
   1.158 + */
   1.159 +	
   1.160 +	IMPORT_C void AddUnitTestL(const CUnitTest* aUnitTest);
   1.161 +
   1.162 +/**
   1.163 +	@fn				IMPORT_C void AddParamUnitTestL(const CUnitTest* aUnitTest)
   1.164 +	Intended Usage	:	Used by derived classes to add UnitTests which can only be run when
   1.165 +	they are supplied with parameters from the UI.
   1.166 +	Error Condition	:
   1.167 +	@since			7.0
   1.168 +	@param			aUnitTest The unit test to add to the list
   1.169 +	@pre 			None
   1.170 +	@post			The specified unit test is added to the list of test to be executed and 
   1.171 +	is flagged as requiring parameters
   1.172 + */
   1.173 +	
   1.174 +	IMPORT_C void AddParamUnitTestL(const CUnitTest* aUnitTest);
   1.175 +
   1.176 +/**
   1.177 +	@fn				IMPORT_C virtual void ConstructL() = 0
   1.178 +	Intended Usage	:	Standard two-phase construction method.  To be implemented 
   1.179 +	in derived class
   1.180 +	Error Condition	:	
   1.181 +	@since			7.0
   1.182 +	@pre 			First phase of construction is complete
   1.183 +	@post			Object is fully constructed
   1.184 + */
   1.185 +	
   1.186 +	IMPORT_C virtual void ConstructL() = 0;
   1.187 +
   1.188 +/**
   1.189 +	@fn				IMPORT_C void ComponentTesterConstructL()
   1.190 +	Intended Usage	:	Must be called by derived class ConstructL() to perform base class 
   1.191 +					initialisation.
   1.192 +	Error Condition	:	
   1.193 +	@since			7.0
   1.194 +	@pre 			None
   1.195 +	@post			Object is fully constructed
   1.196 + */
   1.197 +	
   1.198 +	IMPORT_C void ComponentTesterConstructL();
   1.199 +
   1.200 +/**
   1.201 +	@fn				IMPORT_C void RunL()
   1.202 +	Intended Usage	:	
   1.203 +	Error Condition	:	
   1.204 +	@since			7.0
   1.205 +	@pre 			This CComponentTester is fully constructed
   1.206 +	@post			One of the CUnitTest contained in this CComponentTester has been run
   1.207 + */
   1.208 +	
   1.209 +	IMPORT_C void RunL();
   1.210 +
   1.211 +/**
   1.212 +	@fn				IMPORT_C void DoCancel()
   1.213 +	Intended Usage	:	
   1.214 +	Error Condition	:	
   1.215 +	@since			7.0
   1.216 +	@pre 			This CComponentTester is fully constructed.
   1.217 +	@post			Any outstanding asynchronous requests are cancelled.
   1.218 + */
   1.219 +	
   1.220 +	IMPORT_C void DoCancel();
   1.221 +
   1.222 +protected:
   1.223 +/** List of all the unit tests which make up this component test*/
   1.224 +	
   1.225 +	RPointerArray<CUnitTest>* iUnitTests;
   1.226 +/** The test logging mechanism*/
   1.227 +	
   1.228 +	CDataLogger&			iDataLogger;
   1.229 +/** The observer to inform when we have completed the test */
   1.230 +	
   1.231 +	MComponentTestObserver&		iObserver;
   1.232 +/** The index of the unittest which is to be run next */
   1.233 +	
   1.234 +	TInt						iCurrentUnitTest;
   1.235 +/** The list of tests to run, NULL means run all tests. We take ownership of the list but 
   1.236 +	not the items on it.*/
   1.237 +	
   1.238 +	RPointerArray<TTestInfo>*	iUnitTestsToRun;
   1.239 +/** A list of the test which cannot run without a parameter set from the UI */
   1.240 +	
   1.241 +	RArray<TInt>				iParameterizedTests;
   1.242 +/** A placeholder which is only used to ensure correct object cleanup when 
   1.243 +	TransitionSetsL() leaves */
   1.244 +	
   1.245 +	mutable RPointerArray<CUnitTestInfo>* iTransitionSets;
   1.246 +/** Optional reference to the RTest object used in the EXE test harness code which
   1.247 +	kicked off this test framework */
   1.248 +	RTest* iRTest;
   1.249 +
   1.250 +	friend class TComponentTester_StateAccessor;
   1.251 +	};
   1.252 +
   1.253 +#endif