First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
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>
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);
38 GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect)
41 TInt res = aImage.GetInfo(info);
44 info.iUsage = ESgUsageNone;
45 info.iCpuAccess = ESgCpuAccessReadOnly;
47 res = image.Create(info, aImage);
50 const TAny* dataAddressSrc = NULL;
51 TInt dataStrideSrc = 0;
52 res = image.MapReadOnly(dataAddressSrc, dataStrideSrc);
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();
61 TRect rectDest = info.iSizeInPixels;
62 rect.Intersection(rectDest);
63 if(rect.Height() > bitmapSize.iHeight)
65 rect.SetHeight(bitmapSize.iHeight);
67 if(rect.Width() > bitmapSize.iWidth)
69 rect.SetWidth(bitmapSize.iWidth);
71 CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc,
72 dataStrideSrc, displayModeSrc, rect);
81 GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest,
82 TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect)
87 if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest))
89 Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height());
93 switch(aDisplayModeSrc)
97 CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest,
98 (TUint16*)aDataAddressSrc, aDataStrideSrc, aRect);
106 GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest,
107 TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect)
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;
116 switch(aDisplayModeDest)
120 TUint16* dataAddressDest = static_cast<TUint16*> (aDataAddressDest);
121 const TInt dataStrideLengthDest = aDataStrideDest / bppSrc;
122 while(dataAddressSrcEnd > dataAddressSrc)
124 Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc);
125 dataAddressSrc += dataStrideLengthSrc;
126 dataAddressDest += dataStrideLengthDest;
132 const TInt bppDest = 4;
133 TUint32* dataAddressDest = static_cast<TUint32*> (aDataAddressDest);
134 const TInt dataStrideLengthDest = aDataStrideDest / bppDest;
136 while(dataAddressSrcEnd > dataAddressSrc)
138 const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width;
139 TUint32* dataAddressDestCur = dataAddressDest;
140 TUint16* dataAddressSrcCur = dataAddressSrc;
142 while(dataAddressSrcLineEnd > dataAddressSrcCur)
144 *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU();
145 dataAddressDestCur++;
148 dataAddressSrc += dataStrideLengthSrc;
149 dataAddressDest += dataStrideLengthDest;
155 TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
156 const TInt dataStrideLengthDest = aDataStrideDest;
158 while(dataAddressSrcEnd > dataAddressSrc)
160 const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
161 TUint8* dataAddressDestCur = dataAddressDest;
162 TUint16* dataAddressSrcCur = dataAddressSrc;
164 while(dataAddressDstLineEnd > dataAddressDestCur)
166 *dataAddressDestCur = 0;
167 for(TInt index = 0; index < 8; index +=2)
169 TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4();
171 *dataAddressDestCur |= col;
174 dataAddressDestCur++;
176 dataAddressSrc += dataStrideLengthSrc;
177 dataAddressDest += dataStrideLengthDest;
183 TUint8* dataAddressDest = static_cast<TUint8*> (aDataAddressDest);
184 const TInt dataStrideLengthDest = aDataStrideDest;
186 while(dataAddressSrcEnd > dataAddressSrc)
188 const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest;
189 TUint8* dataAddressDestCur = dataAddressDest;
190 TUint16* dataAddressSrcCur = dataAddressSrc;
192 while(dataAddressDstLineEnd > dataAddressDestCur)
194 *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256();
196 dataAddressDestCur++;
198 dataAddressSrc += dataStrideLengthSrc;
199 dataAddressDest += dataStrideLengthDest;
208 TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat)
212 case EUidPixelFormatARGB_8888_PRE:
214 case EUidPixelFormatARGB_8888:
216 case EUidPixelFormatRGB_565:
224 TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode)
226 switch (aDisplayMode)
237 return EUidPixelFormatXRGB_8888;
241 return EUidPixelFormatXRGB_4444;
245 return EUidPixelFormatRGB_565;
249 return EUidPixelFormatARGB_8888;
253 return EUidPixelFormatARGB_8888_PRE;
257 return EUidPixelFormatUnknown;
263 CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep)
270 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
272 CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
275 directGdiDriver->Close();
280 void CTGc::ConstructL()
282 _LIT(KTestName,"GC Test");
283 iTest=new(ELeave) CTestBase(KTestName,this);
285 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
286 TInt err = CDirectGdiDriver::Open();
287 User::LeaveIfError(err);
288 err = SgDriver::Open();
291 CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static();
294 directGdiDriver->Close();
301 //Class derived from MWsGraphicResolver. Used for playing the commands from command buffer
302 class CWSGraphicsRes: public CBase, public MWsGraphicResolver
305 void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const
307 //Orveriding by giving empty implemention
311 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
313 //Class CDrawTextInContextTest
316 CDrawTextInContextTest::CDrawTextInContextTest(){}
318 CDrawTextInContextTest::~CDrawTextInContextTest()
325 delete iCommandBuffer;
326 delete iWsGraphicRes;
328 TheClient->iScreen->ReleaseFont(iFont);
330 delete iDirectGdiGcWrapper;
331 if(iWrapperImageTarget)
333 iWrapperImageTarget->Close();
335 delete iWrapperImageTarget;
336 iWrapperImage.Close();
337 iWrapperImageCollection.Close();
340 void CDrawTextInContextTest::BaseConstructL()
342 //Initialise font settings
344 fsp.iTypeface.iName=_L("Series 60 Sans");
346 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp));
348 //Initialise TTextParameter
353 iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"));
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));
361 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
362 User::LeaveIfNull(theDGdiDriver);
365 info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
366 info.iSizeInPixels = KBitmapSize;
367 info.iPixelFormat = EUidPixelFormatRGB_565;
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);
378 //clean image-----------------
379 CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget);
380 CleanupStack::PushL(directGdiGcWrapper);
382 directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha);
383 directGdiGcWrapper->SetBrushColor(KRgbWhite);
384 directGdiGcWrapper->Clear();
386 CleanupStack::PopAndDestroy(1, directGdiGcWrapper);
389 //Used to record draw commands
390 iRemoteGc = CRemoteGc::NewL(TheClient->iScreen);
392 //Used to play recorded draw commands
393 iCommandBuffer = CCommandBuffer::NewL();
395 //Dummy class created required for CCommandBuffer::Play
396 iWsGraphicRes = new (ELeave) CWSGraphicsRes();
398 //Offset for CCommandBuffer::Play
399 iOffset = TPoint(0,0);
401 //Result of doing the test
402 iHasPassedTest = EFalse;
405 void CDrawTextInContextTest::Test()
407 /* Create reference bitmap by drawing using bitgc */
408 iRefBitGc->UseFont(iFont);
410 iRefBitGc->DiscardFont();
412 /* Drawing using CBitGcWrapper via CRemotGc*/
414 //Capturing the commands in remote gc
415 iRemoteGc->BeginDraw(KBitmapRect);
416 iRemoteGc->UseFont(iFont);
417 DoDrawTextRemoteGc();
418 iRemoteGc->DiscardFont();
419 iRemoteGc->EndDraw();
421 //Externalize the captured commands from remote gc in to a buffer
422 iRemoteGc->ExternalizeL(iMsgBuf, ETrue);
424 //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer
425 iCommandBuffer->InternalizeL(iMsgBuf.Pckg());
427 //Play the commands on test window using command buffer
428 iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper);
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);
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);
441 iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse);
443 CleanupStack::PopAndDestroy(bitmap);
446 TBool CDrawTextInContextTest::HasPassedTest()
448 return iHasPassedTest;
452 // Class DrawTextInContextTestPoint
455 CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){}
457 CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){}
459 CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL()
461 CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint;
462 CleanupStack::PushL(self);
464 CleanupStack::Pop(self);
468 void CDrawTextInContextTestPoint::ConstructL()
471 iPosition = TPoint(0,0);
474 void CDrawTextInContextTestPoint::DoDrawTextBitGc()
476 iRefBitGc->DrawText(iText,&iParam,iPosition);
479 void CDrawTextInContextTestPoint::DoDrawTextRemoteGc()
481 iRemoteGc->DrawText(iText,&iParam,iPosition);
485 // Class DrawTextInContextTestBox
488 CDrawTextInContextTestBox::CDrawTextInContextTestBox(){}
490 CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){}
492 CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL()
494 CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox;
495 CleanupStack::PushL(self);
497 CleanupStack::Pop(self);
501 void CDrawTextInContextTestBox::ConstructL()
504 iClipFillRect = TRect(10,50,640,120);
505 iBaselineOffset = 40;
506 iTTextAlign = CGraphicsContext::ELeft;
509 void CDrawTextInContextTestBox::DoDrawTextBitGc()
511 iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
514 void CDrawTextInContextTestBox::DoDrawTextRemoteGc()
516 iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign);
520 // Class CDrawTextInContextTestPointVertical
523 CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){}
525 CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){}
527 CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL()
529 CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical;
530 CleanupStack::PushL(self);
532 CleanupStack::Pop(self);
536 void CDrawTextInContextTestPointVertical::ConstructL()
539 iPosition = TPoint(0,0);
543 void CDrawTextInContextTestPointVertical::DoDrawTextBitGc()
545 iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
548 void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc()
550 iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp);
554 // Class CDrawTextInContextTestBoxVertical
557 CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){}
559 CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){}
561 CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL()
563 CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical;
564 CleanupStack::PushL(self);
566 CleanupStack::Pop(self);
570 void CDrawTextInContextTestBoxVertical::ConstructL()
573 iClipFillRect = TRect(10,50,640,120);
574 iBaselineOffset = 40;
576 iTTextAlign = CGraphicsContext::ELeft;
579 void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc()
581 iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
584 void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc()
586 iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign);
588 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
590 void CleanUpFont(TAny* aFont)
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);
598 @SYMTestCaseID GRAPHICS-WSERV-0437
600 @SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow
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
609 void CTGc::TestOutlineAndShadowL()
611 TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
612 TRegionFix<1> clippingRegion(sourceRect);
614 CWsScreenDevice* device = TheClient->iScreen;
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);
623 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
624 CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
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();
638 RWsGraphicMsgBuf msgBuf;
639 CleanupClosePushL(msgBuf);
640 //Externalize the captured commands from remote gc in to a buffer
641 remoteGc->ExternalizeL(msgBuf, ETrue);
643 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
644 CleanupStack::PushL(wsGrap);
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());
652 TestWin->Win()->Invalidate();
653 TestWin->Win()->BeginRedraw();
654 TheGc->Activate(*TestWin->Win());
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);
660 cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
663 TestWin->Win()->EndRedraw();
665 BaseWin->Win()->Invalidate();
666 BaseWin->Win()->BeginRedraw();
667 TheGc->Activate(*BaseWin->Win());
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();
677 BaseWin->Win()->EndRedraw();
678 TheClient->iWs.Finish();
679 TheClient->WaitForRedrawsToFinish();
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()"));
684 CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc
685 CleanupStack::Pop();//font
686 TheClient->iScreen->ReleaseFont(font);
689 void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/)
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);
699 aWindow.Win()->SetBackgroundColor(KRgbGreen);
701 aWindow.Win()->Invalidate();
703 if(!bActivateBeforeRedraw)
705 aWindow.Win()->BeginRedraw();
708 TheGc->Activate(*(aWindow.Win()));
709 TheGc->SetOrigin(gcOrigin);
710 TheGc->SetClippingRect(gcClipRect);
712 if(bActivateBeforeRedraw)
714 aWindow.Win()->BeginRedraw();
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);
728 aWindow.Win()->EndRedraw();
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.
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.
761 void CTGc::TestGcClipRectOrigin()
763 TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse);
764 TestGcClipRectOrigin_DrawContent(*TestWin, ETrue);
768 CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()"));
772 @SYMTestCaseID GRAPHICS-WSERV-0469
774 @SYMTestCaseDesc Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is
776 @SYMTestPriority High
777 @SYMTestStatus Implemented
779 @SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of
780 the window, and MWsGraphicsContext should use transparent white.
782 void CTGc::TestResetWithBackgroundColorL()
784 const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight);
785 const TRegionFix<1> KClippingRegion(KSourceRect);
787 CWsScreenDevice* device = TheClient->iScreen;
789 CRemoteGc* remoteGc = CRemoteGc::NewL(device);
790 CleanupStack::PushL(remoteGc);
792 //note this remote GC has not been activated on any window
793 remoteGc->BeginDraw(KSourceRect);
795 //Draw the commands in remote gc
796 remoteGc->SetBrushColor(KRgbGreen); //nothing green is seen in this test
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);
806 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
807 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
808 User::LeaveIfNull(theDGdiDriver);
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
815 RSgImageCollection imageCollection;
816 CleanupClosePushL(imageCollection);
817 TInt res = imageCollection.Create(info, 1);
818 User::LeaveIfError(res);
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);
828 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
830 CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
831 User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA));
832 CleanupStack::PushL(bitmap);
834 CFbsBitmapDevice *fbsDevice = CFbsBitmapDevice::NewL(bitmap);
835 CleanupStack::PushL(fbsDevice);
838 //prepare the command buffer for playback
839 RWsGraphicMsgBuf msgBuf;
840 CleanupClosePushL(msgBuf);
842 //Externalize the captured commands from remote gc in to a buffer
843 remoteGc->ExternalizeL(msgBuf, ETrue);
845 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
846 CleanupStack::PushL(wsGrap);
848 CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
849 CleanupStack::PushL(cmdBuf);
850 cmdBuf->InternalizeL(msgBuf.Pckg());
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);
859 //check that the background has been cleared to transparent white.
861 info.iUsage = ESgUsageNone;
862 info.iCpuAccess = ESgCpuAccessReadOnly;
864 CleanupClosePushL(image1);
865 res = image1.Create(info, image);
868 res = image1.MapReadOnly(data, stride);
869 User::LeaveIfError(res);
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));
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);
886 iStep->TEST(color==testColor);
888 //now test drawing to a window to ensure that the brush colour is
889 //the window background colour
891 //display a blue window
892 BaseWin->Win()->SetBackgroundColor(KRgbBlue);
893 BaseWin->Win()->Invalidate();
894 BaseWin->Win()->BeginRedraw();
895 TheGc->Activate(*BaseWin->Win());
898 BaseWin->Win()->EndRedraw();
899 TheClient->iWs.Finish();
900 TheClient->WaitForRedrawsToFinish();
902 //start drawing the display commands with a green background
904 BaseWin->Win()->SetBackgroundColor(KRgbYellow);
905 BaseWin->Win()->Invalidate();
906 BaseWin->Win()->BeginRedraw();
907 TheGc->Activate(*BaseWin->Win());
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);
913 cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc);
917 BaseWin->Win()->EndRedraw();
918 TheClient->iWs.Finish();
919 TheClient->WaitForRedrawsToFinish();
921 //check that the background has been cleared to yellow, using brush colour
922 TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode());
925 TheClient->iScreen->GetPixel(color, position);
926 iStep->TEST(color==KRgbYellow);
928 BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor
930 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
931 CleanupStack::PopAndDestroy(9, remoteGc);
933 CleanupStack::PopAndDestroy(7, remoteGc);
938 @SYMTestCaseID GRAPHICS-WSERV-0481
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
946 @SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same
948 void CTGc::TestCommandBufferL()
950 CWsScreenDevice* device = TheClient->iScreen;
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);
959 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
960 CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
962 CRemoteGc* remoteGc = CRemoteGc::NewL(device);
963 CleanupStack::PushL(remoteGc);
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);
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();
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)
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);
998 User::LeaveIfError(res);
999 CleanupClosePushL(drawableSource);
1000 //-------end create image---------
1002 remoteGc->ResetCommandBuffer();
1003 remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight));
1004 //Capturing the commands in remote gc
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();
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));
1075 dr->DrawResource(TPoint(30, 40), drawableSource);
1078 remoteGc->SetClippingRegion(region);
1079 remoteGc->DiscardFont();
1080 remoteGc->EndDraw();
1082 RWsGraphicMsgBuf msgBuf;
1083 CleanupClosePushL(msgBuf);
1084 //Externalize the captured commands from remote gc in to a buffer
1085 remoteGc->ExternalizeL(msgBuf, EFalse);
1087 CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
1088 CleanupStack::PushL(cmdBuf);
1089 const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL();
1090 if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse)
1092 User::Panic(_L("TestCommandBufferL"), KErrGeneral);
1095 //Internalize the buffer with captured commands (from CRemoteGC)
1096 //in to CCommandBuffer
1097 cmdBuf->InternalizeL(msgBuf.Pckg());
1099 TheGc->Activate(*TestWin->Win());
1100 TestWin->Win()->Invalidate();
1102 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1104 * Make sure anything that can leave is done outside the
1105 * BeginRedraw/EndRedraw bracket.
1107 CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes();
1108 CleanupStack::PushL(wsGrap);
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.
1118 TestWin->Win()->BeginRedraw();
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);
1124 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1125 cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc);
1126 CleanupStack::PopAndDestroy(wsGrap);
1128 TheGc->Deactivate();
1129 TestWin->Win()->EndRedraw();
1130 remoteGc->ResetCommandBuffer();
1131 BaseWin->Win()->Invalidate();
1132 BaseWin->Win()->BeginRedraw();
1133 TheGc->Activate(*BaseWin->Win());
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();
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));
1194 TheGc->DiscardFont();
1195 TheGc->Deactivate();
1196 BaseWin->Win()->EndRedraw();
1198 TheClient->WaitForRedrawsToFinish();
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()"));
1204 INFO_PRINTF1(_L("The CheckRect function returned error."));
1207 INFO_PRINTF1(_L("bitmap deleted."));
1209 INFO_PRINTF1(_L("bitmapMask deleted."));
1211 INFO_PRINTF1(_L("bitmapWs deleted."));
1212 delete bitmapWsMask;
1213 INFO_PRINTF1(_L("bitmapWsMask deleted."));
1215 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1216 CleanupStack::PopAndDestroy(7, remoteGc);
1218 CleanupStack::PopAndDestroy(4, remoteGc);
1220 CleanupStack::Pop();//font
1221 INFO_PRINTF1(_L("CleanupStack popped."));
1222 TheClient->iScreen->ReleaseFont(font);
1226 @SYMTestCaseID GRAPHICS-WSERV-0482
1228 @SYMTestCaseDesc Play empty command buffer.
1229 @SYMTestPriority Medium
1230 @SYMTestStatus Implemented
1232 @SYMTestExpectedResults return KErrEof error
1234 void CTGc::TestEmptyCommandBufferL()
1236 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1237 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
1238 CleanupStack::PushL(wsGrap);
1241 CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
1242 CleanupStack::PushL(cmdBuf);
1244 TheGc->Activate(*TestWin->Win());
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);
1250 TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc);
1254 User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral);
1256 TheGc->Deactivate();
1257 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1258 CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc
1260 CleanupStack::PopAndDestroy(cmdBuf);
1264 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1266 @SYMTestCaseID GRAPHICS-WSERV-0486
1268 @SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow
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
1276 @SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same
1278 void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL()
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);
1286 CWsScreenDevice* device = TheClient->iScreen;
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.
1293 TDisplayMode displayMode = device->DisplayMode();
1294 if (TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) == 32)
1296 displayMode = EColor16MAP;
1299 _LIT(KText,"RemoteGc & MWsGraphicsContext");
1300 TFontSpec fSpec(KTestFontTypefaceName,23);
1301 fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
1302 fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
1303 fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
1306 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec));
1307 CleanupStack::PushL(TCleanupItem(CleanUpFont, font));
1309 //Record the commands using CRemoteGc
1310 CRemoteGc* remoteGc = CRemoteGc::NewL(device);
1311 CleanupStack::PushL(remoteGc);
1312 remoteGc->BeginDraw(KTestRect);
1313 //fill background with white
1314 remoteGc->SetPenStyle(CFbsBitGc::ENullPen);
1315 remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
1316 remoteGc->SetBrushColor(KRgbWhite);
1317 remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size()));
1318 remoteGc->SetPenStyle(CFbsBitGc::ESolidPen);
1319 //Capturing the commands in remote gc
1320 remoteGc->SetClippingRect(KClippingRect2);
1321 remoteGc->SetClippingRegion(KClippingRegion);
1322 remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
1323 remoteGc->SetBrushColor(TRgb(0,150,150));
1324 remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
1325 remoteGc->SetBrushColor(TRgb(150,100,150));
1326 remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
1327 remoteGc->SetBrushColor(KRgbGreen);
1328 remoteGc->SetShadowColor(KRgbDarkRed);
1329 remoteGc->SetPenColor(KRgbBlack);
1330 remoteGc->UseFont(font);
1331 remoteGc->DrawText(KText, TPoint(2,40));
1332 remoteGc->DiscardFont();
1333 remoteGc->EndDraw();
1335 RWsGraphicMsgBuf msgBuf;
1336 CleanupClosePushL(msgBuf);
1337 //Externalize the captured commands from remote gc in to a buffer
1338 remoteGc->ExternalizeL(msgBuf, ETrue);
1340 CCommandBuffer* cmdBuf = CCommandBuffer::NewL();
1341 CleanupStack::PushL(cmdBuf);
1342 //Internalize the buffer with captured commands (from CRemoteGC)
1343 //in to CCommandBuffer
1344 cmdBuf->InternalizeL(msgBuf.Pckg());
1346 CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static();
1347 User::LeaveIfNull(theDGdiDriver);
1350 info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource;
1351 info.iSizeInPixels = TestWin->Size();
1352 info.iPixelFormat = PixelFormatFromDisplayMode(displayMode);
1354 RSgImageCollection imageCollection;
1355 CleanupClosePushL(imageCollection);
1356 TInt res = imageCollection.Create(info, 1);
1357 User::LeaveIfError(res);
1359 CleanupClosePushL(image);
1360 res = imageCollection.OpenImage(0, image);
1361 User::LeaveIfError(res);
1362 RDirectGdiImageTarget imageTarget(*theDGdiDriver);
1363 CleanupClosePushL(imageTarget);
1365 res = imageTarget.Create(image);
1366 User::LeaveIfError(res);
1368 CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget);
1369 CleanupStack::PushL(directGdiGcWrapper);
1371 //Dummy class created
1372 CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes();
1373 CleanupStack::PushL(wsGrap);
1375 //Play the commands on test window using command buffer
1376 cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper);
1378 //Set window back to same as test bitmap background
1379 BaseWin->Win()->SetBackgroundColor(KRgbWhite);
1381 BaseWin->Win()->Invalidate();
1382 BaseWin->Win()->BeginRedraw();
1383 TheGc->Activate(*BaseWin->Win());
1385 TheGc->SetClippingRect(KClippingRect2);
1386 TheGc->SetClippingRegion(KClippingRegion);
1387 TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
1388 TheGc->SetBrushColor(TRgb(0,150,150));
1389 TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60)));
1390 TheGc->SetBrushColor(TRgb(150,100,150));
1391 TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60)));
1392 TheGc->SetBrushColor(KRgbGreen);
1393 TheGc->SetShadowColor(KRgbDarkRed);
1394 TheGc->SetPenColor(KRgbBlack);
1395 TheGc->UseFont(font);
1396 //Draw the text on base window using CWindowGC
1397 TheGc->DrawText(KText, TPoint(2, 40));
1398 TheGc->DiscardFont();
1399 TheGc->Deactivate();
1400 BaseWin->Win()->EndRedraw();
1401 TheClient->iWs.Finish();
1402 TheClient->WaitForRedrawsToFinish();
1404 //Create a bitmap and then copy the screen to it
1405 TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size()));
1406 CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap();
1407 User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode));
1408 CleanupStack::PushL(screenBitmap);
1409 TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc);
1411 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
1412 CleanupStack::PushL(bitmap);
1414 image.GetInfo(info);
1415 bitmap->Create(info.iSizeInPixels, displayMode);
1416 TRect rect(info.iSizeInPixels);
1417 CopyImageToBitmapL(bitmap, image, rect);
1419 //Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap
1420 TInt differentPixels = 0;
1421 res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger());
1422 if (differentPixels != 0)
1424 INFO_PRINTF2(_L(" Pixels different %d"), differentPixels);
1427 CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap
1428 CleanupStack::Pop();//font
1429 TheClient->iScreen->ReleaseFont(font);
1433 @SYMTestCaseID GRAPHICS-WSERV-0487
1435 @SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&)
1436 @SYMTestPriority High
1437 @SYMTestStatus Implemented
1438 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
1439 Record the same DrawText commands using CRemoteGc and play the recorded commands on a
1440 bitmap using MWsGraphicsContext. Compare the two bitmaps.
1441 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
1443 void CTGc::TestCRemoteGcDrawTextInContextPointL()
1445 CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL();
1446 CleanupStack::PushL(test);
1448 TEST(test->HasPassedTest());
1449 CleanupStack::PopAndDestroy(); //test
1453 @SYMTestCaseID GRAPHICS-WSERV-0488
1455 @SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
1456 @SYMTestPriority High
1457 @SYMTestStatus Implemented
1458 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText.
1459 Record the same DrawText commands using CRemoteGc and play the recorded commands on a
1460 bitmap using MWsGraphicsContext. Compare the two bitmaps.
1461 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
1463 void CTGc::TestCRemoteGcDrawTextInContextBoxL()
1465 CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL();
1466 CleanupStack::PushL(test);
1468 TEST(test->HasPassedTest());
1469 CleanupStack::PopAndDestroy(); //test
1473 @SYMTestCaseID GRAPHICS-WSERV-0489
1475 @SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&)
1476 @SYMTestPriority High
1477 @SYMTestStatus Implemented
1478 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
1479 Record the same DrawText commands using CRemoteGc and play the recorded commands on a
1480 bitmap using MWsGraphicsContext. Compare the two bitmaps.
1481 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
1483 void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL()
1485 CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL();
1486 CleanupStack::PushL(test);
1488 TEST(test->HasPassedTest());
1489 CleanupStack::PopAndDestroy(); //test
1493 @SYMTestCaseID GRAPHICS-WSERV-0490
1495 @SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt)
1496 @SYMTestPriority High
1497 @SYMTestStatus Implemented
1498 @SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText.
1499 Record the same DrawText commands using CRemoteGc and play the recorded commands on a
1500 bitmap using MWsGraphicsContext. Compare the two bitmaps.
1501 @SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same
1503 void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL()
1505 CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL();
1506 CleanupStack::PushL(test);
1508 TEST(test->HasPassedTest());
1509 CleanupStack::PopAndDestroy(); //test
1511 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1514 @SYMTestCaseID GRAPHICS-WSERV-0494
1516 @SYMTestCaseDesc Negative test to show that using SetBrushStyle() will not panic WServ with different
1518 @SYMTestPriority High
1519 @SYMTestStatus Implemented
1520 @SYMTestActions Four seperate panic situations are tested:
1522 Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
1523 Draw a line to force the playback to occur.
1524 Call Finish on the GC.
1525 Destroy the brush bitmap.
1527 Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush.
1528 Draw a line to force the playback to occur.
1529 Destroy the brush bitmap.
1530 Call Finish on the GC.
1532 Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush.
1533 Draw a line to force the playback to occur.
1534 Set the brush bitmap and style again.
1535 Call Finish on the GC.
1536 Destroy the brush bitmap.
1537 @SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called.
1539 void CTGc::TestGcSetBrushPatternL()
1541 // Extended bitmap test data.
1542 const TUint8 KTestData[] = "TEST DATA";
1543 const TInt KTestDataSize = sizeof(KTestData);
1544 const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF);
1546 // First try using a regular bitmap as the brush pattern.
1547 BaseWin->Win()->Invalidate();
1548 BaseWin->Win()->BeginRedraw();
1549 TheGc->Activate(*BaseWin->Win());
1550 CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap;
1551 CleanupStack::PushL(bitmapRegular);
1552 TInt res = bitmapRegular->Create(TSize(10,10), EColor64K);
1553 TEST(res == KErrNone);
1554 //Record the commands using CWindowGc.
1555 TheGc->UseBrushPattern(bitmapRegular);
1556 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
1557 // DrawLine() is only used here to force playback of the commands.
1558 TheGc->DrawLine(TPoint(0,0), TPoint(1,1));
1559 TheGc->Deactivate();
1560 BaseWin->Win()->EndRedraw();
1561 TheClient->iWs.Finish();
1562 CleanupStack::PopAndDestroy(1, bitmapRegular);
1564 // Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap
1565 // before calling Finish().
1566 BaseWin->Win()->Invalidate();
1567 BaseWin->Win()->BeginRedraw();
1568 TheGc->Activate(*BaseWin->Win());
1569 bitmapRegular = new (ELeave) CFbsBitmap;
1570 CleanupStack::PushL(bitmapRegular);
1571 res = bitmapRegular->Create(TSize(10,10), EColor64K);
1572 TEST(res == KErrNone);
1573 //Record the commands using CWindowGc.
1574 TheGc->UseBrushPattern(bitmapRegular);
1575 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
1576 TheGc->DrawLine(TPoint(0,0), TPoint(1,1));
1577 CleanupStack::PopAndDestroy(1, bitmapRegular);
1578 TheGc->Deactivate();
1579 BaseWin->Win()->EndRedraw();
1580 TheClient->iWs.Finish();
1582 // Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as
1583 // the brush pattern.
1584 BaseWin->Win()->Invalidate();
1585 BaseWin->Win()->BeginRedraw();
1586 TheGc->Activate(*BaseWin->Win());
1587 // Create a dummy extended bitmap to use as a brush bitmap.
1588 // This is unsupported by the default implementation of DirectGDI.
1589 CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap;
1590 CleanupStack::PushL(bitmapExtended);
1591 res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize);
1592 TEST(res == KErrNone);
1593 //Record the commands using CWindowGc.
1594 TheGc->UseBrushPattern(bitmapExtended);
1595 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
1596 TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
1597 TheGc->UseBrushPattern(bitmapExtended);
1598 // Forth, do it twice so that we test the state commands and the drawops commands.
1599 TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
1600 TheGc->DrawLine(TPoint(0,0), TPoint(100,100));
1601 TheGc->Deactivate();
1602 BaseWin->Win()->EndRedraw();
1603 TheClient->iWs.Finish();
1604 CleanupStack::PopAndDestroy(1, bitmapExtended);
1608 @SYMTestCaseID GRAPHICS-WSERV-0576
1610 @SYMTestCaseDesc Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap.
1611 @SYMTestPriority High
1612 @SYMTestStatus Implemented
1613 @SYMTestActions - Draw the bitmap to TestWin (keeping the window hidden)
1615 - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted)
1616 - Draw the same bitmap (same image, different bitmap object instance) to BaseWin
1617 - Compare contents of TestWin with BaseWin
1618 @SYMTestExpectedResults TestWin and BaseWin should both show the bitmap.
1620 void CTGc::TestGcDeleteBitmap1L()
1622 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
1623 CleanupStack::PushL(bitmap);
1624 TInt ret = bitmap->Load(TEST_BITMAP_NAME,0);
1625 TEST(ret == KErrNone);
1627 // send drawing to hidden window
1628 TestWin->SetVisible(EFalse);
1629 TestWin->Win()->Invalidate();
1630 TestWin->Win()->BeginRedraw();
1631 TheGc->Activate(*TestWin->Win());
1632 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1633 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1634 TheGc->SetBrushColor(TRgb(255, 0, 0));
1636 TheGc->BitBlt(TPoint(0,0), bitmap);
1637 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
1639 TheGc->Deactivate();
1640 TestWin->Win()->EndRedraw();
1641 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)
1643 // make window visible (forcing it to draw)
1644 TestWin->SetVisible(ETrue);
1645 TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win
1647 // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing
1648 // the window now (by making it visible above) should display the bitmap on screen, even
1649 // though we've deleted it in this thread
1651 // now create the bitmap again, and draw it to the base win (for comparison with test win)
1652 bitmap = new (ELeave) CFbsBitmap;
1653 CleanupStack::PushL(bitmap);
1654 ret = bitmap->Load(TEST_BITMAP_NAME,0);
1655 TEST(ret == KErrNone);
1656 BaseWin->SetVisible(ETrue);
1657 BaseWin->Win()->Invalidate();
1658 BaseWin->Win()->BeginRedraw();
1659 TheGc->Activate(*BaseWin->Win());
1660 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1661 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1662 TheGc->SetBrushColor(TRgb(255, 0, 0));
1664 TheGc->BitBlt(TPoint(0,0), bitmap);
1665 TheGc->Deactivate();
1666 BaseWin->Win()->EndRedraw();
1667 TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win
1669 CleanupStack::PopAndDestroy(bitmap);
1671 // the test bitmap should be shown in both base win and test win, so we now check that the
1672 // contents of base win and test win are the same
1673 CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()"));
1677 @SYMTestCaseID GRAPHICS-WSERV-0577
1679 @SYMTestCaseDesc Check window server is still able to use a bitmap required by window drawing, even
1680 after the client has released its handle to the bitmap. Also check window server
1681 releases the bitmap, when it's no longer used by window drawing.
1682 @SYMTestPriority High
1683 @SYMTestStatus Implemented
1684 @SYMTestActions - Clean BaseWin and TestWin from content that has been left over from previous test
1685 - Draw test bitmap to TestWin
1687 - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing)
1689 - Draw new content to TestWin, so that previously drawn bitmap is covered
1690 - Duplicate bitmap (the bitmap is no longer used by window drawing)
1691 @SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas
1692 bitmap duplication fails, when the bitmap is no longer used by window drawing.
1694 void CTGc::TestGcDeleteBitmap2L()
1696 //send new drawing to test and base windows, in order to cover
1697 //any content has been left on them (through previous test)
1698 BaseWin->SetVisible(ETrue);
1699 BaseWin->Win()->Invalidate();
1700 BaseWin->Win()->BeginRedraw();
1701 TheGc->Activate(*BaseWin->Win());
1702 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1703 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1704 TheGc->SetBrushColor(TRgb(0, 0, 255));
1706 TheGc->Deactivate();
1707 BaseWin->Win()->EndRedraw();
1709 TestWin->SetVisible(ETrue);
1710 TestWin->Win()->Invalidate();
1711 TestWin->Win()->BeginRedraw();
1712 TheGc->Activate(*TestWin->Win());
1713 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1714 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1715 TheGc->SetBrushColor(TRgb(0, 0, 255));
1717 TheGc->Deactivate();
1718 TestWin->Win()->EndRedraw();
1720 TheClient->iWs.Flush();
1721 TheClient->iWs.Finish();
1724 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
1725 CleanupStack::PushL(bitmap);
1726 TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0);
1727 TEST(ret == KErrNone);
1728 TInt bitmapHandle = bitmap->Handle();
1730 //send bitmap drawing to test window
1731 TestWin->Win()->Invalidate();
1732 TestWin->Win()->BeginRedraw();
1733 TheGc->Activate(*TestWin->Win());
1734 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1735 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1736 TheGc->SetBrushColor(TRgb(0, 255, 0));
1738 TheGc->BitBlt(TPoint(0,0), bitmap);
1739 TheGc->Deactivate();
1740 TestWin->Win()->EndRedraw();
1742 CleanupStack::PopAndDestroy(bitmap);
1744 TheClient->iWs.Flush();
1745 TheClient->iWs.Finish();
1747 //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though
1748 //the initial bitmap object is deleted) , since there is a window segment using it
1749 bitmap = new (ELeave) CFbsBitmap;
1750 CleanupStack::PushL(bitmap);
1751 ret = bitmap->Duplicate(bitmapHandle);
1752 TEST(ret == KErrNone);
1753 CleanupStack::PopAndDestroy(bitmap);
1755 //send new drawing to test window, in order to cover the bitmap that was previously drawn
1756 TestWin->Win()->Invalidate();
1757 TestWin->Win()->BeginRedraw();
1758 TheGc->Activate(*TestWin->Win());
1759 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1760 TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
1761 TheGc->SetBrushColor(TRgb(0, 0, 255));
1763 TheGc->Deactivate();
1764 TestWin->Win()->EndRedraw();
1766 TheClient->iWs.Flush();
1767 TheClient->iWs.Finish();
1769 //check that wserv can't duplicate test bitmap, since no window segment uses it any more
1770 bitmap = new (ELeave) CFbsBitmap;
1771 CleanupStack::PushL(bitmap);
1772 ret = bitmap->Duplicate(bitmapHandle);
1773 TEST(ret != KErrNone);
1774 CleanupStack::PopAndDestroy(bitmap);
1777 void CTGc::RunTestCaseL(TInt /*aCurTestCase*/)
1779 ((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1780 switch(++iTest->iState)
1783 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437"));
1784 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text"));
1785 TestOutlineAndShadowL();
1788 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
1789 iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));
1790 TestGcClipRectOrigin();
1793 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
1794 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));
1795 TestResetWithBackgroundColorL();
1798 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481"));
1799 iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests"));
1800 TestCommandBufferL();
1803 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482"));
1804 iTest->LogSubTest(_L("CCommandBuffer, coverage tests"));
1805 TestEmptyCommandBufferL();
1808 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494"));
1809 iTest->LogSubTest(_L("CWindowGc, Brush Pattern test"));
1810 TestGcSetBrushPatternL();
1813 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576"));
1814 iTest->LogSubTest(_L("CWindowGc, delete bitmap 1"));
1815 TestGcDeleteBitmap1L();
1818 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577"));
1819 iTest->LogSubTest(_L("CWindowGc, delete bitmap 2"));
1820 TestGcDeleteBitmap2L();
1822 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1824 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471"));
1825 iTest->LogSubTest(_L("Test GC clip rect and origin attributes."));
1826 TestGcClipRectOrigin();
1829 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469"));
1830 iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour"));
1831 TestResetWithBackgroundColorL();
1834 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486"));
1835 iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test"));
1836 TestCRemoteGcAndMWsGraphicsContextClippingRectL();
1839 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487"));
1840 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test"));
1841 TestCRemoteGcDrawTextInContextPointL();
1844 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488"));
1845 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test"));
1846 TestCRemoteGcDrawTextInContextBoxL();
1849 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489"));
1850 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical test"));
1851 TestCRemoteGcDrawTextInContextPointVerticalL();
1854 ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490"));
1855 iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert test"));
1856 TestCRemoteGcDrawTextInContextBoxVerticalL();
1858 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1860 ((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1861 ((CTGcStep*)iStep)->CloseTMSGraphicsStep();
1865 ((CTGcStep*)iStep)->RecordTestResultL();
1868 __CONSTRUCT_STEP__(Gc)