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