|
1 // Copyright (c) 1995-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 // Automatically test the window server |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <w32std.h> |
|
21 #include <e32svr.h> |
|
22 #include <hal.h> |
|
23 #include "../tlib/testbase.h" |
|
24 #include <stdlib.h> |
|
25 #include "AUTO.H" |
|
26 |
|
27 LOCAL_D const TUint KPanicThreadHeapSize=0x8000; |
|
28 |
|
29 GLREF_C TInt ProcPriTestOtherProcess(TAny *aScreenNumber); |
|
30 GLREF_C TInt ProcToKill(TAny *aScreenNumber); |
|
31 GLREF_C TInt ProcDirect(TAny *aScreenNumber); |
|
32 GLREF_C TInt ProcMultiDisplay(TAny *aScreenNumber); |
|
33 |
|
34 _LIT(Priority,"ProcPriTest"); |
|
35 _LIT(ToKill,"ProcToKill"); |
|
36 _LIT(Direct,"ProcDirect"); |
|
37 _LIT(MultiDisplay,"ProcMultiDisplay"); |
|
38 |
|
39 CProcess::TInitialFunction CProcess::iFunctions[]= |
|
40 { |
|
41 TInitialFunction(Priority,ProcPriTestOtherProcess), |
|
42 TInitialFunction(ToKill,ProcToKill), |
|
43 TInitialFunction(Direct,ProcDirect), |
|
44 TInitialFunction(MultiDisplay,ProcMultiDisplay) |
|
45 }; |
|
46 |
|
47 GLDEF_D TestWindow *BaseWin; |
|
48 GLDEF_D TestWindow *TestWin; |
|
49 GLDEF_D TestClient *TheClient=NULL; |
|
50 GLDEF_D CWindowGc *TheGc; |
|
51 TInt CTestBase::iMaxGrays=0; |
|
52 TInt CTestBase::iScreenNo=0; |
|
53 TInt CTestBase::iMaxColors=0; |
|
54 TInt CTestBase::iNumberTestsPass=0; |
|
55 TInt CTestBase::iNumberTests=0; |
|
56 TRect CTestBase::iNormalPointerCursorArea; |
|
57 TPartialRedrawType CTestBase::iRedrawType=EPartialRedraw_Unknown; |
|
58 TInt CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = 0; |
|
59 TInt CTestDriver::iTestNum=0; |
|
60 |
|
61 GLDEF_D TInt TheTestResult=ETestPassed; // start with passed to anticipate empty test table |
|
62 |
|
63 const TInt KBorderWinWidth = 5; |
|
64 |
|
65 _LIT(Auto,"AUTO "); |
|
66 |
|
67 TInt64 TTestRects::iSeed=0; |
|
68 TRect TTestRects::iList[]={ |
|
69 // 0-5 |
|
70 TRect(2,2,2,2), |
|
71 TRect(2,2,2,2), |
|
72 TRect(2,2,2,2), |
|
73 TRect(2,2,2,2), |
|
74 TRect(2,2,2,2), |
|
75 // 5-13 |
|
76 TRect(0,0,0,0), |
|
77 TRect(2,0,2,0), |
|
78 TRect(4,0,4,0), |
|
79 TRect(0,2,0,2), |
|
80 TRect(2,2,2,2), |
|
81 TRect(4,2,4,2), |
|
82 TRect(0,4,0,4), |
|
83 TRect(2,4,2,4), |
|
84 TRect(4,4,4,4), |
|
85 // 13-22 |
|
86 TRect(0,0,1,1), |
|
87 TRect(1,0,3,1), |
|
88 TRect(3,0,4,1), |
|
89 TRect(0,1,1,3), |
|
90 TRect(1,1,3,3), |
|
91 TRect(3,1,4,3), |
|
92 TRect(0,3,1,4), |
|
93 TRect(1,3,3,4), |
|
94 TRect(3,3,4,4), |
|
95 // 23-31 |
|
96 TRect(0,0,2,0), |
|
97 TRect(2,0,4,0), |
|
98 TRect(0,0,4,0), |
|
99 TRect(0,2,2,2), |
|
100 TRect(2,2,4,2), |
|
101 TRect(0,2,4,2), |
|
102 TRect(0,4,2,4), |
|
103 TRect(2,4,4,4), |
|
104 TRect(0,4,4,4), |
|
105 // 32-40 |
|
106 TRect(0,0,0,2), |
|
107 TRect(0,2,0,4), |
|
108 TRect(0,0,0,4), |
|
109 TRect(2,0,2,2), |
|
110 TRect(2,2,2,4), |
|
111 TRect(2,0,2,4), |
|
112 TRect(4,0,4,2), |
|
113 TRect(4,2,4,4), |
|
114 TRect(4,0,4,4), |
|
115 // 41-44 |
|
116 TRect(0,0,2,2), |
|
117 TRect(2,0,4,2), |
|
118 TRect(0,2,2,4), |
|
119 TRect(2,2,4,4), |
|
120 // 45-48 |
|
121 TRect(0,0,3,3), |
|
122 TRect(1,0,4,3), |
|
123 TRect(0,1,3,4), |
|
124 TRect(1,1,4,4), |
|
125 // 49 |
|
126 TRect(0,0,4,4), |
|
127 // 40-53 |
|
128 TRect(1,2,2,2), |
|
129 TRect(2,2,3,2), |
|
130 TRect(2,1,2,2), |
|
131 TRect(2,2,3,2), |
|
132 // 54-59 |
|
133 TRect(1,2,3,2), |
|
134 TRect(2,1,2,3), |
|
135 TRect(1,1,2,2), |
|
136 TRect(1,2,2,3), |
|
137 TRect(2,2,3,3), |
|
138 TRect(2,1,3,2), |
|
139 // 60-63 |
|
140 TRect(1,1,3,2), |
|
141 TRect(1,1,2,3), |
|
142 TRect(1,2,3,3), |
|
143 TRect(2,1,3,3)}; |
|
144 |
|
145 #if defined(__WINS__) |
|
146 void FindNonMatchingPixelL(TPoint aPt1,TPoint aPt2,TSize aSize) |
|
147 // This function is purely for use when debugging to find the first non-matching pixel |
|
148 // when a check of two on screen rects has failed. |
|
149 { |
|
150 HBufC8* buf1=HBufC8::NewMaxLC(2*aSize.iWidth); |
|
151 HBufC8* buf2=HBufC8::NewMaxLC(2*aSize.iWidth); |
|
152 TPtr8 ptr1=buf1->Des(); |
|
153 TPtr8 ptr2=buf2->Des(); |
|
154 TInt row=0; |
|
155 TBool ret = true; |
|
156 for (;row<aSize.iHeight;++row) |
|
157 { |
|
158 TheClient->iScreen->GetScanLine(ptr1,aPt1,aSize.iWidth,EColor64K); |
|
159 TheClient->iScreen->GetScanLine(ptr2,aPt2,aSize.iWidth,EColor64K); |
|
160 if (ptr1!=ptr2) |
|
161 break; |
|
162 ++aPt1.iY; |
|
163 ++aPt2.iY; |
|
164 } |
|
165 TRgb color1,color2; |
|
166 if (row<aSize.iHeight) |
|
167 { |
|
168 for (TInt col=0;col<aSize.iWidth;++col) |
|
169 { |
|
170 TheClient->iScreen->GetPixel(color1,aPt1); |
|
171 TheClient->iScreen->GetPixel(color2,aPt2); |
|
172 if (color1!=color2) |
|
173 { // Break here to find first pixel that didn't match. |
|
174 TBuf<256> buf; |
|
175 _LIT(KFindNonMatchingPixelFmt,"First non matching pixel (%d,%d)"); |
|
176 buf.Format(KFindNonMatchingPixelFmt,col,row); |
|
177 TheClient->iWs.LogMessage(buf); |
|
178 break; |
|
179 |
|
180 } |
|
181 ++aPt1.iX; |
|
182 ++aPt2.iX; |
|
183 } |
|
184 } |
|
185 CleanupStack::PopAndDestroy(2); |
|
186 } |
|
187 |
|
188 void FindNonMatchingPixel(TPoint aPt1,TPoint aPt2,TSize aSize) |
|
189 { |
|
190 TRAPD(ignore,FindNonMatchingPixelL(aPt1,aPt2,aSize)); |
|
191 } |
|
192 #endif |
|
193 |
|
194 void AutoPanic(TInt aPanic) |
|
195 { |
|
196 User::Panic(_L("Auto"),aPanic); |
|
197 } |
|
198 |
|
199 void CleanUpWindow(TAny *aWindow) |
|
200 { |
|
201 ((RWindowTreeNode *)aWindow)->Close(); |
|
202 } |
|
203 |
|
204 void PushWindowL(RWindowTreeNode *aWindow) |
|
205 { |
|
206 CleanupStack::PushL(TCleanupItem(CleanUpWindow,aWindow)); |
|
207 } |
|
208 |
|
209 |
|
210 TBool OpacityAndAlphaSupportedL() |
|
211 { |
|
212 // If opacity is not implemented, EFalse will be returned |
|
213 if(TransparencySupportedL()!=KErrNone) |
|
214 return EFalse; |
|
215 |
|
216 const TRgb KTransparencyColor(0,0,0); |
|
217 RWindow winb(TheClient->iWs); |
|
218 CleanupClosePushL(winb); |
|
219 RWindow wint(TheClient->iWs); |
|
220 CleanupClosePushL(wint); |
|
221 User::LeaveIfError(winb.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); |
|
222 User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); |
|
223 winb.SetExtent(TPoint(0,0), TSize(50,50)); |
|
224 wint.SetExtent(TPoint(0,0), TSize(50,50)); |
|
225 winb.SetRequiredDisplayMode(EColor256); |
|
226 wint.SetRequiredDisplayMode(EColor256); |
|
227 wint.SetTransparencyFactor(KTransparencyColor); |
|
228 winb.SetBackgroundColor(TRgb(0,0,255)); |
|
229 wint.SetBackgroundColor(TRgb(255,0,0)); |
|
230 winb.Activate(); |
|
231 wint.Activate(); |
|
232 |
|
233 wint.BeginRedraw(); |
|
234 TheClient->iGc->Activate(wint); |
|
235 TheClient->iGc->SetOpaque(ETrue); |
|
236 TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
237 TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
238 TheClient->iGc->SetBrushColor(TRgb(0,255,0)); |
|
239 TheClient->iGc->DrawRect(TRect(TPoint(0,0), TSize(50,50))); |
|
240 TheClient->iGc->SetOpaque(EFalse); |
|
241 TheClient->iGc->Deactivate(); |
|
242 wint.EndRedraw(); |
|
243 TheClient->Flush(); |
|
244 |
|
245 // The window should be all green, if opacity is working, or all blue if it isn't. |
|
246 // If the window has any other colour, then something has broken. |
|
247 TRgb color; |
|
248 TheClient->iScreen->GetPixel(color,TPoint(25,25)); |
|
249 if (color.Red()>0 || ((color.Green()==0) == (color.Blue()==0))) |
|
250 User::Leave(KErrGeneral); |
|
251 TBool ret=(color.Green()>0); |
|
252 |
|
253 CleanupStack::PopAndDestroy(2,&winb); // wint |
|
254 return ret; |
|
255 } |
|
256 |
|
257 TInt TransparencySupportedL() |
|
258 { |
|
259 // Creates a window and enables alpha transparency, if this feature |
|
260 // is not enabled, KErrNotSupported will be returned |
|
261 RWindow win(TheClient->iWs); |
|
262 User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); |
|
263 win.SetExtent(TPoint(0,0), TSize(50,50)); |
|
264 TInt ret=win.SetTransparencyAlphaChannel(); |
|
265 win.Close(); |
|
266 return ret; |
|
267 } |
|
268 |
|
269 TInt CheckScalingSupportedOrNot() |
|
270 { |
|
271 TBool scalingSupported=EFalse; |
|
272 TSizeMode originalModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); |
|
273 TSizeMode tempData=originalModeData; |
|
274 tempData.iScreenScale=TSize(2,2); |
|
275 TheClient->iScreen->SetCurrentScreenModeAttributes(tempData); |
|
276 TSize scale=TheClient->iScreen->GetCurrentScreenModeScale(); |
|
277 if (scale.iWidth==2 && scale.iHeight==2) |
|
278 { |
|
279 scalingSupported=ETrue; |
|
280 } |
|
281 TheClient->iScreen->SetCurrentScreenModeAttributes(originalModeData); |
|
282 TheClient->Flush(); |
|
283 return scalingSupported; |
|
284 } |
|
285 |
|
286 TBool CheckNonZeroOriginsSupportedOrNot() |
|
287 { |
|
288 TBool nonZeroOriginsSupported=EFalse; |
|
289 TSizeMode sizeMode1=TheClient->iScreen->GetCurrentScreenModeAttributes(); |
|
290 TSizeMode sizeMode2=sizeMode1; |
|
291 sizeMode2.iOrigin=TPoint(30,30); |
|
292 TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode2); |
|
293 TPoint origin=TheClient->iScreen->GetCurrentScreenModeScaledOrigin(); |
|
294 if (origin.iX==30 && origin.iY==30) |
|
295 { |
|
296 nonZeroOriginsSupported=ETrue; |
|
297 } |
|
298 TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode1); |
|
299 TheClient->Flush(); |
|
300 return nonZeroOriginsSupported; |
|
301 } |
|
302 |
|
303 TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale) |
|
304 { |
|
305 TPoint logicalPt(aPhysicalPtMinusOrigin); |
|
306 if (aScale.iWidth!=1) |
|
307 { |
|
308 logicalPt.iX=(logicalPt.iX>= 0 ? logicalPt.iX/aScale.iWidth : (logicalPt.iX-(aScale.iWidth-1))/aScale.iWidth); |
|
309 } |
|
310 if (aScale.iHeight!=1) |
|
311 { |
|
312 logicalPt.iY=(logicalPt.iY>= 0 ? logicalPt.iY/aScale.iHeight : (logicalPt.iY-(aScale.iHeight-1))/aScale.iHeight); |
|
313 } |
|
314 return logicalPt; |
|
315 } |
|
316 |
|
317 // |
|
318 // Log window, logs testing // |
|
319 // |
|
320 |
|
321 LogWindow::LogWindow() : CTWin(), iTestTitle(KNullDesC), iSubTitle(KNullDesC), iMessage(KNullDesC) |
|
322 {} |
|
323 |
|
324 void LogWindow::ConstructL(CTWinBase &parent) |
|
325 { |
|
326 CTWin::ConstructL(parent); |
|
327 iTitleHeight=iFont->HeightInPixels()+4; |
|
328 } |
|
329 |
|
330 void LogWindow::DrawSubTitle() |
|
331 { |
|
332 iGc->DrawText(iSubTitle, TRect(2,iTitleHeight*2,iSize.iWidth-2,iTitleHeight*3),iFont->AscentInPixels(), CGraphicsContext::ECenter); |
|
333 } |
|
334 |
|
335 void LogWindow::DrawMessage() |
|
336 { |
|
337 iGc->DrawText(iMessage, TRect(1,iTitleHeight*4,iSize.iWidth-2,iTitleHeight*5),iFont->AscentInPixels(), CGraphicsContext::ECenter); |
|
338 } |
|
339 |
|
340 void LogWindow::Draw() |
|
341 { |
|
342 iGc->SetPenColor(TRgb::Gray16(8)); |
|
343 iGc->SetPenColor(TRgb::Gray16(0)); |
|
344 DrawBorder(); |
|
345 iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); |
|
346 iGc->DrawText(iTestTitle, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iTestTitle))/2,iFont->AscentInPixels()+2)); |
|
347 DrawSubTitle(); |
|
348 DrawMessage(); |
|
349 } |
|
350 |
|
351 /** |
|
352 This function is not used at the moment but I leave it in in case I need it when I improve the logging in |
|
353 the log window. |
|
354 */ |
|
355 void LogWindow::LogTest(const TDesC &aTitle,TInt aNum) |
|
356 { |
|
357 _LIT(Test,"Test %d,%S"); |
|
358 iTestTitle.Format(Test,aNum,&aTitle); |
|
359 TLogMessageText buf; |
|
360 _LIT(AutoNewTest,"AUTO New Test: "); |
|
361 buf.Append(AutoNewTest); |
|
362 buf.Append(iTestTitle); |
|
363 TheClient->LogMessage(buf); |
|
364 iMessage.Zero(); |
|
365 iWin.Invalidate(); |
|
366 } |
|
367 |
|
368 /** |
|
369 This function is not used at the moment but I leave it in in case I need it when I improve the logging in |
|
370 the log window. |
|
371 */ |
|
372 const TDesC& LogWindow::LogSubTest(const TDesC &aTitle,TInt aNum) |
|
373 { |
|
374 _LIT(SubTest,"Sub-Test[%d], %S"); |
|
375 iSubTitle.Format(SubTest,aNum,&aTitle); |
|
376 TLogMessageText buf; |
|
377 buf.Append(Auto); |
|
378 buf.Append(iSubTitle); |
|
379 TheClient->LogMessage(buf); |
|
380 iMessage.Zero(); |
|
381 iGc->Activate(iWin); |
|
382 iGc->UseFont((CFont *)iFont); |
|
383 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
384 DrawSubTitle(); |
|
385 DrawMessage(); |
|
386 iGc->Deactivate(); |
|
387 TheClient->iWs.Flush(); |
|
388 return iSubTitle; |
|
389 } |
|
390 |
|
391 const TDesC& LogWindow::LogMessage(TBool aLog,const TDesC& aText,TInt aNum) |
|
392 { |
|
393 if (aNum!=EDummyValue) |
|
394 { |
|
395 _LIT(StringInt,"%S %d"); |
|
396 iMessage.Format(StringInt,&aText,aNum); |
|
397 } |
|
398 else |
|
399 { |
|
400 _LIT(String,"%S"); |
|
401 iMessage.Format(String,&aText); |
|
402 } |
|
403 iGc->Activate(iWin); |
|
404 iGc->UseFont((CFont *)iFont); |
|
405 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
406 DrawMessage(); |
|
407 iGc->Deactivate(); |
|
408 if (aLog) |
|
409 { |
|
410 TLogMessageText buf; |
|
411 buf.Append(Auto); |
|
412 buf.Append(iMessage); |
|
413 TheClient->LogMessage(buf); |
|
414 } |
|
415 TheClient->iWs.Flush(); |
|
416 return iMessage; |
|
417 } |
|
418 |
|
419 |
|
420 // |
|
421 // Test window, simple window used to do test graphics in // |
|
422 // |
|
423 TestWindow::TestWindow() : CTWin() |
|
424 { |
|
425 } |
|
426 |
|
427 TestWindow::~TestWindow() |
|
428 { |
|
429 delete iBorderWin; |
|
430 } |
|
431 |
|
432 void TestWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) |
|
433 { |
|
434 iBorderWin=new(ELeave) CBorderWindow(); |
|
435 iBorderWin->SetUpL(pos,size,parent,aGc); |
|
436 TRAPD(err, CTWin::ConstructL(*iBorderWin)); |
|
437 if (err==KErrNone) |
|
438 { |
|
439 SetExt(TPoint(2,2),TSize(size.iWidth-4,size.iHeight-4)); |
|
440 if (err==KErrNone) |
|
441 { |
|
442 Activate(); |
|
443 AssignGC(aGc); |
|
444 return; |
|
445 } |
|
446 } |
|
447 delete this; |
|
448 User::Leave(err); |
|
449 } |
|
450 |
|
451 void TestWindow::Draw() |
|
452 { |
|
453 iGc->Clear(); |
|
454 } |
|
455 |
|
456 void TestWindow::ClearWin() |
|
457 { |
|
458 TheGc->Activate(*Win()); |
|
459 TheGc->Clear(); |
|
460 TheGc->Deactivate(); |
|
461 } |
|
462 |
|
463 void TestWindow::SetBorderExt(TPoint aPos, TSize aSize) |
|
464 { |
|
465 iBorderWin->SetExt(aPos, aSize); |
|
466 } |
|
467 |
|
468 CBorderWindow* TestWindow::GetBorderWin() |
|
469 { |
|
470 return iBorderWin; |
|
471 } |
|
472 // |
|
473 CBorderWindow::CBorderWindow() : CTWin() |
|
474 { |
|
475 } |
|
476 |
|
477 void CBorderWindow::ConstructL(CTWinBase &parent) |
|
478 { |
|
479 CTWin::ConstructL(parent); |
|
480 } |
|
481 |
|
482 void CBorderWindow::Draw() |
|
483 { |
|
484 iGc->SetBrushColor(TRgb::Gray16(0)); |
|
485 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
486 iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
487 iGc->DrawRect(TRect(Size())); |
|
488 } |
|
489 |
|
490 // |
|
491 |
|
492 TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) |
|
493 { |
|
494 } |
|
495 |
|
496 void TestWindowGroup::BecomeOwning() |
|
497 { |
|
498 iGroupWin.DefaultOwningWindow(); |
|
499 } |
|
500 |
|
501 void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) |
|
502 { |
|
503 if (aKey.iModifiers&EModifierFunc) |
|
504 { |
|
505 switch(aKey.iCode) |
|
506 { |
|
507 case 'f': |
|
508 TheClient->Driver()->iTest->TriggerFail(); |
|
509 break; |
|
510 } |
|
511 } |
|
512 else if (iCurWin) |
|
513 iCurWin->WinKeyL(aKey,aTime); |
|
514 } |
|
515 |
|
516 void TestWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &aTime) |
|
517 { |
|
518 if (iCurWin) |
|
519 iCurWin->KeyDownL(aKey,aTime); |
|
520 } |
|
521 |
|
522 void TestWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &aTime) |
|
523 { |
|
524 if (iCurWin) |
|
525 iCurWin->KeyUpL(aKey,aTime); |
|
526 } |
|
527 |
|
528 // |
|
529 |
|
530 TestClient::TestClient() |
|
531 {} |
|
532 |
|
533 void TestClient::ConstructL() |
|
534 { |
|
535 CTClient::ConstructL(); |
|
536 |
|
537 iGroup=new(ELeave) TestWindowGroup(this); |
|
538 iGroup->ConstructL(); |
|
539 |
|
540 iScreen->GetScreenSizeModeList(&iScreenModes); |
|
541 iScreen->SetScreenMode(iScreenModes[0]); |
|
542 TSize screenSize=iScreen->SizeInPixels(); |
|
543 |
|
544 TInt winWidth=(screenSize.iWidth/3)-10; |
|
545 TInt winHeight=screenSize.iHeight-10; |
|
546 iStdLogWindow=new(ELeave) LogWindow(); |
|
547 iStdLogWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); |
|
548 BaseWin=new(ELeave) TestWindow(); |
|
549 BaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),iGroup,*iGc); |
|
550 TestWin=new(ELeave) TestWindow(); |
|
551 TestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),iGroup,*iGc); |
|
552 |
|
553 iDriver = CTestDriver::CreateL(iScreenNumber); // virtual constructor |
|
554 |
|
555 TheGc=new(ELeave) CWindowGc(iScreen); |
|
556 User::LeaveIfError(TheGc->Construct()); |
|
557 |
|
558 _LIT(KTestLog,"WSERV Auto Test Log"); |
|
559 LogMessage(KTestLog()); |
|
560 LogAvailableScreenModeL(); |
|
561 |
|
562 //This class was designed to be created once and reused by all the tests, now it is created for each test, |
|
563 //this needs to be changed back so tests like the following are only done once. |
|
564 TestWsSetBufferSizeL(); |
|
565 TestWsSetMaxBufferSizeL(); |
|
566 } |
|
567 |
|
568 inline CTestDriver* TestClient::Driver() |
|
569 { |
|
570 return iDriver; |
|
571 } |
|
572 |
|
573 TBool TestClient::WaitForEvent() |
|
574 { |
|
575 if (iEventHandler->iStatus!=KRequestPending) |
|
576 return ETrue; |
|
577 else if (iRedrawEventHandler->iStatus!=KRequestPending) |
|
578 return EFalse; |
|
579 User::WaitForRequest(iEventHandler->iStatus,iRedrawEventHandler->iStatus); |
|
580 TRequestStatus* status=&iEventHandler->iStatus; |
|
581 TBool ret=ETrue; |
|
582 if (iEventHandler->iStatus==KRequestPending) |
|
583 { |
|
584 status=&iRedrawEventHandler->iStatus; |
|
585 ret=EFalse; |
|
586 } |
|
587 TInt reason=status->Int(); |
|
588 *status=KRequestPending; |
|
589 User::RequestComplete(status,reason); |
|
590 return ret; |
|
591 } |
|
592 |
|
593 TBool TestClient::IsEventWaiting() |
|
594 { |
|
595 return (iEventHandler->iStatus!=KRequestPending || iRedrawEventHandler->iStatus!=KRequestPending); |
|
596 } |
|
597 |
|
598 TestClient::~TestClient() |
|
599 { |
|
600 iScreenModes.Close(); |
|
601 delete iDriver; |
|
602 delete TheGc; |
|
603 delete iStdLogWindow; |
|
604 delete BaseWin; |
|
605 delete TestWin; |
|
606 } |
|
607 |
|
608 void TestClient::LogAvailableScreenModeL() |
|
609 { |
|
610 _LIT(KColorModes,"Color Modes: "); |
|
611 _LIT(KComma,", "); |
|
612 _LIT(KColor,"Color"); |
|
613 _LIT(KGrey,"Grey"); |
|
614 CArrayFixFlat<TInt>* modeList=new(ELeave) CArrayFixFlat<TInt>(15); |
|
615 iWs.GetColorModeList(modeList); |
|
616 TLogMessageText buf,buf2; |
|
617 buf.Append(KColorModes); |
|
618 TDisplayMode mode; |
|
619 TInt ii=0; |
|
620 FOREVER |
|
621 { |
|
622 mode=STATIC_CAST(TDisplayMode,(*modeList)[ii]); |
|
623 buf.AppendNum((*modeList)[ii]); |
|
624 buf2.Append(TDisplayModeUtils::IsDisplayModeColor(mode)?KColor():KGrey()); |
|
625 buf2.AppendNum(TDisplayModeUtils::NumDisplayModeColors(mode)); |
|
626 if (mode==EColor16MU) |
|
627 buf2.Append('U'); |
|
628 if (++ii==modeList->Count()) |
|
629 break; |
|
630 buf.Append(KComma); |
|
631 buf2.Append(KComma); |
|
632 } |
|
633 LogMessage(buf); |
|
634 LogMessage(buf2); |
|
635 delete modeList; |
|
636 } |
|
637 |
|
638 void TestClient::TestWsSetBufferSizeL() |
|
639 { |
|
640 RWsSession ws; |
|
641 User::LeaveIfError(ws.Connect()); |
|
642 ws.SetBufferSizeL(256); // default buffer size 640 |
|
643 ws.SetBufferSizeL(0x8000); // 16K is max buffer size |
|
644 ws.SetBufferSizeL(0x4000); |
|
645 ws.Close(); |
|
646 } |
|
647 |
|
648 void TestClient::TestWsSetMaxBufferSizeL() |
|
649 { |
|
650 RWsSession ws; |
|
651 User::LeaveIfError(ws.Connect()); |
|
652 // allow buffer to grow bigger than the default 640 bytes |
|
653 const TInt KBigMessageSize = 800; |
|
654 ws.SetMaxBufferSizeL(KBigMessageSize + 8); // big message + command header length |
|
655 |
|
656 // send the big message to the wserv |
|
657 TBuf8<KBigMessageSize> bigMessage; |
|
658 |
|
659 // LogMessage needs a pointer to a TInt with the message size at the start of the buffer |
|
660 const TInt szLength = sizeof(TInt); |
|
661 TInt length = KBigMessageSize - szLength; // length in Unicode characters |
|
662 bigMessage.Append((TUint8*) &length, szLength); |
|
663 |
|
664 _LIT(KLetterA, "a"); |
|
665 do |
|
666 { |
|
667 bigMessage.Append((TUint8*) KLetterA().Ptr(), 2); |
|
668 } |
|
669 while (bigMessage.Length() < KBigMessageSize); |
|
670 |
|
671 // send to Wserv, note that the message is too long to be logged |
|
672 ws.TestWrite(ws.WsHandle(), EWsClOpLogMessage, bigMessage.Ptr(), KBigMessageSize); |
|
673 ws.Flush(); |
|
674 |
|
675 ws.Close(); |
|
676 } |
|
677 |
|
678 void TestClient::SetTestClientScreenMode(TInt aMode) |
|
679 { |
|
680 iScreen->SetAppScreenMode(aMode); |
|
681 iScreen->SetScreenMode(aMode); |
|
682 UpdateTestClientScreenMode(); |
|
683 } |
|
684 |
|
685 void TestClient::UpdateTestClientScreenMode() |
|
686 { |
|
687 TSize screenSize=iScreen->SizeInPixels(); |
|
688 |
|
689 // Sets new positions and dimensions for the three window and their controlling border windows |
|
690 |
|
691 if (screenSize.iHeight > screenSize.iWidth) // Portrait mode |
|
692 { |
|
693 TInt winWidth=screenSize.iWidth - (KBorderWinWidth * 2); |
|
694 TInt winHeight=(screenSize.iHeight/3) - (KBorderWinWidth * 2); |
|
695 |
|
696 iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); |
|
697 BaseWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3+KBorderWinWidth),TSize(winWidth,winHeight)); |
|
698 BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); |
|
699 TestWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3*2+KBorderWinWidth),TSize(winWidth,winHeight)); |
|
700 TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); |
|
701 } |
|
702 else // Landscape modes |
|
703 { |
|
704 TInt winWidth=(screenSize.iWidth/3) - (KBorderWinWidth * 2); |
|
705 TInt winHeight=screenSize.iHeight - (KBorderWinWidth * 2); |
|
706 |
|
707 iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); |
|
708 BaseWin->SetBorderExt(TPoint(screenSize.iWidth/3 + KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); |
|
709 BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); |
|
710 TestWin->SetBorderExt(TPoint(screenSize.iWidth/3*2+KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); |
|
711 TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); |
|
712 } |
|
713 |
|
714 // Remove shading artefacts from window resizing operations |
|
715 TestWin->Win()->Invalidate(); |
|
716 TestWin->Win()->BeginRedraw(); |
|
717 TestWin->ClearWin(); |
|
718 TestWin->Win()->EndRedraw(); |
|
719 |
|
720 BaseWin->Win()->Invalidate(); |
|
721 BaseWin->Win()->BeginRedraw(); |
|
722 BaseWin->ClearWin(); |
|
723 BaseWin->Win()->EndRedraw(); |
|
724 |
|
725 TheClient->iWs.Flush(); |
|
726 } |
|
727 |
|
728 |
|
729 // |
|
730 // TestDriver, drives the test code // |
|
731 // |
|
732 CTestDriver* CTestDriver::CreateL(TInt aScreenNumber) |
|
733 { |
|
734 CTestDriver* self = NULL; |
|
735 if (aScreenNumber==KDefaultScreen) |
|
736 self = new (ELeave) CTestDriverPrimary(aScreenNumber); |
|
737 else |
|
738 self = new (ELeave) CTestDriverSecondary(aScreenNumber); |
|
739 |
|
740 return self; |
|
741 } |
|
742 |
|
743 CTestDriver::CTestDriver(TInt aScreenNumber) |
|
744 : iScreenNumber(aScreenNumber) |
|
745 { |
|
746 iStartTime.HomeTime(); |
|
747 HAL::Get(HALData::EDisplayNumberOfScreens, iNumberOfScreens); |
|
748 } |
|
749 |
|
750 CTestDriver::~CTestDriver() |
|
751 { |
|
752 } |
|
753 |
|
754 void CTestDriver::DestroyTest() |
|
755 { |
|
756 delete iTest; |
|
757 iTest=NULL; |
|
758 } |
|
759 |
|
760 void CTestDriver::TestComplete2() |
|
761 { |
|
762 ++iTestNum; |
|
763 if (iTestNum==iTestSize) |
|
764 { |
|
765 TBuf<64> timeBuf; |
|
766 TTime endTime; |
|
767 endTime.HomeTime(); |
|
768 TTimeIntervalMicroSeconds elapseTime=endTime.MicroSecondsFrom(iStartTime); |
|
769 TInt64 elapseTime2=elapseTime.Int64()/1000; |
|
770 TUint diffi = I64LOW(elapseTime2); |
|
771 _LIT(TestPass,"PASSED"); |
|
772 _LIT(TestFail,"FAILED"); |
|
773 TInt noOfTests=CTestBase::iNumberTests; |
|
774 TInt noOfTestsPass=CTestBase::iNumberTestsPass; |
|
775 _LIT(TimeBuf,"Elapse Time %d:%02d.%03d %S"); |
|
776 timeBuf.Format(TimeBuf,diffi/60000,(diffi/1000)%60,diffi%1000000,&(noOfTests==noOfTestsPass?TestPass:TestFail)); |
|
777 TBuf<60> testReport; |
|
778 _LIT(Checks,"Checks"); |
|
779 _LIT(Fails,"Fails"); |
|
780 _LIT(TestReport,"Tests:%d %S:%d"); |
|
781 TInt testNumber=(noOfTests==noOfTestsPass? noOfTestsPass : noOfTests-noOfTestsPass); |
|
782 testReport.Format(TestReport,iTestNum,&(noOfTests==noOfTestsPass?Checks():Fails()),testNumber); |
|
783 if (noOfTests!=noOfTestsPass) |
|
784 { |
|
785 _LIT(NumTests,"/%d"); |
|
786 testReport.AppendFormat(NumTests,noOfTests); |
|
787 } |
|
788 |
|
789 TBuf<60> logTestReport; |
|
790 _LIT(LogReport," %S:%d/%d"); |
|
791 logTestReport.Format(LogReport,&Checks,noOfTestsPass,noOfTests); |
|
792 TLogMessageText buf; |
|
793 _LIT(Finished,"AUTO Testing Complete, "); |
|
794 buf.Append(Finished); |
|
795 buf.Append(timeBuf); |
|
796 buf.Append(logTestReport); |
|
797 TheClient->LogMessage(buf); |
|
798 |
|
799 TheTestResult = noOfTests==noOfTestsPass? ETestPassed : ETestFailed; |
|
800 DoDisplayDialog(timeBuf,testReport); |
|
801 } |
|
802 } |
|
803 |
|
804 // |
|
805 // Test driver for primary screen (has digitiser/pointer) |
|
806 // |
|
807 CTestDriverPrimary::CTestDriverPrimary(TInt aScreenNumber) : CTestDriver(aScreenNumber) |
|
808 { |
|
809 TInt i; |
|
810 TInt numOfEntries = 1; |
|
811 for (i=0; i<numOfEntries; ++i) |
|
812 { |
|
813 ++iTestSize; |
|
814 } |
|
815 |
|
816 // omit multi display test (last entry in test table) |
|
817 // for single screen platform |
|
818 // |
|
819 if (iNumberOfScreens==1) |
|
820 --iTestSize; |
|
821 |
|
822 } |
|
823 |
|
824 void CTestDriverPrimary::DoDisplayDialog(TDesC& timeBuf,TDesC& testReport) |
|
825 { |
|
826 DisplayDialog(_L("Auto tests complete"),timeBuf, testReport); |
|
827 } |
|
828 |
|
829 // |
|
830 // Test driver for secondary screens |
|
831 // |
|
832 CTestDriverSecondary::CTestDriverSecondary(TInt aScreenNumber) : CTestDriver(aScreenNumber) |
|
833 { |
|
834 TInt i; |
|
835 TInt numOfEntries = 1; |
|
836 for (i=0; i<numOfEntries; ++i) |
|
837 { |
|
838 ++iTestSize; |
|
839 } |
|
840 } |
|
841 |
|
842 void CTestDriverSecondary::DoDisplayDialog(TDesC& timeBuf,TDesC& testReport) |
|
843 { |
|
844 if (TheTestResult==ETestFailed) |
|
845 DisplayDialog(iScreenNumber,_L("Auto tests complete"),timeBuf, testReport); |
|
846 } |
|
847 |
|
848 // TTestRects // |
|
849 // |
|
850 // This class provides a list of rectangles to test graphics to the test windows |
|
851 // The list designed to test all cases total clipping, partial clipping, touching the edges, |
|
852 // unclipped etc etc... |
|
853 // |
|
854 // NOTE:- Quick test version, does not provide a proper list yet |
|
855 // |
|
856 // For the rectangle list the graphics area is divided into 9 logical areas:- |
|
857 // 0:The area above & left of the drawing area |
|
858 // 1:The area above but within the left & right limits of the drawing area |
|
859 // 2:The area above & right of the drawing area |
|
860 // 3:The area left of but within the top & bottom limits of the drawing area |
|
861 // 4:The area within the drawing area |
|
862 // 5:The area right of but within the top & bottom limits of the drawing area |
|
863 // 6:The area below & left of the drawing area |
|
864 // 7:The area below but within the left & right limits of the drawing area |
|
865 // 8:The area below & right of the drawing area |
|
866 // |
|
867 // | | |
|
868 // 0 | 1 | 2 |
|
869 // | | |
|
870 // ------------------------- |
|
871 // | | |
|
872 // 3 | 4 | 5 |
|
873 // | | |
|
874 // ------------------------- |
|
875 // | | |
|
876 // 6 | 7 | 8 |
|
877 // | | |
|
878 // |
|
879 // |
|
880 // The full list of rectangles needed to test an official release is as follows: |
|
881 // |
|
882 // 0-8: A rectangle wholly within each area (0 to 8) without touching the edges (if possible) |
|
883 // 9-17: A rectangle wholly within each area and touching all bounding edges |
|
884 // 18-26: A rectangle traversing each horizontal pair & triple of areas without touching the boundarys |
|
885 // 27-35: A rectangle traversing each vertical pair & triple of areas without touching the boundarys |
|
886 // 36-39: A rectangle traversing each 2x2 block of areas without touching the boundarys |
|
887 // 40-43: A rectangle traversing each 2x2 block of areas touching each boundary |
|
888 // 44: A rectangle that includes all areas |
|
889 // 45-48: A rectangle fully enclosed in the central area that touches each edge |
|
890 // 49-54: A rectangle fully enclosed in the central area that touches each pair of edges |
|
891 // 55-58: A rectangle fully enclosed in the central area that touches each set of three edges |
|
892 // 59-67: A Zero size rectangle in each of the 9 areas |
|
893 // 68-77: Wide rectangles with heights from 0 to 9 in the central area |
|
894 // 78-87: Tall rectangles with widths from 0 to 9 in the central area |
|
895 // |
|
896 |
|
897 void TTestRects::Construct(const RWindow &aWindow) |
|
898 { |
|
899 // 59-67 |
|
900 // Special case, does not use rectangles from here |
|
901 // 68-77 |
|
902 // Special case, does not use rectangles from here |
|
903 // 78-87 |
|
904 // Special case, does not use rectangles from here |
|
905 // |
|
906 |
|
907 iSize=aWindow.Size(); |
|
908 /* |
|
909 TInt wid=size.iWidth; |
|
910 TInt hgt=size.iHeight; |
|
911 TInt wid2=wid/2; |
|
912 TInt hgt2=hgt/2; |
|
913 TInt wid3=wid/3; |
|
914 TInt hgt3=hgt/3; |
|
915 TInt wid4=wid/4; |
|
916 TInt hgt4=hgt/4; |
|
917 TInt 2wid=wid*2; |
|
918 TInt 2hgt=hgt*2; |
|
919 TInt 3wid=wid*3; |
|
920 TInt 3hgt=hgt*3; |
|
921 // 0-8 |
|
922 iList[0]=TRect(-wid,-hgt,-wid2,-hgt2); |
|
923 iList[1]=TRect(wid3,-hgt,wid-wid3,-hgt2); |
|
924 iList[2]=TRect(wid+wid2,-2hgt,2wid,-hgt); |
|
925 iList[3]=TRect(-3wid,hgt3,-wid3,hgt-hgt3); |
|
926 iList[4]=TRect(wid4,hgt3,wid-wid3,hgt-hgt4); |
|
927 iList[5]=TRect(3wid,hgt4,wid+3wid,hgt-hgt4); |
|
928 iList[6]=TRect(-wid3,hgt+hgt4,-wid2,hgt+hgt); |
|
929 iList[7]=TRect(wid2,hgt+hgt4,wid-wid4,hgt+hgt3); |
|
930 iList[8]=TRect(2wid,hgt+hgt4,3wid,hgt+hgt2); |
|
931 // 9-17 |
|
932 iList[9]=TRect(-wid,-hgt,0,0); |
|
933 iList[10]=TRect(0,-2hgt,wid,0); |
|
934 iList[11]=TRect(wid,-hgt2,wid+wid3,0); |
|
935 iList[12]=TRect(-wid3,0,0,hgt); |
|
936 iList[13]=TRect(0,0,wid,hgt); |
|
937 iList[14]=TRect(wid,0,wid+wid4,hgt); |
|
938 iList[15]=TRect(-wid,hgt,0,hgt+hgt4); |
|
939 iList[16]=TRect(0,hgt,wid,hgt+hgt); |
|
940 iList[17]=TRect(wid,hgt,wid+3wid,hgt+3hgt); |
|
941 // 18-26 |
|
942 iList[18]=TRect(-wid,-hgt,wid2,hgt3); |
|
943 iList[19]=TRect(wid3,-2hgt,2wid,-hgt3); |
|
944 iList[20]=TRect(-wid,-hgt2,wid3,-hgt3); |
|
945 iList[21]=TRect(-wid3,hgt4,wid2,hgt2); |
|
946 iList[22]=TRect(wid3,hgt3,wid+wid3,hgt-hgt3); |
|
947 iList[23]=TRect(-wid,hgt2,wid+wid4,hgt-hgt3); |
|
948 iList[24]=TRect(-wid,2hgt,wid3,3hgt); |
|
949 iList[25]=TRect(wid-wid4,hgt+hgt3,wid+wid4,2hgt); |
|
950 iList[26]=TRect(-wid4,hgt+hgt4,wid+wid4,3); |
|
951 */ |
|
952 /* |
|
953 iList[0]=TRect(0,0,size.iWidth,size.iHeight); |
|
954 iList[1]=TRect(-10,-10,size.iWidth/2,size.iHeight/2); |
|
955 iList[2]=TRect(size.iWidth/2,size.iHeight/2,size.iWidth+10,size.iHeight+10); |
|
956 iList[3]=TRect(size.iWidth/4,size.iHeight/4,size.iWidth/2,size.iHeight/2); |
|
957 iList[4]=TRect(-10,size.iHeight/4,size.iWidth+10,size.iHeight/2); |
|
958 */ |
|
959 } |
|
960 |
|
961 TInt TTestRects::Count1() const |
|
962 // |
|
963 // Count1() provides the simple base set of rectangles |
|
964 // |
|
965 { |
|
966 return(2); |
|
967 } |
|
968 |
|
969 TInt TTestRects::Count2() const |
|
970 // |
|
971 // Count2() provides an increased set of rectangles for each graphics func to test itself more thoroughly |
|
972 // |
|
973 { |
|
974 return(5); |
|
975 } |
|
976 |
|
977 TInt TTestRects::Count3() const |
|
978 // |
|
979 // Count3() provides the full set of rects for each graphics func to a quick test on |
|
980 // |
|
981 { |
|
982 return(88); |
|
983 } |
|
984 |
|
985 /** Reset the seed value to 0. */ |
|
986 void TTestRects::ResetSeed() |
|
987 { |
|
988 iSeed = 0; |
|
989 } |
|
990 |
|
991 TInt TTestRects::Rnd(TInt aSize) |
|
992 // |
|
993 // Return a random based around aSize, maybe bigger maybe smaller, who knows? |
|
994 // |
|
995 { |
|
996 TInt rnd=Math::Rand(iSeed); |
|
997 TInt result; |
|
998 if (rnd&0x8) // Increase from aSize |
|
999 result=aSize*((rnd&0x7)+1); |
|
1000 else // Decrease from aSize |
|
1001 result=aSize/((rnd&0x7)+1); |
|
1002 return(result); |
|
1003 } |
|
1004 |
|
1005 TInt TTestRects::RndMax(TInt aSize) |
|
1006 // |
|
1007 // Return a random from 0 to aSize inclusive |
|
1008 // |
|
1009 { |
|
1010 TInt64 tmpl=Math::Rand(iSeed); |
|
1011 TInt tmp = I64INT(tmpl) & 0xFFFF; |
|
1012 tmp*=aSize; |
|
1013 tmp/=0xFFFF; |
|
1014 return(tmp); |
|
1015 } |
|
1016 |
|
1017 TInt TTestRects::RectCoord(TInt aSection,TInt aSize) |
|
1018 { |
|
1019 TInt result=0; |
|
1020 switch(aSection) |
|
1021 { |
|
1022 case 0: |
|
1023 result=-(1+Rnd(aSize)); |
|
1024 break; |
|
1025 case 1: |
|
1026 result=0; |
|
1027 break; |
|
1028 case 2: |
|
1029 result=1+RndMax(aSize-2); |
|
1030 break; |
|
1031 case 3: |
|
1032 result=aSize; |
|
1033 break; |
|
1034 case 4: |
|
1035 result=aSize+1+Rnd(aSize); |
|
1036 break; |
|
1037 default: |
|
1038 AutoPanic(EAutoPanicTestRectsSection); |
|
1039 } |
|
1040 return(result); |
|
1041 } |
|
1042 |
|
1043 void TTestRects::RectCoordPair(TInt &aTl, TInt &aBr, TInt aSection, TInt aSize) |
|
1044 { |
|
1045 do |
|
1046 { |
|
1047 aTl=RectCoord(aSection,aSize); |
|
1048 aBr=RectCoord(aSection,aSize); |
|
1049 } while(aTl==aBr && aSize>1); |
|
1050 if (aTl>aBr) |
|
1051 { |
|
1052 TInt tmp=aBr; |
|
1053 aBr=aTl; |
|
1054 aTl=tmp; |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 TRect TTestRects::operator[](TInt aIndex) |
|
1059 { |
|
1060 TRect rect; |
|
1061 if (aIndex<EMaxRectFromList) |
|
1062 { |
|
1063 const TRect *pRect=&iList[aIndex]; |
|
1064 if (pRect->iTl.iX==pRect->iBr.iX) |
|
1065 RectCoordPair(rect.iTl.iX,rect.iBr.iX,pRect->iTl.iX,iSize.iWidth); |
|
1066 else |
|
1067 { |
|
1068 rect.iTl.iX=RectCoord(pRect->iTl.iX,iSize.iWidth); |
|
1069 rect.iBr.iX=RectCoord(pRect->iBr.iX,iSize.iWidth); |
|
1070 } |
|
1071 if (pRect->iTl.iY==pRect->iBr.iY) |
|
1072 RectCoordPair(rect.iTl.iY,rect.iBr.iY,pRect->iTl.iY,iSize.iHeight); |
|
1073 else |
|
1074 { |
|
1075 rect.iTl.iY=RectCoord(pRect->iTl.iX,iSize.iHeight); |
|
1076 rect.iBr.iY=RectCoord(pRect->iBr.iX,iSize.iHeight); |
|
1077 } |
|
1078 } |
|
1079 else if (aIndex<EMaxRectZeroSize) |
|
1080 { |
|
1081 rect.iTl.iX=RectCoord(((aIndex-EMaxRectFromList)%3)*2,iSize.iWidth); |
|
1082 rect.iTl.iY=RectCoord(((aIndex-EMaxRectFromList)/3)*2,iSize.iHeight); |
|
1083 rect.iBr=rect.iTl; |
|
1084 } |
|
1085 else if (aIndex<EMaxRectWide) |
|
1086 { |
|
1087 rect.iTl.iX=1; |
|
1088 rect.iBr.iX=iSize.iWidth-1; |
|
1089 rect.iTl.iY=1; |
|
1090 rect.iBr.iY=rect.iTl.iY+(aIndex-EMaxRectWide); |
|
1091 } |
|
1092 else if (aIndex<EMaxRectHigh) |
|
1093 { |
|
1094 rect.iTl.iX=1; |
|
1095 rect.iBr.iX=rect.iTl.iX+(aIndex-EMaxRectHigh); |
|
1096 rect.iTl.iY=1; |
|
1097 rect.iBr.iY=iSize.iHeight-1; |
|
1098 } |
|
1099 else |
|
1100 AutoPanic(EAutoPanicTestRectsIndex); |
|
1101 return(rect); |
|
1102 } |
|
1103 |
|
1104 |
|
1105 /*CBitmap*/ |
|
1106 |
|
1107 CBitmap* CBitmap::NewLC(const TSize& aSizeInPixels,TDisplayMode aDispMode) |
|
1108 { |
|
1109 return NewLC(0,aSizeInPixels,aDispMode); |
|
1110 } |
|
1111 |
|
1112 CBitmap* CBitmap::NewL(const TSize& aSizeInPixels,TDisplayMode aDispMode) |
|
1113 { |
|
1114 CBitmap* self=NewLC(0,aSizeInPixels,aDispMode); |
|
1115 CleanupStack::Pop(self); |
|
1116 return self; |
|
1117 } |
|
1118 |
|
1119 CBitmap* CBitmap::NewL(TInt aHandle) |
|
1120 { |
|
1121 CBitmap* self=NewLC(aHandle,TSize(),ENone); |
|
1122 CleanupStack::Pop(self); |
|
1123 return self; |
|
1124 } |
|
1125 |
|
1126 CBitmap* CBitmap::NewL(TDesC& /*aFileName*/) |
|
1127 { |
|
1128 User::Leave(KErrNotSupported); |
|
1129 return NULL; |
|
1130 } |
|
1131 |
|
1132 CBitmap* CBitmap::NewLC(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode) |
|
1133 { |
|
1134 CBitmap* self=new(ELeave) CBitmap(); |
|
1135 CleanupStack::PushL(self); |
|
1136 self->ConstructL(aHandle, aSizeInPixels, aDispMode); |
|
1137 return self; |
|
1138 } |
|
1139 |
|
1140 void CBitmap::ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode) |
|
1141 { |
|
1142 iBitmap=new(ELeave) CFbsBitmap(); |
|
1143 if (aHandle==0) |
|
1144 { |
|
1145 User::LeaveIfError(iBitmap->Create(aSizeInPixels,aDispMode)); |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 User::LeaveIfError(iBitmap->Duplicate(aHandle)); |
|
1150 } |
|
1151 iDevice=CFbsBitmapDevice::NewL(iBitmap); |
|
1152 User::LeaveIfError(iDevice->CreateContext(iGc)); |
|
1153 } |
|
1154 |
|
1155 CBitmap::~CBitmap() |
|
1156 { |
|
1157 delete iGc; |
|
1158 delete iDevice; |
|
1159 delete iBitmap; |
|
1160 } |
|
1161 |
|
1162 |
|
1163 // CTestBase // |
|
1164 |
|
1165 CTestBase::CTestBase(const TDesC& aTitle,CTWsGraphicsBase* aTestBase) |
|
1166 { |
|
1167 iTestBase=aTestBase; |
|
1168 iTitle.Copy(aTitle); |
|
1169 |
|
1170 iScreenNo = iTestBase->GetScreenFromIni(); |
|
1171 |
|
1172 TheClient=new(ELeave) TestClient(); |
|
1173 |
|
1174 if (CTestBase::iScreenNo == 1) |
|
1175 { |
|
1176 TheClient->SetScreenNumber(1); |
|
1177 iScreenNumber = 1; |
|
1178 } |
|
1179 else |
|
1180 { |
|
1181 TheClient->SetScreenNumber(0); |
|
1182 iScreenNumber = 0; |
|
1183 } |
|
1184 |
|
1185 if (iScreenNumber == 1) |
|
1186 { |
|
1187 iMinWin = new(ELeave) CMinWin(iScreenNumber); |
|
1188 iMinWin->ConstructL(); |
|
1189 } |
|
1190 |
|
1191 iTestNum=CTestDriver::iTestNum; |
|
1192 TheClient->ConstructL(); |
|
1193 TheClient->StdLogWindow().LogTest(iTitle,iTestNum); |
|
1194 iDriver=TheClient->Driver(); |
|
1195 |
|
1196 if (CTestBase::iScreenNo == 1) |
|
1197 { |
|
1198 TheClient->iWs.SetFocusScreen(1); |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 TheClient->iWs.SetFocusScreen(0); |
|
1203 } |
|
1204 |
|
1205 iTestRects.Construct(*BaseWin->Win()); |
|
1206 iStdTestWindowSize=BaseWin->Size(); |
|
1207 iRedrawType=EPartialRedraw_Unknown; // Reset between tests |
|
1208 if (iMaxGrays+iMaxColors==0) |
|
1209 { |
|
1210 TheClient->iWs.GetDefModeMaxNumColors(iMaxColors,iMaxGrays); |
|
1211 iNormalPointerCursorArea=TheClient->iWs.PointerCursorArea(); |
|
1212 } |
|
1213 } |
|
1214 |
|
1215 CTestBase::~CTestBase() |
|
1216 { |
|
1217 delete iMinWin; |
|
1218 delete TheClient; |
|
1219 } |
|
1220 |
|
1221 void CTestBase::CloseAllPanicWindows() |
|
1222 { |
|
1223 TInt idFocus = TheClient->iWs.GetFocusWindowGroup(); |
|
1224 TWsEvent event; |
|
1225 event.SetType(EEventKey); |
|
1226 TKeyEvent *keyEvent = event.Key(); |
|
1227 keyEvent->iCode = EKeyEscape; |
|
1228 keyEvent->iScanCode = EStdKeyEscape; |
|
1229 keyEvent->iModifiers = 0; |
|
1230 TInt theLimit = 50; |
|
1231 while(idFocus != NULL && (theLimit-- > 0)) |
|
1232 { |
|
1233 TheClient->iWs.SendEventToAllWindowGroups(event); |
|
1234 idFocus = TheClient->iWs.GetFocusWindowGroup(); |
|
1235 } |
|
1236 } |
|
1237 |
|
1238 /** |
|
1239 Returns the size of the standard test windows. |
|
1240 @see iStdTestWindowSize |
|
1241 */ |
|
1242 const TSize& CTestBase::StdTestWindowSize() |
|
1243 { |
|
1244 return iStdTestWindowSize; |
|
1245 } |
|
1246 |
|
1247 /** Returns the number of greys available in the richest grey mode */ |
|
1248 TInt CTestBase::MaxGrays() const |
|
1249 { |
|
1250 return iMaxGrays; |
|
1251 } |
|
1252 |
|
1253 /** Returns the number of colours available in the richest supported colour mode. */ |
|
1254 TInt CTestBase::MaxColors() const |
|
1255 { |
|
1256 return iMaxColors; |
|
1257 } |
|
1258 |
|
1259 void CTestBase::TriggerFail() |
|
1260 { |
|
1261 iFail=ETrue; |
|
1262 } |
|
1263 |
|
1264 void CTestBase::LogLeave(TInt aErr) |
|
1265 { |
|
1266 TLogMessageText buf; |
|
1267 _LIT(Leave,"AUTO Left with error code %d in "); |
|
1268 buf.AppendFormat(Leave,aErr); |
|
1269 buf.Append(iSubTitle); |
|
1270 TheClient->LogMessage(buf); |
|
1271 } |
|
1272 |
|
1273 void CTestBase::LogSubTest(const TDesC &aSubTitle) |
|
1274 { |
|
1275 Driver()->iSubTestNum++; |
|
1276 iSubTitle=aSubTitle; |
|
1277 iTestBase->Logger().Write(TheClient->StdLogWindow().LogSubTest(aSubTitle,iState)); |
|
1278 } |
|
1279 |
|
1280 void CTestBase::LogMessage(TInt aValue) |
|
1281 { |
|
1282 _LIT(WinID,"Win Id:"); |
|
1283 TheClient->StdLogWindow().LogMessage(EFalse,WinID,aValue); |
|
1284 } |
|
1285 |
|
1286 void CTestBase::LogSubState(TInt aSubState) |
|
1287 { |
|
1288 _LIT(SubTest,"SubState"); |
|
1289 iTestBase->Logger().Write(TheClient->StdLogWindow().LogMessage(ETrue,SubTest,aSubState)); |
|
1290 } |
|
1291 |
|
1292 TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect) |
|
1293 { |
|
1294 TRect rect1(aRect); |
|
1295 TRect rect2(aRect); |
|
1296 rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); |
|
1297 rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); |
|
1298 TBool match=TheClient->iScreen->RectCompare(rect1,rect2); |
|
1299 #if defined(__WINS__) |
|
1300 if (!match) |
|
1301 FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); |
|
1302 #endif |
|
1303 return match; |
|
1304 } |
|
1305 |
|
1306 TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags) |
|
1307 { |
|
1308 TRect rect1(aRect); |
|
1309 TRect rect2(aRect); |
|
1310 rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); |
|
1311 rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); |
|
1312 TBool match=TheClient->iScreen->RectCompare(rect1,rect2, aFlags); |
|
1313 #if defined(__WINS__) |
|
1314 if (!match) |
|
1315 FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); |
|
1316 #endif |
|
1317 return match; |
|
1318 } |
|
1319 |
|
1320 TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect) |
|
1321 { |
|
1322 return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect); |
|
1323 } |
|
1324 |
|
1325 TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2) |
|
1326 { |
|
1327 TSize winSize=aWin1->Size(); |
|
1328 TRect rect1(aWin1->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); |
|
1329 TRect rect2(aWin2->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); |
|
1330 return TheClient->iScreen->RectCompare(rect1,rect2); |
|
1331 } |
|
1332 |
|
1333 TBool DoCheckRect(CTBaseWin *aWin1, CTBaseWin *aWin2, const TRect &aRect, TUint aFlags) |
|
1334 { |
|
1335 return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect, aFlags); |
|
1336 } |
|
1337 |
|
1338 |
|
1339 /** |
|
1340 Compares the contents of 2 rectangular areas of the screen. |
|
1341 |
|
1342 @param aPos1 The top left corner of the first rectangle. |
|
1343 @param aPos2 The top left corner of the second rectangle. |
|
1344 @param aSize The size of the rectangles |
|
1345 @return ETrue if the 2 areas have the same content, EFalse otherwise. |
|
1346 */ |
|
1347 TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize) |
|
1348 { |
|
1349 return TheClient->iScreen->RectCompare(TRect(aPos1,aSize),TRect(aPos2,aSize)); |
|
1350 } |
|
1351 |
|
1352 void CTestBase::DrawTestBackground(TBool aInvertColors, const TSize &aSize, TInt aGrays/*=16*/) |
|
1353 // |
|
1354 // Draws a standard test background with a mix of colors (shades). |
|
1355 // This is mainly used to test for graphic functions writing outside the intended area. |
|
1356 // |
|
1357 // This code assumes an TheGc is already active on the window to use. |
|
1358 // |
|
1359 { |
|
1360 TheGc->SetBrushColor(TRgb::Gray256(255)); |
|
1361 TInt step=5; |
|
1362 TInt col=0; |
|
1363 TInt colorInc=(aGrays>9 ? 17 : 85); |
|
1364 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1365 TheGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1366 for(TInt row=0;row<aSize.iHeight;row+=step) |
|
1367 { |
|
1368 TheGc->SetBrushColor(TRgb::Gray256(aInvertColors ? 255-col:col)); |
|
1369 TheGc->DrawRect(TRect(0,row,aSize.iWidth,row+step)); |
|
1370 col=col+colorInc; |
|
1371 if (col>255) |
|
1372 col=0; |
|
1373 } |
|
1374 } |
|
1375 |
|
1376 void CTestBase::AbortL() |
|
1377 { |
|
1378 CTestDriver* driver=iDriver; |
|
1379 iDriver->DestroyTest(); |
|
1380 driver->TestComplete2(); |
|
1381 User::Leave(ETestFailed); |
|
1382 } |
|
1383 |
|
1384 /*CTWsGraphicsBase*/ |
|
1385 |
|
1386 CTWsGraphicsBase::CTWsGraphicsBase(CTestStep* aStep) : CTGraphicsBase(aStep) |
|
1387 { |
|
1388 } |
|
1389 |
|
1390 CTWsGraphicsBase::~CTWsGraphicsBase() |
|
1391 { |
|
1392 delete iTest; |
|
1393 } |
|
1394 |
|
1395 void CTWsGraphicsBase::CreateTestBaseL(CTTMSGraphicsStep* aTmsStep) |
|
1396 { |
|
1397 __ASSERT_ALWAYS(iTest==NULL,AutoPanic(EAutoPanicRecalledCreateTestBaseL)); |
|
1398 iTest=new(ELeave) CTestBase(iStep->TestStepName(),this); |
|
1399 iTmsStep = aTmsStep; |
|
1400 } |
|
1401 /** |
|
1402 Gets the Screen Number from an .ini file supplied to the RUN_TEST_STEP. Screen number should |
|
1403 be put under the section [useScreen] as screen=0 or screen=1. |
|
1404 |
|
1405 @return Screen number Defined in .ini file, otherwise 0. |
|
1406 */ |
|
1407 TInt CTWsGraphicsBase::GetScreenFromIni() const |
|
1408 { |
|
1409 _LIT(KUseScreenSection, "useScreen"); |
|
1410 _LIT(KScreen, "screen"); |
|
1411 |
|
1412 TInt screen = 0; |
|
1413 TBool configAvailable = iStep->GetIntFromConfig(KUseScreenSection, KScreen, screen); |
|
1414 if(configAvailable) |
|
1415 { |
|
1416 return screen; |
|
1417 } |
|
1418 else |
|
1419 { |
|
1420 return 0; |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 void CTWsGraphicsBase::TestComplete() |
|
1425 { |
|
1426 _LIT(KTestComplete,"Test complete"); |
|
1427 INFO_PRINTF1(KTestComplete); |
|
1428 CTGraphicsBase::TestComplete(); |
|
1429 } |
|
1430 |
|
1431 void CTWsGraphicsBase::LogMessage(const TText8* aFile,TInt aLine,TRefByValue<const TDesC> aFmt,...) |
|
1432 { |
|
1433 TLogMessageText buf; |
|
1434 VA_LIST list; |
|
1435 VA_START(list,aFmt); |
|
1436 buf.AppendFormatList(aFmt,list); |
|
1437 TheClient->LogMessage(buf); |
|
1438 Logger().LogExtra(aFile,aLine,ESevrInfo,buf); |
|
1439 VA_END(list); |
|
1440 } |
|
1441 |
|
1442 TBool CTWsGraphicsBase::CheckRetValue(TBool aPass, const TDesC *aErrorMsg, const TDesC &aErrorFunction) |
|
1443 { |
|
1444 if (!aPass && aErrorMsg) |
|
1445 { |
|
1446 LOG_MESSAGE3(_L("%S %S failed"),aErrorMsg,&aErrorFunction); |
|
1447 iTmsStep->MQCTest(EFalse,((TText8*)__FILE__),__LINE__); |
|
1448 } |
|
1449 iStep->TEST(aPass); |
|
1450 return aPass; |
|
1451 } |
|
1452 |
|
1453 void CTWsGraphicsBase::CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine) |
|
1454 { |
|
1455 if (!DoCheckRect(BaseWin, TestWin, BaseWin->Size())) |
|
1456 { |
|
1457 #ifdef __WINS__ |
|
1458 _LIT(KMessage,"ERROR: Test Failed but is ignored on WINSCW"); |
|
1459 Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); |
|
1460 #else // __WINS__ |
|
1461 iStep->TEST(EFalse); |
|
1462 _LIT(KMessage,"ERROR: Test Failed"); |
|
1463 Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); |
|
1464 #endif // __WINS__ |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) |
|
1469 { |
|
1470 CheckRetValue(DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRect()")); |
|
1471 } |
|
1472 |
|
1473 void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) |
|
1474 { |
|
1475 CheckRect(aPos1,aPos2,aSize,&aErrorMsg); |
|
1476 } |
|
1477 |
|
1478 void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) |
|
1479 { |
|
1480 CheckRetValue(!DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRectNoMatch()")); |
|
1481 } |
|
1482 |
|
1483 void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) |
|
1484 { |
|
1485 CheckRectNoMatch(aPos1,aPos2,aSize,&aErrorMsg); |
|
1486 } |
|
1487 |
|
1488 void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) |
|
1489 { |
|
1490 CheckRetValue(DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRect()")); |
|
1491 } |
|
1492 |
|
1493 void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) |
|
1494 { |
|
1495 CheckRect(aWin1,aWin2,&aErrorMsg); |
|
1496 } |
|
1497 |
|
1498 void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) |
|
1499 { |
|
1500 CheckRetValue(!DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRectNoMatch()")); |
|
1501 } |
|
1502 |
|
1503 void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) |
|
1504 { |
|
1505 CheckRectNoMatch(aWin1,aWin2,&aErrorMsg); |
|
1506 } |
|
1507 |
|
1508 TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) |
|
1509 { |
|
1510 return CheckRetValue(DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRect()")); |
|
1511 } |
|
1512 |
|
1513 TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) |
|
1514 { |
|
1515 return CheckRect(aWin1,aWin2,aRect,&aErrorMsg); |
|
1516 } |
|
1517 |
|
1518 void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) |
|
1519 { |
|
1520 CheckRetValue(!DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRectNoMatch()")); |
|
1521 } |
|
1522 |
|
1523 void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) |
|
1524 { |
|
1525 CheckRectNoMatch(aWin1,aWin2,aRect,&aErrorMsg); |
|
1526 } |
|
1527 |
|
1528 void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC *aErrorMsg) |
|
1529 { |
|
1530 CheckRetValue(DoCheckRect(BaseWin,TestWin,aRect),aErrorMsg,_L("CompareWindows()")); |
|
1531 } |
|
1532 |
|
1533 TBool CTWsGraphicsBase::CompareWindows(const TDesC *aErrorMsg) |
|
1534 { |
|
1535 return CheckRetValue(DoCheckRect(BaseWin,TestWin,TRect(BaseWin->Size())),aErrorMsg,_L("CompareWindows()")); |
|
1536 } |
|
1537 |
|
1538 void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC &aErrorMsg) |
|
1539 { |
|
1540 CompareWindows(aRect,&aErrorMsg); |
|
1541 } |
|
1542 |
|
1543 TBool CTWsGraphicsBase::CompareWindows(const TDesC &aErrorMsg) |
|
1544 { |
|
1545 return CompareWindows(&aErrorMsg); |
|
1546 } |
|
1547 |
|
1548 /** |
|
1549 Returns the size of the standard test windows. |
|
1550 |
|
1551 Several tests use 3 windows : one is a log window, one is a reference window |
|
1552 and one is the actual output of the test. All these windows have the same width which is roughly |
|
1553 1/3 of the screen. They also have the same height which is roughly equal to the screen height. |
|
1554 */ |
|
1555 const TSize& CTWsGraphicsBase::StdTestWindowSize() |
|
1556 { |
|
1557 return iTest->StdTestWindowSize(); |
|
1558 } |
|
1559 |
|
1560 /** Returns the number of greys available in the richest grey mode */ |
|
1561 TInt CTWsGraphicsBase::MaxGrays() const |
|
1562 { |
|
1563 return iTest->MaxGrays(); |
|
1564 } |
|
1565 |
|
1566 /** Returns the number of colours available in the richest supported colour mode. */ |
|
1567 TInt CTWsGraphicsBase::MaxColors() const |
|
1568 { |
|
1569 return iTest->MaxColors(); |
|
1570 } |
|
1571 |
|
1572 // |
|
1573 // Panic testing // |
|
1574 // |
|
1575 |
|
1576 LOCAL_C TInt PanicThreadFunc(TAny *aPtr) |
|
1577 { |
|
1578 CTrapCleanup* CleanUpStack=CTrapCleanup::New(); |
|
1579 SPanicParams *ptr=(SPanicParams *)aPtr; |
|
1580 TInt ret; |
|
1581 TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->ptr)); |
|
1582 delete CleanUpStack; |
|
1583 if (ret==EWsExitReasonBad) |
|
1584 AutoPanic(EAutoPanicPanicFailed); |
|
1585 return(ret); |
|
1586 } |
|
1587 |
|
1588 TInt CTestBase::LaunchPanicThread(RThread &aThread, SPanicParams *aPtr) |
|
1589 { |
|
1590 TBuf<32> threadName; |
|
1591 threadName.Format(TRefByValue<const TDesC>(_L("AutoPanicThread%d")),iThreadNumber++); |
|
1592 return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); |
|
1593 } |
|
1594 |
|
1595 TInt CTestBase::TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished) |
|
1596 { |
|
1597 RThread thread; |
|
1598 TRequestStatus stat; |
|
1599 TInt err=LaunchPanicThread(thread, aPtr); |
|
1600 if (err==KErrAlreadyExists) |
|
1601 { |
|
1602 // wait for kernel to clear up old threads |
|
1603 // and have several attempts at starting the thread |
|
1604 // if unsuccessful the first time |
|
1605 for (TInt i=0;i<3;i++) |
|
1606 { |
|
1607 User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs |
|
1608 err=LaunchPanicThread(thread, aPtr); |
|
1609 if (err!=KErrAlreadyExists) |
|
1610 break; |
|
1611 } |
|
1612 } |
|
1613 User::LeaveIfError(err); |
|
1614 thread.Logon(stat); |
|
1615 User::SetJustInTime(EFalse); |
|
1616 thread.Resume(); |
|
1617 User::WaitForRequest(stat); |
|
1618 User::SetJustInTime(ETrue); |
|
1619 |
|
1620 TBool testFinished=EFalse; |
|
1621 TBool testPassed=ETrue; |
|
1622 if (thread.ExitType()==EExitKill) |
|
1623 { |
|
1624 User::LeaveIfError(thread.ExitReason()); |
|
1625 if(thread.ExitReason()!=EWsExitReasonFinished) |
|
1626 { |
|
1627 testPassed=EFalse; |
|
1628 } |
|
1629 testFinished=ETrue; // Finish tests |
|
1630 } |
|
1631 else |
|
1632 { |
|
1633 if ((thread.ExitCategory().Compare(aCategory)!=0) |
|
1634 || (aExitReason!=EWservNoPanic && thread.ExitReason()!=aExitReason) |
|
1635 || (thread.ExitType()!=EExitPanic)) |
|
1636 { |
|
1637 testPassed=EFalse; |
|
1638 } |
|
1639 } |
|
1640 |
|
1641 if(aTestFinished) |
|
1642 *aTestFinished=testFinished; |
|
1643 thread.Close(); |
|
1644 return(testPassed); |
|
1645 } |
|
1646 |
|
1647 TInt CTestBase::TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) |
|
1648 { |
|
1649 return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV, aTestFinished); |
|
1650 } |
|
1651 |
|
1652 TInt CTestBase::TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) |
|
1653 { |
|
1654 return TestPanicL(aFunction,aExitReason,aInt,aPtr,KW32,aTestFinished); |
|
1655 } |
|
1656 |
|
1657 TInt CTestBase::TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr) |
|
1658 { |
|
1659 _LIT(KWSERV1,"Wserv Internal Panic"); |
|
1660 return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV1); |
|
1661 } |
|
1662 |
|
1663 TInt CTestBase::TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished) |
|
1664 { |
|
1665 SPanicParams params; |
|
1666 params.num=aInt; |
|
1667 params.func=aFunction; |
|
1668 params.ptr=aPtr; |
|
1669 return TestPanicL(¶ms, aExitReason, aCategory, aTestFinished); |
|
1670 } |
|
1671 |
|
1672 TBool CTestBase::IsFullRomL() |
|
1673 { |
|
1674 TBool isFullRom = EFalse; |
|
1675 _LIT(KWinName,"EikonServer"); |
|
1676 TInt numWinGroups=TheClient->iWs.NumWindowGroups(); |
|
1677 CArrayFixFlat<TInt>* list=new(ELeave) CArrayFixFlat<TInt>(numWinGroups); |
|
1678 TheClient->iWs.WindowGroupList(list); |
|
1679 numWinGroups=list->Count(); // Just in case it changed between originally getting it and getting the actual list |
|
1680 TBuf<64> name; |
|
1681 TInt ii; |
|
1682 for(ii=0;ii<numWinGroups;++ii) |
|
1683 { |
|
1684 TheClient->iWs.GetWindowGroupNameFromIdentifier((*list)[ii],name); |
|
1685 #ifndef DISABLE_FAIL_DIALOG |
|
1686 TInt ordinalPos=0; |
|
1687 ordinalPos+=ordinalPos; //To stop a warning |
|
1688 ordinalPos= |
|
1689 #endif |
|
1690 TheClient->iWs.GetWindowGroupOrdinalPriority((*list)[ii]); |
|
1691 if (name==KWinName) |
|
1692 { |
|
1693 isFullRom = ETrue; |
|
1694 break; |
|
1695 } |
|
1696 } |
|
1697 delete list; |
|
1698 return isFullRom; |
|
1699 } |
|
1700 |
|
1701 void CTestBase::DelayIfFullRomL() |
|
1702 { |
|
1703 if (IsFullRomL()) |
|
1704 User::After(400000); |
|
1705 } |
|
1706 |
|
1707 TPartialRedrawType CTestBase::RedrawStoreTypeL() |
|
1708 { |
|
1709 /* if (iRedrawType==EPartialRedraw_Unknown) |
|
1710 { |
|
1711 const TRgb KRed=TRgb(255,0,0); |
|
1712 const TRgb KGreen=TRgb(0,255,0); |
|
1713 const TRgb KBlue=TRgb(0,0,255); |
|
1714 CWsScreenDevice* scrDev=TheClient->iScreen; |
|
1715 TSize winSize=scrDev->SizeInPixels(); |
|
1716 CBlankWindow* win=new(ELeave) CBlankWindow(KRed); //Window will be red if WSERV just draws in background color |
|
1717 CleanupStack::PushL(win); |
|
1718 TDisplayMode mode=EColor256; |
|
1719 win->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //Window is activated |
|
1720 win->RealDraw(ETrue); |
|
1721 win->SetColor(KGreen); |
|
1722 CBlankWindow* win2=new(ELeave) CBlankWindow(KRed); |
|
1723 CleanupStack::PushL(win2); |
|
1724 win2->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //New Window completely obscures other window |
|
1725 win2->RealDraw(ETrue); |
|
1726 win->CTWin::DrawNow(); //Window will be green if drawn from stored commands |
|
1727 win2->CTWin::DrawNow(); |
|
1728 win2->SetVisible(EFalse); |
|
1729 TRgb col; |
|
1730 scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if storing off by default and green otherwise |
|
1731 if (col==KRed) |
|
1732 { |
|
1733 win->Win()->EnableRedrawStore(ETrue); |
|
1734 win->CTWin::DrawNow(); //Create stored commands |
|
1735 } |
|
1736 else |
|
1737 __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); |
|
1738 win->SetColor(KBlue); |
|
1739 TRect redrawRect(TSize(10,10)); |
|
1740 win->Invalidate(redrawRect); |
|
1741 win->Win()->BeginRedraw(redrawRect); |
|
1742 win->DrawNow(redrawRect); //Top left of Window will be blue if it draws itself |
|
1743 win->Win()->EndRedraw(); |
|
1744 win2->SetVisible(ETrue); |
|
1745 win2->SetVisible(EFalse); |
|
1746 scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if stored commands were lost |
|
1747 iRedrawType=EPartialRedraw_None; |
|
1748 if (col!=KRed) |
|
1749 { |
|
1750 __ASSERT_ALWAYS(col==KBlue,AutoPanic(EAutoPanicRedrawStoring)); |
|
1751 TheClient->WaitForRedrawsToFinish(); |
|
1752 win2->SetVisible(ETrue); |
|
1753 win2->SetVisible(EFalse); |
|
1754 scrDev->GetPixel(col,TPoint(15,15)); //Pixel will be blue if partial redraw triggers full redraw |
|
1755 iRedrawType=EPartialRedraw_PreserveStoredCmds; |
|
1756 if (col!=KBlue) |
|
1757 { |
|
1758 __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); |
|
1759 iRedrawType=EPartialRedraw_FullRedrawSupport; |
|
1760 } |
|
1761 } |
|
1762 CleanupStack::PopAndDestroy(2,win); |
|
1763 } |
|
1764 return iRedrawType;*/ |
|
1765 return EPartialRedraw_FullRedrawSupport; |
|
1766 } |
|
1767 |
|
1768 void CTestBase::SetUpMember(TSpriteMember &aMember) |
|
1769 { |
|
1770 aMember.iMaskBitmap=NULL; |
|
1771 aMember.iInvertMask=EFalse; |
|
1772 aMember.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
1773 aMember.iOffset=TPoint(); |
|
1774 aMember.iInterval=TTimeIntervalMicroSeconds32(0); |
|
1775 } |
|
1776 |
|
1777 void CTestBase::SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers) |
|
1778 { |
|
1779 if (aModifiers&EModifierAlt) |
|
1780 SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftFunc); |
|
1781 if (aModifiers&EModifierCtrl) |
|
1782 SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftCtrl); |
|
1783 if (aModifiers&EModifierShift) |
|
1784 SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); |
|
1785 SimulateKeyDownUp(aScanCode); |
|
1786 if (aModifiers&EModifierShift) |
|
1787 SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); |
|
1788 if (aModifiers&EModifierCtrl) |
|
1789 SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); |
|
1790 if (aModifiers&EModifierAlt) |
|
1791 SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); |
|
1792 } |
|
1793 |
|
1794 void CTestBase::SimulateKeyDownUp(TInt aScanCode) |
|
1795 { |
|
1796 __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); |
|
1797 SimulateKey(TRawEvent::EKeyDown,aScanCode); |
|
1798 SimulateKey(TRawEvent::EKeyUp,aScanCode); |
|
1799 } |
|
1800 |
|
1801 void CTestBase::SimulatePointerDownUp(TInt aX, TInt aY) |
|
1802 { |
|
1803 SimulatePointer(TRawEvent::EButton1Down,aX,aY); |
|
1804 SimulatePointer(TRawEvent::EButton1Up,aX,aY); |
|
1805 } |
|
1806 |
|
1807 void CTestBase::SimulateKey(TRawEvent::TType aType, TInt aScanCode) |
|
1808 { |
|
1809 TRawEvent rawEvent; |
|
1810 rawEvent.Set(aType,aScanCode); |
|
1811 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
1812 } |
|
1813 |
|
1814 /** |
|
1815 * Determine if the configuration supports pointer event testing. |
|
1816 * |
|
1817 * There are certain circumstances where we want to skip pointer event |
|
1818 * testing because we are simulating pointer events, and don't want to |
|
1819 * simulate a pointer event from an impossible co-ordinate. We'd rather |
|
1820 * just identify that there is no point in doing the test and skip over |
|
1821 * to the next test case. |
|
1822 * |
|
1823 * In particular, when a ROM configured with a digitiser is deployed on a |
|
1824 * Naviengine, with hardware configuration DIP switches which say that there |
|
1825 * is an external screen connected, then no touch pad is active. |
|
1826 * The base port under these conditions returns a digitiser area (0,0,0,0) |
|
1827 * |
|
1828 * @return ETrue if the configuration supports pointer event testing, otherwise |
|
1829 * return EFalse. |
|
1830 */ |
|
1831 TBool CTestBase::ConfigurationSupportsPointerEventTesting() const |
|
1832 { |
|
1833 if (iNormalPointerCursorArea.IsEmpty()) |
|
1834 { |
|
1835 return EFalse; |
|
1836 } |
|
1837 return ETrue; |
|
1838 } |
|
1839 |
|
1840 |
|
1841 void CTestBase::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY) |
|
1842 { |
|
1843 __ASSERT_DEBUG(ConfigurationSupportsPointerEventTesting(), AutoPanic(EAutoPanicNoDigitiser)); |
|
1844 |
|
1845 |
|
1846 #ifdef WSERV_TAUTO_LOG_POINTER_EVENTS |
|
1847 TLogMessageText buf; |
|
1848 _LIT(KLog,"SimulatePointer Type=%d Pos=(%d,%d)"); |
|
1849 buf.Format(KLog,aType,aX,aY); |
|
1850 TheClient->LogMessage(buf); |
|
1851 #endif |
|
1852 |
|
1853 TRawEvent rawEvent; |
|
1854 rawEvent.Set(aType,aX,aY); |
|
1855 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
1856 } |
|
1857 |
|
1858 void CTestBase::SimulateEvent(TRawEvent::TType aType) |
|
1859 { |
|
1860 TRawEvent rawEvent; |
|
1861 rawEvent.Set(aType); |
|
1862 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
1863 } |
|
1864 |
|
1865 void CTestBase::LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint) |
|
1866 { |
|
1867 _LIT(KPixel,"Pixel(%d,%d) R=%d G=%d B=%d"); |
|
1868 TLogMessageText buf; |
|
1869 TBuf8<2560> screen; |
|
1870 const TRgb* pixel; |
|
1871 if (aStartPoint.iX==aEndPoint.iX) |
|
1872 ++aEndPoint.iX; |
|
1873 if (aStartPoint.iY==aEndPoint.iY) |
|
1874 ++aEndPoint.iY; |
|
1875 TInt width=aEndPoint.iX-aStartPoint.iX; |
|
1876 TInt xx,yy; |
|
1877 for (yy=aStartPoint.iY;yy<aEndPoint.iY;++yy) |
|
1878 { |
|
1879 xx=aStartPoint.iX; |
|
1880 aDevice.GetScanLine(screen,aBasePoint+TPoint(xx,yy),width,ERgb); |
|
1881 pixel=REINTERPRET_CAST(const TRgb*,screen.Ptr()); |
|
1882 for (;xx<aEndPoint.iX;++xx,++pixel) |
|
1883 { |
|
1884 buf.Format(KPixel,xx,yy,pixel->Red(),pixel->Green(),pixel->Blue()); |
|
1885 //RDebug::Print(buf); |
|
1886 TheClient->iWs.LogMessage(buf); |
|
1887 } |
|
1888 } |
|
1889 TheClient->iWs.Flush(); |
|
1890 } |
|
1891 |
|
1892 void CTestBase::LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen) |
|
1893 { |
|
1894 _LIT(KValue,"Pixel(%d,%d) Byte %d, Value %d"); |
|
1895 TLogMessageText buf; |
|
1896 TBuf8<2560> screen; |
|
1897 aDevice.GetScanLine(screen,aStartPoint,aLen,EGray4); |
|
1898 TInt len=(aLen+3)/4; |
|
1899 TInt ii; |
|
1900 for (ii=0;ii<len;++ii,aStartPoint.iX+=4) |
|
1901 { |
|
1902 buf.Format(KValue,aStartPoint.iX,aStartPoint.iY,ii,screen[ii]); |
|
1903 TheClient->iWs.LogMessage(buf); |
|
1904 } |
|
1905 } |
|
1906 |
|
1907 void CTestBase::UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass) |
|
1908 { |
|
1909 iNumberTests+=aNoOfTest; |
|
1910 iNumberTestsPass+=aNoOfTestPass; |
|
1911 } |
|
1912 |
|
1913 TInt CTestBase::SaveScreen(const TDesC& aFileName) |
|
1914 { |
|
1915 return SaveScreen(aFileName,TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()); |
|
1916 } |
|
1917 |
|
1918 TInt CTestBase::SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) |
|
1919 { |
|
1920 TRAPD(err,SaveScreenL(aFileName,aScreenSize,aColorDepth)); |
|
1921 return err; |
|
1922 } |
|
1923 |
|
1924 void CTestBase::SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) |
|
1925 { |
|
1926 CBitmap* copyOfScreen=CBitmap::NewLC(aScreenSize,aColorDepth); |
|
1927 CFbsScreenDevice* scrDevice=CFbsScreenDevice::NewL(iScreenNumber,aColorDepth); |
|
1928 CleanupStack::PushL(scrDevice); |
|
1929 CFbsBitGc* gc; |
|
1930 User::LeaveIfError(scrDevice->CreateContext(gc)); |
|
1931 CleanupStack::PushL(gc); |
|
1932 copyOfScreen->Gc().BitBlt(TPoint(),*gc); |
|
1933 User::LeaveIfError(copyOfScreen->Bitmap().Save(aFileName)); |
|
1934 CleanupStack::PopAndDestroy(3,copyOfScreen); |
|
1935 } |
|
1936 |
|
1937 |
|
1938 /*CProcess*/ |
|
1939 _LIT(KScreenTag,"Screen"); |
|
1940 |
|
1941 void CProcess::GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg) |
|
1942 { |
|
1943 TInt pos = aParam.Find(KScreenTag); |
|
1944 if (pos!=KErrNotFound) |
|
1945 aProcArg = aParam.Left(pos-1); |
|
1946 else |
|
1947 aProcArg = aParam; |
|
1948 } |
|
1949 |
|
1950 void CProcess::GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg) |
|
1951 { |
|
1952 TInt pos = aParam.Find(KScreenTag); |
|
1953 if (pos!=KErrNotFound) |
|
1954 { |
|
1955 TBufArg secondArg(aParam.Right(aParam.Length()-pos)); |
|
1956 if (secondArg.Length()>6) |
|
1957 { |
|
1958 TBuf<1> digit(secondArg.Mid(6,1)); |
|
1959 TLex lex(digit); |
|
1960 lex.Val(aScreenArg); |
|
1961 } |
|
1962 } |
|
1963 } |
|
1964 |
|
1965 TInt CProcess::Start(const TWinCommand& aParam) |
|
1966 { |
|
1967 // parse command line aParam to retrieve value of |
|
1968 // screen number if it is specified |
|
1969 // |
|
1970 // command line format: <process-id> [screen<id>] |
|
1971 // |
|
1972 TBufArg procArg(_L("")); |
|
1973 TInt screenArg = KDefaultScreen; |
|
1974 |
|
1975 GetProcArg(aParam, procArg); |
|
1976 GetScreenArg(aParam, screenArg); |
|
1977 |
|
1978 TInt ii; |
|
1979 for(ii=0;ii<eNumProcessCalls;ii++) |
|
1980 { |
|
1981 if (procArg==iFunctions[ii].iParam) |
|
1982 { |
|
1983 TRAPD(ret,iFunctions[ii].iFunction((TAny*)screenArg)); |
|
1984 |
|
1985 // need to pass test result to owning process |
|
1986 // for multiple display test |
|
1987 if (ii==eProcessMultiDisplayTest) |
|
1988 ret = TheTestResult; |
|
1989 |
|
1990 return ret; |
|
1991 } |
|
1992 } |
|
1993 |
|
1994 return KErrNone; //Shouldn't get here |
|
1995 } |
|
1996 |
|
1997 CProcess* CProcess::NewL(TInt aFunctionNo,TInt aScreenNumber) |
|
1998 { |
|
1999 CProcess* self=new(ELeave) CProcess(); |
|
2000 CleanupStack::PushL(self); |
|
2001 self->ConstructL(aFunctionNo,aScreenNumber); |
|
2002 CleanupStack::Pop(self); |
|
2003 return self; |
|
2004 } |
|
2005 |
|
2006 CProcess* CProcess::NewTL(TInt aFunctionNo,TInt aScreenNumber,TRequestStatus* aStatus /*=NULL*/) |
|
2007 { |
|
2008 CProcess* self=new(ELeave) CProcess(); |
|
2009 CleanupStack::PushL(self); |
|
2010 self->ConstructTL(aFunctionNo,aScreenNumber,aStatus); |
|
2011 CleanupStack::Pop(self); |
|
2012 return self; |
|
2013 } |
|
2014 |
|
2015 CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr |
|
2016 ,TRequestStatus* aStatus) |
|
2017 { |
|
2018 CProcess* self=new(ELeave) CProcess(); |
|
2019 CleanupStack::PushL(self); |
|
2020 self->ConstructL(aName,aFunction,aPtr,aStatus); |
|
2021 CleanupStack::Pop(self); |
|
2022 return self; |
|
2023 } |
|
2024 |
|
2025 CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr ,TRequestStatus* aLogonStatus,TRequestStatus& aRendesvouzStatus) |
|
2026 { |
|
2027 CProcess* self=new(ELeave) CProcess(); |
|
2028 CleanupStack::PushL(self); |
|
2029 self->ConstructRendezvousL(aName,aFunction,aPtr,aLogonStatus,aRendesvouzStatus); |
|
2030 CleanupStack::Pop(self); |
|
2031 return self; |
|
2032 } |
|
2033 |
|
2034 CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendesvouzStatus) |
|
2035 { |
|
2036 return NewThreadRendezvousL(aName,ThreadInit,aPtr,NULL,aRendesvouzStatus); |
|
2037 } |
|
2038 |
|
2039 CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadStartUp* aPtr) |
|
2040 { |
|
2041 return NewThreadL(aName,ThreadInit,aPtr,NULL); |
|
2042 } |
|
2043 |
|
2044 CProcess* CProcess::NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus/*=NULL*/) |
|
2045 { |
|
2046 return NewThreadL(aName,SimpleThreadInit,aPtr,aStatus); |
|
2047 } |
|
2048 |
|
2049 _LIT(KSpace," "); |
|
2050 _LIT(KScreenFormat,"%d"); |
|
2051 |
|
2052 void CProcess::ConstructL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/) |
|
2053 { |
|
2054 Close(); |
|
2055 // add screen number into command line param |
|
2056 // format: <proc-id> [screen<id>] |
|
2057 // |
|
2058 TBuf<100> commandLine; |
|
2059 |
|
2060 commandLine = iFunctions[aFunctionNo].iParam; |
|
2061 commandLine.Append(KSpace); |
|
2062 commandLine.Append(KScreenTag); |
|
2063 commandLine.AppendFormat(KScreenFormat,aScreenNumber); |
|
2064 User::LeaveIfError(iOther.Create(RProcess().FileName(),commandLine)); |
|
2065 iCreated|=eOtherCreated; |
|
2066 iOther.Resume(); |
|
2067 } |
|
2068 |
|
2069 void CProcess::ConstructTL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/,TRequestStatus* aStatus) |
|
2070 { |
|
2071 Close(); |
|
2072 TUint flag=eThreadCreated; |
|
2073 TInt err=iThread.Create(iFunctions[aFunctionNo].iParam,iFunctions[aFunctionNo].iFunction |
|
2074 ,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,(TAny*)aScreenNumber,EOwnerThread); |
|
2075 User::LeaveIfError(err); |
|
2076 iCreated|=flag; |
|
2077 if (aStatus) |
|
2078 Logon(*aStatus); |
|
2079 iThread.Resume(); |
|
2080 } |
|
2081 |
|
2082 |
|
2083 void CProcess::ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus) |
|
2084 { |
|
2085 Close(); |
|
2086 User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); |
|
2087 iCreated|=eThreadCreated; |
|
2088 if (aStatus) |
|
2089 Logon(*aStatus); |
|
2090 iThread.Resume(); |
|
2091 } |
|
2092 |
|
2093 void CProcess::ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus) |
|
2094 { |
|
2095 Close(); |
|
2096 User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); |
|
2097 iCreated|=eThreadCreated; |
|
2098 if (aLogonStatus) |
|
2099 Logon(*aLogonStatus); |
|
2100 |
|
2101 iThread.Rendezvous(aRendezvousStatus); |
|
2102 iThread.Resume(); |
|
2103 } |
|
2104 |
|
2105 void CProcess::Logon(TRequestStatus& aStatus) const |
|
2106 { |
|
2107 if (iCreated&eThreadCreated) |
|
2108 iThread.Logon(aStatus); |
|
2109 else |
|
2110 { |
|
2111 iOther.Logon(aStatus); |
|
2112 } |
|
2113 } |
|
2114 |
|
2115 void CProcess::Terminate(TInt aReason) |
|
2116 { |
|
2117 if (iCreated&eThreadCreated) |
|
2118 iThread.Terminate(aReason); |
|
2119 else |
|
2120 { |
|
2121 iOther.Terminate(aReason); |
|
2122 } |
|
2123 Close(); |
|
2124 } |
|
2125 |
|
2126 void CProcess::Close() |
|
2127 { |
|
2128 if (iCreated&eOtherCreated) |
|
2129 iOther.Close(); |
|
2130 if (iCreated&eThreadCreated) |
|
2131 iThread.Close(); |
|
2132 iCreated=0; |
|
2133 } |
|
2134 |
|
2135 CProcess::~CProcess() |
|
2136 { |
|
2137 Close(); |
|
2138 } |
|
2139 |
|
2140 TBool CProcess::StillAlive() |
|
2141 { |
|
2142 if (iCreated&eOtherCreated) |
|
2143 return iOther.ExitType()==EExitPending; |
|
2144 return iThread.ExitType()==EExitPending; |
|
2145 } |
|
2146 |
|
2147 void CProcess::LeaveIfDied() //Can Leave |
|
2148 { |
|
2149 User::After(200000); //0.2 secs |
|
2150 if (StillAlive()) |
|
2151 return; |
|
2152 if (iCreated&eOtherCreated) |
|
2153 User::Leave(iOther.ExitReason()); |
|
2154 User::Leave(iThread.ExitReason()); |
|
2155 } |
|
2156 |
|
2157 const TInt KFirstInstanceId = 1; |
|
2158 const TInt KOtherInstanceId = 2; |
|
2159 |
|
2160 TBool CProcess::ProcessDied(TInt aScreenNo/*=KDefaultScreen*/) |
|
2161 { |
|
2162 _LIT(pName,"TAutoServer*"); |
|
2163 TFindProcess find(pName); |
|
2164 TFullName name; |
|
2165 |
|
2166 TBool found = EFalse; |
|
2167 TInt instanceId = aScreenNo==KDefaultScreen? KFirstInstanceId : KOtherInstanceId; |
|
2168 // find the correct instance of the process |
|
2169 // required in multi display test |
|
2170 while (!found && find.Next(name)==KErrNone) |
|
2171 { |
|
2172 TPtrC scrId = name.Right(1); |
|
2173 TInt id; |
|
2174 TLex lex(scrId); |
|
2175 lex.Val(id); |
|
2176 if (id==instanceId) |
|
2177 found = ETrue; |
|
2178 } |
|
2179 if (!found) |
|
2180 return EFalse; |
|
2181 |
|
2182 RProcess p; |
|
2183 p.Open(name); |
|
2184 if (p.Id()!=RProcess().Id()) |
|
2185 return EFalse; |
|
2186 p.Close(); |
|
2187 return (find.Next(name)!=KErrNone); |
|
2188 } |
|
2189 |
|
2190 TInt CProcess::ThreadInit(TAny *aPtr) |
|
2191 { |
|
2192 __UHEAP_MARK; |
|
2193 TInt err=KErrNone; |
|
2194 CTrapCleanup* CleanUpStack=CTrapCleanup::New(); |
|
2195 if (CleanUpStack==NULL) |
|
2196 err=KErrNoMemory; |
|
2197 else |
|
2198 { |
|
2199 TRAP(err,InitialiseL(STATIC_CAST(TThreadStartUp*,aPtr))) |
|
2200 delete CleanUpStack; |
|
2201 } |
|
2202 __UHEAP_MARKEND; |
|
2203 return(err); |
|
2204 } |
|
2205 |
|
2206 void CProcess::InitialiseL(TThreadStartUp* aPtr) |
|
2207 { |
|
2208 CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; |
|
2209 CActiveScheduler::Install(activeScheduler); |
|
2210 CleanupStack::PushL(activeScheduler); |
|
2211 aPtr->iInitFunction(aPtr->iParam); |
|
2212 CActiveScheduler::Start(); |
|
2213 CleanupStack::PopAndDestroy(activeScheduler); |
|
2214 } |
|
2215 |
|
2216 TInt CProcess::SimpleThreadInit(TAny *aPtr) |
|
2217 { |
|
2218 __UHEAP_MARK; |
|
2219 TInt err=KErrNone; |
|
2220 CTrapCleanup* CleanUpStack=CTrapCleanup::New(); |
|
2221 if (CleanUpStack==NULL) |
|
2222 err=KErrNoMemory; |
|
2223 else |
|
2224 { |
|
2225 TThreadStartUp* ptr=STATIC_CAST(TThreadStartUp*,aPtr); |
|
2226 ptr->iInitFunction(ptr->iParam); |
|
2227 delete CleanUpStack; |
|
2228 } |
|
2229 __UHEAP_MARKEND; |
|
2230 return(err); |
|
2231 } |
|
2232 |
|
2233 /*CMinWin*/ |
|
2234 |
|
2235 CMinWin::CMinWin(TInt aScreenNo): iScreenNo(aScreenNo) |
|
2236 {} |
|
2237 |
|
2238 void CMinWin::ConstructL() |
|
2239 { |
|
2240 User::LeaveIfError(iWs.Connect()); |
|
2241 iScr=new(ELeave) CWsScreenDevice(iWs); |
|
2242 User::LeaveIfError(iScr->Construct(iScreenNo)); |
|
2243 iGroup=RWindowGroup(iWs); |
|
2244 User::LeaveIfError(iGroup.Construct(8970+iScreenNo,ETrue)); |
|
2245 iWin=RWindow(iWs); |
|
2246 User::LeaveIfError(iWin.Construct((RWindowTreeNode)iGroup,(TUint32)this)); |
|
2247 iRect=TSize(10,10); |
|
2248 iWin.SetExtent(TPoint(0,0),iRect.Size()); |
|
2249 iWin.SetRequiredDisplayMode(EColor256); |
|
2250 iWin.SetBackgroundColor(KRgbGreen); |
|
2251 iWin.Activate(); |
|
2252 iGc=new(ELeave) CWindowGc(iScr); |
|
2253 User::LeaveIfError(iGc->Construct()); |
|
2254 |
|
2255 Draw(iRect); |
|
2256 iWs.Flush(); |
|
2257 } |
|
2258 |
|
2259 CMinWin::~CMinWin() |
|
2260 { |
|
2261 delete iGc; |
|
2262 iWin.Close(); |
|
2263 iGroup.Close(); |
|
2264 delete iScr; |
|
2265 iWs.Close(); |
|
2266 } |
|
2267 |
|
2268 void CMinWin::Draw(const TRect& aRect) |
|
2269 { |
|
2270 iWin.BeginRedraw(); |
|
2271 iGc->Activate(iWin); |
|
2272 iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2273 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2274 iGc->SetBrushColor(KRgbGreen); |
|
2275 iGc->DrawRect(aRect); |
|
2276 iGc->Deactivate(); |
|
2277 iWin.EndRedraw(); |
|
2278 } |
|
2279 |
|
2280 |
|
2281 /*CTimeOut*/ |
|
2282 |
|
2283 void CTimeOut::ConstructL() |
|
2284 { |
|
2285 CTimer::ConstructL(); |
|
2286 CActiveScheduler::Add(this); |
|
2287 } |
|
2288 |
|
2289 void CTimeOut::Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack) |
|
2290 { |
|
2291 iCallBack=aCallBack; |
|
2292 After(aInterval); |
|
2293 } |
|
2294 |
|
2295 void CTimeOut::RunL() |
|
2296 { |
|
2297 iCallBack.CallBack(); |
|
2298 } |
|
2299 |
|
2300 /* |
|
2301 * Simply returns the DisplayMode as a string. Used to display mode details on test results. |
|
2302 */ |
|
2303 GLDEF_C TPtrC DisplayModeAsString(TDisplayMode aMode) |
|
2304 { |
|
2305 |
|
2306 TPtrC modeAsString; |
|
2307 |
|
2308 switch(aMode) |
|
2309 { |
|
2310 case ENone: |
|
2311 _LIT(KENoneMode,"ENone"); |
|
2312 modeAsString.Set(KENoneMode); |
|
2313 break; |
|
2314 case EGray2: |
|
2315 _LIT(KEGray2Mode,"EGray2"); |
|
2316 modeAsString.Set(KEGray2Mode); |
|
2317 break; |
|
2318 case EGray4: |
|
2319 _LIT(KEGray4Mode,"EGray4"); |
|
2320 modeAsString.Set(KEGray4Mode); |
|
2321 break; |
|
2322 case EGray16: |
|
2323 _LIT(KEGray16Mode,"EGray16"); |
|
2324 modeAsString.Set(KEGray16Mode); |
|
2325 break; |
|
2326 case EGray256: |
|
2327 _LIT(KEGray256Mode,"EGray256"); |
|
2328 modeAsString.Set(KEGray256Mode); |
|
2329 break; |
|
2330 case EColor16: |
|
2331 _LIT(KEColor16Mode,"EColor16"); |
|
2332 modeAsString.Set(KEColor16Mode); |
|
2333 break; |
|
2334 case EColor256: |
|
2335 _LIT(KEColor256Mode,"EColor256"); |
|
2336 modeAsString.Set(KEColor256Mode); |
|
2337 break; |
|
2338 case EColor64K: |
|
2339 _LIT(KEColor64KMode,"EColor64K"); |
|
2340 modeAsString.Set(KEColor64KMode); |
|
2341 break; |
|
2342 case EColor16M: |
|
2343 _LIT(KEColor16MMode,"EColor16M"); |
|
2344 modeAsString.Set(KEColor16MMode); |
|
2345 break; |
|
2346 case EColor4K: |
|
2347 _LIT(KEColor4KMode,"EColor4K"); |
|
2348 modeAsString.Set(KEColor4KMode); |
|
2349 break; |
|
2350 case EColor16MU: |
|
2351 _LIT(KEColor16MUMode,"EColor16MU"); |
|
2352 modeAsString.Set(KEColor16MUMode); |
|
2353 break; |
|
2354 case EColor16MA: |
|
2355 _LIT(KEColor16MAMode,"EColor16MA"); |
|
2356 modeAsString.Set(KEColor16MAMode); |
|
2357 break; |
|
2358 case EColor16MAP: |
|
2359 _LIT(KEColor16MAPMode,"EColor16MAP"); |
|
2360 modeAsString.Set(KEColor16MAPMode); |
|
2361 break; |
|
2362 default: |
|
2363 _LIT(KUnknownMode,"Unknown"); |
|
2364 modeAsString.Set(KUnknownMode); |
|
2365 break; |
|
2366 } |
|
2367 |
|
2368 return modeAsString; |
|
2369 } |
|
2370 |
|
2371 // Check if an area of a bitmap is of a certain color |
|
2372 GLDEF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare) |
|
2373 { |
|
2374 const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy(default) or exact compare? |
|
2375 |
|
2376 TBool result = ETrue; |
|
2377 /* TInt mismatchedPixels = 0; */ // -- Useful for debugging |
|
2378 TRgb bitmapPix = TRgb(0,0,0,0); //testWin Pixel |
|
2379 for (TInt x = 0; x < aArea.Size().iWidth; x++) |
|
2380 { |
|
2381 for (TInt y = 0; y < aArea.Size().iHeight; y++) |
|
2382 { |
|
2383 aBitmap.GetPixel(bitmapPix, TPoint(x,y)); |
|
2384 |
|
2385 //Check if there are differeces in color between the bitmap and the test color |
|
2386 if(((TReal)abs(bitmapPix.Red() - aCheckColor.Red())/255) > errorLimit || |
|
2387 ((TReal)abs(bitmapPix.Blue() - aCheckColor.Blue())/255) > errorLimit || |
|
2388 ((TReal)abs(bitmapPix.Green() - aCheckColor.Green())/255) > errorLimit || |
|
2389 ((TReal)abs(bitmapPix.Alpha() - aCheckColor.Alpha())/255) > errorLimit) |
|
2390 { |
|
2391 /* mismatchedPixels++; */ // -- Useful for debugging |
|
2392 result = EFalse; |
|
2393 break; |
|
2394 } |
|
2395 } |
|
2396 } |
|
2397 |
|
2398 /* INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); */ // -- Useful for debugging |
|
2399 return result; |
|
2400 } |
|
2401 |
|
2402 // Compare a section of two bitmaps |
|
2403 GLDEF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare) |
|
2404 { |
|
2405 const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? |
|
2406 |
|
2407 TBool result = ETrue; |
|
2408 |
|
2409 if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) |
|
2410 { |
|
2411 RDebug::Printf(" DisplayMode difference %d, %d", aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); |
|
2412 } |
|
2413 |
|
2414 TRgb bitmap1Pix = TRgb(0,0,0,0); |
|
2415 TRgb bitmap2Pix = TRgb(0,0,0,0); |
|
2416 for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) |
|
2417 { |
|
2418 for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) |
|
2419 { |
|
2420 aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); |
|
2421 aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); |
|
2422 |
|
2423 //Check if there are differences between the colors of the two bitmaps |
|
2424 if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || |
|
2425 ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || |
|
2426 ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || |
|
2427 ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) |
|
2428 { |
|
2429 /* |
|
2430 * There was a difference so return without checking the rest of the |
|
2431 * bitmap. If you are seeing Lossy compare errors, and want to diagnose |
|
2432 * further, consider switching over to using a recording version of this |
|
2433 * function, LossyCompareBitmapRecord() |
|
2434 */ |
|
2435 result = EFalse; |
|
2436 break; |
|
2437 } |
|
2438 } |
|
2439 } |
|
2440 |
|
2441 return result; |
|
2442 } |
|
2443 |
|
2444 /** |
|
2445 * Compare two bitmaps, optionally a lossy comparison, recording any differences and saving bitmaps |
|
2446 * |
|
2447 * @param aBitmap1 Bitmap being checked |
|
2448 * @param aBitmap2 Reference Bitmap |
|
2449 * @param aCompareRect Area of bitmap to compare |
|
2450 * @param aLossyCompare ETrue means use a lossy compare strategy, else do an exact compare |
|
2451 * @param aPixelsDifferent Returned value representing the number of pixels which are different |
|
2452 * @param aLogger Facility for logging to be reported by this function |
|
2453 * @return ETrue if the bitmaps are the same (or similar). |
|
2454 * Otherwise EFalse, with logging reporting the differences, and bitmaps saved in c:\logs\ |
|
2455 * @pre c:\logs directory must exist |
|
2456 */ |
|
2457 GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger) |
|
2458 { |
|
2459 const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? |
|
2460 |
|
2461 TBool result = ETrue; |
|
2462 TInt mismatchedPixels = 0; |
|
2463 TRgb bitmap1Pix = TRgb(0,0,0,0); |
|
2464 TRgb bitmap2Pix = TRgb(0,0,0,0); |
|
2465 if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) |
|
2466 { |
|
2467 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, |
|
2468 _L(" DisplayMode difference %d, %d"), aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); |
|
2469 } |
|
2470 for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) |
|
2471 { |
|
2472 for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) |
|
2473 { |
|
2474 aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); |
|
2475 aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); |
|
2476 |
|
2477 //Check if there are differences between the colors of the two bitmaps |
|
2478 if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || |
|
2479 ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || |
|
2480 ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || |
|
2481 ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) |
|
2482 { |
|
2483 mismatchedPixels++; |
|
2484 |
|
2485 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, |
|
2486 _L(" Pixel difference %d,%d: %d"),x,y, bitmap1Pix.Difference(bitmap2Pix)); |
|
2487 result = EFalse; |
|
2488 // we loop around again to pick up all the differences |
|
2489 } |
|
2490 } |
|
2491 } |
|
2492 aPixelsDifferent = mismatchedPixels; |
|
2493 |
|
2494 /* |
|
2495 * When the bitmaps are different, we store them locally in c:\\logs in |
|
2496 * timestamped files. Save() is a non-const method; this is why aBitmap1 |
|
2497 * and aBitmap2 are non-const. Saving can fail, perhaps because we have |
|
2498 * exceeded storage limits. |
|
2499 */ |
|
2500 if (!result) |
|
2501 { |
|
2502 TTime now; |
|
2503 now.UniversalTime(); |
|
2504 TInt timestamp = I64INT(now.Int64() & 0x7fffffffu); |
|
2505 timestamp/=1000; // a millisecond resolution is easier to track |
|
2506 TFileName mbmFileSrc; |
|
2507 mbmFileSrc.Format (_L("c:\\logs\\%d_LossyCompareBitmap1.mbm"), timestamp); |
|
2508 TFileName mbmFileDst; |
|
2509 mbmFileDst.Format (_L("c:\\logs\\%d_LossyCompareBitmap2.mbm"), timestamp); |
|
2510 TInt saveResult1; |
|
2511 TInt saveResult2; |
|
2512 saveResult1 = aBitmap1.Save(mbmFileSrc); |
|
2513 saveResult2 = aBitmap2.Save(mbmFileDst); |
|
2514 if (saveResult1 == KErrNone && saveResult2 == KErrNone) |
|
2515 { |
|
2516 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, |
|
2517 _L(" Bitmaps are different: see %S, %S"), &mbmFileSrc, &mbmFileDst); |
|
2518 } |
|
2519 else |
|
2520 { |
|
2521 aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, |
|
2522 _L(" Bitmaps are different, but could not save files into c:\\logs : %d %d"), saveResult1, saveResult2); |
|
2523 } |
|
2524 } |
|
2525 |
|
2526 return result; |
|
2527 } |
|
2528 |
|
2529 // Check if an area of a screen is of a certain color |
|
2530 GLDEF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor) |
|
2531 { |
|
2532 aScreen.CopyScreenToBitmap(&aBitmap, aArea); |
|
2533 return LossyCheckBlankBitmap(aBitmap, aArea, aCheckColor); |
|
2534 } |
|
2535 |
|
2536 // Compare a section of two windows on the screen |
|
2537 GLDEF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect) |
|
2538 { |
|
2539 aScreen.CopyScreenToBitmap(&aBitmap1, aCompareRect); |
|
2540 aScreen.CopyScreenToBitmap(&aBitmap2, aCompareRect); |
|
2541 return LossyCompareBitmap(aBitmap1, aBitmap2, aCompareRect); |
|
2542 } |
|
2543 |