lowlevellibsandfws/pluginfw/Test_Bed/TestManagerTest/TestManagerTransitions.inl
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The implementation of the transition classes upon the CTestManager class methods.
       
    15 // 
       
    16 //
       
    17 
       
    18 // ______________________________________________________________________________
       
    19 //
       
    20 _LIT(KTestManagerNewLTransition,"CTestManager_NewL_Transition");
       
    21 
       
    22 inline CTestManager_NewL_Transition::CTestManager_NewL_Transition(CUnitTestContext& aUTContext,
       
    23 													TTransitionValidator& aValidator)
       
    24 : CTransitionType(KTestManagerNewLTransition, aUTContext, aValidator)
       
    25 	{
       
    26 	// Do nothing here.
       
    27 	}
       
    28 
       
    29 inline void CTestManager_NewL_Transition::TransitMethodL()
       
    30 	{
       
    31 	_LIT(KTestManagerNewLTransitMethod, "CTestManager::NewL transition");
       
    32 	Context().DataLogger().LogInformation(KTestManagerNewLTransitMethod);
       
    33 	Context().iTestManager = CTestManager::NewL(Context().iTestListArray, Context().DataLogger(), Context().ManagerObserver());
       
    34 	}
       
    35 
       
    36 inline CTestManager_UnitTestContext& CTestManager_NewL_Transition::Context() const
       
    37 	{
       
    38 	return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext);
       
    39 	}
       
    40 
       
    41 // ______________________________________________________________________________
       
    42 //
       
    43 _LIT(KTestManagerDtorTransition,"CTestManager_Dtor_Transition");
       
    44 
       
    45 inline CTestManager_Dtor_Transition::CTestManager_Dtor_Transition(CUnitTestContext& aUTContext,
       
    46 													TTransitionValidator& aValidator)
       
    47 : CTransition(KTestManagerDtorTransition, aUTContext, aValidator)
       
    48 	{
       
    49 	// Do nothing here.
       
    50 	}
       
    51 
       
    52 inline void CTestManager_Dtor_Transition::TransitMethodL()
       
    53 	{
       
    54 	_LIT(KTestManagerDtorTransitMethod, "CTestManager::Dtor transition");
       
    55 	Context().DataLogger().LogInformation(KTestManagerDtorTransitMethod);
       
    56 	delete Context().iTestManager;
       
    57 	Context().iTestManager = NULL;
       
    58 	}
       
    59 
       
    60 inline CTestManager_UnitTestContext& CTestManager_Dtor_Transition::Context() const
       
    61 	{
       
    62 	return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext);
       
    63 	}
       
    64 
       
    65 // ______________________________________________________________________________
       
    66 //
       
    67 _LIT(KTestManagerRunTestsTransition,"CTestManager_RunTests_Transition");
       
    68 
       
    69 inline CTestManager_RunTests_Transition::CTestManager_RunTests_Transition(CUnitTestContext& aUTContext,
       
    70 													TTransitionValidator& aValidator)
       
    71 : CTransition(KTestManagerRunTestsTransition, aUTContext, aValidator)
       
    72 	{
       
    73 	// Do nothing here.
       
    74 	}
       
    75 
       
    76 inline void CTestManager_RunTests_Transition::TransitMethodL()
       
    77 	{
       
    78 	_LIT(KTestManagerRunTestsTransitMethod, "CTestManager::RunTests transition");
       
    79 	Context().DataLogger().LogInformation(KTestManagerRunTestsTransitMethod);
       
    80 	
       
    81 	_LIT(KComponentInfoCreateAndDestroyUnitTest,"CComponentInfo_CreateAndDestroy_UnitTest_STUB");
       
    82 	Context().iTests.ResetAndDestroy();
       
    83 	Context().iTestController = CTestController::NewLC(CActiveScheduler::Current(),NULL);
       
    84 	// Find the available components and place them in an array
       
    85 	Context().iComponents = &(Context().iTestController->FindComponents());
       
    86 	const RPointerArray<CComponentInfo>& components = *(Context().iComponents);
       
    87 	const TInt ccount = Context().iComponents->Count();
       
    88 	TBool found = EFalse;
       
    89 	for(TInt i = 0; i < ccount && !found; ++i)
       
    90 		{
       
    91 		// Find the unit tests available for each the previously found components
       
    92 		const RPointerArray<CUnitTestInfo>& unitTests = components[i]->UnitTestsInfo();
       
    93 		const TInt ucount = unitTests.Count();
       
    94 		for(TInt j = 0; j < ucount && !found; ++j)
       
    95 			{
       
    96 			// Look for the unit test that matches the one that we wish to find
       
    97 			found = unitTests[j]->UnitTestId() == KComponentInfoCreateAndDestroyUnitTest;
       
    98 			if(found)
       
    99 				{
       
   100 				TTestInfo* testInfo = new(ELeave) TTestInfo;
       
   101 				testInfo->iComponentId = i;
       
   102 				testInfo->iUnitTestId = j;
       
   103 				testInfo->iRunTime = 0;		// Run immediately
       
   104 				testInfo->iParameters = NULL;
       
   105 				User::LeaveIfError(Context().iTests.Append(testInfo));
       
   106 				}
       
   107 			}
       
   108 		}
       
   109 	if(!found)
       
   110 		User::Leave(KErrNotFound);
       
   111 
       
   112 	CleanupStack::PopAndDestroy(Context().iTestController);
       
   113 	Context().iTestController = NULL;
       
   114 	Context().iTestManager->RunTests(&Context().iTests);
       
   115 	}
       
   116 
       
   117 inline CTestManager_UnitTestContext& CTestManager_RunTests_Transition::Context() const
       
   118 	{
       
   119 	return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext);
       
   120 	}
       
   121 
       
   122 // ______________________________________________________________________________
       
   123 //
       
   124 _LIT(KTestManagerTestComponentLTransition,"CTestManager_TestComponentL_Transition");
       
   125 
       
   126 inline CTestManager_TestComponentL_Transition::CTestManager_TestComponentL_Transition(CUnitTestContext& aUTContext,
       
   127 													TTransitionValidator& aValidator)
       
   128 : CTransitionType(KTestManagerTestComponentLTransition, aUTContext, aValidator)
       
   129 	{
       
   130 	// Do nothing here.
       
   131 	}
       
   132 
       
   133 inline void CTestManager_TestComponentL_Transition::TransitMethodL()
       
   134 	{
       
   135 	_LIT(KTestManagerTestComponentLTransitMethod, "CTestManager::TestComponentL transition");
       
   136 	Context().DataLogger().LogInformation(KTestManagerTestComponentLTransitMethod);
       
   137 	TTestManager_StateAccessor& accessor = REINTERPRET_CAST(TTestManager_StateAccessor&, Context().StateAccessor());
       
   138 	accessor.TestComponentL(*(Context().iTestManager), Context().iComponentIndex);
       
   139 	accessor.ActivateManager(*(Context().iTestManager));
       
   140 	Context().iTestManagerObserverStub->SetSchedulerStarted(ETrue);
       
   141 	CActiveScheduler::Start();
       
   142 	}
       
   143 
       
   144 inline CTestManager_UnitTestContext& CTestManager_TestComponentL_Transition::Context() const
       
   145 	{
       
   146 	return REINTERPRET_CAST(CTestManager_UnitTestContext&,iUTContext);
       
   147 	}
       
   148 
       
   149 
       
   150