Update contrib.
2 * Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_LinkedFontUpdateTests.h"
20 CTLinkedFontsUpdateStage1::CTLinkedFontsUpdateStage1(CTestStep* aStep)
21 : CTGraphicsBase(aStep)
23 iFontLinkingSupported = EFalse;
26 CTLinkedFontsUpdateStage1::~CTLinkedFontsUpdateStage1()
30 void CTLinkedFontsUpdateStage1::TestPanic(TInt aPanic)
32 _LIT(KFntTestStorePanicCategory,"TestFntStore");
33 User::Panic(KFntTestStorePanicCategory,aPanic);
36 void CTLinkedFontsUpdateStage1::RunTestCaseL(TInt aCurTestCase)
38 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
42 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
46 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0200"));
47 RegisterThenUpdateTestL();
50 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0201"));
51 NegativeUpdateTestsL();
54 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
58 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
59 ((CTLinkedFontsUpdateStage1Step*)iStep)->CloseTMSGraphicsStep();
63 ((CTLinkedFontsUpdateStage1Step*)iStep)->RecordTestResultL();
67 Connect to the Font Bitmap Server and construct a CFbsTypeface store to access the fontstore.
69 void CTLinkedFontsUpdateStage1::SetupTestsL()
71 TInt ret = RFbsSession::Connect();
74 iFbs = RFbsSession::GetSession();
76 iTfStore = CFbsTypefaceStore::NewL(NULL);
79 void CTLinkedFontsUpdateStage1::CloseTestsL()
82 RFbsSession::Disconnect();
86 GRAPHICS-FNTSTORE-LINKEDFONTS-0200
95 Creates three brand new linked typefaces, then updates each. The first typeface has an
96 element added to it, the second has one removed and the third is replaced with a different
99 The outcome of the update process is checked after a reboot by test case 202.
108 Checks the update process has completed succesfully.
110 @SYMTestExpectedResults
111 Linked fonts are created and updated successfully. Validation of the new file is performed after a reboot.
114 void CTLinkedFontsUpdateStage1::RegisterThenUpdateTestL()
116 CLinkedTypefaceSpecification* addSpec = CreateAddTypefaceLC(EFalse);
117 CLinkedTypefaceSpecification* removeSpec = CreateRemoveTypefaceLC(EFalse);
118 CLinkedTypefaceSpecification* updateSpec = CreateUpdateTypefaceLC(EFalse);
120 //Create three new linked fonts
121 TRAPD(ret, addSpec->RegisterLinkedTypefaceL(*iTfStore));
123 //Ensure that a supporting rasterizer is present.
124 if (ret == KErrNotSupported)
126 WARN_PRINTF1(_L("There is not a font rasterizer present supporting font linking installed, skipping test."));
127 CleanupStack::PopAndDestroy(3, addSpec);
132 iFontLinkingSupported = ETrue;
135 TEST(ret == KErrNone);
136 TRAP(ret, removeSpec->RegisterLinkedTypefaceL(*iTfStore));
137 TEST(ret == KErrNone);
138 TRAP(ret, updateSpec->RegisterLinkedTypefaceL(*iTfStore));
139 TEST(ret == KErrNone);
141 CleanupStack::PopAndDestroy(3);
143 //Update the three linked fonts with their new specifications
144 addSpec = CreateAddTypefaceLC(ETrue);
145 TRAP(ret, addSpec->UpdateLinkedTypefaceL(*iTfStore));
146 TEST(ret == KErrNone);
148 removeSpec = CreateRemoveTypefaceLC(ETrue);
149 TRAP(ret, removeSpec->UpdateLinkedTypefaceL(*iTfStore));
150 TEST(ret == KErrNone);
152 updateSpec = CreateUpdateTypefaceLC(ETrue);
153 TRAP(ret, updateSpec->UpdateLinkedTypefaceL(*iTfStore));
154 TEST(ret == KErrNone);
156 CleanupStack::PopAndDestroy(3, addSpec);
161 GRAPHICS-FNTSTORE-LINKEDFONTS-0201
170 Attempt to update a linked font with Invalid or Non-Existent Elements.
171 Attempt to update a non-linked font.
180 Ensures the correct error codes are returned showing that no updates were made to the relevant typefaces.
182 @SYMTestExpectedResults
183 All invalid updates will return KErrNotFound or KErrAccessDenied
185 void CTLinkedFontsUpdateStage1::NegativeUpdateTestsL()
187 if (!iFontLinkingSupported)
189 WARN_PRINTF1(_L("There is not a font rasterizer present supporting font linking installed, skipping test."));
192 //Update with invalid element
193 CLinkedTypefaceSpecification* invalidSpec = CreateUpdateTypefaceLC(EFalse);
195 CLinkedTypefaceElementSpec* invalidElement = CLinkedTypefaceElementSpec::NewLC(_L("SomeThingInValid"), 1);
196 invalidSpec->AddTypefaceAtBackL(*invalidElement);
197 CleanupStack::Pop(invalidElement);
199 TRAPD(ret, invalidSpec->UpdateLinkedTypefaceL(*iTfStore));
200 TEST(ret == KErrNotFound);
202 CleanupStack::PopAndDestroy(invalidSpec);
204 //Update a typeface that doesn't exist.
205 _LIT(KNonExistantTypeface, "DoesNotExist");
206 CLinkedTypefaceSpecification* nonExistentTypeface = CreateNegativeTestTypefaceLC(KNonExistantTypeface);
207 TRAP(ret, nonExistentTypeface->UpdateLinkedTypefaceL(*iTfStore));
208 TEST(ret == KErrNotFound);
210 CleanupStack::PopAndDestroy(nonExistentTypeface);
212 //Update the default techview font (that is not a linked font).
213 _LIT(KNonLinkedFontName, "DejaVu Sans Condensed");
214 CLinkedTypefaceSpecification* nonLinkedTypeface = CreateNegativeTestTypefaceLC(KNonLinkedFontName);
215 TRAP(ret, nonLinkedTypeface->UpdateLinkedTypefaceL(*iTfStore));
216 TEST(ret == KErrAccessDenied);
218 CleanupStack::PopAndDestroy(nonLinkedTypeface);
223 Create a typeface to test adding a new element to a linked font.
224 @param TBool EFalse for Original, ETrue for Update version
226 CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateAddTypefaceLC(TBool aUpdate)
228 CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KAddElementFontName);
232 CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1);
233 element->SetCanonical(ETrue);
234 spec->AddTypefaceAtBackL(*element);
235 CleanupStack::Pop(element);
237 element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2);
238 spec->AddTypefaceAtBackL(*element);
239 CleanupStack::Pop(element);
243 element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 2);
244 spec->AddTypefaceAtBackL(*element);
245 CleanupStack::Pop(element);
252 Create a typeface to test removing an element from a linked font.
253 @param TBool EFalse for Original, ETrue for Update version
255 CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateRemoveTypefaceLC(TBool aUpdate)
257 CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KRemoveElementFontName);
260 CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1);
261 element->SetCanonical(ETrue);
262 spec->AddTypefaceAtBackL(*element);
263 CleanupStack::Pop(element);
265 element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2);
266 spec->AddTypefaceAtBackL(*element);
267 CleanupStack::Pop(element);
271 element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 2);
272 spec->AddTypefaceAtBackL(*element);
273 CleanupStack::Pop(element);
280 Create a typeface to test completely changing a linked font.
281 @param TBool EFalse for Original, ETrue for Update version
283 CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateUpdateTypefaceLC(TBool aUpdate)
285 CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KUpdateFontName);
288 CLinkedTypefaceElementSpec* element;
292 element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1);
293 element->SetCanonical(ETrue);
294 spec->AddTypefaceAtBackL(*element);
295 CleanupStack::Pop(element);
298 element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2);
299 spec->AddTypefaceAtBackL(*element);
300 CleanupStack::Pop(element);
304 CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 1);
305 element->SetCanonical(ETrue);
306 spec->AddTypefaceAtBackL(*element);
307 CleanupStack::Pop(element);
314 Create a typeface for use in the negative test cases.
316 This has a number of typeface groups already added to it.
318 @see CTLinkedFontsUpdate1::AddGroups()
319 @param aName The name of the typeface.
321 CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateNegativeTestTypefaceLC(const TDesC& aName)
323 CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(aName);
327 CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(_L("DejaVu Sans Condensed"), 1);
328 element->SetCanonical(ETrue);
329 spec->AddTypefaceAtBackL(*element);
330 CleanupStack::Pop(element);
336 Adds two simple linked typeface groups to the linked typeface group.
338 @param aSpec The specification to have groups added to
340 void CTLinkedFontsUpdateStage1::AddGroups(CLinkedTypefaceSpecification* aSpec)
342 CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(1);
343 grp->SetBaselineShift(CLinkedTypefaceGroup::EBaselineShift);
344 aSpec->AddLinkedTypefaceGroupL(*grp);
345 CleanupStack::Pop(grp);
347 grp = CLinkedTypefaceGroup::NewLC(2);
348 grp->SetBaselineShift(CLinkedTypefaceGroup::ENoBaselineShift);
349 aSpec->AddLinkedTypefaceGroupL(*grp);
350 CleanupStack::Pop(grp);
353 __CONSTRUCT_STEP__(LinkedFontsUpdateStage1)
356 //CTLinkedFontsUpdate2
357 CTLinkedFontsUpdateStage2::CTLinkedFontsUpdateStage2(CTestStep* aStep)
358 : CTGraphicsBase(aStep)
362 CTLinkedFontsUpdateStage2::~CTLinkedFontsUpdateStage2()
366 void CTLinkedFontsUpdateStage2::TestPanic(TInt aPanic)
368 _LIT(KFntTestStorePanicCategory,"TestFntStore");
369 User::Panic(KFntTestStorePanicCategory,aPanic);
372 void CTLinkedFontsUpdateStage2::RunTestCaseL(TInt aCurTestCase)
374 ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
375 switch (aCurTestCase)
378 ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
382 ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0202"));
383 ValidateLinkedFontsL();
386 ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
389 ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
390 ((CTLinkedFontsUpdateStage2Step*)iStep)->CloseTMSGraphicsStep();
394 ((CTLinkedFontsUpdateStage2Step*)iStep)->RecordTestResultL();
398 Connect to the Font Bitmap Server and construct a CFbsTypeface store to access the fontstore.
400 void CTLinkedFontsUpdateStage2::SetupTestsL()
402 TInt ret = RFbsSession::Connect();
403 TEST2(ret, KErrNone);
405 iFbs = RFbsSession::GetSession();
407 iTfStore = CFbsTypefaceStore::NewL(NULL);
410 void CTLinkedFontsUpdateStage2::CloseTestsL()
413 RFbsSession::Disconnect();
417 GRAPHICS-FNTSTORE-LINKEDFONTS-0202
426 Tests the updates made to three linked typefaces created by test case 200; this checks the linked fonts
427 have been correctly updated to the latest specification.
436 Checks the update process has completed succesfully.
438 @SYMTestExpectedResults
439 The linked fonts match the specification they were updated to.
440 Failures may be due to other failures in test case xxx as this is the second stage of these tests.
442 void CTLinkedFontsUpdateStage2::ValidateLinkedFontsL()
444 CLinkedTypefaceSpecification* addSpec = CLinkedTypefaceSpecification::NewLC(KAddElementFontName);
445 TRAPD(ret, addSpec->FetchLinkedTypefaceSpecificationL(*iTfStore));
446 TEST(ret == KErrNone);
448 CLinkedTypefaceSpecification* removeSpec = CLinkedTypefaceSpecification::NewLC(KRemoveElementFontName);
449 TRAP(ret, removeSpec->FetchLinkedTypefaceSpecificationL(*iTfStore));
450 TEST(ret == KErrNone);
452 CLinkedTypefaceSpecification* updateSpec = CLinkedTypefaceSpecification::NewLC(KUpdateFontName);
453 TRAP(ret, updateSpec->FetchLinkedTypefaceSpecificationL(*iTfStore));
454 TEST(ret == KErrNone);
456 //Test Elements are in correct order
457 TEST(addSpec->TypefaceCount() == 3);
459 if (addSpec->Typeface(0))
460 TEST(addSpec->Typeface(0)->ElementName() == KElement1Name);
464 if (addSpec->Typeface(1))
465 TEST(addSpec->Typeface(1)->ElementName() == KElement2Name);
469 if (addSpec->Typeface(2))
470 TEST(addSpec->Typeface(2)->ElementName() == KElement3Name);
474 TEST(removeSpec->TypefaceCount() == 2);
475 if (addSpec->Typeface(0))
476 TEST(removeSpec->Typeface(0)->ElementName() == KElement1Name);
480 if (addSpec->Typeface(1))
481 TEST(removeSpec->Typeface(1)->ElementName() == KElement2Name);
485 TEST(updateSpec->TypefaceCount() == 2);
486 if (addSpec->Typeface(1))
487 TEST(updateSpec->Typeface(0)->ElementName() == KElement2Name);
491 if (addSpec->Typeface(1))
492 TEST(updateSpec->Typeface(1)->ElementName() == KElement3Name);
496 CleanupStack::PopAndDestroy(3, addSpec);
499 __CONSTRUCT_STEP__(LinkedFontsUpdateStage2)