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 |
// GDI.CPP
|
sl@0
|
15 |
// Test GDI functions
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
@internalComponent - Internal Symbian test code
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "TGDI.H"
|
sl@0
|
26 |
|
sl@0
|
27 |
#define TAUTO_BITMAP_NAME _L("Z:\\WSTEST\\TAUTO.MBM")
|
sl@0
|
28 |
|
sl@0
|
29 |
//#define LOGGING on //Uncomment this line to get extra test logging - useful if debugging a failure of one of the tests
|
sl@0
|
30 |
|
sl@0
|
31 |
typedef CGdiTestLowLevel *(*GdiTestFunc)();
|
sl@0
|
32 |
|
sl@0
|
33 |
_LIT(KMonospaceTestFontTypefaceName,"Arial");
|
sl@0
|
34 |
const TInt KMaxFontSize = 200;
|
sl@0
|
35 |
|
sl@0
|
36 |
static inline TBool IsLengthEqual(TInt aLLen, TInt aRLen, TInt aBbLen)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
// 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
|
39 |
// are stuck together. So add a tolerance of -1.
|
sl@0
|
40 |
return (((aLLen+aRLen)==aBbLen) || ((aLLen+aRLen-1)==aBbLen));
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
struct GdiTest
|
sl@0
|
44 |
{
|
sl@0
|
45 |
GdiTestFunc func;
|
sl@0
|
46 |
const TText *txt;
|
sl@0
|
47 |
};
|
sl@0
|
48 |
|
sl@0
|
49 |
GdiTest GdiTestFuncs[]={
|
sl@0
|
50 |
{BoxTextTest,_S("BoxText")},
|
sl@0
|
51 |
{VertTextTest,_S("VertText")},
|
sl@0
|
52 |
/*{JustifiedTextTest,_S("JustifiedText")},*/ // DEF107985 The test for JustifiedText has been removed as it was a bad/useless test
|
sl@0
|
53 |
{VertBoxTextTest,_S("VertBoxText")},
|
sl@0
|
54 |
{SetOriginTest,_S("SetOrigin")},
|
sl@0
|
55 |
{PolyLineTest,_S("PolyLine")},
|
sl@0
|
56 |
{PolygonTest,_S("Polygon")},
|
sl@0
|
57 |
{DrawArcTest,_S("DrawArc")},
|
sl@0
|
58 |
{DrawPieTest,_S("DrawPie")},
|
sl@0
|
59 |
{DrawRoundRectTest,_S("DrawRoundRect")},
|
sl@0
|
60 |
{WideLineTest,_S("WideLine")},
|
sl@0
|
61 |
{DrawTextTest,_S("DrawText")},
|
sl@0
|
62 |
{DrawRectTest,_S("DrawRect")},
|
sl@0
|
63 |
};
|
sl@0
|
64 |
|
sl@0
|
65 |
CTestWindow::CTestWindow(TRgb aCol) : CBlankWindow(aCol)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
CTestWindow::~CTestWindow()
|
sl@0
|
70 |
{
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
void CTestWindow::ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
iWin=RWindow(TheClient->iWs);
|
sl@0
|
76 |
User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle));
|
sl@0
|
77 |
SetExt(aPos,aSize);
|
sl@0
|
78 |
Activate();
|
sl@0
|
79 |
AssignGC(aGc);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
void CGdiTestLowLevel::SetGdiTest(CTGdi *aGdiTest)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iGdiTest=aGdiTest;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
void CGdiTestLowLevel::AssignGdi(CWindowGc *aGc)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
iGdi=aGc;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
void CGdiTestLowLevel::ConstructL(TInt)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
void CGdiTestLowLevel::PreTestSetupL(const TRect &,TInt)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
//=======================================//
|
sl@0
|
101 |
// Individual GDI low level test classes //
|
sl@0
|
102 |
//=======================================//
|
sl@0
|
103 |
|
sl@0
|
104 |
|
sl@0
|
105 |
void CGdiRect::ConstructL(TInt)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
void CGdiRect::PreTestSetupL(const TRect &, TInt aCount)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
iBrushCol=TRgb::Gray256(aCount&0x1 ? 0xFF : 0x60);
|
sl@0
|
112 |
iPenCol=TRgb::Gray256(aCount&0x1 ? 0xA0 : 0x0);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
TInt CGdiRect::Count(TBool )
|
sl@0
|
116 |
{
|
sl@0
|
117 |
return(1);
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
void CGdiDrawRect::BaseTest(const TRect &aRect, TInt aCount)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TheTest(aRect,aCount);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
void CGdiDrawRect::TheTest(const TRect &aRect, TInt)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
iGdi->SetBrushColor(iBrushCol);
|
sl@0
|
128 |
iGdi->SetPenColor(iPenCol);
|
sl@0
|
129 |
iGdi->DrawRect(aRect);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
TInt CGdiDrawRect::Count(TBool aMode)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
return(aMode ? 4:1);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
TInt CGdiDrawRoundRect::Count(TBool aMode)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
return(aMode ? 4:1);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
void CGdiDrawRoundRect::BaseTest(const TRect &aRect, TInt aCount)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
TheTest(aRect,aCount);
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
void CGdiDrawRoundRect::TheTest(const TRect &aRect, TInt aCount)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
iGdi->SetBrushColor(iBrushCol);
|
sl@0
|
150 |
iGdi->SetPenColor(iPenCol);
|
sl@0
|
151 |
TSize size((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4);
|
sl@0
|
152 |
switch(aCount)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
case 0:
|
sl@0
|
155 |
size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4);
|
sl@0
|
156 |
break;
|
sl@0
|
157 |
case 1:
|
sl@0
|
158 |
size.SetSize(0,0);
|
sl@0
|
159 |
break;
|
sl@0
|
160 |
case 2:
|
sl@0
|
161 |
size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/2,(aRect.iBr.iY-aRect.iTl.iY)/2);
|
sl@0
|
162 |
break;
|
sl@0
|
163 |
case 3:
|
sl@0
|
164 |
size.SetSize((aRect.iBr.iX-aRect.iTl.iX),(aRect.iBr.iY-aRect.iTl.iY));
|
sl@0
|
165 |
break;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
iGdi->DrawRoundRect(aRect,size);
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
TInt CGdiDrawACP::Count(TBool )
|
sl@0
|
171 |
{
|
sl@0
|
172 |
return(1);
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
void CGdiDrawACP::ConstructL(TInt)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
void CGdiDrawACP::PreTestSetupL(const TRect &, TInt )
|
sl@0
|
180 |
{
|
sl@0
|
181 |
iBrushCol=TRgb::Gray256(0xff);
|
sl@0
|
182 |
iPenCol=TRgb(0,0,0);
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
void CGdiDrawArc::BaseTest(const TRect &aRect, TInt aCount)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
TheTest(aRect,aCount);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
void CGdiDrawArc::TheTest(const TRect &aRect, TInt)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
iGdi->SetBrushColor(iBrushCol);
|
sl@0
|
193 |
iGdi->SetPenColor(iPenCol);
|
sl@0
|
194 |
TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY);
|
sl@0
|
195 |
iGdi->DrawArc(aRect,start,TPoint(0,0));
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
void CGdiDrawPie::BaseTest(const TRect &aRect, TInt aCount)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
TheTest(aRect,aCount);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
|
sl@0
|
203 |
void CGdiDrawPie::TheTest(const TRect &aRect, TInt)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
iGdi->SetBrushColor(iBrushCol);
|
sl@0
|
206 |
iGdi->SetPenColor(iPenCol);
|
sl@0
|
207 |
TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY);
|
sl@0
|
208 |
iGdi->DrawPie(aRect,start,TPoint(0,0));
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
//
|
sl@0
|
212 |
// Polyline tests
|
sl@0
|
213 |
//
|
sl@0
|
214 |
|
sl@0
|
215 |
CGdiPolyLine::CGdiPolyLine() : iPnts(5)
|
sl@0
|
216 |
{}
|
sl@0
|
217 |
|
sl@0
|
218 |
void CGdiPolyLine::PreTestSetupL(const TRect &aRect, TInt aCount)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
iPnts.Reset();
|
sl@0
|
221 |
TInt wid=aRect.Width();
|
sl@0
|
222 |
TInt hgt=aRect.Height();
|
sl@0
|
223 |
if (aCount==0)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
TInt pos;
|
sl@0
|
226 |
for(pos=0;pos<wid;pos+=10)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
iPnts.AppendL(TPoint(aRect.iTl.iX+pos,aRect.iTl.iY));
|
sl@0
|
229 |
iPnts.AppendL(TPoint(aRect.iTl.iX+pos+5,aRect.iBr.iY));
|
sl@0
|
230 |
}
|
sl@0
|
231 |
for(pos=0;pos<hgt;pos+=10)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
iPnts.AppendL(TPoint(aRect.iTl.iX,aRect.iTl.iY+pos));
|
sl@0
|
234 |
iPnts.AppendL(TPoint(aRect.iBr.iX,aRect.iTl.iY+pos+5));
|
sl@0
|
235 |
}
|
sl@0
|
236 |
}
|
sl@0
|
237 |
else
|
sl@0
|
238 |
{
|
sl@0
|
239 |
TInt hgt=aRect.Height();
|
sl@0
|
240 |
iPnts.AppendL(TPoint(aRect.iTl.iX,aRect.iTl.iY));
|
sl@0
|
241 |
iPnts.AppendL(TPoint(aRect.iBr.iX,aRect.iTl.iY+hgt/2));
|
sl@0
|
242 |
iPnts.AppendL(TPoint(aRect.iTl.iX,aRect.iBr.iY));
|
sl@0
|
243 |
iPnts.AppendL(TPoint(aRect.iBr.iX,aRect.iBr.iY));
|
sl@0
|
244 |
iPnts.AppendL(TPoint(aRect.iTl.iX,aRect.iTl.iY+hgt/2));
|
sl@0
|
245 |
iPnts.AppendL(TPoint(aRect.iBr.iX,aRect.iTl.iY));
|
sl@0
|
246 |
iPnts.AppendL(TPoint(aRect.iTl.iX,aRect.iTl.iY));
|
sl@0
|
247 |
}
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
void CGdiPolyLine::ConstructL(TInt )
|
sl@0
|
251 |
{
|
sl@0
|
252 |
}
|
sl@0
|
253 |
|
sl@0
|
254 |
TInt CGdiPolyLine::Count(TBool aMainTests)
|
sl@0
|
255 |
{
|
sl@0
|
256 |
return(aMainTests ? 2 : 1);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
void CGdiPolyLine::BaseTest(const TRect &, TInt )
|
sl@0
|
260 |
{
|
sl@0
|
261 |
TPoint prev;
|
sl@0
|
262 |
TInt index;
|
sl@0
|
263 |
for(index=0;index<iPnts.Count();index++)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
if (index>0)
|
sl@0
|
266 |
iGdi->DrawLine(prev,iPnts[index]);
|
sl@0
|
267 |
prev=iPnts[index];
|
sl@0
|
268 |
}
|
sl@0
|
269 |
if (index>0)
|
sl@0
|
270 |
iGdi->Plot(iPnts[index-1]);
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
void CGdiPolyLine::TheTest(const TRect &, TInt )
|
sl@0
|
274 |
{
|
sl@0
|
275 |
iGdi->DrawPolyLine(&iPnts);
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
//
|
sl@0
|
279 |
// Polygon tests //
|
sl@0
|
280 |
//
|
sl@0
|
281 |
|
sl@0
|
282 |
CGdiPolygon::CGdiPolygon() : iPnts(5)
|
sl@0
|
283 |
{}
|
sl@0
|
284 |
|
sl@0
|
285 |
void CGdiPolygon::PreTestSetupL(const TRect &aRect, TInt )
|
sl@0
|
286 |
{
|
sl@0
|
287 |
iPnts.Reset();
|
sl@0
|
288 |
TPoint pnt;
|
sl@0
|
289 |
TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep);
|
sl@0
|
290 |
TInt numPoints=0;
|
sl@0
|
291 |
if (maxPoints>0)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
iPnts.AppendL(aRect.iTl);
|
sl@0
|
294 |
while(numPoints<maxPoints)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
if (numPoints&1)
|
sl@0
|
297 |
pnt.SetXY(aRect.iTl.iX+(numPoints+1)*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep);
|
sl@0
|
298 |
else
|
sl@0
|
299 |
pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+(numPoints+1)*KPolygonStep);
|
sl@0
|
300 |
iPnts.AppendL(pnt);
|
sl@0
|
301 |
numPoints++;
|
sl@0
|
302 |
}
|
sl@0
|
303 |
pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep);
|
sl@0
|
304 |
iPnts.AppendL(pnt);
|
sl@0
|
305 |
while(numPoints>0)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
numPoints--;
|
sl@0
|
308 |
if (numPoints&1)
|
sl@0
|
309 |
pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+(numPoints+1)*KPolygonStep);
|
sl@0
|
310 |
else
|
sl@0
|
311 |
pnt.SetXY(aRect.iTl.iX+(numPoints+1)*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep);
|
sl@0
|
312 |
iPnts.AppendL(pnt);
|
sl@0
|
313 |
}
|
sl@0
|
314 |
}
|
sl@0
|
315 |
}
|
sl@0
|
316 |
|
sl@0
|
317 |
void CGdiPolygon::ConstructL(TInt )
|
sl@0
|
318 |
{
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
TInt CGdiPolygon::Count(TBool aMainTests)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
return(aMainTests ? 2 : 1);
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
void CGdiPolygon::BaseTest(const TRect &aRect, TInt )
|
sl@0
|
327 |
{
|
sl@0
|
328 |
iGdi->SetPenColor(TRgb::Gray4(2));
|
sl@0
|
329 |
iGdi->SetBrushColor(TRgb::Gray4(1));
|
sl@0
|
330 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
331 |
TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep);
|
sl@0
|
332 |
for(TInt numPoints=0;numPoints<maxPoints;numPoints++)
|
sl@0
|
333 |
iGdi->DrawRect(TRect(aRect.iTl.iX+numPoints*KPolygonStep + 1,aRect.iTl.iY+numPoints*KPolygonStep + 1,
|
sl@0
|
334 |
aRect.iTl.iX+(numPoints+1)*KPolygonStep ,aRect.iTl.iY+(numPoints+1)*KPolygonStep));
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
void CGdiPolygon::TheTest(const TRect &, TInt )
|
sl@0
|
338 |
//This is the only one that can leave so it's not worth adding an 'L'
|
sl@0
|
339 |
{
|
sl@0
|
340 |
iGdi->SetPenColor(TRgb::Gray4(2));
|
sl@0
|
341 |
iGdi->SetBrushColor(TRgb::Gray4(1));
|
sl@0
|
342 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
343 |
User::LeaveIfError(iGdi->DrawPolygon(&iPnts,CGraphicsContext::EAlternate));
|
sl@0
|
344 |
}
|
sl@0
|
345 |
|
sl@0
|
346 |
//
|
sl@0
|
347 |
|
sl@0
|
348 |
TInt CGdiWideLine::Count(TBool aMainTests)
|
sl@0
|
349 |
{
|
sl@0
|
350 |
return(aMainTests ? EMainNumWidths : EMinorNumWidths);
|
sl@0
|
351 |
}
|
sl@0
|
352 |
|
sl@0
|
353 |
void CGdiWideLine::ConstructL(TInt)
|
sl@0
|
354 |
{
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
void CGdiWideLine::PreTestSetupL(const TRect &, TInt aCount)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
TInt widths[]={1,4,50,-2,
|
sl@0
|
360 |
48,12345,0,3,
|
sl@0
|
361 |
48,123,0,3,
|
sl@0
|
362 |
4,111,555,1000,
|
sl@0
|
363 |
10,-1,-10,-100};
|
sl@0
|
364 |
iWidth=widths[aCount];
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
void CGdiWideLine::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
iGdi->SetPenSize(TSize(iWidth,iWidth));
|
sl@0
|
370 |
iGdi->DrawLine(aRect.iTl,aRect.iBr);
|
sl@0
|
371 |
iGdi->MoveTo(aRect.iTl+TPoint(0,10));
|
sl@0
|
372 |
iGdi->DrawLineBy(aRect.iBr-aRect.iTl);
|
sl@0
|
373 |
iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10));
|
sl@0
|
374 |
iGdi->DrawLineTo(aRect.iBr+TPoint(0,20));
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
void CGdiWideLine::TheTest(const TRect &aRect, TInt)
|
sl@0
|
378 |
{
|
sl@0
|
379 |
iGdi->SetPenSize(TSize(iWidth,iWidth));
|
sl@0
|
380 |
iGdi->MoveTo(aRect.iTl);
|
sl@0
|
381 |
iGdi->DrawLineBy(aRect.iBr-aRect.iTl);
|
sl@0
|
382 |
iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10));
|
sl@0
|
383 |
iGdi->DrawLineTo(aRect.iBr+TPoint(0,10));
|
sl@0
|
384 |
iGdi->DrawLine(aRect.iTl+TPoint(0,20),aRect.iBr+TPoint(0,20));
|
sl@0
|
385 |
}
|
sl@0
|
386 |
|
sl@0
|
387 |
//
|
sl@0
|
388 |
// Set Origin //
|
sl@0
|
389 |
//
|
sl@0
|
390 |
|
sl@0
|
391 |
CGdiSetOrigin::~CGdiSetOrigin()
|
sl@0
|
392 |
{
|
sl@0
|
393 |
delete iPolylineArray;
|
sl@0
|
394 |
delete iPolygonArray;
|
sl@0
|
395 |
TheClient->iScreen->ReleaseFont(iFont);
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
TInt CGdiSetOrigin::Count(TBool )
|
sl@0
|
399 |
{
|
sl@0
|
400 |
return(1);
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
void CGdiSetOrigin::ConstructL(TInt)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
iPolylineArray=new(ELeave) CArrayFixFlat<TPoint>(3);
|
sl@0
|
406 |
iPolylineArray->AppendL(TPoint(40,1));
|
sl@0
|
407 |
iPolylineArray->AppendL(TPoint(50,11));
|
sl@0
|
408 |
iPolylineArray->AppendL(TPoint(40,21));
|
sl@0
|
409 |
iPolygonArray=new(ELeave) CArrayFixFlat<TPoint>(3);
|
sl@0
|
410 |
iPolygonArray->AppendL(TPoint(40,30));
|
sl@0
|
411 |
iPolygonArray->AppendL(TPoint(50,40));
|
sl@0
|
412 |
iPolygonArray->AppendL(TPoint(40,45));
|
sl@0
|
413 |
TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
|
sl@0
|
414 |
User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec));
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
void CGdiSetOrigin::PreTestSetupL(const TRect &, TInt )
|
sl@0
|
418 |
{
|
sl@0
|
419 |
}
|
sl@0
|
420 |
|
sl@0
|
421 |
void CGdiSetOrigin::DrawIt(const TPoint &aOffset)
|
sl@0
|
422 |
{
|
sl@0
|
423 |
iGdi->DrawLine(TPoint(10,10)+aOffset,TPoint(20,30)+aOffset);
|
sl@0
|
424 |
iGdi->DrawLineBy(TPoint(-10,5));
|
sl@0
|
425 |
iGdi->DrawLineTo(TPoint(20,5)+aOffset);
|
sl@0
|
426 |
iGdi->MoveTo(TPoint(20,10)+aOffset);
|
sl@0
|
427 |
iGdi->DrawLineTo(TPoint(30,15)+aOffset);
|
sl@0
|
428 |
iGdi->MoveBy(TPoint(-10,2));
|
sl@0
|
429 |
iGdi->DrawLineBy(TPoint(10,0));
|
sl@0
|
430 |
iGdi->UseFont(iFont);
|
sl@0
|
431 |
iGdi->DrawText(_L("Set Origin Test"),TPoint(40,20)+aOffset);
|
sl@0
|
432 |
iGdi->DiscardFont();
|
sl@0
|
433 |
iGdi->DrawRect(TRect(TPoint(10,45)+aOffset,TPoint(20,55)+aOffset));
|
sl@0
|
434 |
iGdi->DrawRoundRect(TRect(TPoint(21,45)+aOffset,TPoint(30,55)+aOffset),TSize(3,2));
|
sl@0
|
435 |
iGdi->DrawEllipse(TRect(TPoint(31,45)+aOffset,TPoint(40,55)+aOffset));
|
sl@0
|
436 |
TInt index;
|
sl@0
|
437 |
for(index=0;index<iPolylineArray->Count();index++)
|
sl@0
|
438 |
(*iPolylineArray)[index]+=aOffset;
|
sl@0
|
439 |
iGdi->DrawPolyLine(iPolylineArray);
|
sl@0
|
440 |
for(index=0;index<iPolylineArray->Count();index++)
|
sl@0
|
441 |
(*iPolylineArray)[index]-=aOffset;
|
sl@0
|
442 |
for(index=0;index<iPolygonArray->Count();index++)
|
sl@0
|
443 |
(*iPolygonArray)[index]+=aOffset;
|
sl@0
|
444 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
445 |
User::LeaveIfError(iGdi->DrawPolygon(iPolygonArray,CGraphicsContext::EAlternate)); //Doesn't cause any harm if it leaves
|
sl@0
|
446 |
for(index=0;index<iPolygonArray->Count();index++)
|
sl@0
|
447 |
(*iPolygonArray)[index]-=aOffset;
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
void CGdiSetOrigin::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
DrawIt(aRect.iTl);
|
sl@0
|
453 |
}
|
sl@0
|
454 |
|
sl@0
|
455 |
void CGdiSetOrigin::TheTest(const TRect &aRect, TInt)
|
sl@0
|
456 |
{
|
sl@0
|
457 |
iGdi->SetOrigin(aRect.iTl);
|
sl@0
|
458 |
DrawIt(TPoint(0,0));
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
//
|
sl@0
|
462 |
// Draw text //
|
sl@0
|
463 |
//
|
sl@0
|
464 |
|
sl@0
|
465 |
CGdiDrawText::~CGdiDrawText()
|
sl@0
|
466 |
{
|
sl@0
|
467 |
TheClient->iScreen->ReleaseFont(iFont);
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
TInt CGdiDrawText::Count(TBool )
|
sl@0
|
471 |
{
|
sl@0
|
472 |
return(1);
|
sl@0
|
473 |
}
|
sl@0
|
474 |
|
sl@0
|
475 |
void CGdiDrawText::ConstructL(TInt)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
|
sl@0
|
478 |
User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec));
|
sl@0
|
479 |
TInt index;
|
sl@0
|
480 |
for(index=0;index<iBigBuffer.MaxLength();index++)
|
sl@0
|
481 |
iBigBuffer.Append(TChar((index%26)+'a'));
|
sl@0
|
482 |
const TInt characters=iBigBuffer.Length();
|
sl@0
|
483 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
484 |
for(index=0;index<iBigBuffer.MaxLength();index+=33)
|
sl@0
|
485 |
{
|
sl@0
|
486 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(index));
|
sl@0
|
487 |
TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(characters-index));
|
sl@0
|
488 |
TBool result = IsLengthEqual(lLen,rLen,bbLen);
|
sl@0
|
489 |
iGdiTest->TEST(result);
|
sl@0
|
490 |
if (!result)
|
sl@0
|
491 |
{
|
sl@0
|
492 |
_LIT(KLog,"Font width metrics error, Width(%dchars)=%d, Width(%dchars)=%d, Width(%dchars)=%d");
|
sl@0
|
493 |
iGdiTest->LOG_MESSAGE7(KLog,index,lLen,characters-index,rLen,characters,bbLen);
|
sl@0
|
494 |
}
|
sl@0
|
495 |
}
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
void CGdiDrawText::PreTestSetupL(const TRect&,TInt)
|
sl@0
|
499 |
{}
|
sl@0
|
500 |
|
sl@0
|
501 |
void CGdiDrawText::BaseTest(const TRect& aRect,TInt)
|
sl@0
|
502 |
{
|
sl@0
|
503 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
504 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
505 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
506 |
iGdi->UseFont(iFont);
|
sl@0
|
507 |
//
|
sl@0
|
508 |
iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent));
|
sl@0
|
509 |
TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iX)-1; // -1 so one off screen char is drawn to handle overhang
|
sl@0
|
510 |
if (missingChars>=0)
|
sl@0
|
511 |
{
|
sl@0
|
512 |
TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars);
|
sl@0
|
513 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars));
|
sl@0
|
514 |
TInt rLen=iFont->TextWidthInPixels(bbb);
|
sl@0
|
515 |
TBool result = IsLengthEqual(lLen,rLen,bbLen);
|
sl@0
|
516 |
iGdiTest->TEST(result);
|
sl@0
|
517 |
if (!result)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
_LIT(KLog,"Font width metrics error, missingChars=%d %d+%d=%d");
|
sl@0
|
520 |
iGdiTest->LOG_MESSAGE5(KLog,missingChars,lLen,rLen,bbLen);
|
sl@0
|
521 |
}
|
sl@0
|
522 |
iGdi->DrawText(bbb,TPoint(aRect.iBr.iX-rLen,aRect.iTl.iY+fAscent+fHeight));
|
sl@0
|
523 |
}
|
sl@0
|
524 |
iGdi->DiscardFont();
|
sl@0
|
525 |
}
|
sl@0
|
526 |
|
sl@0
|
527 |
void CGdiDrawText::TheTest(const TRect& aRect,TInt)
|
sl@0
|
528 |
{
|
sl@0
|
529 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
530 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
531 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
532 |
iGdi->UseFont(iFont);
|
sl@0
|
533 |
//
|
sl@0
|
534 |
iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent));
|
sl@0
|
535 |
iGdi->DrawText(iBigBuffer,TPoint(aRect.iBr.iX-bbLen,aRect.iTl.iY+fAscent+fHeight));
|
sl@0
|
536 |
iGdi->DiscardFont();
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
//
|
sl@0
|
540 |
// Draw vertical text //
|
sl@0
|
541 |
//
|
sl@0
|
542 |
|
sl@0
|
543 |
CGdiDrawVertText::~CGdiDrawVertText()
|
sl@0
|
544 |
{
|
sl@0
|
545 |
TheClient->iScreen->ReleaseFont(iFont);
|
sl@0
|
546 |
}
|
sl@0
|
547 |
|
sl@0
|
548 |
TInt CGdiDrawVertText::Count(TBool )
|
sl@0
|
549 |
{
|
sl@0
|
550 |
return(1);
|
sl@0
|
551 |
}
|
sl@0
|
552 |
|
sl@0
|
553 |
void CGdiDrawVertText::ConstructL(TInt)
|
sl@0
|
554 |
{
|
sl@0
|
555 |
TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
|
sl@0
|
556 |
User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec));
|
sl@0
|
557 |
TInt index;
|
sl@0
|
558 |
for(index=0;index<iBigBuffer.MaxLength();index++)
|
sl@0
|
559 |
iBigBuffer.Append(TChar((index%26)+'a'));
|
sl@0
|
560 |
//
|
sl@0
|
561 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
562 |
for(index=0;index<iBigBuffer.MaxLength();index+=33)
|
sl@0
|
563 |
{
|
sl@0
|
564 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(index));
|
sl@0
|
565 |
TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(iBigBuffer.Length()-index));
|
sl@0
|
566 |
TBool result = IsLengthEqual(lLen,rLen,bbLen);
|
sl@0
|
567 |
iGdiTest->TEST(result);
|
sl@0
|
568 |
if (!result)
|
sl@0
|
569 |
iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen);
|
sl@0
|
570 |
}
|
sl@0
|
571 |
}
|
sl@0
|
572 |
|
sl@0
|
573 |
void CGdiDrawVertText::PreTestSetupL(const TRect &, TInt )
|
sl@0
|
574 |
{
|
sl@0
|
575 |
}
|
sl@0
|
576 |
|
sl@0
|
577 |
void CGdiDrawVertText::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
578 |
{
|
sl@0
|
579 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
580 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
581 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
582 |
iGdi->UseFont(iFont);
|
sl@0
|
583 |
//
|
sl@0
|
584 |
TInt tlen=iFont->TextWidthInPixels(_L("Hello"));
|
sl@0
|
585 |
iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue);
|
sl@0
|
586 |
iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse);
|
sl@0
|
587 |
TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iY)-1; // -1 so one off screen char is drawn to handle overhang
|
sl@0
|
588 |
if (missingChars>=0)
|
sl@0
|
589 |
{
|
sl@0
|
590 |
TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars);
|
sl@0
|
591 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars));
|
sl@0
|
592 |
TInt rLen=iFont->TextWidthInPixels(bbb);
|
sl@0
|
593 |
TBool result = IsLengthEqual(lLen,rLen,bbLen);
|
sl@0
|
594 |
iGdiTest->TEST(result);
|
sl@0
|
595 |
if (!result)
|
sl@0
|
596 |
iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen);
|
sl@0
|
597 |
|
sl@0
|
598 |
iGdi->DrawTextVertical(bbb,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-rLen),EFalse);
|
sl@0
|
599 |
}
|
sl@0
|
600 |
iGdi->DiscardFont();
|
sl@0
|
601 |
}
|
sl@0
|
602 |
|
sl@0
|
603 |
void CGdiDrawVertText::TheTest(const TRect &aRect, TInt)
|
sl@0
|
604 |
{
|
sl@0
|
605 |
TInt bbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
606 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
607 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
608 |
iGdi->UseFont(iFont);
|
sl@0
|
609 |
//
|
sl@0
|
610 |
TInt tlen=iFont->TextWidthInPixels(_L("Hello"));
|
sl@0
|
611 |
iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue);
|
sl@0
|
612 |
iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse);
|
sl@0
|
613 |
iGdi->DrawTextVertical(iBigBuffer,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-bbLen),EFalse);
|
sl@0
|
614 |
iGdi->DiscardFont();
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
//
|
sl@0
|
618 |
// Draw Justified text //
|
sl@0
|
619 |
//
|
sl@0
|
620 |
|
sl@0
|
621 |
// DEF107985 The test for JustifiedText has been removed as it was a bad/useless test. The original test was
|
sl@0
|
622 |
// broken after it was migrated to TEF TGdi test. It was not worth fixing as the purpose of test was not clear,
|
sl@0
|
623 |
// and fixing it basically required rewriting the whole test.
|
sl@0
|
624 |
//
|
sl@0
|
625 |
|
sl@0
|
626 |
|
sl@0
|
627 |
//
|
sl@0
|
628 |
// Box text //
|
sl@0
|
629 |
//
|
sl@0
|
630 |
|
sl@0
|
631 |
CGdiBoxText::~CGdiBoxText()
|
sl@0
|
632 |
{
|
sl@0
|
633 |
TheClient->iScreen->ReleaseFont(iFont);
|
sl@0
|
634 |
}
|
sl@0
|
635 |
|
sl@0
|
636 |
TInt CGdiBoxText::Count(TBool )
|
sl@0
|
637 |
{
|
sl@0
|
638 |
return(1);
|
sl@0
|
639 |
}
|
sl@0
|
640 |
|
sl@0
|
641 |
void CGdiBoxText::ConstructL(TInt)
|
sl@0
|
642 |
{
|
sl@0
|
643 |
TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
|
sl@0
|
644 |
User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec));
|
sl@0
|
645 |
for(TInt index=0;index<iBigBuffer.MaxLength();index++)
|
sl@0
|
646 |
iBigBuffer.Append(TChar((index%26)+'a'));
|
sl@0
|
647 |
iBbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
648 |
}
|
sl@0
|
649 |
|
sl@0
|
650 |
void CGdiBoxText::PreTestSetupL(const TRect &, TInt )
|
sl@0
|
651 |
{
|
sl@0
|
652 |
}
|
sl@0
|
653 |
|
sl@0
|
654 |
void CGdiBoxText::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
655 |
{
|
sl@0
|
656 |
TInt rWid=aRect.iBr.iX-aRect.iTl.iX;
|
sl@0
|
657 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
658 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
659 |
iGdi->UseFont(iFont);
|
sl@0
|
660 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
661 |
//
|
sl@0
|
662 |
TRect rect(aRect);
|
sl@0
|
663 |
rect.iBr.iY=rect.iTl.iY+fHeight;
|
sl@0
|
664 |
//
|
sl@0
|
665 |
TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid);
|
sl@0
|
666 |
TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars);
|
sl@0
|
667 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars));
|
sl@0
|
668 |
TInt rLen=iFont->TextWidthInPixels(bbb);
|
sl@0
|
669 |
TBool result = IsLengthEqual(lLen,rLen,iBbLen);
|
sl@0
|
670 |
iGdiTest->TEST(result);
|
sl@0
|
671 |
if (!result)
|
sl@0
|
672 |
iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen);
|
sl@0
|
673 |
|
sl@0
|
674 |
iGdi->DrawText(bbb, rect, fAscent,CGraphicsContext::ELeft, rWid-rLen);
|
sl@0
|
675 |
//
|
sl@0
|
676 |
rect.Move(TPoint(0,fHeight));
|
sl@0
|
677 |
iGdi->DrawText(iBigBuffer, rect, fAscent,CGraphicsContext::ELeft, 0);
|
sl@0
|
678 |
//
|
sl@0
|
679 |
TBuf<10> buf2(_L("1234567890"));
|
sl@0
|
680 |
rect.Move(TPoint(0,fHeight));
|
sl@0
|
681 |
iGdi->DrawText(buf2,rect,fAscent,CGraphicsContext::ERight,rect.Width()-iFont->TextWidthInPixels(buf2));
|
sl@0
|
682 |
}
|
sl@0
|
683 |
|
sl@0
|
684 |
void CGdiBoxText::TheTest(const TRect &aRect, TInt)
|
sl@0
|
685 |
{
|
sl@0
|
686 |
TInt rWid=aRect.iBr.iX-aRect.iTl.iX;
|
sl@0
|
687 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
688 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
689 |
iGdi->UseFont(iFont);
|
sl@0
|
690 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
691 |
TRect rect(aRect);
|
sl@0
|
692 |
rect.iBr.iY=rect.iTl.iY+fHeight;
|
sl@0
|
693 |
//
|
sl@0
|
694 |
iGdi->DrawText(iBigBuffer, rect, fAscent, CGraphicsContext::ELeft, rWid-iBbLen);
|
sl@0
|
695 |
//
|
sl@0
|
696 |
rect.Move(TPoint(0,fHeight));
|
sl@0
|
697 |
iGdi->Clear(rect);
|
sl@0
|
698 |
iGdi->SetClippingRegion(TRegionFix<1>(rect));
|
sl@0
|
699 |
iGdi->DrawText(iBigBuffer, rect.iTl+TPoint(0,fAscent));
|
sl@0
|
700 |
TBuf<10> buf2(_L("1234567890"));
|
sl@0
|
701 |
rect.Move(TPoint(0,fHeight));
|
sl@0
|
702 |
iGdi->CancelClippingRegion();
|
sl@0
|
703 |
iGdi->DrawText(buf2,rect,fAscent);
|
sl@0
|
704 |
}
|
sl@0
|
705 |
|
sl@0
|
706 |
//
|
sl@0
|
707 |
// Vert Box text //
|
sl@0
|
708 |
//
|
sl@0
|
709 |
|
sl@0
|
710 |
CGdiVertBoxText::~CGdiVertBoxText()
|
sl@0
|
711 |
{
|
sl@0
|
712 |
TheClient->iScreen->ReleaseFont(iFont);
|
sl@0
|
713 |
}
|
sl@0
|
714 |
|
sl@0
|
715 |
TInt CGdiVertBoxText::Count(TBool )
|
sl@0
|
716 |
{
|
sl@0
|
717 |
return(1);
|
sl@0
|
718 |
}
|
sl@0
|
719 |
|
sl@0
|
720 |
void CGdiVertBoxText::ConstructL(TInt)
|
sl@0
|
721 |
{
|
sl@0
|
722 |
TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
|
sl@0
|
723 |
User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec));
|
sl@0
|
724 |
for(TInt index=0;index<iBigBuffer.MaxLength();index++)
|
sl@0
|
725 |
iBigBuffer.Append(TChar((index%26)+'a'));
|
sl@0
|
726 |
iBbLen=iFont->TextWidthInPixels(iBigBuffer);
|
sl@0
|
727 |
}
|
sl@0
|
728 |
|
sl@0
|
729 |
void CGdiVertBoxText::PreTestSetupL(const TRect &, TInt )
|
sl@0
|
730 |
{
|
sl@0
|
731 |
}
|
sl@0
|
732 |
|
sl@0
|
733 |
void CGdiVertBoxText::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
734 |
{
|
sl@0
|
735 |
TInt rWid=aRect.iBr.iY-aRect.iTl.iY;
|
sl@0
|
736 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
737 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
738 |
iGdi->UseFont(iFont);
|
sl@0
|
739 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
740 |
//
|
sl@0
|
741 |
TRect rect(aRect);
|
sl@0
|
742 |
rect.iBr.iX=rect.iTl.iX+fHeight;
|
sl@0
|
743 |
//
|
sl@0
|
744 |
TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid);
|
sl@0
|
745 |
TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars+1);
|
sl@0
|
746 |
TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars-1));
|
sl@0
|
747 |
TInt rLen=iFont->TextWidthInPixels(bbb);
|
sl@0
|
748 |
TBool result = IsLengthEqual(lLen,rLen,iBbLen);
|
sl@0
|
749 |
iGdiTest->TEST(result);
|
sl@0
|
750 |
if (!result)
|
sl@0
|
751 |
iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen);
|
sl@0
|
752 |
|
sl@0
|
753 |
iGdi->DrawTextVertical(bbb, rect, fAscent, ETrue,CGraphicsContext::ELeft, rWid-rLen);
|
sl@0
|
754 |
//
|
sl@0
|
755 |
rect.iTl.iX=rect.iBr.iX;
|
sl@0
|
756 |
rect.iBr.iX=rect.iTl.iX+fHeight;
|
sl@0
|
757 |
iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue,CGraphicsContext::ELeft, 0);
|
sl@0
|
758 |
}
|
sl@0
|
759 |
|
sl@0
|
760 |
void CGdiVertBoxText::TheTest(const TRect &aRect, TInt)
|
sl@0
|
761 |
{
|
sl@0
|
762 |
TInt rWid=aRect.iBr.iY-aRect.iTl.iY;
|
sl@0
|
763 |
TInt fAscent=iFont->AscentInPixels();
|
sl@0
|
764 |
TInt fHeight=iFont->HeightInPixels();
|
sl@0
|
765 |
iGdi->UseFont(iFont);
|
sl@0
|
766 |
iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
767 |
TRect rect(aRect);
|
sl@0
|
768 |
rect.iBr.iX=rect.iTl.iX+fHeight;
|
sl@0
|
769 |
//
|
sl@0
|
770 |
iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue, CGraphicsContext::ELeft, rWid-iBbLen);
|
sl@0
|
771 |
//
|
sl@0
|
772 |
rect.iTl.iX=rect.iBr.iX;
|
sl@0
|
773 |
rect.iBr.iX=rect.iTl.iX+fHeight;
|
sl@0
|
774 |
iGdi->Clear(rect);
|
sl@0
|
775 |
iGdi->SetClippingRegion(TRegionFix<1>(rect));
|
sl@0
|
776 |
iGdi->DrawTextVertical(iBigBuffer, TPoint(rect.iTl.iX+fAscent,rect.iBr.iY), ETrue);
|
sl@0
|
777 |
}
|
sl@0
|
778 |
|
sl@0
|
779 |
|
sl@0
|
780 |
//
|
sl@0
|
781 |
//
|
sl@0
|
782 |
CGdiBlitMasked::~CGdiBlitMasked()
|
sl@0
|
783 |
{
|
sl@0
|
784 |
for(TInt index=0;index<ENumMasks;index++)
|
sl@0
|
785 |
delete iMask[index];
|
sl@0
|
786 |
delete iBitmap;
|
sl@0
|
787 |
delete iScratch;
|
sl@0
|
788 |
delete iScratchDevice;
|
sl@0
|
789 |
delete iScratchGc;
|
sl@0
|
790 |
delete iScratchMask;
|
sl@0
|
791 |
delete iScratchMaskDevice;
|
sl@0
|
792 |
delete iScratchMaskGc;
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
TInt CGdiBlitMasked::Count(TBool aMainTests)
|
sl@0
|
796 |
{
|
sl@0
|
797 |
return(aMainTests ? ENumMasks*2 : ENumMasks*2);
|
sl@0
|
798 |
}
|
sl@0
|
799 |
|
sl@0
|
800 |
void CGdiBlitMasked::doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize)
|
sl@0
|
801 |
{
|
sl@0
|
802 |
User::LeaveIfNull(aDevice=CFbsBitmapDevice::NewL(aBitmap));
|
sl@0
|
803 |
User::LeaveIfError(aDevice->CreateContext(aGc));
|
sl@0
|
804 |
//
|
sl@0
|
805 |
aGc->SetBrushColor(TRgb(128,128,128));
|
sl@0
|
806 |
aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
807 |
aGc->SetPenStyle(CGraphicsContext::ENullPen);
|
sl@0
|
808 |
aGc->DrawRect(TRect(aBitmap->SizeInPixels()));
|
sl@0
|
809 |
aGc->SetPenStyle(CGraphicsContext::ESolidPen);
|
sl@0
|
810 |
for(TInt index=(-aSize.iHeight);index<aSize.iWidth;index+=5)
|
sl@0
|
811 |
{
|
sl@0
|
812 |
aGc->DrawLine(TPoint(index,0),TPoint(index+aSize.iHeight,aSize.iHeight));
|
sl@0
|
813 |
aGc->DrawLine(TPoint(index,aSize.iHeight),TPoint(index+aSize.iHeight,0));
|
sl@0
|
814 |
}
|
sl@0
|
815 |
}
|
sl@0
|
816 |
|
sl@0
|
817 |
void CGdiBlitMasked::createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize)
|
sl@0
|
818 |
{
|
sl@0
|
819 |
CFbsBitGc *gc=NULL;
|
sl@0
|
820 |
CFbsBitmapDevice *device=NULL;
|
sl@0
|
821 |
aBitmap=new(ELeave) CFbsBitmap();
|
sl@0
|
822 |
User::LeaveIfError(aBitmap->Create(aSize,EGray16));
|
sl@0
|
823 |
TRAPD(err,doCreateTestBitmapL(aBitmap, gc, device, aSize));
|
sl@0
|
824 |
delete gc;
|
sl@0
|
825 |
delete device;
|
sl@0
|
826 |
User::LeaveIfError(err);
|
sl@0
|
827 |
}
|
sl@0
|
828 |
|
sl@0
|
829 |
void CGdiBlitMasked::ConstructL(TInt)
|
sl@0
|
830 |
{
|
sl@0
|
831 |
TSize max(0,0);
|
sl@0
|
832 |
for(TInt index=0;index<ENumMasks;index++)
|
sl@0
|
833 |
{
|
sl@0
|
834 |
iMask[index]=new(ELeave) CFbsBitmap();
|
sl@0
|
835 |
User::LeaveIfError(iMask[index]->Load(TAUTO_BITMAP_NAME,2+index));
|
sl@0
|
836 |
TSize size=iMask[index]->SizeInPixels();
|
sl@0
|
837 |
if (max.iWidth<size.iWidth)
|
sl@0
|
838 |
max.iWidth=size.iWidth;
|
sl@0
|
839 |
if (max.iHeight<size.iHeight)
|
sl@0
|
840 |
max.iHeight=size.iHeight;
|
sl@0
|
841 |
}
|
sl@0
|
842 |
iScratch=new(ELeave) CFbsBitmap();
|
sl@0
|
843 |
User::LeaveIfError(iScratch->Create(max,EGray16));
|
sl@0
|
844 |
iScratchDevice=CFbsBitmapDevice::NewL(iScratch);
|
sl@0
|
845 |
User::LeaveIfError(iScratchDevice->CreateContext(iScratchGc));
|
sl@0
|
846 |
|
sl@0
|
847 |
iScratchMask=new(ELeave) CFbsBitmap();
|
sl@0
|
848 |
User::LeaveIfError(iScratchMask->Create(max,EGray16));
|
sl@0
|
849 |
iScratchMaskDevice=CFbsBitmapDevice::NewL(iScratchMask);
|
sl@0
|
850 |
User::LeaveIfError(iScratchMaskDevice->CreateContext(iScratchMaskGc));
|
sl@0
|
851 |
//
|
sl@0
|
852 |
createTestBitmapL(iBitmap, max);
|
sl@0
|
853 |
}
|
sl@0
|
854 |
|
sl@0
|
855 |
void CGdiBlitMasked::PreTestSetupL(const TRect &, TInt aCount)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
iInvertMask=aCount&0x1;
|
sl@0
|
858 |
aCount>>=1;
|
sl@0
|
859 |
iCurrMask= iMask[aCount%ENumMasks];
|
sl@0
|
860 |
iDrawMode=CGraphicsContext::EDrawModePEN;
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
void CGdiBlitMasked::BaseTest(const TRect &aRect, TInt)
|
sl@0
|
864 |
{
|
sl@0
|
865 |
// needs re-writing to emulate tiling of the source rect
|
sl@0
|
866 |
if (!aRect.Intersects(TRect(BaseWin->Size())))
|
sl@0
|
867 |
return;
|
sl@0
|
868 |
TSize size(aRect.Size());
|
sl@0
|
869 |
TSize bitSize=iBitmap->SizeInPixels();
|
sl@0
|
870 |
if (size.iWidth>bitSize.iWidth)
|
sl@0
|
871 |
size.iWidth=bitSize.iWidth;
|
sl@0
|
872 |
if (size.iHeight>bitSize.iHeight)
|
sl@0
|
873 |
size.iHeight=bitSize.iHeight;
|
sl@0
|
874 |
//
|
sl@0
|
875 |
// Set up the scratch mask as a black and white bitmap containing the mask to blit
|
sl@0
|
876 |
// The mask pattern is replicated all over the scratchmask bitmap
|
sl@0
|
877 |
//
|
sl@0
|
878 |
iScratchMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
879 |
iScratchMaskGc->SetPenStyle(CGraphicsContext::ENullPen);
|
sl@0
|
880 |
iScratchMaskGc->SetBrushColor(TRgb(0,0,0));
|
sl@0
|
881 |
iScratchMaskGc->DrawRect(TRect(iScratchMask->SizeInPixels()));
|
sl@0
|
882 |
iScratchMaskGc->SetPenColor(TRgb(255,255,255));
|
sl@0
|
883 |
iScratchMaskGc->SetPenStyle(CGraphicsContext::ESolidPen);
|
sl@0
|
884 |
TSize maskSize(iCurrMask->SizeInPixels());
|
sl@0
|
885 |
TPoint pos;
|
sl@0
|
886 |
TRgb *rgbBuf=(TRgb *)User::AllocL(maskSize.iWidth*sizeof(TRgb)); //Doesn't do any harm if it leaves
|
sl@0
|
887 |
for(pos.iY=0;pos.iY<maskSize.iHeight;pos.iY++)
|
sl@0
|
888 |
{
|
sl@0
|
889 |
TPtr8 ptr((TUint8 *)rgbBuf,maskSize.iWidth*sizeof(TRgb));
|
sl@0
|
890 |
iCurrMask->GetScanLine(ptr, pos, maskSize.iWidth, ERgb);
|
sl@0
|
891 |
for(TInt index=0;index<maskSize.iWidth;index++)
|
sl@0
|
892 |
{
|
sl@0
|
893 |
iScratchMaskGc->SetPenColor(rgbBuf[index]);
|
sl@0
|
894 |
// if ((isLow && !iLowCutOff) || (!isLow && iLowCutOff))
|
sl@0
|
895 |
iScratchMaskGc->Plot(TPoint(index,pos.iY));
|
sl@0
|
896 |
}
|
sl@0
|
897 |
}
|
sl@0
|
898 |
User::Free(rgbBuf);
|
sl@0
|
899 |
|
sl@0
|
900 |
for(pos.iY=0;pos.iY<size.iHeight;pos.iY+=maskSize.iHeight)
|
sl@0
|
901 |
for(pos.iX=0;pos.iX<size.iWidth;pos.iX+=maskSize.iWidth)
|
sl@0
|
902 |
iScratchMaskGc->CopyRect(pos, TRect(maskSize));
|
sl@0
|
903 |
//
|
sl@0
|
904 |
// Blit this to the screen in ANDNOT mode to clear all the pixels we want the mask blit to draw to
|
sl@0
|
905 |
//
|
sl@0
|
906 |
iGdi->SetDrawMode(CGraphicsContext::EDrawModeANDNOT);
|
sl@0
|
907 |
iGdi->BitBlt(aRect.iTl, iScratchMask, TRect(size));
|
sl@0
|
908 |
//
|
sl@0
|
909 |
// Copy the test bitmap to the scratch bitmap then use the scratch mask to clear all the bits
|
sl@0
|
910 |
// that should masked out of the draw to the screen
|
sl@0
|
911 |
//
|
sl@0
|
912 |
iScratchGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
|
sl@0
|
913 |
iScratchGc->BitBlt(TPoint(0,0), iBitmap);
|
sl@0
|
914 |
iScratchGc->SetDrawMode(CGraphicsContext::EDrawModeAND);
|
sl@0
|
915 |
iScratchGc->BitBlt(TPoint(0,0), iScratchMask);
|
sl@0
|
916 |
//
|
sl@0
|
917 |
// Now copy the scratch bitmap to the screen in OR mode to get the final result
|
sl@0
|
918 |
//
|
sl@0
|
919 |
iGdi->SetDrawMode(CGraphicsContext::EDrawModeOR);
|
sl@0
|
920 |
iGdi->BitBlt(aRect.iTl, iScratch, TRect(size));
|
sl@0
|
921 |
}
|
sl@0
|
922 |
|
sl@0
|
923 |
void CGdiBlitMasked::TheTest(const TRect &aRect, TInt)
|
sl@0
|
924 |
{
|
sl@0
|
925 |
iGdi->BitBltMasked(aRect.iTl,iBitmap,TRect((aRect.iBr-aRect.iTl).AsSize()),
|
sl@0
|
926 |
iCurrMask,iInvertMask);
|
sl@0
|
927 |
}
|
sl@0
|
928 |
//
|
sl@0
|
929 |
//
|
sl@0
|
930 |
|
sl@0
|
931 |
CTGdi::CTGdi(CTestStep* aStep) : CTWsGraphicsBase(aStep), iGdiTest (NULL), iTextOffsetX(10),iTextOffsetY(10)
|
sl@0
|
932 |
{
|
sl@0
|
933 |
}
|
sl@0
|
934 |
|
sl@0
|
935 |
void CTGdi::ConstructL()
|
sl@0
|
936 |
{
|
sl@0
|
937 |
iWinSize=TestWin->Size();
|
sl@0
|
938 |
}
|
sl@0
|
939 |
|
sl@0
|
940 |
TSize CTGdi::WinSize()
|
sl@0
|
941 |
{
|
sl@0
|
942 |
return(iWinSize);
|
sl@0
|
943 |
}
|
sl@0
|
944 |
|
sl@0
|
945 |
void CTGdi::DoGdiTestL(const TRect &aRect, TInt aNum)
|
sl@0
|
946 |
{
|
sl@0
|
947 |
//
|
sl@0
|
948 |
iGdiTest->PreTestSetupL(aRect,aNum);
|
sl@0
|
949 |
//
|
sl@0
|
950 |
BaseWin->Win()->Invalidate();
|
sl@0
|
951 |
BaseWin->Win()->BeginRedraw();
|
sl@0
|
952 |
TheGc->Activate(*BaseWin->Win());
|
sl@0
|
953 |
iTest->DrawTestBackground(EFalse,BaseWin->Size());
|
sl@0
|
954 |
iGdiTest->BaseTest(aRect,aNum);
|
sl@0
|
955 |
TheGc->Deactivate();
|
sl@0
|
956 |
BaseWin->Win()->EndRedraw();
|
sl@0
|
957 |
//
|
sl@0
|
958 |
TestWin->Win()->Invalidate();
|
sl@0
|
959 |
TestWin->Win()->BeginRedraw();
|
sl@0
|
960 |
TheGc->Activate(*TestWin->Win());
|
sl@0
|
961 |
iTest->DrawTestBackground(EFalse,TestWin->Size());
|
sl@0
|
962 |
iGdiTest->TheTest(aRect,aNum);
|
sl@0
|
963 |
TheGc->Deactivate();
|
sl@0
|
964 |
TestWin->Win()->EndRedraw();
|
sl@0
|
965 |
//
|
sl@0
|
966 |
TheClient->iWs.Flush();
|
sl@0
|
967 |
TheClient->WaitForRedrawsToFinish();
|
sl@0
|
968 |
TheClient->iWs.Finish();
|
sl@0
|
969 |
//
|
sl@0
|
970 |
_LIT(KLog,"GDI Substate=%d test=%d rect=(%d,%d,%d,%d) ");
|
sl@0
|
971 |
TBuf<64> buf;
|
sl@0
|
972 |
buf.Format(KLog,iSubState,aNum,aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY);
|
sl@0
|
973 |
iTestPassing=CompareWindows(buf);
|
sl@0
|
974 |
}
|
sl@0
|
975 |
|
sl@0
|
976 |
void CTGdi::GdiTestL(CGdiTestLowLevel *aTest)
|
sl@0
|
977 |
{
|
sl@0
|
978 |
TTestRects::ResetSeed();
|
sl@0
|
979 |
iTestPassing=ETrue;
|
sl@0
|
980 |
iGdiTest=aTest;
|
sl@0
|
981 |
iGdiTest->SetGdiTest(this);
|
sl@0
|
982 |
iGdiTest->AssignGdi(TheGc);
|
sl@0
|
983 |
iGdiTest->ConstructL(iTest->iTestRects.Count1());
|
sl@0
|
984 |
TInt index;
|
sl@0
|
985 |
TInt index2;
|
sl@0
|
986 |
for(index=0; iTestPassing && index<iTest->iTestRects.Count2(); ++index)
|
sl@0
|
987 |
{
|
sl@0
|
988 |
TInt max=iGdiTest->Count(index<iTest->iTestRects.Count1());
|
sl@0
|
989 |
TRect rect=iTest->iTestRects[index];
|
sl@0
|
990 |
#if defined(LOGGING)
|
sl@0
|
991 |
_LIT(KLog1,"Testing rectangle %d (%d,%d,%d,%d) 1st pass");
|
sl@0
|
992 |
LOG_MESSAGE6(KLog1,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
|
sl@0
|
993 |
#endif
|
sl@0
|
994 |
for(index2=0; iTestPassing && index2<max; ++index2)
|
sl@0
|
995 |
DoGdiTestL(rect,index2);
|
sl@0
|
996 |
if (!iTestPassing)
|
sl@0
|
997 |
{
|
sl@0
|
998 |
_LIT(KLog,"Test fail on rectangle %d at iteration %d");
|
sl@0
|
999 |
LOG_MESSAGE3(KLog,index,index2);
|
sl@0
|
1000 |
}
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
for(; iTestPassing && index<iTest->iTestRects.Count3(); index++)
|
sl@0
|
1003 |
{
|
sl@0
|
1004 |
TRect rect=iTest->iTestRects[index];
|
sl@0
|
1005 |
#if defined(LOGGING)
|
sl@0
|
1006 |
_LIT(KLog2,"Testing rectangle %d (%d,%d,%d,%d) 2nd pass");
|
sl@0
|
1007 |
LOG_MESSAGE6(KLog2,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
|
sl@0
|
1008 |
#endif
|
sl@0
|
1009 |
DoGdiTestL(rect,0);
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
delete iGdiTest;
|
sl@0
|
1012 |
iGdiTest=NULL;
|
sl@0
|
1013 |
}
|
sl@0
|
1014 |
|
sl@0
|
1015 |
void CTGdi::NonDrawing()
|
sl@0
|
1016 |
//
|
sl@0
|
1017 |
// Test all non-drawing GDI functions
|
sl@0
|
1018 |
//
|
sl@0
|
1019 |
{
|
sl@0
|
1020 |
TDisplayMode mode=TheClient->iScreen->DisplayMode();
|
sl@0
|
1021 |
TEST((mode!=ERgb) && (mode!=ENone));
|
sl@0
|
1022 |
|
sl@0
|
1023 |
RWsSession session;
|
sl@0
|
1024 |
TInt res = session.Connect();
|
sl@0
|
1025 |
TEST(res == KErrNone);
|
sl@0
|
1026 |
|
sl@0
|
1027 |
CArrayFixFlat<TInt>* modeList= new CArrayFixFlat<TInt> (15);
|
sl@0
|
1028 |
if(!modeList)
|
sl@0
|
1029 |
return;
|
sl@0
|
1030 |
|
sl@0
|
1031 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
1032 |
res = session.GetColorModeList(iTest->iScreenNumber, modeList);
|
sl@0
|
1033 |
#else
|
sl@0
|
1034 |
res = session.GetColorModeList(modeList);
|
sl@0
|
1035 |
#endif //SYMBIAN_GRAPHICS_GCE
|
sl@0
|
1036 |
session.Close();
|
sl@0
|
1037 |
TEST(res == KErrNone);
|
sl@0
|
1038 |
if(res != KErrNone)
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
modeList->Reset();
|
sl@0
|
1041 |
delete modeList;
|
sl@0
|
1042 |
return;
|
sl@0
|
1043 |
}
|
sl@0
|
1044 |
|
sl@0
|
1045 |
TBool found = EFalse;
|
sl@0
|
1046 |
for(TInt ii = 0; ii < modeList->Count() && !found; ii++)
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]);
|
sl@0
|
1049 |
if(mode == mode1)
|
sl@0
|
1050 |
{
|
sl@0
|
1051 |
found = ETrue;
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
}
|
sl@0
|
1054 |
modeList->Reset();
|
sl@0
|
1055 |
delete modeList;
|
sl@0
|
1056 |
|
sl@0
|
1057 |
TEST(found);
|
sl@0
|
1058 |
}
|
sl@0
|
1059 |
|
sl@0
|
1060 |
//
|
sl@0
|
1061 |
// Auxiliary Fn for Test Case ID CTGdi_TestDefetct_DEF045746
|
sl@0
|
1062 |
// This method draws the text represented by aText parameter on the window
|
sl@0
|
1063 |
// passed to it.
|
sl@0
|
1064 |
//
|
sl@0
|
1065 |
void CTGdi::DrawTextOnWindow(const TDesC& aText,CTWin* aWin)
|
sl@0
|
1066 |
{
|
sl@0
|
1067 |
aWin->Win()->BeginRedraw();
|
sl@0
|
1068 |
TheGc->Activate(*aWin->Win());
|
sl@0
|
1069 |
TheGc->Device()->GetNearestFontToDesignHeightInTwips(iFont,TFontSpec(_L("Arial"),250));
|
sl@0
|
1070 |
TheGc->UseFont(iFont);
|
sl@0
|
1071 |
TheGc->Clear();
|
sl@0
|
1072 |
TheGc->DrawRect(TRect(aWin->Win()->Size()));
|
sl@0
|
1073 |
TheGc->DrawText(aText,TPoint(iTextOffsetX,iTextOffsetY));
|
sl@0
|
1074 |
TheGc->Device()->ReleaseFont(iFont);
|
sl@0
|
1075 |
TheGc->Deactivate();
|
sl@0
|
1076 |
aWin->Win()->EndRedraw();
|
sl@0
|
1077 |
}
|
sl@0
|
1078 |
|
sl@0
|
1079 |
|
sl@0
|
1080 |
void CTGdi::TestDefetct_DEF045746L()
|
sl@0
|
1081 |
{
|
sl@0
|
1082 |
_LIT(KString,"This is a test window for the defect fix DEF045746 \
|
sl@0
|
1083 |
propagated from Opera browser. Most window graphics context drawing\
|
sl@0
|
1084 |
functions map to equivalent CFbsBitGc functions they are implemented\
|
sl@0
|
1085 |
on the screen with any co-ordinates being relative to the top left\
|
sl@0
|
1086 |
corner of the window. However extra clipping is applied. The drawing\
|
sl@0
|
1087 |
will always be clipped to the visible part of the window, in addition\
|
sl@0
|
1088 |
it will be clipped to the non-invalid part if you are not doing a\
|
sl@0
|
1089 |
redraw and to the region being validated if you are doing a redraw.");
|
sl@0
|
1090 |
|
sl@0
|
1091 |
TPtrC TestText(KString().Ptr(),100);
|
sl@0
|
1092 |
TPtrC LargeText(KString().Ptr());
|
sl@0
|
1093 |
TPtrC ShortText(KString().Ptr(),200);
|
sl@0
|
1094 |
|
sl@0
|
1095 |
TSize scrSize=TheClient->iScreen->SizeInPixels();
|
sl@0
|
1096 |
TSize winSize;
|
sl@0
|
1097 |
const TInt windowGap=5;
|
sl@0
|
1098 |
winSize.SetSize(scrSize.iWidth -2* windowGap,scrSize.iHeight/2 - windowGap);
|
sl@0
|
1099 |
|
sl@0
|
1100 |
iWin=new(ELeave) CTestWindow(TRgb(0,0,0));
|
sl@0
|
1101 |
iWin->ConstructL(TPoint(5,5),TSize(winSize),TheClient->iGroup,*TheClient->iGc);
|
sl@0
|
1102 |
CTestWindow* expectWin= new(ELeave) CTestWindow(TRgb(0,0,0));
|
sl@0
|
1103 |
expectWin->ConstructL(TPoint(5,scrSize.iHeight/2 + windowGap),TSize(winSize),TheClient->iGroup,*TheClient->iGc);
|
sl@0
|
1104 |
DrawTextOnWindow(ShortText,iWin);
|
sl@0
|
1105 |
DrawTextOnWindow(TestText,expectWin);
|
sl@0
|
1106 |
TInt fHeight=iFont->HeightInPixels();//Used to compare only pixels where text is drawn
|
sl@0
|
1107 |
TRect iRect=winSize;
|
sl@0
|
1108 |
iRect.iTl.iX=iTextOffsetX;
|
sl@0
|
1109 |
iRect.iTl.iY=iTextOffsetY;
|
sl@0
|
1110 |
iRect.iBr.iY=iTextOffsetY+fHeight;
|
sl@0
|
1111 |
CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L A"));
|
sl@0
|
1112 |
iWin->Invalidate();
|
sl@0
|
1113 |
DrawTextOnWindow(LargeText,iWin);
|
sl@0
|
1114 |
CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L B"));
|
sl@0
|
1115 |
delete iWin;
|
sl@0
|
1116 |
iWin=NULL;
|
sl@0
|
1117 |
delete expectWin;
|
sl@0
|
1118 |
expectWin=NULL;
|
sl@0
|
1119 |
}
|
sl@0
|
1120 |
|
sl@0
|
1121 |
void CTGdi::RunTestCaseL(TInt /*aCurTestCase*/)
|
sl@0
|
1122 |
{
|
sl@0
|
1123 |
//_LIT(KTest1,"NonDrawing"); this test is not running
|
sl@0
|
1124 |
_LIT(KTest2,"DEF045746");
|
sl@0
|
1125 |
_LIT(KTest3,"Drawing Tests");
|
sl@0
|
1126 |
((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
1127 |
static TTime startTime;
|
sl@0
|
1128 |
switch(++iTest->iState)
|
sl@0
|
1129 |
{
|
sl@0
|
1130 |
/**
|
sl@0
|
1131 |
@SYMTestCaseID GRAPHICS-WSERV-0262
|
sl@0
|
1132 |
|
sl@0
|
1133 |
@SYMDEF DEF081259
|
sl@0
|
1134 |
|
sl@0
|
1135 |
@SYMTestCaseDesc Test all non-drawing GDI functions
|
sl@0
|
1136 |
|
sl@0
|
1137 |
@SYMTestPriority High
|
sl@0
|
1138 |
|
sl@0
|
1139 |
@SYMTestStatus Implemented
|
sl@0
|
1140 |
|
sl@0
|
1141 |
@SYMTestActions Check all non-drawing GDI functions operate correctly
|
sl@0
|
1142 |
|
sl@0
|
1143 |
@SYMTestExpectedResults Non-drawing GDI functions operate correctly
|
sl@0
|
1144 |
*/
|
sl@0
|
1145 |
case 1:
|
sl@0
|
1146 |
// start time log
|
sl@0
|
1147 |
startTime.HomeTime();
|
sl@0
|
1148 |
((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0262"));
|
sl@0
|
1149 |
//iTest->LogSubTest(KTest1);
|
sl@0
|
1150 |
//PeterI this tests whether the display mode is EGray4 or EGray16.
|
sl@0
|
1151 |
//The actual display mode is EColor16MU so this test will always fail
|
sl@0
|
1152 |
//NonDrawingL();
|
sl@0
|
1153 |
break;
|
sl@0
|
1154 |
/**
|
sl@0
|
1155 |
* @SYMTestCaseID GRAPHICS-WSERV-0263
|
sl@0
|
1156 |
*
|
sl@0
|
1157 |
* @SYMPREQ DEF045746
|
sl@0
|
1158 |
*
|
sl@0
|
1159 |
* @SYMTestCaseDesc Test defect fix for DEF045746
|
sl@0
|
1160 |
*
|
sl@0
|
1161 |
* @SYMTestPriority High
|
sl@0
|
1162 |
*
|
sl@0
|
1163 |
* @SYMTestStatus Implemented
|
sl@0
|
1164 |
*
|
sl@0
|
1165 |
* @SYMTestActions The method tests CWindowGc::DrawText().The test is carried
|
sl@0
|
1166 |
* out by writing small & very large strings to the window graphic context.
|
sl@0
|
1167 |
*
|
sl@0
|
1168 |
* @SYMTestExpectedResults The window with large / small strings written is
|
sl@0
|
1169 |
* compared with an expected result window. In both the cases strings should
|
sl@0
|
1170 |
* be displayed.
|
sl@0
|
1171 |
*
|
sl@0
|
1172 |
*/
|
sl@0
|
1173 |
case 2:
|
sl@0
|
1174 |
((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0263"));
|
sl@0
|
1175 |
iTest->LogSubTest(KTest2);
|
sl@0
|
1176 |
TestDefetct_DEF045746L();
|
sl@0
|
1177 |
break;
|
sl@0
|
1178 |
/**
|
sl@0
|
1179 |
@SYMTestCaseID GRAPHICS-WSERV-0264
|
sl@0
|
1180 |
|
sl@0
|
1181 |
@SYMDEF DEF081259
|
sl@0
|
1182 |
|
sl@0
|
1183 |
@SYMTestCaseDesc Test all drawing GDI functions
|
sl@0
|
1184 |
|
sl@0
|
1185 |
@SYMTestPriority High
|
sl@0
|
1186 |
|
sl@0
|
1187 |
@SYMTestStatus Implemented
|
sl@0
|
1188 |
|
sl@0
|
1189 |
@SYMTestActions Check all drawing GDI functions operate correctly
|
sl@0
|
1190 |
|
sl@0
|
1191 |
@SYMTestExpectedResults Drawing GDI functions operate correctly
|
sl@0
|
1192 |
*/
|
sl@0
|
1193 |
case 3:
|
sl@0
|
1194 |
{
|
sl@0
|
1195 |
((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0264"));
|
sl@0
|
1196 |
iTest->LogSubTest(KTest3);
|
sl@0
|
1197 |
iSubState = 0;
|
sl@0
|
1198 |
TheClient->WaitForRedrawsToFinish(); //Just in case the two test windows have any invalid areas
|
sl@0
|
1199 |
TInt numTests = sizeof(GdiTestFuncs) / sizeof(GdiTestFuncs[0]);
|
sl@0
|
1200 |
while (iSubState < numTests)
|
sl@0
|
1201 |
{
|
sl@0
|
1202 |
LOG_MESSAGE(TPtrC(GdiTestFuncs[iSubState].txt));
|
sl@0
|
1203 |
GdiTestL((*GdiTestFuncs[iSubState].func)());
|
sl@0
|
1204 |
iSubState++;
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
}
|
sl@0
|
1207 |
break;
|
sl@0
|
1208 |
default:
|
sl@0
|
1209 |
((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1210 |
((CTGdiStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
1211 |
TestComplete();
|
sl@0
|
1212 |
// log time and print duration
|
sl@0
|
1213 |
TTime endTime;
|
sl@0
|
1214 |
endTime.HomeTime();
|
sl@0
|
1215 |
TInt64 duration = endTime.MicroSecondsFrom(startTime).Int64();
|
sl@0
|
1216 |
float time = (float) I64LOW(duration) / 1000.0f;
|
sl@0
|
1217 |
_LIT(KDuration,"Total test duration is %f millisec");
|
sl@0
|
1218 |
RDebug::Print(KDuration, time);
|
sl@0
|
1219 |
break;
|
sl@0
|
1220 |
}
|
sl@0
|
1221 |
((CTGdiStep*)iStep)->RecordTestResultL();
|
sl@0
|
1222 |
}
|
sl@0
|
1223 |
|
sl@0
|
1224 |
CGdiTestLowLevel *SetOriginTest()
|
sl@0
|
1225 |
{
|
sl@0
|
1226 |
return(new(ELeave) CGdiSetOrigin());
|
sl@0
|
1227 |
}
|
sl@0
|
1228 |
|
sl@0
|
1229 |
CGdiTestLowLevel *PolyLineTest()
|
sl@0
|
1230 |
{
|
sl@0
|
1231 |
return(new(ELeave) CGdiPolyLine());
|
sl@0
|
1232 |
}
|
sl@0
|
1233 |
|
sl@0
|
1234 |
CGdiTestLowLevel *PolygonTest()
|
sl@0
|
1235 |
{
|
sl@0
|
1236 |
return(new(ELeave) CGdiPolygon());
|
sl@0
|
1237 |
}
|
sl@0
|
1238 |
|
sl@0
|
1239 |
CGdiTestLowLevel *BlitMaskedTest()
|
sl@0
|
1240 |
{
|
sl@0
|
1241 |
return(new(ELeave) CGdiBlitMasked());
|
sl@0
|
1242 |
}
|
sl@0
|
1243 |
|
sl@0
|
1244 |
CGdiTestLowLevel *DrawArcTest()
|
sl@0
|
1245 |
{
|
sl@0
|
1246 |
return(new(ELeave) CGdiDrawArc());
|
sl@0
|
1247 |
}
|
sl@0
|
1248 |
|
sl@0
|
1249 |
CGdiTestLowLevel *DrawPieTest()
|
sl@0
|
1250 |
{
|
sl@0
|
1251 |
return(new(ELeave) CGdiDrawPie());
|
sl@0
|
1252 |
}
|
sl@0
|
1253 |
|
sl@0
|
1254 |
CGdiTestLowLevel *DrawRoundRectTest()
|
sl@0
|
1255 |
{
|
sl@0
|
1256 |
return(new(ELeave) CGdiDrawRoundRect());
|
sl@0
|
1257 |
}
|
sl@0
|
1258 |
|
sl@0
|
1259 |
CGdiTestLowLevel *BoxTextTest()
|
sl@0
|
1260 |
{
|
sl@0
|
1261 |
return(new(ELeave) CGdiBoxText());
|
sl@0
|
1262 |
}
|
sl@0
|
1263 |
|
sl@0
|
1264 |
CGdiTestLowLevel *VertTextTest()
|
sl@0
|
1265 |
{
|
sl@0
|
1266 |
return(new(ELeave) CGdiDrawVertText());
|
sl@0
|
1267 |
}
|
sl@0
|
1268 |
|
sl@0
|
1269 |
CGdiTestLowLevel *VertBoxTextTest()
|
sl@0
|
1270 |
{
|
sl@0
|
1271 |
return(new(ELeave) CGdiVertBoxText());
|
sl@0
|
1272 |
}
|
sl@0
|
1273 |
|
sl@0
|
1274 |
CGdiTestLowLevel *WideLineTest()
|
sl@0
|
1275 |
{
|
sl@0
|
1276 |
return(new(ELeave) CGdiWideLine());
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
|
sl@0
|
1279 |
CGdiTestLowLevel *DrawTextTest()
|
sl@0
|
1280 |
{
|
sl@0
|
1281 |
return(new(ELeave) CGdiDrawText());
|
sl@0
|
1282 |
}
|
sl@0
|
1283 |
|
sl@0
|
1284 |
CGdiTestLowLevel *DrawRectTest()
|
sl@0
|
1285 |
{
|
sl@0
|
1286 |
return(new(ELeave) CGdiDrawRect());
|
sl@0
|
1287 |
}
|
sl@0
|
1288 |
|
sl@0
|
1289 |
__WS_CONSTRUCT_STEP__(Gdi)
|