os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/ComponentTesterTest/ComponentTesterUnitTest.cpp
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 CComponentTester class.
18 #include "ComponentTesterUnitTest.h"
20 // ______________________________________________________________________________
22 _LIT(KComponentTesterCreateAndDestroyUnitTest,"CComponentTester_CreateAndDestroy_UnitTest");
24 CComponentTester_CreateAndDestroy_UnitTest* CComponentTester_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
25 MUnitTestObserver& aObserver)
27 CComponentTester_CreateAndDestroy_UnitTest* self =
28 new(ELeave) CComponentTester_CreateAndDestroy_UnitTest(aDataLogger,
30 CleanupStack::PushL(self);
36 inline TInt CComponentTester_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
42 delete iStateAccessor;
43 iStateAccessor = NULL;
44 /* delete any validators used */
45 delete iCtorValidator;
46 iCtorValidator = NULL;
47 delete iDtorValidator;
48 iDtorValidator = NULL;
52 inline CComponentTester_CreateAndDestroy_UnitTest::~CComponentTester_CreateAndDestroy_UnitTest()
54 // Simply delete our test class instance
56 delete iStateAccessor;
57 /* delete any validators used */
58 delete iCtorValidator;
59 delete iDtorValidator;
62 inline CComponentTester_CreateAndDestroy_UnitTest::CComponentTester_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
63 MUnitTestObserver& aObserver)
64 : CUnitTest(KComponentTesterCreateAndDestroyUnitTest, aDataLogger, aObserver)
69 // Now the Individual transitions need to be added.
70 inline void CComponentTester_CreateAndDestroy_UnitTest::ConstructL()
72 // Perform the base class initialization
75 // Create the Unit test state accessor
76 iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
77 // Construct the Unit test context.
78 iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
80 // Add the Transitions in the order they are to run
81 // C'tor first, D'tor last...
82 iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
83 iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
85 AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
86 AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));
89 // ______________________________________________________________________________
91 _LIT(KComponentTesterManageUnitTestsUnitTest,"CComponentTester_ManageUnitTests_UnitTest");
93 CComponentTester_ManageUnitTests_UnitTest* CComponentTester_ManageUnitTests_UnitTest::NewL(CDataLogger& aDataLogger,
94 MUnitTestObserver& aObserver)
96 CComponentTester_ManageUnitTests_UnitTest* self =
97 new(ELeave) CComponentTester_ManageUnitTests_UnitTest(aDataLogger,
99 CleanupStack::PushL(self);
105 inline TInt CComponentTester_ManageUnitTests_UnitTest::RunError(TInt aError)
107 // The RunL left so chain to the base first and then cleanup
108 TInt error = CUnitTest::RunError(aError); // Chain to base
111 delete iStateAccessor;
112 iStateAccessor = NULL;
113 /* delete any validators used */
114 delete iCtorValidator;
115 iCtorValidator = NULL;
116 delete iTransitionSetsValidator;
117 iTransitionSetsValidator = NULL;
118 delete iAddUnitTestValidator;
119 iAddUnitTestValidator = NULL;
120 delete iAddParamUnitTestValidator;
121 iAddParamUnitTestValidator = NULL;
122 delete iDtorValidator;
123 iDtorValidator = NULL;
127 inline CComponentTester_ManageUnitTests_UnitTest::~CComponentTester_ManageUnitTests_UnitTest()
129 // Simply delete our test class instance
131 delete iStateAccessor;
132 /* delete any validators used */
133 delete iCtorValidator;
134 delete iTransitionSetsValidator;
135 delete iAddUnitTestValidator;
136 delete iAddParamUnitTestValidator;
137 delete iDtorValidator;
140 inline CComponentTester_ManageUnitTests_UnitTest::CComponentTester_ManageUnitTests_UnitTest(CDataLogger& aDataLogger,
141 MUnitTestObserver& aObserver)
142 : CUnitTest(KComponentTesterManageUnitTestsUnitTest, aDataLogger, aObserver)
147 // Now the Individual transitions need to be added.
148 inline void CComponentTester_ManageUnitTests_UnitTest::ConstructL()
150 // Perform the base class initialization
151 UnitTestConstructL();
153 // Create the Unit test state accessor
154 iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
155 // Construct the Unit test context.
156 iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
158 // Add the Transitions in the order they are to run
159 // C'tor first, D'tor last...
160 iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
161 iTransitionSetsValidator = new(ELeave) TComponentTester_TransitionSets_TransitionValidator(*iUTContext);
162 iAddUnitTestValidator = new(ELeave) TComponentTester_AddUnitTest_TransitionValidator(*iUTContext);
163 iAddParamUnitTestValidator = new(ELeave) TComponentTester_AddParamUnitTest_TransitionValidator(*iUTContext);
164 iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
166 AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
167 AddTransitionL(new(ELeave)CComponentTester_TransitionSetsL_Transition(*iUTContext,*iTransitionSetsValidator));
168 AddTransitionL(new(ELeave)CComponentTester_AddUnitTestL_Transition(*iUTContext,*iAddUnitTestValidator));
169 AddTransitionL(new(ELeave)CComponentTester_AddParamUnitTestL_Transition(*iUTContext,*iAddParamUnitTestValidator));
170 AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));
173 // ______________________________________________________________________________
175 _LIT(KComponentTesterRunTestsUnitTest,"CComponentTester_RunTests_UnitTest");
177 CComponentTester_RunTests_UnitTest* CComponentTester_RunTests_UnitTest::NewL(CDataLogger& aDataLogger,
178 MUnitTestObserver& aObserver)
180 CComponentTester_RunTests_UnitTest* self =
181 new(ELeave) CComponentTester_RunTests_UnitTest(aDataLogger,
183 CleanupStack::PushL(self);
189 inline TInt CComponentTester_RunTests_UnitTest::RunError(TInt aError)
191 // The RunL left so chain to the base first and then cleanup
192 TInt error = CUnitTest::RunError(aError); // Chain to base
195 delete iStateAccessor;
196 iStateAccessor = NULL;
197 /* delete any validators used */
198 delete iCtorValidator;
199 iCtorValidator = NULL;
200 delete iTestComponentValidator;
201 iTestComponentValidator = NULL;
202 delete iRunValidator;
203 iRunValidator = NULL;
204 delete iCompleteValidator;
205 iCompleteValidator = NULL;
206 delete iDtorValidator;
207 iDtorValidator = NULL;
211 inline CComponentTester_RunTests_UnitTest::~CComponentTester_RunTests_UnitTest()
213 // Simply delete our test class instance
215 delete iStateAccessor;
216 /* delete any validators used */
217 delete iCtorValidator;
218 delete iTestComponentValidator;
219 delete iRunValidator;
220 delete iCompleteValidator;
221 delete iDtorValidator;
224 inline CComponentTester_RunTests_UnitTest::CComponentTester_RunTests_UnitTest(CDataLogger& aDataLogger,
225 MUnitTestObserver& aObserver)
226 : CUnitTest(KComponentTesterRunTestsUnitTest, aDataLogger, aObserver)
231 // Now the Individual transitions need to be added.
232 inline void CComponentTester_RunTests_UnitTest::ConstructL()
234 // Perform the base class initialization
235 UnitTestConstructL();
237 // Create the Unit test state accessor
238 iStateAccessor = new(ELeave) TComponentTester_StateAccessor;
239 // Construct the Unit test context.
240 iUTContext = new(ELeave) CComponentTester_UnitTestContext(iDataLogger, *iStateAccessor, *this);
242 // Specify the tests to be run by the TestComponent method. 0 means run all tests
243 // iUTContext->iTests = 0;
244 TTestInfo* testInfo = new(ELeave) TTestInfo;
245 testInfo->iComponentId = 0; // Run the first component found
246 testInfo->iUnitTestId = 0; // Run the first unit test from the the component found
247 testInfo->iRunTime = 0; // Run the test immediately
248 testInfo->iParameters = NULL;
249 User::LeaveIfError(iUTContext->iTests.Append(testInfo));
251 // Add the Transitions in the order they are to run
252 // C'tor first, D'tor last...
253 iCtorValidator = new(ELeave) TComponentTester_Ctor_TransitionValidator(*iUTContext);
254 iTestComponentValidator = new(ELeave) TComponentTester_TestComponent_TransitionValidator(*iUTContext);
255 iRunValidator = new(ELeave) TComponentTester_Run_TransitionValidator(*iUTContext);
256 iCompleteValidator = new(ELeave) TComponentTester_Complete_TransitionValidator(*iUTContext);
257 iDtorValidator = new(ELeave) TComponentTester_Dtor_TransitionValidator(*iUTContext);
259 AddTransitionL(new(ELeave)CComponentTester_NewL_Transition(*iUTContext,*iCtorValidator));
260 AddTransitionL(new(ELeave)CComponentTester_TestComponent_Transition(*iUTContext,*iTestComponentValidator));
261 AddTransitionL(new(ELeave)CComponentTester_RunL_Transition(*iUTContext,*iRunValidator));
262 AddTransitionL(new(ELeave)CComponentTester_Complete_Transition(*iUTContext,*iCompleteValidator));
263 AddTransitionL(new(ELeave)CComponentTester_Dtor_Transition(*iUTContext,*iDtorValidator));