sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
@internalComponent
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "T_LinkedFonts2.h"
|
sl@0
|
26 |
#include "linkedfontsprivate.h"
|
sl@0
|
27 |
#include <graphics/openfontlinkedtypefacespecification.h>
|
sl@0
|
28 |
#include <openfontlinkedtypefaceelementspec.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
CTLinkedFonts2::CTLinkedFonts2(CTestStep* aStep)
|
sl@0
|
31 |
: CTGraphicsBase(aStep)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
CTLinkedFonts2::~CTLinkedFonts2()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
delete iGc;
|
sl@0
|
39 |
delete iDev;
|
sl@0
|
40 |
if (iFbs)
|
sl@0
|
41 |
iFbs->Disconnect();
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
void CTLinkedFonts2::TestPanic(TInt aPanic)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
_LIT(KFntTestStorePanicCategory,"TestFntStore");
|
sl@0
|
47 |
User::Panic(KFntTestStorePanicCategory,aPanic);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
void CTLinkedFonts2::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
53 |
switch (aCurTestCase)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
case 1:
|
sl@0
|
56 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0046"));
|
sl@0
|
57 |
InitializeTestHarnessL();
|
sl@0
|
58 |
break;
|
sl@0
|
59 |
case 2:
|
sl@0
|
60 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0001"));
|
sl@0
|
61 |
TestLinkedClientGettersAndSettersL();
|
sl@0
|
62 |
break;
|
sl@0
|
63 |
case 3:
|
sl@0
|
64 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0002"));
|
sl@0
|
65 |
TestLinkedClientAddAndRemoveL();
|
sl@0
|
66 |
break;
|
sl@0
|
67 |
case 4:
|
sl@0
|
68 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0003"));
|
sl@0
|
69 |
TestOpenClientAddAndRemoveL();
|
sl@0
|
70 |
break;
|
sl@0
|
71 |
case 5:
|
sl@0
|
72 |
/**
|
sl@0
|
73 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0004
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0004"));
|
sl@0
|
76 |
TestLinkedRegistrationAndFetchL();
|
sl@0
|
77 |
break;
|
sl@0
|
78 |
case 6:
|
sl@0
|
79 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0100"));
|
sl@0
|
80 |
TestComplexLinkedFontsBasicL();
|
sl@0
|
81 |
break;
|
sl@0
|
82 |
case 7:
|
sl@0
|
83 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
84 |
//((CTLinkedFonts2Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0101"));
|
sl@0
|
85 |
//TestBitmapFontsL();
|
sl@0
|
86 |
break;
|
sl@0
|
87 |
default:
|
sl@0
|
88 |
CloseTestHarnessL();
|
sl@0
|
89 |
TestComplete();
|
sl@0
|
90 |
((CTLinkedFonts2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
91 |
((CTLinkedFonts2Step*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
92 |
break;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
((CTLinkedFonts2Step*)iStep)->RecordTestResultL();
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
@SYMTestCaseID
|
sl@0
|
99 |
GRAPHICS-FNTSTORE-LINKEDFONTS-0046
|
sl@0
|
100 |
|
sl@0
|
101 |
@SYMTestCaseDesc
|
sl@0
|
102 |
Starts a server session with the font and bitmap server.
|
sl@0
|
103 |
|
sl@0
|
104 |
@SYMTestActions
|
sl@0
|
105 |
1. Creates a session with the Font and Bitmap server.
|
sl@0
|
106 |
2. Gets the current Font and Bitmap server session.
|
sl@0
|
107 |
3. Creates a CFbsScreenDevice object.
|
sl@0
|
108 |
4. Sets screen device to null.
|
sl@0
|
109 |
5. Sets auto update to true.
|
sl@0
|
110 |
6. Creates a font and bitmap server graphics context for the
|
sl@0
|
111 |
device and activates it.
|
sl@0
|
112 |
|
sl@0
|
113 |
@SYMTestExpectedResults
|
sl@0
|
114 |
All steps 1-6 above succeed.
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
void CTLinkedFonts2::StartServer()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
TInt ret = RFbsSession::Connect();
|
sl@0
|
119 |
TEST2(ret, KErrNone);
|
sl@0
|
120 |
iFbs = RFbsSession::GetSession();
|
sl@0
|
121 |
TEST(iFbs != NULL);
|
sl@0
|
122 |
|
sl@0
|
123 |
if (iFbs==NULL)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
//cannot continue
|
sl@0
|
126 |
TestComplete();
|
sl@0
|
127 |
return;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
TInt err;
|
sl@0
|
131 |
TDisplayMode mode[4] = {EColor16MA,EColor16MU,EColor64K,EColor16MAP};
|
sl@0
|
132 |
|
sl@0
|
133 |
TInt count;
|
sl@0
|
134 |
for (count=0; count < (sizeof(mode)/sizeof(mode[0])) ;count++)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
TRAP(err, iDev = CFbsScreenDevice::NewL(KNullDesC, mode[count]));
|
sl@0
|
137 |
if (err!=KErrNotSupported)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
break;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
if(err == KErrNone)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
INFO_PRINTF2(_L("%d screen mode created"),mode[count]);
|
sl@0
|
146 |
iDev->ChangeScreenDevice(NULL);
|
sl@0
|
147 |
iDev->SetAutoUpdate(ETrue);
|
sl@0
|
148 |
iDev->CreateContext(iGc);
|
sl@0
|
149 |
|
sl@0
|
150 |
//use and create a font
|
sl@0
|
151 |
//otherwise for memory tests there is a leak reported since the first AllocL
|
sl@0
|
152 |
//creates the space for the array (e.g. CTypefaceStore::AddFontL()) and
|
sl@0
|
153 |
//although the array is emptied the array element storage is not deleted
|
sl@0
|
154 |
//until everything is closed
|
sl@0
|
155 |
_LIT(KSansSerif, "DejaVu Sans Condensed");
|
sl@0
|
156 |
TTypeface typeface;
|
sl@0
|
157 |
typeface.iName = KSansSerif;
|
sl@0
|
158 |
TFontSpec fs;
|
sl@0
|
159 |
fs.iTypeface = typeface;
|
sl@0
|
160 |
fs.iHeight = 20;
|
sl@0
|
161 |
CFbsFont* font = NULL;
|
sl@0
|
162 |
TInt err1 = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
|
sl@0
|
163 |
TEST(err1==KErrNone);
|
sl@0
|
164 |
if (err1 == KErrNone)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
TSize scrSize = iDev->SizeInPixels();
|
sl@0
|
167 |
iGc->UseFont(font);
|
sl@0
|
168 |
_LIT(KTestText,"TEST");
|
sl@0
|
169 |
iGc->DrawText(KTestText, TPoint((scrSize.iWidth / 2) + 50, 50));
|
sl@0
|
170 |
iGc->DiscardFont();
|
sl@0
|
171 |
iDev->ReleaseFont(font);
|
sl@0
|
172 |
}
|
sl@0
|
173 |
}
|
sl@0
|
174 |
else
|
sl@0
|
175 |
{
|
sl@0
|
176 |
INFO_PRINTF2(_L("Could not create screen mode error %d"),err);
|
sl@0
|
177 |
}
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
|
sl@0
|
181 |
void CTLinkedFonts2::InitializeTestHarnessL()
|
sl@0
|
182 |
{
|
sl@0
|
183 |
INFO_PRINTF1(_L("Initialising the test harness T_LinkedFonts2 (PREQ2146)"));
|
sl@0
|
184 |
StartServer();
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
void CTLinkedFonts2::CloseTestHarnessL()
|
sl@0
|
188 |
{
|
sl@0
|
189 |
}
|
sl@0
|
190 |
/**
|
sl@0
|
191 |
@SYMTestCaseID
|
sl@0
|
192 |
GRAPHICS-FNTSTORE-LINKEDFONTS-0001
|
sl@0
|
193 |
|
sl@0
|
194 |
@SYMPREQ
|
sl@0
|
195 |
PREQ2146
|
sl@0
|
196 |
|
sl@0
|
197 |
@SYMREQ
|
sl@0
|
198 |
PREQ2146
|
sl@0
|
199 |
|
sl@0
|
200 |
@SYMTestCaseDesc
|
sl@0
|
201 |
Create a linked typeface element & group. Set the parameters they provide.
|
sl@0
|
202 |
|
sl@0
|
203 |
@SYMTestPriority
|
sl@0
|
204 |
Critical
|
sl@0
|
205 |
|
sl@0
|
206 |
@SYMTestStatus
|
sl@0
|
207 |
Implemented
|
sl@0
|
208 |
|
sl@0
|
209 |
@SYMTestActions
|
sl@0
|
210 |
Tests that the values set are stored correctly by the linked typeface element & group.
|
sl@0
|
211 |
|
sl@0
|
212 |
@SYMTestExpectedResults
|
sl@0
|
213 |
Values are set correctly
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
void CTLinkedFonts2::TestLinkedClientGettersAndSettersL()
|
sl@0
|
216 |
{
|
sl@0
|
217 |
INFO_PRINTF1(_L("CTLinkedFonts2::TestLinkedClientGettersAndSettersL"));
|
sl@0
|
218 |
CLinkedTypefaceElementSpec *elementSpec;
|
sl@0
|
219 |
_LIT(KLinkedTypefaceName, "TypefaceNumberOne");
|
sl@0
|
220 |
elementSpec = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceName, 10);
|
sl@0
|
221 |
|
sl@0
|
222 |
elementSpec->SetCanonical(ETrue);
|
sl@0
|
223 |
TEST(elementSpec->Canonical());
|
sl@0
|
224 |
|
sl@0
|
225 |
//Test Remaining Getters & Setters
|
sl@0
|
226 |
elementSpec->SetCanonical(EFalse);
|
sl@0
|
227 |
|
sl@0
|
228 |
CleanupStack::PopAndDestroy(elementSpec);
|
sl@0
|
229 |
|
sl@0
|
230 |
CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(10);
|
sl@0
|
231 |
const TInt KPercentageValue = 50;
|
sl@0
|
232 |
TInt ret;
|
sl@0
|
233 |
|
sl@0
|
234 |
grp->SetBoldnessPercentage(KPercentageValue);
|
sl@0
|
235 |
ret = grp->BoldnessPercentage();
|
sl@0
|
236 |
TEST2(ret, KPercentageValue);
|
sl@0
|
237 |
|
sl@0
|
238 |
grp->SetItalicAngle(KPercentageValue);
|
sl@0
|
239 |
ret = grp->ItalicAngle();
|
sl@0
|
240 |
TEST2(ret, KPercentageValue);
|
sl@0
|
241 |
|
sl@0
|
242 |
grp->SetBaselineShift(CLinkedTypefaceGroup::ENoBaselineShift);
|
sl@0
|
243 |
CLinkedTypefaceGroup::TBaselineShift ret2 = grp->BaselineShift();
|
sl@0
|
244 |
TEST2(ret2, CLinkedTypefaceGroup::ENoBaselineShift);
|
sl@0
|
245 |
|
sl@0
|
246 |
CleanupStack::PopAndDestroy(grp);
|
sl@0
|
247 |
}
|
sl@0
|
248 |
|
sl@0
|
249 |
/**
|
sl@0
|
250 |
@SYMTestCaseID
|
sl@0
|
251 |
GRAPHICS-FNTSTORE-LINKEDFONTS-0002
|
sl@0
|
252 |
|
sl@0
|
253 |
@SYMPREQ
|
sl@0
|
254 |
PREQ2146
|
sl@0
|
255 |
|
sl@0
|
256 |
@SYMREQ
|
sl@0
|
257 |
PREQ2146
|
sl@0
|
258 |
|
sl@0
|
259 |
@SYMTestCaseDesc
|
sl@0
|
260 |
Tests construction of a Linked Typeface specification with both valid & invalid data.
|
sl@0
|
261 |
|
sl@0
|
262 |
@SYMTestPriority
|
sl@0
|
263 |
Critical
|
sl@0
|
264 |
|
sl@0
|
265 |
@SYMTestStatus
|
sl@0
|
266 |
Implemented
|
sl@0
|
267 |
|
sl@0
|
268 |
@SYMTestActions
|
sl@0
|
269 |
Tests a number of different combinations (listed) of adding, removing and updating groups and
|
sl@0
|
270 |
elements from a linked typeface specification.
|
sl@0
|
271 |
|
sl@0
|
272 |
Tests applicable to CLinkedTypefaceGroup / CLinkedTypefaceSpecification
|
sl@0
|
273 |
|
sl@0
|
274 |
1. Adding a valid group
|
sl@0
|
275 |
2. Adding a duplicate group
|
sl@0
|
276 |
3. Adding a group with the same Id as an existing one
|
sl@0
|
277 |
4. Removal of group
|
sl@0
|
278 |
12. Remove invalid GroupId
|
sl@0
|
279 |
13. Adding more than KMaxLinkedTypefaceGroups groups
|
sl@0
|
280 |
14. Retrieve Group with index out of bounds
|
sl@0
|
281 |
|
sl@0
|
282 |
|
sl@0
|
283 |
Tests applicable to CLinkedTypefaceElementSpec / CLinkedTypefaceSpecification
|
sl@0
|
284 |
|
sl@0
|
285 |
5. Adding a valid element
|
sl@0
|
286 |
6. Adding a duplicate element
|
sl@0
|
287 |
7. Ensuring ordering of elements is as specified
|
sl@0
|
288 |
8. Ensure canonical index is correct when element moved/removed
|
sl@0
|
289 |
9. Ensuring correct error if extra canonical added
|
sl@0
|
290 |
10. Ensuring correct error if canonical activated "in-place"
|
sl@0
|
291 |
11. Removal of element
|
sl@0
|
292 |
15. Create Specification & Element with too short (0)/long (KMaxTypefaceNameLength) names.
|
sl@0
|
293 |
16. Adding more than KMaxLinkedTypefaces Elements
|
sl@0
|
294 |
17. Retrieve Typeface with index out of bounds
|
sl@0
|
295 |
|
sl@0
|
296 |
@SYMTestExpectedResults
|
sl@0
|
297 |
The canonical index is expected to be set to the values provided through the test after the
|
sl@0
|
298 |
various operations performed. Addition & removal should provide success or fail error codes
|
sl@0
|
299 |
as indicated throughout the test. Actions are referenced within the code with expected results.
|
sl@0
|
300 |
*/
|
sl@0
|
301 |
void CTLinkedFonts2::TestLinkedClientAddAndRemoveL()
|
sl@0
|
302 |
{
|
sl@0
|
303 |
INFO_PRINTF1(_L("TestLinkedClientAddAndRemoveL"));
|
sl@0
|
304 |
|
sl@0
|
305 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(NULL);
|
sl@0
|
306 |
CleanupStack::PushL(store);
|
sl@0
|
307 |
|
sl@0
|
308 |
_LIT(KTestLinkedFont, "TestLinkedFont");
|
sl@0
|
309 |
CLinkedTypefaceSpecification* typefaceSpec =
|
sl@0
|
310 |
CLinkedTypefaceSpecification::NewLC(KTestLinkedFont);
|
sl@0
|
311 |
|
sl@0
|
312 |
TInt canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
313 |
TEST(canIndex == KErrNotFound);
|
sl@0
|
314 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
315 |
TEST(ret == KErrNotFound);
|
sl@0
|
316 |
|
sl@0
|
317 |
|
sl@0
|
318 |
const TInt KGroup1Id = 1;
|
sl@0
|
319 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
|
sl@0
|
320 |
//Action 1 : Valid group
|
sl@0
|
321 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group1));
|
sl@0
|
322 |
TEST(ret == KErrNone);
|
sl@0
|
323 |
CleanupStack::Pop(group1);
|
sl@0
|
324 |
|
sl@0
|
325 |
//Action 2 : Same group again
|
sl@0
|
326 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group1));
|
sl@0
|
327 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
328 |
|
sl@0
|
329 |
//Action 3 : Group with existing Id
|
sl@0
|
330 |
CLinkedTypefaceGroup* duplicateGroup = CLinkedTypefaceGroup::NewLC(KGroup1Id);
|
sl@0
|
331 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*duplicateGroup));
|
sl@0
|
332 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
333 |
CleanupStack::PopAndDestroy(duplicateGroup);
|
sl@0
|
334 |
|
sl@0
|
335 |
//Action 1 : Valid group
|
sl@0
|
336 |
const TInt KGroup2Id = 2;
|
sl@0
|
337 |
CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(KGroup2Id);
|
sl@0
|
338 |
group2->SetBaselineShift(CLinkedTypefaceGroup::EBaselineShift);
|
sl@0
|
339 |
group2->SetScalingOption(CLinkedTypefaceGroup::EScalingUpOrDown);
|
sl@0
|
340 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group2));
|
sl@0
|
341 |
TEST(ret == KErrNone);
|
sl@0
|
342 |
CleanupStack::Pop(group2);
|
sl@0
|
343 |
|
sl@0
|
344 |
const TInt KGroup3Id = 4;
|
sl@0
|
345 |
CLinkedTypefaceGroup* group3 = CLinkedTypefaceGroup::NewLC(KGroup3Id);
|
sl@0
|
346 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group3));
|
sl@0
|
347 |
TEST(ret == KErrNone);
|
sl@0
|
348 |
CleanupStack::Pop(group3);
|
sl@0
|
349 |
|
sl@0
|
350 |
//Action 5 : Japanese typefaces
|
sl@0
|
351 |
_LIT(KJapaneseElement, "Japanese");
|
sl@0
|
352 |
CLinkedTypefaceElementSpec* element1 = CLinkedTypefaceElementSpec::NewLC(KJapaneseElement, KGroup2Id);
|
sl@0
|
353 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element1));
|
sl@0
|
354 |
CleanupStack::Pop(element1);
|
sl@0
|
355 |
|
sl@0
|
356 |
//Action 5: Add the canonical element (Latin)
|
sl@0
|
357 |
_LIT(KLatinElement, "DejaVu Sans Mono Bold");
|
sl@0
|
358 |
CLinkedTypefaceElementSpec* element2 = CLinkedTypefaceElementSpec::NewLC(KLatinElement, KGroup1Id);
|
sl@0
|
359 |
element2->SetCanonical(ETrue);
|
sl@0
|
360 |
|
sl@0
|
361 |
TRAP(ret, typefaceSpec->AddTypefaceAtIndexL(*element2,0));
|
sl@0
|
362 |
TEST(ret == KErrNone);
|
sl@0
|
363 |
CleanupStack::Pop(element2);
|
sl@0
|
364 |
|
sl@0
|
365 |
//Action 8 : Check Canonical Index is correct
|
sl@0
|
366 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
367 |
TEST(canIndex == 0);
|
sl@0
|
368 |
|
sl@0
|
369 |
//Action 5 : Hindi typefaces
|
sl@0
|
370 |
_LIT(KHindiElement, "Chandas");
|
sl@0
|
371 |
CLinkedTypefaceElementSpec* element3 = CLinkedTypefaceElementSpec::NewLC(KHindiElement, KGroup3Id);
|
sl@0
|
372 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element3));
|
sl@0
|
373 |
TEST(ret == KErrNone);
|
sl@0
|
374 |
CleanupStack::Pop(element3);
|
sl@0
|
375 |
|
sl@0
|
376 |
//Action 6 : Same element again
|
sl@0
|
377 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element3));
|
sl@0
|
378 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
379 |
|
sl@0
|
380 |
//Action 7 : Check ordering is correct
|
sl@0
|
381 |
TEST2(element1, typefaceSpec->Typeface(1));
|
sl@0
|
382 |
TEST2(element2, typefaceSpec->Typeface(0));
|
sl@0
|
383 |
TEST2(element3, typefaceSpec->Typeface(2));
|
sl@0
|
384 |
|
sl@0
|
385 |
_LIT(KDummyTypeface, "DummyTypeface");
|
sl@0
|
386 |
CLinkedTypefaceElementSpec* dummyElement1 = CLinkedTypefaceElementSpec::NewLC(KDummyTypeface, KGroup2Id);
|
sl@0
|
387 |
|
sl@0
|
388 |
//Action 9 : Add second canonical
|
sl@0
|
389 |
dummyElement1->SetCanonical(ETrue);
|
sl@0
|
390 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*dummyElement1));
|
sl@0
|
391 |
TEST(ret == KErrArgument);
|
sl@0
|
392 |
|
sl@0
|
393 |
//Add at front of typeface to check canonical index is updated.
|
sl@0
|
394 |
dummyElement1->SetCanonical(EFalse);
|
sl@0
|
395 |
TRAP(ret, typefaceSpec->AddTypefaceAtIndexL(*dummyElement1, 0));
|
sl@0
|
396 |
TEST(ret == KErrNone);
|
sl@0
|
397 |
CleanupStack::Pop(dummyElement1);
|
sl@0
|
398 |
|
sl@0
|
399 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
400 |
TEST(canIndex == 1);
|
sl@0
|
401 |
|
sl@0
|
402 |
dummyElement1 = CLinkedTypefaceElementSpec::NewLC(KDummyTypeface, 180);
|
sl@0
|
403 |
TRAP(ret, typefaceSpec->AddTypefaceAtIndexL(*dummyElement1, 0));
|
sl@0
|
404 |
TEST(ret == KErrArgument);
|
sl@0
|
405 |
CleanupStack::PopAndDestroy(dummyElement1);
|
sl@0
|
406 |
|
sl@0
|
407 |
//Action 11 : Remove Element
|
sl@0
|
408 |
typefaceSpec->RemoveTypeface(0);
|
sl@0
|
409 |
TEST2(element2, typefaceSpec->Typeface(0));
|
sl@0
|
410 |
|
sl@0
|
411 |
//Action 8 : Check canonical index is correct
|
sl@0
|
412 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
413 |
TEST(canIndex == 0);
|
sl@0
|
414 |
|
sl@0
|
415 |
//Action 10 : Check error if extra canonical activated "in place"
|
sl@0
|
416 |
typefaceSpec->Typeface(1)->SetCanonical(ETrue);
|
sl@0
|
417 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
418 |
TEST(canIndex == KErrOverflow);
|
sl@0
|
419 |
TRAP(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
420 |
TEST(ret == KErrOverflow);
|
sl@0
|
421 |
//Reset back to be non-canonical
|
sl@0
|
422 |
typefaceSpec->Typeface(1)->SetCanonical(EFalse);
|
sl@0
|
423 |
|
sl@0
|
424 |
//Action 8 : Check canonical index is correct
|
sl@0
|
425 |
typefaceSpec->RemoveTypeface(0);
|
sl@0
|
426 |
TEST2(element1, typefaceSpec->Typeface(0));
|
sl@0
|
427 |
|
sl@0
|
428 |
//Action 8 : Check canonical index is correct
|
sl@0
|
429 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
430 |
TEST(canIndex == -1);
|
sl@0
|
431 |
|
sl@0
|
432 |
//Action 4 : Remove the group
|
sl@0
|
433 |
TRAP(ret, typefaceSpec->RemoveLinkedTypefaceGroup(KGroup3Id));
|
sl@0
|
434 |
TEST(ret == KErrNone);
|
sl@0
|
435 |
CLinkedTypefaceGroup* groupRet = typefaceSpec->GroupById(KGroup3Id);
|
sl@0
|
436 |
TEST(groupRet == NULL);
|
sl@0
|
437 |
|
sl@0
|
438 |
TEST2(element1, typefaceSpec->Typeface(0));
|
sl@0
|
439 |
|
sl@0
|
440 |
//Action 12 : Remove invalid group
|
sl@0
|
441 |
ret = typefaceSpec->RemoveLinkedTypefaceGroup(180);
|
sl@0
|
442 |
TEST(ret == KErrNotFound);
|
sl@0
|
443 |
//Action 4 : Remove group
|
sl@0
|
444 |
ret = typefaceSpec->RemoveLinkedTypefaceGroup(KGroup1Id);
|
sl@0
|
445 |
TEST(ret == KErrNone);
|
sl@0
|
446 |
groupRet = typefaceSpec->GroupById(KGroup1Id);
|
sl@0
|
447 |
TEST(groupRet == NULL);
|
sl@0
|
448 |
|
sl@0
|
449 |
CleanupStack::PopAndDestroy(typefaceSpec);
|
sl@0
|
450 |
|
sl@0
|
451 |
//Negative Name length tests
|
sl@0
|
452 |
_LIT(KEmptyTypefaceName, "");
|
sl@0
|
453 |
//Action 15 : Create Specification & Element with 0 length names
|
sl@0
|
454 |
TRAP(ret, typefaceSpec = CLinkedTypefaceSpecification::NewLC(KEmptyTypefaceName));
|
sl@0
|
455 |
TEST(ret == KErrArgument);
|
sl@0
|
456 |
TRAP(ret, dummyElement1 = CLinkedTypefaceElementSpec::NewLC(KEmptyTypefaceName,1));
|
sl@0
|
457 |
TEST(ret < KErrNone);
|
sl@0
|
458 |
//Action 15: Create Specification & Element with name longer than KMaxTypefaceNameLength
|
sl@0
|
459 |
_LIT(KLongTypefaceName, "KErrArgumentKErrArgumentKErrArgument");
|
sl@0
|
460 |
TRAP(ret, typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLongTypefaceName));
|
sl@0
|
461 |
TEST(ret == KErrArgument);
|
sl@0
|
462 |
TRAP(ret, dummyElement1 = CLinkedTypefaceElementSpec::NewLC(KLongTypefaceName,1));
|
sl@0
|
463 |
TEST(ret < KErrNone);
|
sl@0
|
464 |
|
sl@0
|
465 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KTestLinkedFont);
|
sl@0
|
466 |
TInt i;
|
sl@0
|
467 |
for (i = 0 ; i <= KMaxLinkedTypefaceGroups+1 ; i++)
|
sl@0
|
468 |
{
|
sl@0
|
469 |
CLinkedTypefaceGroup* group = CLinkedTypefaceGroup::NewLC(i);
|
sl@0
|
470 |
|
sl@0
|
471 |
if (i < KMaxLinkedTypefaceGroups)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
//Add Groups 1-KMaxLinkedTypefaceGroups
|
sl@0
|
474 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group));
|
sl@0
|
475 |
CleanupStack::Pop(group);
|
sl@0
|
476 |
}
|
sl@0
|
477 |
else
|
sl@0
|
478 |
{
|
sl@0
|
479 |
//Action 13 : Add group at KMaxLinkedTypefaceGroups+1
|
sl@0
|
480 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group));
|
sl@0
|
481 |
TEST(ret == KErrOverflow);
|
sl@0
|
482 |
CleanupStack::PopAndDestroy(group);
|
sl@0
|
483 |
}
|
sl@0
|
484 |
}
|
sl@0
|
485 |
|
sl@0
|
486 |
_LIT(KFormatElementName, "Element%d");
|
sl@0
|
487 |
for (i = 0 ; i <= KMaxLinkedTypefaces ; i++)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
TBuf<18> elementName;
|
sl@0
|
490 |
elementName.Format(KFormatElementName,i);
|
sl@0
|
491 |
CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(elementName,i);
|
sl@0
|
492 |
if (i < KMaxLinkedTypefaces)
|
sl@0
|
493 |
{
|
sl@0
|
494 |
//Add Elements 1-KMaxLinkedTypefaces
|
sl@0
|
495 |
TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*element));
|
sl@0
|
496 |
CleanupStack::Pop(element);
|
sl@0
|
497 |
}
|
sl@0
|
498 |
else
|
sl@0
|
499 |
{
|
sl@0
|
500 |
//Action 16 : Add element KMaxLinkedTypefaces+1
|
sl@0
|
501 |
TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*element));
|
sl@0
|
502 |
TEST(ret == KErrOverflow);
|
sl@0
|
503 |
CleanupStack::PopAndDestroy(element);
|
sl@0
|
504 |
}
|
sl@0
|
505 |
}
|
sl@0
|
506 |
|
sl@0
|
507 |
//Action 14 : Retrieve out of bounds groups
|
sl@0
|
508 |
TEST2(typefaceSpec->Group(-1), NULL);
|
sl@0
|
509 |
TEST2(typefaceSpec->Group(typefaceSpec->GroupCount()+1), NULL);
|
sl@0
|
510 |
//Action 17 : Retrieve typeface with index out of bounds
|
sl@0
|
511 |
TEST2(typefaceSpec->Typeface(-1), NULL);
|
sl@0
|
512 |
TEST2(typefaceSpec->Typeface(typefaceSpec->TypefaceCount()+1), NULL);
|
sl@0
|
513 |
//Action 11 : Remove typeface with index out of bounds
|
sl@0
|
514 |
TEST2(typefaceSpec->RemoveTypeface(-1), KErrNotFound);
|
sl@0
|
515 |
TEST2(typefaceSpec->RemoveTypeface(typefaceSpec->TypefaceCount()+1), KErrNotFound);
|
sl@0
|
516 |
|
sl@0
|
517 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
/**
|
sl@0
|
521 |
@SYMTestCaseID
|
sl@0
|
522 |
GRAPHICS-FNTSTORE-LINKEDFONTS-0003
|
sl@0
|
523 |
|
sl@0
|
524 |
@SYMPREQ
|
sl@0
|
525 |
PREQ2146
|
sl@0
|
526 |
|
sl@0
|
527 |
@SYMREQ
|
sl@0
|
528 |
PREQ2146
|
sl@0
|
529 |
|
sl@0
|
530 |
@SYMTestCaseDesc
|
sl@0
|
531 |
Tests the Add & RemoveTypeface functions provided by COpenFontLinkedTypefaceSpecification
|
sl@0
|
532 |
|
sl@0
|
533 |
@SYMTestPriority
|
sl@0
|
534 |
Critical
|
sl@0
|
535 |
|
sl@0
|
536 |
@SYMTestStatus
|
sl@0
|
537 |
Implemented
|
sl@0
|
538 |
|
sl@0
|
539 |
@SYMTestActions
|
sl@0
|
540 |
Tests applicable to CLinkedTypefaceGroup / COpenFontLinkedTypefaceSpecification
|
sl@0
|
541 |
|
sl@0
|
542 |
1. Adding a valid group
|
sl@0
|
543 |
2. Adding a duplicate group (same object)
|
sl@0
|
544 |
3. Adding a group with the same Id as an existing one
|
sl@0
|
545 |
4. Removal of group
|
sl@0
|
546 |
12. Remove invalid GroupId
|
sl@0
|
547 |
13. Adding more than KMaxLinkedTypefaceGroups groups
|
sl@0
|
548 |
14. Retrieve Group with index out of bounds
|
sl@0
|
549 |
|
sl@0
|
550 |
Tests applicable to COpenFontLinkedTypefaceElementSpec / COpenFontLinkedTypefaceSpecification
|
sl@0
|
551 |
|
sl@0
|
552 |
5. Adding a valid element
|
sl@0
|
553 |
6. Adding a duplicate element (same object)
|
sl@0
|
554 |
7. Ensuring ordering of elements is as specified
|
sl@0
|
555 |
8. Ensure canonical index is correct when element moved/removed
|
sl@0
|
556 |
9. Ensuring correct error if extra canonical added
|
sl@0
|
557 |
10. Ensuring correct error if canonical activated "in-place"
|
sl@0
|
558 |
11. Removal of element
|
sl@0
|
559 |
15. Create Specification & Element with too short (0)/long (KMaxTypefaceNameLength) names.
|
sl@0
|
560 |
16. Adding more than KMaxLinkedTypefaces Elements
|
sl@0
|
561 |
17. Retrieve Typeface with index out of bounds
|
sl@0
|
562 |
|
sl@0
|
563 |
@SYMTestExpectedResults
|
sl@0
|
564 |
The canonical index is expected to be set to the values provided through the test after the
|
sl@0
|
565 |
various operations performed. Addition & removal should provide success or fail error codes
|
sl@0
|
566 |
as indicated throughout the test. Actions are referenced within the code with expected results.
|
sl@0
|
567 |
*/
|
sl@0
|
568 |
void CTLinkedFonts2::TestOpenClientAddAndRemoveL()
|
sl@0
|
569 |
{
|
sl@0
|
570 |
INFO_PRINTF1(_L("TestOpenClientAddAndRemoveL"));
|
sl@0
|
571 |
|
sl@0
|
572 |
_LIT(KTestLinkedFont, "TestLinkedFont");
|
sl@0
|
573 |
COpenFontLinkedTypefaceSpecification* typefaceSpec =
|
sl@0
|
574 |
COpenFontLinkedTypefaceSpecification::NewLC(KTestLinkedFont);
|
sl@0
|
575 |
|
sl@0
|
576 |
TInt canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
577 |
TEST(canIndex == -1);
|
sl@0
|
578 |
|
sl@0
|
579 |
TInt ret;
|
sl@0
|
580 |
|
sl@0
|
581 |
//Action 1 : Add a valid group
|
sl@0
|
582 |
const TInt KGroup1Id = 1;
|
sl@0
|
583 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
|
sl@0
|
584 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group1));
|
sl@0
|
585 |
TEST(ret == KErrNone);
|
sl@0
|
586 |
CleanupStack::Pop(group1);
|
sl@0
|
587 |
|
sl@0
|
588 |
//Action 2 : Add a duplicate group
|
sl@0
|
589 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group1));
|
sl@0
|
590 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
591 |
|
sl@0
|
592 |
//Action 3 : Add a group with the same id
|
sl@0
|
593 |
CLinkedTypefaceGroup* duplicateGroup = CLinkedTypefaceGroup::NewLC(KGroup1Id);
|
sl@0
|
594 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*duplicateGroup));
|
sl@0
|
595 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
596 |
CleanupStack::PopAndDestroy(duplicateGroup);
|
sl@0
|
597 |
|
sl@0
|
598 |
//Action 5 : Add a valid element
|
sl@0
|
599 |
const TInt KGroup2Id = 2;
|
sl@0
|
600 |
CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(KGroup2Id);
|
sl@0
|
601 |
group2->SetBaselineShift(CLinkedTypefaceGroup::EBaselineShift);
|
sl@0
|
602 |
group2->SetScalingOption(CLinkedTypefaceGroup::EScalingUpOrDown);
|
sl@0
|
603 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group2));
|
sl@0
|
604 |
TEST(ret == KErrNone);
|
sl@0
|
605 |
CleanupStack::Pop(group2);
|
sl@0
|
606 |
|
sl@0
|
607 |
const TInt KGroup3Id = 4;
|
sl@0
|
608 |
CLinkedTypefaceGroup* group3 = CLinkedTypefaceGroup::NewLC(KGroup3Id);
|
sl@0
|
609 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group3));
|
sl@0
|
610 |
TEST(ret == KErrNone);
|
sl@0
|
611 |
CleanupStack::Pop(group3);
|
sl@0
|
612 |
|
sl@0
|
613 |
//Action 5 : Add a valid element
|
sl@0
|
614 |
_LIT(KJapaneseElement, "Japanese");
|
sl@0
|
615 |
COpenFontLinkedTypefaceElementSpec* element1 = COpenFontLinkedTypefaceElementSpec::NewLC(KJapaneseElement, KGroup2Id);
|
sl@0
|
616 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element1));
|
sl@0
|
617 |
CleanupStack::Pop(element1);
|
sl@0
|
618 |
|
sl@0
|
619 |
//Action 5 : Add a valid element
|
sl@0
|
620 |
_LIT(KLatinElement, "DejaVu Sans Mono Bold");
|
sl@0
|
621 |
COpenFontLinkedTypefaceElementSpec* element2 = COpenFontLinkedTypefaceElementSpec::NewLC(KLatinElement, KGroup1Id);
|
sl@0
|
622 |
element2->SetCanonical(ETrue);
|
sl@0
|
623 |
|
sl@0
|
624 |
TRAP(ret, typefaceSpec->AddTypefaceAtIndexL(*element2,0));
|
sl@0
|
625 |
TEST(ret == KErrNone);
|
sl@0
|
626 |
CleanupStack::Pop(element2);
|
sl@0
|
627 |
|
sl@0
|
628 |
//Action 8 : Ensure canonical index correct
|
sl@0
|
629 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
630 |
TEST(canIndex == 0);
|
sl@0
|
631 |
|
sl@0
|
632 |
_LIT(KHindiElement, "Chandas");
|
sl@0
|
633 |
COpenFontLinkedTypefaceElementSpec* element3 = COpenFontLinkedTypefaceElementSpec::NewLC(KHindiElement, KGroup3Id);
|
sl@0
|
634 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element3));
|
sl@0
|
635 |
TEST(ret == KErrNone);
|
sl@0
|
636 |
CleanupStack::Pop(element3);
|
sl@0
|
637 |
|
sl@0
|
638 |
//Action 6 : Duplicate element
|
sl@0
|
639 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*element3));
|
sl@0
|
640 |
TEST(ret == KErrAlreadyExists);
|
sl@0
|
641 |
|
sl@0
|
642 |
//Action 7 : Ensure ordering correct
|
sl@0
|
643 |
TEST2(element1, typefaceSpec->Typeface(1));
|
sl@0
|
644 |
TEST2(element2, typefaceSpec->Typeface(0));
|
sl@0
|
645 |
TEST2(element3, typefaceSpec->Typeface(2));
|
sl@0
|
646 |
|
sl@0
|
647 |
_LIT(KDummyTypeface, "DummyTypeface");
|
sl@0
|
648 |
COpenFontLinkedTypefaceElementSpec* dummyElement1 = COpenFontLinkedTypefaceElementSpec::NewLC(KDummyTypeface, KGroup2Id);
|
sl@0
|
649 |
|
sl@0
|
650 |
//Action 9 : Add 2nd canonical
|
sl@0
|
651 |
dummyElement1->SetCanonical(ETrue);
|
sl@0
|
652 |
TRAP(ret, typefaceSpec->AddTypefaceAtBackL(*dummyElement1));
|
sl@0
|
653 |
TEST(ret == KErrArgument);
|
sl@0
|
654 |
|
sl@0
|
655 |
//Add at front of typeface to check canonical index is updated.
|
sl@0
|
656 |
dummyElement1->SetCanonical(EFalse);
|
sl@0
|
657 |
TRAP(ret, typefaceSpec->AddTypefaceAtIndexL(*dummyElement1, 0));
|
sl@0
|
658 |
TEST(ret == KErrNone);
|
sl@0
|
659 |
CleanupStack::Pop(dummyElement1);
|
sl@0
|
660 |
|
sl@0
|
661 |
//Action 8 : Check canonical updated
|
sl@0
|
662 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
663 |
TEST(canIndex == 1);
|
sl@0
|
664 |
|
sl@0
|
665 |
//Action 11 : Remove element
|
sl@0
|
666 |
typefaceSpec->RemoveTypeface(0);
|
sl@0
|
667 |
TEST2(element2, typefaceSpec->Typeface(0));
|
sl@0
|
668 |
|
sl@0
|
669 |
//Action 8 : Check canonical updated
|
sl@0
|
670 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
671 |
TEST(canIndex == 0);
|
sl@0
|
672 |
|
sl@0
|
673 |
//Action 10 : Additional canonical set in-place
|
sl@0
|
674 |
typefaceSpec->Typeface(1)->SetCanonical(ETrue);
|
sl@0
|
675 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
676 |
TEST(canIndex == KErrOverflow);
|
sl@0
|
677 |
typefaceSpec->Typeface(1)->SetCanonical(EFalse);
|
sl@0
|
678 |
|
sl@0
|
679 |
//Action 11 : Remove element
|
sl@0
|
680 |
typefaceSpec->RemoveTypeface(0);
|
sl@0
|
681 |
TEST2(element1, typefaceSpec->Typeface(0));
|
sl@0
|
682 |
|
sl@0
|
683 |
//Action 8 : Canonical updated
|
sl@0
|
684 |
canIndex = typefaceSpec->CanonicalIndex();
|
sl@0
|
685 |
TEST(canIndex == -1);
|
sl@0
|
686 |
|
sl@0
|
687 |
//Action 4 : Remove group
|
sl@0
|
688 |
TRAP(ret, typefaceSpec->RemoveLinkedTypefaceGroup(KGroup3Id));
|
sl@0
|
689 |
TEST(ret == KErrNone);
|
sl@0
|
690 |
CLinkedTypefaceGroup* groupRet = typefaceSpec->GroupById(KGroup3Id);
|
sl@0
|
691 |
TEST(groupRet == NULL);
|
sl@0
|
692 |
|
sl@0
|
693 |
TEST2(element1, typefaceSpec->Typeface(0));
|
sl@0
|
694 |
|
sl@0
|
695 |
//Action 12 : Remove invalid group Id
|
sl@0
|
696 |
ret = typefaceSpec->RemoveLinkedTypefaceGroup(180);
|
sl@0
|
697 |
TEST(ret == KErrNotFound);
|
sl@0
|
698 |
ret = typefaceSpec->RemoveLinkedTypefaceGroup(KGroup1Id);
|
sl@0
|
699 |
TEST(ret == KErrNone);
|
sl@0
|
700 |
|
sl@0
|
701 |
CleanupStack::PopAndDestroy(typefaceSpec);
|
sl@0
|
702 |
|
sl@0
|
703 |
//Negative Name length tests
|
sl@0
|
704 |
_LIT(KEmptyTypefaceName, "");
|
sl@0
|
705 |
//Action 15 : Create Specifications
|
sl@0
|
706 |
TRAP(ret, typefaceSpec = COpenFontLinkedTypefaceSpecification::NewLC(KEmptyTypefaceName));
|
sl@0
|
707 |
TEST(ret == KErrArgument);
|
sl@0
|
708 |
TRAP(ret, dummyElement1 = COpenFontLinkedTypefaceElementSpec::NewLC(KEmptyTypefaceName,1));
|
sl@0
|
709 |
TEST(ret < KErrNone);
|
sl@0
|
710 |
_LIT(KLongTypefaceName, "KErrArgumentKErrArgumentKErrArgument");
|
sl@0
|
711 |
TRAP(ret, typefaceSpec = COpenFontLinkedTypefaceSpecification::NewLC(KLongTypefaceName));
|
sl@0
|
712 |
TEST(ret == KErrArgument);
|
sl@0
|
713 |
TRAP(ret, dummyElement1 = COpenFontLinkedTypefaceElementSpec::NewLC(KLongTypefaceName,1));
|
sl@0
|
714 |
TEST(ret < KErrNone);
|
sl@0
|
715 |
|
sl@0
|
716 |
typefaceSpec = COpenFontLinkedTypefaceSpecification::NewLC(KTestLinkedFont);
|
sl@0
|
717 |
TInt i;
|
sl@0
|
718 |
for (i = 0 ; i <= KMaxLinkedTypefaceGroups+1 ; i++)
|
sl@0
|
719 |
{
|
sl@0
|
720 |
CLinkedTypefaceGroup* group = CLinkedTypefaceGroup::NewLC(i);
|
sl@0
|
721 |
|
sl@0
|
722 |
if (i < KMaxLinkedTypefaceGroups)
|
sl@0
|
723 |
{
|
sl@0
|
724 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group));
|
sl@0
|
725 |
CleanupStack::Pop(group);
|
sl@0
|
726 |
}
|
sl@0
|
727 |
else
|
sl@0
|
728 |
{
|
sl@0
|
729 |
TRAP(ret, typefaceSpec->AddLinkedTypefaceGroupL(*group));
|
sl@0
|
730 |
TEST(ret == KErrOverflow);
|
sl@0
|
731 |
CleanupStack::PopAndDestroy(group);
|
sl@0
|
732 |
}
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
_LIT(KFormatElementName, "Element%d");
|
sl@0
|
736 |
for (i = 0 ; i <= KMaxLinkedTypefaces ; i++)
|
sl@0
|
737 |
{
|
sl@0
|
738 |
TBuf<18> elementName;
|
sl@0
|
739 |
elementName.Format(KFormatElementName,i);
|
sl@0
|
740 |
COpenFontLinkedTypefaceElementSpec* element = COpenFontLinkedTypefaceElementSpec::NewLC(elementName,i);
|
sl@0
|
741 |
if (i < KMaxLinkedTypefaces)
|
sl@0
|
742 |
{
|
sl@0
|
743 |
TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*element));
|
sl@0
|
744 |
CleanupStack::Pop(element);
|
sl@0
|
745 |
}
|
sl@0
|
746 |
else
|
sl@0
|
747 |
{
|
sl@0
|
748 |
TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*element));
|
sl@0
|
749 |
TEST(ret == KErrOverflow);
|
sl@0
|
750 |
CleanupStack::PopAndDestroy(element);
|
sl@0
|
751 |
}
|
sl@0
|
752 |
}
|
sl@0
|
753 |
|
sl@0
|
754 |
TEST2(typefaceSpec->Group(-1), NULL);
|
sl@0
|
755 |
TEST2(typefaceSpec->Group(typefaceSpec->GroupCount()+1), NULL);
|
sl@0
|
756 |
TEST2(typefaceSpec->Typeface(-1), NULL);
|
sl@0
|
757 |
TEST2(typefaceSpec->Typeface(typefaceSpec->TypefaceCount()+1), NULL);
|
sl@0
|
758 |
TEST2(typefaceSpec->RemoveTypeface(-1), KErrNotFound);
|
sl@0
|
759 |
TEST2(typefaceSpec->RemoveTypeface(typefaceSpec->TypefaceCount()+1), KErrNotFound);
|
sl@0
|
760 |
CleanupStack::PopAndDestroy(typefaceSpec);
|
sl@0
|
761 |
}
|
sl@0
|
762 |
|
sl@0
|
763 |
/* Function is used to determine if complex fonts are available. It looks for a
|
sl@0
|
764 |
test Devanagari font
|
sl@0
|
765 |
*/
|
sl@0
|
766 |
TBool CTLinkedFonts2::ComplexFontAvailable()
|
sl@0
|
767 |
{
|
sl@0
|
768 |
_LIT(KTypefaceOT, "Chandas");
|
sl@0
|
769 |
|
sl@0
|
770 |
// Create the linked font
|
sl@0
|
771 |
TTypeface typeface;
|
sl@0
|
772 |
typeface.iName = KTypefaceOT;
|
sl@0
|
773 |
TFontSpec fs1;
|
sl@0
|
774 |
fs1.iTypeface = typeface;
|
sl@0
|
775 |
fs1.iHeight = 4;
|
sl@0
|
776 |
CFbsFont* font = NULL;
|
sl@0
|
777 |
TInt err = iDev->GetNearestFontToDesignHeightInPixels(font, fs1);
|
sl@0
|
778 |
if (font)
|
sl@0
|
779 |
{
|
sl@0
|
780 |
TFontSpec fs2 = font->FontSpecInTwips();
|
sl@0
|
781 |
iDev->ReleaseFont(font);
|
sl@0
|
782 |
if (fs2.iTypeface.iName.Compare(KTypefaceOT) == 0)
|
sl@0
|
783 |
{
|
sl@0
|
784 |
return ETrue;
|
sl@0
|
785 |
}
|
sl@0
|
786 |
}
|
sl@0
|
787 |
INFO_PRINTF1(_L("(N.B. Complex font not available so complex parts of test skipped)"));
|
sl@0
|
788 |
return EFalse;
|
sl@0
|
789 |
}
|
sl@0
|
790 |
|
sl@0
|
791 |
/**
|
sl@0
|
792 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0100
|
sl@0
|
793 |
|
sl@0
|
794 |
@SYMPREQ PREQ2146
|
sl@0
|
795 |
|
sl@0
|
796 |
@SYMREQ REQ10924, REQ10925, REQ10926
|
sl@0
|
797 |
|
sl@0
|
798 |
@SYMTestCaseDesc To ensure that a linked typeface including a complex font can be created
|
sl@0
|
799 |
and used. Test access to characters in a complex linked font.
|
sl@0
|
800 |
|
sl@0
|
801 |
@SYMTestPriority Critical
|
sl@0
|
802 |
|
sl@0
|
803 |
@SYMTestStatus Implemented
|
sl@0
|
804 |
|
sl@0
|
805 |
@SYMTestActions (1) Create a linked font with a complex typeface. Draw text,
|
sl@0
|
806 |
and compare against text drawn using a non-linked font.
|
sl@0
|
807 |
|
sl@0
|
808 |
@SYMTestExpectedResults (1) - test allows a linked font with a complex typeface to be created
|
sl@0
|
809 |
*/
|
sl@0
|
810 |
void CTLinkedFonts2::TestComplexLinkedFontsBasicL()
|
sl@0
|
811 |
{
|
sl@0
|
812 |
INFO_PRINTF1(_L("LinkedFonts2::TestComplexLinkedFontsBasicL"));
|
sl@0
|
813 |
|
sl@0
|
814 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
|
sl@0
|
815 |
CleanupStack::PushL(store);
|
sl@0
|
816 |
|
sl@0
|
817 |
TBool testComplex = ComplexFontAvailable();
|
sl@0
|
818 |
if (testComplex)
|
sl@0
|
819 |
{
|
sl@0
|
820 |
// Create typeface to be linked
|
sl@0
|
821 |
_LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
|
sl@0
|
822 |
_LIT(KLinkedTypefaceOT, "Chandas");
|
sl@0
|
823 |
|
sl@0
|
824 |
CLinkedTypefaceSpecification *typefaceSpec;
|
sl@0
|
825 |
_LIT(KLinkedTypefaceTTOT, "LinkedTypefaceComp");
|
sl@0
|
826 |
|
sl@0
|
827 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaceTTOT);
|
sl@0
|
828 |
|
sl@0
|
829 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
830 |
typefaceSpec->AddLinkedTypefaceGroupL(*group1);
|
sl@0
|
831 |
CleanupStack::Pop();
|
sl@0
|
832 |
|
sl@0
|
833 |
CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(2);
|
sl@0
|
834 |
typefaceSpec->AddLinkedTypefaceGroupL(*group2);
|
sl@0
|
835 |
CleanupStack::Pop();
|
sl@0
|
836 |
|
sl@0
|
837 |
// Add first typeface
|
sl@0
|
838 |
CLinkedTypefaceElementSpec *elementSpec1;
|
sl@0
|
839 |
elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
|
sl@0
|
840 |
|
sl@0
|
841 |
CLinkedTypefaceElementSpec *elementSpec2;
|
sl@0
|
842 |
elementSpec2 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceOT, 2);
|
sl@0
|
843 |
elementSpec2->SetCanonical(ETrue);
|
sl@0
|
844 |
|
sl@0
|
845 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
|
sl@0
|
846 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec2);
|
sl@0
|
847 |
CleanupStack::Pop(2, elementSpec1);
|
sl@0
|
848 |
|
sl@0
|
849 |
TEST(typefaceSpec->TypefaceCount() == 2);
|
sl@0
|
850 |
TEST(typefaceSpec->Name() == KLinkedTypefaceTTOT);
|
sl@0
|
851 |
|
sl@0
|
852 |
// Now try registering the linked typeface
|
sl@0
|
853 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
854 |
|
sl@0
|
855 |
if (ret == KErrNotSupported)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
INFO_PRINTF1(_L("No Rasterizer is present that supports the extended Font Linking interface. This test case has been skipped."));
|
sl@0
|
858 |
CleanupStack::PopAndDestroy(2,store);
|
sl@0
|
859 |
}
|
sl@0
|
860 |
else
|
sl@0
|
861 |
{
|
sl@0
|
862 |
TEST(ret == KErrNone);
|
sl@0
|
863 |
|
sl@0
|
864 |
// Create the linked font
|
sl@0
|
865 |
TTypeface typeface;
|
sl@0
|
866 |
typeface.iName = KLinkedTypefaceTTOT;
|
sl@0
|
867 |
TFontSpec fs;
|
sl@0
|
868 |
fs.iTypeface = typeface;
|
sl@0
|
869 |
fs.iHeight = 35;
|
sl@0
|
870 |
CFbsFont* font = NULL;
|
sl@0
|
871 |
TInt err = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
|
sl@0
|
872 |
|
sl@0
|
873 |
//check the font is the one requested
|
sl@0
|
874 |
TFontSpec fontSpec = font->FontSpecInTwips();
|
sl@0
|
875 |
TEST(fontSpec.iTypeface.iName == KLinkedTypefaceTTOT);
|
sl@0
|
876 |
|
sl@0
|
877 |
_LIT16(KEnglish1,"ABCD12345 ");
|
sl@0
|
878 |
_LIT16(KHindi1,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020");
|
sl@0
|
879 |
TEST(font != NULL);
|
sl@0
|
880 |
const TPoint englishLinked(10,75);
|
sl@0
|
881 |
const TPoint hindiLinked(10,150);
|
sl@0
|
882 |
if (font)
|
sl@0
|
883 |
{
|
sl@0
|
884 |
// Use the font
|
sl@0
|
885 |
iGc->UseFont(font);
|
sl@0
|
886 |
iGc->Clear();
|
sl@0
|
887 |
iGc->DrawText(KEnglish1, englishLinked);
|
sl@0
|
888 |
iGc->DrawText(KHindi1, hindiLinked);
|
sl@0
|
889 |
iGc->DiscardFont();
|
sl@0
|
890 |
iDev->Update();
|
sl@0
|
891 |
User::After(1000*1000*5);
|
sl@0
|
892 |
}
|
sl@0
|
893 |
|
sl@0
|
894 |
// All the CFont functions can use a linked font and a non-linked
|
sl@0
|
895 |
// font - with the same base font, results should be the same.
|
sl@0
|
896 |
// Compare with the test function.
|
sl@0
|
897 |
|
sl@0
|
898 |
//output the Hindi text
|
sl@0
|
899 |
TTypeface typeface2;
|
sl@0
|
900 |
typeface2.iName = KLinkedTypefaceOT;
|
sl@0
|
901 |
TFontSpec fs2;
|
sl@0
|
902 |
fs2.iTypeface = typeface2;
|
sl@0
|
903 |
fs2.iHeight = 35;
|
sl@0
|
904 |
CFbsFont* font2 = NULL;
|
sl@0
|
905 |
err = iDev->GetNearestFontToDesignHeightInPixels(font2, fs2);
|
sl@0
|
906 |
TEST(font2 != NULL);
|
sl@0
|
907 |
|
sl@0
|
908 |
//check the font is the one requested
|
sl@0
|
909 |
fontSpec = font2->FontSpecInTwips();
|
sl@0
|
910 |
TEST(fontSpec.iTypeface.iName == KLinkedTypefaceOT);
|
sl@0
|
911 |
|
sl@0
|
912 |
const TPoint englishHindiFont(240, 75);
|
sl@0
|
913 |
const TPoint hindiHindiFont(240, 150);
|
sl@0
|
914 |
if (font2)
|
sl@0
|
915 |
{
|
sl@0
|
916 |
// Use the font
|
sl@0
|
917 |
iGc->UseFont(font2);
|
sl@0
|
918 |
iGc->DrawText(KEnglish1, englishHindiFont);
|
sl@0
|
919 |
iGc->DrawText(KHindi1, hindiHindiFont);
|
sl@0
|
920 |
iGc->DiscardFont();
|
sl@0
|
921 |
iDev->Update();
|
sl@0
|
922 |
User::After(1000*1000);
|
sl@0
|
923 |
iDev->ReleaseFont(font2);
|
sl@0
|
924 |
}
|
sl@0
|
925 |
|
sl@0
|
926 |
//output the English text
|
sl@0
|
927 |
TTypeface typeface3;
|
sl@0
|
928 |
typeface3.iName = KLinkedTypefaceTT;
|
sl@0
|
929 |
TFontSpec fs3;
|
sl@0
|
930 |
fs3.iTypeface = typeface3;
|
sl@0
|
931 |
fs3.iHeight = 35;
|
sl@0
|
932 |
CFbsFont* font3 = NULL;
|
sl@0
|
933 |
err = iDev->GetNearestFontToDesignHeightInPixels(font3, fs3);
|
sl@0
|
934 |
TEST(font3 != NULL);
|
sl@0
|
935 |
|
sl@0
|
936 |
//check the font is the one requested
|
sl@0
|
937 |
fontSpec = font3->FontSpecInTwips();
|
sl@0
|
938 |
TEST(fontSpec.iTypeface.iName == KLinkedTypefaceTT);
|
sl@0
|
939 |
|
sl@0
|
940 |
const TPoint englishSansSerifFont(440, 75);
|
sl@0
|
941 |
const TPoint hindiSansSerifFont(440, 150);
|
sl@0
|
942 |
if (font3)
|
sl@0
|
943 |
{
|
sl@0
|
944 |
// Use the font
|
sl@0
|
945 |
iGc->UseFont(font3);
|
sl@0
|
946 |
iGc->DrawText(KEnglish1, englishSansSerifFont);
|
sl@0
|
947 |
iGc->DrawText(KHindi1, hindiSansSerifFont);
|
sl@0
|
948 |
iGc->DiscardFont();
|
sl@0
|
949 |
iDev->Update();
|
sl@0
|
950 |
User::After(1000*1000);
|
sl@0
|
951 |
iDev->ReleaseFont(font3);
|
sl@0
|
952 |
}
|
sl@0
|
953 |
|
sl@0
|
954 |
//compare rects.
|
sl@0
|
955 |
if (font)
|
sl@0
|
956 |
{
|
sl@0
|
957 |
CFont::TMeasureTextOutput compareEnglish;
|
sl@0
|
958 |
CFont::TMeasureTextOutput compareHindi;
|
sl@0
|
959 |
//get the size of a text box to do the comparison
|
sl@0
|
960 |
font->MeasureText(KEnglish1, NULL, &compareEnglish);
|
sl@0
|
961 |
font->MeasureText(KHindi1, NULL, &compareHindi);
|
sl@0
|
962 |
|
sl@0
|
963 |
//compare English
|
sl@0
|
964 |
TRect englishLinkedRect (englishLinked.iX,englishLinked.iY,
|
sl@0
|
965 |
englishLinked.iX+compareEnglish.iBounds.Width(),
|
sl@0
|
966 |
englishLinked.iY+compareEnglish.iBounds.Height());
|
sl@0
|
967 |
TRect englishSansSerifRect (englishSansSerifFont.iX,englishSansSerifFont.iY,
|
sl@0
|
968 |
englishSansSerifFont.iX+compareEnglish.iBounds.Width(),
|
sl@0
|
969 |
englishSansSerifFont.iY+compareEnglish.iBounds.Height());
|
sl@0
|
970 |
|
sl@0
|
971 |
TBool val = iDev->RectCompare(englishLinkedRect, *iDev,englishSansSerifRect);
|
sl@0
|
972 |
//this value is not compared since the rasterizer may resize/reposition fonts
|
sl@0
|
973 |
|
sl@0
|
974 |
//compare Hindi
|
sl@0
|
975 |
TRect hindiLinkedRect (hindiLinked.iX,hindiLinked.iY,
|
sl@0
|
976 |
hindiLinked.iX+compareHindi.iBounds.Width(),
|
sl@0
|
977 |
hindiLinked.iY+compareHindi.iBounds.Height());
|
sl@0
|
978 |
TRect hindiHindiRect (hindiHindiFont.iX,hindiHindiFont.iY,
|
sl@0
|
979 |
hindiHindiFont.iX+compareHindi.iBounds.Width(),
|
sl@0
|
980 |
hindiHindiFont.iY+compareHindi.iBounds.Height());
|
sl@0
|
981 |
val=iDev->RectCompare(hindiLinkedRect, *iDev,hindiHindiRect);
|
sl@0
|
982 |
//do not call TEST(val) since size/position may be slightly different
|
sl@0
|
983 |
iDev->ReleaseFont(font);
|
sl@0
|
984 |
}
|
sl@0
|
985 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
986 |
}
|
sl@0
|
987 |
}
|
sl@0
|
988 |
}
|
sl@0
|
989 |
|
sl@0
|
990 |
/**
|
sl@0
|
991 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0101
|
sl@0
|
992 |
|
sl@0
|
993 |
@SYMPREQ PREQ2146
|
sl@0
|
994 |
|
sl@0
|
995 |
@SYMREQ REQ10924, REQ10925, REQ10926
|
sl@0
|
996 |
|
sl@0
|
997 |
@SYMTestCaseDesc To test PREQ2146 linked fonts with bitmap fonts. Bitmap fonts are not
|
sl@0
|
998 |
supported so an error needs to be returned on registration.
|
sl@0
|
999 |
|
sl@0
|
1000 |
@SYMTestPriority Critical
|
sl@0
|
1001 |
|
sl@0
|
1002 |
@SYMTestStatus Implemented
|
sl@0
|
1003 |
|
sl@0
|
1004 |
@SYMTestActions (1) Create a linked typeface elements, with one of them from a bitmap font
|
sl@0
|
1005 |
try registering, and KErrNotSupported error should be returned
|
sl@0
|
1006 |
|
sl@0
|
1007 |
@SYMTestExpectedResults (1) - registering a bitmap font returns KErrNotSupported.
|
sl@0
|
1008 |
*/
|
sl@0
|
1009 |
void CTLinkedFonts2::TestBitmapFontsL()
|
sl@0
|
1010 |
{
|
sl@0
|
1011 |
INFO_PRINTF1(_L("LinkedFonts2::TestBitmapFontsL"));
|
sl@0
|
1012 |
|
sl@0
|
1013 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
|
sl@0
|
1014 |
CleanupStack::PushL(store);
|
sl@0
|
1015 |
|
sl@0
|
1016 |
// Create typeface to be linked
|
sl@0
|
1017 |
_LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
|
sl@0
|
1018 |
_LIT(KLinkedTypeFace1, "LinkedFont1"); //this is a bitmap font
|
sl@0
|
1019 |
|
sl@0
|
1020 |
CLinkedTypefaceSpecification *typefaceSpec;
|
sl@0
|
1021 |
_LIT(KLinkedTypefaceBitmap, "LinkedTypefaceBitmap");
|
sl@0
|
1022 |
|
sl@0
|
1023 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaceBitmap);
|
sl@0
|
1024 |
|
sl@0
|
1025 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
1026 |
typefaceSpec->AddLinkedTypefaceGroupL(*group1);
|
sl@0
|
1027 |
CleanupStack::Pop();
|
sl@0
|
1028 |
|
sl@0
|
1029 |
CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(2);
|
sl@0
|
1030 |
typefaceSpec->AddLinkedTypefaceGroupL(*group2);
|
sl@0
|
1031 |
CleanupStack::Pop();
|
sl@0
|
1032 |
|
sl@0
|
1033 |
// Add first typeface
|
sl@0
|
1034 |
CLinkedTypefaceElementSpec *elementSpec1;
|
sl@0
|
1035 |
elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 2);
|
sl@0
|
1036 |
|
sl@0
|
1037 |
CLinkedTypefaceElementSpec *elementSpec2;
|
sl@0
|
1038 |
elementSpec2 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace1, 1);
|
sl@0
|
1039 |
elementSpec2->SetCanonical(ETrue);
|
sl@0
|
1040 |
|
sl@0
|
1041 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
|
sl@0
|
1042 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec2);
|
sl@0
|
1043 |
CleanupStack::Pop(2, elementSpec1);
|
sl@0
|
1044 |
|
sl@0
|
1045 |
TEST(typefaceSpec->TypefaceCount() == 2);
|
sl@0
|
1046 |
TEST(typefaceSpec->Name() == KLinkedTypefaceBitmap);
|
sl@0
|
1047 |
|
sl@0
|
1048 |
// Now try regstering the linked typeface
|
sl@0
|
1049 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
1050 |
TEST(ret == KErrNotSupported);
|
sl@0
|
1051 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
|
sl@0
|
1054 |
/**
|
sl@0
|
1055 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0109
|
sl@0
|
1056 |
|
sl@0
|
1057 |
@SYMPREQ PREQ2146
|
sl@0
|
1058 |
|
sl@0
|
1059 |
@SYMREQ REQ10924, REQ10925, REQ10926
|
sl@0
|
1060 |
|
sl@0
|
1061 |
@SYMTestCaseDesc To test PREQ2146 linked fonts updates to the TOpenFontCharMetrics class.
|
sl@0
|
1062 |
|
sl@0
|
1063 |
@SYMTestPriority Critical
|
sl@0
|
1064 |
|
sl@0
|
1065 |
@SYMTestStatus Implemented
|
sl@0
|
1066 |
|
sl@0
|
1067 |
@SYMTestActions (1) Create a TOpenFontCharMetrics object.
|
sl@0
|
1068 |
(2) Check that nothing is set
|
sl@0
|
1069 |
(3) Set a small positive baseline
|
sl@0
|
1070 |
(4) Check that the baseline is as set and the glyph type is still not set
|
sl@0
|
1071 |
(5) Set a large positive baseline
|
sl@0
|
1072 |
(6) Check that the baseline is as set and the glyph type is still not set
|
sl@0
|
1073 |
(7) Set a large negative baseline
|
sl@0
|
1074 |
(8) Check that the baseline is as set and the glyph type is still not set
|
sl@0
|
1075 |
(9) Set the glyph type.
|
sl@0
|
1076 |
(10) Check that the baseline is as set and the glyph type is as set
|
sl@0
|
1077 |
(11) Set the baseline to a again to various values
|
sl@0
|
1078 |
(12) Check that the baseline is as set and the glyph type has not changed
|
sl@0
|
1079 |
|
sl@0
|
1080 |
@SYMTestExpectedResults (2) the default values are 0 for baseline and EGlyphBitmapTypeNotDefined for glyph type
|
sl@0
|
1081 |
(4)(6)(8)(10)(12) The values are are set, and setting the baseline does
|
sl@0
|
1082 |
not alter the glyph type and vice-versa.
|
sl@0
|
1083 |
*/
|
sl@0
|
1084 |
void CTLinkedFonts2::TestTOpenFontMetrics()
|
sl@0
|
1085 |
{
|
sl@0
|
1086 |
TOpenFontMetrics metrics;
|
sl@0
|
1087 |
|
sl@0
|
1088 |
TInt len = metrics.BaselineCorrection();
|
sl@0
|
1089 |
TEST(len==0);
|
sl@0
|
1090 |
|
sl@0
|
1091 |
metrics.SetBaselineCorrection(22);
|
sl@0
|
1092 |
len = metrics.BaselineCorrection();
|
sl@0
|
1093 |
TEST(len==22);
|
sl@0
|
1094 |
|
sl@0
|
1095 |
metrics.SetBaselineCorrection(444);
|
sl@0
|
1096 |
len = metrics.BaselineCorrection();
|
sl@0
|
1097 |
TEST(len==444);
|
sl@0
|
1098 |
|
sl@0
|
1099 |
metrics.SetBaselineCorrection(-333);
|
sl@0
|
1100 |
len = metrics.BaselineCorrection();
|
sl@0
|
1101 |
TEST(len==-333);
|
sl@0
|
1102 |
|
sl@0
|
1103 |
metrics.SetBaselineCorrection(444);
|
sl@0
|
1104 |
len = metrics.BaselineCorrection();
|
sl@0
|
1105 |
TEST(len==444);
|
sl@0
|
1106 |
|
sl@0
|
1107 |
metrics.SetBaselineCorrection(-1);
|
sl@0
|
1108 |
len = metrics.BaselineCorrection();
|
sl@0
|
1109 |
TEST(len==-1);
|
sl@0
|
1110 |
|
sl@0
|
1111 |
}
|
sl@0
|
1112 |
|
sl@0
|
1113 |
void CTLinkedFonts2::TestLinkedRegistrationAndFetchL()
|
sl@0
|
1114 |
{
|
sl@0
|
1115 |
INFO_PRINTF1(_L("CTLinkedFonts2::TestLinkedRegistrationAndFetchL"));
|
sl@0
|
1116 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
|
sl@0
|
1117 |
CleanupStack::PushL(store);
|
sl@0
|
1118 |
|
sl@0
|
1119 |
//Create and register a dummy linked typeface to register.
|
sl@0
|
1120 |
_LIT(KFetchTypefaceName, "FetchFont");
|
sl@0
|
1121 |
CLinkedTypefaceSpecification* typefaceSpec = CLinkedTypefaceSpecification::NewLC(KFetchTypefaceName);
|
sl@0
|
1122 |
|
sl@0
|
1123 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
1124 |
group1->SetBoldnessPercentage(20);
|
sl@0
|
1125 |
group1->SetItalicAngle(10);
|
sl@0
|
1126 |
group1->SetBaselineShift(CLinkedTypefaceGroup::EBaselineShift);
|
sl@0
|
1127 |
group1->SetScalingOption(CLinkedTypefaceGroup::EScalingDown);
|
sl@0
|
1128 |
|
sl@0
|
1129 |
typefaceSpec->AddLinkedTypefaceGroupL(*group1);
|
sl@0
|
1130 |
CleanupStack::Pop(group1);
|
sl@0
|
1131 |
|
sl@0
|
1132 |
CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(2);
|
sl@0
|
1133 |
group2->SetBoldnessPercentage(21);
|
sl@0
|
1134 |
group2->SetItalicAngle(11);
|
sl@0
|
1135 |
group2->SetBaselineShift(CLinkedTypefaceGroup::ENoBaselineShift);
|
sl@0
|
1136 |
group2->SetScalingOption(CLinkedTypefaceGroup::EScalingUp);
|
sl@0
|
1137 |
|
sl@0
|
1138 |
typefaceSpec->AddLinkedTypefaceGroupL(*group2);
|
sl@0
|
1139 |
CleanupStack::Pop(group2);
|
sl@0
|
1140 |
|
sl@0
|
1141 |
_LIT(KElement1Name, "DejaVu Sans Condensed");
|
sl@0
|
1142 |
CLinkedTypefaceElementSpec* element1 = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1);
|
sl@0
|
1143 |
element1->SetCanonical(ETrue);
|
sl@0
|
1144 |
typefaceSpec->AddTypefaceAtBackL(*element1);
|
sl@0
|
1145 |
CleanupStack::Pop(element1);
|
sl@0
|
1146 |
|
sl@0
|
1147 |
_LIT(KElement2Name, "Chandas");
|
sl@0
|
1148 |
CLinkedTypefaceElementSpec* element2 = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2);
|
sl@0
|
1149 |
typefaceSpec->AddTypefaceAtBackL(*element2);
|
sl@0
|
1150 |
CleanupStack::Pop(element2);
|
sl@0
|
1151 |
|
sl@0
|
1152 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
1153 |
if (ret == KErrNotSupported)
|
sl@0
|
1154 |
{
|
sl@0
|
1155 |
INFO_PRINTF1(_L("No Rasterizer is present that supports the extended Font Linking interface. This test case has been skipped."));
|
sl@0
|
1156 |
CleanupStack::PopAndDestroy(2,store);
|
sl@0
|
1157 |
}
|
sl@0
|
1158 |
else
|
sl@0
|
1159 |
{
|
sl@0
|
1160 |
TEST(ret == KErrNone);
|
sl@0
|
1161 |
|
sl@0
|
1162 |
CLinkedTypefaceSpecification* fetchSpec = CLinkedTypefaceSpecification::NewLC(KFetchTypefaceName);
|
sl@0
|
1163 |
TRAP(ret, fetchSpec->FetchLinkedTypefaceSpecificationL(*store));
|
sl@0
|
1164 |
TEST(ret == KErrNone);
|
sl@0
|
1165 |
|
sl@0
|
1166 |
//Compare Groups. Ordering isn't important so can get group by id rather than index.
|
sl@0
|
1167 |
TEST(typefaceSpec->GroupCount() == fetchSpec->GroupCount());
|
sl@0
|
1168 |
CLinkedTypefaceGroup* groupf = fetchSpec->GroupById(1);
|
sl@0
|
1169 |
TEST(CompareGroups(group1,groupf));
|
sl@0
|
1170 |
|
sl@0
|
1171 |
groupf = fetchSpec->GroupById(2);
|
sl@0
|
1172 |
TEST(CompareGroups(group2,groupf));
|
sl@0
|
1173 |
|
sl@0
|
1174 |
//Check elements match
|
sl@0
|
1175 |
TEST(typefaceSpec->TypefaceCount() == fetchSpec->TypefaceCount());
|
sl@0
|
1176 |
|
sl@0
|
1177 |
CLinkedTypefaceElementSpec* elementf = fetchSpec->Typeface(0);
|
sl@0
|
1178 |
TEST(CompareElementSpecs(elementf, element1));
|
sl@0
|
1179 |
elementf = fetchSpec->Typeface(1);
|
sl@0
|
1180 |
TEST(CompareElementSpecs(elementf, element2));
|
sl@0
|
1181 |
|
sl@0
|
1182 |
CleanupStack::PopAndDestroy(3,store);
|
sl@0
|
1183 |
}
|
sl@0
|
1184 |
}
|
sl@0
|
1185 |
|
sl@0
|
1186 |
/**
|
sl@0
|
1187 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0110
|
sl@0
|
1188 |
|
sl@0
|
1189 |
@SYMDEF DEF137360
|
sl@0
|
1190 |
|
sl@0
|
1191 |
@SYMTestCaseDesc Ensure that font full names are used to build a linked font
|
sl@0
|
1192 |
|
sl@0
|
1193 |
@SYMTestPriority Critical
|
sl@0
|
1194 |
|
sl@0
|
1195 |
@SYMTestStatus Implemented
|
sl@0
|
1196 |
|
sl@0
|
1197 |
@SYMTestActions Attempt to register a linked font using a font full name rather than a family
|
sl@0
|
1198 |
name. DejaVu Sans Condensed is both a family name and a full name. DejaVu Sans Mono Bold is full name only.
|
sl@0
|
1199 |
|
sl@0
|
1200 |
@SYMTestExpectedResults Registration of the linked font will be sucessful.
|
sl@0
|
1201 |
Failing with KErrNotFound means either the test font is not available or there is a regression.
|
sl@0
|
1202 |
*/
|
sl@0
|
1203 |
void CTLinkedFonts2::TestFontNameUsage()
|
sl@0
|
1204 |
{
|
sl@0
|
1205 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(NULL);
|
sl@0
|
1206 |
CleanupStack::PushL(store);
|
sl@0
|
1207 |
|
sl@0
|
1208 |
CLinkedTypefaceSpecification* nameSpec = CLinkedTypefaceSpecification::NewLC(_L("FullNameTest"));
|
sl@0
|
1209 |
|
sl@0
|
1210 |
CLinkedTypefaceGroup* group = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
1211 |
nameSpec->AddLinkedTypefaceGroupL(*group);
|
sl@0
|
1212 |
CleanupStack::Pop(group);
|
sl@0
|
1213 |
|
sl@0
|
1214 |
//Use a font whose name doesn't match a family name
|
sl@0
|
1215 |
CLinkedTypefaceElementSpec* element1 = CLinkedTypefaceElementSpec::NewLC(_L("DejaVu Sans Mono Bold"), 1);
|
sl@0
|
1216 |
element1->SetCanonical(ETrue);
|
sl@0
|
1217 |
nameSpec->AddTypefaceAtBackL(*element1);
|
sl@0
|
1218 |
CleanupStack::Pop(element1);
|
sl@0
|
1219 |
|
sl@0
|
1220 |
CLinkedTypefaceElementSpec* element2 = CLinkedTypefaceElementSpec::NewLC(_L("Chandas"), 1);
|
sl@0
|
1221 |
nameSpec->AddTypefaceAtBackL(*element2);
|
sl@0
|
1222 |
CleanupStack::Pop(element2);
|
sl@0
|
1223 |
|
sl@0
|
1224 |
TRAPD(ret, store->RegisterLinkedTypeface(*nameSpec));
|
sl@0
|
1225 |
|
sl@0
|
1226 |
TEST(ret == KErrNone);
|
sl@0
|
1227 |
|
sl@0
|
1228 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
|
sl@0
|
1231 |
TBool CTLinkedFonts2::CompareElementSpecs(CLinkedTypefaceElementSpec* aSpec1, CLinkedTypefaceElementSpec* aSpec2)
|
sl@0
|
1232 |
{
|
sl@0
|
1233 |
if ( (aSpec1 == NULL ) && (aSpec2 == NULL) )
|
sl@0
|
1234 |
return ETrue;
|
sl@0
|
1235 |
if ( (aSpec1 == NULL) || (aSpec2 == NULL) )
|
sl@0
|
1236 |
return EFalse;
|
sl@0
|
1237 |
if (aSpec1->ElementName().Compare(aSpec2->ElementName()) != 0)
|
sl@0
|
1238 |
return EFalse;
|
sl@0
|
1239 |
if (aSpec1->Canonical() != aSpec2->Canonical())
|
sl@0
|
1240 |
return EFalse;
|
sl@0
|
1241 |
if (aSpec1->GroupId() != aSpec2->GroupId())
|
sl@0
|
1242 |
return EFalse;
|
sl@0
|
1243 |
|
sl@0
|
1244 |
return ETrue;
|
sl@0
|
1245 |
}
|
sl@0
|
1246 |
|
sl@0
|
1247 |
TBool CTLinkedFonts2::CompareElementSpecs(COpenFontLinkedTypefaceElementSpec* aSpec1, COpenFontLinkedTypefaceElementSpec* aSpec2)
|
sl@0
|
1248 |
{
|
sl@0
|
1249 |
if ( (aSpec1 == NULL ) && (aSpec2 == NULL) )
|
sl@0
|
1250 |
return ETrue;
|
sl@0
|
1251 |
if ( (aSpec1 == NULL) || (aSpec2 == NULL) )
|
sl@0
|
1252 |
return EFalse;
|
sl@0
|
1253 |
if (aSpec1->ElementName().Compare(aSpec2->ElementName()) != 0)
|
sl@0
|
1254 |
return EFalse;
|
sl@0
|
1255 |
if (aSpec1->Canonical() != aSpec2->Canonical())
|
sl@0
|
1256 |
return EFalse;
|
sl@0
|
1257 |
if (aSpec1->GroupId() != aSpec2->GroupId())
|
sl@0
|
1258 |
return EFalse;
|
sl@0
|
1259 |
|
sl@0
|
1260 |
return ETrue;
|
sl@0
|
1261 |
}
|
sl@0
|
1262 |
/**
|
sl@0
|
1263 |
Compare two linked typeface groups; the first varable should be a locally created group and the second one fetched from the
|
sl@0
|
1264 |
rasterizer. If the local group has thresholds / metrics set to -1 ("best guess by rasterizer") then the differences between the
|
sl@0
|
1265 |
values are ignored.
|
sl@0
|
1266 |
*/
|
sl@0
|
1267 |
TBool CTLinkedFonts2::CompareGroups(CLinkedTypefaceGroup* aLocalGroup, CLinkedTypefaceGroup* aFetchedGroup)
|
sl@0
|
1268 |
{
|
sl@0
|
1269 |
if ( (aLocalGroup == NULL) && (aFetchedGroup == NULL) )
|
sl@0
|
1270 |
return ETrue;
|
sl@0
|
1271 |
if ( (aLocalGroup == NULL) || (aFetchedGroup == NULL) )
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
INFO_PRINTF1(_L("One of the specified groups is NULL"));
|
sl@0
|
1274 |
return EFalse;
|
sl@0
|
1275 |
}
|
sl@0
|
1276 |
|
sl@0
|
1277 |
if (aLocalGroup->BaselineShift() != aFetchedGroup->BaselineShift())
|
sl@0
|
1278 |
return EFalse;
|
sl@0
|
1279 |
|
sl@0
|
1280 |
/*if (aLocalGroup->BoldnessPercentage() != -1)
|
sl@0
|
1281 |
{
|
sl@0
|
1282 |
if (aLocalGroup->BoldnessPercentage() != aFetchedGroup->BoldnessPercentage())
|
sl@0
|
1283 |
{
|
sl@0
|
1284 |
INFO_PRINTF1(_L("Fail below caused by non-matching boldness percentages"));
|
sl@0
|
1285 |
return EFalse;
|
sl@0
|
1286 |
}
|
sl@0
|
1287 |
}
|
sl@0
|
1288 |
|
sl@0
|
1289 |
if (aLocalGroup->ItalicAngle() != -1)
|
sl@0
|
1290 |
{
|
sl@0
|
1291 |
if (aLocalGroup->ItalicAngle() != aFetchedGroup->ItalicAngle())
|
sl@0
|
1292 |
{
|
sl@0
|
1293 |
INFO_PRINTF1(_L("Fail below caused by non-matching italic angles"));
|
sl@0
|
1294 |
return EFalse;
|
sl@0
|
1295 |
}
|
sl@0
|
1296 |
}
|
sl@0
|
1297 |
*/
|
sl@0
|
1298 |
if (aLocalGroup->ScalingOption() != aFetchedGroup->ScalingOption())
|
sl@0
|
1299 |
return EFalse;
|
sl@0
|
1300 |
if (aLocalGroup->GroupId() != aFetchedGroup->GroupId())
|
sl@0
|
1301 |
return EFalse;
|
sl@0
|
1302 |
|
sl@0
|
1303 |
return ETrue;
|
sl@0
|
1304 |
}
|
sl@0
|
1305 |
|
sl@0
|
1306 |
__CONSTRUCT_STEP__(LinkedFonts2)
|