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 // This file contains the definition of the
15 // class CAllTransitionsUnitTest
16 // Note : All the REComSession references from this file
17 // These are simple fudges for early development tests
18 // before the true server migration of the code.
24 #include "TestUtilities.h" // For __FILE__LINE__
25 #include "Interface.h"
26 #include <ecom/test_bed/datalogger.h>
28 #include "MagicUnitTests.h"
29 #include "MagicTransitions.h"
30 #include "MagicTransitionValidation.h"
32 #include "TlsData.h" // For GlobalData
34 #define UNUSED_VAR(a) a = a
36 // ______________________________________________________________________________
38 _LIT(KInterfaceCreateAndDestroyUnitTest,"CExampleInterfaceCreateAndDestroyUnitTest");
40 CExampleInterfaceCreateAndDestroyUnitTest* CExampleInterfaceCreateAndDestroyUnitTest::NewL(CDataLogger& aDataLogger,
41 MUnitTestObserver& aObserver)
43 CExampleInterfaceCreateAndDestroyUnitTest* self =
44 new(ELeave) CExampleInterfaceCreateAndDestroyUnitTest(aDataLogger,
46 CleanupStack::PushL(self);
47 // Chain to the base which calls the ConstructL
53 TInt CExampleInterfaceCreateAndDestroyUnitTest::RunError(TInt aError)
55 // The RunL left so chain to the base first and then cleanup
56 TInt error = CUnitTest::RunError(aError); // Chain to base
59 delete iStateAccessor;
60 iStateAccessor = NULL;
61 delete iCtorValidator;
62 delete iDtorValidator;
69 CExampleInterfaceCreateAndDestroyUnitTest::~CExampleInterfaceCreateAndDestroyUnitTest()
71 // Simply delete our test class instance
73 delete iStateAccessor;
74 delete iCtorValidator;
75 delete iDtorValidator;
79 CExampleInterfaceCreateAndDestroyUnitTest::CExampleInterfaceCreateAndDestroyUnitTest(CDataLogger& aDataLogger,
80 MUnitTestObserver& aObserver)
81 : CUnitTest(KInterfaceCreateAndDestroyUnitTest, aDataLogger, aObserver)
86 // Now the Individual transitions need to be added.
87 void CExampleInterfaceCreateAndDestroyUnitTest::ConstructL()
89 // Perform the base class initialization
92 // Create the Unit test state accessor
93 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor();
96 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
98 // Add the Transitions in the order they are to run
99 // C'tor first, D'tor last...
100 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
101 AddTransitionL(new(ELeave)CExampleInterfaceNewLTransition(*iUTContext,*iCtorValidator));
103 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
104 AddTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext,*iDtorValidator));
106 // ______________________________________________________________________________
108 _LIT(KExampleInterfaceAltCreateAndDestroyUnitTest,"CExampleInterfaceAltCreateAndDestroyUnitTest");
110 CExampleInterfaceAltCreateAndDestroyUnitTest* CExampleInterfaceAltCreateAndDestroyUnitTest::NewL(CDataLogger& aDataLogger,
111 MUnitTestObserver& aObserver)
113 CExampleInterfaceAltCreateAndDestroyUnitTest* self =
114 new(ELeave) CExampleInterfaceAltCreateAndDestroyUnitTest(aDataLogger,
116 CleanupStack::PushL(self);
117 // Chain to the base which calls the ConstructL
119 CleanupStack::Pop(self);
123 TInt CExampleInterfaceAltCreateAndDestroyUnitTest::RunError(TInt aError)
125 // The RunL left so chain to the base first and then cleanup
126 TInt error = CUnitTest::RunError(aError); // Chain to base
129 delete iStateAccessor;
130 iStateAccessor = NULL;
131 delete iCtorValidator;
132 iCtorValidator = NULL;
133 delete iDtorValidator;
134 iDtorValidator = NULL;
139 CExampleInterfaceAltCreateAndDestroyUnitTest::~CExampleInterfaceAltCreateAndDestroyUnitTest()
141 // Simply delete our test class instance
143 delete iStateAccessor;
144 delete iCtorValidator;
145 delete iDtorValidator;
149 CExampleInterfaceAltCreateAndDestroyUnitTest::CExampleInterfaceAltCreateAndDestroyUnitTest(CDataLogger& aDataLogger,
150 MUnitTestObserver& aObserver)
151 : CUnitTest(KExampleInterfaceAltCreateAndDestroyUnitTest, aDataLogger, aObserver)
156 // Now the Individual transitions need to be added.
157 void CExampleInterfaceAltCreateAndDestroyUnitTest::ConstructL()
159 // Perform the base class initialization
160 UnitTestConstructL();
162 // Create the Unit test state accessor
163 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor();
165 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
167 // Create the required validators
168 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
169 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
171 // Add the transitions in the order they are to run
172 AddTransitionL(new(ELeave)CExampleInterfaceNewWPLTransition(*iUTContext, *iCtorValidator));
173 AddTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext, *iDtorValidator));
175 AddTransitionL(new(ELeave)CExampleInterfaceNewResolveLTransition(*iUTContext, *iCtorValidator));
176 AddTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext, *iDtorValidator));
180 // ______________________________________________________________________________
182 _LIT(KExampleInterfaceListAllImplementationsUnitTest,"CExampleInterface_ListImplementations_UnitTest");
184 CExampleInterface_ListImplementations_UnitTest* CExampleInterface_ListImplementations_UnitTest::NewL(CDataLogger& aDataLogger,
185 MUnitTestObserver& aObserver)
187 CExampleInterface_ListImplementations_UnitTest* self =
188 new(ELeave) CExampleInterface_ListImplementations_UnitTest(aDataLogger,
190 CleanupStack::PushL(self);
196 inline TInt CExampleInterface_ListImplementations_UnitTest::RunError(TInt aError)
198 // The RunL left so chain to the base first and then cleanup
199 TInt error = CUnitTest::RunError(aError); // Chain to base
202 delete iStateAccessor;
203 // delete any validators used
204 delete iCtorValidator;
205 iCtorValidator = NULL;
206 delete iListImplementationsValidator;
207 iListImplementationsValidator = NULL;
208 delete iDtorValidator;
209 iDtorValidator = NULL;
214 inline CExampleInterface_ListImplementations_UnitTest::~CExampleInterface_ListImplementations_UnitTest()
217 delete iStateAccessor;
218 // delete any validators used
219 delete iCtorValidator;
220 delete iListImplementationsValidator;
221 delete iDtorValidator;
224 inline CExampleInterface_ListImplementations_UnitTest::CExampleInterface_ListImplementations_UnitTest(CDataLogger& aDataLogger,
225 MUnitTestObserver& aObserver)
226 : CUnitTest(KExampleInterfaceListAllImplementationsUnitTest, aDataLogger, aObserver)
231 // Now the Individual transitions need to be added.
232 inline void CExampleInterface_ListImplementations_UnitTest::ConstructL()
234 // Perform the base class initialization
235 UnitTestConstructL();
237 // Create the Unit test state accessor
238 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor;
239 // Construct the Unit test context.
240 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
241 // Add the Transitions in the order they are to run
242 // C'tor first, D'tor last...
243 // Examples of C'tor and D'tor transitions on CExampleInterface class.
244 // using ctor and dtor validators
245 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
246 AddTransitionL(new(ELeave)CExampleInterfaceNewLTransition(*iUTContext,*iCtorValidator));
248 iListImplementationsValidator = new(ELeave) TExampleInterface_ListImplementations_TransitionValidator(*iUTContext);
249 AddTransitionL(new(ELeave)CExampleInterfaceListAllImplementationsLTransition(*iUTContext,*iListImplementationsValidator));
250 AddTransitionL(new(ELeave)CExampleInterfaceListImplementationsLTransition(*iUTContext,*iListImplementationsValidator));
252 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
253 AddTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext,*iDtorValidator));
256 // ______________________________________________________________________________
258 _LIT(KExampleInterfaceDefectHAN4WZHSYUnitTest,"CExampleInterface_DefectHAN4WZHSY_UnitTest");
260 CExampleInterface_DefectHAN4WZHSY_UnitTest* CExampleInterface_DefectHAN4WZHSY_UnitTest::NewL(CDataLogger& aDataLogger,
261 MUnitTestObserver& aObserver)
263 CExampleInterface_DefectHAN4WZHSY_UnitTest* self =
264 new(ELeave) CExampleInterface_DefectHAN4WZHSY_UnitTest(aDataLogger,
266 CleanupStack::PushL(self);
272 inline TInt CExampleInterface_DefectHAN4WZHSY_UnitTest::RunError(TInt aError)
274 // The RunL left so chain to the base first and then cleanup
275 TInt error = CUnitTest::RunError(aError); // Chain to base
277 delete iStateAccessor;
282 delete iCtorValidator;
283 delete iDtorValidator;
291 inline CExampleInterface_DefectHAN4WZHSY_UnitTest::~CExampleInterface_DefectHAN4WZHSY_UnitTest()
293 // Simply delete our test class instance
295 delete iStateAccessor;
297 delete iCtorValidator;
298 delete iDtorValidator;
301 inline CExampleInterface_DefectHAN4WZHSY_UnitTest::CExampleInterface_DefectHAN4WZHSY_UnitTest(CDataLogger& aDataLogger,
302 MUnitTestObserver& aObserver)
303 : CUnitTest(KExampleInterfaceDefectHAN4WZHSYUnitTest, aDataLogger, aObserver)
308 // Now the Individual transitions need to be added.
309 inline void CExampleInterface_DefectHAN4WZHSY_UnitTest::ConstructL()
311 // Perform the base class initialization
312 UnitTestConstructL();
314 // Create the Unit test state accessor
315 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor;
316 // Construct the Unit test context.
317 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
319 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
320 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
322 AddTransitionL(new(ELeave)CExampleInterfaceNewLTransition(*iUTContext,*iCtorValidator));
323 AddTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext,*iDtorValidator));
326 // ______________________________________________________________________________
328 _LIT(KExampleInterfaceDefectCUO4YCEUEUnitTest,"CExampleInterface_DefectCUO4YCEUE_UnitTest");
330 CExampleInterface_DefectCUO4YCEUE_UnitTest* CExampleInterface_DefectCUO4YCEUE_UnitTest::NewL(CDataLogger& aDataLogger,
331 MUnitTestObserver& aObserver)
333 CExampleInterface_DefectCUO4YCEUE_UnitTest* self =
334 new(ELeave) CExampleInterface_DefectCUO4YCEUE_UnitTest(aDataLogger,
336 CleanupStack::PushL(self);
338 CleanupStack::Pop(self);
342 inline TInt CExampleInterface_DefectCUO4YCEUE_UnitTest::RunError(TInt aError)
344 // The RunL left so chain to the base first and then cleanup
345 TInt error = CUnitTest::RunError(aError); // Chain to base
347 delete iStateAccessor;
349 delete iCtorValidator;
350 delete iDtorValidator;
361 inline CExampleInterface_DefectCUO4YCEUE_UnitTest::~CExampleInterface_DefectCUO4YCEUE_UnitTest()
363 // Simply delete our test class instance
365 delete iStateAccessor;
367 delete iCtorValidator;
368 delete iDtorValidator;
371 inline CExampleInterface_DefectCUO4YCEUE_UnitTest::CExampleInterface_DefectCUO4YCEUE_UnitTest(CDataLogger& aDataLogger,
372 MUnitTestObserver& aObserver)
373 : CUnitTest(KExampleInterfaceDefectCUO4YCEUEUnitTest, aDataLogger, aObserver)
378 // Now the Individual transitions need to be added.
379 inline void CExampleInterface_DefectCUO4YCEUE_UnitTest::ConstructL()
381 // Perform the base class initialization
382 UnitTestConstructL();
384 // Create the Unit test state accessor
385 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor;
386 // Construct the Unit test context.
387 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
389 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
390 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
392 AddTransitionL(new(ELeave)CExampleInterfaceDoubleNewLTransition(*iUTContext,*iCtorValidator));
393 AddTransitionL(new(ELeave)CExampleInterfaceDoubleDtorTransition(*iUTContext,*iDtorValidator));
396 // ______________________________________________________________________________
398 _LIT(KExampleInterfaceDefectEVS4Z9BPGUnitTest,"CExampleInterface_DefectEVS4Z9BPG_UnitTest");
400 CExampleInterface_DefectEVS4Z9BPG_UnitTest* CExampleInterface_DefectEVS4Z9BPG_UnitTest::NewL(CDataLogger& aDataLogger,
401 MUnitTestObserver& aObserver)
403 CExampleInterface_DefectEVS4Z9BPG_UnitTest* self =
404 new(ELeave) CExampleInterface_DefectEVS4Z9BPG_UnitTest(aDataLogger,
406 CleanupStack::PushL(self);
408 CleanupStack::Pop(self);
412 inline TInt CExampleInterface_DefectEVS4Z9BPG_UnitTest::RunError(TInt aError)
414 // The RunL left so chain to the base first and then cleanup
415 TInt error = CUnitTest::RunError(aError); // Chain to base
417 delete iStateAccessor;
419 delete iCtorValidator;
420 delete iDefaultValidator;
421 delete iDtorValidator;
427 iDefaultValidator = 0;
433 inline CExampleInterface_DefectEVS4Z9BPG_UnitTest::~CExampleInterface_DefectEVS4Z9BPG_UnitTest()
435 // Simply delete our test class instance
437 delete iStateAccessor;
439 delete iCtorValidator;
440 delete iDefaultValidator;
441 delete iDtorValidator;
444 inline CExampleInterface_DefectEVS4Z9BPG_UnitTest::CExampleInterface_DefectEVS4Z9BPG_UnitTest(CDataLogger& aDataLogger,
445 MUnitTestObserver& aObserver)
446 : CUnitTest(KExampleInterfaceDefectEVS4Z9BPGUnitTest, aDataLogger, aObserver)
451 // Now the Individual transitions need to be added.
452 inline void CExampleInterface_DefectEVS4Z9BPG_UnitTest::ConstructL()
454 // Perform the base class initialization
455 UnitTestConstructL();
457 // Create the Unit test state accessor
458 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor;
459 // Construct the Unit test context.
460 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
462 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
463 iDefaultValidator = new(ELeave) TExampleInterface_Default_TransitionValidator(*iUTContext);
464 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
466 AddTransitionL(new(ELeave)CExampleInterfaceDoubleNewLTransition(*iUTContext,*iCtorValidator));
467 AddTransitionL(new(ELeave)CExampleInterfaceDoMethodLTransition(*iUTContext,*iDefaultValidator));
468 AddTransitionL(new(ELeave)CExampleInterfaceDoubleDtorTransition(*iUTContext,*iDtorValidator));
471 // ______________________________________________________________________________
473 _LIT(KExampleInterfaceDefectKRN53SL4QUnitTest,"CExampleInterface_DefectKRN53SL4Q_UnitTest");
475 CExampleInterface_DefectKRN53SL4Q_UnitTest* CExampleInterface_DefectKRN53SL4Q_UnitTest::NewL(CDataLogger& aDataLogger,
476 MUnitTestObserver& aObserver)
478 CExampleInterface_DefectKRN53SL4Q_UnitTest* self =
479 new(ELeave) CExampleInterface_DefectKRN53SL4Q_UnitTest(aDataLogger,
481 CleanupStack::PushL(self);
483 CleanupStack::Pop(self);
487 inline TInt CExampleInterface_DefectKRN53SL4Q_UnitTest::RunError(TInt aError)
489 // The RunL left so chain to the base first and then cleanup
490 TInt error = CUnitTest::RunError(aError); // Chain to base
492 delete iStateAccessor;
494 delete iCtorValidator;
495 delete iDefaultValidator;
496 delete iDtorValidator;
502 iDefaultValidator = 0;
508 inline CExampleInterface_DefectKRN53SL4Q_UnitTest::~CExampleInterface_DefectKRN53SL4Q_UnitTest()
510 // Simply delete our test class instance
512 delete iStateAccessor;
514 delete iCtorValidator;
515 delete iDefaultValidator;
516 delete iDtorValidator;
519 inline CExampleInterface_DefectKRN53SL4Q_UnitTest::CExampleInterface_DefectKRN53SL4Q_UnitTest(CDataLogger& aDataLogger,
520 MUnitTestObserver& aObserver)
521 : CUnitTest(KExampleInterfaceDefectKRN53SL4QUnitTest, aDataLogger, aObserver)
526 TInt ThreadFunc(TAny* aTrapHandler)
528 User::SetTrapHandler(REINTERPRET_CAST(TCleanupTrapHandler*, aTrapHandler));
530 RImplInfoPtrArray implementations;
531 TRAPD(error, CExampleInterface::ListImplementationsL(implementations));
536 // Now the Individual transitions need to be added.
537 inline void CExampleInterface_DefectKRN53SL4Q_UnitTest::ConstructL()
539 // Perform the base class initialization
540 UnitTestConstructL();
542 // Create the Unit test state accessor
543 iStateAccessor = new(ELeave) TExampleInterface_StateAccessor;
544 // Construct the Unit test context.
545 iUTContext = new(ELeave) CExampleInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
547 _LIT(KNewThreadName, "ListImpl");
548 User::Leave (KErrNone != iUTContext->iListImplThread.Create(KNewThreadName(), // The name of the thread
549 ThreadFunc, //CExampleInterface_UnitTestContext::ListImplementationsThreadFunction, // The function to be called when this thread resumes
550 2048, // The stacksize for this thread
551 2048, // min heap size
552 2048, // max heap size
553 User::TrapHandler())); // Parameter to be passed to function
556 iCtorValidator = new(ELeave) TExampleInterface_Ctor_TransitionValidator(*iUTContext);
557 iDefaultValidator = new(ELeave) TExampleInterface_Default_TransitionValidator(*iUTContext);
558 iDtorValidator = new(ELeave) TExampleInterface_Dtor_TransitionValidator(*iUTContext);
560 AddTransitionL(new(ELeave)CExampleInterfaceNewLTransition(*iUTContext,*iCtorValidator));
561 AddTransitionL(new(ELeave)CExampleInterfaceListImplementationsLNewThreadTransition(*iUTContext,*iDefaultValidator));
562 AddBlockingTransitionL(new(ELeave)CExampleInterfaceDtorTransition(*iUTContext,*iDtorValidator));