sl@0
|
1 |
// Copyright (c) 2005-2010 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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <hal.h>
|
sl@0
|
18 |
#include <w32debug.h>
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <graphics/fbsdefs.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "apgrfxfacade.h"
|
sl@0
|
23 |
#include "TGraphicsHarness.h"
|
sl@0
|
24 |
#include "GraphicsTestUtilsServer.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
_LIT(KGraphicsTestFrameworkPanic, "Graphics Test Framework");
|
sl@0
|
27 |
const TInt KTestCleanupStack = 0x40;
|
sl@0
|
28 |
|
sl@0
|
29 |
const TDisplayMode testDisplayModes[] =
|
sl@0
|
30 |
{
|
sl@0
|
31 |
EGray2,
|
sl@0
|
32 |
EGray4,
|
sl@0
|
33 |
EGray16,
|
sl@0
|
34 |
EGray256,
|
sl@0
|
35 |
EColor16,
|
sl@0
|
36 |
EColor256,
|
sl@0
|
37 |
EColor64K,
|
sl@0
|
38 |
EColor16M,
|
sl@0
|
39 |
EColor4K,
|
sl@0
|
40 |
EColor16MU,
|
sl@0
|
41 |
EColor16MA,
|
sl@0
|
42 |
EColor16MAP,
|
sl@0
|
43 |
};
|
sl@0
|
44 |
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
The test code manager, provides functions to set active object
|
sl@0
|
47 |
with lowest priority for running tests in auto mode.
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
class CTestManager : public CActive
|
sl@0
|
50 |
{
|
sl@0
|
51 |
friend class CTGraphicsBase;
|
sl@0
|
52 |
protected:
|
sl@0
|
53 |
static CTestManager* NewL(MTestCases* aAutoTestApp);
|
sl@0
|
54 |
~CTestManager();
|
sl@0
|
55 |
void FinishAllTestCases();
|
sl@0
|
56 |
void StartTest(); //initialize an active object and set it status as active
|
sl@0
|
57 |
void SetSelfDrive(TBool aSelfDrive);
|
sl@0
|
58 |
void CaseComplete();
|
sl@0
|
59 |
private:
|
sl@0
|
60 |
CTestManager(MTestCases* aAutoTestApp);
|
sl@0
|
61 |
void NextTest();
|
sl@0
|
62 |
// from CActive
|
sl@0
|
63 |
void RunL();
|
sl@0
|
64 |
void DoCancel();
|
sl@0
|
65 |
TInt RunError(TInt aError);
|
sl@0
|
66 |
private:
|
sl@0
|
67 |
MTestCases* iTestCase;
|
sl@0
|
68 |
TInt iCurTestCaseNumber; //a current test case, every time when function RunTestCaseL is called this member inc by one
|
sl@0
|
69 |
TBool iTestCompleted;
|
sl@0
|
70 |
TBool iSelfDrive;
|
sl@0
|
71 |
};
|
sl@0
|
72 |
|
sl@0
|
73 |
/** Construct an active object with the lowest priority */
|
sl@0
|
74 |
CTestManager::CTestManager(MTestCases* aTestCases) :
|
sl@0
|
75 |
CActive(EPriorityIdle), iTestCase(aTestCases), iSelfDrive(EFalse)
|
sl@0
|
76 |
{}
|
sl@0
|
77 |
|
sl@0
|
78 |
CTestManager::~CTestManager()
|
sl@0
|
79 |
{
|
sl@0
|
80 |
Cancel();
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
CTestManager* CTestManager::NewL(MTestCases* aTestCases)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
CTestManager *theTestManager=new (ELeave) CTestManager(aTestCases);
|
sl@0
|
86 |
CActiveScheduler::Add(theTestManager);
|
sl@0
|
87 |
return theTestManager;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void CTestManager::RunL()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
__ASSERT_ALWAYS(iTestCase, User::Panic(KGraphicsTestFrameworkPanic, KErrBadHandle));
|
sl@0
|
93 |
if( iTestCompleted)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
return;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
// debug statement to indicate progress of test suite by
|
sl@0
|
99 |
// printing the sub-test that is currently active
|
sl@0
|
100 |
TTime timeStamp;
|
sl@0
|
101 |
timeStamp.HomeTime();
|
sl@0
|
102 |
TBuf<50> dateStr;
|
sl@0
|
103 |
_LIT(KDateString3,"%-B%:0%J%:1%T%:2%S%:3.%Cms");
|
sl@0
|
104 |
timeStamp.FormatL(dateStr, KDateString3);
|
sl@0
|
105 |
++iCurTestCaseNumber;
|
sl@0
|
106 |
RDebug::Print(_L("%S - Test Case Number: %d"), &dateStr, iCurTestCaseNumber);
|
sl@0
|
107 |
|
sl@0
|
108 |
iTestCase->RunTestCaseL(iCurTestCaseNumber);
|
sl@0
|
109 |
if (iTestCompleted)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
_LIT(KFinished,"Finished test case %d and test completed");
|
sl@0
|
112 |
RDebug::Print(KFinished,iCurTestCaseNumber);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
else
|
sl@0
|
115 |
{
|
sl@0
|
116 |
if (iSelfDrive)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
_LIT(KStarted,"Started test case %d");
|
sl@0
|
119 |
RDebug::Print(KStarted,iCurTestCaseNumber);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
else
|
sl@0
|
122 |
{
|
sl@0
|
123 |
NextTest();
|
sl@0
|
124 |
}
|
sl@0
|
125 |
}
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
void CTestManager::DoCancel()
|
sl@0
|
129 |
{
|
sl@0
|
130 |
if (!iSelfDrive)
|
sl@0
|
131 |
iTestCompleted = ETrue;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
TInt CTestManager::RunError(TInt aError)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
TTime timeStamp;
|
sl@0
|
137 |
timeStamp.HomeTime();
|
sl@0
|
138 |
TBuf<50> dateStr;
|
sl@0
|
139 |
_LIT(KDateString3,"%-B%:0%J%:1%T%:2%S%:3 %Cms");
|
sl@0
|
140 |
timeStamp.FormatL(dateStr, KDateString3);
|
sl@0
|
141 |
_LIT(KTestLeft,"RunTestCaseL left of %S - Test Case Number: %d");
|
sl@0
|
142 |
RDebug::Print(KTestLeft, &dateStr, iCurTestCaseNumber);
|
sl@0
|
143 |
|
sl@0
|
144 |
aError = iTestCase->RunTestCaseLeft(aError);
|
sl@0
|
145 |
FinishAllTestCases();
|
sl@0
|
146 |
return aError;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
/**
|
sl@0
|
150 |
Initialize an active object and set it as active
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
void CTestManager::StartTest()
|
sl@0
|
153 |
{
|
sl@0
|
154 |
TRequestStatus *pS= (&iStatus);
|
sl@0
|
155 |
User::RequestComplete(pS, 0);
|
sl@0
|
156 |
SetActive();
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
/**
|
sl@0
|
160 |
Time to move on to the next test step
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
void CTestManager::NextTest()
|
sl@0
|
163 |
{
|
sl@0
|
164 |
_LIT(KFinished,"Finished test case %d");
|
sl@0
|
165 |
RDebug::Print(KFinished,iCurTestCaseNumber);
|
sl@0
|
166 |
StartTest();
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
/**
|
sl@0
|
170 |
Stop active scheduler, and quit a test step
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
void CTestManager::FinishAllTestCases()
|
sl@0
|
173 |
{
|
sl@0
|
174 |
iTestCompleted = ETrue;
|
sl@0
|
175 |
CActiveScheduler::Stop();
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
/**
|
sl@0
|
179 |
Controls wether the manager calls RunTestCaseL whenever the system is otherwise idol
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
void CTestManager::SetSelfDrive(TBool aSelfDrive)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
if (iSelfDrive!=aSelfDrive)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
iSelfDrive = aSelfDrive;
|
sl@0
|
186 |
if (aSelfDrive)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
if (IsActive())
|
sl@0
|
189 |
Cancel();
|
sl@0
|
190 |
}
|
sl@0
|
191 |
else
|
sl@0
|
192 |
{
|
sl@0
|
193 |
if (!IsActive() && !iTestCompleted)
|
sl@0
|
194 |
NextTest();
|
sl@0
|
195 |
}
|
sl@0
|
196 |
}
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
/**
|
sl@0
|
200 |
Tells the manager this case is finished so you can call RunTestCaseL again
|
sl@0
|
201 |
*/
|
sl@0
|
202 |
void CTestManager::CaseComplete()
|
sl@0
|
203 |
{
|
sl@0
|
204 |
__ASSERT_DEBUG(!IsActive(), User::Panic(KGraphicsTestFrameworkPanic, ETestPanicAlreadyActive));
|
sl@0
|
205 |
if (iSelfDrive && !iTestCompleted)
|
sl@0
|
206 |
NextTest();
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
//-------------
|
sl@0
|
211 |
|
sl@0
|
212 |
EXPORT_C const TDesC& CTGraphicsBase::ColorModeName(TDisplayMode aMode)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
_LIT(KNone,"None");
|
sl@0
|
215 |
_LIT(KGray2,"Grey2");
|
sl@0
|
216 |
_LIT(KGray4,"Grey4");
|
sl@0
|
217 |
_LIT(KGray16,"Grey16");
|
sl@0
|
218 |
_LIT(KGray256,"Grey256");
|
sl@0
|
219 |
_LIT(KColor16,"Color16");
|
sl@0
|
220 |
_LIT(KColor256,"Color256");
|
sl@0
|
221 |
_LIT(KColor4K,"Color4K");
|
sl@0
|
222 |
_LIT(KColor64K,"Color64K");
|
sl@0
|
223 |
_LIT(KColor16M,"Color16M");
|
sl@0
|
224 |
_LIT(KColor16MU,"Color16MU");
|
sl@0
|
225 |
_LIT(KColor16MA,"Color16MA");
|
sl@0
|
226 |
_LIT(KColor16MAP,"Color16MAP");
|
sl@0
|
227 |
_LIT(KRgb,"RGB");
|
sl@0
|
228 |
_LIT(KUnknown,"Unknown");
|
sl@0
|
229 |
switch(aMode)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
case ENone:
|
sl@0
|
232 |
return KNone;
|
sl@0
|
233 |
case EGray2:
|
sl@0
|
234 |
return KGray2;
|
sl@0
|
235 |
case EGray4:
|
sl@0
|
236 |
return KGray4;
|
sl@0
|
237 |
case EGray16:
|
sl@0
|
238 |
return KGray16;
|
sl@0
|
239 |
case EGray256:
|
sl@0
|
240 |
return KGray256;
|
sl@0
|
241 |
case EColor16:
|
sl@0
|
242 |
return KColor16;
|
sl@0
|
243 |
case EColor256:
|
sl@0
|
244 |
return KColor256;
|
sl@0
|
245 |
case EColor64K:
|
sl@0
|
246 |
return KColor64K;
|
sl@0
|
247 |
case EColor16M:
|
sl@0
|
248 |
return KColor16M;
|
sl@0
|
249 |
case ERgb:
|
sl@0
|
250 |
return KRgb;
|
sl@0
|
251 |
case EColor4K:
|
sl@0
|
252 |
return KColor4K;
|
sl@0
|
253 |
case EColor16MU:
|
sl@0
|
254 |
return KColor16MU;
|
sl@0
|
255 |
case EColor16MA:
|
sl@0
|
256 |
return KColor16MA;
|
sl@0
|
257 |
case EColor16MAP:
|
sl@0
|
258 |
return KColor16MAP;
|
sl@0
|
259 |
default:
|
sl@0
|
260 |
return KUnknown;
|
sl@0
|
261 |
}
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
EXPORT_C const TDesC& CTGraphicsBase::RotationName(CFbsBitGc::TGraphicsOrientation aOrientation)
|
sl@0
|
265 |
{
|
sl@0
|
266 |
_LIT(K0,"Normal");
|
sl@0
|
267 |
_LIT(K90,"Rotated90");
|
sl@0
|
268 |
_LIT(K180,"Rotated180");
|
sl@0
|
269 |
_LIT(K270,"Rotated270");
|
sl@0
|
270 |
_LIT(KUnknown,"Unknown");
|
sl@0
|
271 |
switch(aOrientation)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
case CFbsBitGc::EGraphicsOrientationNormal:
|
sl@0
|
274 |
return K0;
|
sl@0
|
275 |
case CFbsBitGc::EGraphicsOrientationRotated90:
|
sl@0
|
276 |
return K90;
|
sl@0
|
277 |
case CFbsBitGc::EGraphicsOrientationRotated180:
|
sl@0
|
278 |
return K180;
|
sl@0
|
279 |
case CFbsBitGc::EGraphicsOrientationRotated270:
|
sl@0
|
280 |
return K270;
|
sl@0
|
281 |
default:
|
sl@0
|
282 |
return KUnknown;
|
sl@0
|
283 |
}
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
EXPORT_C void CTGraphicsBase::SaveScreenShotL(CFbsScreenDevice* aScdv)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
#ifdef __WINS__
|
sl@0
|
289 |
_LIT(KBitmapDrive, "c:");
|
sl@0
|
290 |
#else
|
sl@0
|
291 |
_LIT(KBitmapDrive, "e:");
|
sl@0
|
292 |
#endif
|
sl@0
|
293 |
_LIT(KBitmapPath, "\\screenshot.mbm");
|
sl@0
|
294 |
TDisplayMode dispMode = aScdv->DisplayMode();
|
sl@0
|
295 |
TSize scrSize = aScdv->SizeInPixels();
|
sl@0
|
296 |
CFbsBitmap* dstBmp = new(ELeave) CFbsBitmap;
|
sl@0
|
297 |
CleanupStack::PushL(dstBmp);
|
sl@0
|
298 |
User::LeaveIfError(dstBmp->Create(scrSize, dispMode));
|
sl@0
|
299 |
HBufC8* row = HBufC8::NewLC(scrSize.iWidth*4);
|
sl@0
|
300 |
TPtr8 prow = row->Des();
|
sl@0
|
301 |
for (TInt ii = 0; ii < scrSize.iHeight; ++ii)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
aScdv->GetScanLine(prow, TPoint(0, ii), scrSize.iWidth, dispMode);
|
sl@0
|
304 |
dstBmp->SetScanLine(prow,ii);
|
sl@0
|
305 |
}
|
sl@0
|
306 |
CleanupStack::PopAndDestroy(row);
|
sl@0
|
307 |
TFileName mbmFile;
|
sl@0
|
308 |
mbmFile.Append(KBitmapDrive);
|
sl@0
|
309 |
mbmFile.Append(KBitmapPath);
|
sl@0
|
310 |
User::LeaveIfError(dstBmp->Save(mbmFile));
|
sl@0
|
311 |
CleanupStack::PopAndDestroy(dstBmp);
|
sl@0
|
312 |
}
|
sl@0
|
313 |
|
sl@0
|
314 |
EXPORT_C CTGraphicsBase::CTGraphicsBase(CTestStep* aStep) :
|
sl@0
|
315 |
iStep(aStep)
|
sl@0
|
316 |
{}
|
sl@0
|
317 |
|
sl@0
|
318 |
EXPORT_C CTGraphicsBase::~CTGraphicsBase()
|
sl@0
|
319 |
{
|
sl@0
|
320 |
if(iTestManager)
|
sl@0
|
321 |
{
|
sl@0
|
322 |
iTestManager -> Cancel();
|
sl@0
|
323 |
}
|
sl@0
|
324 |
delete iTestManager;
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
void CTGraphicsBase::InitializeL()
|
sl@0
|
328 |
{
|
sl@0
|
329 |
__ASSERT_DEBUG(iStep, User::Panic(KGraphicsTestFrameworkPanic, KErrBadHandle));
|
sl@0
|
330 |
iTestManager = CTestManager::NewL(this);
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
/**
|
sl@0
|
334 |
The function must be called after all test cases completed
|
sl@0
|
335 |
*/
|
sl@0
|
336 |
EXPORT_C void CTGraphicsBase::TestComplete()
|
sl@0
|
337 |
{
|
sl@0
|
338 |
if(iTestManager)
|
sl@0
|
339 |
{
|
sl@0
|
340 |
iTestManager -> FinishAllTestCases();
|
sl@0
|
341 |
}
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
EXPORT_C void CTGraphicsBase::SetSelfDrive(TBool aSelfDrive)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
if (iTestManager)
|
sl@0
|
347 |
iTestManager->SetSelfDrive(aSelfDrive);
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
EXPORT_C void CTGraphicsBase::CaseComplete()
|
sl@0
|
351 |
{
|
sl@0
|
352 |
if (iTestManager)
|
sl@0
|
353 |
iTestManager->CaseComplete();
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
EXPORT_C TInt CTGraphicsBase::RunTestCaseLeft(TInt aError)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
_LIT(KRunTestCaseLLeft,"The RunTestCaseL left with %d");
|
sl@0
|
359 |
ERR_PRINTF2(KRunTestCaseLLeft,aError);
|
sl@0
|
360 |
iStep->SetTestStepResult(EFail);
|
sl@0
|
361 |
return KErrNone;
|
sl@0
|
362 |
}
|
sl@0
|
363 |
|
sl@0
|
364 |
/** Start a test cases loop */
|
sl@0
|
365 |
void CTGraphicsBase::Execute()
|
sl@0
|
366 |
{
|
sl@0
|
367 |
__ASSERT_DEBUG(iTestManager, User::Panic(KGraphicsTestFrameworkPanic, KErrBadHandle));
|
sl@0
|
368 |
__ASSERT_DEBUG(CActiveScheduler::Current(), User::Panic(KGraphicsTestFrameworkPanic, KErrBadHandle));
|
sl@0
|
369 |
|
sl@0
|
370 |
iTestManager -> StartTest();
|
sl@0
|
371 |
CActiveScheduler::Start();
|
sl@0
|
372 |
}
|
sl@0
|
373 |
/**
|
sl@0
|
374 |
Reset test cases counter to a new value. Can be used for running the same consequence of test
|
sl@0
|
375 |
cases with different initial parameters.
|
sl@0
|
376 |
aNewCurrentTestCase cannot be negative.
|
sl@0
|
377 |
*/
|
sl@0
|
378 |
EXPORT_C void CTGraphicsBase::ResetCounter(TInt aNewCurrentTestCase )
|
sl@0
|
379 |
{
|
sl@0
|
380 |
__ASSERT_DEBUG(aNewCurrentTestCase >= 0, User::Panic(KGraphicsTestFrameworkPanic, KErrArgument));
|
sl@0
|
381 |
iTestManager->iCurTestCaseNumber = aNewCurrentTestCase;
|
sl@0
|
382 |
}
|
sl@0
|
383 |
|
sl@0
|
384 |
//---------------------
|
sl@0
|
385 |
/**
|
sl@0
|
386 |
Initialise the cleanup stack.
|
sl@0
|
387 |
*/
|
sl@0
|
388 |
void CTGraphicsStep::SetupCleanup(CTrapCleanup*& tc)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
tc = CTrapCleanup::New();
|
sl@0
|
391 |
if (!tc)
|
sl@0
|
392 |
{
|
sl@0
|
393 |
User::Panic(_L("Out of memory"), KErrNoMemory);
|
sl@0
|
394 |
}
|
sl@0
|
395 |
|
sl@0
|
396 |
TRAPD(r,
|
sl@0
|
397 |
{
|
sl@0
|
398 |
for ( TInt ii = KTestCleanupStack; ii > 0; ii-- )
|
sl@0
|
399 |
CleanupStack::PushL( (TAny*)1 );
|
sl@0
|
400 |
TEST( r == KErrNone );
|
sl@0
|
401 |
CleanupStack::Pop( KTestCleanupStack );
|
sl@0
|
402 |
} );
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
void CTGraphicsStep::LogHeapInfo(RWsSession& aWs, TBool aStart)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
_LIT(KInfoStart,"Start");
|
sl@0
|
408 |
_LIT(KInfoEnd,"End");
|
sl@0
|
409 |
_LIT(KInfoCheckPassed,"WsHeap leak check passed");
|
sl@0
|
410 |
_LIT(KInfoCheckFailed,"Memory leak detected. Number of orphaned cells=%d.");
|
sl@0
|
411 |
_LIT(KInfoCheckFailed2,"See epocwindout for the address of the first orphaned cell.");
|
sl@0
|
412 |
_LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d");
|
sl@0
|
413 |
_LIT(KInfoDisabled,"Memory leak testing has not been enabled.");
|
sl@0
|
414 |
|
sl@0
|
415 |
TPckgBuf<TWsDebugHeapInfo> heapInfo;
|
sl@0
|
416 |
aWs.DebugInfo(EWsDebugInfoHeap,heapInfo);
|
sl@0
|
417 |
TBuf<256> infoBuf;
|
sl@0
|
418 |
if (aStart)
|
sl@0
|
419 |
{
|
sl@0
|
420 |
infoBuf.Append(KInfoStart);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
else
|
sl@0
|
423 |
{
|
sl@0
|
424 |
infoBuf.Append(KInfoEnd);
|
sl@0
|
425 |
TInt heapFailCount=aWs.DebugInfo(EWsDebugFetchCheckHeapResult);
|
sl@0
|
426 |
if (heapFailCount==KErrNone)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
INFO_PRINTF1(KInfoCheckPassed);
|
sl@0
|
429 |
}
|
sl@0
|
430 |
else if (heapFailCount>0) // Negative error should be ignored as it means the check has not been enabled
|
sl@0
|
431 |
{
|
sl@0
|
432 |
TEST(0);
|
sl@0
|
433 |
ERR_PRINTF2(KInfoCheckFailed,heapFailCount);
|
sl@0
|
434 |
ERR_PRINTF1(KInfoCheckFailed2);
|
sl@0
|
435 |
}
|
sl@0
|
436 |
else
|
sl@0
|
437 |
{
|
sl@0
|
438 |
WARN_PRINTF1(KInfoDisabled);
|
sl@0
|
439 |
}
|
sl@0
|
440 |
}
|
sl@0
|
441 |
infoBuf.AppendFormat(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable);
|
sl@0
|
442 |
INFO_PRINTF1(infoBuf);
|
sl@0
|
443 |
}
|
sl@0
|
444 |
|
sl@0
|
445 |
/**
|
sl@0
|
446 |
Main entry point from CTestStep class.
|
sl@0
|
447 |
Creates cleanup stack, background window and launches a test
|
sl@0
|
448 |
*/
|
sl@0
|
449 |
EXPORT_C TVerdict CTGraphicsStep::doTestStepL()
|
sl@0
|
450 |
{
|
sl@0
|
451 |
TInt memFree;
|
sl@0
|
452 |
HAL::Get(HALData::EMemoryRAMFree, memFree);
|
sl@0
|
453 |
INFO_PRINTF2(_L("Test started - RAM free: %d"), memFree);
|
sl@0
|
454 |
|
sl@0
|
455 |
__UHEAP_MARK;
|
sl@0
|
456 |
CTrapCleanup* tc = NULL;
|
sl@0
|
457 |
SetupCleanup(tc);
|
sl@0
|
458 |
|
sl@0
|
459 |
TInt err = RFbsSession::Connect();
|
sl@0
|
460 |
if(err != KErrNone)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
FbsStartup();
|
sl@0
|
463 |
err = RFbsSession::Connect();
|
sl@0
|
464 |
|
sl@0
|
465 |
if(err != KErrNone)
|
sl@0
|
466 |
{
|
sl@0
|
467 |
User::Panic(_L("Font bitmap session connect"), err);
|
sl@0
|
468 |
}
|
sl@0
|
469 |
}
|
sl@0
|
470 |
RWsSession ws;
|
sl@0
|
471 |
err = ws.Connect();
|
sl@0
|
472 |
if (iLogHeapInfo && err==KErrNone)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
ws.DebugInfo(EWsDebugSetCheckHeapOnDisconnectClient);
|
sl@0
|
475 |
LogHeapInfo(ws,ETrue);
|
sl@0
|
476 |
}
|
sl@0
|
477 |
TInt theId1 = NULL;
|
sl@0
|
478 |
#ifdef __WINS__
|
sl@0
|
479 |
RWindowGroup winGroup = RWindowGroup(ws);
|
sl@0
|
480 |
RWindow theWindow(ws);
|
sl@0
|
481 |
if (err==KErrNone)
|
sl@0
|
482 |
{
|
sl@0
|
483 |
const TUint32 ENullWsHandle = 0xFFFFFFFF; // Events delivered to this handle are thrown away
|
sl@0
|
484 |
//creat background window with the size of the screen
|
sl@0
|
485 |
//it is particulary important for tests which draw on the screen, read screen buffer
|
sl@0
|
486 |
//and compare result. By default top TEF window is concole and blinking cursor can interfere
|
sl@0
|
487 |
//with the work of the tests
|
sl@0
|
488 |
TSize size(640, 240); //some default value
|
sl@0
|
489 |
//retrieve screen size
|
sl@0
|
490 |
err = GetScreenSize(size);
|
sl@0
|
491 |
if(err)
|
sl@0
|
492 |
{
|
sl@0
|
493 |
WARN_PRINTF2(_L("Can't retrieve size from screen driver err = %d"), err);
|
sl@0
|
494 |
}
|
sl@0
|
495 |
|
sl@0
|
496 |
winGroup.Construct(ENullWsHandle);
|
sl@0
|
497 |
winGroup.AutoForeground(ETrue);
|
sl@0
|
498 |
theId1 = winGroup.Identifier();
|
sl@0
|
499 |
|
sl@0
|
500 |
theWindow.Construct(winGroup, ENullWsHandle);
|
sl@0
|
501 |
theWindow.SetExtent(TPoint(0, 0), size);
|
sl@0
|
502 |
theWindow.SetVisible(ETrue);
|
sl@0
|
503 |
theWindow.Activate();
|
sl@0
|
504 |
|
sl@0
|
505 |
//the following trick we need to put the window on the top
|
sl@0
|
506 |
TApaTaskListFacade taskList(ws);
|
sl@0
|
507 |
TApaTaskFacade task = taskList.FindByPos(1);
|
sl@0
|
508 |
task.BringToForeground();
|
sl@0
|
509 |
TApaTaskFacade task1(ws);
|
sl@0
|
510 |
task1.SetWgId(theId1);
|
sl@0
|
511 |
task1.BringToForeground();
|
sl@0
|
512 |
}
|
sl@0
|
513 |
#endif
|
sl@0
|
514 |
if (err==KErrNone)
|
sl@0
|
515 |
{
|
sl@0
|
516 |
CloseAllPanicWindows(theId1, ws);
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
// initialize the test and kick off the test cases loop
|
sl@0
|
520 |
TRAP(err, TestSetupL(); // initialize a test step
|
sl@0
|
521 |
ExecuteL()); // run active scheduler, in order to complete test execution
|
sl@0
|
522 |
// CTGraphicsStep::TestComplete function needs to be called
|
sl@0
|
523 |
|
sl@0
|
524 |
if (err)
|
sl@0
|
525 |
{
|
sl@0
|
526 |
SetTestStepResult(EFail);
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
TestClose(); // free all allocated resources here
|
sl@0
|
530 |
|
sl@0
|
531 |
if (ws.Handle())
|
sl@0
|
532 |
{
|
sl@0
|
533 |
CloseAllPanicWindows(theId1, ws);
|
sl@0
|
534 |
#ifdef __WINS__
|
sl@0
|
535 |
theWindow.Close();
|
sl@0
|
536 |
winGroup.Close();
|
sl@0
|
537 |
#endif
|
sl@0
|
538 |
ws.Close();
|
sl@0
|
539 |
User::After(50000);
|
sl@0
|
540 |
// Prev close will trigger Wserv dummy shutdown and heap check
|
sl@0
|
541 |
// We then re-connect to get the result of the shutdown.
|
sl@0
|
542 |
RWsSession ws2;
|
sl@0
|
543 |
TInt errConnection;
|
sl@0
|
544 |
TInt MaxNumberOfAttempt=10;
|
sl@0
|
545 |
TInt currentAttempt=0;
|
sl@0
|
546 |
do
|
sl@0
|
547 |
{
|
sl@0
|
548 |
errConnection=ws2.Connect();
|
sl@0
|
549 |
if (errConnection==KErrNone)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
LogHeapInfo(ws2,EFalse);
|
sl@0
|
552 |
ws2.Close();
|
sl@0
|
553 |
}
|
sl@0
|
554 |
else
|
sl@0
|
555 |
{
|
sl@0
|
556 |
RDebug::Printf("Connection Error with Wserv... %i",errConnection);
|
sl@0
|
557 |
User::After(50000);
|
sl@0
|
558 |
}
|
sl@0
|
559 |
currentAttempt++;
|
sl@0
|
560 |
}while( (errConnection!=KErrNone) && (currentAttempt<MaxNumberOfAttempt) );
|
sl@0
|
561 |
}
|
sl@0
|
562 |
RFbsSession::Disconnect();
|
sl@0
|
563 |
|
sl@0
|
564 |
delete tc;
|
sl@0
|
565 |
|
sl@0
|
566 |
__UHEAP_MARKEND;
|
sl@0
|
567 |
|
sl@0
|
568 |
return TestStepResult();
|
sl@0
|
569 |
}
|
sl@0
|
570 |
|
sl@0
|
571 |
void CTGraphicsStep::CloseAllPanicWindows(TInt aId, RWsSession& ws) const
|
sl@0
|
572 |
{
|
sl@0
|
573 |
TInt idFocus = ws.GetFocusWindowGroup();
|
sl@0
|
574 |
TWsEvent event;
|
sl@0
|
575 |
event.SetType(EEventKey); //EEventKeyDown
|
sl@0
|
576 |
TKeyEvent *keyEvent = event.Key();
|
sl@0
|
577 |
keyEvent->iCode = EKeyEscape;
|
sl@0
|
578 |
keyEvent->iScanCode = EStdKeyEscape;
|
sl@0
|
579 |
keyEvent->iModifiers = 0;
|
sl@0
|
580 |
TInt theLimit = 50;
|
sl@0
|
581 |
while(idFocus != aId && (theLimit-- > 0))
|
sl@0
|
582 |
{
|
sl@0
|
583 |
ws.SendEventToAllWindowGroups(event);
|
sl@0
|
584 |
idFocus = ws.GetFocusWindowGroup();
|
sl@0
|
585 |
}
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
TInt CTGraphicsStep::GetScreenSize(TSize& aSize) const
|
sl@0
|
589 |
{
|
sl@0
|
590 |
CFbsScreenDevice* dev = NULL;
|
sl@0
|
591 |
|
sl@0
|
592 |
TInt err = KErrNone;
|
sl@0
|
593 |
TInt sizeOfDisplayMode = sizeof (testDisplayModes) / sizeof(testDisplayModes[0]);
|
sl@0
|
594 |
|
sl@0
|
595 |
for(TInt theScreenModeIndex = sizeOfDisplayMode - 1; theScreenModeIndex ; theScreenModeIndex--)
|
sl@0
|
596 |
{
|
sl@0
|
597 |
TDisplayMode disp = testDisplayModes[theScreenModeIndex];
|
sl@0
|
598 |
TRAP(err, dev = CFbsScreenDevice::NewL(_L(""), disp)); //scdv
|
sl@0
|
599 |
if(err == KErrNone)
|
sl@0
|
600 |
{
|
sl@0
|
601 |
aSize = dev->SizeInPixels();
|
sl@0
|
602 |
delete dev;
|
sl@0
|
603 |
return KErrNone;
|
sl@0
|
604 |
}
|
sl@0
|
605 |
delete dev;
|
sl@0
|
606 |
dev = NULL;
|
sl@0
|
607 |
}
|
sl@0
|
608 |
|
sl@0
|
609 |
return err;
|
sl@0
|
610 |
}
|
sl@0
|
611 |
|
sl@0
|
612 |
/** Installs an active scheduler and launches a test*/
|
sl@0
|
613 |
void CTGraphicsStep::ExecuteL()
|
sl@0
|
614 |
{
|
sl@0
|
615 |
CActiveScheduler* theAs = new (ELeave) CActiveScheduler;
|
sl@0
|
616 |
CleanupStack::PushL(theAs);
|
sl@0
|
617 |
CActiveScheduler::Install(theAs);
|
sl@0
|
618 |
|
sl@0
|
619 |
CTGraphicsBase* autoTest = CreateTestL();
|
sl@0
|
620 |
User::LeaveIfNull(autoTest);
|
sl@0
|
621 |
CleanupStack::PushL(autoTest);
|
sl@0
|
622 |
|
sl@0
|
623 |
autoTest -> InitializeL();
|
sl@0
|
624 |
autoTest -> ConstructL();
|
sl@0
|
625 |
autoTest -> Execute();
|
sl@0
|
626 |
|
sl@0
|
627 |
CleanupStack::PopAndDestroy(2, theAs);
|
sl@0
|
628 |
}
|
sl@0
|
629 |
|
sl@0
|
630 |
TInt E32Dll( )
|
sl@0
|
631 |
{
|
sl@0
|
632 |
return 0;
|
sl@0
|
633 |
}
|
sl@0
|
634 |
|