sl@0
|
1 |
// Copyright (c) 2006-2010 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 |
#include "toutlineandshadowfonts.h"
|
sl@0
|
23 |
#include <test/testexecutestepbase.h>
|
sl@0
|
24 |
#include <openfont.h>
|
sl@0
|
25 |
#include <test/thashreferenceimages.h>
|
sl@0
|
26 |
#include <graphics/fbsdefs.h>
|
sl@0
|
27 |
#include "fbsmessage.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
//Note: This test should run with a rasterizer which supports EFourColourBlendGlyphBitmap (e.g. iType)
|
sl@0
|
30 |
//otherwise the tests will fail.
|
sl@0
|
31 |
|
sl@0
|
32 |
//Path where reference mbm files get created, these reference bitmaps are useful when debugging.
|
sl@0
|
33 |
_LIT(KPath, "c:\\bitgditest\\%S.mbm");
|
sl@0
|
34 |
|
sl@0
|
35 |
// Constructor
|
sl@0
|
36 |
CTOutlineAndShadowFonts::CTOutlineAndShadowFonts(CTestStep* aStep):CTGraphicsBase(aStep),iStep(aStep) { }
|
sl@0
|
37 |
|
sl@0
|
38 |
void CTOutlineAndShadowFonts::ConstructL()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
if (RFbsSession::Connect() != KErrNone)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
FbsStartup();
|
sl@0
|
43 |
TInt conret = RFbsSession::Connect();
|
sl@0
|
44 |
TEST2(conret, KErrNone);
|
sl@0
|
45 |
}
|
sl@0
|
46 |
iFbs = RFbsSession::GetSession();
|
sl@0
|
47 |
iHashUtil = CTHashReferenceImages::NewL(iStep,iFbs,&KPath);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
// Destructor
|
sl@0
|
51 |
CTOutlineAndShadowFonts::~CTOutlineAndShadowFonts()
|
sl@0
|
52 |
{
|
sl@0
|
53 |
FreeScreenDevice();
|
sl@0
|
54 |
RFbsSession::Disconnect();
|
sl@0
|
55 |
delete iHashUtil;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
Creates screen device for the given display mode if supported
|
sl@0
|
61 |
@param aMode display mode for which device has to be created
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
void CTOutlineAndShadowFonts::CreateScreenDeviceL(TDisplayMode aMode)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
iBitmap = new(ELeave) CFbsBitmap;
|
sl@0
|
66 |
//Considering the intersection of the screen size for both hw and emulator so that same
|
sl@0
|
67 |
//baselined hash can be used to test for both
|
sl@0
|
68 |
iBitmap->Create(TSize(KScreenWidth, KScreenHeight), aMode);
|
sl@0
|
69 |
iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
|
sl@0
|
70 |
User::LeaveIfError(iBitmapDevice->CreateContext((CGraphicsContext*&)iGc));
|
sl@0
|
71 |
iHashUtil->SetScreenDeviceAndBitmap(iBitmapDevice,iBitmap,iGc);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
Delete the devices created and gc.
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
void CTOutlineAndShadowFonts::FreeScreenDevice()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
delete iBitmapDevice;
|
sl@0
|
80 |
delete iBitmap;
|
sl@0
|
81 |
delete iGc;
|
sl@0
|
82 |
iBitmapDevice = NULL;
|
sl@0
|
83 |
iBitmap = NULL;
|
sl@0
|
84 |
iGc = NULL;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
|
sl@0
|
88 |
/**
|
sl@0
|
89 |
Auxilary function will be called in case of a leave to release the font
|
sl@0
|
90 |
@param aCleanFont font to be released
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
void CleanUpFont(TAny* aCleanFont)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
SCleanFont* cleanFont= static_cast<SCleanFont*>(aCleanFont);
|
sl@0
|
95 |
(cleanFont->device)->ReleaseFont(cleanFont->font);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
TBool CTOutlineAndShadowFonts::CheckMonoTypeInstalledL()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
CreateScreenDeviceL(EColor16MU);
|
sl@0
|
101 |
//
|
sl@0
|
102 |
TFontSpec fontSpec;
|
sl@0
|
103 |
fontSpec.iTypeface.iName = KFontFace[0];
|
sl@0
|
104 |
fontSpec.iHeight = KHeight;
|
sl@0
|
105 |
fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
|
sl@0
|
106 |
fontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn);
|
sl@0
|
107 |
fontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn);
|
sl@0
|
108 |
CFont* font;
|
sl@0
|
109 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec));
|
sl@0
|
110 |
TBool monoTypeInstalled=font->FontSpecInTwips().iFontStyle.BitmapType()==EFourColourBlendGlyphBitmap;
|
sl@0
|
111 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
112 |
if (!monoTypeInstalled)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
INFO_PRINTF1(_L("Monotype fonts not installed, Run iType\\binaries\\ityperast.cmd to install them"));
|
sl@0
|
115 |
TEST(EFalse);
|
sl@0
|
116 |
TestComplete();
|
sl@0
|
117 |
}
|
sl@0
|
118 |
return(monoTypeInstalled);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0008
|
sl@0
|
123 |
|
sl@0
|
124 |
@SYMPREQ PREQ1543
|
sl@0
|
125 |
|
sl@0
|
126 |
@SYMTestCaseDesc Checks the fonts metrics. Tests the metrics with and without outline and shadow effects
|
sl@0
|
127 |
for different typefaces and screen modes
|
sl@0
|
128 |
|
sl@0
|
129 |
@SYMTestPriority Critical
|
sl@0
|
130 |
|
sl@0
|
131 |
@SYMTestStatus Implemented
|
sl@0
|
132 |
|
sl@0
|
133 |
@SYMTestActions Create two fonts, one with and without shadow and outline effects on.
|
sl@0
|
134 |
Get the font metrics using GetNearestFontToDesignHeightInPixels
|
sl@0
|
135 |
Compare the different font metrics for both the fonts.
|
sl@0
|
136 |
API Calls:
|
sl@0
|
137 |
CTOutlineAndShadowFonts::DoOutlineandShadowFontsMetrics()
|
sl@0
|
138 |
|
sl@0
|
139 |
@SYMTestExpectedResults font metrics with and without outline and shadow effects should not vary by more than 3.
|
sl@0
|
140 |
*/
|
sl@0
|
141 |
void CTOutlineAndShadowFonts::TestOutlineandShadowFontsMetricsL()
|
sl@0
|
142 |
{
|
sl@0
|
143 |
INFO_PRINTF1(_L("TestOutlineandShadowFontsMetricsL()"));
|
sl@0
|
144 |
FreeScreenDevice();
|
sl@0
|
145 |
CreateScreenDeviceL(EColor16MU); //Create device for EColor16MU
|
sl@0
|
146 |
for (TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0008; numOfSubTests++)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
DoOutlineandShadowFontsMetrics(KTestSettingsToTestFontMetrics[numOfSubTests], fontFaceIndex);
|
sl@0
|
151 |
}
|
sl@0
|
152 |
}
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
/**
|
sl@0
|
156 |
Utility function to determine whether a specified value lies within a defined range of values.
|
sl@0
|
157 |
@param aMin The lower value of the range.
|
sl@0
|
158 |
@param aValue The value to be compared.
|
sl@0
|
159 |
@param aMax The higher value of the range.
|
sl@0
|
160 |
@return ETrue, if the specified value lies within the range; EFalse, otherwise.
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
TBool CTOutlineAndShadowFonts::TestRange(TInt aMin, TInt aValue, TInt aMax)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
if (Rng(aMin, aValue, aMax))
|
sl@0
|
165 |
{
|
sl@0
|
166 |
return ETrue;
|
sl@0
|
167 |
}
|
sl@0
|
168 |
else
|
sl@0
|
169 |
{
|
sl@0
|
170 |
INFO_PRINTF4(_L("TestRange: !(%i !<= %i !<= %i)"), aMin, aValue, aMax);
|
sl@0
|
171 |
return EFalse;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
Utility function to determine whether a specified value is below a certain value.
|
sl@0
|
177 |
@param aValue The value to be compared.
|
sl@0
|
178 |
@param aMax The highest permitted value.
|
sl@0
|
179 |
@return ETrue, if the specified value is below the maximum; EFalse, otherwise.
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
TBool CTOutlineAndShadowFonts::TestLessThanOrEqual(TInt aValue, TInt aMax)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
if (aValue <= aMax)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
return ETrue;
|
sl@0
|
186 |
}
|
sl@0
|
187 |
else
|
sl@0
|
188 |
{
|
sl@0
|
189 |
INFO_PRINTF3(_L("TestLessThanOrEqual: !(%i !<= %i)"), aValue, aMax);
|
sl@0
|
190 |
return EFalse;
|
sl@0
|
191 |
}
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
/**
|
sl@0
|
195 |
Auxilary function called from TestOutlineandShadowFontsMetricsL
|
sl@0
|
196 |
@param aSettings holds the effects settings (outline, shadow etc...)
|
sl@0
|
197 |
@param aFontIndex holds the font index
|
sl@0
|
198 |
*/
|
sl@0
|
199 |
void CTOutlineAndShadowFonts::DoOutlineandShadowFontsMetrics(const STestFontParameters &aSettings, TInt aFontIndex)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
TFontSpec fontSpecWithOutEffects;
|
sl@0
|
202 |
//Create fontspec without shadow and outline effects on
|
sl@0
|
203 |
PrepareTestEnvironment(fontSpecWithOutEffects, aSettings , aFontIndex, EFalse, EFalse);
|
sl@0
|
204 |
CFbsFont* font1 = NULL;
|
sl@0
|
205 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fontSpecWithOutEffects) == KErrNone);
|
sl@0
|
206 |
TEST(font1 != NULL);
|
sl@0
|
207 |
|
sl@0
|
208 |
TFontSpec fontSpecWithEffects;
|
sl@0
|
209 |
//Create fontspec with shadow and outline effects on if asked for
|
sl@0
|
210 |
PrepareTestEnvironment(fontSpecWithEffects, aSettings, aFontIndex, ETrue, EFalse);
|
sl@0
|
211 |
CFbsFont* font2 = NULL;
|
sl@0
|
212 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fontSpecWithEffects) == KErrNone);
|
sl@0
|
213 |
TEST(font2 != NULL);
|
sl@0
|
214 |
|
sl@0
|
215 |
//get the name of the fonts
|
sl@0
|
216 |
TOpenFontFaceAttrib font1Attrib;
|
sl@0
|
217 |
TBool haveFont1Attrib;
|
sl@0
|
218 |
haveFont1Attrib = font1->GetFaceAttrib(font1Attrib);
|
sl@0
|
219 |
INFO_PRINTF1(_L("Font names"));
|
sl@0
|
220 |
if (haveFont1Attrib)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
INFO_PRINTF1(font1Attrib.FullName());
|
sl@0
|
223 |
}
|
sl@0
|
224 |
TOpenFontFaceAttrib font2Attrib;
|
sl@0
|
225 |
TBool haveFont2Attrib;
|
sl@0
|
226 |
haveFont2Attrib = font2->GetFaceAttrib(font2Attrib);
|
sl@0
|
227 |
if (haveFont2Attrib)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
INFO_PRINTF1(font2Attrib.FullName());
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
//Check different font metrics with and without outline and shadow effects
|
sl@0
|
233 |
TUid uid1 = font1->TypeUid();
|
sl@0
|
234 |
TUid uid2 = font2->TypeUid();
|
sl@0
|
235 |
ASSERT_EQUALS(KCFbsFontUid, uid1);
|
sl@0
|
236 |
ASSERT_EQUALS(KCFbsFontUid, uid2);
|
sl@0
|
237 |
TInt valueFontWithoutEffects = font1->AscentInPixels();
|
sl@0
|
238 |
TInt valueFontWithEffects = font2->AscentInPixels();
|
sl@0
|
239 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
240 |
|
sl@0
|
241 |
valueFontWithoutEffects = font1->BaselineOffsetInPixels();
|
sl@0
|
242 |
valueFontWithEffects = font2->BaselineOffsetInPixels();
|
sl@0
|
243 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
244 |
for (TInt c=0;c<256;c++)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
valueFontWithoutEffects = font1->CharWidthInPixels(c);
|
sl@0
|
247 |
valueFontWithEffects = font2->CharWidthInPixels(c);
|
sl@0
|
248 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
249 |
}
|
sl@0
|
250 |
//CharactersJoin
|
sl@0
|
251 |
valueFontWithoutEffects = font1->DescentInPixels();
|
sl@0
|
252 |
valueFontWithEffects = font2->DescentInPixels();
|
sl@0
|
253 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
254 |
|
sl@0
|
255 |
//Extended function
|
sl@0
|
256 |
valueFontWithoutEffects = font1->FontCapitalAscent();
|
sl@0
|
257 |
valueFontWithEffects = font2->FontCapitalAscent();
|
sl@0
|
258 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
259 |
|
sl@0
|
260 |
valueFontWithoutEffects = font1->FontLineGap();
|
sl@0
|
261 |
valueFontWithEffects = font2->FontLineGap();
|
sl@0
|
262 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
263 |
|
sl@0
|
264 |
valueFontWithoutEffects = font1->FontMaxAscent();
|
sl@0
|
265 |
valueFontWithEffects = font2->FontMaxAscent();
|
sl@0
|
266 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
267 |
|
sl@0
|
268 |
valueFontWithoutEffects = font1->FontMaxDescent();
|
sl@0
|
269 |
valueFontWithEffects = font2->FontMaxDescent();
|
sl@0
|
270 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
271 |
|
sl@0
|
272 |
valueFontWithoutEffects = font1->FontMaxHeight();
|
sl@0
|
273 |
valueFontWithEffects = font2->FontMaxHeight();
|
sl@0
|
274 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
275 |
|
sl@0
|
276 |
//FontSpecInTwips - will be different
|
sl@0
|
277 |
TFontSpec spec = font1->FontSpecInTwips();
|
sl@0
|
278 |
TFontSpec spec2 = font2->FontSpecInTwips();
|
sl@0
|
279 |
TEST(spec.iHeight == spec2.iHeight);
|
sl@0
|
280 |
valueFontWithoutEffects = font1->FontStandardDescent();
|
sl@0
|
281 |
valueFontWithEffects = font2->FontStandardDescent();
|
sl@0
|
282 |
TEST(valueFontWithoutEffects+KDifferByOne >= valueFontWithEffects);
|
sl@0
|
283 |
|
sl@0
|
284 |
valueFontWithoutEffects = font1->HeightInPixels();
|
sl@0
|
285 |
valueFontWithEffects = font2->HeightInPixels();
|
sl@0
|
286 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
287 |
|
sl@0
|
288 |
valueFontWithoutEffects = font1->MaxCharWidthInPixels();
|
sl@0
|
289 |
valueFontWithEffects = font2->MaxCharWidthInPixels();
|
sl@0
|
290 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
291 |
|
sl@0
|
292 |
valueFontWithoutEffects = font1->MaxNormalCharWidthInPixels();
|
sl@0
|
293 |
valueFontWithEffects = font2->MaxNormalCharWidthInPixels();
|
sl@0
|
294 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
295 |
|
sl@0
|
296 |
_LIT(KMeasureText,"ABCdef456");
|
sl@0
|
297 |
CFont::TMeasureTextOutput out1;
|
sl@0
|
298 |
CFont::TMeasureTextOutput out2;
|
sl@0
|
299 |
valueFontWithoutEffects = font1->MeasureText(KMeasureText,NULL,&out1);
|
sl@0
|
300 |
valueFontWithEffects = font2->MeasureText(KMeasureText,NULL,&out2);
|
sl@0
|
301 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
302 |
TEST(out1.iChars == out2.iChars);
|
sl@0
|
303 |
TEST(out1.iGlyphs == out2.iGlyphs);
|
sl@0
|
304 |
TEST(out1.iGroups == out2.iGroups);
|
sl@0
|
305 |
TEST(out1.iSpaces == out2.iSpaces);
|
sl@0
|
306 |
TEST(TestLessThanOrEqual(out1.iBounds.iTl.iX-KDifferByOne, out2.iBounds.iTl.iX));
|
sl@0
|
307 |
TEST(TestLessThanOrEqual(out1.iBounds.iTl.iY-KDifferByOne, out2.iBounds.iTl.iY));
|
sl@0
|
308 |
TEST(TestLessThanOrEqual(out1.iBounds.iBr.iX-KDifferByOne, out2.iBounds.iBr.iX));
|
sl@0
|
309 |
TEST(TestLessThanOrEqual(out1.iBounds.iBr.iY-KDifferByOne, out2.iBounds.iBr.iY));
|
sl@0
|
310 |
TEST(TestLessThanOrEqual(out1.iMaxGlyphSize.iHeight-KDifferByOne, out2.iMaxGlyphSize.iHeight));
|
sl@0
|
311 |
TEST(TestLessThanOrEqual(out1.iMaxGlyphSize.iWidth-KDifferByOne, out2.iMaxGlyphSize.iWidth));
|
sl@0
|
312 |
valueFontWithoutEffects = font1->TextCount(KMeasureText, 30);
|
sl@0
|
313 |
valueFontWithEffects = font2->TextCount(KMeasureText, 30);
|
sl@0
|
314 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
315 |
TInt val3;
|
sl@0
|
316 |
TInt val4;
|
sl@0
|
317 |
valueFontWithoutEffects = font1->TextCount(KMeasureText, 30, val3);
|
sl@0
|
318 |
valueFontWithEffects = font2->TextCount(KMeasureText, 30, val4);
|
sl@0
|
319 |
TEST(val3 == val4);
|
sl@0
|
320 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
321 |
valueFontWithoutEffects = font1->TextWidthInPixels(KMeasureText);
|
sl@0
|
322 |
valueFontWithEffects = font2->TextWidthInPixels(KMeasureText);
|
sl@0
|
323 |
TEST(TestRange(valueFontWithoutEffects, valueFontWithEffects, valueFontWithoutEffects+KDifferByThree));
|
sl@0
|
324 |
uid1 = font1->TypeUid();
|
sl@0
|
325 |
uid2 = font2->TypeUid();
|
sl@0
|
326 |
TEST(uid1 == uid2);
|
sl@0
|
327 |
for (TInt c=0;c<256;c++)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
const TUint8 *p1 = NULL;
|
sl@0
|
330 |
const TUint8 *p2 = NULL;
|
sl@0
|
331 |
TCharacterMetrics m1 = font1->CharacterMetrics(c, p1);
|
sl@0
|
332 |
TCharacterMetrics m2 = font2->CharacterMetrics(c, p2);
|
sl@0
|
333 |
TEST(TestLessThanOrEqual(m1.iAscentInPixels-KDifferByOne, m2.iAscentInPixels));
|
sl@0
|
334 |
TEST(TestLessThanOrEqual(m1.iHeightInPixels-KDifferByOne, m2.iHeightInPixels));
|
sl@0
|
335 |
TEST(TestLessThanOrEqual(m1.iLeftAdjustInPixels-KDifferByTwo, m2.iLeftAdjustInPixels));
|
sl@0
|
336 |
TEST(m1.iMoveInPixels == m2.iMoveInPixels);
|
sl@0
|
337 |
TEST(TestLessThanOrEqual(m1.iRightAdjustInPixels-KDifferByTwo, m2.iRightAdjustInPixels));
|
sl@0
|
338 |
}
|
sl@0
|
339 |
TOpenFontMetrics ofm1;
|
sl@0
|
340 |
TOpenFontMetrics ofm2;
|
sl@0
|
341 |
TBool r1 = font1->GetFontMetrics(ofm1);
|
sl@0
|
342 |
TBool r2 = font2->GetFontMetrics(ofm2);
|
sl@0
|
343 |
TEST(ofm1.Size() == ofm2.Size());
|
sl@0
|
344 |
TEST(ofm1.Ascent() == ofm2.Ascent());
|
sl@0
|
345 |
TEST(ofm1.Descent() == ofm2.Descent());
|
sl@0
|
346 |
TEST(ofm1.MaxHeight() == ofm2.MaxHeight());
|
sl@0
|
347 |
TEST(ofm1.MaxDepth() == ofm2.MaxDepth());
|
sl@0
|
348 |
TEST(ofm1.MaxWidth() == ofm2.MaxWidth());
|
sl@0
|
349 |
|
sl@0
|
350 |
valueFontWithoutEffects = font1->RawTextWidthInPixels(KMeasureText);
|
sl@0
|
351 |
valueFontWithEffects = font2->RawTextWidthInPixels(KMeasureText);
|
sl@0
|
352 |
TEST(valueFontWithoutEffects == valueFontWithEffects);
|
sl@0
|
353 |
|
sl@0
|
354 |
valueFontWithoutEffects = font1->TextWidthInPixels(KMeasureText);
|
sl@0
|
355 |
valueFontWithEffects = font2->TextWidthInPixels(KMeasureText);
|
sl@0
|
356 |
TEST(TestLessThanOrEqual(valueFontWithoutEffects, valueFontWithEffects));
|
sl@0
|
357 |
|
sl@0
|
358 |
SCharWidth scw1;
|
sl@0
|
359 |
SCharWidth scw2;
|
sl@0
|
360 |
font1->TextWidthInPixels(KMeasureText,scw1);
|
sl@0
|
361 |
font2->TextWidthInPixels(KMeasureText,scw2);
|
sl@0
|
362 |
TEST(TestLessThanOrEqual(scw1.iLeftAdjust-KDifferByOne, scw2.iLeftAdjust));
|
sl@0
|
363 |
TEST(scw1.iMove == scw2.iMove);
|
sl@0
|
364 |
TEST(TestLessThanOrEqual(scw1.iRightAdjust-KDifferByTwo, scw2.iRightAdjust));
|
sl@0
|
365 |
TEST(TestLessThanOrEqual(scw1.iWidth-KDifferByOne, scw2.iWidth));
|
sl@0
|
366 |
iBitmapDevice->ReleaseFont(font2);
|
sl@0
|
367 |
iBitmapDevice->ReleaseFont(font1);
|
sl@0
|
368 |
}
|
sl@0
|
369 |
|
sl@0
|
370 |
/**
|
sl@0
|
371 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0009
|
sl@0
|
372 |
|
sl@0
|
373 |
@SYMPREQ PREQ1543
|
sl@0
|
374 |
|
sl@0
|
375 |
@SYMTestCaseDesc Test the setter and getters for pen colour, brush colour and shadow colour.
|
sl@0
|
376 |
|
sl@0
|
377 |
@SYMTestPriority Critical
|
sl@0
|
378 |
|
sl@0
|
379 |
@SYMTestStatus Implemented
|
sl@0
|
380 |
|
sl@0
|
381 |
@SYMTestActions Set colors to pen, brush and shadow call SetPenColor(), SetBrushColor(), SetShadowColor() respectively
|
sl@0
|
382 |
Get colors of pen, brush and shadow using PenColor(), BrushColor() and GetShadowColor() respectively
|
sl@0
|
383 |
|
sl@0
|
384 |
@SYMTestExpectedResults pen, brush and shadow colour should return default colours if not set,
|
sl@0
|
385 |
else should return the colour set using SetPenColor(), SetBrushColor() and SetShadowColor() respectively
|
sl@0
|
386 |
*/
|
sl@0
|
387 |
void CTOutlineAndShadowFonts::TestOutlinePenAndShadowColorL()
|
sl@0
|
388 |
{
|
sl@0
|
389 |
INFO_PRINTF1(_L("TestOutlinePenAndShadowColorL()"));
|
sl@0
|
390 |
for(TInt displayMode = ENone; displayMode < KNumOfDisplayModes; displayMode++)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
FreeScreenDevice();
|
sl@0
|
393 |
CreateScreenDeviceL(KDisplayModes[displayMode]);
|
sl@0
|
394 |
DoOutlinePenAndShadowColor();
|
sl@0
|
395 |
}
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
/**
|
sl@0
|
399 |
Auxilary function called from TestOutlinePenAndShadowColorL
|
sl@0
|
400 |
API Calls:
|
sl@0
|
401 |
CFbsBitGc::PenColor()
|
sl@0
|
402 |
CFbsBitGc::SetPenColor()
|
sl@0
|
403 |
CFbsBitGc::BrushColor()
|
sl@0
|
404 |
CFbsBitGc::SetBrushColor()
|
sl@0
|
405 |
CFbsBitGc::GetShadowColor()
|
sl@0
|
406 |
CFbsBitGc::SetShadowColor()
|
sl@0
|
407 |
*/
|
sl@0
|
408 |
void CTOutlineAndShadowFonts::DoOutlinePenAndShadowColor()
|
sl@0
|
409 |
{
|
sl@0
|
410 |
//iGc->Reset();
|
sl@0
|
411 |
TRgb color;
|
sl@0
|
412 |
color = iGc->PenColor();
|
sl@0
|
413 |
|
sl@0
|
414 |
//Pen colour is used for drawing outline
|
sl@0
|
415 |
TEST(color == KDefaultOutlinePenColor);
|
sl@0
|
416 |
color = iGc->BrushColor();
|
sl@0
|
417 |
|
sl@0
|
418 |
//Brush colour is used as fill colour
|
sl@0
|
419 |
TEST(color == KDefaultFillColor);
|
sl@0
|
420 |
iGc->GetShadowColor(color);
|
sl@0
|
421 |
TEST(color == KDefaultShadowColor);
|
sl@0
|
422 |
iGc->SetShadowColor(KRgbGreen);
|
sl@0
|
423 |
iGc->GetShadowColor(color);
|
sl@0
|
424 |
TEST(color == KRgbGreen);
|
sl@0
|
425 |
iGc->SetPenColor(KRgbYellow);
|
sl@0
|
426 |
color = iGc->PenColor();
|
sl@0
|
427 |
TEST(color == KRgbYellow);
|
sl@0
|
428 |
iGc->SetBrushColor(KRgbRed);
|
sl@0
|
429 |
color = iGc->BrushColor();
|
sl@0
|
430 |
TEST(color == KRgbRed);
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
/**
|
sl@0
|
434 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0010
|
sl@0
|
435 |
|
sl@0
|
436 |
@SYMPREQ PREQ1543
|
sl@0
|
437 |
|
sl@0
|
438 |
@SYMTestCaseDesc Tests the text drawn using DrawTextVertical and DrawText with shadow and outline effects on
|
sl@0
|
439 |
with different display modes and orientations.
|
sl@0
|
440 |
|
sl@0
|
441 |
@SYMTestPriority Critical
|
sl@0
|
442 |
|
sl@0
|
443 |
@SYMTestStatus Implemented
|
sl@0
|
444 |
|
sl@0
|
445 |
@SYMTestActions Call DrawTextVertical and DrawText with different effect on, display modes and orientations.
|
sl@0
|
446 |
API Calls:
|
sl@0
|
447 |
CFbsBitGc::DrawTextVertical()
|
sl@0
|
448 |
CFbsBitGc::DrawText()
|
sl@0
|
449 |
CTOutlineAndShadowFonts::CompareHashValuesL()
|
sl@0
|
450 |
|
sl@0
|
451 |
@SYMTestExpectedResults Hash generated for the drawn text should be same with the baselined hash value.
|
sl@0
|
452 |
*/
|
sl@0
|
453 |
void CTOutlineAndShadowFonts::TestDrawTextWithOutlineAndShadowL()
|
sl@0
|
454 |
{
|
sl@0
|
455 |
INFO_PRINTF1(_L("TestDrawTextWithOutlineAndShadowL()"));
|
sl@0
|
456 |
for(TInt displayMode = 0; displayMode < KNumOfDisplayModes; displayMode++)
|
sl@0
|
457 |
{
|
sl@0
|
458 |
FreeScreenDevice();
|
sl@0
|
459 |
CreateScreenDeviceL(KDisplayModes[displayMode]);
|
sl@0
|
460 |
INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[displayMode]);
|
sl@0
|
461 |
for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
|
sl@0
|
462 |
{
|
sl@0
|
463 |
iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
|
sl@0
|
464 |
for (TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
|
sl@0
|
465 |
{
|
sl@0
|
466 |
for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0010; numOfSubTests++)
|
sl@0
|
467 |
{
|
sl@0
|
468 |
//Test with only one display mode i.e. EColor16MU for EMonochromeGlyphBitmap to reduce test execution time
|
sl@0
|
469 |
if ((KTestSettingsToTestOutlineAndShadow[numOfSubTests].fSpecAndGcSettings & ESetMonochromeGlyphBitmap) && (displayMode != EColor16MU))
|
sl@0
|
470 |
{
|
sl@0
|
471 |
continue;
|
sl@0
|
472 |
}
|
sl@0
|
473 |
|
sl@0
|
474 |
//Test transparency for display mode EColor64K and above as it is not supported in other display modes
|
sl@0
|
475 |
if (KTestSettingsToTestOutlineAndShadow[numOfSubTests].penColor.Alpha() < 255 && displayMode < 6)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
continue;
|
sl@0
|
478 |
}
|
sl@0
|
479 |
HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC(KTestName0010, numOfSubTests, KFontFaceShortName, fontFaceIndex, displayMode, orient);
|
sl@0
|
480 |
DoDrawTextWithOutlineAndShadowL(KTestSettingsToTestOutlineAndShadow[numOfSubTests], *hashIdString, fontFaceIndex);
|
sl@0
|
481 |
CleanupStack::PopAndDestroy(hashIdString);
|
sl@0
|
482 |
}
|
sl@0
|
483 |
}
|
sl@0
|
484 |
}
|
sl@0
|
485 |
}
|
sl@0
|
486 |
iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
/**
|
sl@0
|
490 |
Auxilary function called TestDrawTextWithOutlineAndShadowL.
|
sl@0
|
491 |
@param aSettings holds the effects settings (Outline, Shadow, Bitmap type etc...)
|
sl@0
|
492 |
@param aHashIdString holds the HashID string
|
sl@0
|
493 |
@param aFontIndex holds the font index
|
sl@0
|
494 |
*/
|
sl@0
|
495 |
void CTOutlineAndShadowFonts::DoDrawTextWithOutlineAndShadowL(const STestFontParameters &aSettings, const TDesC& aHashIdString, const TInt aFontIndex)
|
sl@0
|
496 |
{
|
sl@0
|
497 |
TFontSpec fontSpec;
|
sl@0
|
498 |
PrepareTestEnvironment(fontSpec, aSettings, aFontIndex, ETrue, ETrue);
|
sl@0
|
499 |
CFont* font;
|
sl@0
|
500 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone);
|
sl@0
|
501 |
SCleanFont cleanupFont = {iBitmapDevice, font};
|
sl@0
|
502 |
CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont));
|
sl@0
|
503 |
iGc->UseFont(font);
|
sl@0
|
504 |
if(EVerticalDraw & aSettings.fSpecAndGcSettings)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
iGc->DrawTextVertical(KTextPhrase, TPoint(20,60), ERotate90Degrees & aSettings.fSpecAndGcSettings);
|
sl@0
|
507 |
}
|
sl@0
|
508 |
else
|
sl@0
|
509 |
{
|
sl@0
|
510 |
iGc->DrawText(KTextPhrase, KPoint);
|
sl@0
|
511 |
}
|
sl@0
|
512 |
iHashUtil->CompareHashValuesL(aHashIdString);
|
sl@0
|
513 |
CleanupStack::Pop();//font
|
sl@0
|
514 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
515 |
iGc->DiscardFont();
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|
sl@0
|
518 |
/**
|
sl@0
|
519 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0011
|
sl@0
|
520 |
|
sl@0
|
521 |
@SYMPREQ PREQ1543
|
sl@0
|
522 |
|
sl@0
|
523 |
@SYMTestCaseDesc Tests outline and shadow effects with strikethrough, softedge and underLine
|
sl@0
|
524 |
for different orientations.
|
sl@0
|
525 |
|
sl@0
|
526 |
@SYMTestPriority Critical
|
sl@0
|
527 |
|
sl@0
|
528 |
@SYMTestStatus Implemented
|
sl@0
|
529 |
|
sl@0
|
530 |
@SYMTestActions Draw text with different effects on
|
sl@0
|
531 |
Repeat the same with all supported display modes and orientations. Generate hash key for the drawn text.
|
sl@0
|
532 |
API Calls:
|
sl@0
|
533 |
CFbsBitGc::DrawText()
|
sl@0
|
534 |
CTHashReferenceImages::CompareHashValuesL()
|
sl@0
|
535 |
|
sl@0
|
536 |
@SYMTestExpectedResults Hash generated for the drawn text should be same with the baselined hash value.
|
sl@0
|
537 |
*/
|
sl@0
|
538 |
void CTOutlineAndShadowFonts::TestDrawTextWithStrikeThroughL()
|
sl@0
|
539 |
{
|
sl@0
|
540 |
INFO_PRINTF1(_L("TestDrawTextWithStrikeThroughL()"));
|
sl@0
|
541 |
for(TInt displayMode = 0; displayMode < KNumOfDisplayModes; displayMode++)
|
sl@0
|
542 |
{
|
sl@0
|
543 |
INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[displayMode]);
|
sl@0
|
544 |
FreeScreenDevice();
|
sl@0
|
545 |
CreateScreenDeviceL(KDisplayModes[displayMode]);
|
sl@0
|
546 |
|
sl@0
|
547 |
for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0011; numOfSubTests++)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC(KTestName0011, numOfSubTests, &(KFontFace[0]), 0, displayMode, 0);
|
sl@0
|
550 |
DoSetStrikeThroughAndDrawTestL(KTestSettingsToTestStrikeAndUnderline[numOfSubTests], *hashIdString);
|
sl@0
|
551 |
CleanupStack::PopAndDestroy(hashIdString);
|
sl@0
|
552 |
}
|
sl@0
|
553 |
}
|
sl@0
|
554 |
}
|
sl@0
|
555 |
|
sl@0
|
556 |
/**
|
sl@0
|
557 |
Auxilary function called from TestDrawTextWithStrikeThroughL API
|
sl@0
|
558 |
@SYMTestCaseDesc Tests drawn text with different effects like
|
sl@0
|
559 |
strikethrough, softedge, underLine etc for different orientations.
|
sl@0
|
560 |
@param aSettings holds font settings
|
sl@0
|
561 |
@param aHashIdString holds HashID
|
sl@0
|
562 |
*/
|
sl@0
|
563 |
void CTOutlineAndShadowFonts::DoSetStrikeThroughAndDrawTestL(const STestFontParameters &aSettings, const TDesC& aHashIdString)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
TFontSpec fontSpec;
|
sl@0
|
566 |
//Passing 0 as font index as testing with one typeface is sufficient in this case
|
sl@0
|
567 |
PrepareTestEnvironment(fontSpec, aSettings, 0, ETrue, EFalse);
|
sl@0
|
568 |
|
sl@0
|
569 |
CFont* font;
|
sl@0
|
570 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone);
|
sl@0
|
571 |
SCleanFont cleanupFont = {iBitmapDevice, font};
|
sl@0
|
572 |
CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont));
|
sl@0
|
573 |
iGc->UseFont(font);
|
sl@0
|
574 |
iGc->DrawText(KTextPhrase,KPoint);
|
sl@0
|
575 |
iHashUtil->CompareHashValuesL(aHashIdString);
|
sl@0
|
576 |
CleanupStack::Pop();//font
|
sl@0
|
577 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
578 |
iGc->DiscardFont();
|
sl@0
|
579 |
}
|
sl@0
|
580 |
|
sl@0
|
581 |
/**
|
sl@0
|
582 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0012
|
sl@0
|
583 |
|
sl@0
|
584 |
@SYMTestCaseDesc Negative tests.
|
sl@0
|
585 |
|
sl@0
|
586 |
@SYMTestPriority Critical
|
sl@0
|
587 |
|
sl@0
|
588 |
@SYMTestStatus Implemented
|
sl@0
|
589 |
|
sl@0
|
590 |
@SYMTestActions Create font spec with different -ve scenarios.
|
sl@0
|
591 |
Like pass bitmap type other than valid on, -ve pen size etc.
|
sl@0
|
592 |
|
sl@0
|
593 |
API Calls:
|
sl@0
|
594 |
CFbsBitGc::GetNearestFontToDesignHeightInPixels()
|
sl@0
|
595 |
TFontStyle::SetEffects()
|
sl@0
|
596 |
|
sl@0
|
597 |
@SYMTestExpectedResults Tests should not panic.
|
sl@0
|
598 |
*/
|
sl@0
|
599 |
void CTOutlineAndShadowFonts::NegativeRastTestL()
|
sl@0
|
600 |
{
|
sl@0
|
601 |
INFO_PRINTF1(_L("NegativeRastTestL()"));
|
sl@0
|
602 |
FreeScreenDevice();
|
sl@0
|
603 |
CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
|
sl@0
|
604 |
|
sl@0
|
605 |
TFontSpec fsp;
|
sl@0
|
606 |
STestFontParameters settings;
|
sl@0
|
607 |
|
sl@0
|
608 |
INFO_PRINTF1(_L("Drawing empty text"));
|
sl@0
|
609 |
settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
610 |
PrepareTestEnvironment(fsp, settings, 0);
|
sl@0
|
611 |
iGc->SetPenSize(TSize(10,10));
|
sl@0
|
612 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
613 |
|
sl@0
|
614 |
INFO_PRINTF1(_L("Drawing empty text with unknown typeface"));
|
sl@0
|
615 |
fsp.iTypeface.iName=_L("ERROR FONT"); //Typeface which does not exist
|
sl@0
|
616 |
iGc->SetPenSize(TSize(3,3));
|
sl@0
|
617 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
618 |
|
sl@0
|
619 |
INFO_PRINTF1(_L("Drawing empty text with invalid glyph bitmap type"));
|
sl@0
|
620 |
fsp.iFontStyle.SetBitmapType((TGlyphBitmapType)KInvalidBitmapType); //Invalid glyph bitmap type
|
sl@0
|
621 |
CFont* font;
|
sl@0
|
622 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fsp) == KErrNone);
|
sl@0
|
623 |
iGc->UseFont(font);
|
sl@0
|
624 |
iGc->DrawText(KTextPhrase,KPoint);
|
sl@0
|
625 |
TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EMonochromeGlyphBitmap);
|
sl@0
|
626 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
627 |
iGc->DiscardFont();
|
sl@0
|
628 |
|
sl@0
|
629 |
INFO_PRINTF1(_L("Drawing text with brush style ENullBrush"));
|
sl@0
|
630 |
iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
|
sl@0
|
631 |
settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
632 |
PrepareTestEnvironment(fsp, settings, 0);
|
sl@0
|
633 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
634 |
|
sl@0
|
635 |
INFO_PRINTF1(_L("Drawing text with brush style ESolidBrush"));
|
sl@0
|
636 |
iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
637 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
638 |
|
sl@0
|
639 |
INFO_PRINTF1(_L("Drawing text with large pen size"));
|
sl@0
|
640 |
iGc->SetPenSize(TSize(1000,1000));
|
sl@0
|
641 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
642 |
|
sl@0
|
643 |
INFO_PRINTF1(_L("Drawing text with -ve pen size"));
|
sl@0
|
644 |
settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
645 |
PrepareTestEnvironment(fsp, settings, 0);
|
sl@0
|
646 |
iGc->SetPenSize(TSize(-1,-1));
|
sl@0
|
647 |
NegativeRastTestDrawText(fsp);
|
sl@0
|
648 |
}
|
sl@0
|
649 |
|
sl@0
|
650 |
/**
|
sl@0
|
651 |
Auxilary function called from NegativeRastTestL
|
sl@0
|
652 |
@param aFontSpec holds fonts specifications
|
sl@0
|
653 |
*/
|
sl@0
|
654 |
void CTOutlineAndShadowFonts::NegativeRastTestDrawText(const TFontSpec &aFontSpec)
|
sl@0
|
655 |
{
|
sl@0
|
656 |
CFont* font;
|
sl@0
|
657 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, aFontSpec) == KErrNone);
|
sl@0
|
658 |
iGc->UseFont(font);
|
sl@0
|
659 |
iGc->DrawText(KTextPhrase, KPoint);
|
sl@0
|
660 |
iGc->DrawTextVertical(KTextPhrase, KPoint, EFalse);
|
sl@0
|
661 |
iGc->DiscardFont();
|
sl@0
|
662 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
/**
|
sl@0
|
666 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0013
|
sl@0
|
667 |
|
sl@0
|
668 |
@SYMPREQ PREQ1543
|
sl@0
|
669 |
|
sl@0
|
670 |
@SYMTestCaseDesc Test glyph bitmap types with outline and shadow effects on and off
|
sl@0
|
671 |
|
sl@0
|
672 |
@SYMTestPriority Critical
|
sl@0
|
673 |
|
sl@0
|
674 |
@SYMTestStatus Implemented
|
sl@0
|
675 |
|
sl@0
|
676 |
@SYMTestActions Create fonts with and without specifying the bitmap type
|
sl@0
|
677 |
API Calls:
|
sl@0
|
678 |
TFontStyle::BitmapType()
|
sl@0
|
679 |
|
sl@0
|
680 |
@SYMTestExpectedResults Glyph bitmap type should be EFourColourBlendGlyphBitmap when either of outline or shadow effect on and EAntiAliasedGlyphBitmap set in fontspec
|
sl@0
|
681 |
*/
|
sl@0
|
682 |
void CTOutlineAndShadowFonts::TestCheckBitmapTypesL()
|
sl@0
|
683 |
{
|
sl@0
|
684 |
INFO_PRINTF1(_L("TestCheckBitmapTypesL()"));
|
sl@0
|
685 |
FreeScreenDevice();
|
sl@0
|
686 |
CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
|
sl@0
|
687 |
|
sl@0
|
688 |
CFont* font;
|
sl@0
|
689 |
TFontSpec fontSpec;
|
sl@0
|
690 |
STestFontParameters settings;
|
sl@0
|
691 |
|
sl@0
|
692 |
PrepareTestEnvironment(fontSpec, settings, 0);
|
sl@0
|
693 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
|
sl@0
|
694 |
//Check for the bitmap type to be EMonochromeGlyphBitmap when no bitmap type is set.
|
sl@0
|
695 |
TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EMonochromeGlyphBitmap);
|
sl@0
|
696 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
697 |
|
sl@0
|
698 |
settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
699 |
PrepareTestEnvironment(fontSpec, settings, 0);
|
sl@0
|
700 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
|
sl@0
|
701 |
//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
|
sl@0
|
702 |
//EDropShadow or EOutline effects are on.
|
sl@0
|
703 |
TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
|
sl@0
|
704 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
705 |
|
sl@0
|
706 |
settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
707 |
PrepareTestEnvironment(fontSpec, settings, 0);
|
sl@0
|
708 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
|
sl@0
|
709 |
//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
|
sl@0
|
710 |
//EDropShadow or EOutline effects are on.
|
sl@0
|
711 |
TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
|
sl@0
|
712 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
713 |
|
sl@0
|
714 |
settings.fSpecAndGcSettings = EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
715 |
PrepareTestEnvironment(fontSpec, settings, 0);
|
sl@0
|
716 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
|
sl@0
|
717 |
//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
|
sl@0
|
718 |
//EDropShadow or EOutline effects are on.
|
sl@0
|
719 |
TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
|
sl@0
|
720 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
721 |
}
|
sl@0
|
722 |
|
sl@0
|
723 |
/**
|
sl@0
|
724 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0014
|
sl@0
|
725 |
|
sl@0
|
726 |
@SYMPREQ PREQ1543
|
sl@0
|
727 |
|
sl@0
|
728 |
@SYMTestCaseDesc OOM tests, checks OOM condition for GetNearestFontToDesignHeightInPixels.
|
sl@0
|
729 |
|
sl@0
|
730 |
@SYMTestPriority Critical
|
sl@0
|
731 |
|
sl@0
|
732 |
@SYMTestStatus Implemented
|
sl@0
|
733 |
|
sl@0
|
734 |
@SYMTestActions
|
sl@0
|
735 |
API Calls:
|
sl@0
|
736 |
CFbsBitGc::GetNearestFontToDesignHeightInPixels()
|
sl@0
|
737 |
TFontStyle::SetEffects()
|
sl@0
|
738 |
|
sl@0
|
739 |
@SYMTestExpectedResults Checks the OOM condition and finds if it takes care of OOM cases for GetNearestFontToDesignHeightInPixels
|
sl@0
|
740 |
*/
|
sl@0
|
741 |
void CTOutlineAndShadowFonts::TestOOML()
|
sl@0
|
742 |
{
|
sl@0
|
743 |
INFO_PRINTF1(_L("TestOOML()"));
|
sl@0
|
744 |
FreeScreenDevice();
|
sl@0
|
745 |
CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
|
sl@0
|
746 |
|
sl@0
|
747 |
//OOM for normal text
|
sl@0
|
748 |
for(TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
|
sl@0
|
749 |
{
|
sl@0
|
750 |
DoOOM(fontFaceIndex, EFalse);
|
sl@0
|
751 |
}
|
sl@0
|
752 |
}
|
sl@0
|
753 |
|
sl@0
|
754 |
/**
|
sl@0
|
755 |
Auxilary function called from TestOOML API
|
sl@0
|
756 |
@SYMTestCaseDesc checks OOM condition for DrawText() and DrawTextVertical().
|
sl@0
|
757 |
@param aFontSpec holds font specifications
|
sl@0
|
758 |
@param aDrawVerticalText holds bool, if true calls DrawTextVertical else calls DrawText api's
|
sl@0
|
759 |
*/
|
sl@0
|
760 |
void CTOutlineAndShadowFonts::DoOOM(TInt aFontIndex, TBool aDrawVerticalText)
|
sl@0
|
761 |
{
|
sl@0
|
762 |
__UHEAP_RESET;
|
sl@0
|
763 |
TFontSpec fSpec;
|
sl@0
|
764 |
STestFontParameters settings;
|
sl@0
|
765 |
settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
766 |
PrepareTestEnvironment(fSpec, settings, aFontIndex);
|
sl@0
|
767 |
|
sl@0
|
768 |
//GetNearestFontToDesignHeightInPixels
|
sl@0
|
769 |
iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
|
sl@0
|
770 |
CFont* font = NULL;
|
sl@0
|
771 |
TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels(font,fSpec) == KErrNone);
|
sl@0
|
772 |
TInt ret;
|
sl@0
|
773 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
774 |
for (TInt count = 1; ; count++)
|
sl@0
|
775 |
{
|
sl@0
|
776 |
__UHEAP_SETFAIL(RHeap::EDeterministic,count);
|
sl@0
|
777 |
__UHEAP_MARK;
|
sl@0
|
778 |
font=NULL;
|
sl@0
|
779 |
ret = iBitmapDevice->GetNearestFontToDesignHeightInPixels(font,fSpec);
|
sl@0
|
780 |
if (ret == KErrNoMemory)
|
sl@0
|
781 |
{
|
sl@0
|
782 |
ASSERT(!font);
|
sl@0
|
783 |
__UHEAP_MARKEND;
|
sl@0
|
784 |
}
|
sl@0
|
785 |
else if (ret == KErrNone)
|
sl@0
|
786 |
{
|
sl@0
|
787 |
ASSERT(font);
|
sl@0
|
788 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
789 |
__UHEAP_MARKEND;
|
sl@0
|
790 |
break;
|
sl@0
|
791 |
}
|
sl@0
|
792 |
else
|
sl@0
|
793 |
{
|
sl@0
|
794 |
__UHEAP_MARKEND;
|
sl@0
|
795 |
TEST(ret == KErrNone);
|
sl@0
|
796 |
}
|
sl@0
|
797 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
798 |
}
|
sl@0
|
799 |
|
sl@0
|
800 |
//DrawText and DrawTextVertical with EDropShadow effect on and EOutline effect off
|
sl@0
|
801 |
settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
802 |
settings.brushColor = KRgbBlack;
|
sl@0
|
803 |
settings.penColor = KRgbGreen;
|
sl@0
|
804 |
settings.shadowColor = KRgbRed;
|
sl@0
|
805 |
PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
|
sl@0
|
806 |
GetFontAndDrawOOM(fSpec, aDrawVerticalText);
|
sl@0
|
807 |
|
sl@0
|
808 |
//DrawText and DrawTextVertical with EDropShadow effect off and EOutline effect on
|
sl@0
|
809 |
settings.fSpecAndGcSettings = EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
810 |
PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
|
sl@0
|
811 |
GetFontAndDrawOOM(fSpec, aDrawVerticalText);
|
sl@0
|
812 |
|
sl@0
|
813 |
//DrawText and DrawTextVertical with EDropShadow effect on and EOutline effect on
|
sl@0
|
814 |
settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
|
sl@0
|
815 |
PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
|
sl@0
|
816 |
GetFontAndDrawOOM(fSpec, aDrawVerticalText);
|
sl@0
|
817 |
|
sl@0
|
818 |
__UHEAP_RESET;
|
sl@0
|
819 |
}
|
sl@0
|
820 |
|
sl@0
|
821 |
/**
|
sl@0
|
822 |
Auxilary function called from DoOOM API
|
sl@0
|
823 |
@SYMTestCaseDesc checks OOM condition for DrawText() and DrawTextVertical().
|
sl@0
|
824 |
@param aFontSpec holds font specifications
|
sl@0
|
825 |
@param aDrawVerticalText holds bool value, if true calls DrawTextVertical else calls DrawText api's
|
sl@0
|
826 |
*/
|
sl@0
|
827 |
void CTOutlineAndShadowFonts::GetFontAndDrawOOM(TFontSpec aFontSpec, TBool aDrawVerticalText)
|
sl@0
|
828 |
{
|
sl@0
|
829 |
__UHEAP_RESET;
|
sl@0
|
830 |
_LIT(KDRAWME,"Outline and Shadow");
|
sl@0
|
831 |
CFont* font = NULL;
|
sl@0
|
832 |
iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
|
sl@0
|
833 |
TInt ret= iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, aFontSpec);
|
sl@0
|
834 |
TEST(ret == KErrNone);
|
sl@0
|
835 |
for (TInt count = 1; ; count++)
|
sl@0
|
836 |
{
|
sl@0
|
837 |
__UHEAP_SETFAIL(RHeap::EDeterministic,count);
|
sl@0
|
838 |
__UHEAP_MARK;
|
sl@0
|
839 |
iGc->UseFont(font);
|
sl@0
|
840 |
if (aDrawVerticalText)
|
sl@0
|
841 |
{
|
sl@0
|
842 |
iGc->DrawTextVertical(KDRAWME, TPoint(3, 4), EFalse);
|
sl@0
|
843 |
}
|
sl@0
|
844 |
else
|
sl@0
|
845 |
{
|
sl@0
|
846 |
iGc->DrawText(KDRAWME, TPoint(3, 4));
|
sl@0
|
847 |
}
|
sl@0
|
848 |
if (ret == KErrNoMemory)
|
sl@0
|
849 |
{
|
sl@0
|
850 |
iGc->DrawTextVertical(KDRAWME, TPoint(3, 4), EFalse);
|
sl@0
|
851 |
__UHEAP_MARKEND;
|
sl@0
|
852 |
}
|
sl@0
|
853 |
else if (ret == KErrNone)
|
sl@0
|
854 |
{
|
sl@0
|
855 |
ASSERT(font);
|
sl@0
|
856 |
iBitmapDevice->ReleaseFont(font);
|
sl@0
|
857 |
iGc->DiscardFont();
|
sl@0
|
858 |
__UHEAP_MARKEND;
|
sl@0
|
859 |
break;
|
sl@0
|
860 |
}
|
sl@0
|
861 |
else
|
sl@0
|
862 |
{
|
sl@0
|
863 |
__UHEAP_MARKEND;
|
sl@0
|
864 |
TEST(ret == KErrNone);
|
sl@0
|
865 |
}
|
sl@0
|
866 |
}
|
sl@0
|
867 |
}
|
sl@0
|
868 |
|
sl@0
|
869 |
/**
|
sl@0
|
870 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0015
|
sl@0
|
871 |
|
sl@0
|
872 |
@SYMPREQ PREQ2555
|
sl@0
|
873 |
|
sl@0
|
874 |
@SYMTestCaseDesc Check bitmaptype EAntiAliasedOrMonochromeGlyphBitmap returns the correct actual
|
sl@0
|
875 |
bitmap type. This test uses the "Series 60 Sans SemiBold" font.
|
sl@0
|
876 |
Sizes 0-7:monochrome; 8-16:anti-aliased; 16 and above:monochrome.
|
sl@0
|
877 |
|
sl@0
|
878 |
@SYMTestPriority Normal
|
sl@0
|
879 |
|
sl@0
|
880 |
@SYMTestStatus Implemented
|
sl@0
|
881 |
|
sl@0
|
882 |
@SYMTestActions
|
sl@0
|
883 |
Set the font size of the test font to 6, 12, 20 respectively and the bitmap type to EAntiAliasedOrMonochromeGlyphBitmap.
|
sl@0
|
884 |
Then call CFbsDevice::GetNearestFontToDesignHeightInPixels() to return the font and draw a text string on the left side of
|
sl@0
|
885 |
the bitmap. Draw the same string using the reference font on the right side of the bitmap. Use CFbsDevice::RectCompare()
|
sl@0
|
886 |
to compare the two halves of the bitmap.
|
sl@0
|
887 |
|
sl@0
|
888 |
@SYMTestExpectedResults The two halves should be the same.
|
sl@0
|
889 |
*/
|
sl@0
|
890 |
void CTOutlineAndShadowFonts::TestAntiAliasedOrMonochromeGlyphBitmapL()
|
sl@0
|
891 |
{
|
sl@0
|
892 |
iGc->Reset();
|
sl@0
|
893 |
FreeScreenDevice();
|
sl@0
|
894 |
CreateScreenDeviceL(EColor64K);
|
sl@0
|
895 |
_LIT(KGaspTypefaceName, "Series 60 Sans SemiBold");
|
sl@0
|
896 |
TFontSpec testFontSpec;
|
sl@0
|
897 |
testFontSpec.iTypeface.iName = KGaspTypefaceName;
|
sl@0
|
898 |
testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedOrMonochromeGlyphBitmap);
|
sl@0
|
899 |
TFontSpec refFontSpec;
|
sl@0
|
900 |
refFontSpec.iTypeface.iName = KGaspTypefaceName;
|
sl@0
|
901 |
|
sl@0
|
902 |
TInt fontsizes[3] = {6, 12, 20};
|
sl@0
|
903 |
CFont* testFont;
|
sl@0
|
904 |
CFont* refFont;
|
sl@0
|
905 |
TPoint leftMidPoint = TPoint(KScreenWidth/4, KScreenHeight/2);
|
sl@0
|
906 |
TPoint rightMidPoint = TPoint(KScreenWidth*3/4, KScreenHeight/2);
|
sl@0
|
907 |
_LIT(KTestString, "Abcde");
|
sl@0
|
908 |
|
sl@0
|
909 |
//anti-aliased
|
sl@0
|
910 |
testFontSpec.iHeight = fontsizes[0];
|
sl@0
|
911 |
refFontSpec.iHeight = fontsizes[0];
|
sl@0
|
912 |
refFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
|
sl@0
|
913 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
|
sl@0
|
914 |
iGc->UseFont(testFont);
|
sl@0
|
915 |
iGc->DrawText(KTestString, leftMidPoint);
|
sl@0
|
916 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
|
sl@0
|
917 |
iGc->UseFont(refFont);
|
sl@0
|
918 |
iGc->DrawText(KTestString, rightMidPoint);
|
sl@0
|
919 |
TBool testPassed = iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight));
|
sl@0
|
920 |
TEST(testPassed);
|
sl@0
|
921 |
if (!testPassed)
|
sl@0
|
922 |
{
|
sl@0
|
923 |
TFontSpec fontSpec = testFont->FontSpecInTwips();
|
sl@0
|
924 |
INFO_PRINTF3(_L("Test font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
925 |
fontSpec = refFont->FontSpecInTwips();
|
sl@0
|
926 |
INFO_PRINTF3(_L("Ref font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
927 |
}
|
sl@0
|
928 |
iBitmapDevice->ReleaseFont(testFont);
|
sl@0
|
929 |
iBitmapDevice->ReleaseFont(refFont);
|
sl@0
|
930 |
|
sl@0
|
931 |
//monochrome
|
sl@0
|
932 |
iGc->Clear();
|
sl@0
|
933 |
testFontSpec.iHeight = fontsizes[1];
|
sl@0
|
934 |
refFontSpec.iHeight = fontsizes[1];
|
sl@0
|
935 |
refFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap);
|
sl@0
|
936 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
|
sl@0
|
937 |
iGc->UseFont(testFont);
|
sl@0
|
938 |
iGc->DrawText(KTestString, leftMidPoint);
|
sl@0
|
939 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
|
sl@0
|
940 |
iGc->UseFont(refFont);
|
sl@0
|
941 |
iGc->DrawText(KTestString, rightMidPoint);
|
sl@0
|
942 |
testPassed = iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight));
|
sl@0
|
943 |
TEST(testPassed);
|
sl@0
|
944 |
if (!testPassed)
|
sl@0
|
945 |
{
|
sl@0
|
946 |
TFontSpec fontSpec = testFont->FontSpecInTwips();
|
sl@0
|
947 |
INFO_PRINTF3(_L("Test font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
948 |
fontSpec = refFont->FontSpecInTwips();
|
sl@0
|
949 |
INFO_PRINTF3(_L("Ref font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
950 |
}
|
sl@0
|
951 |
iBitmapDevice->ReleaseFont(testFont);
|
sl@0
|
952 |
iBitmapDevice->ReleaseFont(refFont);
|
sl@0
|
953 |
|
sl@0
|
954 |
//anti-aliased
|
sl@0
|
955 |
iGc->Clear();
|
sl@0
|
956 |
testFontSpec.iHeight = fontsizes[2];
|
sl@0
|
957 |
refFontSpec.iHeight = fontsizes[2];
|
sl@0
|
958 |
refFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
|
sl@0
|
959 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
|
sl@0
|
960 |
iGc->UseFont(testFont);
|
sl@0
|
961 |
iGc->DrawText(KTestString, leftMidPoint);
|
sl@0
|
962 |
User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
|
sl@0
|
963 |
iGc->UseFont(refFont);
|
sl@0
|
964 |
iGc->DrawText(KTestString, rightMidPoint);
|
sl@0
|
965 |
testPassed = iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight));
|
sl@0
|
966 |
TEST(testPassed);
|
sl@0
|
967 |
if (!testPassed)
|
sl@0
|
968 |
{
|
sl@0
|
969 |
TFontSpec fontSpec = testFont->FontSpecInTwips();
|
sl@0
|
970 |
INFO_PRINTF3(_L("Test font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
971 |
fontSpec = refFont->FontSpecInTwips();
|
sl@0
|
972 |
INFO_PRINTF3(_L("Ref font: %S, height in twips = %d"), &fontSpec.iTypeface.Name(), fontSpec.iHeight);
|
sl@0
|
973 |
}
|
sl@0
|
974 |
iBitmapDevice->ReleaseFont(testFont);
|
sl@0
|
975 |
iBitmapDevice->ReleaseFont(refFont);
|
sl@0
|
976 |
}
|
sl@0
|
977 |
/**
|
sl@0
|
978 |
Sets the fontspec and gc attributes according to the flags set in STestFontParameters for the test.
|
sl@0
|
979 |
Before setting gc attributes it is cleared and reset.
|
sl@0
|
980 |
@param aFontSpec holds all effective font settings
|
sl@0
|
981 |
@param aSettings holds the flags for setting the fontspec and gc
|
sl@0
|
982 |
@param aFontIndex the fonts index of KFontFace to be set as typeface
|
sl@0
|
983 |
@param aSetEffects ETrue will set the effects on in fontspec if their flags are enabled. By default it is ETrue.
|
sl@0
|
984 |
@param aSetColors ETrue will set the colours in gc from STestFontParameters. By default it is EFalse.
|
sl@0
|
985 |
*/
|
sl@0
|
986 |
void CTOutlineAndShadowFonts::PrepareTestEnvironment(TFontSpec &aFontSpec, const STestFontParameters &aSettings, const TInt aFontIndex, TBool aSetEffects, TBool aSetColors)
|
sl@0
|
987 |
{
|
sl@0
|
988 |
//Set the typeface from the font face array
|
sl@0
|
989 |
aFontSpec.iTypeface.iName = KFontFace[aFontIndex];
|
sl@0
|
990 |
aFontSpec.iHeight = KHeight;
|
sl@0
|
991 |
|
sl@0
|
992 |
//Set the effects on if any of flags for the effects are set in aSettings and aSetEffects is ETrue
|
sl@0
|
993 |
if(aSetEffects)
|
sl@0
|
994 |
{
|
sl@0
|
995 |
aFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn & aSettings.fSpecAndGcSettings);
|
sl@0
|
996 |
aFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn & aSettings.fSpecAndGcSettings);
|
sl@0
|
997 |
aFontSpec.iFontStyle.SetEffects(FontEffect::ESoftEdge, ESoftEdgeOn & aSettings.fSpecAndGcSettings);
|
sl@0
|
998 |
aFontSpec.iFontStyle.SetEffects(FontEffect::EAlgorithmicBold, EAlgorithmicBoldOn & aSettings.fSpecAndGcSettings);
|
sl@0
|
999 |
}
|
sl@0
|
1000 |
|
sl@0
|
1001 |
iGc->Reset();
|
sl@0
|
1002 |
iGc->Clear();
|
sl@0
|
1003 |
iGc->SetStrikethroughStyle((EIsStrikethroughOn & aSettings.fSpecAndGcSettings) ? EStrikethroughOn : EStrikethroughOff);
|
sl@0
|
1004 |
iGc->SetUnderlineStyle((EIsUnderlineOn & aSettings.fSpecAndGcSettings) ? EUnderlineOn : EUnderlineOff);
|
sl@0
|
1005 |
|
sl@0
|
1006 |
//Set the glyph bitmap type
|
sl@0
|
1007 |
if(ESetMonochromeGlyphBitmap & aSettings.fSpecAndGcSettings)
|
sl@0
|
1008 |
{
|
sl@0
|
1009 |
aFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap);
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
else if(ESetAntiAliasedGlyphBitmap & aSettings.fSpecAndGcSettings)
|
sl@0
|
1012 |
{
|
sl@0
|
1013 |
aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
|
sl@0
|
1014 |
}
|
sl@0
|
1015 |
|
sl@0
|
1016 |
//Set the colours in gc if asked for
|
sl@0
|
1017 |
if(aSetColors)
|
sl@0
|
1018 |
{
|
sl@0
|
1019 |
iGc->SetBrushColor(aSettings.brushColor);
|
sl@0
|
1020 |
iGc->SetPenColor(aSettings.penColor);
|
sl@0
|
1021 |
iGc->SetShadowColor(aSettings.shadowColor);
|
sl@0
|
1022 |
|
sl@0
|
1023 |
if (aSettings.backgroundColor != KRgbWhite)
|
sl@0
|
1024 |
{
|
sl@0
|
1025 |
iGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
|
sl@0
|
1026 |
CFbsBitmap* bgBitmap = new CFbsBitmap;
|
sl@0
|
1027 |
bgBitmap->Create(TSize(1, 1), EColor16MA);
|
sl@0
|
1028 |
bgBitmap->BeginDataAccess();
|
sl@0
|
1029 |
Mem::Copy(bgBitmap->DataAddress(), &(aSettings.backgroundColor), 4);
|
sl@0
|
1030 |
bgBitmap->EndDataAccess(EFalse);
|
sl@0
|
1031 |
iGc->DrawBitmap(TRect(TPoint(0, 0), iBitmap->SizeInPixels()), bgBitmap);
|
sl@0
|
1032 |
delete bgBitmap;
|
sl@0
|
1033 |
iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
|
sl@0
|
1034 |
}
|
sl@0
|
1035 |
}
|
sl@0
|
1036 |
}
|
sl@0
|
1037 |
|
sl@0
|
1038 |
void CTOutlineAndShadowFonts::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
1041 |
switch (aCurTestCase)
|
sl@0
|
1042 |
{
|
sl@0
|
1043 |
case 1:
|
sl@0
|
1044 |
{
|
sl@0
|
1045 |
/**
|
sl@0
|
1046 |
@SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0007
|
sl@0
|
1047 |
*/
|
sl@0
|
1048 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0007"));
|
sl@0
|
1049 |
CheckMonoTypeInstalledL();
|
sl@0
|
1050 |
break;
|
sl@0
|
1051 |
}
|
sl@0
|
1052 |
case 2:
|
sl@0
|
1053 |
{
|
sl@0
|
1054 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0008"));
|
sl@0
|
1055 |
TestOutlineandShadowFontsMetricsL();
|
sl@0
|
1056 |
break;
|
sl@0
|
1057 |
}
|
sl@0
|
1058 |
case 3:
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0009"));
|
sl@0
|
1061 |
TestOutlinePenAndShadowColorL();
|
sl@0
|
1062 |
break;
|
sl@0
|
1063 |
}
|
sl@0
|
1064 |
case 4:
|
sl@0
|
1065 |
{
|
sl@0
|
1066 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0010"));
|
sl@0
|
1067 |
TestDrawTextWithOutlineAndShadowL();
|
sl@0
|
1068 |
break;
|
sl@0
|
1069 |
}
|
sl@0
|
1070 |
case 5:
|
sl@0
|
1071 |
{
|
sl@0
|
1072 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0011"));
|
sl@0
|
1073 |
TestDrawTextWithStrikeThroughL();
|
sl@0
|
1074 |
break;
|
sl@0
|
1075 |
}
|
sl@0
|
1076 |
case 6:
|
sl@0
|
1077 |
{
|
sl@0
|
1078 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0012"));
|
sl@0
|
1079 |
NegativeRastTestL();
|
sl@0
|
1080 |
break;
|
sl@0
|
1081 |
}
|
sl@0
|
1082 |
case 7:
|
sl@0
|
1083 |
{
|
sl@0
|
1084 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0013"));
|
sl@0
|
1085 |
TestCheckBitmapTypesL();
|
sl@0
|
1086 |
break;
|
sl@0
|
1087 |
}
|
sl@0
|
1088 |
case 8:
|
sl@0
|
1089 |
{
|
sl@0
|
1090 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0015"));
|
sl@0
|
1091 |
TestAntiAliasedOrMonochromeGlyphBitmapL();
|
sl@0
|
1092 |
break;
|
sl@0
|
1093 |
}
|
sl@0
|
1094 |
case 9:
|
sl@0
|
1095 |
{
|
sl@0
|
1096 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0014"));
|
sl@0
|
1097 |
TestOOML();
|
sl@0
|
1098 |
break;
|
sl@0
|
1099 |
}
|
sl@0
|
1100 |
default:
|
sl@0
|
1101 |
{
|
sl@0
|
1102 |
((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1103 |
((CTOutlineAndShadowFontsStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
1104 |
TestComplete();
|
sl@0
|
1105 |
break;
|
sl@0
|
1106 |
}
|
sl@0
|
1107 |
}
|
sl@0
|
1108 |
((CTOutlineAndShadowFontsStep*)iStep)->RecordTestResultL();
|
sl@0
|
1109 |
}
|
sl@0
|
1110 |
|
sl@0
|
1111 |
//--------------
|
sl@0
|
1112 |
__CONSTRUCT_STEP__(OutlineAndShadowFonts)
|