os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TestManagerTest/TestManagerUnitTest.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/TestManagerTest/TestManagerUnitTest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,237 @@
     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 CTestManager class.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "TestManagerUnitTest.h"
    1.22 +#include "TestController.h"
    1.23 +
    1.24 +extern CComponentTester* NewComponentTestLC_STUB(
    1.25 +	CDataLogger& aDataLogger,
    1.26 +	MComponentTestObserver&	aComponentTestObserver);
    1.27 +
    1.28 +// ______________________________________________________________________________
    1.29 +//
    1.30 +_LIT(KTestManagerCreateAndDestroyUnitTest,"CTestManager_CreateAndDestroy_UnitTest");
    1.31 +
    1.32 +CTestManager_CreateAndDestroy_UnitTest* CTestManager_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
    1.33 +											MUnitTestObserver& aObserver)
    1.34 +	{
    1.35 +	CTestManager_CreateAndDestroy_UnitTest* self = 
    1.36 +					new(ELeave) CTestManager_CreateAndDestroy_UnitTest(aDataLogger,
    1.37 +																aObserver);
    1.38 +	CleanupStack::PushL(self);
    1.39 +	self->ConstructL();
    1.40 +	CleanupStack::Pop();
    1.41 +	return self; 
    1.42 +	}
    1.43 +
    1.44 +inline TInt CTestManager_CreateAndDestroy_UnitTest::RunError(TInt aError)
    1.45 +	{
    1.46 +	// The RunL left so chain to the base first and then cleanup
    1.47 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
    1.48 +	delete iUTContext;
    1.49 +	iUTContext = NULL;
    1.50 +	delete iStateAccessor;
    1.51 +	iStateAccessor = NULL;
    1.52 +	/* delete any validators used */
    1.53 +	delete iCtorValidator;
    1.54 +	iCtorValidator = NULL;
    1.55 +	delete iDtorValidator;
    1.56 +	iDtorValidator = NULL;
    1.57 +
    1.58 +	return error;
    1.59 +	}
    1.60 +
    1.61 +inline CTestManager_CreateAndDestroy_UnitTest::~CTestManager_CreateAndDestroy_UnitTest()
    1.62 +	{
    1.63 +	// Simply delete our test class instance
    1.64 +	delete iUTContext;
    1.65 +	delete iStateAccessor;
    1.66 +	/* delete any validators used */
    1.67 +	delete iCtorValidator;
    1.68 +	delete iDtorValidator;
    1.69 +	}
    1.70 +
    1.71 +inline CTestManager_CreateAndDestroy_UnitTest::CTestManager_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
    1.72 +																	MUnitTestObserver& aObserver)
    1.73 +: CUnitTest(KTestManagerCreateAndDestroyUnitTest, aDataLogger, aObserver)
    1.74 +	{
    1.75 +	//Do nothing
    1.76 +	}
    1.77 +
    1.78 +// Now the Individual transitions need to be added.
    1.79 +inline void CTestManager_CreateAndDestroy_UnitTest::ConstructL()
    1.80 +	{
    1.81 +	// Perform the base class initialization
    1.82 +	UnitTestConstructL();
    1.83 +
    1.84 +	// Create the Unit test state accessor
    1.85 +	iStateAccessor = new(ELeave) TTestManager_StateAccessor;
    1.86 +	// Construct the Unit test context.
    1.87 +	iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
    1.88 +	iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
    1.89 +	// Construct, and store the observer stub
    1.90 +	iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
    1.91 +
    1.92 +	// Add the Transitions in the order they are to run
    1.93 +	// C'tor first, D'tor last...
    1.94 +	iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
    1.95 +	iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
    1.96 +
    1.97 +	AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
    1.98 +	AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
    1.99 +	}
   1.100 +
   1.101 +// ______________________________________________________________________________
   1.102 +//
   1.103 +_LIT(KTestManagerManageTestsUnitTest,"CTestManager_ManageTests_UnitTest");
   1.104 +
   1.105 +CTestManager_ManageTests_UnitTest* CTestManager_ManageTests_UnitTest::NewL(CDataLogger& aDataLogger,
   1.106 +											MUnitTestObserver& aObserver)
   1.107 +	{
   1.108 +	CTestManager_ManageTests_UnitTest* self = 
   1.109 +					new(ELeave) CTestManager_ManageTests_UnitTest(aDataLogger,
   1.110 +																aObserver);
   1.111 +	CleanupStack::PushL(self);
   1.112 +	self->ConstructL();
   1.113 +	CleanupStack::Pop();
   1.114 +	return self; 
   1.115 +	}
   1.116 +
   1.117 +inline TInt CTestManager_ManageTests_UnitTest::RunError(TInt aError)
   1.118 +	{
   1.119 +	// The RunL left so chain to the base first and then cleanup
   1.120 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.121 +	delete iUTContext;
   1.122 +	iUTContext = NULL;
   1.123 +	delete iStateAccessor;
   1.124 +	iStateAccessor = NULL;
   1.125 +	/* delete any validators used */
   1.126 +	delete iCtorValidator;
   1.127 +	iCtorValidator = NULL;
   1.128 +	delete iRunTestsValidator;
   1.129 +	iRunTestsValidator = NULL;
   1.130 +	delete iTestComponentValidator;
   1.131 +	iTestComponentValidator =NULL;
   1.132 +	delete iDtorValidator;
   1.133 +	iDtorValidator = NULL;
   1.134 +
   1.135 +	return error;
   1.136 +	}
   1.137 +
   1.138 +inline CTestManager_ManageTests_UnitTest::~CTestManager_ManageTests_UnitTest()
   1.139 +	{
   1.140 +	// Simply delete our test class instance
   1.141 +	delete iUTContext;
   1.142 +	delete iStateAccessor;
   1.143 +	/* delete any validators used */
   1.144 +	delete iCtorValidator;
   1.145 +	delete iRunTestsValidator;
   1.146 +	delete iTestComponentValidator;
   1.147 +	delete iDtorValidator;
   1.148 +	}
   1.149 +
   1.150 +inline CTestManager_ManageTests_UnitTest::CTestManager_ManageTests_UnitTest(CDataLogger& aDataLogger,
   1.151 +																	MUnitTestObserver& aObserver)
   1.152 +: CUnitTest(KTestManagerManageTestsUnitTest, aDataLogger, aObserver)
   1.153 +	{
   1.154 +	//Do nothing
   1.155 +	}
   1.156 +
   1.157 +// Now the Individual transitions need to be added.
   1.158 +inline void CTestManager_ManageTests_UnitTest::ConstructL()
   1.159 +	{
   1.160 +	// Perform the base class initialization
   1.161 +	UnitTestConstructL();
   1.162 +
   1.163 +	// Create the Unit test state accessor
   1.164 +	iStateAccessor = new(ELeave) TTestManager_StateAccessor;
   1.165 +	// Construct the Unit test context.
   1.166 +	iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   1.167 +	iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
   1.168 +	// Construct, and store the observer stub
   1.169 +	iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
   1.170 +
   1.171 +	CComponentInfo* compInfo = CComponentInfo::NewL(NewComponentTestLC_STUB, NULL);
   1.172 +	CleanupStack::PushL(compInfo);
   1.173 +	
   1.174 +	User::LeaveIfError(iUTContext->iTestListArray->Append(compInfo));
   1.175 +	CleanupStack::Pop(compInfo);
   1.176 +
   1.177 +
   1.178 +	// Add the Transitions in the order they are to run
   1.179 +	// C'tor first, D'tor last...
   1.180 +	iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
   1.181 +	iRunTestsValidator = new(ELeave) TTestManager_RunTests_TransitionValidator(*iUTContext);
   1.182 +	iTestComponentValidator = new(ELeave) TTestManager_TestComponent_TransitionValidator(*iUTContext);
   1.183 +	iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
   1.184 +
   1.185 +	AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
   1.186 +//	AddTransitionL(new(ELeave)CTestManager_RunTests_Transition(*iUTContext,*iRunTestsValidator));
   1.187 +	AddTransitionL(new(ELeave)CTestManager_TestComponentL_Transition(*iUTContext,*iTestComponentValidator));
   1.188 +	AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.189 +
   1.190 +	}
   1.191 +
   1.192 +// ______________________________________________________________________________
   1.193 +//
   1.194 +_LIT(KTestManagerCreateAndDestroyUnitTest_STUB,"CTestManager_CreateAndDestroy_UnitTest_STUB");
   1.195 +
   1.196 +CTestManager_CreateAndDestroy_UnitTest_STUB* CTestManager_CreateAndDestroy_UnitTest_STUB::NewL(CDataLogger& aDataLogger,
   1.197 +											MUnitTestObserver& aObserver)
   1.198 +	{
   1.199 +	CTestManager_CreateAndDestroy_UnitTest_STUB* self = 
   1.200 +					new(ELeave) CTestManager_CreateAndDestroy_UnitTest_STUB(aDataLogger,
   1.201 +																aObserver);
   1.202 +	CleanupStack::PushL(self);
   1.203 +	self->ConstructL();
   1.204 +	CleanupStack::Pop();
   1.205 +	return self; 
   1.206 +	}
   1.207 +
   1.208 +inline TInt CTestManager_CreateAndDestroy_UnitTest_STUB::RunError(TInt aError)
   1.209 +	{
   1.210 +	// The RunL left so chain to the base first and then cleanup
   1.211 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.212 +
   1.213 +	//Do nothing else since stub
   1.214 +
   1.215 +	return error;
   1.216 +	}
   1.217 +
   1.218 +inline CTestManager_CreateAndDestroy_UnitTest_STUB::~CTestManager_CreateAndDestroy_UnitTest_STUB()
   1.219 +	{
   1.220 +	//Do nothing
   1.221 +	}
   1.222 +
   1.223 +inline CTestManager_CreateAndDestroy_UnitTest_STUB::CTestManager_CreateAndDestroy_UnitTest_STUB(CDataLogger& aDataLogger,
   1.224 +																	MUnitTestObserver& aObserver)
   1.225 +: CUnitTest(KTestManagerCreateAndDestroyUnitTest_STUB, aDataLogger, aObserver)
   1.226 +	{
   1.227 +	//Do nothing
   1.228 +	}
   1.229 +
   1.230 +// Now the Individual transitions need to be added.
   1.231 +inline void CTestManager_CreateAndDestroy_UnitTest_STUB::ConstructL()
   1.232 +	{
   1.233 +	// Perform the base class initialization
   1.234 +	UnitTestConstructL();
   1.235 +
   1.236 +	//Do nothing else since stub
   1.237 +	}
   1.238 +
   1.239 +
   1.240 +