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 CTestController class. sl@0: // sl@0: // sl@0: sl@0: #include "TestControllerUnitTest.h" sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerCreateAndDestroyUnitTest,"CTestController_CreateAndDestroy_UnitTest"); sl@0: sl@0: CTestController_CreateAndDestroy_UnitTest* CTestController_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CTestController_CreateAndDestroy_UnitTest* self = sl@0: new(ELeave) CTestController_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 CTestController_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: sl@0: return error; sl@0: } sl@0: sl@0: inline CTestController_CreateAndDestroy_UnitTest::~CTestController_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: iFs.Close(); sl@0: delete iCtorValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CTestController_CreateAndDestroy_UnitTest::CTestController_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KTestControllerCreateAndDestroyUnitTest, aDataLogger, aObserver) sl@0: { sl@0: //Do nothing sl@0: } sl@0: sl@0: _LIT(KLogTitle,"Dummy Log title"); sl@0: sl@0: // Now the Individual transitions need to be added. sl@0: inline void CTestController_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) TTestController_StateAccessor; sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CTestController_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs); sl@0: iUTContext->iScheduler = new(ELeave) CActiveScheduler; sl@0: iUTContext->iLogInfo = new(ELeave) TLoggingInfo; sl@0: iUTContext->iLogInfo->iTitle = &(KLogTitle); sl@0: iUTContext->iLogInfo->iUseRDebug = ETrue; sl@0: iUTContext->iLogInfo->iLogOutput = 0; sl@0: iUTContext->iLogInfo->iReportOutput = 0; sl@0: iUTContext->iLogInfo->iStyle = EHtml; 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) TTestController_Ctor_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TTestController_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CTestController_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CTestController_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerFindTestsUnitTest,"CTestController_FindTests_UnitTest"); sl@0: sl@0: CTestController_FindTests_UnitTest* CTestController_FindTests_UnitTest::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CTestController_FindTests_UnitTest* self = sl@0: new(ELeave) CTestController_FindTests_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 CTestController_FindTests_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 iFindComponentsValidator; sl@0: iFindComponentsValidator = NULL; sl@0: delete iStartValidator; sl@0: iStartValidator = NULL; sl@0: delete iDtorValidator; sl@0: iDtorValidator = NULL; sl@0: sl@0: return error; sl@0: } sl@0: sl@0: inline CTestController_FindTests_UnitTest::~CTestController_FindTests_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: iFs.Close(); sl@0: delete iCtorValidator; sl@0: delete iFindComponentsValidator; sl@0: delete iStartValidator; sl@0: delete iDtorValidator; sl@0: } sl@0: sl@0: inline CTestController_FindTests_UnitTest::CTestController_FindTests_UnitTest(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KTestControllerFindTestsUnitTest, 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 CTestController_FindTests_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) TTestController_StateAccessor; sl@0: // Construct the Unit test context. sl@0: sl@0: // Open the required file server connection sl@0: User::LeaveIfError(iFs.Connect()); sl@0: sl@0: // Construct the Unit test context. sl@0: iUTContext = new(ELeave) CTestController_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs); sl@0: iUTContext->iScheduler = new(ELeave) CActiveScheduler; sl@0: iUTContext->iLogInfo = new(ELeave) TLoggingInfo; sl@0: iUTContext->iLogInfo->iTitle = &(KLogTitle); sl@0: iUTContext->iLogInfo->iUseRDebug = ETrue; sl@0: iUTContext->iLogInfo->iLogOutput = 0; sl@0: iUTContext->iLogInfo->iReportOutput = 0; sl@0: iUTContext->iLogInfo->iStyle = EHtml; 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) TTestController_Ctor_TransitionValidator(*iUTContext); sl@0: iFindComponentsValidator = new(ELeave) TTestController_FindComponents_TransitionValidator(*iUTContext); sl@0: iStartValidator = new(ELeave) TTestController_Start_TransitionValidator(*iUTContext); sl@0: iDtorValidator = new(ELeave) TTestController_Dtor_TransitionValidator(*iUTContext); sl@0: sl@0: AddTransitionL(new(ELeave)CTestController_NewL_Transition(*iUTContext,*iCtorValidator)); sl@0: AddTransitionL(new(ELeave)CTestController_FindComponents_Transition(*iUTContext, *iFindComponentsValidator)); sl@0: AddTransitionL(new(ELeave)CTestController_Start_Transition(*iUTContext, *iStartValidator)); sl@0: AddTransitionL(new(ELeave)CTestController_Dtor_Transition(*iUTContext,*iDtorValidator)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerCreateAndDestroyUnitTest_STUB,"CTestController_CreateAndDestroy_UnitTest_STUB"); sl@0: sl@0: CTestController_CreateAndDestroy_UnitTest_STUB* CTestController_CreateAndDestroy_UnitTest_STUB::NewL(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: { sl@0: CTestController_CreateAndDestroy_UnitTest_STUB* self = sl@0: new(ELeave) CTestController_CreateAndDestroy_UnitTest_STUB(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 CTestController_CreateAndDestroy_UnitTest_STUB::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: sl@0: //Do nothing else since stub sl@0: sl@0: return error; sl@0: } sl@0: sl@0: inline CTestController_CreateAndDestroy_UnitTest_STUB::~CTestController_CreateAndDestroy_UnitTest_STUB() sl@0: { sl@0: //Do nothing sl@0: } sl@0: sl@0: inline CTestController_CreateAndDestroy_UnitTest_STUB::CTestController_CreateAndDestroy_UnitTest_STUB(CDataLogger& aDataLogger, sl@0: MUnitTestObserver& aObserver) sl@0: : CUnitTest(KTestControllerCreateAndDestroyUnitTest_STUB, 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 CTestController_CreateAndDestroy_UnitTest_STUB::ConstructL() sl@0: { sl@0: // Perform the base class initialization sl@0: UnitTestConstructL(); sl@0: sl@0: //Do nothing else since stub sl@0: }