Update contrib.
2 * Copyright (c) 2006-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.
20 #include "t_linkedfontsmemory.h"
21 #include "T_LinkedFonts2.h"
22 #include "fbsmessage.h"
24 #include <linkedfonts.h>
26 class CTLinkedFontsMemory : public CTLinkedFonts2
29 CTLinkedFontsMemory(CTestStep* aStep);
30 ~CTLinkedFontsMemory();
31 //base class static void TestPanic(TInt aPanic);
33 // From CTGraphicsStep
34 virtual void RunTestCaseL(TInt aCurTestCase);
37 TInt TestLinkedFontsMemory1L(TInt aTypefaces);
38 void TestLinkedFontsMemory1L();
39 TInt TestLinkedFontsCreateLinkedTypefacesL(const TDesC& aName,TInt aTypefaces);
40 TInt TestLinkedFontsMemory_Part2(const TDesC& aName);
41 void TestLinkedFontsMemory2();
42 void TestLinkedFontsMemory3();
43 void TestLinkedFontsMemory4();
44 void TestMemoryUsage();
46 void SetHeapFail(RFbsSession::THeapFailType aType, TInt aFailures);
47 TInt HeapCount(RFbsSession::THeapFailType aType);
48 void SetHeapReset(RFbsSession::THeapFailType aType);
49 void SetHeapCheck(RFbsSession::THeapFailType aType);
50 void TestCompareText();
51 TInt FontAndBitmapServerSharedHeap();
52 void DisplayRamInfo(const TDesC &aTextInfo) const;
53 TBool CheckRasterizerInstalledL();
56 CTLinkedFontsMemory::CTLinkedFontsMemory(CTestStep* aStep)
57 : CTLinkedFonts2(aStep)
61 CTLinkedFontsMemory::~CTLinkedFontsMemory()
65 void CTLinkedFontsMemory::SetHeapFail(RFbsSession::THeapFailType aType, TInt aFailures)
67 __ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
68 iFbs->SendCommand(EFbsMessSetHeapFail, aType, aFailures);
71 TInt CTLinkedFontsMemory::HeapCount(RFbsSession::THeapFailType aType)
73 __ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
74 return iFbs->SendCommand(EFbsMessHeapCount, aType);
77 void CTLinkedFontsMemory::SetHeapReset(RFbsSession::THeapFailType aType)
79 __ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
80 iFbs->SendCommand(EFbsMessSetHeapReset, aType);
83 void CTLinkedFontsMemory::SetHeapCheck(RFbsSession::THeapFailType aType)
85 __ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
86 iFbs->SendCommand(EFbsMessSetHeapCheck, aType);
89 TInt CTLinkedFontsMemory::FontAndBitmapServerSharedHeap()
91 __ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
92 return iFbs->SendCommand(EFbsMessHeap);
95 _LIT(KLinkedFontsMemoryTestFont,"MemTestLinkedFnt");
96 TBool CTLinkedFontsMemory::CheckRasterizerInstalledL()
98 CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
99 CleanupStack::PushL(store);
101 // Create typeface to be linked
102 CLinkedTypefaceSpecification *typefaceSpec;
103 typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFontsMemoryTestFont);
105 CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
106 typefaceSpec->AddLinkedTypefaceGroupL(*group1);
109 // Add first typeface
110 CLinkedTypefaceElementSpec *elementSpec1;
111 _LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
112 elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
113 elementSpec1->SetCanonical(ETrue);
115 typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
116 CleanupStack::Pop(1, elementSpec1);
118 // Now try regstering the linked typeface
119 TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
120 CleanupStack::PopAndDestroy(2, store);
124 case KErrAlreadyExists:
128 INFO_PRINTF1(_L("Linked fonts memory: no linked fonts rasterizer found"));
133 _LIT(KDrawMe, "lInKED FOnTS");
135 void CTLinkedFontsMemory::TestCompareText()
137 _LIT(KWithout, "WithoutLinkedFontTT");
139 typeface.iName = KWithout;
141 fs.iTypeface = typeface;
143 CFbsFont* font = NULL;
144 TInt err1 = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
146 if (font && err1 == KErrNone)
149 TSize scrSize = iDev->SizeInPixels();
151 iGc->DrawText(KDrawMe, TPoint((scrSize.iWidth / 2) + 50, 50));
153 iDev->ReleaseFont(font);
155 TPoint right(scrSize.iWidth / 2, 0);
156 TBool val = iDev->RectCompare(TRect(left, TPoint(scrSize.iWidth / 2, scrSize.iHeight)), *iDev,TRect(right, TPoint(scrSize.iWidth, scrSize.iHeight)));
159 iGc->DrawRect(TRect(left, TPoint(scrSize.iWidth / 2, scrSize.iHeight)));
160 iGc->DrawRect(TRect(right, TPoint(scrSize.iWidth, scrSize.iHeight)));
167 TEST(0); //there is a failure
171 /** these fonts need to be provided, and are used for creating linked typefaces
173 Typeface name: LinkedFont1
174 This will be the dominant font. It contains 178 characters.
175 Some of the characters (13) are deleted from this file and separated in to other three files.
176 Characters missing are F, D, J, M, P, S, V, X, Z, a, n, l, y.
179 Typeface name: LinkedFont2
180 Characters available (7): F, J, M, S, Z, a, y.
183 Typeface name: LinkedFont3
184 Characters available (4): D, P, x, l
187 Typeface name: LinkedFont4
188 Characters available (2): V, n
190 TWithoutLinkedFont.ttf
191 Typeface name: WithoutLinkedFont
192 Characters available: It contains 191 characters U+0020-U+007E and U+00A0-U+00FF
195 _LIT(KLinkedFont1, "LinkedFont1TT");
196 _LIT(KLinkedFont2, "LinkedFont2TT");
197 _LIT(KLinkedFont3, "LinkedFont3TT");
198 _LIT(KLinkedFont4, "LinkedFont4TT");
200 /** Memory test helper function to create different typefaces. Function adds from 1 to four
203 TInt CTLinkedFontsMemory::TestLinkedFontsCreateLinkedTypefacesL(const TDesC &aName,TInt aTypefaces)
207 CLinkedTypefaceSpecification *typefaceSpec;
209 typefaceSpec = CLinkedTypefaceSpecification::NewLC(aName);
211 CLinkedTypefaceGroup* group1;
213 group1 = CLinkedTypefaceGroup::NewLC(1); //may well leave, function trapped, groupID = 1
214 typefaceSpec->AddLinkedTypefaceGroupL(*group1);
215 CleanupStack::Pop(); //pop the group, now referenced via typeface
217 CLinkedTypefaceElementSpec *elementSpec1;
218 elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont1, 1);
219 elementSpec1->SetCanonical(ETrue);
220 typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
221 CleanupStack::Pop(); //pop the element, now referenced via typeface
223 // Create and add second linked typeface
226 CLinkedTypefaceElementSpec *elementSpec2;
227 elementSpec2 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont2, 1);
228 typefaceSpec->AddTypefaceAtBackL(*elementSpec2);
229 CleanupStack::Pop(); //pop the element, now referenced via typeface
232 // Create and add third typeface to be linked
235 CLinkedTypefaceElementSpec *elementSpec3;
236 elementSpec3 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont3, 1);
237 typefaceSpec->AddTypefaceAtBackL(*elementSpec3);
238 CleanupStack::Pop(); //pop the element, now referenced via typeface
241 // Create and add fourth typeface to be linked
244 CLinkedTypefaceElementSpec *elementSpec4;
245 elementSpec4 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont4, 1);
246 TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*elementSpec4));
247 CleanupStack::Pop(); //pop the element, now referenced via typeface
250 // Try registering the typeface
251 CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
252 CleanupStack::PushL(store);
253 typefaceSpec->RegisterLinkedTypefaceL(*store);
254 CleanupStack::PopAndDestroy(2, typefaceSpec); //store and typefaceSpec
258 /** This is the function which does the operations which are tested, called from OOM loop
259 * in general the function does not return a low memory error; the function just leaves.
260 * An exception may be for registration.
262 TInt CTLinkedFontsMemory::TestLinkedFontsMemory1L(TInt aTypefaces)
266 //these are for the linked typefaces
267 _LIT(KLinkedTypeface1, "LinkedMem1-1"); //has LinkedFont1
268 _LIT(KLinkedTypeface2, "LinkedMem1-2"); //has LinkedFont1, LinkedFont2
269 _LIT(KLinkedTypeface3, "LinkedMem1-3"); //has LinkedFont1, LinkedFont2, LinkedFont3
270 _LIT(KLinkedTypeface4, "LinkedMem1-4"); //has LinkedFont1, LinkedFont2, LinkedFont3, LinkedFont4
272 // Create canonical typeface to be linked
277 ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface1,1);
280 ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface2,2);
283 ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface3,3);
286 ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface4,4);
289 __ASSERT_ALWAYS(ETrue,Panic(EFntTypefaceIndexOutOfRange));
293 RDebug::Printf("%d TestLinkedFontsMemory1L(%d)", ret, aTypefaces);
298 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0102
302 @SYMREQ REQ10924, REQ10925, REQ10926
304 @SYMTestCaseDesc To ensure that a linked typeface can be created and registered
305 without memory leaks, under low memory conditions.
307 @SYMTestPriority Critical
309 @SYMTestStatus Implemented
311 @SYMTestActions (1) Create an OOM loop, setting this process's heap memory to fail.
312 testing the client side heap memory allocation.
313 In the loop create and register a linked typeface with 1-4
316 @SYMTestExpectedResults (1) - There are no memory leaks, and the test exits the OOM loop.
318 void CTLinkedFontsMemory::TestLinkedFontsMemory1L()
322 INFO_PRINTF1(_L("TestLinkedFontsMemory"));
324 for (steps=1;steps<=4;steps++)
327 for (failures = 1; ; failures++)
329 __UHEAP_SETFAIL(RHeap::EDeterministic,failures);
335 TRAP(err, val= TestLinkedFontsMemory1L(steps));
340 if (err == KErrNotFound)
342 INFO_PRINTF3(_L("Failure below occurred on Step %i; failure=%i"), steps, failures);
347 if ((err == KErrNone) && (val == KErrNone))
356 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0103
360 @SYMREQ REQ10924, REQ10925, REQ10926
362 @SYMTestCaseDesc To ensure that a linked typeface can be created and fonts created
363 and used without memory leaks, under low memory conditions
365 @SYMTestPriority Critical
367 @SYMTestStatus Implemented
369 @SYMTestActions (1) Create an OOM loop, setting the server's heap memory to fail.
370 In the loop create and register a linked typeface with 1-4
372 (2) Draw text with the four linked fonts from the four
374 (3) Compare the text output against an unlinked font with the same
377 @SYMTestExpectedResults (1) - There are no memory leaks, and the test exits the OOM loop.
378 (2) - The text is draw successfully
379 (3) - The text compares identically.
381 void CTLinkedFontsMemory::TestLinkedFontsMemory2()
385 INFO_PRINTF1(_L("TestLinkedFontsMemory Server Heap"));
387 // Initially test for linked typeface creation
388 _LIT(name1, "typefaceNameMem2-1");
389 _LIT(name2, "typefaceNameMem2-2");
390 _LIT(name3, "typefaceNameMem2-3");
391 _LIT(name4, "typefaceNameMem2-4");
394 for (steps=1;steps<=4;steps++)
396 INFO_PRINTF2(_L("Testing creating linked typeface %d typefaces"),steps);
397 for (failures = 1;;failures++)
399 // Try creating the typeface
404 SetHeapFail(RFbsSession::EHeapFailTypeServerMemory, failures);
405 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
406 SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //on
411 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, steps));
414 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, steps));
417 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, steps));
420 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name4, steps));
424 SetHeapReset(RFbsSession::EHeapFailTypeServerMemory);
425 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
426 SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //off
428 //If the linked font cannot be created because the typefaces are not present or
429 //it has already been created then fail the test.
430 if (err == KErrNotFound || err == KErrAlreadyExists)
432 INFO_PRINTF1(_L("Failure below caused by missing linked font element file or linked font file already being generated."));
437 if ((val >= 0) && (err == KErrNone))
442 INFO_PRINTF1(_L("Testing linked typeface font creation and usage"));
443 for(steps=1;steps<=4;steps++)
445 INFO_PRINTF2(_L("Testing font usage: linked font with %d fonts"),steps);
446 for (failures = 1; ; failures++)
450 TInt serverBefore=HeapCount(RFbsSession::EHeapFailTypeServerMemory);
453 RHeap *heap = (RHeap*)FontAndBitmapServerSharedHeap();
458 countBefore = heap->Count();
460 SetHeapFail(RFbsSession::EHeapFailTypeServerMemory, failures);
461 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
467 val=TestLinkedFontsMemory_Part2(name1);
470 val=TestLinkedFontsMemory_Part2(name2);
473 val=TestLinkedFontsMemory_Part2(name3);
476 val=TestLinkedFontsMemory_Part2(name4);
480 TInt serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
485 countAfter = heap->Count();
486 badCell = __RHEAP_MARKEND(heap);
489 SetHeapReset(RFbsSession::EHeapFailTypeServerMemory);
490 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
496 //do a comparison of the text
503 TEST(countBefore == countAfter);
504 TEST(serverBefore == serverAfter);
510 TInt CTLinkedFontsMemory::TestLinkedFontsMemory_Part2(const TDesC &aName)
514 Typeface.iName = aName;
516 fs.iTypeface = Typeface;
518 CFbsFont* font = NULL;
519 TInt err1 = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
521 if (font && err1 == KErrNone)
526 iGc->DrawText(KDrawMe, TPoint(50, 50));
528 iDev->ReleaseFont(font);
530 else if (font == NULL)
532 TEST(err1==KErrNoMemory);
543 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0104
547 @SYMREQ REQ10924, REQ10925, REQ10926
549 @SYMTestCaseDesc To ensure that a linked typeface can be created and fonts created
550 and used under low memory conditions
552 @SYMTestPriority Critical
554 @SYMTestStatus Implemented
556 @SYMTestActions (1) This function checks that no memory has been retained from the
557 usage of a linked font. This tests server heap and shared heap
560 @SYMTestExpectedResults (1) - There are no memory leaks.
562 void CTLinkedFontsMemory::TestLinkedFontsMemory3()
564 _LIT( KTest1, "typefaceNameMem2-1");
565 _LIT( KTest2, "typefaceNameMem2-2");
566 _LIT( KTest3, "typefaceNameMem2-3");
567 _LIT( KTest4, "typefaceNameMem2-4");
570 TInt serverBefore = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
571 // need to get heap from client side.
572 RHeap *heap = (RHeap*)FontAndBitmapServerSharedHeap();
577 countBefore = heap->Count();
581 for (TInt numRuns = 0 ; numRuns <= 50 ; numRuns++)
583 for (TInt steps=1;steps<=4;steps++)
589 Typeface.iName = KTest1;
592 Typeface.iName = KTest2;
595 Typeface.iName = KTest3;
598 Typeface.iName = KTest4;
602 fs.iTypeface = Typeface;
608 for (count = 0; count < 10; count++)
610 err = iDev->GetNearestFontToDesignHeightInPixels(fnt[count], fs);
611 //now try getting the same font twice, if count is 5
614 TEST(err == KErrNone);
616 for (count = 0; count < 10; count++)
618 iDev->ReleaseFont(fnt[count]);
623 serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
628 countAfter = heap->Count();
629 badCell = __RHEAP_MARKEND(heap);
632 TEST (countAfter <= countBefore);
634 RDebug::Printf("serverAfter(%i) <= serverBefore(%i)", serverAfter, serverBefore);
635 INFO_PRINTF3(_L("serverAfter(%i) <= serverBefore(%i)"), serverAfter, serverBefore);
637 TEST(serverAfter <= serverBefore); // Note some true type tables are freed.
642 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0105
646 @SYMREQ REQ10924, REQ10925, REQ10926
648 @SYMTestCaseDesc To ensure that a linked typeface can be created and fonts created
649 and used under low memory conditions of the font and bitmap
652 @SYMTestPriority Critical
654 @SYMTestStatus Implemented
656 @SYMTestActions (1) Create an OOM loop, setting the shared heap memory to fail.
657 In the loop create and register a linked typeface with 1-4
658 typefaces. Draw text with the four linked fonts from the four
661 @SYMTestExpectedResults (1) - There are no memory leaks, and the test exits the OOM loop.
663 void CTLinkedFontsMemory::TestLinkedFontsMemory4()
668 INFO_PRINTF1(_L("TestLinkedFontsMemory Shared Heap"));
670 // Initially test for linked typeface creation
671 // Initially test for linked typeface creation
672 _LIT(name1, "typefaceNameMem4-1");
673 _LIT(name2, "typefaceNameMem4-2");
674 _LIT(name3, "typefaceNameMem4-3");
675 _LIT(name4, "typefaceNameMem4-4");
678 for(steps=1;steps<=4;steps++)
680 INFO_PRINTF2(_L("Testing creating linked typeface %d typefaces"),steps);
681 for (failures = 1; ; failures++)
683 // Try creating the typeface
688 SetHeapFail(RFbsSession::EHeapFailTypeHeapMemory, failures);
689 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
690 SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //on
695 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, 1));
698 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, 2));
701 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, 3));
704 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name4, 4));
708 SetHeapReset(RFbsSession::EHeapFailTypeHeapMemory);
709 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
710 SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //off
712 //If the linked font cannot be created because the typefaces are not present or
713 //it has already been created then fail the test.
714 if (err == KErrNotFound || err == KErrAlreadyExists)
716 INFO_PRINTF1(_L("Failure below caused by missing linked font element file or linked font file already being generated."));
721 if ((val >= 0) && (err == KErrNone))
726 INFO_PRINTF1(_L("Testing linked typeface font creation and usage"));
727 for (steps=1;steps<=4;steps++)
729 INFO_PRINTF2(_L("Testing font usage: linked font with %d fonts"), steps);
730 for (failures = 1; ; failures++)
734 TInt serverBefore=HeapCount(RFbsSession::EHeapFailTypeServerMemory);
735 RHeap *heap=(RHeap*)FontAndBitmapServerSharedHeap();
736 TInt countBefore = 0;
740 countBefore = heap->Count();
742 SetHeapFail(RFbsSession::EHeapFailTypeHeapMemory, failures);
743 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
748 val = TestLinkedFontsMemory_Part2(name1);
751 val = TestLinkedFontsMemory_Part2(name2);
754 val = TestLinkedFontsMemory_Part2(name3);
757 val = TestLinkedFontsMemory_Part2(name4);
761 TInt serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
766 countAfter = heap->Count();
767 badCell = __RHEAP_MARKEND(heap);
769 SetHeapReset(RFbsSession::EHeapFailTypeHeapMemory);
770 SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
782 TEST (countBefore == countAfter);
783 TEST(serverBefore == serverAfter);
789 void CTLinkedFontsMemory::DisplayRamInfo(const TDesC& aTextInfo) const
792 HAL::Get(HALData::EMemoryRAMFree, val);
794 _LIT(KTotalRamText, "RAM free: %d ");
795 buf.Format(KTotalRamText,val);
796 buf.Append(aTextInfo);
797 iStep->INFO_PRINTF1(buf);
801 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0106
805 @SYMREQ REQ10924, REQ10925, REQ10926
807 @SYMTestCaseDesc To test memory usage performance of linked font creation.
808 Test memory usage performance of linked font character access.
810 @SYMTestPriority High
812 @SYMTestStatus Implemented
814 @SYMTestActions (1) Display available ram. Create a linked typeface with 1-4 linked typeface
815 and display ram available.
816 (2) Create four linked fonts from the four linked typefaces. After each step
817 display the available RAM.
818 (3) Use each of the four linked fonts in turn for drawing text, and at each
819 step display the available RAM.
821 @SYMTestExpectedResults (1) (2) (3) RAM usage is displayed.
822 There are no memory leaks.
824 void CTLinkedFontsMemory::TestMemoryUsage()
827 INFO_PRINTF1(_L("Test Memory Usage 1"));
829 // Initially test for linked typeface creation
830 // Initially test for linked typeface creation
831 _LIT(name0, "WithoutLinkedFontTT");
832 _LIT(name1, "typefaceMemUse-1");
833 _LIT(name2, "typefaceMemUse-2");
834 _LIT(name3, "typefaceMemUse-3");
835 _LIT(name4, "typefaceMemUse-4");
838 _LIT(KPriorToTesting, "Prior to testing");
840 DisplayRamInfo(KPriorToTesting);
844 //get memory after registering a typeface
845 for(steps=1;steps<=4;steps++)
850 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, 1));
851 _LIT(KOneTypeface, "Typeface with one typeface created");
852 DisplayRamInfo(KOneTypeface);
855 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, 2));
856 _LIT(KTwoTypeface, "Typeface with two typefaces created");
857 DisplayRamInfo(KTwoTypeface);
860 TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, 3));
861 _LIT(KThreeTypeface, "Typeface with three typefaces created");
862 DisplayRamInfo(KThreeTypeface);
865 TRAP(err,val = TestLinkedFontsCreateLinkedTypefacesL(name4, 4));
866 _LIT(KFourTypeface, "Typeface with four typefaces created");
867 DisplayRamInfo(KFourTypeface);
870 TEST(err == KErrNone);
871 TEST(val == KErrNone);
875 memset (font,0, sizeof(CFont*)*5);
877 _LIT(KGettingFonts, "Now getting 5 fonts, the first one of which is not linked");
878 DisplayRamInfo(KGettingFonts);
879 //get memory after retrieving a font
880 for (steps=0;steps<5;steps++)
887 typeface.iName = name0;
889 fs.iTypeface = typeface;
891 err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
893 _LIT(KOneFont, "Non linked font typeface");
894 DisplayRamInfo(KOneFont);
901 typeface.iName = name1;
903 fs.iTypeface = typeface;
905 err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
907 _LIT(KOneFont, "LinkedFont one typeface");
908 DisplayRamInfo(KOneFont);
914 typeface.iName = name2;
916 fs.iTypeface = typeface;
918 err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
920 _LIT(KTwoFont, "LinkedFont two typefaces");
921 DisplayRamInfo(KTwoFont);
927 typeface.iName = name3;
929 fs.iTypeface = typeface;
931 err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
933 _LIT(KThreeFont, "LinkedFont three typefaces");
934 DisplayRamInfo(KThreeFont);
940 typeface.iName = name4;
942 fs.iTypeface = typeface;
944 err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
946 _LIT(KFourFont, "LinkedFont four typefaces");
947 DisplayRamInfo(KFourFont);
953 //get memory after font usage
954 const TDesC* string[5];
960 string[0]=&KString0();
961 string[1]=&KString1();
962 string[2]=&KString2();
963 string[3]=&KString3();
964 string[4]=&KString4();
966 _LIT(KWritingCharacter,"Now outputing a single character from each of the five fonts");
967 DisplayRamInfo(KWritingCharacter);
968 for (steps=0;steps<5;steps++)
971 iGc->UseFont(font[steps]);
973 _LIT(KNowUsingFont,"Now using font");
974 DisplayRamInfo(KNowUsingFont);
975 iGc->DrawText(*string[steps], TPoint(100, 100));
977 _LIT(KNumberOfSteps,"The font in use has %d linked fonts");
978 buf.Format(KNumberOfSteps, steps);
984 for (steps=0;steps<5;steps++)
986 iDev->ReleaseFont(font[steps]);
988 _LIT(KTestEnd,"At the end of the memory test");
989 DisplayRamInfo(KTestEnd);
992 void CTLinkedFontsMemory::RunTestCaseL( TInt aCurTestCase )
995 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
996 switch ( aCurTestCase )
999 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1001 if (!CheckRasterizerInstalledL())
1008 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0102"));
1010 //memory tests are not valid under DEBUG/ urel, and they will fail
1012 // This is for client side memory
1013 TestLinkedFontsMemory1L();
1019 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1022 //((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0103"));
1023 // This is for server side memory
1024 //TestLinkedFontsMemory2(); //- test crashes the server (from the rasterizer)
1031 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0104"));
1034 // This is to check that there are no leaks getting and releasing fonts
1035 //TestLinkedFontsMemory3();
1041 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0105"));
1044 // This is for heap memory
1045 //TestLinkedFontsMemory4();
1055 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0106"));
1063 ((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1064 ((CTLinkedFontsMemoryStep*)iStep)->CloseTMSGraphicsStep();
1068 ((CTLinkedFontsMemoryStep*)iStep)->RecordTestResultL();
1072 __CONSTRUCT_STEP__(LinkedFontsMemory)