|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The unit test class implementations for the CTestController class. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TestControllerUnitTest.h" |
|
19 |
|
20 // ______________________________________________________________________________ |
|
21 // |
|
22 _LIT(KTestControllerCreateAndDestroyUnitTest,"CTestController_CreateAndDestroy_UnitTest"); |
|
23 |
|
24 CTestController_CreateAndDestroy_UnitTest* CTestController_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, |
|
25 MUnitTestObserver& aObserver) |
|
26 { |
|
27 CTestController_CreateAndDestroy_UnitTest* self = |
|
28 new(ELeave) CTestController_CreateAndDestroy_UnitTest(aDataLogger, |
|
29 aObserver); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 inline TInt CTestController_CreateAndDestroy_UnitTest::RunError(TInt aError) |
|
37 { |
|
38 // The RunL left so chain to the base first and then cleanup |
|
39 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
40 delete iUTContext; |
|
41 iUTContext = NULL; |
|
42 delete iStateAccessor; |
|
43 iStateAccessor = NULL; |
|
44 // delete any validators used |
|
45 delete iCtorValidator; |
|
46 iCtorValidator = NULL; |
|
47 delete iDtorValidator; |
|
48 iDtorValidator = NULL; |
|
49 |
|
50 return error; |
|
51 } |
|
52 |
|
53 inline CTestController_CreateAndDestroy_UnitTest::~CTestController_CreateAndDestroy_UnitTest() |
|
54 { |
|
55 // Simply delete our test class instance |
|
56 delete iUTContext; |
|
57 delete iStateAccessor; |
|
58 // delete any validators used |
|
59 iFs.Close(); |
|
60 delete iCtorValidator; |
|
61 delete iDtorValidator; |
|
62 } |
|
63 |
|
64 inline CTestController_CreateAndDestroy_UnitTest::CTestController_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, |
|
65 MUnitTestObserver& aObserver) |
|
66 : CUnitTest(KTestControllerCreateAndDestroyUnitTest, aDataLogger, aObserver) |
|
67 { |
|
68 //Do nothing |
|
69 } |
|
70 |
|
71 _LIT(KLogTitle,"Dummy Log title"); |
|
72 |
|
73 // Now the Individual transitions need to be added. |
|
74 inline void CTestController_CreateAndDestroy_UnitTest::ConstructL() |
|
75 { |
|
76 // Perform the base class initialization |
|
77 UnitTestConstructL(); |
|
78 |
|
79 // Create the Unit test state accessor |
|
80 iStateAccessor = new(ELeave) TTestController_StateAccessor; |
|
81 // Construct the Unit test context. |
|
82 iUTContext = new(ELeave) CTestController_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs); |
|
83 iUTContext->iScheduler = new(ELeave) CActiveScheduler; |
|
84 iUTContext->iLogInfo = new(ELeave) TLoggingInfo; |
|
85 iUTContext->iLogInfo->iTitle = &(KLogTitle); |
|
86 iUTContext->iLogInfo->iUseRDebug = ETrue; |
|
87 iUTContext->iLogInfo->iLogOutput = 0; |
|
88 iUTContext->iLogInfo->iReportOutput = 0; |
|
89 iUTContext->iLogInfo->iStyle = EHtml; |
|
90 |
|
91 // Add the Transitions in the order they are to run |
|
92 // C'tor first, D'tor last... |
|
93 iCtorValidator = new(ELeave) TTestController_Ctor_TransitionValidator(*iUTContext); |
|
94 iDtorValidator = new(ELeave) TTestController_Dtor_TransitionValidator(*iUTContext); |
|
95 |
|
96 AddTransitionL(new(ELeave)CTestController_NewL_Transition(*iUTContext,*iCtorValidator)); |
|
97 AddTransitionL(new(ELeave)CTestController_Dtor_Transition(*iUTContext,*iDtorValidator)); |
|
98 } |
|
99 |
|
100 // ______________________________________________________________________________ |
|
101 // |
|
102 _LIT(KTestControllerFindTestsUnitTest,"CTestController_FindTests_UnitTest"); |
|
103 |
|
104 CTestController_FindTests_UnitTest* CTestController_FindTests_UnitTest::NewL(CDataLogger& aDataLogger, |
|
105 MUnitTestObserver& aObserver) |
|
106 { |
|
107 CTestController_FindTests_UnitTest* self = |
|
108 new(ELeave) CTestController_FindTests_UnitTest(aDataLogger, |
|
109 aObserver); |
|
110 CleanupStack::PushL(self); |
|
111 self->ConstructL(); |
|
112 CleanupStack::Pop(); |
|
113 return self; |
|
114 } |
|
115 |
|
116 inline TInt CTestController_FindTests_UnitTest::RunError(TInt aError) |
|
117 { |
|
118 // The RunL left so chain to the base first and then cleanup |
|
119 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
120 delete iUTContext; |
|
121 iUTContext = NULL; |
|
122 delete iStateAccessor; |
|
123 iStateAccessor = NULL; |
|
124 // delete any validators used |
|
125 delete iCtorValidator; |
|
126 iCtorValidator = NULL; |
|
127 delete iFindComponentsValidator; |
|
128 iFindComponentsValidator = NULL; |
|
129 delete iStartValidator; |
|
130 iStartValidator = NULL; |
|
131 delete iDtorValidator; |
|
132 iDtorValidator = NULL; |
|
133 |
|
134 return error; |
|
135 } |
|
136 |
|
137 inline CTestController_FindTests_UnitTest::~CTestController_FindTests_UnitTest() |
|
138 { |
|
139 // Simply delete our test class instance |
|
140 delete iUTContext; |
|
141 delete iStateAccessor; |
|
142 // delete any validators used |
|
143 iFs.Close(); |
|
144 delete iCtorValidator; |
|
145 delete iFindComponentsValidator; |
|
146 delete iStartValidator; |
|
147 delete iDtorValidator; |
|
148 } |
|
149 |
|
150 inline CTestController_FindTests_UnitTest::CTestController_FindTests_UnitTest(CDataLogger& aDataLogger, |
|
151 MUnitTestObserver& aObserver) |
|
152 : CUnitTest(KTestControllerFindTestsUnitTest, aDataLogger, aObserver) |
|
153 { |
|
154 //Do nothing |
|
155 } |
|
156 |
|
157 // Now the Individual transitions need to be added. |
|
158 inline void CTestController_FindTests_UnitTest::ConstructL() |
|
159 { |
|
160 // Perform the base class initialization |
|
161 UnitTestConstructL(); |
|
162 |
|
163 // Create the Unit test state accessor |
|
164 iStateAccessor = new(ELeave) TTestController_StateAccessor; |
|
165 // Construct the Unit test context. |
|
166 |
|
167 // Open the required file server connection |
|
168 User::LeaveIfError(iFs.Connect()); |
|
169 |
|
170 // Construct the Unit test context. |
|
171 iUTContext = new(ELeave) CTestController_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs); |
|
172 iUTContext->iScheduler = new(ELeave) CActiveScheduler; |
|
173 iUTContext->iLogInfo = new(ELeave) TLoggingInfo; |
|
174 iUTContext->iLogInfo->iTitle = &(KLogTitle); |
|
175 iUTContext->iLogInfo->iUseRDebug = ETrue; |
|
176 iUTContext->iLogInfo->iLogOutput = 0; |
|
177 iUTContext->iLogInfo->iReportOutput = 0; |
|
178 iUTContext->iLogInfo->iStyle = EHtml; |
|
179 |
|
180 // Add the Transitions in the order they are to run |
|
181 // C'tor first, D'tor last... |
|
182 iCtorValidator = new(ELeave) TTestController_Ctor_TransitionValidator(*iUTContext); |
|
183 iFindComponentsValidator = new(ELeave) TTestController_FindComponents_TransitionValidator(*iUTContext); |
|
184 iStartValidator = new(ELeave) TTestController_Start_TransitionValidator(*iUTContext); |
|
185 iDtorValidator = new(ELeave) TTestController_Dtor_TransitionValidator(*iUTContext); |
|
186 |
|
187 AddTransitionL(new(ELeave)CTestController_NewL_Transition(*iUTContext,*iCtorValidator)); |
|
188 AddTransitionL(new(ELeave)CTestController_FindComponents_Transition(*iUTContext, *iFindComponentsValidator)); |
|
189 AddTransitionL(new(ELeave)CTestController_Start_Transition(*iUTContext, *iStartValidator)); |
|
190 AddTransitionL(new(ELeave)CTestController_Dtor_Transition(*iUTContext,*iDtorValidator)); |
|
191 } |
|
192 |
|
193 // ______________________________________________________________________________ |
|
194 // |
|
195 _LIT(KTestControllerCreateAndDestroyUnitTest_STUB,"CTestController_CreateAndDestroy_UnitTest_STUB"); |
|
196 |
|
197 CTestController_CreateAndDestroy_UnitTest_STUB* CTestController_CreateAndDestroy_UnitTest_STUB::NewL(CDataLogger& aDataLogger, |
|
198 MUnitTestObserver& aObserver) |
|
199 { |
|
200 CTestController_CreateAndDestroy_UnitTest_STUB* self = |
|
201 new(ELeave) CTestController_CreateAndDestroy_UnitTest_STUB(aDataLogger, |
|
202 aObserver); |
|
203 CleanupStack::PushL(self); |
|
204 self->ConstructL(); |
|
205 CleanupStack::Pop(); |
|
206 return self; |
|
207 } |
|
208 |
|
209 inline TInt CTestController_CreateAndDestroy_UnitTest_STUB::RunError(TInt aError) |
|
210 { |
|
211 // The RunL left so chain to the base first and then cleanup |
|
212 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
213 |
|
214 //Do nothing else since stub |
|
215 |
|
216 return error; |
|
217 } |
|
218 |
|
219 inline CTestController_CreateAndDestroy_UnitTest_STUB::~CTestController_CreateAndDestroy_UnitTest_STUB() |
|
220 { |
|
221 //Do nothing |
|
222 } |
|
223 |
|
224 inline CTestController_CreateAndDestroy_UnitTest_STUB::CTestController_CreateAndDestroy_UnitTest_STUB(CDataLogger& aDataLogger, |
|
225 MUnitTestObserver& aObserver) |
|
226 : CUnitTest(KTestControllerCreateAndDestroyUnitTest_STUB, aDataLogger, aObserver) |
|
227 { |
|
228 //Do nothing |
|
229 } |
|
230 |
|
231 // Now the Individual transitions need to be added. |
|
232 inline void CTestController_CreateAndDestroy_UnitTest_STUB::ConstructL() |
|
233 { |
|
234 // Perform the base class initialization |
|
235 UnitTestConstructL(); |
|
236 |
|
237 //Do nothing else since stub |
|
238 } |