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 CUnitTest class. sl@0: // sl@0: // sl@0: sl@0: #include "UnitTestUnitTest.h" sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KUnitTestCreateAndDestroyUnitTest,"CUnitTest_CreateAndDestroy_UnitTest"); sl@0: sl@0: CUnitTest_CreateAndDestroy_UnitTest* CUnitTest_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CUnitTest_CreateAndDestroy_UnitTest* self = sl@0: new(ELeave) CUnitTest_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 CUnitTest_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: delete iStateAccessor; 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 CUnitTest_CreateAndDestroy_UnitTest::~CUnitTest_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 CUnitTest_CreateAndDestroy_UnitTest::CUnitTest_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KUnitTestCreateAndDestroyUnitTest, 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 CUnitTest_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) TUnitTest_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CUnitTest_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) TUnitTest_Ctor_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KUnitTestManageTransitionsUnitTest,"CUnitTest_ManageTransitions_UnitTest"); sl@0: sl@0: CUnitTest_ManageTransitions_UnitTest* CUnitTest_ManageTransitions_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CUnitTest_ManageTransitions_UnitTest* self = sl@0: new(ELeave) CUnitTest_ManageTransitions_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 CUnitTest_ManageTransitions_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: delete iStateAccessor; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: iCtorValidator = NULL; sl@0: delete iTransitionSetValidator; sl@0: iTransitionSetValidator = NULL; sl@0: delete iGetCurrentTransitionValidator; sl@0: iGetCurrentTransitionValidator = NULL; sl@0: delete iSetCurrentTransitionValidator; sl@0: iSetCurrentTransitionValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: return error; sl@0: } sl@0: sl@0: inline CUnitTest_ManageTransitions_UnitTest::~CUnitTest_ManageTransitions_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 iTransitionSetValidator; sl@0: delete iGetCurrentTransitionValidator; sl@0: delete iSetCurrentTransitionValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CUnitTest_ManageTransitions_UnitTest::CUnitTest_ManageTransitions_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KUnitTestManageTransitionsUnitTest, 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 CUnitTest_ManageTransitions_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) TUnitTest_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CUnitTest_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) TUnitTest_Ctor_TransitionValidator(*iUTContext); sl@0: iTransitionSetValidator = new(ELeave) TUnitTest_TransitionSet_TransitionValidator(*iUTContext); sl@0: iGetCurrentTransitionValidator = new(ELeave) TUnitTest_GetCurrentTransition_TransitionValidator(*iUTContext); sl@0: iSetCurrentTransitionValidator = new(ELeave) TUnitTest_SetCurrentTransition_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_TransitionSetL_Transition(*iUTContext,*iTransitionSetValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_GetCurrentTransition_Transition(*iUTContext,*iGetCurrentTransitionValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_SetCurrentTransition_Transition(*iUTContext,*iSetCurrentTransitionValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KUnitTestRunTestsUnitTest,"CUnitTest_RunTests_UnitTest"); sl@0: sl@0: CUnitTest_RunTests_UnitTest* CUnitTest_RunTests_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CUnitTest_RunTests_UnitTest* self = sl@0: new(ELeave) CUnitTest_RunTests_UnitTest(aDataLogger, sl@0: aObserver); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: inline TInt CUnitTest_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 iSetParametersValidator; sl@0: iSetParametersValidator = NULL; sl@0: delete iPrepareUnitTestValidator; sl@0: iPrepareUnitTestValidator = NULL; sl@0: delete iRunTestValidator; sl@0: iRunTestValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: return error; sl@0: } sl@0: sl@0: inline CUnitTest_RunTests_UnitTest::~CUnitTest_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 iSetParametersValidator; sl@0: delete iPrepareUnitTestValidator; sl@0: delete iRunTestValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CUnitTest_RunTests_UnitTest::CUnitTest_RunTests_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KUnitTestRunTestsUnitTest, 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 CUnitTest_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) TUnitTest_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CUnitTest_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) TUnitTest_Ctor_TransitionValidator(*iUTContext); sl@0: iSetParametersValidator = new(ELeave) TUnitTest_SetParameters_TransitionValidator(*iUTContext); sl@0: iPrepareUnitTestValidator = new(ELeave) TUnitTest_PrepareUnitTest_TransitionValidator(*iUTContext); sl@0: iRunTestValidator = new(ELeave) TUnitTest_RunTest_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_SetParametersL_Transition(*iUTContext,*iSetParametersValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_PrepareUnitTestL_Transition(*iUTContext,*iPrepareUnitTestValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_RunTest_Transition(*iUTContext,*iRunTestValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KUnitTestAllOtherUnitTest,"CUnitTest_AllOther_UnitTest"); sl@0: sl@0: CUnitTest_AllOther_UnitTest* CUnitTest_AllOther_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CUnitTest_AllOther_UnitTest* self = sl@0: new(ELeave) CUnitTest_AllOther_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 CUnitTest_AllOther_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: delete iStateAccessor; sl@0: /* delete any validators used */ sl@0: delete iCtorValidator; sl@0: iCtorValidator = NULL; sl@0: delete iAddTransitionValidator; sl@0: iAddTransitionValidator = NULL; sl@0: delete iAddBlockingTransitionValidator; sl@0: iAddBlockingTransitionValidator = NULL; sl@0: delete iAddLeaveErrorCodeValidator; sl@0: iAddLeaveErrorCodeValidator = NULL; sl@0: delete iUnitTestNameValidator; sl@0: iUnitTestNameValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: sl@0: return error; sl@0: } sl@0: sl@0: inline CUnitTest_AllOther_UnitTest::~CUnitTest_AllOther_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 iAddTransitionValidator; sl@0: delete iAddBlockingTransitionValidator; sl@0: delete iAddLeaveErrorCodeValidator; sl@0: delete iUnitTestNameValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CUnitTest_AllOther_UnitTest::CUnitTest_AllOther_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KUnitTestAllOtherUnitTest, 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 CUnitTest_AllOther_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) TUnitTest_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CUnitTest_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) TUnitTest_Ctor_TransitionValidator(*iUTContext); sl@0: iAddTransitionValidator = new(ELeave) TUnitTest_AddTransition_TransitionValidator(*iUTContext); sl@0: iAddBlockingTransitionValidator = new(ELeave) TUnitTest_AddBlockingTransition_TransitionValidator(*iUTContext); sl@0: iAddLeaveErrorCodeValidator = new(ELeave) TUnitTest_AddLeaveErrorCode_TransitionValidator(*iUTContext); sl@0: iUnitTestNameValidator = new(ELeave) TUnitTest_UnitTestName_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_AddTransitionL_Transition(*iUTContext,*iAddTransitionValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_AddBlockingTransitionL_Transition(*iUTContext,*iAddBlockingTransitionValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_AddLeaveErrorCodeL_Transition(*iUTContext,*iAddLeaveErrorCodeValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_UnitTestName_Transition(*iUTContext,*iUnitTestNameValidator)); sl@0: AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: