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 CTestManager class.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "TestManagerUnitTest.h"
|
sl@0
|
19 |
#include "TestController.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
extern CComponentTester* NewComponentTestLC_STUB(
|
sl@0
|
22 |
CDataLogger& aDataLogger,
|
sl@0
|
23 |
MComponentTestObserver& aComponentTestObserver);
|
sl@0
|
24 |
|
sl@0
|
25 |
// ______________________________________________________________________________
|
sl@0
|
26 |
//
|
sl@0
|
27 |
_LIT(KTestManagerCreateAndDestroyUnitTest,"CTestManager_CreateAndDestroy_UnitTest");
|
sl@0
|
28 |
|
sl@0
|
29 |
CTestManager_CreateAndDestroy_UnitTest* CTestManager_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
|
sl@0
|
30 |
MUnitTestObserver& aObserver)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
CTestManager_CreateAndDestroy_UnitTest* self =
|
sl@0
|
33 |
new(ELeave) CTestManager_CreateAndDestroy_UnitTest(aDataLogger,
|
sl@0
|
34 |
aObserver);
|
sl@0
|
35 |
CleanupStack::PushL(self);
|
sl@0
|
36 |
self->ConstructL();
|
sl@0
|
37 |
CleanupStack::Pop();
|
sl@0
|
38 |
return self;
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
inline TInt CTestManager_CreateAndDestroy_UnitTest::RunError(TInt aError)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
// The RunL left so chain to the base first and then cleanup
|
sl@0
|
44 |
TInt error = CUnitTest::RunError(aError); // Chain to base
|
sl@0
|
45 |
delete iUTContext;
|
sl@0
|
46 |
iUTContext = NULL;
|
sl@0
|
47 |
delete iStateAccessor;
|
sl@0
|
48 |
iStateAccessor = NULL;
|
sl@0
|
49 |
/* delete any validators used */
|
sl@0
|
50 |
delete iCtorValidator;
|
sl@0
|
51 |
iCtorValidator = NULL;
|
sl@0
|
52 |
delete iDtorValidator;
|
sl@0
|
53 |
iDtorValidator = NULL;
|
sl@0
|
54 |
|
sl@0
|
55 |
return error;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
inline CTestManager_CreateAndDestroy_UnitTest::~CTestManager_CreateAndDestroy_UnitTest()
|
sl@0
|
59 |
{
|
sl@0
|
60 |
// Simply delete our test class instance
|
sl@0
|
61 |
delete iUTContext;
|
sl@0
|
62 |
delete iStateAccessor;
|
sl@0
|
63 |
/* delete any validators used */
|
sl@0
|
64 |
delete iCtorValidator;
|
sl@0
|
65 |
delete iDtorValidator;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
inline CTestManager_CreateAndDestroy_UnitTest::CTestManager_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
|
sl@0
|
69 |
MUnitTestObserver& aObserver)
|
sl@0
|
70 |
: CUnitTest(KTestManagerCreateAndDestroyUnitTest, aDataLogger, aObserver)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
//Do nothing
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
// Now the Individual transitions need to be added.
|
sl@0
|
76 |
inline void CTestManager_CreateAndDestroy_UnitTest::ConstructL()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
// Perform the base class initialization
|
sl@0
|
79 |
UnitTestConstructL();
|
sl@0
|
80 |
|
sl@0
|
81 |
// Create the Unit test state accessor
|
sl@0
|
82 |
iStateAccessor = new(ELeave) TTestManager_StateAccessor;
|
sl@0
|
83 |
// Construct the Unit test context.
|
sl@0
|
84 |
iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
|
sl@0
|
85 |
iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
|
sl@0
|
86 |
// Construct, and store the observer stub
|
sl@0
|
87 |
iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
|
sl@0
|
88 |
|
sl@0
|
89 |
// Add the Transitions in the order they are to run
|
sl@0
|
90 |
// C'tor first, D'tor last...
|
sl@0
|
91 |
iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
|
sl@0
|
92 |
iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
|
sl@0
|
93 |
|
sl@0
|
94 |
AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
|
sl@0
|
95 |
AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
// ______________________________________________________________________________
|
sl@0
|
99 |
//
|
sl@0
|
100 |
_LIT(KTestManagerManageTestsUnitTest,"CTestManager_ManageTests_UnitTest");
|
sl@0
|
101 |
|
sl@0
|
102 |
CTestManager_ManageTests_UnitTest* CTestManager_ManageTests_UnitTest::NewL(CDataLogger& aDataLogger,
|
sl@0
|
103 |
MUnitTestObserver& aObserver)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
CTestManager_ManageTests_UnitTest* self =
|
sl@0
|
106 |
new(ELeave) CTestManager_ManageTests_UnitTest(aDataLogger,
|
sl@0
|
107 |
aObserver);
|
sl@0
|
108 |
CleanupStack::PushL(self);
|
sl@0
|
109 |
self->ConstructL();
|
sl@0
|
110 |
CleanupStack::Pop();
|
sl@0
|
111 |
return self;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
inline TInt CTestManager_ManageTests_UnitTest::RunError(TInt aError)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
// The RunL left so chain to the base first and then cleanup
|
sl@0
|
117 |
TInt error = CUnitTest::RunError(aError); // Chain to base
|
sl@0
|
118 |
delete iUTContext;
|
sl@0
|
119 |
iUTContext = NULL;
|
sl@0
|
120 |
delete iStateAccessor;
|
sl@0
|
121 |
iStateAccessor = NULL;
|
sl@0
|
122 |
/* delete any validators used */
|
sl@0
|
123 |
delete iCtorValidator;
|
sl@0
|
124 |
iCtorValidator = NULL;
|
sl@0
|
125 |
delete iRunTestsValidator;
|
sl@0
|
126 |
iRunTestsValidator = NULL;
|
sl@0
|
127 |
delete iTestComponentValidator;
|
sl@0
|
128 |
iTestComponentValidator =NULL;
|
sl@0
|
129 |
delete iDtorValidator;
|
sl@0
|
130 |
iDtorValidator = NULL;
|
sl@0
|
131 |
|
sl@0
|
132 |
return error;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
inline CTestManager_ManageTests_UnitTest::~CTestManager_ManageTests_UnitTest()
|
sl@0
|
136 |
{
|
sl@0
|
137 |
// Simply delete our test class instance
|
sl@0
|
138 |
delete iUTContext;
|
sl@0
|
139 |
delete iStateAccessor;
|
sl@0
|
140 |
/* delete any validators used */
|
sl@0
|
141 |
delete iCtorValidator;
|
sl@0
|
142 |
delete iRunTestsValidator;
|
sl@0
|
143 |
delete iTestComponentValidator;
|
sl@0
|
144 |
delete iDtorValidator;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
inline CTestManager_ManageTests_UnitTest::CTestManager_ManageTests_UnitTest(CDataLogger& aDataLogger,
|
sl@0
|
148 |
MUnitTestObserver& aObserver)
|
sl@0
|
149 |
: CUnitTest(KTestManagerManageTestsUnitTest, aDataLogger, aObserver)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
//Do nothing
|
sl@0
|
152 |
}
|
sl@0
|
153 |
|
sl@0
|
154 |
// Now the Individual transitions need to be added.
|
sl@0
|
155 |
inline void CTestManager_ManageTests_UnitTest::ConstructL()
|
sl@0
|
156 |
{
|
sl@0
|
157 |
// Perform the base class initialization
|
sl@0
|
158 |
UnitTestConstructL();
|
sl@0
|
159 |
|
sl@0
|
160 |
// Create the Unit test state accessor
|
sl@0
|
161 |
iStateAccessor = new(ELeave) TTestManager_StateAccessor;
|
sl@0
|
162 |
// Construct the Unit test context.
|
sl@0
|
163 |
iUTContext = new(ELeave) CTestManager_UnitTestContext(iDataLogger, *iStateAccessor, *this);
|
sl@0
|
164 |
iUTContext->iTestListArray = new(ELeave) RPointerArray<CComponentInfo>;
|
sl@0
|
165 |
// Construct, and store the observer stub
|
sl@0
|
166 |
iUTContext->iTestManagerObserverStub = CTestManagerObserverStub::NewL();
|
sl@0
|
167 |
|
sl@0
|
168 |
CComponentInfo* compInfo = CComponentInfo::NewL(NewComponentTestLC_STUB, NULL);
|
sl@0
|
169 |
CleanupStack::PushL(compInfo);
|
sl@0
|
170 |
|
sl@0
|
171 |
User::LeaveIfError(iUTContext->iTestListArray->Append(compInfo));
|
sl@0
|
172 |
CleanupStack::Pop(compInfo);
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
// Add the Transitions in the order they are to run
|
sl@0
|
176 |
// C'tor first, D'tor last...
|
sl@0
|
177 |
iCtorValidator = new(ELeave) TTestManager_Ctor_TransitionValidator(*iUTContext);
|
sl@0
|
178 |
iRunTestsValidator = new(ELeave) TTestManager_RunTests_TransitionValidator(*iUTContext);
|
sl@0
|
179 |
iTestComponentValidator = new(ELeave) TTestManager_TestComponent_TransitionValidator(*iUTContext);
|
sl@0
|
180 |
iDtorValidator = new(ELeave) TTestManager_Dtor_TransitionValidator(*iUTContext);
|
sl@0
|
181 |
|
sl@0
|
182 |
AddTransitionL(new(ELeave)CTestManager_NewL_Transition(*iUTContext,*iCtorValidator));
|
sl@0
|
183 |
// AddTransitionL(new(ELeave)CTestManager_RunTests_Transition(*iUTContext,*iRunTestsValidator));
|
sl@0
|
184 |
AddTransitionL(new(ELeave)CTestManager_TestComponentL_Transition(*iUTContext,*iTestComponentValidator));
|
sl@0
|
185 |
AddTransitionL(new(ELeave)CTestManager_Dtor_Transition(*iUTContext,*iDtorValidator));
|
sl@0
|
186 |
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
// ______________________________________________________________________________
|
sl@0
|
190 |
//
|
sl@0
|
191 |
_LIT(KTestManagerCreateAndDestroyUnitTest_STUB,"CTestManager_CreateAndDestroy_UnitTest_STUB");
|
sl@0
|
192 |
|
sl@0
|
193 |
CTestManager_CreateAndDestroy_UnitTest_STUB* CTestManager_CreateAndDestroy_UnitTest_STUB::NewL(CDataLogger& aDataLogger,
|
sl@0
|
194 |
MUnitTestObserver& aObserver)
|
sl@0
|
195 |
{
|
sl@0
|
196 |
CTestManager_CreateAndDestroy_UnitTest_STUB* self =
|
sl@0
|
197 |
new(ELeave) CTestManager_CreateAndDestroy_UnitTest_STUB(aDataLogger,
|
sl@0
|
198 |
aObserver);
|
sl@0
|
199 |
CleanupStack::PushL(self);
|
sl@0
|
200 |
self->ConstructL();
|
sl@0
|
201 |
CleanupStack::Pop();
|
sl@0
|
202 |
return self;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
inline TInt CTestManager_CreateAndDestroy_UnitTest_STUB::RunError(TInt aError)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
// The RunL left so chain to the base first and then cleanup
|
sl@0
|
208 |
TInt error = CUnitTest::RunError(aError); // Chain to base
|
sl@0
|
209 |
|
sl@0
|
210 |
//Do nothing else since stub
|
sl@0
|
211 |
|
sl@0
|
212 |
return error;
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
inline CTestManager_CreateAndDestroy_UnitTest_STUB::~CTestManager_CreateAndDestroy_UnitTest_STUB()
|
sl@0
|
216 |
{
|
sl@0
|
217 |
//Do nothing
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
inline CTestManager_CreateAndDestroy_UnitTest_STUB::CTestManager_CreateAndDestroy_UnitTest_STUB(CDataLogger& aDataLogger,
|
sl@0
|
221 |
MUnitTestObserver& aObserver)
|
sl@0
|
222 |
: CUnitTest(KTestManagerCreateAndDestroyUnitTest_STUB, aDataLogger, aObserver)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
//Do nothing
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
// Now the Individual transitions need to be added.
|
sl@0
|
228 |
inline void CTestManager_CreateAndDestroy_UnitTest_STUB::ConstructL()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
// Perform the base class initialization
|
sl@0
|
231 |
UnitTestConstructL();
|
sl@0
|
232 |
|
sl@0
|
233 |
//Do nothing else since stub
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
|
sl@0
|
237 |
|