sl@0: /* sl@0: * Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: #include "T_LinkedFontUpdateTests.h" sl@0: sl@0: CTLinkedFontsUpdateStage1::CTLinkedFontsUpdateStage1(CTestStep* aStep) sl@0: : CTGraphicsBase(aStep) sl@0: { sl@0: iFontLinkingSupported = EFalse; sl@0: } sl@0: sl@0: CTLinkedFontsUpdateStage1::~CTLinkedFontsUpdateStage1() sl@0: { sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage1::TestPanic(TInt aPanic) sl@0: { sl@0: _LIT(KFntTestStorePanicCategory,"TestFntStore"); sl@0: User::Panic(KFntTestStorePanicCategory,aPanic); sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage1::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch (aCurTestCase) sl@0: { sl@0: case 1: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: SetupTestsL(); sl@0: break; sl@0: case 2: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0200")); sl@0: RegisterThenUpdateTestL(); sl@0: break; sl@0: case 3: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0201")); sl@0: NegativeUpdateTestsL(); sl@0: break; sl@0: case 4: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: CloseTestsL(); sl@0: break; sl@0: default: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: /** sl@0: Connect to the Font Bitmap Server and construct a CFbsTypeface store to access the fontstore. sl@0: */ sl@0: void CTLinkedFontsUpdateStage1::SetupTestsL() sl@0: { sl@0: TInt ret = RFbsSession::Connect(); sl@0: TEST2(ret, KErrNone); sl@0: sl@0: iFbs = RFbsSession::GetSession(); sl@0: sl@0: iTfStore = CFbsTypefaceStore::NewL(NULL); sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage1::CloseTestsL() sl@0: { sl@0: delete iTfStore; sl@0: RFbsSession::Disconnect(); sl@0: } sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-LINKEDFONTS-0200 sl@0: sl@0: @SYMPREQ sl@0: PREQ2147 sl@0: sl@0: @SYMREQ sl@0: REQ11859 sl@0: sl@0: @SYMTestCaseDesc sl@0: Creates three brand new linked typefaces, then updates each. The first typeface has an sl@0: element added to it, the second has one removed and the third is replaced with a different sl@0: specification. sl@0: sl@0: The outcome of the update process is checked after a reboot by test case 202. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Checks the update process has completed succesfully. sl@0: sl@0: @SYMTestExpectedResults sl@0: Linked fonts are created and updated successfully. Validation of the new file is performed after a reboot. sl@0: */ sl@0: sl@0: void CTLinkedFontsUpdateStage1::RegisterThenUpdateTestL() sl@0: { sl@0: CLinkedTypefaceSpecification* addSpec = CreateAddTypefaceLC(EFalse); sl@0: CLinkedTypefaceSpecification* removeSpec = CreateRemoveTypefaceLC(EFalse); sl@0: CLinkedTypefaceSpecification* updateSpec = CreateUpdateTypefaceLC(EFalse); sl@0: sl@0: //Create three new linked fonts sl@0: TRAPD(ret, addSpec->RegisterLinkedTypefaceL(*iTfStore)); sl@0: sl@0: //Ensure that a supporting rasterizer is present. sl@0: if (ret == KErrNotSupported) sl@0: { sl@0: WARN_PRINTF1(_L("There is not a font rasterizer present supporting font linking installed, skipping test.")); sl@0: CleanupStack::PopAndDestroy(3, addSpec); sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: iFontLinkingSupported = ETrue; sl@0: } sl@0: sl@0: TEST(ret == KErrNone); sl@0: TRAP(ret, removeSpec->RegisterLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: TRAP(ret, updateSpec->RegisterLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(3); sl@0: sl@0: //Update the three linked fonts with their new specifications sl@0: addSpec = CreateAddTypefaceLC(ETrue); sl@0: TRAP(ret, addSpec->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: removeSpec = CreateRemoveTypefaceLC(ETrue); sl@0: TRAP(ret, removeSpec->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: updateSpec = CreateUpdateTypefaceLC(ETrue); sl@0: TRAP(ret, updateSpec->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(3, addSpec); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-LINKEDFONTS-0201 sl@0: sl@0: @SYMPREQ sl@0: PREQ2147 sl@0: sl@0: @SYMREQ sl@0: REQ11859 sl@0: sl@0: @SYMTestCaseDesc sl@0: Attempt to update a linked font with Invalid or Non-Existent Elements. sl@0: Attempt to update a non-linked font. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Ensures the correct error codes are returned showing that no updates were made to the relevant typefaces. sl@0: sl@0: @SYMTestExpectedResults sl@0: All invalid updates will return KErrNotFound or KErrAccessDenied sl@0: */ sl@0: void CTLinkedFontsUpdateStage1::NegativeUpdateTestsL() sl@0: { sl@0: if (!iFontLinkingSupported) sl@0: { sl@0: WARN_PRINTF1(_L("There is not a font rasterizer present supporting font linking installed, skipping test.")); sl@0: return; sl@0: } sl@0: //Update with invalid element sl@0: CLinkedTypefaceSpecification* invalidSpec = CreateUpdateTypefaceLC(EFalse); sl@0: sl@0: CLinkedTypefaceElementSpec* invalidElement = CLinkedTypefaceElementSpec::NewLC(_L("SomeThingInValid"), 1); sl@0: invalidSpec->AddTypefaceAtBackL(*invalidElement); sl@0: CleanupStack::Pop(invalidElement); sl@0: sl@0: TRAPD(ret, invalidSpec->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(invalidSpec); sl@0: sl@0: //Update a typeface that doesn't exist. sl@0: _LIT(KNonExistantTypeface, "DoesNotExist"); sl@0: CLinkedTypefaceSpecification* nonExistentTypeface = CreateNegativeTestTypefaceLC(KNonExistantTypeface); sl@0: TRAP(ret, nonExistentTypeface->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(nonExistentTypeface); sl@0: sl@0: //Update the default techview font (that is not a linked font). sl@0: _LIT(KNonLinkedFontName, "DejaVu Sans Condensed"); sl@0: CLinkedTypefaceSpecification* nonLinkedTypeface = CreateNegativeTestTypefaceLC(KNonLinkedFontName); sl@0: TRAP(ret, nonLinkedTypeface->UpdateLinkedTypefaceL(*iTfStore)); sl@0: TEST(ret == KErrAccessDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(nonLinkedTypeface); sl@0: sl@0: } sl@0: sl@0: /** sl@0: Create a typeface to test adding a new element to a linked font. sl@0: @param TBool EFalse for Original, ETrue for Update version sl@0: */ sl@0: CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateAddTypefaceLC(TBool aUpdate) sl@0: { sl@0: CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KAddElementFontName); sl@0: sl@0: AddGroups(spec); sl@0: sl@0: CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1); sl@0: element->SetCanonical(ETrue); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: if (aUpdate) sl@0: { sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 2); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: } sl@0: sl@0: return spec; sl@0: } sl@0: sl@0: /** sl@0: Create a typeface to test removing an element from a linked font. sl@0: @param TBool EFalse for Original, ETrue for Update version sl@0: */ sl@0: CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateRemoveTypefaceLC(TBool aUpdate) sl@0: { sl@0: CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KRemoveElementFontName); sl@0: AddGroups(spec); sl@0: sl@0: CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1); sl@0: element->SetCanonical(ETrue); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: if (!aUpdate) sl@0: { sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 2); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: } sl@0: sl@0: return spec; sl@0: } sl@0: sl@0: /** sl@0: Create a typeface to test completely changing a linked font. sl@0: @param TBool EFalse for Original, ETrue for Update version sl@0: */ sl@0: CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateUpdateTypefaceLC(TBool aUpdate) sl@0: { sl@0: CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KUpdateFontName); sl@0: AddGroups(spec); sl@0: sl@0: CLinkedTypefaceElementSpec* element; sl@0: sl@0: if (!aUpdate) sl@0: { sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement1Name, 1); sl@0: element->SetCanonical(ETrue); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: } sl@0: sl@0: element = CLinkedTypefaceElementSpec::NewLC(KElement2Name, 2); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: if (aUpdate) sl@0: { sl@0: CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(KElement3Name, 1); sl@0: element->SetCanonical(ETrue); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: } sl@0: sl@0: return spec; sl@0: } sl@0: sl@0: /** sl@0: Create a typeface for use in the negative test cases. sl@0: sl@0: This has a number of typeface groups already added to it. sl@0: sl@0: @see CTLinkedFontsUpdate1::AddGroups() sl@0: @param aName The name of the typeface. sl@0: */ sl@0: CLinkedTypefaceSpecification* CTLinkedFontsUpdateStage1::CreateNegativeTestTypefaceLC(const TDesC& aName) sl@0: { sl@0: CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(aName); sl@0: sl@0: AddGroups(spec); sl@0: sl@0: CLinkedTypefaceElementSpec* element = CLinkedTypefaceElementSpec::NewLC(_L("DejaVu Sans Condensed"), 1); sl@0: element->SetCanonical(ETrue); sl@0: spec->AddTypefaceAtBackL(*element); sl@0: CleanupStack::Pop(element); sl@0: sl@0: return spec; sl@0: } sl@0: sl@0: /** sl@0: Adds two simple linked typeface groups to the linked typeface group. sl@0: sl@0: @param aSpec The specification to have groups added to sl@0: */ sl@0: void CTLinkedFontsUpdateStage1::AddGroups(CLinkedTypefaceSpecification* aSpec) sl@0: { sl@0: CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(1); sl@0: grp->SetBaselineShift(CLinkedTypefaceGroup::EBaselineShift); sl@0: aSpec->AddLinkedTypefaceGroupL(*grp); sl@0: CleanupStack::Pop(grp); sl@0: sl@0: grp = CLinkedTypefaceGroup::NewLC(2); sl@0: grp->SetBaselineShift(CLinkedTypefaceGroup::ENoBaselineShift); sl@0: aSpec->AddLinkedTypefaceGroupL(*grp); sl@0: CleanupStack::Pop(grp); sl@0: } sl@0: sl@0: __CONSTRUCT_STEP__(LinkedFontsUpdateStage1) sl@0: sl@0: sl@0: //CTLinkedFontsUpdate2 sl@0: CTLinkedFontsUpdateStage2::CTLinkedFontsUpdateStage2(CTestStep* aStep) sl@0: : CTGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTLinkedFontsUpdateStage2::~CTLinkedFontsUpdateStage2() sl@0: { sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage2::TestPanic(TInt aPanic) sl@0: { sl@0: _LIT(KFntTestStorePanicCategory,"TestFntStore"); sl@0: User::Panic(KFntTestStorePanicCategory,aPanic); sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage2::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch (aCurTestCase) sl@0: { sl@0: case 1: sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: SetupTestsL(); sl@0: break; sl@0: case 2: sl@0: ((CTLinkedFontsUpdateStage1Step*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0202")); sl@0: ValidateLinkedFontsL(); sl@0: break; sl@0: case 3: sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: CloseTestsL(); sl@0: default: sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTLinkedFontsUpdateStage2Step*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: /** sl@0: Connect to the Font Bitmap Server and construct a CFbsTypeface store to access the fontstore. sl@0: */ sl@0: void CTLinkedFontsUpdateStage2::SetupTestsL() sl@0: { sl@0: TInt ret = RFbsSession::Connect(); sl@0: TEST2(ret, KErrNone); sl@0: sl@0: iFbs = RFbsSession::GetSession(); sl@0: sl@0: iTfStore = CFbsTypefaceStore::NewL(NULL); sl@0: } sl@0: sl@0: void CTLinkedFontsUpdateStage2::CloseTestsL() sl@0: { sl@0: delete iTfStore; sl@0: RFbsSession::Disconnect(); sl@0: } sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-LINKEDFONTS-0202 sl@0: sl@0: @SYMPREQ sl@0: PREQ2147 sl@0: sl@0: @SYMREQ sl@0: REQ11859 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests the updates made to three linked typefaces created by test case 200; this checks the linked fonts sl@0: have been correctly updated to the latest specification. sl@0: sl@0: @SYMTestPriority sl@0: Critical sl@0: sl@0: @SYMTestStatus sl@0: Implemented sl@0: sl@0: @SYMTestActions sl@0: Checks the update process has completed succesfully. sl@0: sl@0: @SYMTestExpectedResults sl@0: The linked fonts match the specification they were updated to. sl@0: Failures may be due to other failures in test case xxx as this is the second stage of these tests. sl@0: */ sl@0: void CTLinkedFontsUpdateStage2::ValidateLinkedFontsL() sl@0: { sl@0: CLinkedTypefaceSpecification* addSpec = CLinkedTypefaceSpecification::NewLC(KAddElementFontName); sl@0: TRAPD(ret, addSpec->FetchLinkedTypefaceSpecificationL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: CLinkedTypefaceSpecification* removeSpec = CLinkedTypefaceSpecification::NewLC(KRemoveElementFontName); sl@0: TRAP(ret, removeSpec->FetchLinkedTypefaceSpecificationL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: CLinkedTypefaceSpecification* updateSpec = CLinkedTypefaceSpecification::NewLC(KUpdateFontName); sl@0: TRAP(ret, updateSpec->FetchLinkedTypefaceSpecificationL(*iTfStore)); sl@0: TEST(ret == KErrNone); sl@0: sl@0: //Test Elements are in correct order sl@0: TEST(addSpec->TypefaceCount() == 3); sl@0: sl@0: if (addSpec->Typeface(0)) sl@0: TEST(addSpec->Typeface(0)->ElementName() == KElement1Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: if (addSpec->Typeface(1)) sl@0: TEST(addSpec->Typeface(1)->ElementName() == KElement2Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: if (addSpec->Typeface(2)) sl@0: TEST(addSpec->Typeface(2)->ElementName() == KElement3Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: TEST(removeSpec->TypefaceCount() == 2); sl@0: if (addSpec->Typeface(0)) sl@0: TEST(removeSpec->Typeface(0)->ElementName() == KElement1Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: if (addSpec->Typeface(1)) sl@0: TEST(removeSpec->Typeface(1)->ElementName() == KElement2Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: TEST(updateSpec->TypefaceCount() == 2); sl@0: if (addSpec->Typeface(1)) sl@0: TEST(updateSpec->Typeface(0)->ElementName() == KElement2Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: if (addSpec->Typeface(1)) sl@0: TEST(updateSpec->Typeface(1)->ElementName() == KElement3Name); sl@0: else sl@0: TEST(EFalse); sl@0: sl@0: CleanupStack::PopAndDestroy(3, addSpec); sl@0: } sl@0: sl@0: __CONSTRUCT_STEP__(LinkedFontsUpdateStage2)