1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/UnitTestTest/UnitTestUnitTest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,341 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// The unit test class implementations for the CUnitTest class.
1.18 +//
1.19 +//
1.20 +
1.21 +#include "UnitTestUnitTest.h"
1.22 +
1.23 +// ______________________________________________________________________________
1.24 +//
1.25 +_LIT(KUnitTestCreateAndDestroyUnitTest,"CUnitTest_CreateAndDestroy_UnitTest");
1.26 +
1.27 +CUnitTest_CreateAndDestroy_UnitTest* CUnitTest_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
1.28 + MUnitTestObserver& aObserver)
1.29 + {
1.30 + CUnitTest_CreateAndDestroy_UnitTest* self =
1.31 + new(ELeave) CUnitTest_CreateAndDestroy_UnitTest(aDataLogger,
1.32 + aObserver);
1.33 + CleanupStack::PushL(self);
1.34 + self->ConstructL();
1.35 + CleanupStack::Pop();
1.36 + return self;
1.37 + }
1.38 +
1.39 +inline TInt CUnitTest_CreateAndDestroy_UnitTest::RunError(TInt aError)
1.40 + {
1.41 + // The RunL left so chain to the base first and then cleanup
1.42 + TInt error = CUnitTest::RunError(aError); // Chain to base
1.43 + delete iUTContext;
1.44 + delete iStateAccessor;
1.45 + /* delete any validators used */
1.46 + delete iCtorValidator;
1.47 + iCtorValidator = NULL;
1.48 + delete iDtorValidator;
1.49 + iDtorValidator = NULL;
1.50 + return error;
1.51 + }
1.52 +
1.53 +inline CUnitTest_CreateAndDestroy_UnitTest::~CUnitTest_CreateAndDestroy_UnitTest()
1.54 + {
1.55 + // Simply delete our test class instance
1.56 + delete iUTContext;
1.57 + delete iStateAccessor;
1.58 + /* delete any validators used */
1.59 + delete iCtorValidator;
1.60 + delete iDtorValidator;
1.61 + }
1.62 +
1.63 +inline CUnitTest_CreateAndDestroy_UnitTest::CUnitTest_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
1.64 + MUnitTestObserver& aObserver)
1.65 +: CUnitTest(KUnitTestCreateAndDestroyUnitTest, aDataLogger, aObserver)
1.66 + {
1.67 + //Do nothing
1.68 + }
1.69 +
1.70 +// Now the Individual transitions need to be added.
1.71 +inline void CUnitTest_CreateAndDestroy_UnitTest::ConstructL()
1.72 + {
1.73 + // Perform the base class initialization
1.74 + UnitTestConstructL();
1.75 +
1.76 + // Create the Unit test state accessor
1.77 + iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
1.78 + // Construct the Unit test context.
1.79 + iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
1.80 +
1.81 + // Add the Transitions in the order they are to run
1.82 + // C'tor first, D'tor last...
1.83 + iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
1.84 + iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
1.85 +
1.86 + AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
1.87 + AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
1.88 + }
1.89 +
1.90 +// ______________________________________________________________________________
1.91 +//
1.92 +_LIT(KUnitTestManageTransitionsUnitTest,"CUnitTest_ManageTransitions_UnitTest");
1.93 +
1.94 +CUnitTest_ManageTransitions_UnitTest* CUnitTest_ManageTransitions_UnitTest::NewL(CDataLogger& aDataLogger,
1.95 + MUnitTestObserver& aObserver)
1.96 + {
1.97 + CUnitTest_ManageTransitions_UnitTest* self =
1.98 + new(ELeave) CUnitTest_ManageTransitions_UnitTest(aDataLogger,
1.99 + aObserver);
1.100 + CleanupStack::PushL(self);
1.101 + self->ConstructL();
1.102 + CleanupStack::Pop();
1.103 + return self;
1.104 + }
1.105 +
1.106 +inline TInt CUnitTest_ManageTransitions_UnitTest::RunError(TInt aError)
1.107 + {
1.108 + // The RunL left so chain to the base first and then cleanup
1.109 + TInt error = CUnitTest::RunError(aError); // Chain to base
1.110 + delete iUTContext;
1.111 + delete iStateAccessor;
1.112 + /* delete any validators used */
1.113 + delete iCtorValidator;
1.114 + iCtorValidator = NULL;
1.115 + delete iTransitionSetValidator;
1.116 + iTransitionSetValidator = NULL;
1.117 + delete iGetCurrentTransitionValidator;
1.118 + iGetCurrentTransitionValidator = NULL;
1.119 + delete iSetCurrentTransitionValidator;
1.120 + iSetCurrentTransitionValidator = NULL;
1.121 + delete iDtorValidator;
1.122 + iDtorValidator = NULL;
1.123 + return error;
1.124 + }
1.125 +
1.126 +inline CUnitTest_ManageTransitions_UnitTest::~CUnitTest_ManageTransitions_UnitTest()
1.127 + {
1.128 + // Simply delete our test class instance
1.129 + delete iUTContext;
1.130 + delete iStateAccessor;
1.131 + /* delete any validators used */
1.132 + delete iCtorValidator;
1.133 + delete iTransitionSetValidator;
1.134 + delete iGetCurrentTransitionValidator;
1.135 + delete iSetCurrentTransitionValidator;
1.136 + delete iDtorValidator;
1.137 + }
1.138 +
1.139 +inline CUnitTest_ManageTransitions_UnitTest::CUnitTest_ManageTransitions_UnitTest(CDataLogger& aDataLogger,
1.140 + MUnitTestObserver& aObserver)
1.141 +: CUnitTest(KUnitTestManageTransitionsUnitTest, aDataLogger, aObserver)
1.142 + {
1.143 + //Do nothing
1.144 + }
1.145 +
1.146 +// Now the Individual transitions need to be added.
1.147 +inline void CUnitTest_ManageTransitions_UnitTest::ConstructL()
1.148 + {
1.149 + // Perform the base class initialization
1.150 + UnitTestConstructL();
1.151 +
1.152 + // Create the Unit test state accessor
1.153 + iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
1.154 + // Construct the Unit test context.
1.155 + iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
1.156 +
1.157 + // Add the Transitions in the order they are to run
1.158 + // C'tor first, D'tor last...
1.159 + iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
1.160 + iTransitionSetValidator = new(ELeave) TUnitTest_TransitionSet_TransitionValidator(*iUTContext);
1.161 + iGetCurrentTransitionValidator = new(ELeave) TUnitTest_GetCurrentTransition_TransitionValidator(*iUTContext);
1.162 + iSetCurrentTransitionValidator = new(ELeave) TUnitTest_SetCurrentTransition_TransitionValidator(*iUTContext);
1.163 + iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
1.164 +
1.165 + AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
1.166 + AddTransitionL(new(ELeave)CUnitTest_TransitionSetL_Transition(*iUTContext,*iTransitionSetValidator));
1.167 + AddTransitionL(new(ELeave)CUnitTest_GetCurrentTransition_Transition(*iUTContext,*iGetCurrentTransitionValidator));
1.168 + AddTransitionL(new(ELeave)CUnitTest_SetCurrentTransition_Transition(*iUTContext,*iSetCurrentTransitionValidator));
1.169 + AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
1.170 + }
1.171 +
1.172 +// ______________________________________________________________________________
1.173 +//
1.174 +_LIT(KUnitTestRunTestsUnitTest,"CUnitTest_RunTests_UnitTest");
1.175 +
1.176 +CUnitTest_RunTests_UnitTest* CUnitTest_RunTests_UnitTest::NewL(CDataLogger& aDataLogger,
1.177 + MUnitTestObserver& aObserver)
1.178 + {
1.179 + CUnitTest_RunTests_UnitTest* self =
1.180 + new(ELeave) CUnitTest_RunTests_UnitTest(aDataLogger,
1.181 + aObserver);
1.182 + CleanupStack::PushL(self);
1.183 + self->ConstructL();
1.184 + CleanupStack::Pop(self);
1.185 + return self;
1.186 + }
1.187 +
1.188 +inline TInt CUnitTest_RunTests_UnitTest::RunError(TInt aError)
1.189 + {
1.190 + // The RunL left so chain to the base first and then cleanup
1.191 + TInt error = CUnitTest::RunError(aError); // Chain to base
1.192 + delete iUTContext;
1.193 + iUTContext = NULL;
1.194 + delete iStateAccessor;
1.195 + iStateAccessor = NULL;
1.196 + /* delete any validators used */
1.197 + delete iCtorValidator;
1.198 + iCtorValidator = NULL;
1.199 + delete iSetParametersValidator;
1.200 + iSetParametersValidator = NULL;
1.201 + delete iPrepareUnitTestValidator;
1.202 + iPrepareUnitTestValidator = NULL;
1.203 + delete iRunTestValidator;
1.204 + iRunTestValidator = NULL;
1.205 + delete iDtorValidator;
1.206 + iDtorValidator = NULL;
1.207 + return error;
1.208 + }
1.209 +
1.210 +inline CUnitTest_RunTests_UnitTest::~CUnitTest_RunTests_UnitTest()
1.211 + {
1.212 + // Simply delete our test class instance
1.213 + delete iUTContext;
1.214 + delete iStateAccessor;
1.215 + /* delete any validators used */
1.216 + delete iCtorValidator;
1.217 + delete iSetParametersValidator;
1.218 + delete iPrepareUnitTestValidator;
1.219 + delete iRunTestValidator;
1.220 + delete iDtorValidator;
1.221 + }
1.222 +
1.223 +inline CUnitTest_RunTests_UnitTest::CUnitTest_RunTests_UnitTest(CDataLogger& aDataLogger,
1.224 + MUnitTestObserver& aObserver)
1.225 +: CUnitTest(KUnitTestRunTestsUnitTest, aDataLogger, aObserver)
1.226 + {
1.227 + //Do nothing
1.228 + }
1.229 +
1.230 +// Now the Individual transitions need to be added.
1.231 +inline void CUnitTest_RunTests_UnitTest::ConstructL()
1.232 + {
1.233 + // Perform the base class initialization
1.234 + UnitTestConstructL();
1.235 +
1.236 + // Create the Unit test state accessor
1.237 + iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
1.238 + // Construct the Unit test context.
1.239 + iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
1.240 +
1.241 + // Add the Transitions in the order they are to run
1.242 + // C'tor first, D'tor last...
1.243 + iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
1.244 + iSetParametersValidator = new(ELeave) TUnitTest_SetParameters_TransitionValidator(*iUTContext);
1.245 + iPrepareUnitTestValidator = new(ELeave) TUnitTest_PrepareUnitTest_TransitionValidator(*iUTContext);
1.246 + iRunTestValidator = new(ELeave) TUnitTest_RunTest_TransitionValidator(*iUTContext);
1.247 + iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
1.248 +
1.249 + AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
1.250 + AddTransitionL(new(ELeave)CUnitTest_SetParametersL_Transition(*iUTContext,*iSetParametersValidator));
1.251 + AddTransitionL(new(ELeave)CUnitTest_PrepareUnitTestL_Transition(*iUTContext,*iPrepareUnitTestValidator));
1.252 + AddTransitionL(new(ELeave)CUnitTest_RunTest_Transition(*iUTContext,*iRunTestValidator));
1.253 + AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
1.254 + }
1.255 +
1.256 +
1.257 +// ______________________________________________________________________________
1.258 +//
1.259 +_LIT(KUnitTestAllOtherUnitTest,"CUnitTest_AllOther_UnitTest");
1.260 +
1.261 +CUnitTest_AllOther_UnitTest* CUnitTest_AllOther_UnitTest::NewL(CDataLogger& aDataLogger,
1.262 + MUnitTestObserver& aObserver)
1.263 + {
1.264 + CUnitTest_AllOther_UnitTest* self =
1.265 + new(ELeave) CUnitTest_AllOther_UnitTest(aDataLogger,
1.266 + aObserver);
1.267 + CleanupStack::PushL(self);
1.268 + self->ConstructL();
1.269 + CleanupStack::Pop();
1.270 + return self;
1.271 + }
1.272 +
1.273 +inline TInt CUnitTest_AllOther_UnitTest::RunError(TInt aError)
1.274 + {
1.275 + // The RunL left so chain to the base first and then cleanup
1.276 + TInt error = CUnitTest::RunError(aError); // Chain to base
1.277 + delete iUTContext;
1.278 + delete iStateAccessor;
1.279 + /* delete any validators used */
1.280 + delete iCtorValidator;
1.281 + iCtorValidator = NULL;
1.282 + delete iAddTransitionValidator;
1.283 + iAddTransitionValidator = NULL;
1.284 + delete iAddBlockingTransitionValidator;
1.285 + iAddBlockingTransitionValidator = NULL;
1.286 + delete iAddLeaveErrorCodeValidator;
1.287 + iAddLeaveErrorCodeValidator = NULL;
1.288 + delete iUnitTestNameValidator;
1.289 + iUnitTestNameValidator = NULL;
1.290 + delete iDtorValidator;
1.291 + iDtorValidator = NULL;
1.292 +
1.293 + return error;
1.294 + }
1.295 +
1.296 +inline CUnitTest_AllOther_UnitTest::~CUnitTest_AllOther_UnitTest()
1.297 + {
1.298 + // Simply delete our test class instance
1.299 + delete iUTContext;
1.300 + delete iStateAccessor;
1.301 + /* delete any validators used */
1.302 + delete iCtorValidator;
1.303 + delete iAddTransitionValidator;
1.304 + delete iAddBlockingTransitionValidator;
1.305 + delete iAddLeaveErrorCodeValidator;
1.306 + delete iUnitTestNameValidator;
1.307 + delete iDtorValidator;
1.308 + }
1.309 +
1.310 +inline CUnitTest_AllOther_UnitTest::CUnitTest_AllOther_UnitTest(CDataLogger& aDataLogger,
1.311 + MUnitTestObserver& aObserver)
1.312 +: CUnitTest(KUnitTestAllOtherUnitTest, aDataLogger, aObserver)
1.313 + {
1.314 + //Do nothing
1.315 + }
1.316 +
1.317 +// Now the Individual transitions need to be added.
1.318 +inline void CUnitTest_AllOther_UnitTest::ConstructL()
1.319 + {
1.320 + // Perform the base class initialization
1.321 + UnitTestConstructL();
1.322 +
1.323 + // Create the Unit test state accessor
1.324 + iStateAccessor = new(ELeave) TUnitTest_StateAccessor;
1.325 + // Construct the Unit test context.
1.326 + iUTContext = new(ELeave) CUnitTest_UnitTestContext(iDataLogger, *iStateAccessor, *this);
1.327 +
1.328 + // Add the Transitions in the order they are to run
1.329 + // C'tor first, D'tor last...
1.330 + iCtorValidator = new(ELeave) TUnitTest_Ctor_TransitionValidator(*iUTContext);
1.331 + iAddTransitionValidator = new(ELeave) TUnitTest_AddTransition_TransitionValidator(*iUTContext);
1.332 + iAddBlockingTransitionValidator = new(ELeave) TUnitTest_AddBlockingTransition_TransitionValidator(*iUTContext);
1.333 + iAddLeaveErrorCodeValidator = new(ELeave) TUnitTest_AddLeaveErrorCode_TransitionValidator(*iUTContext);
1.334 + iUnitTestNameValidator = new(ELeave) TUnitTest_UnitTestName_TransitionValidator(*iUTContext);
1.335 + iDtorValidator = new(ELeave) TUnitTest_Dtor_TransitionValidator(*iUTContext);
1.336 +
1.337 + AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
1.338 + AddTransitionL(new(ELeave)CUnitTest_AddTransitionL_Transition(*iUTContext,*iAddTransitionValidator));
1.339 + AddTransitionL(new(ELeave)CUnitTest_AddBlockingTransitionL_Transition(*iUTContext,*iAddBlockingTransitionValidator));
1.340 + AddTransitionL(new(ELeave)CUnitTest_AddLeaveErrorCodeL_Transition(*iUTContext,*iAddLeaveErrorCodeValidator));
1.341 + AddTransitionL(new(ELeave)CUnitTest_UnitTestName_Transition(*iUTContext,*iUnitTestNameValidator));
1.342 + AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
1.343 + }
1.344 +