sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // GDI.CPP sl@0: // Test GDI functions sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TGDI.H" sl@0: sl@0: #define TAUTO_BITMAP_NAME _L("Z:\\WSTEST\\TAUTO.MBM") sl@0: sl@0: //#define LOGGING on //Uncomment this line to get extra test logging - useful if debugging a failure of one of the tests sl@0: sl@0: typedef CGdiTestLowLevel *(*GdiTestFunc)(); sl@0: sl@0: _LIT(KMonospaceTestFontTypefaceName,"Arial"); sl@0: const TInt KMaxFontSize = 200; sl@0: sl@0: static inline TBool IsLengthEqual(TInt aLLen, TInt aRLen, TInt aBbLen) sl@0: { sl@0: // The bounding box of a 'w' is one pixel wider than it should be. W overlaps in to the bounding box of 'x' as the two sl@0: // are stuck together. So add a tolerance of -1. sl@0: return (((aLLen+aRLen)==aBbLen) || ((aLLen+aRLen-1)==aBbLen)); sl@0: } sl@0: sl@0: struct GdiTest sl@0: { sl@0: GdiTestFunc func; sl@0: const TText *txt; sl@0: }; sl@0: sl@0: GdiTest GdiTestFuncs[]={ sl@0: {BoxTextTest,_S("BoxText")}, sl@0: {VertTextTest,_S("VertText")}, sl@0: /*{JustifiedTextTest,_S("JustifiedText")},*/ // DEF107985 The test for JustifiedText has been removed as it was a bad/useless test sl@0: {VertBoxTextTest,_S("VertBoxText")}, sl@0: {SetOriginTest,_S("SetOrigin")}, sl@0: {PolyLineTest,_S("PolyLine")}, sl@0: {PolygonTest,_S("Polygon")}, sl@0: {DrawArcTest,_S("DrawArc")}, sl@0: {DrawPieTest,_S("DrawPie")}, sl@0: {DrawRoundRectTest,_S("DrawRoundRect")}, sl@0: {WideLineTest,_S("WideLine")}, sl@0: {DrawTextTest,_S("DrawText")}, sl@0: {DrawRectTest,_S("DrawRect")}, sl@0: }; sl@0: sl@0: CTestWindow::CTestWindow(TRgb aCol) : CBlankWindow(aCol) sl@0: { sl@0: } sl@0: sl@0: CTestWindow::~CTestWindow() sl@0: { sl@0: } sl@0: sl@0: void CTestWindow::ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc) sl@0: { sl@0: iWin=RWindow(TheClient->iWs); sl@0: User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle)); sl@0: SetExt(aPos,aSize); sl@0: Activate(); sl@0: AssignGC(aGc); sl@0: } sl@0: sl@0: void CGdiTestLowLevel::SetGdiTest(CTGdi *aGdiTest) sl@0: { sl@0: iGdiTest=aGdiTest; sl@0: } sl@0: sl@0: void CGdiTestLowLevel::AssignGdi(CWindowGc *aGc) sl@0: { sl@0: iGdi=aGc; sl@0: } sl@0: sl@0: void CGdiTestLowLevel::ConstructL(TInt) sl@0: { sl@0: } sl@0: sl@0: void CGdiTestLowLevel::PreTestSetupL(const TRect &,TInt) sl@0: { sl@0: } sl@0: sl@0: //=======================================// sl@0: // Individual GDI low level test classes // sl@0: //=======================================// sl@0: sl@0: sl@0: void CGdiRect::ConstructL(TInt) sl@0: { sl@0: } sl@0: sl@0: void CGdiRect::PreTestSetupL(const TRect &, TInt aCount) sl@0: { sl@0: iBrushCol=TRgb::Gray256(aCount&0x1 ? 0xFF : 0x60); sl@0: iPenCol=TRgb::Gray256(aCount&0x1 ? 0xA0 : 0x0); sl@0: } sl@0: sl@0: TInt CGdiRect::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiDrawRect::BaseTest(const TRect &aRect, TInt aCount) sl@0: { sl@0: TheTest(aRect,aCount); sl@0: } sl@0: sl@0: void CGdiDrawRect::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetBrushColor(iBrushCol); sl@0: iGdi->SetPenColor(iPenCol); sl@0: iGdi->DrawRect(aRect); sl@0: } sl@0: sl@0: TInt CGdiDrawRect::Count(TBool aMode) sl@0: { sl@0: return(aMode ? 4:1); sl@0: } sl@0: sl@0: TInt CGdiDrawRoundRect::Count(TBool aMode) sl@0: { sl@0: return(aMode ? 4:1); sl@0: } sl@0: sl@0: void CGdiDrawRoundRect::BaseTest(const TRect &aRect, TInt aCount) sl@0: { sl@0: TheTest(aRect,aCount); sl@0: } sl@0: sl@0: void CGdiDrawRoundRect::TheTest(const TRect &aRect, TInt aCount) sl@0: { sl@0: iGdi->SetBrushColor(iBrushCol); sl@0: iGdi->SetPenColor(iPenCol); sl@0: TSize size((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); sl@0: switch(aCount) sl@0: { sl@0: case 0: sl@0: size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); sl@0: break; sl@0: case 1: sl@0: size.SetSize(0,0); sl@0: break; sl@0: case 2: sl@0: size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/2,(aRect.iBr.iY-aRect.iTl.iY)/2); sl@0: break; sl@0: case 3: sl@0: size.SetSize((aRect.iBr.iX-aRect.iTl.iX),(aRect.iBr.iY-aRect.iTl.iY)); sl@0: break; sl@0: } sl@0: iGdi->DrawRoundRect(aRect,size); sl@0: } sl@0: sl@0: TInt CGdiDrawACP::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiDrawACP::ConstructL(TInt) sl@0: { sl@0: } sl@0: sl@0: void CGdiDrawACP::PreTestSetupL(const TRect &, TInt ) sl@0: { sl@0: iBrushCol=TRgb::Gray256(0xff); sl@0: iPenCol=TRgb(0,0,0); sl@0: } sl@0: sl@0: void CGdiDrawArc::BaseTest(const TRect &aRect, TInt aCount) sl@0: { sl@0: TheTest(aRect,aCount); sl@0: } sl@0: sl@0: void CGdiDrawArc::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetBrushColor(iBrushCol); sl@0: iGdi->SetPenColor(iPenCol); sl@0: TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); sl@0: iGdi->DrawArc(aRect,start,TPoint(0,0)); sl@0: } sl@0: sl@0: void CGdiDrawPie::BaseTest(const TRect &aRect, TInt aCount) sl@0: { sl@0: TheTest(aRect,aCount); sl@0: } sl@0: sl@0: void CGdiDrawPie::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetBrushColor(iBrushCol); sl@0: iGdi->SetPenColor(iPenCol); sl@0: TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); sl@0: iGdi->DrawPie(aRect,start,TPoint(0,0)); sl@0: } sl@0: sl@0: // sl@0: // Polyline tests sl@0: // sl@0: sl@0: CGdiPolyLine::CGdiPolyLine() : iPnts(5) sl@0: {} sl@0: sl@0: void CGdiPolyLine::PreTestSetupL(const TRect &aRect, TInt aCount) sl@0: { sl@0: iPnts.Reset(); sl@0: TInt wid=aRect.Width(); sl@0: TInt hgt=aRect.Height(); sl@0: if (aCount==0) sl@0: { sl@0: TInt pos; sl@0: for(pos=0;pos0) sl@0: iGdi->DrawLine(prev,iPnts[index]); sl@0: prev=iPnts[index]; sl@0: } sl@0: if (index>0) sl@0: iGdi->Plot(iPnts[index-1]); sl@0: } sl@0: sl@0: void CGdiPolyLine::TheTest(const TRect &, TInt ) sl@0: { sl@0: iGdi->DrawPolyLine(&iPnts); sl@0: } sl@0: sl@0: // sl@0: // Polygon tests // sl@0: // sl@0: sl@0: CGdiPolygon::CGdiPolygon() : iPnts(5) sl@0: {} sl@0: sl@0: void CGdiPolygon::PreTestSetupL(const TRect &aRect, TInt ) sl@0: { sl@0: iPnts.Reset(); sl@0: TPoint pnt; sl@0: TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); sl@0: TInt numPoints=0; sl@0: if (maxPoints>0) sl@0: { sl@0: iPnts.AppendL(aRect.iTl); sl@0: while(numPoints0) sl@0: { sl@0: numPoints--; sl@0: if (numPoints&1) sl@0: pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+(numPoints+1)*KPolygonStep); sl@0: else sl@0: pnt.SetXY(aRect.iTl.iX+(numPoints+1)*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep); sl@0: iPnts.AppendL(pnt); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CGdiPolygon::ConstructL(TInt ) sl@0: { sl@0: } sl@0: sl@0: TInt CGdiPolygon::Count(TBool aMainTests) sl@0: { sl@0: return(aMainTests ? 2 : 1); sl@0: } sl@0: sl@0: void CGdiPolygon::BaseTest(const TRect &aRect, TInt ) sl@0: { sl@0: iGdi->SetPenColor(TRgb::Gray4(2)); sl@0: iGdi->SetBrushColor(TRgb::Gray4(1)); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); sl@0: for(TInt numPoints=0;numPointsDrawRect(TRect(aRect.iTl.iX+numPoints*KPolygonStep + 1,aRect.iTl.iY+numPoints*KPolygonStep + 1, sl@0: aRect.iTl.iX+(numPoints+1)*KPolygonStep ,aRect.iTl.iY+(numPoints+1)*KPolygonStep)); sl@0: } sl@0: sl@0: void CGdiPolygon::TheTest(const TRect &, TInt ) sl@0: //This is the only one that can leave so it's not worth adding an 'L' sl@0: { sl@0: iGdi->SetPenColor(TRgb::Gray4(2)); sl@0: iGdi->SetBrushColor(TRgb::Gray4(1)); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: User::LeaveIfError(iGdi->DrawPolygon(&iPnts,CGraphicsContext::EAlternate)); sl@0: } sl@0: sl@0: // sl@0: sl@0: TInt CGdiWideLine::Count(TBool aMainTests) sl@0: { sl@0: return(aMainTests ? EMainNumWidths : EMinorNumWidths); sl@0: } sl@0: sl@0: void CGdiWideLine::ConstructL(TInt) sl@0: { sl@0: } sl@0: sl@0: void CGdiWideLine::PreTestSetupL(const TRect &, TInt aCount) sl@0: { sl@0: TInt widths[]={1,4,50,-2, sl@0: 48,12345,0,3, sl@0: 48,123,0,3, sl@0: 4,111,555,1000, sl@0: 10,-1,-10,-100}; sl@0: iWidth=widths[aCount]; sl@0: } sl@0: sl@0: void CGdiWideLine::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetPenSize(TSize(iWidth,iWidth)); sl@0: iGdi->DrawLine(aRect.iTl,aRect.iBr); sl@0: iGdi->MoveTo(aRect.iTl+TPoint(0,10)); sl@0: iGdi->DrawLineBy(aRect.iBr-aRect.iTl); sl@0: iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); sl@0: iGdi->DrawLineTo(aRect.iBr+TPoint(0,20)); sl@0: } sl@0: sl@0: void CGdiWideLine::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetPenSize(TSize(iWidth,iWidth)); sl@0: iGdi->MoveTo(aRect.iTl); sl@0: iGdi->DrawLineBy(aRect.iBr-aRect.iTl); sl@0: iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); sl@0: iGdi->DrawLineTo(aRect.iBr+TPoint(0,10)); sl@0: iGdi->DrawLine(aRect.iTl+TPoint(0,20),aRect.iBr+TPoint(0,20)); sl@0: } sl@0: sl@0: // sl@0: // Set Origin // sl@0: // sl@0: sl@0: CGdiSetOrigin::~CGdiSetOrigin() sl@0: { sl@0: delete iPolylineArray; sl@0: delete iPolygonArray; sl@0: TheClient->iScreen->ReleaseFont(iFont); sl@0: } sl@0: sl@0: TInt CGdiSetOrigin::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiSetOrigin::ConstructL(TInt) sl@0: { sl@0: iPolylineArray=new(ELeave) CArrayFixFlat(3); sl@0: iPolylineArray->AppendL(TPoint(40,1)); sl@0: iPolylineArray->AppendL(TPoint(50,11)); sl@0: iPolylineArray->AppendL(TPoint(40,21)); sl@0: iPolygonArray=new(ELeave) CArrayFixFlat(3); sl@0: iPolygonArray->AppendL(TPoint(40,30)); sl@0: iPolygonArray->AppendL(TPoint(50,40)); sl@0: iPolygonArray->AppendL(TPoint(40,45)); sl@0: TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); sl@0: } sl@0: sl@0: void CGdiSetOrigin::PreTestSetupL(const TRect &, TInt ) sl@0: { sl@0: } sl@0: sl@0: void CGdiSetOrigin::DrawIt(const TPoint &aOffset) sl@0: { sl@0: iGdi->DrawLine(TPoint(10,10)+aOffset,TPoint(20,30)+aOffset); sl@0: iGdi->DrawLineBy(TPoint(-10,5)); sl@0: iGdi->DrawLineTo(TPoint(20,5)+aOffset); sl@0: iGdi->MoveTo(TPoint(20,10)+aOffset); sl@0: iGdi->DrawLineTo(TPoint(30,15)+aOffset); sl@0: iGdi->MoveBy(TPoint(-10,2)); sl@0: iGdi->DrawLineBy(TPoint(10,0)); sl@0: iGdi->UseFont(iFont); sl@0: iGdi->DrawText(_L("Set Origin Test"),TPoint(40,20)+aOffset); sl@0: iGdi->DiscardFont(); sl@0: iGdi->DrawRect(TRect(TPoint(10,45)+aOffset,TPoint(20,55)+aOffset)); sl@0: iGdi->DrawRoundRect(TRect(TPoint(21,45)+aOffset,TPoint(30,55)+aOffset),TSize(3,2)); sl@0: iGdi->DrawEllipse(TRect(TPoint(31,45)+aOffset,TPoint(40,55)+aOffset)); sl@0: TInt index; sl@0: for(index=0;indexCount();index++) sl@0: (*iPolylineArray)[index]+=aOffset; sl@0: iGdi->DrawPolyLine(iPolylineArray); sl@0: for(index=0;indexCount();index++) sl@0: (*iPolylineArray)[index]-=aOffset; sl@0: for(index=0;indexCount();index++) sl@0: (*iPolygonArray)[index]+=aOffset; sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: User::LeaveIfError(iGdi->DrawPolygon(iPolygonArray,CGraphicsContext::EAlternate)); //Doesn't cause any harm if it leaves sl@0: for(index=0;indexCount();index++) sl@0: (*iPolygonArray)[index]-=aOffset; sl@0: } sl@0: sl@0: void CGdiSetOrigin::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: DrawIt(aRect.iTl); sl@0: } sl@0: sl@0: void CGdiSetOrigin::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->SetOrigin(aRect.iTl); sl@0: DrawIt(TPoint(0,0)); sl@0: } sl@0: sl@0: // sl@0: // Draw text // sl@0: // sl@0: sl@0: CGdiDrawText::~CGdiDrawText() sl@0: { sl@0: TheClient->iScreen->ReleaseFont(iFont); sl@0: } sl@0: sl@0: TInt CGdiDrawText::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiDrawText::ConstructL(TInt) sl@0: { sl@0: TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); sl@0: TInt index; sl@0: for(index=0;indexTextWidthInPixels(iBigBuffer); sl@0: for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); sl@0: TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(characters-index)); sl@0: TBool result = IsLengthEqual(lLen,rLen,bbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: { sl@0: _LIT(KLog,"Font width metrics error, Width(%dchars)=%d, Width(%dchars)=%d, Width(%dchars)=%d"); sl@0: iGdiTest->LOG_MESSAGE7(KLog,index,lLen,characters-index,rLen,characters,bbLen); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CGdiDrawText::PreTestSetupL(const TRect&,TInt) sl@0: {} sl@0: sl@0: void CGdiDrawText::BaseTest(const TRect& aRect,TInt) sl@0: { sl@0: TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: // sl@0: iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); sl@0: TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iX)-1; // -1 so one off screen char is drawn to handle overhang sl@0: if (missingChars>=0) sl@0: { sl@0: TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); sl@0: TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); sl@0: TInt rLen=iFont->TextWidthInPixels(bbb); sl@0: TBool result = IsLengthEqual(lLen,rLen,bbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: { sl@0: _LIT(KLog,"Font width metrics error, missingChars=%d %d+%d=%d"); sl@0: iGdiTest->LOG_MESSAGE5(KLog,missingChars,lLen,rLen,bbLen); sl@0: } sl@0: iGdi->DrawText(bbb,TPoint(aRect.iBr.iX-rLen,aRect.iTl.iY+fAscent+fHeight)); sl@0: } sl@0: iGdi->DiscardFont(); sl@0: } sl@0: sl@0: void CGdiDrawText::TheTest(const TRect& aRect,TInt) sl@0: { sl@0: TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: // sl@0: iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); sl@0: iGdi->DrawText(iBigBuffer,TPoint(aRect.iBr.iX-bbLen,aRect.iTl.iY+fAscent+fHeight)); sl@0: iGdi->DiscardFont(); sl@0: } sl@0: sl@0: // sl@0: // Draw vertical text // sl@0: // sl@0: sl@0: CGdiDrawVertText::~CGdiDrawVertText() sl@0: { sl@0: TheClient->iScreen->ReleaseFont(iFont); sl@0: } sl@0: sl@0: TInt CGdiDrawVertText::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiDrawVertText::ConstructL(TInt) sl@0: { sl@0: TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); sl@0: TInt index; sl@0: for(index=0;indexTextWidthInPixels(iBigBuffer); sl@0: for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); sl@0: TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(iBigBuffer.Length()-index)); sl@0: TBool result = IsLengthEqual(lLen,rLen,bbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); sl@0: } sl@0: } sl@0: sl@0: void CGdiDrawVertText::PreTestSetupL(const TRect &, TInt ) sl@0: { sl@0: } sl@0: sl@0: void CGdiDrawVertText::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: // sl@0: TInt tlen=iFont->TextWidthInPixels(_L("Hello")); sl@0: iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); sl@0: iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); sl@0: TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iY)-1; // -1 so one off screen char is drawn to handle overhang sl@0: if (missingChars>=0) sl@0: { sl@0: TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); sl@0: TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); sl@0: TInt rLen=iFont->TextWidthInPixels(bbb); sl@0: TBool result = IsLengthEqual(lLen,rLen,bbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); sl@0: sl@0: iGdi->DrawTextVertical(bbb,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-rLen),EFalse); sl@0: } sl@0: iGdi->DiscardFont(); sl@0: } sl@0: sl@0: void CGdiDrawVertText::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: // sl@0: TInt tlen=iFont->TextWidthInPixels(_L("Hello")); sl@0: iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); sl@0: iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); sl@0: iGdi->DrawTextVertical(iBigBuffer,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-bbLen),EFalse); sl@0: iGdi->DiscardFont(); sl@0: } sl@0: sl@0: // sl@0: // Draw Justified text // sl@0: // sl@0: sl@0: // DEF107985 The test for JustifiedText has been removed as it was a bad/useless test. The original test was sl@0: // broken after it was migrated to TEF TGdi test. It was not worth fixing as the purpose of test was not clear, sl@0: // and fixing it basically required rewriting the whole test. sl@0: // sl@0: sl@0: sl@0: // sl@0: // Box text // sl@0: // sl@0: sl@0: CGdiBoxText::~CGdiBoxText() sl@0: { sl@0: TheClient->iScreen->ReleaseFont(iFont); sl@0: } sl@0: sl@0: TInt CGdiBoxText::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiBoxText::ConstructL(TInt) sl@0: { sl@0: TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); sl@0: for(TInt index=0;indexTextWidthInPixels(iBigBuffer); sl@0: } sl@0: sl@0: void CGdiBoxText::PreTestSetupL(const TRect &, TInt ) sl@0: { sl@0: } sl@0: sl@0: void CGdiBoxText::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt rWid=aRect.iBr.iX-aRect.iTl.iX; sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: // sl@0: TRect rect(aRect); sl@0: rect.iBr.iY=rect.iTl.iY+fHeight; sl@0: // sl@0: TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); sl@0: TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); sl@0: TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); sl@0: TInt rLen=iFont->TextWidthInPixels(bbb); sl@0: TBool result = IsLengthEqual(lLen,rLen,iBbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); sl@0: sl@0: iGdi->DrawText(bbb, rect, fAscent,CGraphicsContext::ELeft, rWid-rLen); sl@0: // sl@0: rect.Move(TPoint(0,fHeight)); sl@0: iGdi->DrawText(iBigBuffer, rect, fAscent,CGraphicsContext::ELeft, 0); sl@0: // sl@0: TBuf<10> buf2(_L("1234567890")); sl@0: rect.Move(TPoint(0,fHeight)); sl@0: iGdi->DrawText(buf2,rect,fAscent,CGraphicsContext::ERight,rect.Width()-iFont->TextWidthInPixels(buf2)); sl@0: } sl@0: sl@0: void CGdiBoxText::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt rWid=aRect.iBr.iX-aRect.iTl.iX; sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TRect rect(aRect); sl@0: rect.iBr.iY=rect.iTl.iY+fHeight; sl@0: // sl@0: iGdi->DrawText(iBigBuffer, rect, fAscent, CGraphicsContext::ELeft, rWid-iBbLen); sl@0: // sl@0: rect.Move(TPoint(0,fHeight)); sl@0: iGdi->Clear(rect); sl@0: iGdi->SetClippingRegion(TRegionFix<1>(rect)); sl@0: iGdi->DrawText(iBigBuffer, rect.iTl+TPoint(0,fAscent)); sl@0: TBuf<10> buf2(_L("1234567890")); sl@0: rect.Move(TPoint(0,fHeight)); sl@0: iGdi->CancelClippingRegion(); sl@0: iGdi->DrawText(buf2,rect,fAscent); sl@0: } sl@0: sl@0: // sl@0: // Vert Box text // sl@0: // sl@0: sl@0: CGdiVertBoxText::~CGdiVertBoxText() sl@0: { sl@0: TheClient->iScreen->ReleaseFont(iFont); sl@0: } sl@0: sl@0: TInt CGdiVertBoxText::Count(TBool ) sl@0: { sl@0: return(1); sl@0: } sl@0: sl@0: void CGdiVertBoxText::ConstructL(TInt) sl@0: { sl@0: TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); sl@0: for(TInt index=0;indexTextWidthInPixels(iBigBuffer); sl@0: } sl@0: sl@0: void CGdiVertBoxText::PreTestSetupL(const TRect &, TInt ) sl@0: { sl@0: } sl@0: sl@0: void CGdiVertBoxText::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt rWid=aRect.iBr.iY-aRect.iTl.iY; sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: // sl@0: TRect rect(aRect); sl@0: rect.iBr.iX=rect.iTl.iX+fHeight; sl@0: // sl@0: TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); sl@0: TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars+1); sl@0: TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars-1)); sl@0: TInt rLen=iFont->TextWidthInPixels(bbb); sl@0: TBool result = IsLengthEqual(lLen,rLen,iBbLen); sl@0: iGdiTest->TEST(result); sl@0: if (!result) sl@0: iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); sl@0: sl@0: iGdi->DrawTextVertical(bbb, rect, fAscent, ETrue,CGraphicsContext::ELeft, rWid-rLen); sl@0: // sl@0: rect.iTl.iX=rect.iBr.iX; sl@0: rect.iBr.iX=rect.iTl.iX+fHeight; sl@0: iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue,CGraphicsContext::ELeft, 0); sl@0: } sl@0: sl@0: void CGdiVertBoxText::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: TInt rWid=aRect.iBr.iY-aRect.iTl.iY; sl@0: TInt fAscent=iFont->AscentInPixels(); sl@0: TInt fHeight=iFont->HeightInPixels(); sl@0: iGdi->UseFont(iFont); sl@0: iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TRect rect(aRect); sl@0: rect.iBr.iX=rect.iTl.iX+fHeight; sl@0: // sl@0: iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue, CGraphicsContext::ELeft, rWid-iBbLen); sl@0: // sl@0: rect.iTl.iX=rect.iBr.iX; sl@0: rect.iBr.iX=rect.iTl.iX+fHeight; sl@0: iGdi->Clear(rect); sl@0: iGdi->SetClippingRegion(TRegionFix<1>(rect)); sl@0: iGdi->DrawTextVertical(iBigBuffer, TPoint(rect.iTl.iX+fAscent,rect.iBr.iY), ETrue); sl@0: } sl@0: sl@0: sl@0: // sl@0: // sl@0: CGdiBlitMasked::~CGdiBlitMasked() sl@0: { sl@0: for(TInt index=0;indexCreateContext(aGc)); sl@0: // sl@0: aGc->SetBrushColor(TRgb(128,128,128)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aBitmap->SizeInPixels())); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: for(TInt index=(-aSize.iHeight);indexDrawLine(TPoint(index,0),TPoint(index+aSize.iHeight,aSize.iHeight)); sl@0: aGc->DrawLine(TPoint(index,aSize.iHeight),TPoint(index+aSize.iHeight,0)); sl@0: } sl@0: } sl@0: sl@0: void CGdiBlitMasked::createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize) sl@0: { sl@0: CFbsBitGc *gc=NULL; sl@0: CFbsBitmapDevice *device=NULL; sl@0: aBitmap=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(aBitmap->Create(aSize,EGray16)); sl@0: TRAPD(err,doCreateTestBitmapL(aBitmap, gc, device, aSize)); sl@0: delete gc; sl@0: delete device; sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void CGdiBlitMasked::ConstructL(TInt) sl@0: { sl@0: TSize max(0,0); sl@0: for(TInt index=0;indexLoad(TAUTO_BITMAP_NAME,2+index)); sl@0: TSize size=iMask[index]->SizeInPixels(); sl@0: if (max.iWidthCreate(max,EGray16)); sl@0: iScratchDevice=CFbsBitmapDevice::NewL(iScratch); sl@0: User::LeaveIfError(iScratchDevice->CreateContext(iScratchGc)); sl@0: sl@0: iScratchMask=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iScratchMask->Create(max,EGray16)); sl@0: iScratchMaskDevice=CFbsBitmapDevice::NewL(iScratchMask); sl@0: User::LeaveIfError(iScratchMaskDevice->CreateContext(iScratchMaskGc)); sl@0: // sl@0: createTestBitmapL(iBitmap, max); sl@0: } sl@0: sl@0: void CGdiBlitMasked::PreTestSetupL(const TRect &, TInt aCount) sl@0: { sl@0: iInvertMask=aCount&0x1; sl@0: aCount>>=1; sl@0: iCurrMask= iMask[aCount%ENumMasks]; sl@0: iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: } sl@0: sl@0: void CGdiBlitMasked::BaseTest(const TRect &aRect, TInt) sl@0: { sl@0: // needs re-writing to emulate tiling of the source rect sl@0: if (!aRect.Intersects(TRect(BaseWin->Size()))) sl@0: return; sl@0: TSize size(aRect.Size()); sl@0: TSize bitSize=iBitmap->SizeInPixels(); sl@0: if (size.iWidth>bitSize.iWidth) sl@0: size.iWidth=bitSize.iWidth; sl@0: if (size.iHeight>bitSize.iHeight) sl@0: size.iHeight=bitSize.iHeight; sl@0: // sl@0: // Set up the scratch mask as a black and white bitmap containing the mask to blit sl@0: // The mask pattern is replicated all over the scratchmask bitmap sl@0: // sl@0: iScratchMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iScratchMaskGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iScratchMaskGc->SetBrushColor(TRgb(0,0,0)); sl@0: iScratchMaskGc->DrawRect(TRect(iScratchMask->SizeInPixels())); sl@0: iScratchMaskGc->SetPenColor(TRgb(255,255,255)); sl@0: iScratchMaskGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: TSize maskSize(iCurrMask->SizeInPixels()); sl@0: TPoint pos; sl@0: TRgb *rgbBuf=(TRgb *)User::AllocL(maskSize.iWidth*sizeof(TRgb)); //Doesn't do any harm if it leaves sl@0: for(pos.iY=0;pos.iYGetScanLine(ptr, pos, maskSize.iWidth, ERgb); sl@0: for(TInt index=0;indexSetPenColor(rgbBuf[index]); sl@0: // if ((isLow && !iLowCutOff) || (!isLow && iLowCutOff)) sl@0: iScratchMaskGc->Plot(TPoint(index,pos.iY)); sl@0: } sl@0: } sl@0: User::Free(rgbBuf); sl@0: sl@0: for(pos.iY=0;pos.iYCopyRect(pos, TRect(maskSize)); sl@0: // sl@0: // Blit this to the screen in ANDNOT mode to clear all the pixels we want the mask blit to draw to sl@0: // sl@0: iGdi->SetDrawMode(CGraphicsContext::EDrawModeANDNOT); sl@0: iGdi->BitBlt(aRect.iTl, iScratchMask, TRect(size)); sl@0: // sl@0: // Copy the test bitmap to the scratch bitmap then use the scratch mask to clear all the bits sl@0: // that should masked out of the draw to the screen sl@0: // sl@0: iScratchGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: iScratchGc->BitBlt(TPoint(0,0), iBitmap); sl@0: iScratchGc->SetDrawMode(CGraphicsContext::EDrawModeAND); sl@0: iScratchGc->BitBlt(TPoint(0,0), iScratchMask); sl@0: // sl@0: // Now copy the scratch bitmap to the screen in OR mode to get the final result sl@0: // sl@0: iGdi->SetDrawMode(CGraphicsContext::EDrawModeOR); sl@0: iGdi->BitBlt(aRect.iTl, iScratch, TRect(size)); sl@0: } sl@0: sl@0: void CGdiBlitMasked::TheTest(const TRect &aRect, TInt) sl@0: { sl@0: iGdi->BitBltMasked(aRect.iTl,iBitmap,TRect((aRect.iBr-aRect.iTl).AsSize()), sl@0: iCurrMask,iInvertMask); sl@0: } sl@0: // sl@0: // sl@0: sl@0: CTGdi::CTGdi(CTestStep* aStep) : CTWsGraphicsBase(aStep), iGdiTest (NULL), iTextOffsetX(10),iTextOffsetY(10) sl@0: { sl@0: } sl@0: sl@0: void CTGdi::ConstructL() sl@0: { sl@0: iWinSize=TestWin->Size(); sl@0: } sl@0: sl@0: TSize CTGdi::WinSize() sl@0: { sl@0: return(iWinSize); sl@0: } sl@0: sl@0: void CTGdi::DoGdiTestL(const TRect &aRect, TInt aNum) sl@0: { sl@0: // sl@0: iGdiTest->PreTestSetupL(aRect,aNum); sl@0: // sl@0: BaseWin->Win()->Invalidate(); sl@0: BaseWin->Win()->BeginRedraw(); sl@0: TheGc->Activate(*BaseWin->Win()); sl@0: iTest->DrawTestBackground(EFalse,BaseWin->Size()); sl@0: iGdiTest->BaseTest(aRect,aNum); sl@0: TheGc->Deactivate(); sl@0: BaseWin->Win()->EndRedraw(); sl@0: // sl@0: TestWin->Win()->Invalidate(); sl@0: TestWin->Win()->BeginRedraw(); sl@0: TheGc->Activate(*TestWin->Win()); sl@0: iTest->DrawTestBackground(EFalse,TestWin->Size()); sl@0: iGdiTest->TheTest(aRect,aNum); sl@0: TheGc->Deactivate(); sl@0: TestWin->Win()->EndRedraw(); sl@0: // sl@0: TheClient->iWs.Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: // sl@0: _LIT(KLog,"GDI Substate=%d test=%d rect=(%d,%d,%d,%d) "); sl@0: TBuf<64> buf; sl@0: buf.Format(KLog,iSubState,aNum,aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); sl@0: iTestPassing=CompareWindows(buf); sl@0: } sl@0: sl@0: void CTGdi::GdiTestL(CGdiTestLowLevel *aTest) sl@0: { sl@0: TTestRects::ResetSeed(); sl@0: iTestPassing=ETrue; sl@0: iGdiTest=aTest; sl@0: iGdiTest->SetGdiTest(this); sl@0: iGdiTest->AssignGdi(TheGc); sl@0: iGdiTest->ConstructL(iTest->iTestRects.Count1()); sl@0: TInt index; sl@0: TInt index2; sl@0: for(index=0; iTestPassing && indexiTestRects.Count2(); ++index) sl@0: { sl@0: TInt max=iGdiTest->Count(indexiTestRects.Count1()); sl@0: TRect rect=iTest->iTestRects[index]; sl@0: #if defined(LOGGING) sl@0: _LIT(KLog1,"Testing rectangle %d (%d,%d,%d,%d) 1st pass"); sl@0: LOG_MESSAGE6(KLog1,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: #endif sl@0: for(index2=0; iTestPassing && index2iTestRects.Count3(); index++) sl@0: { sl@0: TRect rect=iTest->iTestRects[index]; sl@0: #if defined(LOGGING) sl@0: _LIT(KLog2,"Testing rectangle %d (%d,%d,%d,%d) 2nd pass"); sl@0: LOG_MESSAGE6(KLog2,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); sl@0: #endif sl@0: DoGdiTestL(rect,0); sl@0: } sl@0: delete iGdiTest; sl@0: iGdiTest=NULL; sl@0: } sl@0: sl@0: void CTGdi::NonDrawing() sl@0: // sl@0: // Test all non-drawing GDI functions sl@0: // sl@0: { sl@0: TDisplayMode mode=TheClient->iScreen->DisplayMode(); sl@0: TEST((mode!=ERgb) && (mode!=ENone)); sl@0: sl@0: RWsSession session; sl@0: TInt res = session.Connect(); sl@0: TEST(res == KErrNone); sl@0: sl@0: CArrayFixFlat* modeList= new CArrayFixFlat (15); sl@0: if(!modeList) sl@0: return; sl@0: sl@0: #if defined(SYMBIAN_GRAPHICS_GCE) sl@0: res = session.GetColorModeList(iTest->iScreenNumber, modeList); sl@0: #else sl@0: res = session.GetColorModeList(modeList); sl@0: #endif //SYMBIAN_GRAPHICS_GCE sl@0: session.Close(); sl@0: TEST(res == KErrNone); sl@0: if(res != KErrNone) sl@0: { sl@0: modeList->Reset(); sl@0: delete modeList; sl@0: return; sl@0: } sl@0: sl@0: TBool found = EFalse; sl@0: for(TInt ii = 0; ii < modeList->Count() && !found; ii++) sl@0: { sl@0: TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]); sl@0: if(mode == mode1) sl@0: { sl@0: found = ETrue; sl@0: } sl@0: } sl@0: modeList->Reset(); sl@0: delete modeList; sl@0: sl@0: TEST(found); sl@0: } sl@0: sl@0: // sl@0: // Auxiliary Fn for Test Case ID CTGdi_TestDefetct_DEF045746 sl@0: // This method draws the text represented by aText parameter on the window sl@0: // passed to it. sl@0: // sl@0: void CTGdi::DrawTextOnWindow(const TDesC& aText,CTWin* aWin) sl@0: { sl@0: aWin->Win()->BeginRedraw(); sl@0: TheGc->Activate(*aWin->Win()); sl@0: TheGc->Device()->GetNearestFontToDesignHeightInTwips(iFont,TFontSpec(_L("Arial"),250)); sl@0: TheGc->UseFont(iFont); sl@0: TheGc->Clear(); sl@0: TheGc->DrawRect(TRect(aWin->Win()->Size())); sl@0: TheGc->DrawText(aText,TPoint(iTextOffsetX,iTextOffsetY)); sl@0: TheGc->Device()->ReleaseFont(iFont); sl@0: TheGc->Deactivate(); sl@0: aWin->Win()->EndRedraw(); sl@0: } sl@0: sl@0: sl@0: void CTGdi::TestDefetct_DEF045746L() sl@0: { sl@0: _LIT(KString,"This is a test window for the defect fix DEF045746 \ sl@0: propagated from Opera browser. Most window graphics context drawing\ sl@0: functions map to equivalent CFbsBitGc functions they are implemented\ sl@0: on the screen with any co-ordinates being relative to the top left\ sl@0: corner of the window. However extra clipping is applied. The drawing\ sl@0: will always be clipped to the visible part of the window, in addition\ sl@0: it will be clipped to the non-invalid part if you are not doing a\ sl@0: redraw and to the region being validated if you are doing a redraw."); sl@0: sl@0: TPtrC TestText(KString().Ptr(),100); sl@0: TPtrC LargeText(KString().Ptr()); sl@0: TPtrC ShortText(KString().Ptr(),200); sl@0: sl@0: TSize scrSize=TheClient->iScreen->SizeInPixels(); sl@0: TSize winSize; sl@0: const TInt windowGap=5; sl@0: winSize.SetSize(scrSize.iWidth -2* windowGap,scrSize.iHeight/2 - windowGap); sl@0: sl@0: iWin=new(ELeave) CTestWindow(TRgb(0,0,0)); sl@0: iWin->ConstructL(TPoint(5,5),TSize(winSize),TheClient->iGroup,*TheClient->iGc); sl@0: CTestWindow* expectWin= new(ELeave) CTestWindow(TRgb(0,0,0)); sl@0: expectWin->ConstructL(TPoint(5,scrSize.iHeight/2 + windowGap),TSize(winSize),TheClient->iGroup,*TheClient->iGc); sl@0: DrawTextOnWindow(ShortText,iWin); sl@0: DrawTextOnWindow(TestText,expectWin); sl@0: TInt fHeight=iFont->HeightInPixels();//Used to compare only pixels where text is drawn sl@0: TRect iRect=winSize; sl@0: iRect.iTl.iX=iTextOffsetX; sl@0: iRect.iTl.iY=iTextOffsetY; sl@0: iRect.iBr.iY=iTextOffsetY+fHeight; sl@0: CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L A")); sl@0: iWin->Invalidate(); sl@0: DrawTextOnWindow(LargeText,iWin); sl@0: CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L B")); sl@0: delete iWin; sl@0: iWin=NULL; sl@0: delete expectWin; sl@0: expectWin=NULL; sl@0: } sl@0: sl@0: void CTGdi::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: //_LIT(KTest1,"NonDrawing"); this test is not running sl@0: _LIT(KTest2,"DEF045746"); sl@0: _LIT(KTest3,"Drawing Tests"); sl@0: ((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: static TTime startTime; sl@0: switch(++iTest->iState) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0262 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test all non-drawing GDI functions sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check all non-drawing GDI functions operate correctly sl@0: sl@0: @SYMTestExpectedResults Non-drawing GDI functions operate correctly sl@0: */ sl@0: case 1: sl@0: // start time log sl@0: startTime.HomeTime(); sl@0: ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0262")); sl@0: //iTest->LogSubTest(KTest1); sl@0: //PeterI this tests whether the display mode is EGray4 or EGray16. sl@0: //The actual display mode is EColor16MU so this test will always fail sl@0: //NonDrawingL(); sl@0: break; sl@0: /** sl@0: * @SYMTestCaseID GRAPHICS-WSERV-0263 sl@0: * sl@0: * @SYMPREQ DEF045746 sl@0: * sl@0: * @SYMTestCaseDesc Test defect fix for DEF045746 sl@0: * sl@0: * @SYMTestPriority High sl@0: * sl@0: * @SYMTestStatus Implemented sl@0: * sl@0: * @SYMTestActions The method tests CWindowGc::DrawText().The test is carried sl@0: * out by writing small & very large strings to the window graphic context. sl@0: * sl@0: * @SYMTestExpectedResults The window with large / small strings written is sl@0: * compared with an expected result window. In both the cases strings should sl@0: * be displayed. sl@0: * sl@0: */ sl@0: case 2: sl@0: ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0263")); sl@0: iTest->LogSubTest(KTest2); sl@0: TestDefetct_DEF045746L(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0264 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test all drawing GDI functions sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check all drawing GDI functions operate correctly sl@0: sl@0: @SYMTestExpectedResults Drawing GDI functions operate correctly sl@0: */ sl@0: case 3: sl@0: { sl@0: ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0264")); sl@0: iTest->LogSubTest(KTest3); sl@0: iSubState = 0; sl@0: TheClient->WaitForRedrawsToFinish(); //Just in case the two test windows have any invalid areas sl@0: TInt numTests = sizeof(GdiTestFuncs) / sizeof(GdiTestFuncs[0]); sl@0: while (iSubState < numTests) sl@0: { sl@0: LOG_MESSAGE(TPtrC(GdiTestFuncs[iSubState].txt)); sl@0: GdiTestL((*GdiTestFuncs[iSubState].func)()); sl@0: iSubState++; sl@0: } sl@0: } sl@0: break; sl@0: default: sl@0: ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTGdiStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: // log time and print duration sl@0: TTime endTime; sl@0: endTime.HomeTime(); sl@0: TInt64 duration = endTime.MicroSecondsFrom(startTime).Int64(); sl@0: float time = (float) I64LOW(duration) / 1000.0f; sl@0: _LIT(KDuration,"Total test duration is %f millisec"); sl@0: RDebug::Print(KDuration, time); sl@0: break; sl@0: } sl@0: ((CTGdiStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: CGdiTestLowLevel *SetOriginTest() sl@0: { sl@0: return(new(ELeave) CGdiSetOrigin()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *PolyLineTest() sl@0: { sl@0: return(new(ELeave) CGdiPolyLine()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *PolygonTest() sl@0: { sl@0: return(new(ELeave) CGdiPolygon()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *BlitMaskedTest() sl@0: { sl@0: return(new(ELeave) CGdiBlitMasked()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *DrawArcTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawArc()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *DrawPieTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawPie()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *DrawRoundRectTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawRoundRect()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *BoxTextTest() sl@0: { sl@0: return(new(ELeave) CGdiBoxText()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *VertTextTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawVertText()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *VertBoxTextTest() sl@0: { sl@0: return(new(ELeave) CGdiVertBoxText()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *WideLineTest() sl@0: { sl@0: return(new(ELeave) CGdiWideLine()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *DrawTextTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawText()); sl@0: } sl@0: sl@0: CGdiTestLowLevel *DrawRectTest() sl@0: { sl@0: return(new(ELeave) CGdiDrawRect()); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(Gdi)