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: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #ifndef __TGDI_H__ sl@0: #define __TGDI_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include "../tlib/testbase.h" sl@0: #include sl@0: #include "AUTO.H" sl@0: #include "TGraphicsHarness.h" sl@0: sl@0: class CGdiTestLowLevel; sl@0: sl@0: CGdiTestLowLevel *SetOriginTest(); sl@0: CGdiTestLowLevel *PolyLineTest(); sl@0: CGdiTestLowLevel *PolygonTest(); sl@0: CGdiTestLowLevel *BlitMaskedTest(); sl@0: CGdiTestLowLevel *DrawArcTest(); sl@0: CGdiTestLowLevel *DrawPieTest(); sl@0: CGdiTestLowLevel *DrawRoundRectTest(); sl@0: CGdiTestLowLevel *BoxTextTest(); sl@0: CGdiTestLowLevel *VertTextTest(); sl@0: CGdiTestLowLevel *JustifiedTextTest(); sl@0: CGdiTestLowLevel *VertBoxTextTest(); sl@0: CGdiTestLowLevel *WideLineTest(); sl@0: CGdiTestLowLevel *DrawTextTest(); sl@0: CGdiTestLowLevel *DrawRectTest(); sl@0: sl@0: class CTGdi; sl@0: class CGdiTestLowLevel : public CBase sl@0: // sl@0: // BaseTest uses code that is assumed to be good to draw to one window sl@0: // TheTest uses the code beng tested to draw a matching pattern sl@0: // sl@0: { sl@0: public: sl@0: void AssignGdi(CWindowGc *aGc); sl@0: void SetGdiTest(CTGdi *aGdiTest); sl@0: virtual void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: virtual void BaseTest(const TRect &aRect, TInt aCount)=0; sl@0: virtual void TheTest(const TRect &aRect, TInt aCount)=0; sl@0: virtual void ConstructL(TInt aNumOfRects); sl@0: virtual TInt Count(TBool aMainTests)=0; sl@0: protected: sl@0: CWindowGc *iGdi; sl@0: CTGdi *iGdiTest; sl@0: }; sl@0: sl@0: class CGdiRect : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: protected: sl@0: TRgb iBrushCol; sl@0: TRgb iPenCol; sl@0: }; sl@0: sl@0: sl@0: class CGdiDrawRect : public CGdiRect sl@0: { sl@0: public: sl@0: TInt Count(TBool aMainTests); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: }; sl@0: sl@0: class CGdiDrawRoundRect : public CGdiRect sl@0: { sl@0: public: sl@0: TInt Count(TBool aMainTests); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: }; sl@0: sl@0: class CGdiDrawACP : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: protected: sl@0: TRgb iBrushCol; sl@0: TRgb iPenCol; sl@0: }; sl@0: sl@0: class CGdiDrawArc : public CGdiDrawACP sl@0: { sl@0: public: sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: }; sl@0: sl@0: class CGdiDrawPie : public CGdiDrawACP sl@0: { sl@0: public: sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: }; sl@0: sl@0: class CGdiPolyLine : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: CGdiPolyLine(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: private: sl@0: CArrayFixSeg iPnts; sl@0: }; sl@0: sl@0: class CGdiPolygon : public CGdiTestLowLevel sl@0: { sl@0: private: sl@0: enum {KMaxPolygonPoints=100}; sl@0: enum {KPolygonStep=4}; sl@0: public: sl@0: CGdiPolygon(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: private: sl@0: CArrayFixSeg iPnts; sl@0: }; sl@0: sl@0: class CGdiWideLine : public CGdiTestLowLevel sl@0: { sl@0: private: sl@0: enum TMaxWidths { sl@0: EMainNumWidths=16, sl@0: EMinorNumWidths=4}; sl@0: public: sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TInt iWidth; sl@0: }; sl@0: sl@0: class CGdiSetOrigin : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: ~CGdiSetOrigin(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void DrawIt(const TPoint &aOffset); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: CFbsFont *iFont; sl@0: CArrayFixFlat *iPolylineArray; sl@0: CArrayFixFlat *iPolygonArray; sl@0: }; sl@0: sl@0: class CGdiDrawText : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: ~CGdiDrawText(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TInt iWidth; sl@0: CFbsFont *iFont; sl@0: TBuf<0x400> iBigBuffer; sl@0: }; sl@0: sl@0: class CGdiDrawVertText : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: ~CGdiDrawVertText(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TInt iWidth; sl@0: CFbsFont *iFont; sl@0: TBuf<0x400> iBigBuffer; sl@0: }; sl@0: sl@0: //class CGdiDrawJustifiedText : public CGdiTestLowLevel sl@0: //DEF107985 The test for JustifiedText has been removed as it was a bad/useless test sl@0: sl@0: class CGdiBoxText : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: ~CGdiBoxText(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TInt iWidth; sl@0: TInt iBbLen; sl@0: CFbsFont *iFont; sl@0: TBuf<0x400> iBigBuffer; sl@0: }; sl@0: sl@0: class CGdiVertBoxText : public CGdiTestLowLevel sl@0: { sl@0: public: sl@0: ~CGdiVertBoxText(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TInt iWidth; sl@0: TInt iBbLen; sl@0: CFbsFont *iFont; sl@0: TBuf<0x400> iBigBuffer; sl@0: }; sl@0: /* sl@0: class CGdiDottedLine : public CGdiTestLowLevel sl@0: { sl@0: enum TMaxPatterns { sl@0: EMainMaxPatterns=5, sl@0: EMinorMaxPatterns=3}; sl@0: public: sl@0: void SetGridRegion(TRegion &grid,const TRect &aRect); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: TUint iPattern; sl@0: TInt iPattLen; sl@0: static TUint iPatterns[EMainMaxPatterns]; sl@0: static TInt iPattLens[EMainMaxPatterns]; sl@0: }; sl@0: TUint CGdiDottedLine::iPatterns[]={ sl@0: 0x55FF0033, sl@0: 0xFF00, sl@0: 0x1, sl@0: 0xFFFF, sl@0: 0xF0F0F0}; sl@0: TInt CGdiDottedLine::iPattLens[]={ sl@0: 32, sl@0: 16, sl@0: 2, sl@0: 32, sl@0: 24}; sl@0: */ sl@0: class CTestWindow : public CBlankWindow sl@0: { sl@0: public: sl@0: CTestWindow(TRgb aCol); sl@0: ~CTestWindow(); sl@0: void ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc ); sl@0: }; sl@0: sl@0: class CGdiBlitMasked: public CGdiTestLowLevel sl@0: { sl@0: enum TNumMasks {ENumMasks=2}; sl@0: public: sl@0: ~CGdiBlitMasked(); sl@0: void PreTestSetupL(const TRect &aRect, TInt aCount); sl@0: void BaseTest(const TRect &aRect, TInt aCount); sl@0: void TheTest(const TRect &aRect, TInt aCount); sl@0: void ConstructL(TInt aNumOfRects); sl@0: TInt Count(TBool aMainTests); sl@0: private: sl@0: void doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize); sl@0: void createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize); sl@0: private: sl@0: CFbsBitmap *iMask[ENumMasks]; sl@0: CFbsBitmap *iBitmap; sl@0: // sl@0: CFbsBitmap *iScratch; sl@0: CFbsBitmapDevice *iScratchDevice; sl@0: CFbsBitGc *iScratchGc; sl@0: // sl@0: CFbsBitmap *iScratchMask; sl@0: CFbsBitmapDevice *iScratchMaskDevice; sl@0: CFbsBitGc *iScratchMaskGc; sl@0: // sl@0: TBool iInvertMask; sl@0: CFbsBitmap *iCurrMask; sl@0: CGraphicsContext::TDrawMode iDrawMode; sl@0: }; sl@0: sl@0: class CTGdi : public CTWsGraphicsBase sl@0: { sl@0: public: sl@0: CTGdi(CTestStep* aStep); sl@0: void ConstructL(); sl@0: TSize WinSize(); sl@0: void GdiTestL(CGdiTestLowLevel *aTest); sl@0: void TestDefetct_DEF045746L(); sl@0: void DrawTextOnWindow(const TDesC& aText,CTWin* aWin); sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: private: sl@0: void DoGdiTestL(const TRect &aRect, TInt aNum); sl@0: void NonDrawing(); sl@0: private: sl@0: TSize iWinSize; sl@0: TInt iSubState; sl@0: CGdiTestLowLevel *iGdiTest; sl@0: CTestWindow* iWin; sl@0: CFont* iFont; sl@0: TInt iTextOffsetX; sl@0: TInt iTextOffsetY; sl@0: TBool iTestPassing; sl@0: }; sl@0: sl@0: class CTGdiStep : public CTGraphicsStep sl@0: { sl@0: public: sl@0: CTGdiStep(); sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual CTGraphicsBase* CreateTestL(); sl@0: }; sl@0: sl@0: _LIT(KTGdiStep,"TGdi"); sl@0: sl@0: sl@0: #endif