os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/ComponentTesterTest/ComponentTesterUnitTest.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/ComponentTesterTest/ComponentTesterUnitTest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,266 @@
     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 +// The unit test class implementations for the CComponentTester class.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "ComponentTesterUnitTest.h"
    1.22 +
    1.23 +// ______________________________________________________________________________
    1.24 +//
    1.25 +_LIT(KComponentTesterCreateAndDestroyUnitTest,"CComponentTester_CreateAndDestroy_UnitTest");
    1.26 +
    1.27 +CComponentTester_CreateAndDestroy_UnitTest* CComponentTester_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
    1.28 +											MUnitTestObserver& aObserver)
    1.29 +	{
    1.30 +	CComponentTester_CreateAndDestroy_UnitTest* self = 
    1.31 +					new(ELeave) CComponentTester_CreateAndDestroy_UnitTest(aDataLogger,
    1.32 +																aObserver);
    1.33 +	CleanupStack::PushL(self);
    1.34 +	self->ConstructL();
    1.35 +	CleanupStack::Pop();
    1.36 +	return self; 
    1.37 +	}
    1.38 +
    1.39 +inline TInt CComponentTester_CreateAndDestroy_UnitTest::RunError(TInt aError)
    1.40 +	{
    1.41 +	// The RunL left so chain to the base first and then cleanup
    1.42 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
    1.43 +	delete iUTContext;
    1.44 +	iUTContext = NULL;
    1.45 +	delete iStateAccessor;
    1.46 +	iStateAccessor = NULL;
    1.47 +	/* delete any validators used */
    1.48 +	delete iCtorValidator;
    1.49 +	iCtorValidator = NULL;
    1.50 +	delete iDtorValidator;
    1.51 +	iDtorValidator = NULL;
    1.52 +	return error;
    1.53 +	}
    1.54 +
    1.55 +inline CComponentTester_CreateAndDestroy_UnitTest::~CComponentTester_CreateAndDestroy_UnitTest()
    1.56 +	{
    1.57 +	// Simply delete our test class instance
    1.58 +	delete iUTContext;
    1.59 +	delete iStateAccessor;
    1.60 +	/* delete any validators used */
    1.61 +	delete iCtorValidator;
    1.62 +	delete iDtorValidator;
    1.63 +	}
    1.64 +
    1.65 +inline CComponentTester_CreateAndDestroy_UnitTest::CComponentTester_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
    1.66 +																	MUnitTestObserver& aObserver)
    1.67 +: CUnitTest(KComponentTesterCreateAndDestroyUnitTest, aDataLogger, aObserver)
    1.68 +	{
    1.69 +	//Do nothing
    1.70 +	}
    1.71 +
    1.72 +// Now the Individual transitions need to be added.
    1.73 +inline void CComponentTester_CreateAndDestroy_UnitTest::ConstructL()
    1.74 +	{
    1.75 +	// Perform the base class initialization
    1.76 +	UnitTestConstructL();
    1.77 +
    1.78 +	// Create the Unit test state accessor
    1.79 +	iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
    1.80 +	// Construct the Unit test context.
    1.81 +	iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
    1.82 +
    1.83 +	// Add the Transitions in the order they are to run
    1.84 +	// C'tor first, D'tor last...
    1.85 +	iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
    1.86 +	iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
    1.87 +
    1.88 +	AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
    1.89 +	AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));
    1.90 +	}
    1.91 +
    1.92 +// ______________________________________________________________________________
    1.93 +//
    1.94 +_LIT(KComponentTesterManageUnitTestsUnitTest,"CComponentTester_ManageUnitTests_UnitTest");
    1.95 +
    1.96 +CComponentTester_ManageUnitTests_UnitTest* CComponentTester_ManageUnitTests_UnitTest::NewL(CDataLogger& aDataLogger,
    1.97 +											MUnitTestObserver& aObserver)
    1.98 +	{
    1.99 +	CComponentTester_ManageUnitTests_UnitTest* self = 
   1.100 +					new(ELeave) CComponentTester_ManageUnitTests_UnitTest(aDataLogger,
   1.101 +																aObserver);
   1.102 +	CleanupStack::PushL(self);
   1.103 +	self->ConstructL();
   1.104 +	CleanupStack::Pop();
   1.105 +	return self; 
   1.106 +	}
   1.107 +
   1.108 +inline TInt CComponentTester_ManageUnitTests_UnitTest::RunError(TInt aError)
   1.109 +	{
   1.110 +	// The RunL left so chain to the base first and then cleanup
   1.111 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.112 +	delete iUTContext;
   1.113 +	iUTContext = NULL;
   1.114 +	delete iStateAccessor;
   1.115 +	iStateAccessor = NULL;
   1.116 +	/* delete any validators used */
   1.117 +	delete iCtorValidator;
   1.118 +	iCtorValidator = NULL;
   1.119 +	delete iTransitionSetsValidator;
   1.120 +	iTransitionSetsValidator = NULL;
   1.121 +	delete iAddUnitTestValidator;
   1.122 +	iAddUnitTestValidator = NULL;
   1.123 +	delete iAddParamUnitTestValidator;
   1.124 +	iAddParamUnitTestValidator = NULL;
   1.125 +	delete iDtorValidator;
   1.126 +	iDtorValidator = NULL;
   1.127 +	return error;
   1.128 +	}
   1.129 +
   1.130 +inline CComponentTester_ManageUnitTests_UnitTest::~CComponentTester_ManageUnitTests_UnitTest()
   1.131 +	{
   1.132 +	// Simply delete our test class instance
   1.133 +	delete iUTContext;
   1.134 +	delete iStateAccessor;
   1.135 +	/* delete any validators used */
   1.136 +	delete iCtorValidator;
   1.137 +	delete iTransitionSetsValidator;
   1.138 +	delete iAddUnitTestValidator;
   1.139 +	delete iAddParamUnitTestValidator;
   1.140 +	delete iDtorValidator;
   1.141 +	}
   1.142 +
   1.143 +inline CComponentTester_ManageUnitTests_UnitTest::CComponentTester_ManageUnitTests_UnitTest(CDataLogger& aDataLogger,
   1.144 +																	MUnitTestObserver& aObserver)
   1.145 +: CUnitTest(KComponentTesterManageUnitTestsUnitTest, aDataLogger, aObserver)
   1.146 +	{
   1.147 +	//Do nothing
   1.148 +	}
   1.149 +
   1.150 +// Now the Individual transitions need to be added.
   1.151 +inline void CComponentTester_ManageUnitTests_UnitTest::ConstructL()
   1.152 +	{
   1.153 +	// Perform the base class initialization
   1.154 +	UnitTestConstructL();
   1.155 +
   1.156 +	// Create the Unit test state accessor
   1.157 +	iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
   1.158 +	// Construct the Unit test context.
   1.159 +	iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   1.160 +
   1.161 +	// Add the Transitions in the order they are to run
   1.162 +	// C'tor first, D'tor last...
   1.163 +	iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
   1.164 +	iTransitionSetsValidator = new(ELeave) TComponentTester_TransitionSets_TransitionValidator(*iUTContext);
   1.165 +	iAddUnitTestValidator = new(ELeave) TComponentTester_AddUnitTest_TransitionValidator(*iUTContext);
   1.166 +	iAddParamUnitTestValidator = new(ELeave) TComponentTester_AddParamUnitTest_TransitionValidator(*iUTContext);
   1.167 +	iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
   1.168 +
   1.169 +	AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
   1.170 +	AddTransitionL(new(ELeave)CComponentTester_TransitionSetsL_Transition(*iUTContext,*iTransitionSetsValidator));
   1.171 +	AddTransitionL(new(ELeave)CComponentTester_AddUnitTestL_Transition(*iUTContext,*iAddUnitTestValidator));
   1.172 +	AddTransitionL(new(ELeave)CComponentTester_AddParamUnitTestL_Transition(*iUTContext,*iAddParamUnitTestValidator));
   1.173 +	AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.174 +	}
   1.175 +
   1.176 +// ______________________________________________________________________________
   1.177 +//
   1.178 +_LIT(KComponentTesterRunTestsUnitTest,"CComponentTester_RunTests_UnitTest");
   1.179 +
   1.180 +CComponentTester_RunTests_UnitTest* CComponentTester_RunTests_UnitTest::NewL(CDataLogger& aDataLogger,
   1.181 +											MUnitTestObserver& aObserver)
   1.182 +	{
   1.183 +	CComponentTester_RunTests_UnitTest* self = 
   1.184 +					new(ELeave) CComponentTester_RunTests_UnitTest(aDataLogger,
   1.185 +																aObserver);
   1.186 +	CleanupStack::PushL(self);
   1.187 +	self->ConstructL();
   1.188 +	CleanupStack::Pop();
   1.189 +	return self; 
   1.190 +	}
   1.191 +
   1.192 +inline TInt CComponentTester_RunTests_UnitTest::RunError(TInt aError)
   1.193 +	{
   1.194 +	// The RunL left so chain to the base first and then cleanup
   1.195 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.196 +	delete iUTContext;
   1.197 +	iUTContext = NULL;
   1.198 +	delete iStateAccessor;
   1.199 +	iStateAccessor = NULL;
   1.200 +	/* delete any validators used */
   1.201 +	delete iCtorValidator;
   1.202 +	iCtorValidator = NULL;
   1.203 +	delete iTestComponentValidator;
   1.204 +	iTestComponentValidator = NULL;
   1.205 +	delete iRunValidator;
   1.206 +	iRunValidator = NULL;
   1.207 +	delete iCompleteValidator;
   1.208 +	iCompleteValidator = NULL;
   1.209 +	delete iDtorValidator;
   1.210 +	iDtorValidator = NULL;
   1.211 +	return error;
   1.212 +	}
   1.213 +
   1.214 +inline CComponentTester_RunTests_UnitTest::~CComponentTester_RunTests_UnitTest()
   1.215 +	{
   1.216 +	// Simply delete our test class instance
   1.217 +	delete iUTContext;
   1.218 +	delete iStateAccessor;
   1.219 +	/* delete any validators used */
   1.220 +	delete iCtorValidator;
   1.221 +	delete iTestComponentValidator;
   1.222 +	delete iRunValidator;
   1.223 +	delete iCompleteValidator;
   1.224 +	delete iDtorValidator;
   1.225 +	}
   1.226 +
   1.227 +inline CComponentTester_RunTests_UnitTest::CComponentTester_RunTests_UnitTest(CDataLogger& aDataLogger,
   1.228 +																	MUnitTestObserver& aObserver)
   1.229 +: CUnitTest(KComponentTesterRunTestsUnitTest, aDataLogger, aObserver)
   1.230 +	{
   1.231 +	//Do nothing
   1.232 +	}
   1.233 +
   1.234 +// Now the Individual transitions need to be added.
   1.235 +inline void CComponentTester_RunTests_UnitTest::ConstructL()
   1.236 +	{
   1.237 +	// Perform the base class initialization
   1.238 +	UnitTestConstructL();
   1.239 +
   1.240 +	// Create the Unit test state accessor
   1.241 +	iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
   1.242 +	// Construct the Unit test context.
   1.243 +	iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   1.244 +
   1.245 +	// Specify the tests to be run by the TestComponent method. 0 means run all tests
   1.246 +//	iUTContext->iTests = 0;
   1.247 +	TTestInfo* testInfo = new(ELeave) TTestInfo;
   1.248 +	testInfo->iComponentId = 0;		// Run the first component found
   1.249 +	testInfo->iUnitTestId = 0;		// Run the first unit test from the the component found
   1.250 +	testInfo->iRunTime = 0;			// Run the test immediately
   1.251 +	testInfo->iParameters = NULL;
   1.252 +	User::LeaveIfError(iUTContext->iTests.Append(testInfo));
   1.253 +
   1.254 +	// Add the Transitions in the order they are to run
   1.255 +	// C'tor first, D'tor last...
   1.256 +	iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
   1.257 +	iTestComponentValidator = new(ELeave) TComponentTester_TestComponent_TransitionValidator(*iUTContext);
   1.258 +	iRunValidator = new(ELeave) TComponentTester_Run_TransitionValidator(*iUTContext);
   1.259 +	iCompleteValidator = new(ELeave) TComponentTester_Complete_TransitionValidator(*iUTContext);
   1.260 +	iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
   1.261 +
   1.262 +	AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
   1.263 +	AddTransitionL(new(ELeave)CComponentTester_TestComponent_Transition(*iUTContext,*iTestComponentValidator));
   1.264 +	AddTransitionL(new(ELeave)CComponentTester_RunL_Transition(*iUTContext,*iRunValidator));
   1.265 +	AddTransitionL(new(ELeave)CComponentTester_Complete_Transition(*iUTContext,*iCompleteValidator));
   1.266 +	AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.267 +	}
   1.268 +
   1.269 +