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