os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TestControllerTest/TestControllerTransitions.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 CTestController class methods.
    15 // 
    16 //
    17 
    18 IMPORT_C CComponentTester* NewComponentTestLC_STUB(
    19 	CDataLogger& aDataLogger,
    20 	MComponentTestObserver&	aComponentTestObserver);
    21 
    22 // ______________________________________________________________________________
    23 //
    24 _LIT(KTestControllerNewLTransition,"CTestController_NewL_Transition");
    25 
    26 inline CTestController_NewL_Transition::CTestController_NewL_Transition(CUnitTestContext& aUTContext,
    27 													TTransitionValidator& aValidator)
    28 : CTransitionType(KTestControllerNewLTransition, aUTContext, aValidator)
    29 	{
    30 	// Do nothing here.
    31 	}
    32 
    33 inline void CTestController_NewL_Transition::TransitMethodL()
    34 	{
    35 	_LIT(KTestControllerNewLTransitMethod, "CTestController::NewL transition");
    36 	Context().DataLogger().LogInformation(KTestControllerNewLTransitMethod);
    37 	Context().iTestController = CTestController::NewL(Context().iScheduler, NewComponentTestLC_STUB, NULL, Context().iLogInfo);
    38 	}
    39 
    40 inline CTestController_UnitTestContext& CTestController_NewL_Transition::Context() const
    41 	{
    42 	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
    43 	}
    44 
    45 // ______________________________________________________________________________
    46 //
    47 _LIT(KTestControllerDtorTransition,"CTestController_Dtor_Transition");
    48 
    49 inline CTestController_Dtor_Transition::CTestController_Dtor_Transition(CUnitTestContext& aUTContext,
    50 													TTransitionValidator& aValidator)
    51 : CTransition(KTestControllerDtorTransition, aUTContext, aValidator)
    52 	{
    53 	// Do nothing here.
    54 	}
    55 
    56 inline void CTestController_Dtor_Transition::TransitMethodL()
    57 	{
    58 	_LIT(KTestControllerDtorTransitMethod, "CTestController::Dtor transition");
    59 	Context().DataLogger().LogInformation(KTestControllerDtorTransitMethod);
    60 	delete Context().iTestController;
    61 	Context().iTestController = NULL;
    62 	}
    63 
    64 inline CTestController_UnitTestContext& CTestController_Dtor_Transition::Context() const
    65 	{
    66 	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
    67 	}
    68 
    69 // ______________________________________________________________________________
    70 //
    71 _LIT(KTestControllerFindComponentsTransition,"CTestController_FindComponents_Transition");
    72 
    73 inline CTestController_FindComponents_Transition::CTestController_FindComponents_Transition(CUnitTestContext& aUTContext,
    74 													TTransitionValidator& aValidator)
    75 : CTransition(KTestControllerFindComponentsTransition, aUTContext, aValidator)
    76 	{
    77 	// Do nothing here.
    78 	}
    79 
    80 // This is the name of the test that we wish to find
    81 _LIT(KComponentInfoCreateAndDestroyUnitTest,"CTestController_CreateAndDestroy_UnitTest_STUB");
    82 
    83 inline void CTestController_FindComponents_Transition::TransitMethodL()
    84 	{
    85 	_LIT(KTestControllerFindComponentsTransitMethod, "CTestController::FindComponents transition");
    86 	Context().DataLogger().LogInformation(KTestControllerFindComponentsTransitMethod);
    87 	
    88 	Context().iTests.ResetAndDestroy();
    89 	// Find the available components and place them in an array
    90 	const RPointerArray<CComponentInfo>& components = Context().iTestController->FindComponents();
    91 	const TInt ccount = components.Count();
    92 	TBool found = EFalse;
    93 	for(TInt i = 0; i < ccount && !found; ++i)
    94 		{
    95 		// Find the unit tests available for each the previously found components
    96 		const RPointerArray<CUnitTestInfo>& unitTests = components[i]->UnitTestsInfo();
    97 		const TInt ucount = unitTests.Count();
    98 		for(TInt j = 0; j < ucount && !found; ++j)
    99 			{
   100 			// Look for the unit test that matches the one that we wish to find
   101 			found = unitTests[j]->UnitTestId() == KComponentInfoCreateAndDestroyUnitTest;
   102 			if(found)
   103 				{
   104 				TTestInfo* testInfo = new(ELeave) TTestInfo;
   105 				testInfo->iComponentId = i;
   106 				testInfo->iUnitTestId = j;
   107 				testInfo->iRunTime = 0;		// Run immediately
   108 				testInfo->iParameters = NULL;
   109 				User::LeaveIfError(Context().iTests.Append(testInfo));
   110 				}
   111 			}
   112 		}
   113 	if(!found)
   114 		User::Leave(KErrNotFound);
   115 	}
   116 
   117 inline CTestController_UnitTestContext& CTestController_FindComponents_Transition::Context() const
   118 	{
   119 	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
   120 	}
   121 
   122 // ______________________________________________________________________________
   123 //
   124 _LIT(KTestControllerStartTransition,"CTestController_Start_Transition");
   125 
   126 inline CTestController_Start_Transition::CTestController_Start_Transition(CUnitTestContext& aUTContext,
   127 													TTransitionValidator& aValidator)
   128 : CTransition(KTestControllerStartTransition, aUTContext, aValidator)
   129 	{
   130 	// Do nothing here.
   131 	}
   132 
   133 inline void CTestController_Start_Transition::TransitMethodL()
   134 	{
   135 	_LIT(KTestControllerStartTransitMethod, "CTestController::Start transition");
   136 	Context().DataLogger().LogInformation(KTestControllerStartTransitMethod);
   137 	Context().iTestController->Start(&Context().iTests);
   138 	}
   139 
   140 inline CTestController_UnitTestContext& CTestController_Start_Transition::Context() const
   141 	{
   142 	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
   143 	}
   144 
   145 
   146 // Add additional Transition class Implementations here...
   147