os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/inc/TestController.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// This file contains the definition of the class CTestController
sl@0
    15
// This file comment is for DOxygen only and is ignored by EDoc.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @test
sl@0
    21
*/
sl@0
    22
sl@0
    23
#ifndef __TESTCONTROLLER_H__
sl@0
    24
#define __TESTCONTROLLER_H__
sl@0
    25
sl@0
    26
#include <e32base.h>
sl@0
    27
#include <e32test.h>
sl@0
    28
sl@0
    29
#include <ecom/test_bed/componentinfo.h>
sl@0
    30
#include <ecom/test_bed/testmanager.h>
sl@0
    31
#include <ecom/test_bed/transitionobserver.h>
sl@0
    32
#include <ecom/test_bed/transition.h>
sl@0
    33
#include <ecom/test_bed/managerobserver.h>
sl@0
    34
sl@0
    35
class CComponentTester;
sl@0
    36
class CDataLogger;
sl@0
    37
sl@0
    38
// Global function typedef declaration of function provided by a test module of the component
sl@0
    39
// under test and is used as an entry point to kick start test bed. Provided as argument to CTestController.
sl@0
    40
typedef CComponentTester* (*ComponentTesterInitialiserLC)(CDataLogger&, MComponentTestObserver&);
sl@0
    41
sl@0
    42
/**
sl@0
    43
	@internalAll
sl@0
    44
	Comments : Manages the whole test procedure.
sl@0
    45
 */
sl@0
    46
sl@0
    47
class CTestController : public CBase, private MManagerObserver
sl@0
    48
	{
sl@0
    49
public:
sl@0
    50
/**
sl@0
    51
	@fn				static IMPORT_C CTestController* NewL(CActiveScheduler* aScheduler,
sl@0
    52
														  ComponentTesterInitialiserLC aEntryPoint,
sl@0
    53
														  RTest* aRTest = NULL,
sl@0
    54
														  TLoggingInfo*		aLogInfo = NULL)
sl@0
    55
	Intended Usage	: Standardized safe construction which leaves nothing on the cleanup stack.
sl@0
    56
	@leave  		KErrNoMemory.
sl@0
    57
	@since			7.0
sl@0
    58
	@param 			aScheduler The active scheduler to use,  pass NULL if no scheduler exists
sl@0
    59
	@param			aEntryPoint The global function used to create the derived CComponentTester object.
sl@0
    60
	@param			aRTest Optional RTest object to use in check unit test results
sl@0
    61
	@param			aLogInfo The logging info to use, defaults to NULL
sl@0
    62
	@return			CTestController* A pointer to the newly created class.
sl@0
    63
	@pre 			None
sl@0
    64
	@post			Nothing is on the CleanupStack
sl@0
    65
 */
sl@0
    66
	
sl@0
    67
	static IMPORT_C CTestController* NewL(CActiveScheduler* aScheduler,
sl@0
    68
										  ComponentTesterInitialiserLC aEntryPoint,
sl@0
    69
										  RTest* aRTest = NULL,
sl@0
    70
										  TLoggingInfo*	aLogInfo = NULL);
sl@0
    71
sl@0
    72
/**
sl@0
    73
	@fn				static IMPORT_C CTestController* NewLC(CActiveScheduler* aScheduler,
sl@0
    74
														   ComponentTesterInitialiserLC aEntryPoint,
sl@0
    75
														   RTest* aRTest = NULL,
sl@0
    76
														   TLoggingInfo*	 aLogInfo = NULL)
sl@0
    77
	Intended Usage	: Standardized safe construction which leaves CTestController* on the cleanup stack.
sl@0
    78
	@leave  		KErrNoMemory.
sl@0
    79
	@since			7.0
sl@0
    80
	@param 			aScheduler The active scheduler, if one exists, otherwise NULL
sl@0
    81
	@param			aEntryPoint The global function used to create the derived CComponentTester object.
sl@0
    82
	@param			aRTest Optional RTest object to use in check unit test results
sl@0
    83
	@param			aLogInfo The logging configuration information
sl@0
    84
	@return			CTestController* A pointer to the newly created class.
sl@0
    85
	@pre 			None
sl@0
    86
	@post			CTestController is on the CleanupStack
sl@0
    87
 */
sl@0
    88
	
sl@0
    89
	static IMPORT_C CTestController* NewLC(CActiveScheduler* aScheduler,
sl@0
    90
										   ComponentTesterInitialiserLC aEntryPoint,
sl@0
    91
										   RTest* aRTest = NULL,
sl@0
    92
										   TLoggingInfo* aLogInfo = NULL);
sl@0
    93
sl@0
    94
/**
sl@0
    95
	@fn				 ~CTestController()
sl@0
    96
	Intended Usage	: Standardized virtual destruction method
sl@0
    97
	@since			7.0
sl@0
    98
 */
sl@0
    99
	
sl@0
   100
	virtual IMPORT_C ~CTestController();
sl@0
   101
sl@0
   102
/**
sl@0
   103
	@fn				Start()
sl@0
   104
	Intended Usage	:	Starts the testbed and runs all tests on all components.  This 
sl@0
   105
					function runs synchronously and does not return until all tests 
sl@0
   106
					are complete.
sl@0
   107
	@since			7.0
sl@0
   108
	@pre 			This object is constructed
sl@0
   109
	@post			Starts the active scheduler and therefore doesn't complete until the 
sl@0
   110
					active scheduler is stopped.
sl@0
   111
 */
sl@0
   112
	IMPORT_C void Start();
sl@0
   113
sl@0
   114
/**
sl@0
   115
	@fn				Start(RPointerArray<TTestInfo>* aTests)
sl@0
   116
	Intended Usage	:	Starts the specified tests.This function runs 
sl@0
   117
					synchronously and does not return until all tests are complete.
sl@0
   118
	@since			7.0
sl@0
   119
	@param			aTests The list of tests to be run.
sl@0
   120
	@pre 			This object is constructed
sl@0
   121
	@post			Starts the active scheduler and therefore doesn't complete until the 
sl@0
   122
					active scheduler is stopped.
sl@0
   123
 */
sl@0
   124
	
sl@0
   125
	IMPORT_C void Start(RPointerArray<TTestInfo>* aTests);
sl@0
   126
sl@0
   127
/**
sl@0
   128
	@fn				Start(TRequestStatus* aStatus)
sl@0
   129
	Intended Usage	:	Starts the testbed and runs all tests on all components.  This 
sl@0
   130
					function runs asynchronously and completes aStatus when all tests 
sl@0
   131
					are complete.
sl@0
   132
	@since			7.0
sl@0
   133
	@param			aStatus Status word for the calling function.  Is completed when all 
sl@0
   134
					tests are complete.
sl@0
   135
	@pre 			This object is constructed
sl@0
   136
	@post			An asynchronous request is issued to run all tests.
sl@0
   137
 */
sl@0
   138
	IMPORT_C void Start(TRequestStatus* aStatus);
sl@0
   139
sl@0
   140
/**
sl@0
   141
	@fn				Start(TRequestStatus* aStatus, RPointerArray<TTestInfo>* aTests)
sl@0
   142
	Intended Usage	:	Starts the specified tests.  If the default for aTest is used
sl@0
   143
					then all tests are run on all components.  This function runs 
sl@0
   144
					asynchronously and completes aStatus when all tests are complete.
sl@0
   145
	@since			7.0
sl@0
   146
	@param			aStatus Status word for the calling function.  Is completed when all 
sl@0
   147
					tests are complete.
sl@0
   148
	@param			aTests The list of tests to be run.
sl@0
   149
	@pre 			This object is constructed.
sl@0
   150
	@post			An asynchronous request is issued to run the specified tests.
sl@0
   151
 */
sl@0
   152
	IMPORT_C void Start(TRequestStatus* aStatus, RPointerArray<TTestInfo>* aTests);
sl@0
   153
sl@0
   154
/**
sl@0
   155
	@fn				RPointerArray<CComponentInfo>& FindComponents() const
sl@0
   156
	Intended Usage	:	Returns an array of the components available for testing
sl@0
   157
	Error Condition	:	
sl@0
   158
	@since			7.0
sl@0
   159
	@return			RPointerArray<CComponentInfo>& Information on the components which 
sl@0
   160
					are available for testing.
sl@0
   161
	@pre 			The object is fully constructed
sl@0
   162
	@post			Returns an array of the available components which can be used to select
sl@0
   163
					which test to run.
sl@0
   164
 */
sl@0
   165
	
sl@0
   166
	IMPORT_C const RPointerArray<CComponentInfo>& FindComponents() const;
sl@0
   167
sl@0
   168
/**
sl@0
   169
	@fn				IMPORT_C CDataLogger& DataLogger()
sl@0
   170
	Intended Usage	:	Returns a reference to the file logging functionality for use 
sl@0
   171
					by the user interface component.
sl@0
   172
	@since			7.0
sl@0
   173
	@return			CDataLogger& The current data logger to allow external logging
sl@0
   174
	@pre 			The CTestController has been created so that the data logger exists
sl@0
   175
	@post			Unspecified
sl@0
   176
 */
sl@0
   177
	
sl@0
   178
	static IMPORT_C CDataLogger& DataLogger();
sl@0
   179
sl@0
   180
/**
sl@0
   181
	@fn				Cancel()
sl@0
   182
	Intended Usage	:	Cancels any outstanding tests.
sl@0
   183
	@since			7.0
sl@0
   184
	@pre 			This object has been created and the asynchronous version of 
sl@0
   185
					Start has been called.
sl@0
   186
	@post			Any outstanding tests have been cancelled.
sl@0
   187
 */
sl@0
   188
	IMPORT_C void Cancel();
sl@0
   189
sl@0
   190
	friend class TTestController_StateAccessor;
sl@0
   191
sl@0
   192
private:
sl@0
   193
/**
sl@0
   194
	@fn				 CTestController(CActiveScheduler* aScheduler)
sl@0
   195
	Intended Usage	: Constructor
sl@0
   196
	@since			7.0
sl@0
   197
	@param 			aScheduler The existing active scheduler or NULL
sl@0
   198
	@param			aRTest Optional RTest object to use in check unit test results
sl@0
   199
 */
sl@0
   200
	
sl@0
   201
	CTestController(CActiveScheduler* aScheduler, RTest* aRTest = NULL);
sl@0
   202
sl@0
   203
/**
sl@0
   204
	@fn				void ConstructL(TLoggingInfo* aLogInfo, ComponentTesterInitialiserLC aEntryPoint)
sl@0
   205
	Intended Usage	: Completes the safe construction of the CTestController object
sl@0
   206
	@leave  		KErrNoMemory.
sl@0
   207
	@since			7.0
sl@0
   208
	@param			aLogInfo The logging configuration information
sl@0
   209
	@param			aEntryPoint The global function used to create the derived CComponentTester object.
sl@0
   210
	@pre 			First phase of construction is complete
sl@0
   211
	@post			Object is fully constructed
sl@0
   212
 */
sl@0
   213
	
sl@0
   214
	void ConstructL(TLoggingInfo* aLogInfo, ComponentTesterInitialiserLC aEntryPoint);
sl@0
   215
sl@0
   216
/**
sl@0
   217
	@fn				void InitialiseComponentTesterL(ComponentTesterInitialiserLC aEntryPointLC)
sl@0
   218
	@leave  		KErrNoMemory.
sl@0
   219
	Intended Usage	:	Called during construction to find all test modules
sl@0
   220
	Error Condition	:	
sl@0
   221
	@since			7.0
sl@0
   222
	@param			aEntryPointLC The global function used to create the derived CComponentTester object.
sl@0
   223
	@pre 			None
sl@0
   224
	@post			A list of all tests is available
sl@0
   225
 */
sl@0
   226
	void InitialiseComponentTesterL(ComponentTesterInitialiserLC aEntryPointLC);
sl@0
   227
sl@0
   228
/**
sl@0
   229
	@fn				TestsComplete()
sl@0
   230
	Intended Usage	:	Called by the CTestManager to indicate that all tests
sl@0
   231
					are complete.  Either stops the active scheduler if in 
sl@0
   232
					synchronous mode or completes the client if in async mode.
sl@0
   233
	@since			7.0
sl@0
   234
	@pre 			This object is constructed
sl@0
   235
	@post			Appropriate action is taken to complete the tests.
sl@0
   236
 */
sl@0
   237
	void TestsComplete();
sl@0
   238
sl@0
   239
private:
sl@0
   240
/** Starts the tests and stops the active scheduler when finished*/
sl@0
   241
	
sl@0
   242
	CTestManager*			iTestManager;
sl@0
   243
/** A list of the available tests*/
sl@0
   244
	
sl@0
   245
	RPointerArray<CComponentInfo>	iTestList;
sl@0
   246
/** Placeholder for an active scheduler if one is passed in on creation */
sl@0
   247
	
sl@0
   248
	CActiveScheduler*	iScheduler;
sl@0
   249
/** Flag indicating if we own the active scheduler in iScheduler */
sl@0
   250
	
sl@0
   251
	TBool				iOwnScheduler;
sl@0
   252
/** Provides the file logging capability */
sl@0
   253
	
sl@0
   254
	CDataLogger*		iDataLogger;
sl@0
   255
/** The status word of the client (if tests were run asynchronously). Will be completed
sl@0
   256
	when all tests have finished running. */
sl@0
   257
	TRequestStatus* iClientStatus;
sl@0
   258
/** Optional reference to the RTest object used in the EXE test harness code which
sl@0
   259
	kicked off this test framework */
sl@0
   260
	RTest* iRTest;
sl@0
   261
	};  // End of CTestController definition
sl@0
   262
sl@0
   263
sl@0
   264
#endif // _INC_TESTCONTROLLER_3A34E468034A_INCLUDED