os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/UnitTestTest/UnitTestUnitTest.cpp
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 unit test class implementations for the CUnitTest class.
    15 // 
    16 //
    17 
    18 #include "UnitTestUnitTest.h"
    19 
    20 // ______________________________________________________________________________
    21 //
    22 _LIT(KUnitTestCreateAndDestroyUnitTest,"CUnitTest_CreateAndDestroy_UnitTest");
    23 
    24 CUnitTest_CreateAndDestroy_UnitTest* CUnitTest_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
    25 											MUnitTestObserver& aObserver)
    26 	{
    27 	CUnitTest_CreateAndDestroy_UnitTest* self = 
    28 					new(ELeave) CUnitTest_CreateAndDestroy_UnitTest(aDataLogger,
    29 																aObserver);
    30 	CleanupStack::PushL(self);
    31 	self->ConstructL();
    32 	CleanupStack::Pop();
    33 	return self; 
    34 	}
    35 
    36 inline TInt CUnitTest_CreateAndDestroy_UnitTest::RunError(TInt aError)
    37 	{
    38 	// The RunL left so chain to the base first and then cleanup
    39 	TInt error = CUnitTest::RunError(aError);	// Chain to base
    40 	delete iUTContext;
    41 	delete iStateAccessor;
    42 	/* delete any validators used */
    43 	delete iCtorValidator;
    44 	iCtorValidator = NULL;
    45 	delete iDtorValidator;
    46 	iDtorValidator = NULL;
    47 	return error;
    48 	}
    49 
    50 inline CUnitTest_CreateAndDestroy_UnitTest::~CUnitTest_CreateAndDestroy_UnitTest()
    51 	{
    52 	// Simply delete our test class instance
    53 	delete iUTContext;
    54 	delete iStateAccessor;
    55 	/* delete any validators used */
    56 	delete iCtorValidator;
    57 	delete iDtorValidator;
    58 	}
    59 
    60 inline CUnitTest_CreateAndDestroy_UnitTest::CUnitTest_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
    61 																	MUnitTestObserver& aObserver)
    62 : CUnitTest(KUnitTestCreateAndDestroyUnitTest, aDataLogger, aObserver)
    63 	{
    64 	//Do nothing
    65 	}
    66 
    67 // Now the Individual transitions need to be added.
    68 inline void CUnitTest_CreateAndDestroy_UnitTest::ConstructL()
    69 	{
    70 	// Perform the base class initialization
    71 	UnitTestConstructL();
    72 
    73 	// Create the Unit test state accessor
    74 	iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
    75 	// Construct the Unit test context.
    76 	iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
    77 
    78 	// Add the Transitions in the order they are to run
    79 	// C'tor first, D'tor last...
    80 	iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
    81 	iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
    82 
    83 	AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
    84 	AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
    85 	}
    86 
    87 // ______________________________________________________________________________
    88 //
    89 _LIT(KUnitTestManageTransitionsUnitTest,"CUnitTest_ManageTransitions_UnitTest");
    90 
    91 CUnitTest_ManageTransitions_UnitTest* CUnitTest_ManageTransitions_UnitTest::NewL(CDataLogger& aDataLogger,
    92 											MUnitTestObserver& aObserver)
    93 	{
    94 	CUnitTest_ManageTransitions_UnitTest* self = 
    95 					new(ELeave) CUnitTest_ManageTransitions_UnitTest(aDataLogger,
    96 																aObserver);
    97 	CleanupStack::PushL(self);
    98 	self->ConstructL();
    99 	CleanupStack::Pop();
   100 	return self; 
   101 	}
   102 
   103 inline TInt CUnitTest_ManageTransitions_UnitTest::RunError(TInt aError)
   104 	{
   105 	// The RunL left so chain to the base first and then cleanup
   106 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   107 	delete iUTContext;
   108 	delete iStateAccessor;
   109 	/* delete any validators used */
   110 	delete iCtorValidator;
   111 	iCtorValidator = NULL;
   112 	delete iTransitionSetValidator;
   113 	iTransitionSetValidator = NULL;
   114 	delete iGetCurrentTransitionValidator;
   115 	iGetCurrentTransitionValidator = NULL;
   116 	delete iSetCurrentTransitionValidator;
   117 	iSetCurrentTransitionValidator = NULL;
   118 	delete iDtorValidator;
   119 	iDtorValidator = NULL;
   120 	return error;
   121 	}
   122 
   123 inline CUnitTest_ManageTransitions_UnitTest::~CUnitTest_ManageTransitions_UnitTest()
   124 	{
   125 	// Simply delete our test class instance
   126 	delete iUTContext;
   127 	delete iStateAccessor;
   128 	/* delete any validators used */
   129 	delete iCtorValidator;
   130 	delete iTransitionSetValidator;
   131 	delete iGetCurrentTransitionValidator;
   132 	delete iSetCurrentTransitionValidator;
   133 	delete iDtorValidator;
   134 	}
   135 
   136 inline CUnitTest_ManageTransitions_UnitTest::CUnitTest_ManageTransitions_UnitTest(CDataLogger& aDataLogger,
   137 																	MUnitTestObserver& aObserver)
   138 : CUnitTest(KUnitTestManageTransitionsUnitTest, aDataLogger, aObserver)
   139 	{
   140 	//Do nothing
   141 	}
   142 
   143 // Now the Individual transitions need to be added.
   144 inline void CUnitTest_ManageTransitions_UnitTest::ConstructL()
   145 	{
   146 	// Perform the base class initialization
   147 	UnitTestConstructL();
   148 
   149 	// Create the Unit test state accessor
   150 	iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
   151 	// Construct the Unit test context.
   152 	iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   153 
   154 	// Add the Transitions in the order they are to run
   155 	// C'tor first, D'tor last...
   156 	iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
   157 	iTransitionSetValidator = new(ELeave) TUnitTest_TransitionSet_TransitionValidator(*iUTContext);
   158 	iGetCurrentTransitionValidator = new(ELeave) TUnitTest_GetCurrentTransition_TransitionValidator(*iUTContext);
   159 	iSetCurrentTransitionValidator = new(ELeave) TUnitTest_SetCurrentTransition_TransitionValidator(*iUTContext);
   160 	iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
   161 
   162 	AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
   163 	AddTransitionL(new(ELeave)CUnitTest_TransitionSetL_Transition(*iUTContext,*iTransitionSetValidator));
   164 	AddTransitionL(new(ELeave)CUnitTest_GetCurrentTransition_Transition(*iUTContext,*iGetCurrentTransitionValidator));
   165 	AddTransitionL(new(ELeave)CUnitTest_SetCurrentTransition_Transition(*iUTContext,*iSetCurrentTransitionValidator));
   166 	AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
   167 	}
   168 
   169 // ______________________________________________________________________________
   170 //
   171 _LIT(KUnitTestRunTestsUnitTest,"CUnitTest_RunTests_UnitTest");
   172 
   173 CUnitTest_RunTests_UnitTest* CUnitTest_RunTests_UnitTest::NewL(CDataLogger& aDataLogger,
   174 											MUnitTestObserver& aObserver)
   175 	{
   176 	CUnitTest_RunTests_UnitTest* self = 
   177 					new(ELeave) CUnitTest_RunTests_UnitTest(aDataLogger,
   178 																aObserver);
   179 	CleanupStack::PushL(self);
   180 	self->ConstructL();
   181 	CleanupStack::Pop(self);
   182 	return self; 
   183 	}
   184 
   185 inline TInt CUnitTest_RunTests_UnitTest::RunError(TInt aError)
   186 	{
   187 	// The RunL left so chain to the base first and then cleanup
   188 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   189 	delete iUTContext;
   190 	iUTContext = NULL;
   191 	delete iStateAccessor;
   192 	iStateAccessor = NULL;
   193 	/* delete any validators used */
   194 	delete iCtorValidator;
   195 	iCtorValidator = NULL;
   196 	delete iSetParametersValidator;
   197 	iSetParametersValidator = NULL;
   198 	delete iPrepareUnitTestValidator;
   199 	iPrepareUnitTestValidator = NULL;
   200 	delete iRunTestValidator;
   201 	iRunTestValidator = NULL;
   202 	delete iDtorValidator;
   203 	iDtorValidator = NULL;
   204 	return error;
   205 	}
   206 
   207 inline CUnitTest_RunTests_UnitTest::~CUnitTest_RunTests_UnitTest()
   208 	{
   209 	// Simply delete our test class instance
   210 	delete iUTContext;
   211 	delete iStateAccessor;
   212 	/* delete any validators used */
   213 	delete iCtorValidator;
   214 	delete iSetParametersValidator;
   215 	delete iPrepareUnitTestValidator;
   216 	delete iRunTestValidator;
   217 	delete iDtorValidator;
   218 	}
   219 
   220 inline CUnitTest_RunTests_UnitTest::CUnitTest_RunTests_UnitTest(CDataLogger& aDataLogger,
   221 																	MUnitTestObserver& aObserver)
   222 : CUnitTest(KUnitTestRunTestsUnitTest, aDataLogger, aObserver)
   223 	{
   224 	//Do nothing
   225 	}
   226 
   227 // Now the Individual transitions need to be added.
   228 inline void CUnitTest_RunTests_UnitTest::ConstructL()
   229 	{
   230 	// Perform the base class initialization
   231 	UnitTestConstructL();
   232 
   233 	// Create the Unit test state accessor
   234 	iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
   235 	// Construct the Unit test context.
   236 	iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   237 
   238 	// Add the Transitions in the order they are to run
   239 	// C'tor first, D'tor last...
   240 	iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
   241 	iSetParametersValidator = new(ELeave) TUnitTest_SetParameters_TransitionValidator(*iUTContext);
   242 	iPrepareUnitTestValidator = new(ELeave) TUnitTest_PrepareUnitTest_TransitionValidator(*iUTContext);
   243 	iRunTestValidator = new(ELeave) TUnitTest_RunTest_TransitionValidator(*iUTContext);
   244 	iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
   245 
   246 	AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
   247 	AddTransitionL(new(ELeave)CUnitTest_SetParametersL_Transition(*iUTContext,*iSetParametersValidator));
   248 	AddTransitionL(new(ELeave)CUnitTest_PrepareUnitTestL_Transition(*iUTContext,*iPrepareUnitTestValidator));
   249 	AddTransitionL(new(ELeave)CUnitTest_RunTest_Transition(*iUTContext,*iRunTestValidator));
   250 	AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
   251 	}
   252 
   253 
   254 // ______________________________________________________________________________
   255 //
   256 _LIT(KUnitTestAllOtherUnitTest,"CUnitTest_AllOther_UnitTest");
   257 
   258 CUnitTest_AllOther_UnitTest* CUnitTest_AllOther_UnitTest::NewL(CDataLogger& aDataLogger,
   259 											MUnitTestObserver& aObserver)
   260 	{
   261 	CUnitTest_AllOther_UnitTest* self = 
   262 					new(ELeave) CUnitTest_AllOther_UnitTest(aDataLogger,
   263 																aObserver);
   264 	CleanupStack::PushL(self);
   265 	self->ConstructL();
   266 	CleanupStack::Pop();
   267 	return self; 
   268 	}
   269 
   270 inline TInt CUnitTest_AllOther_UnitTest::RunError(TInt aError)
   271 	{
   272 	// The RunL left so chain to the base first and then cleanup
   273 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   274 	delete iUTContext;
   275 	delete iStateAccessor;
   276 	/* delete any validators used */
   277 	delete iCtorValidator;
   278 	iCtorValidator = NULL;
   279 	delete iAddTransitionValidator;
   280 	iAddTransitionValidator = NULL;
   281 	delete iAddBlockingTransitionValidator;
   282 	iAddBlockingTransitionValidator = NULL;
   283 	delete iAddLeaveErrorCodeValidator;
   284 	iAddLeaveErrorCodeValidator = NULL;
   285 	delete iUnitTestNameValidator;
   286 	iUnitTestNameValidator = NULL;
   287 	delete iDtorValidator;
   288 	iDtorValidator = NULL;
   289 
   290 	return error;
   291 	}
   292 
   293 inline CUnitTest_AllOther_UnitTest::~CUnitTest_AllOther_UnitTest()
   294 	{
   295 	// Simply delete our test class instance
   296 	delete iUTContext;
   297 	delete iStateAccessor;
   298 	/* delete any validators used */
   299 	delete iCtorValidator;
   300 	delete iAddTransitionValidator;
   301 	delete iAddBlockingTransitionValidator;
   302 	delete iAddLeaveErrorCodeValidator;
   303 	delete iUnitTestNameValidator;
   304 	delete iDtorValidator;
   305 	}
   306 
   307 inline CUnitTest_AllOther_UnitTest::CUnitTest_AllOther_UnitTest(CDataLogger& aDataLogger,
   308 																	MUnitTestObserver& aObserver)
   309 : CUnitTest(KUnitTestAllOtherUnitTest, aDataLogger, aObserver)
   310 	{
   311 	//Do nothing
   312 	}
   313 
   314 // Now the Individual transitions need to be added.
   315 inline void CUnitTest_AllOther_UnitTest::ConstructL()
   316 	{
   317 	// Perform the base class initialization
   318 	UnitTestConstructL();
   319 
   320 	// Create the Unit test state accessor
   321 	iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
   322 	// Construct the Unit test context.
   323 	iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   324 
   325 	// Add the Transitions in the order they are to run
   326 	// C'tor first, D'tor last...
   327 	iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
   328 	iAddTransitionValidator = new(ELeave) TUnitTest_AddTransition_TransitionValidator(*iUTContext);
   329 	iAddBlockingTransitionValidator = new(ELeave) TUnitTest_AddBlockingTransition_TransitionValidator(*iUTContext);
   330 	iAddLeaveErrorCodeValidator = new(ELeave) TUnitTest_AddLeaveErrorCode_TransitionValidator(*iUTContext);
   331 	iUnitTestNameValidator = new(ELeave) TUnitTest_UnitTestName_TransitionValidator(*iUTContext);
   332 	iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
   333 
   334 	AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
   335 	AddTransitionL(new(ELeave)CUnitTest_AddTransitionL_Transition(*iUTContext,*iAddTransitionValidator));
   336 	AddTransitionL(new(ELeave)CUnitTest_AddBlockingTransitionL_Transition(*iUTContext,*iAddBlockingTransitionValidator));
   337 	AddTransitionL(new(ELeave)CUnitTest_AddLeaveErrorCodeL_Transition(*iUTContext,*iAddLeaveErrorCodeValidator));
   338 	AddTransitionL(new(ELeave)CUnitTest_UnitTestName_Transition(*iUTContext,*iUnitTestNameValidator));
   339 	AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
   340 	}
   341