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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The unit test class implementations for the CUnitTest class.
18 #include "UnitTestUnitTest.h"
20 // ______________________________________________________________________________
22 _LIT(KUnitTestCreateAndDestroyUnitTest,"CUnitTest_CreateAndDestroy_UnitTest");
24 CUnitTest_CreateAndDestroy_UnitTest* CUnitTest_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
25 MUnitTestObserver& aObserver)
27 CUnitTest_CreateAndDestroy_UnitTest* self =
28 new(ELeave) CUnitTest_CreateAndDestroy_UnitTest(aDataLogger,
30 CleanupStack::PushL(self);
36 inline TInt CUnitTest_CreateAndDestroy_UnitTest::RunError(TInt aError)
38 // The RunL left so chain to the base first and then cleanup
39 TInt error = CUnitTest::RunError(aError); // Chain to base
41 delete iStateAccessor;
42 /* delete any validators used */
43 delete iCtorValidator;
44 iCtorValidator = NULL;
45 delete iDtorValidator;
46 iDtorValidator = NULL;
50 inline CUnitTest_CreateAndDestroy_UnitTest::~CUnitTest_CreateAndDestroy_UnitTest()
52 // Simply delete our test class instance
54 delete iStateAccessor;
55 /* delete any validators used */
56 delete iCtorValidator;
57 delete iDtorValidator;
60 inline CUnitTest_CreateAndDestroy_UnitTest::CUnitTest_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
61 MUnitTestObserver& aObserver)
62 : CUnitTest(KUnitTestCreateAndDestroyUnitTest, aDataLogger, aObserver)
67 // Now the Individual transitions need to be added.
68 inline void CUnitTest_CreateAndDestroy_UnitTest::ConstructL()
70 // Perform the base class initialization
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);
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);
83 AddTransitionL(new(ELeave)CUnitTest_NewL_Transition(*iUTContext,*iCtorValidator));
84 AddTransitionL(new(ELeave)CUnitTest_Dtor_Transition(*iUTContext,*iDtorValidator));
87 // ______________________________________________________________________________
89 _LIT(KUnitTestManageTransitionsUnitTest,"CUnitTest_ManageTransitions_UnitTest");
91 CUnitTest_ManageTransitions_UnitTest* CUnitTest_ManageTransitions_UnitTest::NewL(CDataLogger& aDataLogger,
92 MUnitTestObserver& aObserver)
94 CUnitTest_ManageTransitions_UnitTest* self =
95 new(ELeave) CUnitTest_ManageTransitions_UnitTest(aDataLogger,
97 CleanupStack::PushL(self);
103 inline TInt CUnitTest_ManageTransitions_UnitTest::RunError(TInt aError)
105 // The RunL left so chain to the base first and then cleanup
106 TInt error = CUnitTest::RunError(aError); // Chain to base
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;
123 inline CUnitTest_ManageTransitions_UnitTest::~CUnitTest_ManageTransitions_UnitTest()
125 // Simply delete our test class instance
127 delete iStateAccessor;
128 /* delete any validators used */
129 delete iCtorValidator;
130 delete iTransitionSetValidator;
131 delete iGetCurrentTransitionValidator;
132 delete iSetCurrentTransitionValidator;
133 delete iDtorValidator;
136 inline CUnitTest_ManageTransitions_UnitTest::CUnitTest_ManageTransitions_UnitTest(CDataLogger& aDataLogger,
137 MUnitTestObserver& aObserver)
138 : CUnitTest(KUnitTestManageTransitionsUnitTest, aDataLogger, aObserver)
143 // Now the Individual transitions need to be added.
144 inline void CUnitTest_ManageTransitions_UnitTest::ConstructL()
146 // Perform the base class initialization
147 UnitTestConstructL();
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);
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);
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));
169 // ______________________________________________________________________________
171 _LIT(KUnitTestRunTestsUnitTest,"CUnitTest_RunTests_UnitTest");
173 CUnitTest_RunTests_UnitTest* CUnitTest_RunTests_UnitTest::NewL(CDataLogger& aDataLogger,
174 MUnitTestObserver& aObserver)
176 CUnitTest_RunTests_UnitTest* self =
177 new(ELeave) CUnitTest_RunTests_UnitTest(aDataLogger,
179 CleanupStack::PushL(self);
181 CleanupStack::Pop(self);
185 inline TInt CUnitTest_RunTests_UnitTest::RunError(TInt aError)
187 // The RunL left so chain to the base first and then cleanup
188 TInt error = CUnitTest::RunError(aError); // Chain to base
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;
207 inline CUnitTest_RunTests_UnitTest::~CUnitTest_RunTests_UnitTest()
209 // Simply delete our test class instance
211 delete iStateAccessor;
212 /* delete any validators used */
213 delete iCtorValidator;
214 delete iSetParametersValidator;
215 delete iPrepareUnitTestValidator;
216 delete iRunTestValidator;
217 delete iDtorValidator;
220 inline CUnitTest_RunTests_UnitTest::CUnitTest_RunTests_UnitTest(CDataLogger& aDataLogger,
221 MUnitTestObserver& aObserver)
222 : CUnitTest(KUnitTestRunTestsUnitTest, aDataLogger, aObserver)
227 // Now the Individual transitions need to be added.
228 inline void CUnitTest_RunTests_UnitTest::ConstructL()
230 // Perform the base class initialization
231 UnitTestConstructL();
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);
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);
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));
254 // ______________________________________________________________________________
256 _LIT(KUnitTestAllOtherUnitTest,"CUnitTest_AllOther_UnitTest");
258 CUnitTest_AllOther_UnitTest* CUnitTest_AllOther_UnitTest::NewL(CDataLogger& aDataLogger,
259 MUnitTestObserver& aObserver)
261 CUnitTest_AllOther_UnitTest* self =
262 new(ELeave) CUnitTest_AllOther_UnitTest(aDataLogger,
264 CleanupStack::PushL(self);
270 inline TInt CUnitTest_AllOther_UnitTest::RunError(TInt aError)
272 // The RunL left so chain to the base first and then cleanup
273 TInt error = CUnitTest::RunError(aError); // Chain to base
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;
293 inline CUnitTest_AllOther_UnitTest::~CUnitTest_AllOther_UnitTest()
295 // Simply delete our test class instance
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;
307 inline CUnitTest_AllOther_UnitTest::CUnitTest_AllOther_UnitTest(CDataLogger& aDataLogger,
308 MUnitTestObserver& aObserver)
309 : CUnitTest(KUnitTestAllOtherUnitTest, aDataLogger, aObserver)
314 // Now the Individual transitions need to be added.
315 inline void CUnitTest_AllOther_UnitTest::ConstructL()
317 // Perform the base class initialization
318 UnitTestConstructL();
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);
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);
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));