os/graphics/windowing/windowserver/test/tauto/TGDI.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code
sl@0
    20
*/
sl@0
    21
sl@0
    22
#ifndef __TGDI_H__
sl@0
    23
#define __TGDI_H__
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <w32std.h>
sl@0
    27
#include "../tlib/testbase.h"
sl@0
    28
#include <bitstd.h>
sl@0
    29
#include "AUTO.H"
sl@0
    30
#include "TGraphicsHarness.h"
sl@0
    31
sl@0
    32
class CGdiTestLowLevel;
sl@0
    33
sl@0
    34
CGdiTestLowLevel *SetOriginTest();
sl@0
    35
CGdiTestLowLevel *PolyLineTest();
sl@0
    36
CGdiTestLowLevel *PolygonTest();
sl@0
    37
CGdiTestLowLevel *BlitMaskedTest();
sl@0
    38
CGdiTestLowLevel *DrawArcTest();
sl@0
    39
CGdiTestLowLevel *DrawPieTest();
sl@0
    40
CGdiTestLowLevel *DrawRoundRectTest();
sl@0
    41
CGdiTestLowLevel *BoxTextTest();
sl@0
    42
CGdiTestLowLevel *VertTextTest();
sl@0
    43
CGdiTestLowLevel *JustifiedTextTest();
sl@0
    44
CGdiTestLowLevel *VertBoxTextTest();
sl@0
    45
CGdiTestLowLevel *WideLineTest();
sl@0
    46
CGdiTestLowLevel *DrawTextTest();
sl@0
    47
CGdiTestLowLevel *DrawRectTest();
sl@0
    48
sl@0
    49
class CTGdi;
sl@0
    50
class CGdiTestLowLevel : public CBase
sl@0
    51
//
sl@0
    52
// BaseTest uses code that is assumed to be good to draw to one window
sl@0
    53
// TheTest uses the code beng tested to draw a matching pattern
sl@0
    54
//
sl@0
    55
	{
sl@0
    56
public:
sl@0
    57
	void AssignGdi(CWindowGc *aGc);
sl@0
    58
	void SetGdiTest(CTGdi *aGdiTest);
sl@0
    59
	virtual void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
    60
	virtual void BaseTest(const TRect &aRect, TInt aCount)=0;
sl@0
    61
	virtual void TheTest(const TRect &aRect, TInt aCount)=0;
sl@0
    62
	virtual void ConstructL(TInt aNumOfRects);
sl@0
    63
	virtual TInt Count(TBool aMainTests)=0;
sl@0
    64
protected:
sl@0
    65
	CWindowGc *iGdi;
sl@0
    66
	CTGdi *iGdiTest;
sl@0
    67
	};
sl@0
    68
sl@0
    69
class CGdiRect : public CGdiTestLowLevel
sl@0
    70
	{
sl@0
    71
public:
sl@0
    72
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
    73
	void ConstructL(TInt aNumOfRects);
sl@0
    74
	TInt Count(TBool aMainTests);
sl@0
    75
protected:
sl@0
    76
	TRgb iBrushCol;
sl@0
    77
	TRgb iPenCol;
sl@0
    78
	};
sl@0
    79
sl@0
    80
sl@0
    81
class CGdiDrawRect : public CGdiRect
sl@0
    82
	{
sl@0
    83
public:
sl@0
    84
	TInt Count(TBool aMainTests);
sl@0
    85
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
    86
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
    87
	};
sl@0
    88
sl@0
    89
class CGdiDrawRoundRect : public CGdiRect
sl@0
    90
	{
sl@0
    91
public:
sl@0
    92
	TInt Count(TBool aMainTests);
sl@0
    93
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
    94
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
    95
	};
sl@0
    96
sl@0
    97
class CGdiDrawACP : public CGdiTestLowLevel
sl@0
    98
	{
sl@0
    99
public:
sl@0
   100
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   101
	void ConstructL(TInt aNumOfRects);
sl@0
   102
	TInt Count(TBool aMainTests);
sl@0
   103
protected:
sl@0
   104
	TRgb iBrushCol;
sl@0
   105
	TRgb iPenCol;
sl@0
   106
	};
sl@0
   107
sl@0
   108
class CGdiDrawArc : public CGdiDrawACP
sl@0
   109
	{
sl@0
   110
public:
sl@0
   111
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   112
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   113
	};
sl@0
   114
sl@0
   115
class CGdiDrawPie : public CGdiDrawACP
sl@0
   116
	{
sl@0
   117
public:
sl@0
   118
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   119
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   120
	};
sl@0
   121
sl@0
   122
class CGdiPolyLine : public CGdiTestLowLevel
sl@0
   123
	{
sl@0
   124
public:
sl@0
   125
	CGdiPolyLine();
sl@0
   126
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   127
	void ConstructL(TInt aNumOfRects);
sl@0
   128
	TInt Count(TBool aMainTests);
sl@0
   129
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   130
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   131
private:
sl@0
   132
	CArrayFixSeg<TPoint> iPnts;
sl@0
   133
	};
sl@0
   134
sl@0
   135
class CGdiPolygon : public CGdiTestLowLevel
sl@0
   136
	{
sl@0
   137
private:
sl@0
   138
	enum {KMaxPolygonPoints=100};
sl@0
   139
	enum {KPolygonStep=4};
sl@0
   140
public:
sl@0
   141
	CGdiPolygon();
sl@0
   142
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   143
	void ConstructL(TInt aNumOfRects);
sl@0
   144
	TInt Count(TBool aMainTests);
sl@0
   145
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   146
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   147
private:
sl@0
   148
	CArrayFixSeg<TPoint> iPnts;
sl@0
   149
	};
sl@0
   150
sl@0
   151
class CGdiWideLine : public CGdiTestLowLevel
sl@0
   152
	{
sl@0
   153
private:
sl@0
   154
	enum TMaxWidths {
sl@0
   155
		EMainNumWidths=16,
sl@0
   156
		EMinorNumWidths=4};
sl@0
   157
public:
sl@0
   158
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   159
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   160
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   161
	void ConstructL(TInt aNumOfRects);
sl@0
   162
	TInt Count(TBool aMainTests);
sl@0
   163
private:
sl@0
   164
	TInt iWidth;
sl@0
   165
	};
sl@0
   166
sl@0
   167
class CGdiSetOrigin : public CGdiTestLowLevel
sl@0
   168
	{
sl@0
   169
public:
sl@0
   170
	~CGdiSetOrigin();
sl@0
   171
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   172
	void DrawIt(const TPoint &aOffset);
sl@0
   173
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   174
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   175
	void ConstructL(TInt aNumOfRects);
sl@0
   176
	TInt Count(TBool aMainTests);
sl@0
   177
private:
sl@0
   178
	CFbsFont *iFont;
sl@0
   179
	CArrayFixFlat<TPoint> *iPolylineArray;
sl@0
   180
	CArrayFixFlat<TPoint> *iPolygonArray;
sl@0
   181
	};
sl@0
   182
sl@0
   183
class CGdiDrawText : public CGdiTestLowLevel
sl@0
   184
	{
sl@0
   185
public:
sl@0
   186
	~CGdiDrawText();
sl@0
   187
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   188
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   189
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   190
	void ConstructL(TInt aNumOfRects);
sl@0
   191
	TInt Count(TBool aMainTests);
sl@0
   192
private:
sl@0
   193
	TInt iWidth;
sl@0
   194
	CFbsFont *iFont;
sl@0
   195
	TBuf<0x400> iBigBuffer;
sl@0
   196
	};
sl@0
   197
sl@0
   198
class CGdiDrawVertText : public CGdiTestLowLevel
sl@0
   199
	{
sl@0
   200
public:
sl@0
   201
	~CGdiDrawVertText();
sl@0
   202
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   203
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   204
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   205
	void ConstructL(TInt aNumOfRects);
sl@0
   206
	TInt Count(TBool aMainTests);
sl@0
   207
private:
sl@0
   208
	TInt iWidth;
sl@0
   209
	CFbsFont *iFont;
sl@0
   210
	TBuf<0x400> iBigBuffer;
sl@0
   211
	};
sl@0
   212
sl@0
   213
//class CGdiDrawJustifiedText : public CGdiTestLowLevel
sl@0
   214
//DEF107985 The test for JustifiedText has been removed as it was a bad/useless test
sl@0
   215
sl@0
   216
class CGdiBoxText : public CGdiTestLowLevel
sl@0
   217
	{
sl@0
   218
public:
sl@0
   219
	~CGdiBoxText();
sl@0
   220
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   221
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   222
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   223
	void ConstructL(TInt aNumOfRects);
sl@0
   224
	TInt Count(TBool aMainTests);
sl@0
   225
private:
sl@0
   226
	TInt iWidth;
sl@0
   227
	TInt iBbLen;
sl@0
   228
	CFbsFont *iFont;
sl@0
   229
	TBuf<0x400> iBigBuffer;
sl@0
   230
	};
sl@0
   231
sl@0
   232
class CGdiVertBoxText : public CGdiTestLowLevel
sl@0
   233
	{
sl@0
   234
public:
sl@0
   235
	~CGdiVertBoxText();
sl@0
   236
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   237
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   238
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   239
	void ConstructL(TInt aNumOfRects);
sl@0
   240
	TInt Count(TBool aMainTests);
sl@0
   241
private:
sl@0
   242
	TInt iWidth;
sl@0
   243
	TInt iBbLen;
sl@0
   244
	CFbsFont *iFont;
sl@0
   245
	TBuf<0x400> iBigBuffer;
sl@0
   246
	};
sl@0
   247
/*
sl@0
   248
class CGdiDottedLine : public CGdiTestLowLevel
sl@0
   249
	{
sl@0
   250
	enum TMaxPatterns {
sl@0
   251
		EMainMaxPatterns=5,
sl@0
   252
		EMinorMaxPatterns=3};
sl@0
   253
public:
sl@0
   254
	void SetGridRegion(TRegion &grid,const TRect &aRect);
sl@0
   255
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   256
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   257
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   258
	void ConstructL(TInt aNumOfRects);
sl@0
   259
	TInt Count(TBool aMainTests);
sl@0
   260
private:
sl@0
   261
	TUint iPattern;
sl@0
   262
	TInt iPattLen;
sl@0
   263
	static TUint iPatterns[EMainMaxPatterns];
sl@0
   264
	static TInt iPattLens[EMainMaxPatterns];
sl@0
   265
	};
sl@0
   266
TUint CGdiDottedLine::iPatterns[]={
sl@0
   267
		0x55FF0033,
sl@0
   268
		0xFF00,
sl@0
   269
		0x1,
sl@0
   270
		0xFFFF,
sl@0
   271
		0xF0F0F0};
sl@0
   272
TInt CGdiDottedLine::iPattLens[]={
sl@0
   273
		32,
sl@0
   274
		16,
sl@0
   275
		2,
sl@0
   276
		32,
sl@0
   277
		24};
sl@0
   278
*/
sl@0
   279
class CTestWindow : public CBlankWindow
sl@0
   280
	{
sl@0
   281
public:
sl@0
   282
	CTestWindow(TRgb aCol);
sl@0
   283
	~CTestWindow();
sl@0
   284
	void ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc );
sl@0
   285
	};
sl@0
   286
sl@0
   287
class CGdiBlitMasked: public CGdiTestLowLevel
sl@0
   288
	{
sl@0
   289
	enum TNumMasks {ENumMasks=2};
sl@0
   290
public:
sl@0
   291
	~CGdiBlitMasked();
sl@0
   292
	void PreTestSetupL(const TRect &aRect, TInt aCount);
sl@0
   293
	void BaseTest(const TRect &aRect, TInt aCount);
sl@0
   294
	void TheTest(const TRect &aRect, TInt aCount);
sl@0
   295
	void ConstructL(TInt aNumOfRects);
sl@0
   296
	TInt Count(TBool aMainTests);
sl@0
   297
private:
sl@0
   298
	void doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize);
sl@0
   299
	void createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize);
sl@0
   300
private:
sl@0
   301
	CFbsBitmap *iMask[ENumMasks];
sl@0
   302
	CFbsBitmap *iBitmap;
sl@0
   303
//
sl@0
   304
	CFbsBitmap *iScratch;
sl@0
   305
	CFbsBitmapDevice *iScratchDevice;
sl@0
   306
	CFbsBitGc *iScratchGc;
sl@0
   307
//
sl@0
   308
	CFbsBitmap *iScratchMask;
sl@0
   309
	CFbsBitmapDevice *iScratchMaskDevice;
sl@0
   310
	CFbsBitGc *iScratchMaskGc;
sl@0
   311
//
sl@0
   312
	TBool iInvertMask;
sl@0
   313
	CFbsBitmap *iCurrMask;
sl@0
   314
	CGraphicsContext::TDrawMode iDrawMode;
sl@0
   315
	};
sl@0
   316
sl@0
   317
class CTGdi : public CTWsGraphicsBase
sl@0
   318
	{
sl@0
   319
public:
sl@0
   320
	CTGdi(CTestStep* aStep);
sl@0
   321
	void ConstructL();
sl@0
   322
	TSize WinSize();
sl@0
   323
	void GdiTestL(CGdiTestLowLevel *aTest);
sl@0
   324
	void TestDefetct_DEF045746L();
sl@0
   325
	void DrawTextOnWindow(const TDesC& aText,CTWin* aWin);
sl@0
   326
protected:
sl@0
   327
//from 	CTGraphicsStep
sl@0
   328
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   329
private:
sl@0
   330
	void DoGdiTestL(const TRect &aRect, TInt aNum);
sl@0
   331
	void NonDrawing();
sl@0
   332
private:
sl@0
   333
	TSize iWinSize;
sl@0
   334
	TInt iSubState;
sl@0
   335
	CGdiTestLowLevel *iGdiTest;
sl@0
   336
	CTestWindow* iWin;
sl@0
   337
	CFont* iFont;
sl@0
   338
	TInt iTextOffsetX;
sl@0
   339
	TInt iTextOffsetY;
sl@0
   340
	TBool iTestPassing;
sl@0
   341
	};
sl@0
   342
	
sl@0
   343
class CTGdiStep : public CTGraphicsStep
sl@0
   344
	{
sl@0
   345
public:
sl@0
   346
	CTGdiStep();
sl@0
   347
protected:	
sl@0
   348
	//from CTGraphicsStep
sl@0
   349
	virtual CTGraphicsBase* CreateTestL();
sl@0
   350
	};
sl@0
   351
sl@0
   352
_LIT(KTGdiStep,"TGdi");
sl@0
   353
sl@0
   354
sl@0
   355
#endif