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 implementation of the transition classes upon the CTestController class methods. sl@0: // sl@0: // sl@0: sl@0: IMPORT_C CComponentTester* NewComponentTestLC_STUB( sl@0: CDataLogger& aDataLogger, sl@0: MComponentTestObserver& aComponentTestObserver); sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerNewLTransition,"CTestController_NewL_Transition"); sl@0: sl@0: inline CTestController_NewL_Transition::CTestController_NewL_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KTestControllerNewLTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestController_NewL_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestControllerNewLTransitMethod, "CTestController::NewL transition"); sl@0: Context().DataLogger().LogInformation(KTestControllerNewLTransitMethod); sl@0: Context().iTestController = CTestController::NewL(Context().iScheduler, NewComponentTestLC_STUB, NULL, Context().iLogInfo); sl@0: } sl@0: sl@0: inline CTestController_UnitTestContext& CTestController_NewL_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerDtorTransition,"CTestController_Dtor_Transition"); sl@0: sl@0: inline CTestController_Dtor_Transition::CTestController_Dtor_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransition(KTestControllerDtorTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestController_Dtor_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestControllerDtorTransitMethod, "CTestController::Dtor transition"); sl@0: Context().DataLogger().LogInformation(KTestControllerDtorTransitMethod); sl@0: delete Context().iTestController; sl@0: Context().iTestController = NULL; sl@0: } sl@0: sl@0: inline CTestController_UnitTestContext& CTestController_Dtor_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerFindComponentsTransition,"CTestController_FindComponents_Transition"); sl@0: sl@0: inline CTestController_FindComponents_Transition::CTestController_FindComponents_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransition(KTestControllerFindComponentsTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: // This is the name of the test that we wish to find sl@0: _LIT(KComponentInfoCreateAndDestroyUnitTest,"CTestController_CreateAndDestroy_UnitTest_STUB"); sl@0: sl@0: inline void CTestController_FindComponents_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestControllerFindComponentsTransitMethod, "CTestController::FindComponents transition"); sl@0: Context().DataLogger().LogInformation(KTestControllerFindComponentsTransitMethod); sl@0: sl@0: Context().iTests.ResetAndDestroy(); sl@0: // Find the available components and place them in an array sl@0: const RPointerArray& components = Context().iTestController->FindComponents(); sl@0: const TInt ccount = components.Count(); sl@0: TBool found = EFalse; sl@0: for(TInt i = 0; i < ccount && !found; ++i) sl@0: { sl@0: // Find the unit tests available for each the previously found components sl@0: const RPointerArray& unitTests = components[i]->UnitTestsInfo(); sl@0: const TInt ucount = unitTests.Count(); sl@0: for(TInt j = 0; j < ucount && !found; ++j) sl@0: { sl@0: // Look for the unit test that matches the one that we wish to find sl@0: found = unitTests[j]->UnitTestId() == KComponentInfoCreateAndDestroyUnitTest; sl@0: if(found) sl@0: { sl@0: TTestInfo* testInfo = new(ELeave) TTestInfo; sl@0: testInfo->iComponentId = i; sl@0: testInfo->iUnitTestId = j; sl@0: testInfo->iRunTime = 0; // Run immediately sl@0: testInfo->iParameters = NULL; sl@0: User::LeaveIfError(Context().iTests.Append(testInfo)); sl@0: } sl@0: } sl@0: } sl@0: if(!found) sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: inline CTestController_UnitTestContext& CTestController_FindComponents_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestControllerStartTransition,"CTestController_Start_Transition"); sl@0: sl@0: inline CTestController_Start_Transition::CTestController_Start_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransition(KTestControllerStartTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestController_Start_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestControllerStartTransitMethod, "CTestController::Start transition"); sl@0: Context().DataLogger().LogInformation(KTestControllerStartTransitMethod); sl@0: Context().iTestController->Start(&Context().iTests); sl@0: } sl@0: sl@0: inline CTestController_UnitTestContext& CTestController_Start_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: sl@0: // Add additional Transition class Implementations here... sl@0: