sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // The unit test class implementations for the CComponentTester class. sl@0: // sl@0: // sl@0: sl@0: #include "ComponentTesterUnitTest.h" sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KComponentTesterCreateAndDestroyUnitTest,"CComponentTester_CreateAndDestroy_UnitTest"); sl@0: sl@0: CComponentTester_CreateAndDestroy_UnitTest* CComponentTester_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CComponentTester_CreateAndDestroy_UnitTest* self = sl@0: new(ELeave) CComponentTester_CreateAndDestroy_UnitTest(aDataLogger, sl@0: aObserver); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: inline TInt CComponentTester_CreateAndDestroy_UnitTest::RunError(TInt aError) sl@0: { sl@0: // The RunL left so chain to the base first and then cleanup sl@0: TInt error = CUnitTest::RunError(aError); // Chain to base sl@0: delete iUTContext; sl@0: iUTContext = NULL; sl@0: delete iStateAccessor; sl@0: iStateAccessor = NULL; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: iCtorValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: return error; sl@0: } sl@0: sl@0: inline CComponentTester_CreateAndDestroy_UnitTest::~CComponentTester_CreateAndDestroy_UnitTest() sl@0: { sl@0: // Simply delete our test class instance sl@0: delete iUTContext; sl@0: delete iStateAccessor; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CComponentTester_CreateAndDestroy_UnitTest::CComponentTester_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KComponentTesterCreateAndDestroyUnitTest, aDataLogger, aObserver) sl@0: { sl@0: //Do nothing sl@0: } sl@0: sl@0: // Now the Individual transitions need to be added. sl@0: inline void CComponentTester_CreateAndDestroy_UnitTest::ConstructL() sl@0: { sl@0: // Perform the base class initialization sl@0: UnitTestConstructL(); sl@0: sl@0: // Create the Unit test state accessor sl@0: iStateAccessor = new(ELeave) TComponentTester_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this); sl@0: sl@0: // Add the Transitions in the order they are to run sl@0: // C'tor first, D'tor last... sl@0: iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KComponentTesterManageUnitTestsUnitTest,"CComponentTester_ManageUnitTests_UnitTest"); sl@0: sl@0: CComponentTester_ManageUnitTests_UnitTest* CComponentTester_ManageUnitTests_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CComponentTester_ManageUnitTests_UnitTest* self = sl@0: new(ELeave) CComponentTester_ManageUnitTests_UnitTest(aDataLogger, sl@0: aObserver); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: inline TInt CComponentTester_ManageUnitTests_UnitTest::RunError(TInt aError) sl@0: { sl@0: // The RunL left so chain to the base first and then cleanup sl@0: TInt error = CUnitTest::RunError(aError); // Chain to base sl@0: delete iUTContext; sl@0: iUTContext = NULL; sl@0: delete iStateAccessor; sl@0: iStateAccessor = NULL; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: iCtorValidator = NULL; sl@0: delete iTransitionSetsValidator; sl@0: iTransitionSetsValidator = NULL; sl@0: delete iAddUnitTestValidator; sl@0: iAddUnitTestValidator = NULL; sl@0: delete iAddParamUnitTestValidator; sl@0: iAddParamUnitTestValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: return error; sl@0: } sl@0: sl@0: inline CComponentTester_ManageUnitTests_UnitTest::~CComponentTester_ManageUnitTests_UnitTest() sl@0: { sl@0: // Simply delete our test class instance sl@0: delete iUTContext; sl@0: delete iStateAccessor; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: delete iTransitionSetsValidator; sl@0: delete iAddUnitTestValidator; sl@0: delete iAddParamUnitTestValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CComponentTester_ManageUnitTests_UnitTest::CComponentTester_ManageUnitTests_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KComponentTesterManageUnitTestsUnitTest, aDataLogger, aObserver) sl@0: { sl@0: //Do nothing sl@0: } sl@0: sl@0: // Now the Individual transitions need to be added. sl@0: inline void CComponentTester_ManageUnitTests_UnitTest::ConstructL() sl@0: { sl@0: // Perform the base class initialization sl@0: UnitTestConstructL(); sl@0: sl@0: // Create the Unit test state accessor sl@0: iStateAccessor = new(ELeave) TComponentTester_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this); sl@0: sl@0: // Add the Transitions in the order they are to run sl@0: // C'tor first, D'tor last... sl@0: iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext); sl@0: iTransitionSetsValidator = new(ELeave) TComponentTester_TransitionSets_TransitionValidator(*iUTContext); sl@0: iAddUnitTestValidator = new(ELeave) TComponentTester_AddUnitTest_TransitionValidator(*iUTContext); sl@0: iAddParamUnitTestValidator = new(ELeave) TComponentTester_AddParamUnitTest_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_TransitionSetsL_Transition(*iUTContext,*iTransitionSetsValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_AddUnitTestL_Transition(*iUTContext,*iAddUnitTestValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_AddParamUnitTestL_Transition(*iUTContext,*iAddParamUnitTestValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KComponentTesterRunTestsUnitTest,"CComponentTester_RunTests_UnitTest"); sl@0: sl@0: CComponentTester_RunTests_UnitTest* CComponentTester_RunTests_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CComponentTester_RunTests_UnitTest* self = sl@0: new(ELeave) CComponentTester_RunTests_UnitTest(aDataLogger, sl@0: aObserver); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: inline TInt CComponentTester_RunTests_UnitTest::RunError(TInt aError) sl@0: { sl@0: // The RunL left so chain to the base first and then cleanup sl@0: TInt error = CUnitTest::RunError(aError); // Chain to base sl@0: delete iUTContext; sl@0: iUTContext = NULL; sl@0: delete iStateAccessor; sl@0: iStateAccessor = NULL; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: iCtorValidator = NULL; sl@0: delete iTestComponentValidator; sl@0: iTestComponentValidator = NULL; sl@0: delete iRunValidator; sl@0: iRunValidator = NULL; sl@0: delete iCompleteValidator; sl@0: iCompleteValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: return error; sl@0: } sl@0: sl@0: inline CComponentTester_RunTests_UnitTest::~CComponentTester_RunTests_UnitTest() sl@0: { sl@0: // Simply delete our test class instance sl@0: delete iUTContext; sl@0: delete iStateAccessor; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: delete iTestComponentValidator; sl@0: delete iRunValidator; sl@0: delete iCompleteValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CComponentTester_RunTests_UnitTest::CComponentTester_RunTests_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KComponentTesterRunTestsUnitTest, aDataLogger, aObserver) sl@0: { sl@0: //Do nothing sl@0: } sl@0: sl@0: // Now the Individual transitions need to be added. sl@0: inline void CComponentTester_RunTests_UnitTest::ConstructL() sl@0: { sl@0: // Perform the base class initialization sl@0: UnitTestConstructL(); sl@0: sl@0: // Create the Unit test state accessor sl@0: iStateAccessor = new(ELeave) TComponentTester_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this); sl@0: sl@0: // Specify the tests to be run by the TestComponent method. 0 means run all tests sl@0: // iUTContext->iTests = 0; sl@0: TTestInfo* testInfo = new(ELeave) TTestInfo; sl@0: testInfo->iComponentId = 0; // Run the first component found sl@0: testInfo->iUnitTestId = 0; // Run the first unit test from the the component found sl@0: testInfo->iRunTime = 0; // Run the test immediately sl@0: testInfo->iParameters = NULL; sl@0: User::LeaveIfError(iUTContext->iTests.Append(testInfo)); sl@0: sl@0: // Add the Transitions in the order they are to run sl@0: // C'tor first, D'tor last... sl@0: iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext); sl@0: iTestComponentValidator = new(ELeave) TComponentTester_TestComponent_TransitionValidator(*iUTContext); sl@0: iRunValidator = new(ELeave) TComponentTester_Run_TransitionValidator(*iUTContext); sl@0: iCompleteValidator = new(ELeave) TComponentTester_Complete_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_TestComponent_Transition(*iUTContext,*iTestComponentValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_RunL_Transition(*iUTContext,*iRunValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_Complete_Transition(*iUTContext,*iCompleteValidator)); sl@0: AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: