1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TGDI.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,355 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#ifndef __TGDI_H__
1.26 +#define __TGDI_H__
1.27 +
1.28 +#include <e32std.h>
1.29 +#include <w32std.h>
1.30 +#include "../tlib/testbase.h"
1.31 +#include <bitstd.h>
1.32 +#include "AUTO.H"
1.33 +#include "TGraphicsHarness.h"
1.34 +
1.35 +class CGdiTestLowLevel;
1.36 +
1.37 +CGdiTestLowLevel *SetOriginTest();
1.38 +CGdiTestLowLevel *PolyLineTest();
1.39 +CGdiTestLowLevel *PolygonTest();
1.40 +CGdiTestLowLevel *BlitMaskedTest();
1.41 +CGdiTestLowLevel *DrawArcTest();
1.42 +CGdiTestLowLevel *DrawPieTest();
1.43 +CGdiTestLowLevel *DrawRoundRectTest();
1.44 +CGdiTestLowLevel *BoxTextTest();
1.45 +CGdiTestLowLevel *VertTextTest();
1.46 +CGdiTestLowLevel *JustifiedTextTest();
1.47 +CGdiTestLowLevel *VertBoxTextTest();
1.48 +CGdiTestLowLevel *WideLineTest();
1.49 +CGdiTestLowLevel *DrawTextTest();
1.50 +CGdiTestLowLevel *DrawRectTest();
1.51 +
1.52 +class CTGdi;
1.53 +class CGdiTestLowLevel : public CBase
1.54 +//
1.55 +// BaseTest uses code that is assumed to be good to draw to one window
1.56 +// TheTest uses the code beng tested to draw a matching pattern
1.57 +//
1.58 + {
1.59 +public:
1.60 + void AssignGdi(CWindowGc *aGc);
1.61 + void SetGdiTest(CTGdi *aGdiTest);
1.62 + virtual void PreTestSetupL(const TRect &aRect, TInt aCount);
1.63 + virtual void BaseTest(const TRect &aRect, TInt aCount)=0;
1.64 + virtual void TheTest(const TRect &aRect, TInt aCount)=0;
1.65 + virtual void ConstructL(TInt aNumOfRects);
1.66 + virtual TInt Count(TBool aMainTests)=0;
1.67 +protected:
1.68 + CWindowGc *iGdi;
1.69 + CTGdi *iGdiTest;
1.70 + };
1.71 +
1.72 +class CGdiRect : public CGdiTestLowLevel
1.73 + {
1.74 +public:
1.75 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.76 + void ConstructL(TInt aNumOfRects);
1.77 + TInt Count(TBool aMainTests);
1.78 +protected:
1.79 + TRgb iBrushCol;
1.80 + TRgb iPenCol;
1.81 + };
1.82 +
1.83 +
1.84 +class CGdiDrawRect : public CGdiRect
1.85 + {
1.86 +public:
1.87 + TInt Count(TBool aMainTests);
1.88 + void BaseTest(const TRect &aRect, TInt aCount);
1.89 + void TheTest(const TRect &aRect, TInt aCount);
1.90 + };
1.91 +
1.92 +class CGdiDrawRoundRect : public CGdiRect
1.93 + {
1.94 +public:
1.95 + TInt Count(TBool aMainTests);
1.96 + void BaseTest(const TRect &aRect, TInt aCount);
1.97 + void TheTest(const TRect &aRect, TInt aCount);
1.98 + };
1.99 +
1.100 +class CGdiDrawACP : public CGdiTestLowLevel
1.101 + {
1.102 +public:
1.103 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.104 + void ConstructL(TInt aNumOfRects);
1.105 + TInt Count(TBool aMainTests);
1.106 +protected:
1.107 + TRgb iBrushCol;
1.108 + TRgb iPenCol;
1.109 + };
1.110 +
1.111 +class CGdiDrawArc : public CGdiDrawACP
1.112 + {
1.113 +public:
1.114 + void BaseTest(const TRect &aRect, TInt aCount);
1.115 + void TheTest(const TRect &aRect, TInt aCount);
1.116 + };
1.117 +
1.118 +class CGdiDrawPie : public CGdiDrawACP
1.119 + {
1.120 +public:
1.121 + void BaseTest(const TRect &aRect, TInt aCount);
1.122 + void TheTest(const TRect &aRect, TInt aCount);
1.123 + };
1.124 +
1.125 +class CGdiPolyLine : public CGdiTestLowLevel
1.126 + {
1.127 +public:
1.128 + CGdiPolyLine();
1.129 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.130 + void ConstructL(TInt aNumOfRects);
1.131 + TInt Count(TBool aMainTests);
1.132 + void BaseTest(const TRect &aRect, TInt aCount);
1.133 + void TheTest(const TRect &aRect, TInt aCount);
1.134 +private:
1.135 + CArrayFixSeg<TPoint> iPnts;
1.136 + };
1.137 +
1.138 +class CGdiPolygon : public CGdiTestLowLevel
1.139 + {
1.140 +private:
1.141 + enum {KMaxPolygonPoints=100};
1.142 + enum {KPolygonStep=4};
1.143 +public:
1.144 + CGdiPolygon();
1.145 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.146 + void ConstructL(TInt aNumOfRects);
1.147 + TInt Count(TBool aMainTests);
1.148 + void BaseTest(const TRect &aRect, TInt aCount);
1.149 + void TheTest(const TRect &aRect, TInt aCount);
1.150 +private:
1.151 + CArrayFixSeg<TPoint> iPnts;
1.152 + };
1.153 +
1.154 +class CGdiWideLine : public CGdiTestLowLevel
1.155 + {
1.156 +private:
1.157 + enum TMaxWidths {
1.158 + EMainNumWidths=16,
1.159 + EMinorNumWidths=4};
1.160 +public:
1.161 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.162 + void BaseTest(const TRect &aRect, TInt aCount);
1.163 + void TheTest(const TRect &aRect, TInt aCount);
1.164 + void ConstructL(TInt aNumOfRects);
1.165 + TInt Count(TBool aMainTests);
1.166 +private:
1.167 + TInt iWidth;
1.168 + };
1.169 +
1.170 +class CGdiSetOrigin : public CGdiTestLowLevel
1.171 + {
1.172 +public:
1.173 + ~CGdiSetOrigin();
1.174 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.175 + void DrawIt(const TPoint &aOffset);
1.176 + void BaseTest(const TRect &aRect, TInt aCount);
1.177 + void TheTest(const TRect &aRect, TInt aCount);
1.178 + void ConstructL(TInt aNumOfRects);
1.179 + TInt Count(TBool aMainTests);
1.180 +private:
1.181 + CFbsFont *iFont;
1.182 + CArrayFixFlat<TPoint> *iPolylineArray;
1.183 + CArrayFixFlat<TPoint> *iPolygonArray;
1.184 + };
1.185 +
1.186 +class CGdiDrawText : public CGdiTestLowLevel
1.187 + {
1.188 +public:
1.189 + ~CGdiDrawText();
1.190 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.191 + void BaseTest(const TRect &aRect, TInt aCount);
1.192 + void TheTest(const TRect &aRect, TInt aCount);
1.193 + void ConstructL(TInt aNumOfRects);
1.194 + TInt Count(TBool aMainTests);
1.195 +private:
1.196 + TInt iWidth;
1.197 + CFbsFont *iFont;
1.198 + TBuf<0x400> iBigBuffer;
1.199 + };
1.200 +
1.201 +class CGdiDrawVertText : public CGdiTestLowLevel
1.202 + {
1.203 +public:
1.204 + ~CGdiDrawVertText();
1.205 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.206 + void BaseTest(const TRect &aRect, TInt aCount);
1.207 + void TheTest(const TRect &aRect, TInt aCount);
1.208 + void ConstructL(TInt aNumOfRects);
1.209 + TInt Count(TBool aMainTests);
1.210 +private:
1.211 + TInt iWidth;
1.212 + CFbsFont *iFont;
1.213 + TBuf<0x400> iBigBuffer;
1.214 + };
1.215 +
1.216 +//class CGdiDrawJustifiedText : public CGdiTestLowLevel
1.217 +//DEF107985 The test for JustifiedText has been removed as it was a bad/useless test
1.218 +
1.219 +class CGdiBoxText : public CGdiTestLowLevel
1.220 + {
1.221 +public:
1.222 + ~CGdiBoxText();
1.223 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.224 + void BaseTest(const TRect &aRect, TInt aCount);
1.225 + void TheTest(const TRect &aRect, TInt aCount);
1.226 + void ConstructL(TInt aNumOfRects);
1.227 + TInt Count(TBool aMainTests);
1.228 +private:
1.229 + TInt iWidth;
1.230 + TInt iBbLen;
1.231 + CFbsFont *iFont;
1.232 + TBuf<0x400> iBigBuffer;
1.233 + };
1.234 +
1.235 +class CGdiVertBoxText : public CGdiTestLowLevel
1.236 + {
1.237 +public:
1.238 + ~CGdiVertBoxText();
1.239 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.240 + void BaseTest(const TRect &aRect, TInt aCount);
1.241 + void TheTest(const TRect &aRect, TInt aCount);
1.242 + void ConstructL(TInt aNumOfRects);
1.243 + TInt Count(TBool aMainTests);
1.244 +private:
1.245 + TInt iWidth;
1.246 + TInt iBbLen;
1.247 + CFbsFont *iFont;
1.248 + TBuf<0x400> iBigBuffer;
1.249 + };
1.250 +/*
1.251 +class CGdiDottedLine : public CGdiTestLowLevel
1.252 + {
1.253 + enum TMaxPatterns {
1.254 + EMainMaxPatterns=5,
1.255 + EMinorMaxPatterns=3};
1.256 +public:
1.257 + void SetGridRegion(TRegion &grid,const TRect &aRect);
1.258 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.259 + void BaseTest(const TRect &aRect, TInt aCount);
1.260 + void TheTest(const TRect &aRect, TInt aCount);
1.261 + void ConstructL(TInt aNumOfRects);
1.262 + TInt Count(TBool aMainTests);
1.263 +private:
1.264 + TUint iPattern;
1.265 + TInt iPattLen;
1.266 + static TUint iPatterns[EMainMaxPatterns];
1.267 + static TInt iPattLens[EMainMaxPatterns];
1.268 + };
1.269 +TUint CGdiDottedLine::iPatterns[]={
1.270 + 0x55FF0033,
1.271 + 0xFF00,
1.272 + 0x1,
1.273 + 0xFFFF,
1.274 + 0xF0F0F0};
1.275 +TInt CGdiDottedLine::iPattLens[]={
1.276 + 32,
1.277 + 16,
1.278 + 2,
1.279 + 32,
1.280 + 24};
1.281 +*/
1.282 +class CTestWindow : public CBlankWindow
1.283 + {
1.284 +public:
1.285 + CTestWindow(TRgb aCol);
1.286 + ~CTestWindow();
1.287 + void ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc );
1.288 + };
1.289 +
1.290 +class CGdiBlitMasked: public CGdiTestLowLevel
1.291 + {
1.292 + enum TNumMasks {ENumMasks=2};
1.293 +public:
1.294 + ~CGdiBlitMasked();
1.295 + void PreTestSetupL(const TRect &aRect, TInt aCount);
1.296 + void BaseTest(const TRect &aRect, TInt aCount);
1.297 + void TheTest(const TRect &aRect, TInt aCount);
1.298 + void ConstructL(TInt aNumOfRects);
1.299 + TInt Count(TBool aMainTests);
1.300 +private:
1.301 + void doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize);
1.302 + void createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize);
1.303 +private:
1.304 + CFbsBitmap *iMask[ENumMasks];
1.305 + CFbsBitmap *iBitmap;
1.306 +//
1.307 + CFbsBitmap *iScratch;
1.308 + CFbsBitmapDevice *iScratchDevice;
1.309 + CFbsBitGc *iScratchGc;
1.310 +//
1.311 + CFbsBitmap *iScratchMask;
1.312 + CFbsBitmapDevice *iScratchMaskDevice;
1.313 + CFbsBitGc *iScratchMaskGc;
1.314 +//
1.315 + TBool iInvertMask;
1.316 + CFbsBitmap *iCurrMask;
1.317 + CGraphicsContext::TDrawMode iDrawMode;
1.318 + };
1.319 +
1.320 +class CTGdi : public CTWsGraphicsBase
1.321 + {
1.322 +public:
1.323 + CTGdi(CTestStep* aStep);
1.324 + void ConstructL();
1.325 + TSize WinSize();
1.326 + void GdiTestL(CGdiTestLowLevel *aTest);
1.327 + void TestDefetct_DEF045746L();
1.328 + void DrawTextOnWindow(const TDesC& aText,CTWin* aWin);
1.329 +protected:
1.330 +//from CTGraphicsStep
1.331 + virtual void RunTestCaseL(TInt aCurTestCase);
1.332 +private:
1.333 + void DoGdiTestL(const TRect &aRect, TInt aNum);
1.334 + void NonDrawing();
1.335 +private:
1.336 + TSize iWinSize;
1.337 + TInt iSubState;
1.338 + CGdiTestLowLevel *iGdiTest;
1.339 + CTestWindow* iWin;
1.340 + CFont* iFont;
1.341 + TInt iTextOffsetX;
1.342 + TInt iTextOffsetY;
1.343 + TBool iTestPassing;
1.344 + };
1.345 +
1.346 +class CTGdiStep : public CTGraphicsStep
1.347 + {
1.348 +public:
1.349 + CTGdiStep();
1.350 +protected:
1.351 + //from CTGraphicsStep
1.352 + virtual CTGraphicsBase* CreateTestL();
1.353 + };
1.354 +
1.355 +_LIT(KTGdiStep,"TGdi");
1.356 +
1.357 +
1.358 +#endif