|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 #include "tgc.h" |
|
22 #include "RemoteGc.h" |
|
23 #include "CommandBuffer.h" |
|
24 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
25 #include "directgdigcwrapper.h" |
|
26 #include <graphics/directgdidriver.h> |
|
27 #include <graphics/sgutils.h> |
|
28 #include <graphics/wsdrawresource.h> |
|
29 #endif |
|
30 |
|
31 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
32 GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect); |
|
33 GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, |
|
34 TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect); |
|
35 GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, |
|
36 TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect); |
|
37 |
|
38 GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect) |
|
39 { |
|
40 TSgImageInfo info; |
|
41 TInt res = aImage.GetInfo(info); |
|
42 if(res == KErrNone) |
|
43 { |
|
44 info.iUsage = ESgUsageNone; |
|
45 info.iCpuAccess = ESgCpuAccessReadOnly; |
|
46 RSgImage image; |
|
47 res = image.Create(info, aImage); |
|
48 if(res == KErrNone) |
|
49 { |
|
50 const TAny* dataAddressSrc = NULL; |
|
51 TInt dataStrideSrc = 0; |
|
52 res = image.MapReadOnly(dataAddressSrc, dataStrideSrc); |
|
53 if(res == KErrNone) |
|
54 { |
|
55 const TDisplayMode displayModeDest = aBitmap->DisplayMode(); |
|
56 const TDisplayMode displayModeSrc = SgUtils::PixelFormatToDisplayMode(info.iPixelFormat); |
|
57 TUint32* dataAddressDest = aBitmap->DataAddress(); |
|
58 const TInt dataStrideDest = aBitmap -> DataStride(); |
|
59 TSize bitmapSize = aBitmap->SizeInPixels(); |
|
60 TRect rect = aRect; |
|
61 TRect rectDest = info.iSizeInPixels; |
|
62 rect.Intersection(rectDest); |
|
63 if(rect.Height() > bitmapSize.iHeight) |
|
64 { |
|
65 rect.SetHeight(bitmapSize.iHeight); |
|
66 } |
|
67 if(rect.Width() > bitmapSize.iWidth) |
|
68 { |
|
69 rect.SetWidth(bitmapSize.iWidth); |
|
70 } |
|
71 CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc, |
|
72 dataStrideSrc, displayModeSrc, rect); |
|
73 |
|
74 image.Unmap(); |
|
75 } |
|
76 image.Close(); |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, |
|
82 TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect) |
|
83 { |
|
84 if(aRect.IsEmpty()) |
|
85 return; |
|
86 |
|
87 if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest)) |
|
88 { |
|
89 Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height()); |
|
90 return; |
|
91 } |
|
92 |
|
93 switch(aDisplayModeSrc) |
|
94 { |
|
95 case EColor64K: |
|
96 { |
|
97 CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest, |
|
98 (TUint16*)aDataAddressSrc, aDataStrideSrc, aRect); |
|
99 break; |
|
100 } |
|
101 default: |
|
102 break; |
|
103 } |
|
104 } |
|
105 |
|
106 GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, |
|
107 TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect) |
|
108 { |
|
109 const TInt bppSrc = 2; |
|
110 const TInt width = aRect.Width(); |
|
111 const TInt height = aRect.Height(); |
|
112 const TInt dataStrideLengthSrc = aDataStrideSrc / bppSrc; |
|
113 TUint16* dataAddressSrc = aDataAddressSrc + aRect.iTl.iY * dataStrideLengthSrc + aRect.iTl.iX; |
|
114 const TUint16* dataAddressSrcEnd = dataAddressSrc + dataStrideLengthSrc * height; |
|
115 |
|
116 switch(aDisplayModeDest) |
|
117 { |
|
118 case EColor64K: |
|
119 { |
|
120 TUint16* dataAddressDest = static_cast<TUint16*> (aDataAddressDest); |
|
121 const TInt dataStrideLengthDest = aDataStrideDest / bppSrc; |
|
122 while(dataAddressSrcEnd > dataAddressSrc) |
|
123 { |
|
124 Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc); |
|
125 dataAddressSrc += dataStrideLengthSrc; |
|
126 dataAddressDest += dataStrideLengthDest; |
|
127 } |
|
128 break; |
|
129 } |
|
130 case EColor16MU: |
|
131 { |
|
132 const TInt bppDest = 4; |
|
133 TUint32* dataAddressDest = static_cast<TUint32*> (aDataAddressDest); |
|
134 const TInt dataStrideLengthDest = aDataStrideDest / bppDest; |
|
135 |
|
136 while(dataAddressSrcEnd > dataAddressSrc) |
|
137 { |
|
138 const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width; |
|
139 TUint32* dataAddressDestCur = dataAddressDest; |
|
140 TUint16* dataAddressSrcCur = dataAddressSrc; |
|
141 |
|
142 while(dataAddressSrcLineEnd > dataAddressSrcCur) |
|
143 { |
|
144 *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU(); |
|
145 dataAddressDestCur++; |
|
146 dataAddressSrcCur++; |
|
147 } |
|
148 dataAddressSrc += dataStrideLengthSrc; |
|
149 dataAddressDest += dataStrideLengthDest; |
|
150 } |
|
151 break; |
|
152 } |
|
153 case EGray4: |
|
154 { |
|
155 TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest); |
|
156 const TInt dataStrideLengthDest = aDataStrideDest; |
|
157 |
|
158 while(dataAddressSrcEnd > dataAddressSrc) |
|
159 { |
|
160 const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; |
|
161 TUint8* dataAddressDestCur = dataAddressDest; |
|
162 TUint16* dataAddressSrcCur = dataAddressSrc; |
|
163 |
|
164 while(dataAddressDstLineEnd > dataAddressDestCur) |
|
165 { |
|
166 *dataAddressDestCur = 0; |
|
167 for(TInt index = 0; index < 8; index +=2) |
|
168 { |
|
169 TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4(); |
|
170 col <<= index; |
|
171 *dataAddressDestCur |= col; |
|
172 dataAddressSrcCur++; |
|
173 } |
|
174 dataAddressDestCur++; |
|
175 } |
|
176 dataAddressSrc += dataStrideLengthSrc; |
|
177 dataAddressDest += dataStrideLengthDest; |
|
178 } |
|
179 break; |
|
180 } |
|
181 case EColor256: |
|
182 { |
|
183 TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest); |
|
184 const TInt dataStrideLengthDest = aDataStrideDest; |
|
185 |
|
186 while(dataAddressSrcEnd > dataAddressSrc) |
|
187 { |
|
188 const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; |
|
189 TUint8* dataAddressDestCur = dataAddressDest; |
|
190 TUint16* dataAddressSrcCur = dataAddressSrc; |
|
191 |
|
192 while(dataAddressDstLineEnd > dataAddressDestCur) |
|
193 { |
|
194 *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256(); |
|
195 dataAddressSrcCur++; |
|
196 dataAddressDestCur++; |
|
197 } |
|
198 dataAddressSrc += dataStrideLengthSrc; |
|
199 dataAddressDest += dataStrideLengthDest; |
|
200 } |
|
201 break; |
|
202 } |
|
203 default: |
|
204 break; |
|
205 } |
|
206 } |
|
207 |
|
208 TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat) |
|
209 { |
|
210 switch(aPixelFormat) |
|
211 { |
|
212 case EUidPixelFormatARGB_8888_PRE: |
|
213 return EColor16MAP; |
|
214 case EUidPixelFormatARGB_8888: |
|
215 return EColor16MA; |
|
216 case EUidPixelFormatRGB_565: |
|
217 return EColor64K; |
|
218 default: |
|
219 break; |
|
220 } |
|
221 return ENone; |
|
222 } |
|
223 |
|
224 TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode) |
|
225 { |
|
226 switch (aDisplayMode) |
|
227 { |
|
228 case EGray2: |
|
229 case EGray4: |
|
230 case EGray16: |
|
231 case EGray256: |
|
232 case EColor16: |
|
233 case EColor256: |
|
234 case EColor16M: |
|
235 case EColor16MU: |
|
236 { |
|
237 return EUidPixelFormatXRGB_8888; |
|
238 } |
|
239 case EColor4K: |
|
240 { |
|
241 return EUidPixelFormatXRGB_4444; |
|
242 } |
|
243 case EColor64K: |
|
244 { |
|
245 return EUidPixelFormatRGB_565; |
|
246 } |
|
247 case EColor16MA: |
|
248 { |
|
249 return EUidPixelFormatARGB_8888; |
|
250 } |
|
251 case EColor16MAP: |
|
252 { |
|
253 return EUidPixelFormatARGB_8888_PRE; |
|
254 } |
|
255 default: |
|
256 { |
|
257 return EUidPixelFormatUnknown; |
|
258 } |
|
259 } |
|
260 } |
|
261 #endif |
|
262 |
|
263 CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep) |
|
264 { |
|
265 } |
|
266 |
|
267 CTGc::~CTGc() |
|
268 { |
|
269 delete iTest; |
|
270 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
271 SgDriver::Close(); |
|
272 CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); |
|
273 if(directGdiDriver) |
|
274 { |
|
275 directGdiDriver->Close(); |
|
276 } |
|
277 #endif |
|
278 } |
|
279 |
|
280 void CTGc::ConstructL() |
|
281 { |
|
282 _LIT(KTestName,"GC Test"); |
|
283 iTest=new(ELeave) CTestBase(KTestName,this); |
|
284 |
|
285 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
286 TInt err = CDirectGdiDriver::Open(); |
|
287 User::LeaveIfError(err); |
|
288 err = SgDriver::Open(); |
|
289 if(err != KErrNone) |
|
290 { |
|
291 CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); |
|
292 if(directGdiDriver) |
|
293 { |
|
294 directGdiDriver->Close(); |
|
295 } |
|
296 User::Leave(err); |
|
297 } |
|
298 #endif |
|
299 } |
|
300 |
|
301 //Class derived from MWsGraphicResolver. Used for playing the commands from command buffer |
|
302 class CWSGraphicsRes: public CBase, public MWsGraphicResolver |
|
303 { |
|
304 public: |
|
305 void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const |
|
306 { |
|
307 //Orveriding by giving empty implemention |
|
308 } |
|
309 }; |
|
310 |
|
311 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
312 // |
|
313 //Class CDrawTextInContextTest |
|
314 // |
|
315 |
|
316 CDrawTextInContextTest::CDrawTextInContextTest(){} |
|
317 |
|
318 CDrawTextInContextTest::~CDrawTextInContextTest() |
|
319 { |
|
320 delete iRefBitmap; |
|
321 delete iRefDevice; |
|
322 delete iRefBitGc; |
|
323 delete iRemoteGc; |
|
324 iMsgBuf.Close(); |
|
325 delete iCommandBuffer; |
|
326 delete iWsGraphicRes; |
|
327 |
|
328 TheClient->iScreen->ReleaseFont(iFont); |
|
329 |
|
330 delete iDirectGdiGcWrapper; |
|
331 if(iWrapperImageTarget) |
|
332 { |
|
333 iWrapperImageTarget->Close(); |
|
334 } |
|
335 delete iWrapperImageTarget; |
|
336 iWrapperImage.Close(); |
|
337 iWrapperImageCollection.Close(); |
|
338 } |
|
339 |
|
340 void CDrawTextInContextTest::BaseConstructL() |
|
341 { |
|
342 //Initialise font settings |
|
343 TFontSpec fsp; |
|
344 fsp.iTypeface.iName=_L("Series 60 Sans"); |
|
345 fsp.iHeight=430; |
|
346 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp)); |
|
347 |
|
348 //Initialise TTextParameter |
|
349 iParam.iStart = 27; |
|
350 iParam.iEnd = 60; |
|
351 |
|
352 //Text to draw |
|
353 iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn")); |
|
354 |
|
355 //For reference bitmap |
|
356 iRefBitmap = new(ELeave) CFbsBitmap(); |
|
357 User::LeaveIfError(iRefBitmap->Create(KBitmapSize, EColor64K)); |
|
358 iRefDevice = CFbsBitmapDevice::NewL(iRefBitmap); |
|
359 User::LeaveIfError(iRefDevice->CreateContext(iRefBitGc)); |
|
360 |
|
361 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); |
|
362 User::LeaveIfNull(theDGdiDriver); |
|
363 |
|
364 TSgImageInfo info; |
|
365 info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; |
|
366 info.iSizeInPixels = KBitmapSize; |
|
367 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
368 |
|
369 TInt res = iWrapperImageCollection.Create(info, 1); |
|
370 User::LeaveIfError(res); |
|
371 res = iWrapperImageCollection.OpenImage(0, iWrapperImage); |
|
372 User::LeaveIfError(res); |
|
373 iWrapperImageTarget = new (ELeave) RDirectGdiImageTarget(*theDGdiDriver); |
|
374 res = iWrapperImageTarget->Create(iWrapperImage); |
|
375 User::LeaveIfError(res); |
|
376 iDirectGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); |
|
377 |
|
378 //clean image----------------- |
|
379 CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); |
|
380 CleanupStack::PushL(directGdiGcWrapper); |
|
381 |
|
382 directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha); |
|
383 directGdiGcWrapper->SetBrushColor(KRgbWhite); |
|
384 directGdiGcWrapper->Clear(); |
|
385 |
|
386 CleanupStack::PopAndDestroy(1, directGdiGcWrapper); |
|
387 //------------------ |
|
388 |
|
389 //Used to record draw commands |
|
390 iRemoteGc = CRemoteGc::NewL(TheClient->iScreen); |
|
391 |
|
392 //Used to play recorded draw commands |
|
393 iCommandBuffer = CCommandBuffer::NewL(); |
|
394 |
|
395 //Dummy class created required for CCommandBuffer::Play |
|
396 iWsGraphicRes = new (ELeave) CWSGraphicsRes(); |
|
397 |
|
398 //Offset for CCommandBuffer::Play |
|
399 iOffset = TPoint(0,0); |
|
400 |
|
401 //Result of doing the test |
|
402 iHasPassedTest = EFalse; |
|
403 } |
|
404 |
|
405 void CDrawTextInContextTest::Test() |
|
406 { |
|
407 /* Create reference bitmap by drawing using bitgc */ |
|
408 iRefBitGc->UseFont(iFont); |
|
409 DoDrawTextBitGc(); |
|
410 iRefBitGc->DiscardFont(); |
|
411 |
|
412 /* Drawing using CBitGcWrapper via CRemotGc*/ |
|
413 |
|
414 //Capturing the commands in remote gc |
|
415 iRemoteGc->BeginDraw(KBitmapRect); |
|
416 iRemoteGc->UseFont(iFont); |
|
417 DoDrawTextRemoteGc(); |
|
418 iRemoteGc->DiscardFont(); |
|
419 iRemoteGc->EndDraw(); |
|
420 |
|
421 //Externalize the captured commands from remote gc in to a buffer |
|
422 iRemoteGc->ExternalizeL(iMsgBuf, ETrue); |
|
423 |
|
424 //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer |
|
425 iCommandBuffer->InternalizeL(iMsgBuf.Pckg()); |
|
426 |
|
427 //Play the commands on test window using command buffer |
|
428 iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper); |
|
429 |
|
430 //Test to see if the bitmap drawn to using CRemoteGc is the same as the reference bitmap |
|
431 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
432 CleanupStack::PushL(bitmap); |
|
433 |
|
434 TSgImageInfo info; |
|
435 iWrapperImage.GetInfo(info); |
|
436 TDisplayMode displayMode = DisplayModeFromPixelFormat(info.iPixelFormat); |
|
437 bitmap->Create(info.iSizeInPixels, displayMode); |
|
438 TRect rect(info.iSizeInPixels); |
|
439 CopyImageToBitmapL(bitmap, iWrapperImage, rect); |
|
440 |
|
441 iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse); |
|
442 |
|
443 CleanupStack::PopAndDestroy(bitmap); |
|
444 } |
|
445 |
|
446 TBool CDrawTextInContextTest::HasPassedTest() |
|
447 { |
|
448 return iHasPassedTest; |
|
449 } |
|
450 |
|
451 // |
|
452 // Class DrawTextInContextTestPoint |
|
453 // |
|
454 |
|
455 CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){} |
|
456 |
|
457 CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){} |
|
458 |
|
459 CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL() |
|
460 { |
|
461 CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint; |
|
462 CleanupStack::PushL(self); |
|
463 self->ConstructL(); |
|
464 CleanupStack::Pop(self); |
|
465 return self; |
|
466 } |
|
467 |
|
468 void CDrawTextInContextTestPoint::ConstructL() |
|
469 { |
|
470 BaseConstructL(); |
|
471 iPosition = TPoint(0,0); |
|
472 } |
|
473 |
|
474 void CDrawTextInContextTestPoint::DoDrawTextBitGc() |
|
475 { |
|
476 iRefBitGc->DrawText(iText,&iParam,iPosition); |
|
477 } |
|
478 |
|
479 void CDrawTextInContextTestPoint::DoDrawTextRemoteGc() |
|
480 { |
|
481 iRemoteGc->DrawText(iText,&iParam,iPosition); |
|
482 } |
|
483 |
|
484 // |
|
485 // Class DrawTextInContextTestBox |
|
486 // |
|
487 |
|
488 CDrawTextInContextTestBox::CDrawTextInContextTestBox(){} |
|
489 |
|
490 CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){} |
|
491 |
|
492 CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL() |
|
493 { |
|
494 CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox; |
|
495 CleanupStack::PushL(self); |
|
496 self->ConstructL(); |
|
497 CleanupStack::Pop(self); |
|
498 return self; |
|
499 } |
|
500 |
|
501 void CDrawTextInContextTestBox::ConstructL() |
|
502 { |
|
503 BaseConstructL(); |
|
504 iClipFillRect = TRect(10,50,640,120); |
|
505 iBaselineOffset = 40; |
|
506 iTTextAlign = CGraphicsContext::ELeft; |
|
507 } |
|
508 |
|
509 void CDrawTextInContextTestBox::DoDrawTextBitGc() |
|
510 { |
|
511 iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); |
|
512 } |
|
513 |
|
514 void CDrawTextInContextTestBox::DoDrawTextRemoteGc() |
|
515 { |
|
516 iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); |
|
517 } |
|
518 |
|
519 // |
|
520 // Class CDrawTextInContextTestPointVertical |
|
521 // |
|
522 |
|
523 CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){} |
|
524 |
|
525 CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){} |
|
526 |
|
527 CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL() |
|
528 { |
|
529 CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical; |
|
530 CleanupStack::PushL(self); |
|
531 self->ConstructL(); |
|
532 CleanupStack::Pop(self); |
|
533 return self; |
|
534 } |
|
535 |
|
536 void CDrawTextInContextTestPointVertical::ConstructL() |
|
537 { |
|
538 BaseConstructL(); |
|
539 iPosition = TPoint(0,0); |
|
540 iUp = EFalse; |
|
541 } |
|
542 |
|
543 void CDrawTextInContextTestPointVertical::DoDrawTextBitGc() |
|
544 { |
|
545 iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp); |
|
546 } |
|
547 |
|
548 void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc() |
|
549 { |
|
550 iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp); |
|
551 } |
|
552 |
|
553 // |
|
554 // Class CDrawTextInContextTestBoxVertical |
|
555 // |
|
556 |
|
557 CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){} |
|
558 |
|
559 CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){} |
|
560 |
|
561 CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL() |
|
562 { |
|
563 CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical; |
|
564 CleanupStack::PushL(self); |
|
565 self->ConstructL(); |
|
566 CleanupStack::Pop(self); |
|
567 return self; |
|
568 } |
|
569 |
|
570 void CDrawTextInContextTestBoxVertical::ConstructL() |
|
571 { |
|
572 BaseConstructL(); |
|
573 iClipFillRect = TRect(10,50,640,120); |
|
574 iBaselineOffset = 40; |
|
575 iUp = EFalse; |
|
576 iTTextAlign = CGraphicsContext::ELeft; |
|
577 } |
|
578 |
|
579 void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc() |
|
580 { |
|
581 iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); |
|
582 } |
|
583 |
|
584 void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc() |
|
585 { |
|
586 iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); |
|
587 } |
|
588 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
589 |
|
590 void CleanUpFont(TAny* aFont) |
|
591 { |
|
592 //Will be called in case of a leave to release the font |
|
593 CFont* font= static_cast<CFont*>(aFont); |
|
594 TheClient->iScreen->ReleaseFont(font); |
|
595 } |
|
596 |
|
597 /** |
|
598 @SYMTestCaseID GRAPHICS-WSERV-0437 |
|
599 @SYMPREQ PREQ1543 |
|
600 @SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow |
|
601 effect on. |
|
602 @SYMTestPriority High |
|
603 @SYMTestStatus Implemented |
|
604 @SYMTestActions Create a font with both outline and shadow effects. Record the commands |
|
605 (like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same |
|
606 commands in CWindowGc and draw text on a different window |
|
607 @SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc should be same |
|
608 */ |
|
609 void CTGc::TestOutlineAndShadowL() |
|
610 { |
|
611 TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); |
|
612 TRegionFix<1> clippingRegion(sourceRect); |
|
613 |
|
614 CWsScreenDevice* device = TheClient->iScreen; |
|
615 |
|
616 _LIT(KText,"Outline and shadow"); |
|
617 TFontSpec fSpec(KTestFontTypefaceName,23); |
|
618 fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
619 fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); |
|
620 fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); |
|
621 |
|
622 CFont *font; |
|
623 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); |
|
624 CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); |
|
625 |
|
626 CRemoteGc* remoteGc = CRemoteGc::NewL(device); |
|
627 CleanupStack::PushL(remoteGc); |
|
628 remoteGc->BeginDraw(sourceRect); |
|
629 //Capturing the commands in remote gc |
|
630 remoteGc->SetBrushColor(KRgbGreen); |
|
631 remoteGc->SetShadowColor(KRgbDarkRed); |
|
632 remoteGc->SetPenColor(KRgbBlack); |
|
633 remoteGc->UseFont(font); |
|
634 remoteGc->DrawText(KText, TPoint(2,40)); |
|
635 remoteGc->DiscardFont(); |
|
636 remoteGc->EndDraw(); |
|
637 |
|
638 RWsGraphicMsgBuf msgBuf; |
|
639 CleanupClosePushL(msgBuf); |
|
640 //Externalize the captured commands from remote gc in to a buffer |
|
641 remoteGc->ExternalizeL(msgBuf, ETrue); |
|
642 |
|
643 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); |
|
644 CleanupStack::PushL(wsGrap); |
|
645 |
|
646 CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); |
|
647 CleanupStack::PushL(cmdBuf); |
|
648 //Internalize the buffer with captured commands (from CRemoteGC) |
|
649 //in to CCommandBuffer |
|
650 cmdBuf->InternalizeL(msgBuf.Pckg()); |
|
651 |
|
652 TestWin->Win()->Invalidate(); |
|
653 TestWin->Win()->BeginRedraw(); |
|
654 TheGc->Activate(*TestWin->Win()); |
|
655 TheGc->Clear(); |
|
656 //Play the commands on test window using command buffer |
|
657 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
658 cmdBuf->Play(TPoint(0, 0), &clippingRegion, sourceRect, TheClient->iWs, *TheGc); |
|
659 #else |
|
660 cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); |
|
661 #endif |
|
662 TheGc->Deactivate(); |
|
663 TestWin->Win()->EndRedraw(); |
|
664 |
|
665 BaseWin->Win()->Invalidate(); |
|
666 BaseWin->Win()->BeginRedraw(); |
|
667 TheGc->Activate(*BaseWin->Win()); |
|
668 TheGc->Clear(); |
|
669 TheGc->SetBrushColor(KRgbGreen); |
|
670 TheGc->SetShadowColor(KRgbDarkRed); |
|
671 TheGc->SetPenColor(KRgbBlack); |
|
672 TheGc->UseFont(font); |
|
673 //Draw the text on base window using CWindowGC |
|
674 TheGc->DrawText(KText, TPoint(2, 40)); |
|
675 TheGc->DiscardFont(); |
|
676 TheGc->Deactivate(); |
|
677 BaseWin->Win()->EndRedraw(); |
|
678 TheClient->iWs.Finish(); |
|
679 TheClient->WaitForRedrawsToFinish(); |
|
680 |
|
681 //Check the text drawn on base and test windows. |
|
682 CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestOutlineAndShadowL()")); |
|
683 |
|
684 CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc |
|
685 CleanupStack::Pop();//font |
|
686 TheClient->iScreen->ReleaseFont(font); |
|
687 } |
|
688 |
|
689 void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/) |
|
690 { |
|
691 TSize winSize = aWindow.Size(); |
|
692 TPoint gcOrigin(winSize.iWidth >> 3, winSize.iWidth >> 3); |
|
693 TRect gcClipRect(0, 0, (winSize.iWidth * 3) >> 2, (winSize.iHeight * 3) >> 2); |
|
694 TRect ellipseRect(gcClipRect); |
|
695 // Shrink the ellipse for better visibility and to fit well within the clip area. |
|
696 ellipseRect.Shrink(3, 3); |
|
697 TSize penSize(1, 1); |
|
698 |
|
699 aWindow.Win()->SetBackgroundColor(KRgbGreen); |
|
700 aWindow.ClearWin(); |
|
701 aWindow.Win()->Invalidate(); |
|
702 |
|
703 if(!bActivateBeforeRedraw) |
|
704 { |
|
705 aWindow.Win()->BeginRedraw(); |
|
706 } |
|
707 |
|
708 TheGc->Activate(*(aWindow.Win())); |
|
709 TheGc->SetOrigin(gcOrigin); |
|
710 TheGc->SetClippingRect(gcClipRect); |
|
711 |
|
712 if(bActivateBeforeRedraw) |
|
713 { |
|
714 aWindow.Win()->BeginRedraw(); |
|
715 } |
|
716 |
|
717 TheGc->SetBrushColor(KRgbDarkRed); |
|
718 TheGc->SetPenColor(KRgbDarkRed); |
|
719 TheGc->SetPenSize(penSize); |
|
720 TheGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
721 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
722 TheGc->DrawEllipse(ellipseRect); |
|
723 TheGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
724 TheGc->SetPenColor(KRgbYellow); |
|
725 TheGc->SetPenStyle(CGraphicsContext::EDashedPen); |
|
726 TheGc->DrawRect(gcClipRect); |
|
727 |
|
728 aWindow.Win()->EndRedraw(); |
|
729 TheGc->Deactivate(); |
|
730 } |
|
731 |
|
732 /** |
|
733 @SYMTestCaseID GRAPHICS-WSERV-0471 |
|
734 @SYMTestCaseDesc This test is to verify that the GC correctly applies the clip rect and |
|
735 origin attributes irrespective of whether the GC is activated on the |
|
736 window before or after the BeginRedraw. |
|
737 @SYMDEF PDEF120091 |
|
738 @SYMTestPriority High |
|
739 @SYMTestStatus Implemented |
|
740 @SYMTestActions The test has following steps: |
|
741 1. For the Test window follow the steps: |
|
742 A. Activate the GC on Test window. |
|
743 B. Set the Origin of the GC to centre of the window. |
|
744 C. Set the Clipping rectangle of the GC to half the size of the window. |
|
745 D. In the BeginDraw and EndDraw call bracket perform the following: |
|
746 a. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. |
|
747 b. Draw a rectangle that is size of the clip rectangle. |
|
748 E. Deactivate the GC. |
|
749 2. For the Base window follow the steps: |
|
750 A. In the BeginDraw and EndDraw call bracket perform the following: |
|
751 a. Activate the GC on Base window. |
|
752 b. Set the Origin of the GC to centre of the window. |
|
753 c. Set the Clipping rectangle of the GC to half the size of the window. |
|
754 d. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. |
|
755 e. Draw a rectangle that is size of the clip rectangle. |
|
756 f. Deactivate the GC. |
|
757 3. Compare Test and Base window. |
|
758 @SYMTestExpectedResults Both the Test and Base window should have the complete |
|
759 non-clipped ellipse completely encapsulated within the rectangle. |
|
760 */ |
|
761 void CTGc::TestGcClipRectOrigin() |
|
762 { |
|
763 TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse); |
|
764 TestGcClipRectOrigin_DrawContent(*TestWin, ETrue); |
|
765 |
|
766 TheClient->Flush(); |
|
767 |
|
768 CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()")); |
|
769 } |
|
770 |
|
771 /** |
|
772 @SYMTestCaseID GRAPHICS-WSERV-0469 |
|
773 @SYMDEF INC116406 |
|
774 @SYMTestCaseDesc Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is |
|
775 set correctly. |
|
776 @SYMTestPriority High |
|
777 @SYMTestStatus Implemented |
|
778 @SYMTestActions |
|
779 @SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of |
|
780 the window, and MWsGraphicsContext should use transparent white. |
|
781 */ |
|
782 void CTGc::TestResetWithBackgroundColorL() |
|
783 { |
|
784 const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); |
|
785 const TRegionFix<1> KClippingRegion(KSourceRect); |
|
786 |
|
787 CWsScreenDevice* device = TheClient->iScreen; |
|
788 |
|
789 CRemoteGc* remoteGc = CRemoteGc::NewL(device); |
|
790 CleanupStack::PushL(remoteGc); |
|
791 |
|
792 //note this remote GC has not been activated on any window |
|
793 remoteGc->BeginDraw(KSourceRect); |
|
794 |
|
795 //Draw the commands in remote gc |
|
796 remoteGc->SetBrushColor(KRgbGreen); //nothing green is seen in this test |
|
797 |
|
798 remoteGc->Reset(); //This resets the brush colour to the background colour of the window |
|
799 //where playback is, in the case of playing back to a window |
|
800 //however with a CFbsBitGc the color is transparent white, as there is no window. |
|
801 remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
802 remoteGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
803 remoteGc->DrawRect(KSourceRect); |
|
804 remoteGc->EndDraw(); |
|
805 |
|
806 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
807 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); |
|
808 User::LeaveIfNull(theDGdiDriver); |
|
809 |
|
810 TSgImageInfo info; |
|
811 info.iUsage = ESgUsageDirectGdiTarget | ESgUsageCompositionSource; |
|
812 info.iSizeInPixels = TSize(TestWin->Size().iWidth, TestWin->Size().iHeight); |
|
813 info.iPixelFormat = EUidPixelFormatXRGB_8888;//among display modes with alpha channel only pre-multiply alpha is supported in directGDI currently |
|
814 |
|
815 RSgImageCollection imageCollection; |
|
816 CleanupClosePushL(imageCollection); |
|
817 TInt res = imageCollection.Create(info, 1); |
|
818 User::LeaveIfError(res); |
|
819 RSgImage image; |
|
820 CleanupClosePushL(image); |
|
821 res = imageCollection.OpenImage(0, image); |
|
822 User::LeaveIfError(res); |
|
823 RDirectGdiImageTarget imageTarget(*theDGdiDriver); |
|
824 CleanupClosePushL(imageTarget); |
|
825 res = imageTarget.Create(image); |
|
826 User::LeaveIfError(res); |
|
827 #endif |
|
828 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
829 //create a bitmap |
|
830 CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); |
|
831 User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA)); |
|
832 CleanupStack::PushL(bitmap); |
|
833 |
|
834 CFbsBitmapDevice *fbsDevice = CFbsBitmapDevice::NewL(bitmap); |
|
835 CleanupStack::PushL(fbsDevice); |
|
836 #endif |
|
837 |
|
838 //prepare the command buffer for playback |
|
839 RWsGraphicMsgBuf msgBuf; |
|
840 CleanupClosePushL(msgBuf); |
|
841 |
|
842 //Externalize the captured commands from remote gc in to a buffer |
|
843 remoteGc->ExternalizeL(msgBuf, ETrue); |
|
844 |
|
845 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); |
|
846 CleanupStack::PushL(wsGrap); |
|
847 |
|
848 CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); |
|
849 CleanupStack::PushL(cmdBuf); |
|
850 cmdBuf->InternalizeL(msgBuf.Pckg()); |
|
851 |
|
852 TRgb color; |
|
853 TRgb testColor(KRgbWhite); |
|
854 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
855 CDirectGdiGcWrapper* directGdiGcWrapper=CDirectGdiGcWrapper::NewL(imageTarget); |
|
856 CleanupStack::PushL(directGdiGcWrapper); |
|
857 cmdBuf->Play(TPoint(),&KClippingRegion,KSourceRect,*wsGrap,*directGdiGcWrapper); |
|
858 |
|
859 //check that the background has been cleared to transparent white. |
|
860 image.GetInfo(info); |
|
861 info.iUsage = ESgUsageNone; |
|
862 info.iCpuAccess = ESgCpuAccessReadOnly; |
|
863 RSgImage image1; |
|
864 CleanupClosePushL(image1); |
|
865 res = image1.Create(info, image); |
|
866 const TAny* data; |
|
867 TInt stride = 0; |
|
868 res = image1.MapReadOnly(data, stride); |
|
869 User::LeaveIfError(res); |
|
870 TPoint pixel(10,10); |
|
871 TInt offset = pixel.iY * stride + pixel.iX * 4; |
|
872 TAny* non_const_data = const_cast <TAny*> (data); |
|
873 TUint8* pointData = static_cast <TUint8*> (non_const_data) + offset; |
|
874 color = *(reinterpret_cast <TRgb*> (pointData)); |
|
875 image1.Unmap(); |
|
876 #endif |
|
877 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
878 CFbsBitGc* fbsBitGc=NULL; |
|
879 User::LeaveIfError(fbsDevice->CreateContext(fbsBitGc)); |
|
880 CleanupStack::PushL(fbsBitGc); |
|
881 fbsBitGc->Activate(fbsDevice); |
|
882 cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *fbsBitGc); |
|
883 bitmap->GetPixel(color, TPoint(10,10)); |
|
884 testColor.SetAlpha(0); |
|
885 #endif |
|
886 iStep->TEST(color==testColor); |
|
887 |
|
888 //now test drawing to a window to ensure that the brush colour is |
|
889 //the window background colour |
|
890 |
|
891 //display a blue window |
|
892 BaseWin->Win()->SetBackgroundColor(KRgbBlue); |
|
893 BaseWin->Win()->Invalidate(); |
|
894 BaseWin->Win()->BeginRedraw(); |
|
895 TheGc->Activate(*BaseWin->Win()); |
|
896 TheGc->Clear(); |
|
897 TheGc->Deactivate(); |
|
898 BaseWin->Win()->EndRedraw(); |
|
899 TheClient->iWs.Finish(); |
|
900 TheClient->WaitForRedrawsToFinish(); |
|
901 |
|
902 //start drawing the display commands with a green background |
|
903 |
|
904 BaseWin->Win()->SetBackgroundColor(KRgbYellow); |
|
905 BaseWin->Win()->Invalidate(); |
|
906 BaseWin->Win()->BeginRedraw(); |
|
907 TheGc->Activate(*BaseWin->Win()); |
|
908 |
|
909 //Play the commands on test window using command buffer |
|
910 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
911 cmdBuf->Play(TPoint(0, 0), &KClippingRegion, KSourceRect, TheClient->iWs, *TheGc); |
|
912 #else |
|
913 cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc); |
|
914 #endif |
|
915 |
|
916 TheGc->Deactivate(); |
|
917 BaseWin->Win()->EndRedraw(); |
|
918 TheClient->iWs.Finish(); |
|
919 TheClient->WaitForRedrawsToFinish(); |
|
920 |
|
921 //check that the background has been cleared to yellow, using brush colour |
|
922 TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode()); |
|
923 position.iX+=10; |
|
924 position.iY+=10; |
|
925 TheClient->iScreen->GetPixel(color, position); |
|
926 iStep->TEST(color==KRgbYellow); |
|
927 |
|
928 BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor |
|
929 |
|
930 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
931 CleanupStack::PopAndDestroy(9, remoteGc); |
|
932 #else |
|
933 CleanupStack::PopAndDestroy(7, remoteGc); |
|
934 #endif |
|
935 } |
|
936 |
|
937 /** |
|
938 @SYMTestCaseID GRAPHICS-WSERV-0481 |
|
939 @SYMPREQ 1841 |
|
940 @SYMTestCaseDesc Create font and graphics with various effect effects. Record the commands |
|
941 (like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same |
|
942 commands in CWindowGc and draw text on a different window |
|
943 @SYMTestPriority Medium |
|
944 @SYMTestStatus Implemented |
|
945 @SYMTestActions |
|
946 @SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same |
|
947 */ |
|
948 void CTGc::TestCommandBufferL() |
|
949 { |
|
950 CWsScreenDevice* device = TheClient->iScreen; |
|
951 |
|
952 _LIT(KBuffText,"Command Buffer"); |
|
953 TFontSpec fSpec(KTestFontTypefaceName,23); |
|
954 fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
955 fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); |
|
956 fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); |
|
957 |
|
958 CFont *font; |
|
959 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); |
|
960 CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); |
|
961 |
|
962 CRemoteGc* remoteGc = CRemoteGc::NewL(device); |
|
963 CleanupStack::PushL(remoteGc); |
|
964 |
|
965 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
966 //-------create image--------- |
|
967 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); |
|
968 User::LeaveIfNull(theDGdiDriver); |
|
969 const TSize KImageSize = TSize(2, 2); |
|
970 TSgImageInfo info; |
|
971 info.iUsage = ESgUsageWindowGcSource; |
|
972 info.iSizeInPixels = KImageSize; |
|
973 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
974 info.iShareable = ETrue; |
|
975 const TInt stride = KImageSize.iWidth * 2; |
|
976 TUint8* buf = (TUint8*) (User::AllocL(KImageSize.iHeight * stride)); |
|
977 CleanupStack::PushL(buf); |
|
978 TUint16* bufCur = ((TUint16*)buf); |
|
979 *bufCur = KRgbRed.Color64K(); |
|
980 *(bufCur + 1) = KRgbRed.Color64K(); |
|
981 *(bufCur + 2) = KRgbRed.Color64K(); |
|
982 *(bufCur + 3) = KRgbRed.Color64K(); |
|
983 |
|
984 RSgImage image; |
|
985 TInt res = image.Create(info, buf, stride); |
|
986 User::LeaveIfError(res); |
|
987 CleanupClosePushL(image); |
|
988 RWsDrawableSource drawableSource(TheClient->iWs); |
|
989 res = drawableSource.Create(image, TheClient->iScreen->GetScreenNumber()); |
|
990 if(res == KErrNotSupported) |
|
991 { |
|
992 INFO_PRINTF1(_L("The current screen is not supports drawable source. This test case terminates now.")); |
|
993 CleanupStack::PopAndDestroy(3, remoteGc); |
|
994 CleanupStack::Pop();//font |
|
995 TheClient->iScreen->ReleaseFont(font); |
|
996 return; |
|
997 } |
|
998 User::LeaveIfError(res); |
|
999 CleanupClosePushL(drawableSource); |
|
1000 //-------end create image--------- |
|
1001 #endif |
|
1002 remoteGc->ResetCommandBuffer(); |
|
1003 remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight)); |
|
1004 //Capturing the commands in remote gc |
|
1005 remoteGc->Clear(); |
|
1006 remoteGc->DrawRect(TRect(10,10,30,30)); |
|
1007 remoteGc->Clear(TRect(10,10,11,11)); |
|
1008 remoteGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); |
|
1009 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
1010 CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap; |
|
1011 User::LeaveIfError(bitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b)); |
|
1012 User::LeaveIfError(bitmapMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b)); |
|
1013 remoteGc->BitBlt(TPoint(100,100), bitmap); |
|
1014 remoteGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); |
|
1015 remoteGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); |
|
1016 CWsBitmap* bitmapWs = new (ELeave) CWsBitmap(TheClient->iWs); |
|
1017 CWsBitmap* bitmapWsMask = new (ELeave) CWsBitmap(TheClient->iWs); |
|
1018 User::LeaveIfError(bitmapWs->Load(_L("Z:\\WSTEST\\TEST.MBM"), 0)); |
|
1019 remoteGc->BitBlt(TPoint(110,110), bitmapWs); |
|
1020 remoteGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); |
|
1021 remoteGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); |
|
1022 remoteGc->SetFadingParameters(128,128); |
|
1023 remoteGc->SetFaded(EFalse); |
|
1024 remoteGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); |
|
1025 remoteGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); |
|
1026 remoteGc->SetOrigin(TPoint(0,30)); |
|
1027 remoteGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1028 remoteGc->SetClippingRect(TRect(0,0,10,10)); |
|
1029 remoteGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1030 remoteGc->SetPenSize(TSize(1,2)); |
|
1031 remoteGc->UseBrushPattern(bitmap); |
|
1032 remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1033 remoteGc->SetBrushOrigin(TPoint(0,0)); |
|
1034 remoteGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); |
|
1035 remoteGc->CancelClippingRect(); |
|
1036 remoteGc->DiscardBrushPattern(); |
|
1037 remoteGc->CancelClippingRegion(); |
|
1038 remoteGc->Reset(); |
|
1039 remoteGc->SetOrigin(TPoint(0,0)); |
|
1040 remoteGc->SetUnderlineStyle(EUnderlineOff); |
|
1041 remoteGc->SetStrikethroughStyle(EStrikethroughOff); |
|
1042 remoteGc->SetWordJustification(1,2); |
|
1043 remoteGc->SetCharJustification(1,2); |
|
1044 remoteGc->UseFont(font); |
|
1045 remoteGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); |
|
1046 remoteGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); |
|
1047 remoteGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); |
|
1048 remoteGc->MoveTo(TPoint(25,150)); |
|
1049 remoteGc->MoveBy(TPoint(5,5)); |
|
1050 remoteGc->DrawLineTo(TPoint(35,160)); |
|
1051 remoteGc->DrawLine(TPoint(35,160),TPoint(25,150)); |
|
1052 remoteGc->DrawLineBy(TPoint(15,6)); |
|
1053 remoteGc->Plot(TPoint(5,5)); |
|
1054 remoteGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); |
|
1055 remoteGc->DrawEllipse(TRect(0,90,10,100)); |
|
1056 remoteGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); |
|
1057 remoteGc->DrawBitmap(TPoint(150,150),bitmap); |
|
1058 remoteGc->DrawBitmap(TRect(160,160,170,170), bitmap); |
|
1059 remoteGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); |
|
1060 remoteGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); |
|
1061 remoteGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); |
|
1062 CArrayFixFlat<TPoint>* polyPoints = new(ELeave) CArrayFixFlat<TPoint>(3); //CArrayFixFlat |
|
1063 CleanupStack::PushL(polyPoints); |
|
1064 TRect rect (200,0,200,100); |
|
1065 polyPoints->AppendL(rect.iTl); |
|
1066 polyPoints->AppendL(rect.Center()); |
|
1067 polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); |
|
1068 remoteGc->DrawPolyLine(polyPoints); |
|
1069 remoteGc->DrawPolyLine(&polyPoints->At(0), 3); |
|
1070 remoteGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); |
|
1071 remoteGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); |
|
1072 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1073 MWsDrawResource* dr = static_cast<MWsDrawResource*>(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); |
|
1074 if(dr) |
|
1075 dr->DrawResource(TPoint(30, 40), drawableSource); |
|
1076 #endif |
|
1077 RRegion region; |
|
1078 remoteGc->SetClippingRegion(region); |
|
1079 remoteGc->DiscardFont(); |
|
1080 remoteGc->EndDraw(); |
|
1081 |
|
1082 RWsGraphicMsgBuf msgBuf; |
|
1083 CleanupClosePushL(msgBuf); |
|
1084 //Externalize the captured commands from remote gc in to a buffer |
|
1085 remoteGc->ExternalizeL(msgBuf, EFalse); |
|
1086 |
|
1087 CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); |
|
1088 CleanupStack::PushL(cmdBuf); |
|
1089 const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL(); |
|
1090 if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse) |
|
1091 { |
|
1092 User::Panic(_L("TestCommandBufferL"), KErrGeneral); |
|
1093 } |
|
1094 delete testCmdBuf; |
|
1095 //Internalize the buffer with captured commands (from CRemoteGC) |
|
1096 //in to CCommandBuffer |
|
1097 cmdBuf->InternalizeL(msgBuf.Pckg()); |
|
1098 |
|
1099 TheGc->Activate(*TestWin->Win()); |
|
1100 TestWin->Win()->Invalidate(); |
|
1101 |
|
1102 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
1103 /* |
|
1104 * Make sure anything that can leave is done outside the |
|
1105 * BeginRedraw/EndRedraw bracket. |
|
1106 */ |
|
1107 CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes(); |
|
1108 CleanupStack::PushL(wsGrap); |
|
1109 #endif |
|
1110 /* |
|
1111 * Note we need to still do BeginRedraw/EndRedraw for the TestWin Window |
|
1112 * even though the CRemoteGc we are going to Play into TestWin already has |
|
1113 * BeginRedraw/EndRedraw commands issued into it. Those commands just allow |
|
1114 * for replacement of draw ops already in the CRemoteGc to be replaced by |
|
1115 * new draw ops covering the same area. The BeginRedraw/EndRedraws never |
|
1116 * get Play()'ed into TestWin. |
|
1117 */ |
|
1118 TestWin->Win()->BeginRedraw(); |
|
1119 TheGc->Clear(); |
|
1120 //Play the commands on test window using command buffer |
|
1121 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1122 cmdBuf->Play(TPoint(), NULL, TRect(TestWin->Size()), TheClient->iWs, *TheGc); |
|
1123 #endif |
|
1124 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
1125 cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); |
|
1126 CleanupStack::PopAndDestroy(wsGrap); |
|
1127 #endif |
|
1128 TheGc->Deactivate(); |
|
1129 TestWin->Win()->EndRedraw(); |
|
1130 remoteGc->ResetCommandBuffer(); |
|
1131 BaseWin->Win()->Invalidate(); |
|
1132 BaseWin->Win()->BeginRedraw(); |
|
1133 TheGc->Activate(*BaseWin->Win()); |
|
1134 TheGc->Clear(); |
|
1135 TheGc->DrawRect(TRect(10,10,30,30)); |
|
1136 TheGc->Clear(TRect(10,10,11,11)); |
|
1137 TheGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); |
|
1138 TheGc->BitBlt(TPoint(100,100), bitmap); |
|
1139 TheGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); |
|
1140 TheGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); |
|
1141 TheGc->BitBlt(TPoint(110,110), bitmapWs); |
|
1142 TheGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); |
|
1143 TheGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); |
|
1144 TheGc->SetFadingParameters(128,128); |
|
1145 TheGc->SetFaded(EFalse); |
|
1146 TheGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); |
|
1147 TheGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); |
|
1148 TheGc->SetOrigin(TPoint(0,30)); |
|
1149 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1150 TheGc->SetClippingRect(TRect(0,0,10,10)); |
|
1151 TheGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1152 TheGc->SetPenSize(TSize(1,2)); |
|
1153 TheGc->UseBrushPattern(bitmap); |
|
1154 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1155 TheGc->SetBrushOrigin(TPoint(0,0)); |
|
1156 TheGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); |
|
1157 TheGc->CancelClippingRect(); |
|
1158 TheGc->DiscardBrushPattern(); |
|
1159 TheGc->CancelClippingRegion(); |
|
1160 TheGc->Reset(); |
|
1161 TheGc->SetOrigin(TPoint(0,0)); |
|
1162 TheGc->SetUnderlineStyle(EUnderlineOff); |
|
1163 TheGc->SetStrikethroughStyle(EStrikethroughOff); |
|
1164 TheGc->SetWordJustification(1,2); |
|
1165 TheGc->SetCharJustification(1,2); |
|
1166 TheGc->UseFont(font); |
|
1167 TheGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); |
|
1168 TheGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); |
|
1169 TheGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); |
|
1170 TheGc->MoveTo(TPoint(25,150)); |
|
1171 TheGc->MoveBy(TPoint(5,5)); |
|
1172 TheGc->DrawLineTo(TPoint(35,160)); |
|
1173 TheGc->DrawLine(TPoint(35,160),TPoint(25,150)); |
|
1174 TheGc->DrawLineBy(TPoint(15,6)); |
|
1175 TheGc->Plot(TPoint(5,5)); |
|
1176 TheGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); |
|
1177 TheGc->DrawEllipse(TRect(0,90,10,100)); |
|
1178 TheGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); |
|
1179 TheGc->DrawBitmap(TPoint(150,150),bitmap); |
|
1180 TheGc->DrawBitmap(TRect(160,160,170,170), bitmap); |
|
1181 TheGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); |
|
1182 TheGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); |
|
1183 TheGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); |
|
1184 TheGc->DrawPolyLine(polyPoints); |
|
1185 TheGc->DrawPolyLine(&polyPoints->At(0), 3); |
|
1186 TheGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); |
|
1187 TheGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); |
|
1188 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1189 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1190 TheGc->SetBrushColor(KRgbRed); |
|
1191 TheGc->SetPenColor(KRgbRed); |
|
1192 TheGc->DrawRect(TRect(30, 40, 32, 42)); |
|
1193 #endif |
|
1194 TheGc->DiscardFont(); |
|
1195 TheGc->Deactivate(); |
|
1196 BaseWin->Win()->EndRedraw(); |
|
1197 TheClient->Flush(); |
|
1198 TheClient->WaitForRedrawsToFinish(); |
|
1199 |
|
1200 //Check the text drawn on base and test windows. |
|
1201 TBool err = CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestCommandBufferL()")); |
|
1202 if (err) |
|
1203 { |
|
1204 INFO_PRINTF1(_L("The CheckRect function returned error.")); |
|
1205 } |
|
1206 delete bitmap; |
|
1207 INFO_PRINTF1(_L("bitmap deleted.")); |
|
1208 delete bitmapMask; |
|
1209 INFO_PRINTF1(_L("bitmapMask deleted.")); |
|
1210 delete bitmapWs; |
|
1211 INFO_PRINTF1(_L("bitmapWs deleted.")); |
|
1212 delete bitmapWsMask; |
|
1213 INFO_PRINTF1(_L("bitmapWsMask deleted.")); |
|
1214 |
|
1215 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1216 CleanupStack::PopAndDestroy(7, remoteGc); |
|
1217 #else |
|
1218 CleanupStack::PopAndDestroy(4, remoteGc); |
|
1219 #endif |
|
1220 CleanupStack::Pop();//font |
|
1221 INFO_PRINTF1(_L("CleanupStack popped.")); |
|
1222 TheClient->iScreen->ReleaseFont(font); |
|
1223 } |
|
1224 |
|
1225 /** |
|
1226 @SYMTestCaseID GRAPHICS-WSERV-0482 |
|
1227 @SYMPREQ 1841 |
|
1228 @SYMTestCaseDesc Play empty command buffer. |
|
1229 @SYMTestPriority Medium |
|
1230 @SYMTestStatus Implemented |
|
1231 @SYMTestActions |
|
1232 @SYMTestExpectedResults return KErrEof error |
|
1233 */ |
|
1234 void CTGc::TestEmptyCommandBufferL() |
|
1235 { |
|
1236 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
1237 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); |
|
1238 CleanupStack::PushL(wsGrap); |
|
1239 #endif |
|
1240 |
|
1241 CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); |
|
1242 CleanupStack::PushL(cmdBuf); |
|
1243 |
|
1244 TheGc->Activate(*TestWin->Win()); |
|
1245 TheGc->Clear(); |
|
1246 //Play the commands on test window using command buffer |
|
1247 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
1248 TInt err = cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); |
|
1249 #else |
|
1250 TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc); |
|
1251 #endif |
|
1252 if(err!=KErrEof) |
|
1253 { |
|
1254 User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral); |
|
1255 } |
|
1256 TheGc->Deactivate(); |
|
1257 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA |
|
1258 CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc |
|
1259 #else |
|
1260 CleanupStack::PopAndDestroy(cmdBuf); |
|
1261 #endif |
|
1262 } |
|
1263 |
|
1264 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1265 /** |
|
1266 @SYMTestCaseID GRAPHICS-WSERV-0486 |
|
1267 @SYMPREQ PREQ2095 |
|
1268 @SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow |
|
1269 effect on. |
|
1270 @SYMTestPriority High |
|
1271 @SYMTestStatus Implemented |
|
1272 @SYMTestActions Create a font with both outline and shadow effects, also use ClippingRect |
|
1273 and ClippingRegion. Record the commands using CRemoteGc and play the recorded commands on a |
|
1274 bitmap using MWsGraphicsContext. Use the same commands in CWindowGc and draw text on a |
|
1275 different window |
|
1276 @SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same |
|
1277 */ |
|
1278 void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL() |
|
1279 { |
|
1280 const TRect KTestRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); |
|
1281 const TRegionFix<1> KTestRegion(KTestRect); |
|
1282 const TRect KClippingRect1(5, 5, TestWin->Size().iWidth-10, 90); |
|
1283 const TRegionFix<1> KClippingRegion(KClippingRect1); |
|
1284 const TRect KClippingRect2(15, 15, TestWin->Size().iWidth-10, TestWin->Size().iHeight-10); |
|
1285 |
|
1286 CWsScreenDevice* device = TheClient->iScreen; |
|
1287 /* |
|
1288 * On hardware, the first screen runs in 64K colors, but the second screen (TV OUT) |
|
1289 * cannot run in this mode, it instead falls back to 16M colors. We need to ensure |
|
1290 * that we use matching color depths for our off-screen bitmaps so that accuracy is |
|
1291 * not lost since we compare bitmaps from the screen versus off-screen. |
|
1292 */ |
|
1293 const TDisplayMode displayMode = device->DisplayMode(); |
|
1294 |
|
1295 _LIT(KText,"RemoteGc & MWsGraphicsContext"); |
|
1296 TFontSpec fSpec(KTestFontTypefaceName,23); |
|
1297 fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
1298 fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); |
|
1299 fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); |
|
1300 |
|
1301 CFont *font; |
|
1302 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); |
|
1303 CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); |
|
1304 |
|
1305 //Record the commands using CRemoteGc |
|
1306 CRemoteGc* remoteGc = CRemoteGc::NewL(device); |
|
1307 CleanupStack::PushL(remoteGc); |
|
1308 remoteGc->BeginDraw(KTestRect); |
|
1309 //fill background with white |
|
1310 remoteGc->SetPenStyle(CFbsBitGc::ENullPen); |
|
1311 remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); |
|
1312 remoteGc->SetBrushColor(KRgbWhite); |
|
1313 remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size())); |
|
1314 remoteGc->SetPenStyle(CFbsBitGc::ESolidPen); |
|
1315 //Capturing the commands in remote gc |
|
1316 remoteGc->SetClippingRect(KClippingRect2); |
|
1317 remoteGc->SetClippingRegion(KClippingRegion); |
|
1318 remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); |
|
1319 remoteGc->SetBrushColor(TRgb(0,150,150)); |
|
1320 remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); |
|
1321 remoteGc->SetBrushColor(TRgb(150,100,150)); |
|
1322 remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); |
|
1323 remoteGc->SetBrushColor(KRgbGreen); |
|
1324 remoteGc->SetShadowColor(KRgbDarkRed); |
|
1325 remoteGc->SetPenColor(KRgbBlack); |
|
1326 remoteGc->UseFont(font); |
|
1327 remoteGc->DrawText(KText, TPoint(2,40)); |
|
1328 remoteGc->DiscardFont(); |
|
1329 remoteGc->EndDraw(); |
|
1330 |
|
1331 RWsGraphicMsgBuf msgBuf; |
|
1332 CleanupClosePushL(msgBuf); |
|
1333 //Externalize the captured commands from remote gc in to a buffer |
|
1334 remoteGc->ExternalizeL(msgBuf, ETrue); |
|
1335 |
|
1336 CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); |
|
1337 CleanupStack::PushL(cmdBuf); |
|
1338 //Internalize the buffer with captured commands (from CRemoteGC) |
|
1339 //in to CCommandBuffer |
|
1340 cmdBuf->InternalizeL(msgBuf.Pckg()); |
|
1341 |
|
1342 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); |
|
1343 User::LeaveIfNull(theDGdiDriver); |
|
1344 |
|
1345 TSgImageInfo info; |
|
1346 info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; |
|
1347 info.iSizeInPixels = TestWin->Size(); |
|
1348 info.iPixelFormat = PixelFormatFromDisplayMode(displayMode); |
|
1349 |
|
1350 RSgImageCollection imageCollection; |
|
1351 CleanupClosePushL(imageCollection); |
|
1352 TInt res = imageCollection.Create(info, 1); |
|
1353 User::LeaveIfError(res); |
|
1354 RSgImage image; |
|
1355 CleanupClosePushL(image); |
|
1356 res = imageCollection.OpenImage(0, image); |
|
1357 User::LeaveIfError(res); |
|
1358 RDirectGdiImageTarget imageTarget(*theDGdiDriver); |
|
1359 CleanupClosePushL(imageTarget); |
|
1360 |
|
1361 res = imageTarget.Create(image); |
|
1362 User::LeaveIfError(res); |
|
1363 |
|
1364 CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget); |
|
1365 CleanupStack::PushL(directGdiGcWrapper); |
|
1366 |
|
1367 //Dummy class created |
|
1368 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); |
|
1369 CleanupStack::PushL(wsGrap); |
|
1370 |
|
1371 //Play the commands on test window using command buffer |
|
1372 cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper); |
|
1373 |
|
1374 //Set window back to same as test bitmap background |
|
1375 BaseWin->Win()->SetBackgroundColor(KRgbWhite); |
|
1376 |
|
1377 BaseWin->Win()->Invalidate(); |
|
1378 BaseWin->Win()->BeginRedraw(); |
|
1379 TheGc->Activate(*BaseWin->Win()); |
|
1380 TheGc->Clear(); |
|
1381 TheGc->SetClippingRect(KClippingRect2); |
|
1382 TheGc->SetClippingRegion(KClippingRegion); |
|
1383 TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush); |
|
1384 TheGc->SetBrushColor(TRgb(0,150,150)); |
|
1385 TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); |
|
1386 TheGc->SetBrushColor(TRgb(150,100,150)); |
|
1387 TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); |
|
1388 TheGc->SetBrushColor(KRgbGreen); |
|
1389 TheGc->SetShadowColor(KRgbDarkRed); |
|
1390 TheGc->SetPenColor(KRgbBlack); |
|
1391 TheGc->UseFont(font); |
|
1392 //Draw the text on base window using CWindowGC |
|
1393 TheGc->DrawText(KText, TPoint(2, 40)); |
|
1394 TheGc->DiscardFont(); |
|
1395 TheGc->Deactivate(); |
|
1396 BaseWin->Win()->EndRedraw(); |
|
1397 TheClient->iWs.Finish(); |
|
1398 TheClient->WaitForRedrawsToFinish(); |
|
1399 |
|
1400 //Create a bitmap and then copy the screen to it |
|
1401 TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size())); |
|
1402 CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap(); |
|
1403 User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode)); |
|
1404 CleanupStack::PushL(screenBitmap); |
|
1405 TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc); |
|
1406 |
|
1407 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
1408 CleanupStack::PushL(bitmap); |
|
1409 |
|
1410 image.GetInfo(info); |
|
1411 bitmap->Create(info.iSizeInPixels, displayMode); |
|
1412 TRect rect(info.iSizeInPixels); |
|
1413 CopyImageToBitmapL(bitmap, image, rect); |
|
1414 |
|
1415 //Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap |
|
1416 TInt differentPixels = 0; |
|
1417 res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger()); |
|
1418 if (differentPixels != 0) |
|
1419 { |
|
1420 INFO_PRINTF2(_L(" Pixels different %d"), differentPixels); |
|
1421 } |
|
1422 TEST(res); |
|
1423 CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap |
|
1424 CleanupStack::Pop();//font |
|
1425 TheClient->iScreen->ReleaseFont(font); |
|
1426 } |
|
1427 |
|
1428 /** |
|
1429 @SYMTestCaseID GRAPHICS-WSERV-0487 |
|
1430 @SYMPREQ PREQ2095 |
|
1431 @SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&) |
|
1432 @SYMTestPriority High |
|
1433 @SYMTestStatus Implemented |
|
1434 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. |
|
1435 Record the same DrawText commands using CRemoteGc and play the recorded commands on a |
|
1436 bitmap using MWsGraphicsContext. Compare the two bitmaps. |
|
1437 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same |
|
1438 */ |
|
1439 void CTGc::TestCRemoteGcDrawTextInContextPointL() |
|
1440 { |
|
1441 CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL(); |
|
1442 CleanupStack::PushL(test); |
|
1443 test->Test(); |
|
1444 TEST(test->HasPassedTest()); |
|
1445 CleanupStack::PopAndDestroy(); //test |
|
1446 } |
|
1447 |
|
1448 /** |
|
1449 @SYMTestCaseID GRAPHICS-WSERV-0488 |
|
1450 @SYMPREQ PREQ2095 |
|
1451 @SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) |
|
1452 @SYMTestPriority High |
|
1453 @SYMTestStatus Implemented |
|
1454 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. |
|
1455 Record the same DrawText commands using CRemoteGc and play the recorded commands on a |
|
1456 bitmap using MWsGraphicsContext. Compare the two bitmaps. |
|
1457 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same |
|
1458 */ |
|
1459 void CTGc::TestCRemoteGcDrawTextInContextBoxL() |
|
1460 { |
|
1461 CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL(); |
|
1462 CleanupStack::PushL(test); |
|
1463 test->Test(); |
|
1464 TEST(test->HasPassedTest()); |
|
1465 CleanupStack::PopAndDestroy(); //test |
|
1466 } |
|
1467 |
|
1468 /** |
|
1469 @SYMTestCaseID GRAPHICS-WSERV-0489 |
|
1470 @SYMPREQ PREQ2095 |
|
1471 @SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&) |
|
1472 @SYMTestPriority High |
|
1473 @SYMTestStatus Implemented |
|
1474 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. |
|
1475 Record the same DrawText commands using CRemoteGc and play the recorded commands on a |
|
1476 bitmap using MWsGraphicsContext. Compare the two bitmaps. |
|
1477 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same |
|
1478 */ |
|
1479 void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL() |
|
1480 { |
|
1481 CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL(); |
|
1482 CleanupStack::PushL(test); |
|
1483 test->Test(); |
|
1484 TEST(test->HasPassedTest()); |
|
1485 CleanupStack::PopAndDestroy(); //test |
|
1486 } |
|
1487 |
|
1488 /** |
|
1489 @SYMTestCaseID GRAPHICS-WSERV-0490 |
|
1490 @SYMPREQ PREQ2095 |
|
1491 @SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) |
|
1492 @SYMTestPriority High |
|
1493 @SYMTestStatus Implemented |
|
1494 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. |
|
1495 Record the same DrawText commands using CRemoteGc and play the recorded commands on a |
|
1496 bitmap using MWsGraphicsContext. Compare the two bitmaps. |
|
1497 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same |
|
1498 */ |
|
1499 void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL() |
|
1500 { |
|
1501 CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL(); |
|
1502 CleanupStack::PushL(test); |
|
1503 test->Test(); |
|
1504 TEST(test->HasPassedTest()); |
|
1505 CleanupStack::PopAndDestroy(); //test |
|
1506 } |
|
1507 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1508 |
|
1509 /** |
|
1510 @SYMTestCaseID GRAPHICS-WSERV-0494 |
|
1511 @SYMDEF DEF131255 |
|
1512 @SYMTestCaseDesc Negative test to show that using SetBrushStyle() will not panic WServ with different |
|
1513 brush bitmaps. |
|
1514 @SYMTestPriority High |
|
1515 @SYMTestStatus Implemented |
|
1516 @SYMTestActions Four seperate panic situations are tested: |
|
1517 1) |
|
1518 Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. |
|
1519 Draw a line to force the playback to occur. |
|
1520 Call Finish on the GC. |
|
1521 Destroy the brush bitmap. |
|
1522 2) |
|
1523 Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. |
|
1524 Draw a line to force the playback to occur. |
|
1525 Destroy the brush bitmap. |
|
1526 Call Finish on the GC. |
|
1527 3+4) |
|
1528 Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush. |
|
1529 Draw a line to force the playback to occur. |
|
1530 Set the brush bitmap and style again. |
|
1531 Call Finish on the GC. |
|
1532 Destroy the brush bitmap. |
|
1533 @SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called. |
|
1534 */ |
|
1535 void CTGc::TestGcSetBrushPatternL() |
|
1536 { |
|
1537 // Extended bitmap test data. |
|
1538 const TUint8 KTestData[] = "TEST DATA"; |
|
1539 const TInt KTestDataSize = sizeof(KTestData); |
|
1540 const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF); |
|
1541 |
|
1542 // First try using a regular bitmap as the brush pattern. |
|
1543 BaseWin->Win()->Invalidate(); |
|
1544 BaseWin->Win()->BeginRedraw(); |
|
1545 TheGc->Activate(*BaseWin->Win()); |
|
1546 CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap; |
|
1547 CleanupStack::PushL(bitmapRegular); |
|
1548 TInt res = bitmapRegular->Create(TSize(10,10), EColor64K); |
|
1549 TEST(res == KErrNone); |
|
1550 //Record the commands using CWindowGc. |
|
1551 TheGc->UseBrushPattern(bitmapRegular); |
|
1552 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1553 // DrawLine() is only used here to force playback of the commands. |
|
1554 TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); |
|
1555 TheGc->Deactivate(); |
|
1556 BaseWin->Win()->EndRedraw(); |
|
1557 TheClient->iWs.Finish(); |
|
1558 CleanupStack::PopAndDestroy(1, bitmapRegular); |
|
1559 |
|
1560 // Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap |
|
1561 // before calling Finish(). |
|
1562 BaseWin->Win()->Invalidate(); |
|
1563 BaseWin->Win()->BeginRedraw(); |
|
1564 TheGc->Activate(*BaseWin->Win()); |
|
1565 bitmapRegular = new (ELeave) CFbsBitmap; |
|
1566 CleanupStack::PushL(bitmapRegular); |
|
1567 res = bitmapRegular->Create(TSize(10,10), EColor64K); |
|
1568 TEST(res == KErrNone); |
|
1569 //Record the commands using CWindowGc. |
|
1570 TheGc->UseBrushPattern(bitmapRegular); |
|
1571 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1572 TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); |
|
1573 CleanupStack::PopAndDestroy(1, bitmapRegular); |
|
1574 TheGc->Deactivate(); |
|
1575 BaseWin->Win()->EndRedraw(); |
|
1576 TheClient->iWs.Finish(); |
|
1577 |
|
1578 // Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as |
|
1579 // the brush pattern. |
|
1580 BaseWin->Win()->Invalidate(); |
|
1581 BaseWin->Win()->BeginRedraw(); |
|
1582 TheGc->Activate(*BaseWin->Win()); |
|
1583 // Create a dummy extended bitmap to use as a brush bitmap. |
|
1584 // This is unsupported by the default implementation of DirectGDI. |
|
1585 CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap; |
|
1586 CleanupStack::PushL(bitmapExtended); |
|
1587 res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize); |
|
1588 TEST(res == KErrNone); |
|
1589 //Record the commands using CWindowGc. |
|
1590 TheGc->UseBrushPattern(bitmapExtended); |
|
1591 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1592 TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); |
|
1593 TheGc->UseBrushPattern(bitmapExtended); |
|
1594 // Forth, do it twice so that we test the state commands and the drawops commands. |
|
1595 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1596 TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); |
|
1597 TheGc->Deactivate(); |
|
1598 BaseWin->Win()->EndRedraw(); |
|
1599 TheClient->iWs.Finish(); |
|
1600 CleanupStack::PopAndDestroy(1, bitmapExtended); |
|
1601 } |
|
1602 |
|
1603 /** |
|
1604 @SYMTestCaseID GRAPHICS-WSERV-0576 |
|
1605 @SYMDEF |
|
1606 @SYMTestCaseDesc Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap. |
|
1607 @SYMTestPriority High |
|
1608 @SYMTestStatus Implemented |
|
1609 @SYMTestActions - Draw the bitmap to TestWin (keeping the window hidden) |
|
1610 - Delete the bitmap |
|
1611 - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted) |
|
1612 - Draw the same bitmap (same image, different bitmap object instance) to BaseWin |
|
1613 - Compare contents of TestWin with BaseWin |
|
1614 @SYMTestExpectedResults TestWin and BaseWin should both show the bitmap. |
|
1615 */ |
|
1616 void CTGc::TestGcDeleteBitmap1L() |
|
1617 { |
|
1618 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
1619 CleanupStack::PushL(bitmap); |
|
1620 TInt ret = bitmap->Load(TEST_BITMAP_NAME,0); |
|
1621 TEST(ret == KErrNone); |
|
1622 |
|
1623 // send drawing to hidden window |
|
1624 TestWin->SetVisible(EFalse); |
|
1625 TestWin->Win()->Invalidate(); |
|
1626 TestWin->Win()->BeginRedraw(); |
|
1627 TheGc->Activate(*TestWin->Win()); |
|
1628 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1629 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1630 TheGc->SetBrushColor(TRgb(255, 0, 0)); |
|
1631 TheGc->Clear(); |
|
1632 TheGc->BitBlt(TPoint(0,0), bitmap); |
|
1633 CleanupStack::PopAndDestroy(bitmap); // before the bitmap is actually deleted, WsFbsDestroyCallBack flushes the command buffer to ensure the bitmap is duplicated in the window server thread |
|
1634 bitmap = NULL; |
|
1635 TheGc->Deactivate(); |
|
1636 TestWin->Win()->EndRedraw(); |
|
1637 TheClient->iWs.Flush(); // calling Flush rather than Finish, as we don't need to wait for any drawing to happen (as the window is currently hidden) |
|
1638 |
|
1639 // make window visible (forcing it to draw) |
|
1640 TestWin->SetVisible(ETrue); |
|
1641 TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win |
|
1642 |
|
1643 // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing |
|
1644 // the window now (by making it visible above) should display the bitmap on screen, even |
|
1645 // though we've deleted it in this thread |
|
1646 |
|
1647 // now create the bitmap again, and draw it to the base win (for comparison with test win) |
|
1648 bitmap = new (ELeave) CFbsBitmap; |
|
1649 CleanupStack::PushL(bitmap); |
|
1650 ret = bitmap->Load(TEST_BITMAP_NAME,0); |
|
1651 TEST(ret == KErrNone); |
|
1652 BaseWin->SetVisible(ETrue); |
|
1653 BaseWin->Win()->Invalidate(); |
|
1654 BaseWin->Win()->BeginRedraw(); |
|
1655 TheGc->Activate(*BaseWin->Win()); |
|
1656 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1657 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1658 TheGc->SetBrushColor(TRgb(255, 0, 0)); |
|
1659 TheGc->Clear(); |
|
1660 TheGc->BitBlt(TPoint(0,0), bitmap); |
|
1661 TheGc->Deactivate(); |
|
1662 BaseWin->Win()->EndRedraw(); |
|
1663 TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win |
|
1664 |
|
1665 CleanupStack::PopAndDestroy(bitmap); |
|
1666 |
|
1667 // the test bitmap should be shown in both base win and test win, so we now check that the |
|
1668 // contents of base win and test win are the same |
|
1669 CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()")); |
|
1670 } |
|
1671 |
|
1672 /** |
|
1673 @SYMTestCaseID GRAPHICS-WSERV-0577 |
|
1674 @SYMDEF |
|
1675 @SYMTestCaseDesc Check window server is still able to use a bitmap required by window drawing, even |
|
1676 after the client has released its handle to the bitmap. Also check window server |
|
1677 releases the bitmap, when it's no longer used by window drawing. |
|
1678 @SYMTestPriority High |
|
1679 @SYMTestStatus Implemented |
|
1680 @SYMTestActions - Clean BaseWin and TestWin from content that has been left over from previous test |
|
1681 - Draw test bitmap to TestWin |
|
1682 - Delete the bitmap |
|
1683 - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing) |
|
1684 - Delete the bitmap |
|
1685 - Draw new content to TestWin, so that previously drawn bitmap is covered |
|
1686 - Duplicate bitmap (the bitmap is no longer used by window drawing) |
|
1687 @SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas |
|
1688 bitmap duplication fails, when the bitmap is no longer used by window drawing. |
|
1689 */ |
|
1690 void CTGc::TestGcDeleteBitmap2L() |
|
1691 { |
|
1692 //send new drawing to test and base windows, in order to cover |
|
1693 //any content has been left on them (through previous test) |
|
1694 BaseWin->SetVisible(ETrue); |
|
1695 BaseWin->Win()->Invalidate(); |
|
1696 BaseWin->Win()->BeginRedraw(); |
|
1697 TheGc->Activate(*BaseWin->Win()); |
|
1698 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1699 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1700 TheGc->SetBrushColor(TRgb(0, 0, 255)); |
|
1701 TheGc->Clear(); |
|
1702 TheGc->Deactivate(); |
|
1703 BaseWin->Win()->EndRedraw(); |
|
1704 |
|
1705 TestWin->SetVisible(ETrue); |
|
1706 TestWin->Win()->Invalidate(); |
|
1707 TestWin->Win()->BeginRedraw(); |
|
1708 TheGc->Activate(*TestWin->Win()); |
|
1709 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1710 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1711 TheGc->SetBrushColor(TRgb(0, 0, 255)); |
|
1712 TheGc->Clear(); |
|
1713 TheGc->Deactivate(); |
|
1714 TestWin->Win()->EndRedraw(); |
|
1715 |
|
1716 TheClient->iWs.Flush(); |
|
1717 TheClient->iWs.Finish(); |
|
1718 |
|
1719 //load test bitmap |
|
1720 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
1721 CleanupStack::PushL(bitmap); |
|
1722 TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0); |
|
1723 TEST(ret == KErrNone); |
|
1724 TInt bitmapHandle = bitmap->Handle(); |
|
1725 |
|
1726 //send bitmap drawing to test window |
|
1727 TestWin->Win()->Invalidate(); |
|
1728 TestWin->Win()->BeginRedraw(); |
|
1729 TheGc->Activate(*TestWin->Win()); |
|
1730 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1731 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1732 TheGc->SetBrushColor(TRgb(0, 255, 0)); |
|
1733 TheGc->Clear(); |
|
1734 TheGc->BitBlt(TPoint(0,0), bitmap); |
|
1735 TheGc->Deactivate(); |
|
1736 TestWin->Win()->EndRedraw(); |
|
1737 |
|
1738 CleanupStack::PopAndDestroy(bitmap); |
|
1739 |
|
1740 TheClient->iWs.Flush(); |
|
1741 TheClient->iWs.Finish(); |
|
1742 |
|
1743 //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though |
|
1744 //the initial bitmap object is deleted) , since there is a window segment using it |
|
1745 bitmap = new (ELeave) CFbsBitmap; |
|
1746 CleanupStack::PushL(bitmap); |
|
1747 ret = bitmap->Duplicate(bitmapHandle); |
|
1748 TEST(ret == KErrNone); |
|
1749 CleanupStack::PopAndDestroy(bitmap); |
|
1750 |
|
1751 //send new drawing to test window, in order to cover the bitmap that was previously drawn |
|
1752 TestWin->Win()->Invalidate(); |
|
1753 TestWin->Win()->BeginRedraw(); |
|
1754 TheGc->Activate(*TestWin->Win()); |
|
1755 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1756 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1757 TheGc->SetBrushColor(TRgb(0, 0, 255)); |
|
1758 TheGc->Clear(); |
|
1759 TheGc->Deactivate(); |
|
1760 TestWin->Win()->EndRedraw(); |
|
1761 |
|
1762 TheClient->iWs.Flush(); |
|
1763 TheClient->iWs.Finish(); |
|
1764 |
|
1765 //check that wserv can't duplicate test bitmap, since no window segment uses it any more |
|
1766 bitmap = new (ELeave) CFbsBitmap; |
|
1767 CleanupStack::PushL(bitmap); |
|
1768 ret = bitmap->Duplicate(bitmapHandle); |
|
1769 TEST(ret != KErrNone); |
|
1770 CleanupStack::PopAndDestroy(bitmap); |
|
1771 } |
|
1772 |
|
1773 void CTGc::RunTestCaseL(TInt /*aCurTestCase*/) |
|
1774 { |
|
1775 ((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
1776 switch(++iTest->iState) |
|
1777 { |
|
1778 case 1: |
|
1779 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437")); |
|
1780 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text")); |
|
1781 TestOutlineAndShadowL(); |
|
1782 break; |
|
1783 case 2: |
|
1784 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); |
|
1785 iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); |
|
1786 TestGcClipRectOrigin(); |
|
1787 break; |
|
1788 case 3: |
|
1789 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); |
|
1790 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); |
|
1791 TestResetWithBackgroundColorL(); |
|
1792 break; |
|
1793 case 4: |
|
1794 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481")); |
|
1795 iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests")); |
|
1796 TestCommandBufferL(); |
|
1797 break; |
|
1798 case 5: |
|
1799 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482")); |
|
1800 iTest->LogSubTest(_L("CCommandBuffer, coverage tests")); |
|
1801 TestEmptyCommandBufferL(); |
|
1802 break; |
|
1803 case 6: |
|
1804 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494")); |
|
1805 iTest->LogSubTest(_L("CWindowGc, Brush Pattern test")); |
|
1806 TestGcSetBrushPatternL(); |
|
1807 break; |
|
1808 case 7: |
|
1809 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576")); |
|
1810 iTest->LogSubTest(_L("CWindowGc, delete bitmap 1")); |
|
1811 TestGcDeleteBitmap1L(); |
|
1812 break; |
|
1813 case 8: |
|
1814 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577")); |
|
1815 iTest->LogSubTest(_L("CWindowGc, delete bitmap 2")); |
|
1816 TestGcDeleteBitmap2L(); |
|
1817 break; |
|
1818 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1819 case 9: |
|
1820 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); |
|
1821 iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); |
|
1822 TestGcClipRectOrigin(); |
|
1823 break; |
|
1824 case 10: |
|
1825 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); |
|
1826 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); |
|
1827 TestResetWithBackgroundColorL(); |
|
1828 break; |
|
1829 case 11: |
|
1830 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486")); |
|
1831 iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test")); |
|
1832 TestCRemoteGcAndMWsGraphicsContextClippingRectL(); |
|
1833 break; |
|
1834 case 12: |
|
1835 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487")); |
|
1836 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test")); |
|
1837 TestCRemoteGcDrawTextInContextPointL(); |
|
1838 break; |
|
1839 case 13: |
|
1840 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488")); |
|
1841 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test")); |
|
1842 TestCRemoteGcDrawTextInContextBoxL(); |
|
1843 break; |
|
1844 case 14: |
|
1845 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489")); |
|
1846 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical test")); |
|
1847 TestCRemoteGcDrawTextInContextPointVerticalL(); |
|
1848 break; |
|
1849 case 15: |
|
1850 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490")); |
|
1851 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert test")); |
|
1852 TestCRemoteGcDrawTextInContextBoxVerticalL(); |
|
1853 break; |
|
1854 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA |
|
1855 default: |
|
1856 ((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
1857 ((CTGcStep*)iStep)->CloseTMSGraphicsStep(); |
|
1858 TestComplete(); |
|
1859 break; |
|
1860 } |
|
1861 ((CTGcStep*)iStep)->RecordTestResultL(); |
|
1862 } |
|
1863 |
|
1864 __CONSTRUCT_STEP__(Gc) |