lowlevellibsandfws/pluginfw/Test_Bed/TestManagerTest/TestManagerUnitTest.cpp
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 unit test class implementations for the CTestManager class.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "TestManagerUnitTest.h"
       
    19 #include "TestController.h"
       
    20 
       
    21 extern CComponentTester* NewComponentTestLC_STUB(
       
    22 	CDataLogger& aDataLogger,
       
    23 	MComponentTestObserver&	aComponentTestObserver);
       
    24 
       
    25 // ______________________________________________________________________________
       
    26 //
       
    27 _LIT(KTestManagerCreateAndDestroyUnitTest,"CTestManager_CreateAndDestroy_UnitTest");
       
    28 
       
    29 CTestManager_CreateAndDestroy_UnitTest* CTestManager_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
       
    30 											MUnitTestObserver& aObserver)
       
    31 	{
       
    32 	CTestManager_CreateAndDestroy_UnitTest* self = 
       
    33 					new(ELeave) CTestManager_CreateAndDestroy_UnitTest(aDataLogger,
       
    34 																aObserver);
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	CleanupStack::Pop();
       
    38 	return self; 
       
    39 	}
       
    40 
       
    41 inline TInt CTestManager_CreateAndDestroy_UnitTest::RunError(TInt aError)
       
    42 	{
       
    43 	// The RunL left so chain to the base first and then cleanup
       
    44 	TInt error = CUnitTest::RunError(aError);	// Chain to base
       
    45 	delete iUTContext;
       
    46 	iUTContext = NULL;
       
    47 	delete iStateAccessor;
       
    48 	iStateAccessor = NULL;
       
    49 	/* delete any validators used */
       
    50 	delete iCtorValidator;
       
    51 	iCtorValidator = NULL;
       
    52 	delete iDtorValidator;
       
    53 	iDtorValidator = NULL;
       
    54 
       
    55 	return error;
       
    56 	}
       
    57 
       
    58 inline CTestManager_CreateAndDestroy_UnitTest::~CTestManager_CreateAndDestroy_UnitTest()
       
    59 	{
       
    60 	// Simply delete our test class instance
       
    61 	delete iUTContext;
       
    62 	delete iStateAccessor;
       
    63 	/* delete any validators used */
       
    64 	delete iCtorValidator;
       
    65 	delete iDtorValidator;
       
    66 	}
       
    67 
       
    68 inline CTestManager_CreateAndDestroy_UnitTest::CTestManager_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
       
    69 																	MUnitTestObserver& aObserver)
       
    70 : CUnitTest(KTestManagerCreateAndDestroyUnitTest, aDataLogger, aObserver)
       
    71 	{
       
    72 	//Do nothing
       
    73 	}
       
    74 
       
    75 // Now the Individual transitions need to be added.
       
    76 inline void CTestManager_CreateAndDestroy_UnitTest::ConstructL()
       
    77 	{
       
    78 	// Perform the base class initialization
       
    79 	UnitTestConstructL();
       
    80 
       
    81 	// Create the Unit test state accessor
       
    82 	iStateAccessor = new(ELeave) TTestManager_StateAccessor;
       
    83 	// Construct the Unit test context.
       
    84 	iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
       
    85 	iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
       
    86 	// Construct, and store the observer stub
       
    87 	iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
       
    88 
       
    89 	// Add the Transitions in the order they are to run
       
    90 	// C'tor first, D'tor last...
       
    91 	iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
       
    92 	iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
       
    93 
       
    94 	AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
       
    95 	AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
       
    96 	}
       
    97 
       
    98 // ______________________________________________________________________________
       
    99 //
       
   100 _LIT(KTestManagerManageTestsUnitTest,"CTestManager_ManageTests_UnitTest");
       
   101 
       
   102 CTestManager_ManageTests_UnitTest* CTestManager_ManageTests_UnitTest::NewL(CDataLogger& aDataLogger,
       
   103 											MUnitTestObserver& aObserver)
       
   104 	{
       
   105 	CTestManager_ManageTests_UnitTest* self = 
       
   106 					new(ELeave) CTestManager_ManageTests_UnitTest(aDataLogger,
       
   107 																aObserver);
       
   108 	CleanupStack::PushL(self);
       
   109 	self->ConstructL();
       
   110 	CleanupStack::Pop();
       
   111 	return self; 
       
   112 	}
       
   113 
       
   114 inline TInt CTestManager_ManageTests_UnitTest::RunError(TInt aError)
       
   115 	{
       
   116 	// The RunL left so chain to the base first and then cleanup
       
   117 	TInt error = CUnitTest::RunError(aError);	// Chain to base
       
   118 	delete iUTContext;
       
   119 	iUTContext = NULL;
       
   120 	delete iStateAccessor;
       
   121 	iStateAccessor = NULL;
       
   122 	/* delete any validators used */
       
   123 	delete iCtorValidator;
       
   124 	iCtorValidator = NULL;
       
   125 	delete iRunTestsValidator;
       
   126 	iRunTestsValidator = NULL;
       
   127 	delete iTestComponentValidator;
       
   128 	iTestComponentValidator =NULL;
       
   129 	delete iDtorValidator;
       
   130 	iDtorValidator = NULL;
       
   131 
       
   132 	return error;
       
   133 	}
       
   134 
       
   135 inline CTestManager_ManageTests_UnitTest::~CTestManager_ManageTests_UnitTest()
       
   136 	{
       
   137 	// Simply delete our test class instance
       
   138 	delete iUTContext;
       
   139 	delete iStateAccessor;
       
   140 	/* delete any validators used */
       
   141 	delete iCtorValidator;
       
   142 	delete iRunTestsValidator;
       
   143 	delete iTestComponentValidator;
       
   144 	delete iDtorValidator;
       
   145 	}
       
   146 
       
   147 inline CTestManager_ManageTests_UnitTest::CTestManager_ManageTests_UnitTest(CDataLogger& aDataLogger,
       
   148 																	MUnitTestObserver& aObserver)
       
   149 : CUnitTest(KTestManagerManageTestsUnitTest, aDataLogger, aObserver)
       
   150 	{
       
   151 	//Do nothing
       
   152 	}
       
   153 
       
   154 // Now the Individual transitions need to be added.
       
   155 inline void CTestManager_ManageTests_UnitTest::ConstructL()
       
   156 	{
       
   157 	// Perform the base class initialization
       
   158 	UnitTestConstructL();
       
   159 
       
   160 	// Create the Unit test state accessor
       
   161 	iStateAccessor = new(ELeave) TTestManager_StateAccessor;
       
   162 	// Construct the Unit test context.
       
   163 	iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
       
   164 	iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
       
   165 	// Construct, and store the observer stub
       
   166 	iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
       
   167 
       
   168 	CComponentInfo* compInfo = CComponentInfo::NewL(NewComponentTestLC_STUB, NULL);
       
   169 	CleanupStack::PushL(compInfo);
       
   170 	
       
   171 	User::LeaveIfError(iUTContext->iTestListArray->Append(compInfo));
       
   172 	CleanupStack::Pop(compInfo);
       
   173 
       
   174 
       
   175 	// Add the Transitions in the order they are to run
       
   176 	// C'tor first, D'tor last...
       
   177 	iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
       
   178 	iRunTestsValidator = new(ELeave) TTestManager_RunTests_TransitionValidator(*iUTContext);
       
   179 	iTestComponentValidator = new(ELeave) TTestManager_TestComponent_TransitionValidator(*iUTContext);
       
   180 	iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
       
   181 
       
   182 	AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
       
   183 //	AddTransitionL(new(ELeave)CTestManager_RunTests_Transition(*iUTContext,*iRunTestsValidator));
       
   184 	AddTransitionL(new(ELeave)CTestManager_TestComponentL_Transition(*iUTContext,*iTestComponentValidator));
       
   185 	AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
       
   186 
       
   187 	}
       
   188 
       
   189 // ______________________________________________________________________________
       
   190 //
       
   191 _LIT(KTestManagerCreateAndDestroyUnitTest_STUB,"CTestManager_CreateAndDestroy_UnitTest_STUB");
       
   192 
       
   193 CTestManager_CreateAndDestroy_UnitTest_STUB* CTestManager_CreateAndDestroy_UnitTest_STUB::NewL(CDataLogger& aDataLogger,
       
   194 											MUnitTestObserver& aObserver)
       
   195 	{
       
   196 	CTestManager_CreateAndDestroy_UnitTest_STUB* self = 
       
   197 					new(ELeave) CTestManager_CreateAndDestroy_UnitTest_STUB(aDataLogger,
       
   198 																aObserver);
       
   199 	CleanupStack::PushL(self);
       
   200 	self->ConstructL();
       
   201 	CleanupStack::Pop();
       
   202 	return self; 
       
   203 	}
       
   204 
       
   205 inline TInt CTestManager_CreateAndDestroy_UnitTest_STUB::RunError(TInt aError)
       
   206 	{
       
   207 	// The RunL left so chain to the base first and then cleanup
       
   208 	TInt error = CUnitTest::RunError(aError);	// Chain to base
       
   209 
       
   210 	//Do nothing else since stub
       
   211 
       
   212 	return error;
       
   213 	}
       
   214 
       
   215 inline CTestManager_CreateAndDestroy_UnitTest_STUB::~CTestManager_CreateAndDestroy_UnitTest_STUB()
       
   216 	{
       
   217 	//Do nothing
       
   218 	}
       
   219 
       
   220 inline CTestManager_CreateAndDestroy_UnitTest_STUB::CTestManager_CreateAndDestroy_UnitTest_STUB(CDataLogger& aDataLogger,
       
   221 																	MUnitTestObserver& aObserver)
       
   222 : CUnitTest(KTestManagerCreateAndDestroyUnitTest_STUB, aDataLogger, aObserver)
       
   223 	{
       
   224 	//Do nothing
       
   225 	}
       
   226 
       
   227 // Now the Individual transitions need to be added.
       
   228 inline void CTestManager_CreateAndDestroy_UnitTest_STUB::ConstructL()
       
   229 	{
       
   230 	// Perform the base class initialization
       
   231 	UnitTestConstructL();
       
   232 
       
   233 	//Do nothing else since stub
       
   234 	}
       
   235 
       
   236 
       
   237