Update contrib.
1 // Copyright (c) 1997-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.
20 #include <graphics/gdi/gdiconsts.h>
22 #include <graphics/fbsdefs.h>
25 TInt PanicTestThread(TAny* aOption);
50 CTAuto::CTAuto(CTestStep* aStep):
51 CTGraphicsBase(aStep),
55 iTestRect[0].SetRect(21,10,22,50);
56 iTestRect[1].SetRect(10,21,50,22);
57 iTestRect[2].SetRect(11,20,90,30);
58 iTestRect[3].SetRect(10,71,90,80);
59 iTestRect[4].SetRect(20,10,31,90);
60 iTestRect[5].SetRect(70,10,80,91);
61 iTestRect[6].SetRect(10,10,90,90);
62 iTestRect[7].SetRect(32,32,96,96);
64 INFO_PRINTF1(_L(" "));
72 void CTAuto::RunTestCaseL(const TInt aCurTestCase)
74 ((CTAutoStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
78 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
82 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
86 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
90 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
94 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
98 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
102 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
106 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
110 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
114 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
118 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
122 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
126 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
130 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
131 TestMapL(EGray256,5);
134 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
135 TestMapL(EColor16,5);
138 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
139 TestMapL(EColor256,3);
142 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
143 TestMapL(EColor4K,5);
146 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
147 TestMapL(EColor64K,4);
150 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
151 TestMapL(EColor16M,4);
154 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
155 TestMapL(EColor16MU,4);
158 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
162 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
166 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
170 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
174 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
178 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
182 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
186 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
190 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
194 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
195 TestBmpL(EColor16MU);
198 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
199 TestBmpL(EColor16MA);
202 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
206 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
207 TestMapL(EColor16MA,4);
210 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0027"));
211 TestBmpL(EColor16MAP);
214 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0025"));
215 TestMem(EColor16MAP);
218 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0026"));
219 TestMapL(EColor16MAP,4);
222 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0029"));
224 INFO_PRINTF2(_L("TestCase %d - Passed Fading Test\r\n"),aCurTestCase);
227 ((CTAutoStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0028"));
231 ((CTAutoStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
232 ((CTAutoStep*)iStep)->CloseTMSGraphicsStep();
236 ((CTAutoStep*)iStep)->RecordTestResultL();
241 @SYMTestCaseID GRAPHICS-BITGDI-0025
245 @SYMTestCaseDesc Tests the memory allocation cleanup after allocations fails
247 @SYMTestPriority High
249 @SYMTestStatus Implemented
251 @SYMTestActions sets memory allocation to fail then checks it is cleaned up correctly
253 @SYMTestExpectedResults Memory should be successfully cleaned up
255 void CTAuto::TestMem(TDisplayMode aDispMode)
257 LowLevelDevice(aDispMode,EFalse);
258 BitmapDevice(aDispMode);
259 LowLevelDevice(aDispMode,ETrue);
260 ScreenDevice(aDispMode);
262 INFO_PRINTF2(_L("Mode %d passed memory test\r\n"),aDispMode);
265 void CTAuto::ScreenDevice(TDisplayMode aDispMode)
267 CFbsScreenDevice* device = NULL;
268 for (TInt count = 1; ; count++)
270 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
272 TRAPD(err,device = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
273 if (err == KErrNotSupported)
278 else if(err == KErrNoMemory)
282 else if (err == KErrNone)
291 User::Panic(_L("CFbsScreenDevice test failed "),err);
298 void CTAuto::BitmapDevice(TDisplayMode aDispMode)
301 TInt ret = bmp.Create(TSize(1,1),aDispMode);
303 User::Panic(_L("Failed to create bitmap"),ret);
305 CFbsBitmapDevice* device = NULL;
306 for (TInt count = 1; ; count++)
308 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
310 TRAPD(err,device = CFbsBitmapDevice::NewL(&bmp));
311 if(err == KErrNotSupported)
316 else if(err == KErrNoMemory)
320 else if (err == KErrNone)
329 User::Panic(_L("CFbsBitmapDevice test failed "),err);
336 void CTAuto::LowLevelDevice(TDisplayMode aDispMode,TBool aScreen)
340 TInt ret = HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress,address);
342 ret = HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels,size.iWidth);
344 ret = HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels,size.iHeight);
346 User::Panic(_L("CFbsDrawDevice test failed "),ret);
348 TPckgBuf<TScreenInfoV01> s;
349 s().iScreenAddressValid = ETrue;
350 s().iScreenAddress = REINTERPRET_CAST(TAny*,address);
351 s().iScreenSize = size;
353 CFbsDrawDevice* fdd = NULL;
355 for(TInt count = 1; ; count++)
357 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
362 TRAP(ret,fdd = CFbsDrawDevice::NewScreenDeviceL(s(),aDispMode));
366 TRAP(ret, fdd = CFbsDrawDevice::NewBitmapDeviceL(s(), aDispMode, CFbsBitmap::ScanLineLength(size.iWidth, aDispMode)));
369 if (ret == KErrNotSupported)
374 else if (ret == KErrNoMemory)
378 else if (ret == KErrNone)
387 User::Panic(_L("CFbsDrawDevice test failed "),ret);
396 @SYMTestCaseID GRAPHICS-BITGDI-0026
400 @SYMTestCaseDesc Colour mapping testing
402 @SYMTestPriority High
404 @SYMTestStatus Implemented
406 @SYMTestActions attempts to map four shades of grey to greys in a colourmap
408 @SYMTestExpectedResults All pixels should map to the colourmap correctly
413 void CTAuto::TestMapL(TDisplayMode aDispMode,TInt aShadowFactor)
415 TRAPD(err,iScreenDevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
416 if (err == KErrNotSupported)
418 User::LeaveIfError(err);
420 User::LeaveIfError(iScreenDevice->CreateContext(iScreenGc));
421 iScreenDevice->ChangeScreenDevice(NULL);
424 TestShadowArea(aShadowFactor);
428 delete iScreenDevice;
430 INFO_PRINTF2(_L("Mode %d passed colour map test\r\n"),aDispMode);
433 void CTAuto::TestMapColors()
439 for (TInt count = 0; count < KNumRects; count++)
441 for (TInt color = 0; color < 4 && iScreenDevice->DisplayMode() != EGray2; color++)
443 Clear(TRgb::Gray4(color));
444 TRect r(iTestRect[count]);
445 colormap[0] = TRgb::Gray4(color);
446 colormap[1] = TRgb::Gray4(3-color);
447 colormap[2] = colormap[1];
448 colormap[3] = colormap[0];
449 if (iScreenDevice->DisplayMode() == EColor64K)
451 colormap[0] = TRgb::Color64K(colormap[0].Color64K());
452 colormap[1] = TRgb::Color64K(colormap[1].Color64K());
453 colormap[2] = colormap[1];
454 colormap[3] = colormap[0];
456 iScreenGc->MapColors(r,colormap,2);
458 for(y=0;y<r.iTl.iY;y++)
461 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
462 TEST(screencolor.Gray4() == color);
464 for(y=r.iTl.iY;y<r.iBr.iY;y++)
465 for(x=0;x<r.iTl.iX;x++)
467 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
468 TEST(screencolor.Gray4() == color);
470 for(y=r.iTl.iY;y<r.iBr.iY;y++)
471 for(x=r.iBr.iX;x<100;x++)
473 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
474 TEST(screencolor.Gray4() == color);
476 for(y=r.iBr.iY;y<100;y++)
479 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
480 TEST(screencolor.Gray4() == color);
482 for(y=r.iTl.iY;y<r.iBr.iY;y++)
483 for(x=r.iTl.iX;x<r.iBr.iX;x++)
485 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
486 TEST(screencolor.Gray4() == 3-color);
488 iScreenGc->MapColors(r,colormap,2);
489 for(y=r.iTl.iY;y<r.iBr.iY;y++)
490 for(x=r.iTl.iX;x<r.iBr.iX;x++)
492 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
493 TEST(screencolor.Gray4() == color);
499 void CTAuto::TestShadowArea(TInt aShadowFactor)
504 for (TInt count = 0; count < KNumRects; count++)
506 for (TInt color = 0; color < 4; color++)
508 if (color > 0 && iScreenDevice->DisplayMode() == EGray2)
511 Clear(TRgb::Gray4(color));
512 TRect r(iTestRect[count]);
513 TRegionFix<1> reg(r);
515 iScreenGc->ShadowArea(®);
517 for(y=0;y<r.iTl.iY;y++)
520 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
521 TEST(screencolor.Gray4() == color);
524 for(y=r.iTl.iY;y<r.iBr.iY;y++)
525 for(x=0;x<r.iTl.iX;x++)
527 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
528 TEST(screencolor.Gray4() == color);
531 for(y=r.iTl.iY;y<r.iBr.iY;y++)
532 for(x=r.iBr.iX;x<100;x++)
534 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
535 TEST(screencolor.Gray4() == color);
538 for(y=r.iBr.iY;y<100;y++)
541 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
542 TEST(screencolor.Gray4() == color);
545 for(y=r.iTl.iY;y<r.iBr.iY;y++)
546 for(x=r.iTl.iX;x<r.iBr.iX;x++)
548 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
549 TEST(screencolor.Gray16() == Max(0,color * 5 - aShadowFactor));
555 void CTAuto::TestFadeArea()
557 DoTestFadeArea(0,255);
558 DoTestFadeArea(0,127);
559 DoTestFadeArea(128,255);
560 DoTestFadeArea(64,192);
563 void CTAuto::DoTestFadeArea(TUint8 aBlackMap,TUint8 aWhiteMap)
565 iScreenGc->SetFadingParameters(aBlackMap,aWhiteMap);
567 DoTestFadeArea(KRgbWhite,FadeColor(KRgbWhite,aBlackMap,aWhiteMap));
568 DoTestFadeArea(KRgbBlack,FadeColor(KRgbBlack,aBlackMap,aWhiteMap));
570 if (iScreenDevice->DisplayMode() == EGray2)
571 return; // EGray2 mode dithers so only check black & white
573 DoTestFadeArea(KRgbGray,FadeColor(KRgbGray,aBlackMap,aWhiteMap));
574 DoTestFadeArea(KRgbDarkGray,FadeColor(KRgbDarkGray,aBlackMap,aWhiteMap));
576 if (iScreenDevice->DisplayMode() == EGray4)
577 return; // EGray4 mode dithers so only check four gray scales
579 DoTestFadeArea(KRgbRed,FadeColor(KRgbRed,aBlackMap,aWhiteMap));
580 DoTestFadeArea(KRgbGreen,FadeColor(KRgbGreen,aBlackMap,aWhiteMap));
581 DoTestFadeArea(KRgbBlue,FadeColor(KRgbBlue,aBlackMap,aWhiteMap));
584 void CTAuto::DoTestFadeArea(TRgb aColor,TRgb aFadedColor)
589 for (TInt count = 0; count < KNumRects; count++)
592 aColor = MapColorToDisplayMode(aColor);
594 TRect r(iTestRect[count]);
595 TRegionFix<1> reg(r);
597 iScreenGc->FadeArea(®);
599 for(y=0;y<r.iTl.iY;y++)
602 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
603 TEST(screencolor == aColor);
606 for(y=r.iTl.iY;y<r.iBr.iY;y++)
607 for(x=0;x<r.iTl.iX;x++)
609 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
610 TEST(screencolor == aColor);
613 for(y=r.iTl.iY;y<r.iBr.iY;y++)
614 for(x=r.iBr.iX;x<100;x++)
616 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
617 TEST(screencolor == aColor);
620 for(y=r.iBr.iY;y<100;y++)
623 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
624 TEST(screencolor == aColor);
627 for(y=r.iTl.iY;y<r.iBr.iY;y++)
628 for(x=r.iTl.iX;x<r.iBr.iX;x++)
630 iScreenDevice->GetPixel(screencolor,TPoint(x,y));
631 TEST(screencolor == aFadedColor);
636 TRgb CTAuto::FadeColor(TRgb aColor,TInt aBlackMap,TInt aWhiteMap)
638 aColor = MapColorToDisplayMode(aColor);
640 TInt red = ((aColor.Red() * (aWhiteMap - aBlackMap + 1)) >> 8) + aBlackMap;
641 TInt green = ((aColor.Green() * (aWhiteMap - aBlackMap + 1)) >> 8) + aBlackMap;
642 TInt blue = ((aColor.Blue() * (aWhiteMap - aBlackMap + 1)) >> 8) + aBlackMap;
644 aColor = TRgb(red,green,blue);
646 aColor = MapColorToDisplayMode(aColor);
651 TRgb CTAuto::MapColorToDisplayMode(TRgb aColor)
653 switch (iScreenDevice->DisplayMode())
656 aColor = TRgb::Gray2(aColor.Gray2());
659 aColor = TRgb::Gray4(aColor.Gray4());
662 aColor = TRgb::Gray16(aColor.Gray16());
665 aColor = TRgb::Gray256(aColor.Gray256());
668 aColor = TRgb::Color16(aColor.Color16());
671 aColor = TRgb::Color256(aColor.Color256());
674 aColor = TRgb::Color4K(aColor.Color4K());
677 aColor = TRgb::Color64K(aColor.Color64K());
680 aColor = TRgb::Color16M(aColor.Color16M());
683 aColor = TRgb::Color16MU(aColor.Color16MU());
686 aColor = TRgb::Color16MA(aColor.Color16MA());
689 aColor = TRgb::Color16MAP(aColor.Color16MAP());
699 void CTAuto::Clear(TRgb aColor)
701 iScreenGc->SetBrushColor(aColor);
707 @SYMTestCaseID GRAPHICS-BITGDI-0027
711 @SYMTestCaseDesc tests drawing a bitmap to the screen in various colour modes
713 @SYMTestPriority High
715 @SYMTestStatus Implemented
717 @SYMTestActions draws to a bitmaps gc and the screens gc then compares the result on a per pixel basis
719 @SYMTestExpectedResults bitmap and screen should be identical
722 // Bitmap drawing testing
724 void CTAuto::TestBmpL(TDisplayMode aDispMode)
726 TRAPD(err,iScreenDevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
727 if (err == KErrNotSupported)
729 User::LeaveIfError(err);
730 iScreenDevice->ChangeScreenDevice(NULL);
731 User::LeaveIfError(iScreenDevice->CreateContext((CGraphicsContext*&)iScreenGc));
733 iHalfScreen = iScreenDevice->SizeInPixels();
734 iHalfScreen.iWidth /= 2;
737 User::LeaveIfError(bitmap.Create(iHalfScreen,aDispMode));
739 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(&bitmap);
740 CleanupStack::PushL(bitmapDevice);
741 CFbsBitGc* bitmapGc = NULL;
742 User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
743 CleanupStack::PushL(bitmapGc);
745 TestGc(iScreenGc,iHalfScreen);
746 TestGc(bitmapGc,iHalfScreen);
748 iScreenGc->BitBlt(TPoint(iHalfScreen.iWidth,0),&bitmap);
750 TRgb* left = new(ELeave) TRgb[iHalfScreen.iWidth];
751 TRgb* right = new(ELeave) TRgb[iHalfScreen.iWidth];
753 TPtr8 leftBuf(REINTERPRET_CAST(TUint8*,left),iHalfScreen.iWidth * sizeof(TRgb),iHalfScreen.iWidth * sizeof(TRgb));
754 TPtr8 rightBuf(REINTERPRET_CAST(TUint8*,right),iHalfScreen.iWidth * sizeof(TRgb),iHalfScreen.iWidth * sizeof(TRgb));
756 for (TInt row = 0; row < iHalfScreen.iHeight; row++)
758 iScreenDevice->GetScanLine(leftBuf,TPoint(0,row),iHalfScreen.iWidth,ERgb);
759 bitmap.GetScanLine(rightBuf,TPoint(iHalfScreen.iWidth,row),iHalfScreen.iWidth,ERgb);
761 TRgb* leftPtr = left;
762 TRgb* rightPtr = right;
764 for (TInt col = 0; col < iHalfScreen.iWidth; col++)
766 if (leftPtr[0] != rightPtr[0])
767 User::Panic(_L("Screen/bitmap mismatch!"),KErrGeneral);
776 CleanupStack::PopAndDestroy(2); // bitmapGc,bitmapDevice
778 delete iScreenDevice;
780 iScreenDevice = NULL;
785 INFO_PRINTF2(_L("Mode %d passed bitmap drawing test\r\n"),aDispMode);
788 void CTAuto::TestGc(CFbsBitGc* aGc,const TSize& aSize)
790 aGc->SetPenStyle(CGraphicsContext::ENullPen);
791 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
792 aGc->SetBrushColor(KRgbBlack);
793 aGc->DrawRect(TRect(TPoint(),iScreenDevice->SizeInPixels()));
794 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
795 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
801 void CTAuto::Colors(CFbsBitGc* aGc,const TSize& aSize)
805 TInt h=aSize.iHeight;
812 aGc->SetPenColor(TRgb::Gray256(i));
813 aGc->SetBrushColor(TRgb::Gray256(i));
814 aGc->DrawRect(TRect(lx,i*h/256,rx,(i+1)*h/256));
820 aGc->SetPenColor(TRgb::Gray16(i));
821 aGc->SetBrushColor(TRgb::Gray16(i));
822 aGc->DrawRect(TRect(lx,i*h/16,rx,(i+1)*h/16));
828 aGc->SetPenColor(TRgb::Gray4(i));
829 aGc->SetBrushColor(TRgb::Gray4(i));
830 aGc->DrawRect(TRect(lx,i*h/4,rx,(i+1)*h/4));
836 aGc->SetPenColor(TRgb(i,0,0));
837 aGc->SetBrushColor(TRgb(i,0,0));
838 aGc->DrawRect(TRect(lx,i*h/256,rx,(i+1)*h/256));
844 aGc->SetPenColor(TRgb(0,i,0));
845 aGc->SetBrushColor(TRgb(0,i,0));
846 aGc->DrawRect(TRect(lx,i*h/256,rx,(i+1)*h/256));
852 aGc->SetPenColor(TRgb(0,0,i));
853 aGc->SetBrushColor(TRgb(0,0,i));
854 aGc->DrawRect(TRect(lx,i*h/256,rx,(i+1)*h/256));
860 aGc->SetPenColor(TRgb::Color256(i));
861 aGc->SetBrushColor(TRgb::Color256(i));
862 aGc->DrawRect(TRect(lx,i*h/256,rx,(i+1)*h/256));
868 aGc->SetPenColor(TRgb::Color16(i));
869 aGc->SetBrushColor(TRgb::Color16(i));
870 aGc->DrawRect(TRect(lx,i*h/16,rx,(i+1)*h/16));
875 void CTAuto::Shapes(CFbsBitGc* aGc,const TSize& aSize)
877 aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
878 aGc->SetPenColor(KRgbWhite);
881 TInt h=aSize.iHeight;
883 CArrayFixFlat<TPoint>* poly=new(ELeave) CArrayFixFlat<TPoint>(4);
886 TPoint temppt(w*5/8,h/48);
887 poly->AppendL(temppt);
888 temppt.SetXY(b-1,h*11/48);
889 poly->AppendL(temppt);
890 temppt.SetXY(a+1,h*11/48);
891 poly->AppendL(temppt);
892 temppt.SetXY(w*5/8,h/48);
893 poly->AppendL(temppt);
894 aGc->DrawPolyLine(poly);
897 aGc->DrawRect(TRect(a+1,h*7/24,b,h*12/24));
898 aGc->DrawRoundRect(TRect(a+1,h*13/24,b,h*18/24),TSize(w/16,h/12));
899 aGc->DrawEllipse(TRect(a+1,h*19/24,b,h*24/24));
900 aGc->DrawArc(TRect(b+1,h*1/24,w-1,h*6/24),TPoint(w*15/16,h*6/24),TPoint(w*13/16,h*6/24));
901 aGc->DrawPie(TRect(b+1,h*7/24,w-1,h*12/24),TPoint(w*13/16,h*7/24),TPoint(w*15/16,h*7/24));
902 aGc->DrawEllipse(TRect(b+1,h*13/24,w-1,h*18/24));
903 aGc->DrawEllipse(TRect(b+1,h*20/24,w-1,h*23/24));
908 @SYMTestCaseID GRAPHICS-BITGDI-0028
912 @SYMTestCaseDesc Tests various graphic panics
914 @SYMTestPriority High
916 @SYMTestStatus Implemented
918 @SYMTestActions Starts a thread that causes various graphic panics depending on the chosen option
920 @SYMTestExpectedResults The thread should panic each time for each chosen option
922 void CTAuto::TestPanics()
924 for (TInt opt = EFirst + 1; opt < ELast; opt++)
927 INFO_PRINTF2(_L("Panic test %d passed\r\n"),opt);
931 void CTAuto::StartThread(TInt aOption)
935 TBuf<256> threadNameBuf;
936 _LIT(KThreadNameFormat, "ptt%d");
937 threadNameBuf.Format(KThreadNameFormat, aOption);
938 TInt threadCreationVal = thrd.Create(threadNameBuf,PanicTestThread,KDefaultStackSize,0x2000,0x20000,(TAny*)aOption);
939 TEST(threadCreationVal==KErrNone);
940 thrd.SetPriority(EPriorityMuchMore);
942 User::SetJustInTime(EFalse);
944 User::WaitForRequest(stat);
946 User::SetJustInTime(ETrue);
951 @SYMTestCaseID GRAPHICS-BITGDI-0029
955 @SYMTestCaseDesc tests fading functionality
957 @SYMTestPriority High
959 @SYMTestStatus Implemented
961 @SYMTestActions Tests fading functionality by drawing two rectangles with different alpha values and compares the results
963 @SYMTestExpectedResults the two bitmaps should be identical after the operations
965 void CTAuto::TestFadingL()
968 TRect rectbitmap1(0,0,100,50);
969 TRect rectbitmap2(25,0,75,100);
971 CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
972 CleanupStack::PushL(bitmap);
973 User::LeaveIfError(bitmap->Create(TSize(100,100), EColor64K));
975 CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(bitmap);
976 CleanupStack::PushL(device);
979 User::LeaveIfError(device->CreateContext(gc));
980 CleanupStack::PushL(gc);
982 CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap;
983 CleanupStack::PushL(bitmap2);
984 User::LeaveIfError(bitmap2->Create(TSize(100,100), EColor64K));
986 CFbsBitmapDevice* device2=CFbsBitmapDevice::NewL(bitmap2);
987 CleanupStack::PushL(device2);
990 User::LeaveIfError(device2->CreateContext(gc2));
991 CleanupStack::PushL(gc2);
993 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
994 gc->SetPenColor(TRgb(0,0,0,0));
996 //Draws rectangle with Alpha Value 0 when Fading is turned OFF
997 gc->SetBrushColor(TRgb(0,0,255,255));
998 gc->DrawRect(rectbitmap2);
1000 //Draws rectangle with Alpha Value 255 when Fading is turned OFF
1001 gc->SetBrushColor(TRgb(255,0,0,0));
1002 gc->DrawRect(rectbitmap1);
1004 gc2->SetBrushStyle(CGraphicsContext::ESolidBrush);
1005 gc2->SetPenColor(TRgb(0,0,0,0));
1008 //Draws rectangle with Alpha Value 255 when Fading is turned OFF
1009 gc2->SetBrushColor(TRgb(0,0,255,255));
1010 gc2->DrawRect(rectbitmap2);
1012 //Draws rectangle with Alpha Value 0 when Fading is turned ON
1013 //Fade Option Turned ON
1014 gc2->SetFaded(ETrue);
1015 gc2->SetBrushColor(TRgb(255,0,0,0));
1016 gc2->DrawRect(rectbitmap1);
1018 TRect rect(0,0,100,100);
1019 res = device->RectCompare(rect,*device2,rect);
1021 CleanupStack::PopAndDestroy(6, bitmap);
1025 TInt PanicTestThread(TAny* aOption)
1027 CTrapCleanup::New();
1028 RFbsSession::Connect();
1030 CFbsScreenDevice* screendevice=NULL;
1031 CFbsBitGc* bitgc=NULL;
1032 CPolygonFiller* polyfill=NULL;
1034 const TInt option = TInt(aOption);
1039 case EPolygonFiller:
1040 polyfill=(CPolygonFiller*)User::Alloc(sizeof(CPolygonFiller));
1041 new(polyfill) CPolygonFiller;
1049 TRAP(ret,screendevice=CFbsScreenDevice::NewL(_L("scdv"),EColor256));
1050 if (ret == KErrNotSupported)
1051 TRAP(ret,screendevice=CFbsScreenDevice::NewL(_L("scdv"),EGray4));
1052 if (ret == KErrNotSupported)
1053 TRAP(ret,screendevice=CFbsScreenDevice::NewL(_L("scdv"),EColor4K));
1054 if (ret != KErrNone)
1055 User::Panic(_L("screendevice failed"),ret);
1056 screendevice->CreateContext((CGraphicsContext*&)bitgc);
1066 TRAP(ret,bitgc=CFbsBitGc::NewL());
1072 case EPolygonFiller:
1073 polyfill->Construct(NULL,CGraphicsContext::EAlternate);
1076 (void)CFbsBitmapDevice::NewL(NULL);
1079 bitgc->DrawBitmap(TPoint(0,0),NULL);
1082 bitgc->DrawBitmap(TRect(0,0,0,0),NULL);
1085 bitgc->DrawBitmap(TRect(0,0,0,0),NULL,TRect(0,0,0,0));
1091 bitgc->MapColors(TRect(0,0,0,0),NULL,0,EFalse);
1094 region.ForceError();
1095 bitgc->SetClippingRegion(®ion);
1098 region.AddRect(TRect(-1,-1,1,1));
1099 bitgc->SetClippingRegion(®ion);
1102 bitgc->UseBrushPattern(NULL);
1105 bitgc->UseBrushPattern((CFbsBitmap*)bitgc);
1108 bitgc->UseBrushPattern(0);
1111 bitgc->UseFont(NULL);
1114 bitgc->DrawText(_L("abc"),TPoint(0,0));
1117 bitgc->DrawText(_L("abc"),TRect(0,0,1,1),0,0);
1120 bitgc->DrawTextVertical(_L("abc"),EFalse);
1123 User::Panic(_L("Default panic"),KErrGeneral);
1129 __CONSTRUCT_STEP__(Auto)
1131 void CTAutoStep::TestSetupL()
1134 User::LeaveIfError(RFbsSession::Connect());
1137 void CTAutoStep::TestClose()
1139 RFbsSession::Disconnect();