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 CTestManager class methods. sl@0: // sl@0: // sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestManagerNewLTransition,"CTestManager_NewL_Transition"); sl@0: sl@0: inline CTestManager_NewL_Transition::CTestManager_NewL_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KTestManagerNewLTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestManager_NewL_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestManagerNewLTransitMethod, "CTestManager::NewL transition"); sl@0: Context().DataLogger().LogInformation(KTestManagerNewLTransitMethod); sl@0: Context().iTestManager = CTestManager::NewL(Context().iTestListArray, Context().DataLogger(), Context().ManagerObserver()); sl@0: } sl@0: sl@0: inline CTestManager_UnitTestContext& CTestManager_NewL_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestManagerDtorTransition,"CTestManager_Dtor_Transition"); sl@0: sl@0: inline CTestManager_Dtor_Transition::CTestManager_Dtor_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransition(KTestManagerDtorTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestManager_Dtor_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestManagerDtorTransitMethod, "CTestManager::Dtor transition"); sl@0: Context().DataLogger().LogInformation(KTestManagerDtorTransitMethod); sl@0: delete Context().iTestManager; sl@0: Context().iTestManager = NULL; sl@0: } sl@0: sl@0: inline CTestManager_UnitTestContext& CTestManager_Dtor_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestManagerRunTestsTransition,"CTestManager_RunTests_Transition"); sl@0: sl@0: inline CTestManager_RunTests_Transition::CTestManager_RunTests_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransition(KTestManagerRunTestsTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestManager_RunTests_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestManagerRunTestsTransitMethod, "CTestManager::RunTests transition"); sl@0: Context().DataLogger().LogInformation(KTestManagerRunTestsTransitMethod); sl@0: sl@0: _LIT(KComponentInfoCreateAndDestroyUnitTest,"CComponentInfo_CreateAndDestroy_UnitTest_STUB"); sl@0: Context().iTests.ResetAndDestroy(); sl@0: Context().iTestController = CTestController::NewLC(CActiveScheduler::Current(),NULL); sl@0: // Find the available components and place them in an array sl@0: Context().iComponents = &(Context().iTestController->FindComponents()); sl@0: const RPointerArray& components = *(Context().iComponents); sl@0: const TInt ccount = Context().iComponents->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: CleanupStack::PopAndDestroy(Context().iTestController); sl@0: Context().iTestController = NULL; sl@0: Context().iTestManager->RunTests(&Context().iTests); sl@0: } sl@0: sl@0: inline CTestManager_UnitTestContext& CTestManager_RunTests_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTestManagerTestComponentLTransition,"CTestManager_TestComponentL_Transition"); sl@0: sl@0: inline CTestManager_TestComponentL_Transition::CTestManager_TestComponentL_Transition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KTestManagerTestComponentLTransition, aUTContext, aValidator) sl@0: { sl@0: // Do nothing here. sl@0: } sl@0: sl@0: inline void CTestManager_TestComponentL_Transition::TransitMethodL() sl@0: { sl@0: _LIT(KTestManagerTestComponentLTransitMethod, "CTestManager::TestComponentL transition"); sl@0: Context().DataLogger().LogInformation(KTestManagerTestComponentLTransitMethod); sl@0: TTestManager_StateAccessor& accessor = REINTERPRET_CAST(TTestManager_StateAccessor&, Context().StateAccessor()); sl@0: accessor.TestComponentL(*(Context().iTestManager), Context().iComponentIndex); sl@0: accessor.ActivateManager(*(Context().iTestManager)); sl@0: Context().iTestManagerObserverStub->SetSchedulerStarted(ETrue); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: inline CTestManager_UnitTestContext& CTestManager_TestComponentL_Transition::Context() const sl@0: { sl@0: return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: sl@0: