|
1 // Copyright (c) 1996-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 // Test backed up windows |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include "TBACKUPW.H" |
|
25 |
|
26 CTBackedUpWindow::CTBackedUpWindow(CTestStep* aStep): |
|
27 CTWsGraphicsBase(aStep) |
|
28 { |
|
29 } |
|
30 |
|
31 |
|
32 void CTBackedUpWindow::CheckWindow(CFbsBitmap *aBitmap) |
|
33 { |
|
34 TPoint oldPos=iBackedUpWindow.Position(); |
|
35 iBackedUpWindow.SetPosition(TPoint(0,0)); |
|
36 |
|
37 iCheckWindow.SetVisible(ETrue); |
|
38 iCheckWindow.SetPosition(iCheckPos); |
|
39 |
|
40 iCheckWindow.BeginRedraw(); |
|
41 TheGc->Activate(iCheckWindow); |
|
42 TheGc->BitBlt(TPoint(0,0), aBitmap); |
|
43 TheGc->Deactivate(); |
|
44 iCheckWindow.EndRedraw(); |
|
45 |
|
46 TheClient->iWs.Flush(); |
|
47 TheClient->WaitForRedrawsToFinish(); |
|
48 TBool retVal = TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)); |
|
49 TEST(retVal); |
|
50 if (!retVal) |
|
51 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)) return value - Expected: %d , Actual: %d"), ETrue, retVal); |
|
52 |
|
53 iCheckWindow.SetVisible(EFalse); |
|
54 iBackedUpWindow.SetPosition(oldPos); |
|
55 } |
|
56 |
|
57 void CTBackedUpWindow::CheckWindow() |
|
58 { |
|
59 CheckWindow(&iBitmap); |
|
60 } |
|
61 |
|
62 void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam) |
|
63 { |
|
64 TheGc->Activate(iBackedUpWindow); |
|
65 Draw(aDrawFunc, aParam, TheGc, iBitGc); |
|
66 TheGc->Deactivate(); |
|
67 } |
|
68 |
|
69 void CTBackedUpWindow::DrawWithTwoGcsL() |
|
70 { |
|
71 RBlankWindow blank(TheClient->iWs); |
|
72 User::LeaveIfError(blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle)); |
|
73 blank.Activate(); |
|
74 CWindowGc *gc2; |
|
75 User::LeaveIfError(TheClient->iScreen->CreateContext(gc2)); |
|
76 CleanupStack::PushL(gc2); |
|
77 |
|
78 CFbsFont *font1; |
|
79 TFontSpec fspec(KTestFontTypefaceName,200); |
|
80 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); |
|
81 CFbsFont *font2; |
|
82 TFontSpec fspec2(KTestFontTypefaceName,400); |
|
83 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); |
|
84 |
|
85 gc2->Activate(iBackedUpWindow); |
|
86 gc2->UseFont(font2); |
|
87 TheGc->Activate(iBackedUpWindow); |
|
88 TheGc->UseFont(font1); |
|
89 _LIT(KText,"Testing123"); |
|
90 TheGc->DrawText(KText,TPoint(20,20)); |
|
91 gc2->DrawText(KText,TPoint(20,40)); |
|
92 iBitGc->UseFont(font1); |
|
93 iBitGc->DrawText(KText,TPoint(20,20)); |
|
94 iBitGc->UseFont(font2); |
|
95 iBitGc->DrawText(KText,TPoint(20,40)); |
|
96 iBitGc->DiscardFont(); |
|
97 TheGc->Deactivate(); |
|
98 TheClient->iScreen->ReleaseFont(font2); |
|
99 TheClient->iScreen->ReleaseFont(font1); |
|
100 CleanupStack::PopAndDestroy(); |
|
101 blank.Close(); |
|
102 } |
|
103 |
|
104 void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc1, CBitmapContext *gc2) //DDD |
|
105 { |
|
106 CBitmapContext *gc; |
|
107 for(TInt mode=0;mode<2;mode++) |
|
108 { |
|
109 if (mode==0) |
|
110 gc=gc1; |
|
111 else |
|
112 gc=gc2; |
|
113 gc->Reset(); |
|
114 switch(aDrawFunc) |
|
115 { |
|
116 case 0: |
|
117 gc->SetBrushColor(*((TRgb *)aParam)); |
|
118 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
119 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
120 gc->DrawRect(TRect(iSize)); |
|
121 break; |
|
122 case 1: |
|
123 { |
|
124 TSize half(iSize.iWidth/2,iSize.iHeight/2); |
|
125 gc->DrawEllipse(TRect(half)); |
|
126 gc->DrawEllipse(TRect(TPoint(0,half.iHeight),half)); |
|
127 TRect rect1(half); |
|
128 gc->SetOrigin(TPoint(half.iWidth,0)); |
|
129 gc->SetClippingRect(rect1); |
|
130 gc->DrawEllipse(rect1); |
|
131 gc->SetOrigin(TPoint(half.iWidth,half.iHeight)); |
|
132 gc->SetClippingRect(rect1); |
|
133 gc->DrawEllipse(rect1); |
|
134 gc->SetOrigin(TPoint(0,0)); |
|
135 gc->CancelClippingRect(); |
|
136 } |
|
137 break; |
|
138 case 2: |
|
139 { |
|
140 TInt param= *((TInt *)aParam); |
|
141 if (param&0x1) |
|
142 gc->DrawLine(TPoint(param+(param*27)%iSize.iWidth,0), |
|
143 TPoint(iSize.iWidth-((param<<1)+(param*19)%iSize.iWidth),iSize.iHeight)); |
|
144 else |
|
145 gc->DrawLine(TPoint(0, (param<<1)+(param*7)%iSize.iHeight), |
|
146 TPoint(iSize.iWidth,param+(param*13)%iSize.iHeight)); |
|
147 } |
|
148 break; |
|
149 case 3: |
|
150 { |
|
151 TPoint pos; |
|
152 for(;pos.iX<iSize.iWidth;pos.iX+=10) |
|
153 gc->DrawLine(pos,pos+TSize(0,iSize.iHeight)); |
|
154 for(pos.iX=0;pos.iY<iSize.iHeight;pos.iY+=10) |
|
155 gc->DrawLine(pos,pos+TSize(iSize.iWidth,0)); |
|
156 } |
|
157 break; |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 CTBackedUpWindow::~CTBackedUpWindow() |
|
163 { |
|
164 iBackedUpWindow.Close(); |
|
165 iCheckWindow.Close(); |
|
166 iOomFrontWindow.Close(); |
|
167 delete iBitGc; |
|
168 delete iBitmapDevice; |
|
169 delete iTestBitmap; |
|
170 delete iMaskBitmap; |
|
171 } |
|
172 |
|
173 void CopyToGray4L(CFbsBitmap*& aDestBitmap,const CFbsBitmap& aSrcBitmap) |
|
174 { |
|
175 aDestBitmap=new(ELeave) CFbsBitmap(); |
|
176 CleanupStack::PushL(aDestBitmap); |
|
177 User::LeaveIfError(aDestBitmap->Create(aSrcBitmap.SizeInPixels(),EGray4)); |
|
178 CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aDestBitmap); |
|
179 CleanupStack::PushL(device); |
|
180 CFbsBitGc* gc; |
|
181 User::LeaveIfError(device->CreateContext(gc)); |
|
182 gc->BitBlt(TPoint(),&aSrcBitmap); |
|
183 delete gc; |
|
184 CleanupStack::PopAndDestroy(device); |
|
185 CleanupStack::Pop(aDestBitmap); |
|
186 } |
|
187 |
|
188 void CTBackedUpWindow::ConstructL() |
|
189 { |
|
190 iBackedUpWindow=RBackedUpWindow(TheClient->iWs); |
|
191 iBackedUpWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); |
|
192 TSize size=TheClient->iScreen->SizeInTwips(); |
|
193 iSize=TheClient->iScreen->SizeInPixels(); |
|
194 iSize.iWidth>>=1; |
|
195 iSize.iHeight>>=1; |
|
196 size.iWidth>>=1; |
|
197 size.iHeight>>=1; |
|
198 size.iWidth-=1; //Modification to get the mapping factor the same as the screen |
|
199 size.iHeight-=1; //Ditto |
|
200 iWinPos.SetXY(iSize.iWidth>>1,iSize.iHeight>>1); |
|
201 User::LeaveIfError(iBackedUpWindow.SetExtentErr(iWinPos,iSize)); |
|
202 iBackedUpWindow.Activate(); |
|
203 |
|
204 iCheckPos.SetXY(iSize.iWidth,0); |
|
205 iCheckWindow=RWindow(TheClient->iWs); |
|
206 iCheckWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
207 iCheckWindow.SetSize(iSize); |
|
208 iCheckWindow.SetVisible(EFalse); |
|
209 iCheckWindow.Activate(); |
|
210 |
|
211 TInt col,grey; |
|
212 TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(col,grey); |
|
213 User::LeaveIfError(iBitmap.Create(iSize,defMode)); |
|
214 iBitmap.SetSizeInTwips(size); |
|
215 iBitmapDevice=CFbsBitmapDevice::NewL(&iBitmap); |
|
216 User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc)); |
|
217 |
|
218 TRgb rgb(TRgb::Gray4(2)); |
|
219 Draw(0,&rgb); |
|
220 |
|
221 iTestBitmap=new(ELeave) CFbsBitmap(); |
|
222 User::LeaveIfError(iTestBitmap->Load(TEST_BITMAP_NAME,0)); |
|
223 iTestBitmap->SetSizeInTwips(TSize(1500,750)); |
|
224 iMaskBitmap=new(ELeave) CFbsBitmap(); |
|
225 User::LeaveIfError(iMaskBitmap->Load(TEST_BITMAP_NAME,0)); |
|
226 TDisplayMode defMode2=iMaskBitmap->DisplayMode(); |
|
227 if (defMode>EGray4) |
|
228 { |
|
229 CFbsBitmap* bitmap=iTestBitmap; |
|
230 CopyToGray4L(iTestBitmap,*bitmap); |
|
231 delete bitmap; |
|
232 bitmap=iMaskBitmap; |
|
233 CopyToGray4L(iMaskBitmap,*bitmap); |
|
234 delete bitmap; |
|
235 } |
|
236 defMode2=iMaskBitmap->DisplayMode(); |
|
237 defMode2=iMaskBitmap->DisplayMode(); |
|
238 } |
|
239 |
|
240 void CTBackedUpWindow::InvisVis() |
|
241 { |
|
242 iBackedUpWindow.SetVisible(EFalse); |
|
243 TheClient->iWs.Flush(); |
|
244 iBackedUpWindow.SetVisible(ETrue); |
|
245 TheClient->iWs.Flush(); |
|
246 } |
|
247 |
|
248 void CTBackedUpWindow::WindowOnTop() |
|
249 { |
|
250 RBlankWindow blank(TheClient->iWs); |
|
251 blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
252 blank.Activate(); |
|
253 blank.Close(); |
|
254 TheClient->iWs.Flush(); |
|
255 |
|
256 TPoint pos; |
|
257 TInt sizeMode=0; |
|
258 TInt draw=13; |
|
259 |
|
260 for(pos.iX=-iSize.iWidth;pos.iX<iSize.iWidth;pos.iX+=50) |
|
261 for(pos.iY=-iSize.iHeight;pos.iY<iSize.iHeight;pos.iY+=50) |
|
262 { |
|
263 blank=RBlankWindow(TheClient->iWs); |
|
264 blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
265 blank.SetColor(TRgb::Gray256(220)); |
|
266 blank.SetShadowHeight(2); |
|
267 blank.SetExtent(pos+iWinPos,TSize((sizeMode&0x1)?iSize.iWidth>>1:iSize.iWidth<<1,(sizeMode&0x2)?iSize.iHeight>>1:iSize.iHeight<<1)); |
|
268 sizeMode=(sizeMode+1)%4; |
|
269 blank.Activate(); |
|
270 Draw(2,&draw); |
|
271 TheClient->iWs.Flush(); |
|
272 draw++; |
|
273 blank.Close(); |
|
274 } |
|
275 } |
|
276 |
|
277 void CTBackedUpWindow::Resize() |
|
278 { |
|
279 RBlankWindow blank(TheClient->iWs); |
|
280 blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
281 blank.SetColor(TRgb::Gray256(128)); |
|
282 blank.Activate(); |
|
283 TInt xtop=(iSize.iWidth)-(iSize.iWidth>>2); |
|
284 TInt ytop=(iSize.iHeight)-(iSize.iHeight>>2); |
|
285 for(TInt winMode=0;winMode<3;winMode++) |
|
286 { |
|
287 switch(winMode) |
|
288 { |
|
289 case 0: |
|
290 blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>1)); |
|
291 break; |
|
292 case 1: |
|
293 blank.SetExtent(TPoint(xtop,0),TSize(iSize.iWidth>>1,iSize.iHeight)); |
|
294 break; |
|
295 case 2: |
|
296 blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight>>1)); |
|
297 break; |
|
298 } |
|
299 blank.SetShadowHeight(winMode); |
|
300 TPoint oldPos=iBackedUpWindow.Position(); |
|
301 TPoint pos=oldPos; |
|
302 for(TUint i=0;i<sizeof(moveList)/sizeof(moveList[0]);i++) |
|
303 { |
|
304 pos+=moveList[i]; |
|
305 iBackedUpWindow.SetPosition(pos); |
|
306 TheClient->iWs.Flush(); |
|
307 } |
|
308 iBackedUpWindow.SetPosition(oldPos); |
|
309 } |
|
310 blank.Close(); |
|
311 } |
|
312 |
|
313 void CTBackedUpWindow::ChildWindows() |
|
314 { |
|
315 TPoint pos; |
|
316 TInt sizeMode=0; |
|
317 TInt draw=13; |
|
318 RBlankWindow blank(TheClient->iWs); |
|
319 for(pos.iX=-(iSize.iWidth>>1);pos.iX<iSize.iWidth;pos.iX+=33) |
|
320 for(pos.iY=-(iSize.iHeight>>1);pos.iY<iSize.iHeight;pos.iY+=33) |
|
321 { |
|
322 blank.Construct(iBackedUpWindow,ENullWsHandle); |
|
323 blank.SetColor(TRgb::Gray256(220)); |
|
324 blank.SetShadowHeight(2); |
|
325 blank.SetExtent(pos,TSize((sizeMode&0x1)?iSize.iWidth>>2:iSize.iWidth,(sizeMode&0x2)?iSize.iHeight>>2:iSize.iHeight)); |
|
326 sizeMode=(sizeMode+1)%4; |
|
327 blank.Activate(); |
|
328 Draw(2,&draw); |
|
329 TheClient->iWs.Flush(); |
|
330 draw++; |
|
331 blank.Close(); |
|
332 } |
|
333 } |
|
334 |
|
335 void CTBackedUpWindow::DupBitmapTestL() |
|
336 { |
|
337 INFO_PRINTF1(_L("AUTO Dup Bitmap Test ")); |
|
338 CFbsBitmap *dup=new(ELeave) CFbsBitmap(); |
|
339 dup->Duplicate(iBackedUpWindow.BitmapHandle()); |
|
340 CheckWindow(dup); |
|
341 TRgb rgb(TRgb::Gray4(1)); |
|
342 Draw(0,&rgb); |
|
343 CheckWindow(dup); |
|
344 INFO_PRINTF1(_L(" Done Window Drawing Test")); |
|
345 |
|
346 CFbsBitmapDevice *dupDevice=NULL; |
|
347 TRAPD(err,dupDevice=CFbsBitmapDevice::NewL(dup)); |
|
348 CFbsBitGc *gc; |
|
349 if (err==KErrNone && dupDevice->CreateContext(gc)==KErrNone) |
|
350 { |
|
351 Draw(3,NULL,gc,iBitGc); // Draw directly to backup bitmap (and test bitmap) |
|
352 iBackedUpWindow.UpdateScreen(); |
|
353 INFO_PRINTF1(_L(" First Bitmap Drawing")); |
|
354 CheckWindow(); |
|
355 TRgb rgb(TRgb::Gray256(128)); |
|
356 TInt col,grey; |
|
357 if (TheClient->iWs.GetDefModeMaxNumColors(col,grey)>EGray4) |
|
358 rgb=TRgb::Gray4(2); |
|
359 Draw(0,&rgb,gc,iBitGc); |
|
360 Draw(1,NULL,gc,iBitGc); |
|
361 iBackedUpWindow.UpdateScreen(TRegionFix<1>(TRect(iSize))); |
|
362 INFO_PRINTF1(_L(" Second Bitmap Drawing")); |
|
363 CheckWindow(); |
|
364 delete gc; |
|
365 } |
|
366 delete dupDevice; |
|
367 delete dup; |
|
368 } |
|
369 |
|
370 void CTBackedUpWindow::UpdateBitmapTestL() |
|
371 { |
|
372 INFO_PRINTF1(_L("AUTO UpdateBitmap ")); |
|
373 CheckWindow(); |
|
374 CFbsBitmap *dup=new(ELeave) CFbsBitmap(); |
|
375 dup->Duplicate(iBackedUpWindow.BitmapHandle()); |
|
376 Draw(3,NULL); |
|
377 iBackedUpWindow.UpdateBackupBitmap(); |
|
378 INFO_PRINTF1(_L(" First Drawing")); |
|
379 CheckWindow(dup); |
|
380 TRgb rgb; |
|
381 if (iSupState==0) |
|
382 rgb=TRgb::Gray256(128); |
|
383 else |
|
384 rgb=TRgb::Gray4(2); |
|
385 Draw(0,&rgb); |
|
386 Draw(1,NULL); |
|
387 iBackedUpWindow.UpdateBackupBitmap(); |
|
388 INFO_PRINTF1(_L(" Second Drawing")); |
|
389 CheckWindow(dup); |
|
390 delete dup; |
|
391 } |
|
392 |
|
393 void CTBackedUpWindow::OOML() |
|
394 { |
|
395 iOomFrontWindow=RBlankWindow(TheClient->iWs); |
|
396 TSize size(iBackedUpWindow.Size()); |
|
397 size.iWidth>>=1; |
|
398 size.iHeight>>=1; |
|
399 TPoint pos(size.iWidth*3/2,size.iHeight*3/2); |
|
400 iOomFrontWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
401 iOomFrontWindow.SetColor(TRgb(TRgb::Gray4(1))); |
|
402 iOomFrontWindow.SetExtent(pos,size); |
|
403 iOomFrontWindow.Activate(); |
|
404 TheClient->iWs.Flush(); |
|
405 |
|
406 TPoint buwPos=iBackedUpWindow.Position(); |
|
407 TSize buwSize=iBackedUpWindow.Size(); |
|
408 for(TInt count=0;count<100;count++) |
|
409 { |
|
410 iOomFrontWindow.SetVisible(ETrue); |
|
411 TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); |
|
412 iBackedUpWindow.SetPosition(buwPos+TPoint(10,5)); |
|
413 iBackedUpWindow.SetPosition(buwPos); |
|
414 iOomFrontWindow.SetSize(size+TSize(10,5)); |
|
415 iOomFrontWindow.SetSize(size); |
|
416 iBackedUpWindow.SetSizeErr(buwSize+TSize(13,7)); |
|
417 iBackedUpWindow.SetSizeErr(buwSize); |
|
418 iOomFrontWindow.SetVisible(EFalse); |
|
419 TheClient->iWs.HeapSetFail(RHeap::ENone,0); |
|
420 User::LeaveIfError(iBackedUpWindow.SetSizeErr(buwSize)); |
|
421 TheClient->WaitForRedrawsToFinish(); |
|
422 CheckWindow(); |
|
423 } |
|
424 |
|
425 iOomFrontWindow.Close(); |
|
426 } |
|
427 |
|
428 void CTBackedUpWindow::doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap) |
|
429 { |
|
430 TSize size=iBackedUpWindow.Size(); |
|
431 CFbsFont *aFont; |
|
432 _LIT(KFontName,"Swiss"); |
|
433 TFontSpec fspec(KFontName,190); |
|
434 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)aFont,fspec)); |
|
435 CFbsBitmap* aBitmap=iTestBitmap; |
|
436 CFbsBitmap* aMaskBitmap=iMaskBitmap; |
|
437 |
|
438 #include "DLLDRAW.H" // Draws to a Gc called 'gc' |
|
439 |
|
440 TheClient->iScreen->ReleaseFont(aFont); |
|
441 } |
|
442 |
|
443 void CTBackedUpWindow::AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap/*=ETrue*/) |
|
444 { |
|
445 aExtraDrawBitMap=EFalse; //Check out when bitblit scaling has changed again |
|
446 aBlank.SetVisible(ETrue); |
|
447 TheGc->Activate(iBackedUpWindow); |
|
448 TRAPD(err,doGraphicFunctionsL(TheGc,aExtraDrawBitMap)); |
|
449 TheGc->Deactivate(); |
|
450 User::LeaveIfError(err); |
|
451 iBitGc->Reset(); |
|
452 iBitGc->SetUserDisplayMode(EGray4); |
|
453 doGraphicFunctionsL(iBitGc,aExtraDrawBitMap); |
|
454 aBlank.SetVisible(EFalse); |
|
455 CheckWindow(); |
|
456 } |
|
457 |
|
458 void CTBackedUpWindow::AllGraphicFunctionsTestsL() |
|
459 { |
|
460 RBlankWindow blank(TheClient->iWs); |
|
461 TInt xtop=(iSize.iWidth)-(iSize.iWidth>>1); |
|
462 TInt ytop=(iSize.iHeight)-(iSize.iHeight>>1); |
|
463 blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); |
|
464 blank.SetColor(TRgb::Gray256(128)); |
|
465 blank.Activate(); |
|
466 blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>2)); |
|
467 AllGraphicFunctionsL(blank); |
|
468 blank.SetExtent(TPoint(0,ytop+10),TSize(iSize.iWidth,iSize.iHeight>>2)); |
|
469 AllGraphicFunctionsL(blank); |
|
470 blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); |
|
471 AllGraphicFunctionsL(blank,EFalse); |
|
472 blank.SetExtent(TPoint(xtop+(iSize.iWidth>>1),ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); |
|
473 AllGraphicFunctionsL(blank,EFalse); |
|
474 blank.SetExtent(TPoint(xtop+10,iSize.iHeight),TSize(iSize.iWidth,iSize.iHeight)); |
|
475 AllGraphicFunctionsL(blank,EFalse); |
|
476 blank.SetExtent(TPoint(xtop,ytop),iSize); |
|
477 AllGraphicFunctionsL(blank,EFalse); |
|
478 blank.SetExtent(TPoint(0,0),TSize(0,0)); |
|
479 AllGraphicFunctionsL(blank); |
|
480 blank.Close(); |
|
481 } |
|
482 |
|
483 void CTBackedUpWindow::RunTestCaseL(TInt /*aCurTestCase*/) |
|
484 { |
|
485 switch(iSupState) |
|
486 { |
|
487 case 0: |
|
488 for (TInt iSubTest=0;iSubTest<KLastSubtest;iSubTest++) |
|
489 { |
|
490 DoSubTestL(iSubTest); |
|
491 } |
|
492 iBackedUpWindow.MaintainBackup(); //Putting this line here is a work around |
|
493 break; |
|
494 case 1: |
|
495 for (TInt iSubTest=0;iSubTest<KLastSubtest;iSubTest++) |
|
496 { |
|
497 DoSubTestL(iSubTest); |
|
498 } |
|
499 break; |
|
500 default: |
|
501 TestComplete(); |
|
502 break; |
|
503 } |
|
504 iSupState++; |
|
505 } |
|
506 |
|
507 void CTBackedUpWindow::DoSubTestL(TInt iState) |
|
508 { |
|
509 _LIT(KTest0,"Simple draw"); |
|
510 _LIT(KTest1,"Resizing"); |
|
511 _LIT(KTest2,"Invisible/Visible"); |
|
512 _LIT(KTest3,"Windows on top"); |
|
513 _LIT(KTest4,"Child Windows"); |
|
514 _LIT(KTest5,"OOM"); |
|
515 _LIT(KTest6,"Update Bitmap"); |
|
516 _LIT(KTest7,"Bitmap duplicate"); |
|
517 _LIT(KTest8,"Two Graphic Contexts"); |
|
518 _LIT(KTest9,"All Graphic Functions"); |
|
519 _LIT(KTest10,"Reactivate"); |
|
520 _LIT(KTest11,"DoDrawCommand"); |
|
521 |
|
522 TRgb rgb1(255,255,255); |
|
523 TRgb rgb2(255,255,255); |
|
524 TRgb rgb3(255,255,255); |
|
525 TRgb rgb4(255,255,255); |
|
526 TRgb rgb5(255,255,255); |
|
527 TRgb rgb6(255,255,255); |
|
528 TRgb rgb7(255,255,255); |
|
529 TRgb color(TRgb::Gray4(2)); |
|
530 |
|
531 iTest->iState=iState; |
|
532 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
533 switch(iState) |
|
534 { |
|
535 /** |
|
536 @SYMTestCaseID GRAPHICS-WSERV-0202-0001 |
|
537 |
|
538 @SYMDEF DEF081259 |
|
539 |
|
540 @SYMTestCaseDesc Test drawing in a backed up window |
|
541 |
|
542 @SYMTestPriority High |
|
543 |
|
544 @SYMTestStatus Implemented |
|
545 |
|
546 @SYMTestActions Draw in a backed up window and a normal window and check |
|
547 the two drawings are the same |
|
548 |
|
549 @SYMTestExpectedResults The two drawings are exactly the same |
|
550 */ |
|
551 case 0: |
|
552 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0001")); |
|
553 iTest->LogSubTest(KTest0); |
|
554 Draw(1,NULL); |
|
555 CheckWindow(); |
|
556 break; |
|
557 /** |
|
558 @SYMTestCaseID GRAPHICS-WSERV-0202-0002 |
|
559 |
|
560 @SYMDEF DEF081259 |
|
561 |
|
562 @SYMTestCaseDesc Test drawing in a backed up window |
|
563 |
|
564 @SYMTestPriority High |
|
565 |
|
566 @SYMTestStatus Implemented |
|
567 |
|
568 @SYMTestActions Draw in a backed up window and a normal window and check |
|
569 the two drawings are the same |
|
570 |
|
571 @SYMTestExpectedResults The two drawings are exactly the same |
|
572 */ |
|
573 case 1: |
|
574 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0002")); |
|
575 iTest->LogSubTest(KTest1); |
|
576 Draw(0,&rgb1); |
|
577 Draw(3,NULL); |
|
578 Resize(); |
|
579 CheckWindow(); |
|
580 break; |
|
581 /** |
|
582 @SYMTestCaseID GRAPHICS-WSERV-0203 |
|
583 |
|
584 @SYMDEF DEF081259 |
|
585 |
|
586 @SYMTestCaseDesc Test making a backed up window invisible |
|
587 |
|
588 @SYMTestPriority High |
|
589 |
|
590 @SYMTestStatus Implemented |
|
591 |
|
592 @SYMTestActions Draw in a backed up window and a normal window, make |
|
593 the backed up window invisible then visible and |
|
594 then check the two drawings are the same |
|
595 |
|
596 @SYMTestExpectedResults The two drawings are exactly the same |
|
597 */ |
|
598 case 2: |
|
599 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0203")); |
|
600 iTest->LogSubTest(KTest2); |
|
601 Draw(0,&rgb2); |
|
602 Draw(1,NULL); |
|
603 InvisVis(); |
|
604 CheckWindow(); |
|
605 break; |
|
606 /** |
|
607 @SYMTestCaseID GRAPHICS-WSERV-0204 |
|
608 |
|
609 @SYMDEF DEF081259 |
|
610 |
|
611 @SYMTestCaseDesc Test drawing in a backed up window and then placing a |
|
612 window on top of it |
|
613 |
|
614 @SYMTestPriority High |
|
615 |
|
616 @SYMTestStatus Implemented |
|
617 |
|
618 @SYMTestActions Draw in a backed up window and a normal window, then |
|
619 place a window on top of the backed up window and then |
|
620 check the two drawings are the same |
|
621 |
|
622 @SYMTestExpectedResults The two drawings are exactly the same |
|
623 */ |
|
624 case 3: |
|
625 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0204")); |
|
626 iTest->LogSubTest(KTest3); |
|
627 //TRgb rgb(220,220,220); |
|
628 Draw(0,&rgb3); |
|
629 Draw(1,NULL); |
|
630 WindowOnTop(); |
|
631 CheckWindow(); |
|
632 break; |
|
633 /** |
|
634 @SYMTestCaseID GRAPHICS-WSERV-0205 |
|
635 |
|
636 @SYMDEF DEF081259 |
|
637 |
|
638 @SYMTestCaseDesc Test drawing in a backed up window and then drawing in |
|
639 a child window |
|
640 |
|
641 @SYMTestPriority High |
|
642 |
|
643 @SYMTestStatus Implemented |
|
644 |
|
645 @SYMTestActions Draw in a backed up window and a normal window, then |
|
646 create and draw in a child window and then |
|
647 check the two original drawings are the same |
|
648 |
|
649 @SYMTestExpectedResults The two drawings are exactly the same |
|
650 */ |
|
651 case 4: |
|
652 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0205")); |
|
653 iTest->LogSubTest(KTest4); |
|
654 Draw(0,&rgb4); |
|
655 Draw(3,NULL); |
|
656 ChildWindows(); |
|
657 CheckWindow(); |
|
658 break; |
|
659 /** |
|
660 @SYMTestCaseID GRAPHICS-WSERV-0206 |
|
661 |
|
662 @SYMDEF DEF081259 |
|
663 |
|
664 @SYMTestCaseDesc Out of memeory test for backed up windows |
|
665 |
|
666 @SYMTestPriority High |
|
667 |
|
668 @SYMTestStatus Implemented |
|
669 |
|
670 @SYMTestActions Out of memeory test for backed up windows |
|
671 |
|
672 @SYMTestExpectedResults Backed up window responds correctly when out |
|
673 of memory |
|
674 */ |
|
675 case 5: |
|
676 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0206")); |
|
677 iTest->LogSubTest(KTest5); |
|
678 if (!iTest->IsFullRomL()) |
|
679 { |
|
680 Draw(0,&rgb5); |
|
681 Draw(3,NULL); |
|
682 OOML(); |
|
683 CheckWindow(); |
|
684 } |
|
685 break; |
|
686 /** |
|
687 @SYMTestCaseID GRAPHICS-WSERV-0207 |
|
688 |
|
689 @SYMDEF DEF081259 |
|
690 |
|
691 @SYMTestCaseDesc Test updating a bitmap in a backed up window |
|
692 |
|
693 @SYMTestPriority High |
|
694 |
|
695 @SYMTestStatus Implemented |
|
696 |
|
697 @SYMTestActions Update a bitmap in a backed up window and a normal window |
|
698 and check the two bitmaps are the same |
|
699 |
|
700 @SYMTestExpectedResults The two bitmaps are exactly the same |
|
701 */ |
|
702 case 6: |
|
703 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0207")); |
|
704 iTest->LogSubTest(KTest6); |
|
705 Draw(0,&rgb6); |
|
706 Draw(1,NULL); |
|
707 UpdateBitmapTestL(); |
|
708 break; |
|
709 /** |
|
710 @SYMTestCaseID GRAPHICS-WSERV-0208 |
|
711 |
|
712 @SYMDEF DEF081259 |
|
713 |
|
714 @SYMTestCaseDesc Test updating a duplicate bitmap in a backed up window |
|
715 |
|
716 @SYMTestPriority High |
|
717 |
|
718 @SYMTestStatus Implemented |
|
719 |
|
720 @SYMTestActions Update a duplicated bitmap in a backed up window and a normal window |
|
721 and check the two bitmaps are the same |
|
722 |
|
723 @SYMTestExpectedResults The two bitmaps are exactly the same |
|
724 */ |
|
725 case 7: |
|
726 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0208")); |
|
727 if (iSupState==0) //Will fail unless the window is fully backup. |
|
728 break; |
|
729 iTest->LogSubTest(KTest7); |
|
730 Draw(0,&rgb7); |
|
731 Draw(1,NULL); |
|
732 DupBitmapTestL(); |
|
733 break; |
|
734 /** |
|
735 @SYMTestCaseID GRAPHICS-WSERV-0209 |
|
736 |
|
737 @SYMDEF DEF081259 |
|
738 |
|
739 @SYMTestCaseDesc Test drawing with two graphic contexts in a backed up window |
|
740 |
|
741 @SYMTestPriority High |
|
742 |
|
743 @SYMTestStatus Implemented |
|
744 |
|
745 @SYMTestActions Draw using two graphic contexts in a backed up window and a normal |
|
746 window and check the two drawings are the same |
|
747 |
|
748 @SYMTestExpectedResults The two drawings are exactly the same |
|
749 */ |
|
750 case 8: |
|
751 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0209")); |
|
752 iTest->LogSubTest(KTest8); |
|
753 Draw(0,&color); |
|
754 Draw(1,NULL); |
|
755 DrawWithTwoGcsL(); |
|
756 CheckWindow(); |
|
757 break; |
|
758 |
|
759 /** |
|
760 @SYMTestCaseID GRAPHICS-WSERV-0210 |
|
761 |
|
762 @SYMDEF DEF081259 |
|
763 |
|
764 @SYMTestCaseDesc Test drawing using all the graphic functions in a backed up window |
|
765 |
|
766 @SYMTestPriority High |
|
767 |
|
768 @SYMTestStatus Implemented |
|
769 |
|
770 @SYMTestActions Draw using all the graphic functions in a backed up window and a normal |
|
771 window and check the two drawings are the same |
|
772 |
|
773 @SYMTestExpectedResults The two drawings are exactly the same |
|
774 */ |
|
775 case 9: |
|
776 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0210")); |
|
777 iTest->LogSubTest(KTest9); |
|
778 if(TheClient->iScreen->SizeInPixels() == TSize(640,240)) |
|
779 AllGraphicFunctionsTestsL(); |
|
780 break; |
|
781 |
|
782 //A Coverage test, nothing spectacular just making the code |
|
783 //go into CWsGc::Reactivate |
|
784 case 10: |
|
785 { |
|
786 /** |
|
787 @SYMTestCaseID GRAPHICS-WSERV-0502 |
|
788 */ |
|
789 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0502")); |
|
790 iTest->LogSubTest(KTest10); |
|
791 TheGc->Deactivate(); |
|
792 RBackedUpWindow extentWindow; |
|
793 extentWindow=RBackedUpWindow(TheClient->iWs); |
|
794 extentWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); |
|
795 TheGc->Activate(extentWindow); |
|
796 TheClient->Flush(); |
|
797 User::LeaveIfError(extentWindow.SetExtentErr(TPoint(2,2), TSize(4,4))); |
|
798 extentWindow.Activate(); |
|
799 extentWindow.Close(); |
|
800 TheGc->Deactivate(); |
|
801 break; |
|
802 } |
|
803 |
|
804 //Coverage for various messages for CWsGc::DoDrawCommand |
|
805 case 11: |
|
806 { |
|
807 /** |
|
808 @SYMTestCaseID GRAPHICS-WSERV-0507 |
|
809 */ |
|
810 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0507")); |
|
811 iTest->LogSubTest(KTest11); |
|
812 TheGc->Activate(iBackedUpWindow); |
|
813 TheGc->Reset(); |
|
814 iBitGc->Reset(); |
|
815 iBitGc->SetUserDisplayMode(EGray4); |
|
816 |
|
817 // EWsGcOpDrawWsGraphic |
|
818 TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10)); |
|
819 |
|
820 //create a large junk buffer so that messages with Ptr suffix will be sent |
|
821 RBuf8 junkBuf8; |
|
822 RBuf junkBuf; |
|
823 junkBuf8.CreateMax(650); // a large enough buffer to sent as Ptr (this value used to crash the code before) |
|
824 junkBuf.CreateMax(650); // a large enough buffer to sent as Ptr |
|
825 for (int i=0; i<junkBuf.MaxLength()-1;i++) |
|
826 { |
|
827 junkBuf8[i] = 'A'; |
|
828 junkBuf[i] = 'A'; |
|
829 } |
|
830 junkBuf8[junkBuf8.MaxLength()-1] = '\0'; |
|
831 junkBuf[junkBuf.MaxLength()-1] = '\0'; |
|
832 |
|
833 // EWsGcOpDrawWsGraphicPtr |
|
834 TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10), junkBuf8); |
|
835 |
|
836 // Set font for drawing on screen |
|
837 CFbsFont *font1; |
|
838 TFontSpec fspec(KTestFontTypefaceName,200); |
|
839 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); |
|
840 TheGc->UseFont(font1); |
|
841 iBitGc->UseFont(font1); |
|
842 |
|
843 // EWsGcOpDrawTextPtr |
|
844 TheGc->DrawText(junkBuf, TPoint(0,0)); |
|
845 iBitGc->DrawText(junkBuf, TPoint(0,0)); |
|
846 |
|
847 // EWsGcOpDrawBoxText - unreachable 299-too lo, 300-too hi |
|
848 |
|
849 // EWsGcOpDrawBoxTextPtr |
|
850 TheGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); |
|
851 iBitGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); |
|
852 |
|
853 // EWsGcOpDrawTextVerticalPtr |
|
854 TheGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); |
|
855 iBitGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); |
|
856 |
|
857 // EWsGcOpDrawBoxTextVerticalPtr |
|
858 TheGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); |
|
859 iBitGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); |
|
860 |
|
861 // EWsGcOpMoveBy |
|
862 TheGc->MoveBy(TPoint(2,2)); |
|
863 iBitGc->MoveBy(TPoint(2,2)); |
|
864 |
|
865 // a bitmap for bitblt ops |
|
866 CWsBitmap bmp(TheClient->iWs); |
|
867 bmp.Create(TSize(16,16), iBackedUpWindow.DisplayMode()); |
|
868 |
|
869 // EWsGcOpGdiWsBlt2 |
|
870 TheGc->BitBlt(TPoint(0,0), &bmp); |
|
871 iBitGc->BitBlt(TPoint(0,0), &bmp); |
|
872 |
|
873 // EWsGcOpGdiWsBlt3 |
|
874 TheGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); |
|
875 iBitGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); |
|
876 |
|
877 // EWsGcOpGdiWsBltMasked |
|
878 TheGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); |
|
879 iBitGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); |
|
880 |
|
881 // EWsGcOpGdiWsAlphaBlendBitmaps |
|
882 TheGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); |
|
883 iBitGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); |
|
884 |
|
885 // EWsGcOpWsDrawBitmapMasked |
|
886 TheGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); |
|
887 iBitGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); |
|
888 |
|
889 // EWsGcOpDrawBitmap |
|
890 TheGc->DrawBitmap(TPoint(0,0), &bmp); |
|
891 iBitGc->DrawBitmap(TPoint(0,0), &bmp); |
|
892 |
|
893 // EWsGcOpDrawBitmapMasked |
|
894 TheGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast<const CFbsBitmap*>(&bmp), |
|
895 TRect(0,0,8,8), static_cast<const CFbsBitmap*>(&bmp), |
|
896 EFalse); |
|
897 iBitGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast<const CFbsBitmap*>(&bmp), |
|
898 TRect(0,0,8,8), static_cast<const CFbsBitmap*>(&bmp), |
|
899 EFalse); |
|
900 |
|
901 // EWsGcOpDrawPolyLineContinued |
|
902 TheGc->DrawPolyLine(reinterpret_cast<const TPoint*>(junkBuf8.Ptr()), |
|
903 TInt(junkBuf8.Size()/sizeof(TPoint))); |
|
904 iBitGc->DrawPolyLine(reinterpret_cast<const TPoint*>(junkBuf8.Ptr()), |
|
905 TInt(junkBuf8.Size()/sizeof(TPoint))); |
|
906 |
|
907 // EWsGcOpCopyRect |
|
908 TheGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); |
|
909 iBitGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); |
|
910 |
|
911 //cleanup |
|
912 TheClient->Flush(); |
|
913 TheGc->DiscardFont(); |
|
914 iBitGc->DiscardFont(); |
|
915 TheClient->iScreen->ReleaseFont(font1); |
|
916 junkBuf.Close(); |
|
917 junkBuf8.Close(); |
|
918 TheGc->Deactivate(); |
|
919 |
|
920 CheckWindow(); |
|
921 |
|
922 //the following have no client equivalent methods |
|
923 // EWsGcOpMapColorsLocal |
|
924 // EWsGcOpDrawPolyLineLocalBufLen |
|
925 // EWsGcOpDrawPolyLineLocal |
|
926 // EWsGcOpDrawPolygonLocalBufLen |
|
927 // EWsGcOpDrawPolygonLocal |
|
928 // EWsGcOpDrawBitmapLocal |
|
929 // EWsGcOpDrawBitmap2Local |
|
930 // EWsGcOpDrawBitmap3Local |
|
931 // EWsGcOpDrawBitmapMaskedLocal |
|
932 // EWsGcOpDrawTextPtr1 |
|
933 // EWsGcOpDrawBoxTextPtr1 |
|
934 // EWsGcOpDrawTextVerticalPtr1 |
|
935 // EWsGcOpDrawBoxTextVerticalPtr1 |
|
936 // EWsGcOpDrawTextLocal |
|
937 // EWsGcOpDrawBoxTextLocal |
|
938 // EWsGcOpGdiBlt2Local |
|
939 // EWsGcOpGdiBlt3Local |
|
940 // EWsGcOpGdiBltMaskedLocal |
|
941 ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); |
|
942 break; |
|
943 } |
|
944 |
|
945 default: |
|
946 ((CTBackedUpWindowStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
947 ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); |
|
948 break; |
|
949 } |
|
950 ((CTBackedUpWindowStep*)iStep)->RecordTestResultL(); |
|
951 } |
|
952 |
|
953 __WS_CONSTRUCT_STEP__(BackedUpWindow) |