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.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// The implementation of the transition classes upon the CTestController class methods.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
IMPORT_C CComponentTester* NewComponentTestLC_STUB(
sl@0
    19
	CDataLogger& aDataLogger,
sl@0
    20
	MComponentTestObserver&	aComponentTestObserver);
sl@0
    21
sl@0
    22
// ______________________________________________________________________________
sl@0
    23
//
sl@0
    24
_LIT(KTestControllerNewLTransition,"CTestController_NewL_Transition");
sl@0
    25
sl@0
    26
inline CTestController_NewL_Transition::CTestController_NewL_Transition(CUnitTestContext& aUTContext,
sl@0
    27
													TTransitionValidator& aValidator)
sl@0
    28
: CTransitionType(KTestControllerNewLTransition, aUTContext, aValidator)
sl@0
    29
	{
sl@0
    30
	// Do nothing here.
sl@0
    31
	}
sl@0
    32
sl@0
    33
inline void CTestController_NewL_Transition::TransitMethodL()
sl@0
    34
	{
sl@0
    35
	_LIT(KTestControllerNewLTransitMethod, "CTestController::NewL transition");
sl@0
    36
	Context().DataLogger().LogInformation(KTestControllerNewLTransitMethod);
sl@0
    37
	Context().iTestController = CTestController::NewL(Context().iScheduler, NewComponentTestLC_STUB, NULL, Context().iLogInfo);
sl@0
    38
	}
sl@0
    39
sl@0
    40
inline CTestController_UnitTestContext& CTestController_NewL_Transition::Context() const
sl@0
    41
	{
sl@0
    42
	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
sl@0
    43
	}
sl@0
    44
sl@0
    45
// ______________________________________________________________________________
sl@0
    46
//
sl@0
    47
_LIT(KTestControllerDtorTransition,"CTestController_Dtor_Transition");
sl@0
    48
sl@0
    49
inline CTestController_Dtor_Transition::CTestController_Dtor_Transition(CUnitTestContext& aUTContext,
sl@0
    50
													TTransitionValidator& aValidator)
sl@0
    51
: CTransition(KTestControllerDtorTransition, aUTContext, aValidator)
sl@0
    52
	{
sl@0
    53
	// Do nothing here.
sl@0
    54
	}
sl@0
    55
sl@0
    56
inline void CTestController_Dtor_Transition::TransitMethodL()
sl@0
    57
	{
sl@0
    58
	_LIT(KTestControllerDtorTransitMethod, "CTestController::Dtor transition");
sl@0
    59
	Context().DataLogger().LogInformation(KTestControllerDtorTransitMethod);
sl@0
    60
	delete Context().iTestController;
sl@0
    61
	Context().iTestController = NULL;
sl@0
    62
	}
sl@0
    63
sl@0
    64
inline CTestController_UnitTestContext& CTestController_Dtor_Transition::Context() const
sl@0
    65
	{
sl@0
    66
	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
sl@0
    67
	}
sl@0
    68
sl@0
    69
// ______________________________________________________________________________
sl@0
    70
//
sl@0
    71
_LIT(KTestControllerFindComponentsTransition,"CTestController_FindComponents_Transition");
sl@0
    72
sl@0
    73
inline CTestController_FindComponents_Transition::CTestController_FindComponents_Transition(CUnitTestContext& aUTContext,
sl@0
    74
													TTransitionValidator& aValidator)
sl@0
    75
: CTransition(KTestControllerFindComponentsTransition, aUTContext, aValidator)
sl@0
    76
	{
sl@0
    77
	// Do nothing here.
sl@0
    78
	}
sl@0
    79
sl@0
    80
// This is the name of the test that we wish to find
sl@0
    81
_LIT(KComponentInfoCreateAndDestroyUnitTest,"CTestController_CreateAndDestroy_UnitTest_STUB");
sl@0
    82
sl@0
    83
inline void CTestController_FindComponents_Transition::TransitMethodL()
sl@0
    84
	{
sl@0
    85
	_LIT(KTestControllerFindComponentsTransitMethod, "CTestController::FindComponents transition");
sl@0
    86
	Context().DataLogger().LogInformation(KTestControllerFindComponentsTransitMethod);
sl@0
    87
	
sl@0
    88
	Context().iTests.ResetAndDestroy();
sl@0
    89
	// Find the available components and place them in an array
sl@0
    90
	const RPointerArray<CComponentInfo>& components = Context().iTestController->FindComponents();
sl@0
    91
	const TInt ccount = components.Count();
sl@0
    92
	TBool found = EFalse;
sl@0
    93
	for(TInt i = 0; i < ccount && !found; ++i)
sl@0
    94
		{
sl@0
    95
		// Find the unit tests available for each the previously found components
sl@0
    96
		const RPointerArray<CUnitTestInfo>& unitTests = components[i]->UnitTestsInfo();
sl@0
    97
		const TInt ucount = unitTests.Count();
sl@0
    98
		for(TInt j = 0; j < ucount && !found; ++j)
sl@0
    99
			{
sl@0
   100
			// Look for the unit test that matches the one that we wish to find
sl@0
   101
			found = unitTests[j]->UnitTestId() == KComponentInfoCreateAndDestroyUnitTest;
sl@0
   102
			if(found)
sl@0
   103
				{
sl@0
   104
				TTestInfo* testInfo = new(ELeave) TTestInfo;
sl@0
   105
				testInfo->iComponentId = i;
sl@0
   106
				testInfo->iUnitTestId = j;
sl@0
   107
				testInfo->iRunTime = 0;		// Run immediately
sl@0
   108
				testInfo->iParameters = NULL;
sl@0
   109
				User::LeaveIfError(Context().iTests.Append(testInfo));
sl@0
   110
				}
sl@0
   111
			}
sl@0
   112
		}
sl@0
   113
	if(!found)
sl@0
   114
		User::Leave(KErrNotFound);
sl@0
   115
	}
sl@0
   116
sl@0
   117
inline CTestController_UnitTestContext& CTestController_FindComponents_Transition::Context() const
sl@0
   118
	{
sl@0
   119
	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
sl@0
   120
	}
sl@0
   121
sl@0
   122
// ______________________________________________________________________________
sl@0
   123
//
sl@0
   124
_LIT(KTestControllerStartTransition,"CTestController_Start_Transition");
sl@0
   125
sl@0
   126
inline CTestController_Start_Transition::CTestController_Start_Transition(CUnitTestContext& aUTContext,
sl@0
   127
													TTransitionValidator& aValidator)
sl@0
   128
: CTransition(KTestControllerStartTransition, aUTContext, aValidator)
sl@0
   129
	{
sl@0
   130
	// Do nothing here.
sl@0
   131
	}
sl@0
   132
sl@0
   133
inline void CTestController_Start_Transition::TransitMethodL()
sl@0
   134
	{
sl@0
   135
	_LIT(KTestControllerStartTransitMethod, "CTestController::Start transition");
sl@0
   136
	Context().DataLogger().LogInformation(KTestControllerStartTransitMethod);
sl@0
   137
	Context().iTestController->Start(&Context().iTests);
sl@0
   138
	}
sl@0
   139
sl@0
   140
inline CTestController_UnitTestContext& CTestController_Start_Transition::Context() const
sl@0
   141
	{
sl@0
   142
	return REINTERPRET_CAST(CTestController_UnitTestContext&,iUTContext);
sl@0
   143
	}
sl@0
   144
sl@0
   145
sl@0
   146
// Add additional Transition class Implementations here...
sl@0
   147