First public contribution.
1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <test/fontinjector.h>
22 #include <test/TGraphicsHarness.h>
24 _LIT(KTempFilename,"c:\\temp.mbm");
25 _LIT(KTestBitmapOnZ,"z:\\system\\data\\tfbs.mbm");
26 _LIT(KTestBitmapOnC,"c:\\tfbs.mbm");
27 _LIT(KFail1Filename,"c:\\testfailed_bitmap1.mbm");
28 _LIT(KFail2Filename,"c:\\testfailed_bitmap2.mbm");
30 // Mostly to test bitmap compression
31 _LIT(KRomNotCompressed,"z:\\system\\data\\rom.mbm");
32 _LIT(KRomCompressed,"z:\\system\\data\\romcomp.mbm");
33 _LIT(KFileNotCompressed,"z:\\system\\data\\file.mbm");
34 _LIT(KFileCompressed,"z:\\system\\data\\filecomp.mbm");
36 // Panic Category for FBServ panics
37 _LIT(KFbsPanicCategory, "FBSERV");
45 class CFbsFontEx : public CFbsFont
48 CFbsFontEx(): CFbsFont() { iHandle=0; iAddressPointer=NULL; }
49 void Reset() { CFbsFont::Reset(); }
50 void SetHandle() { iHandle = 1; }
51 TInt Duplicate(TInt aHandle) { return(CFbsFont::Duplicate(aHandle)); }
52 CBitmapFont* Address() const { return CFbsFont::Address(); }
53 TInt FontHandle() const {return iHandle;}
57 Test utility class whose sole aim is to provide public access to CBitmapFont* from CFbsFont.
59 class CTFbsFont : public CFbsFont
62 static CBitmapFont* FontAddress(CFbsFont* aFont) { return static_cast<CTFbsFont*>(aFont)->Address(); }
65 class CFbsBitmapEx : public CFbsBitmap
68 CBitwiseBitmap* BitmapAddress() { if (!iHandle) return NULL; return iAddressPointer; }
69 void LockHeap() const { CFbsBitmap::LockHeap(); }
70 void UnlockHeap() const { CFbsBitmap::UnlockHeap(); }
71 TInt BitmapHandle() const {return iHandle;}
75 template<class C> class XTCallCounter : public MShellcode
78 XTCallCounter(CTGraphicsBase& aTestBase);
81 void ExecuteShellcode(TInt aFromFunction);
83 CTGraphicsBase& iTestBase;
85 XVtableInjector<C> iInjector;
86 TInt iVFCallsOutsideFBServ;
90 class CTFbs : public CTGraphicsBase
93 CTFbs(CTestStep* aStep);
97 virtual void RunTestCaseL(TInt aCurTestCase);
100 void TestConstruction();
101 void TestConnection();
102 void TestFlushCallBack();
103 static TInt FlushCallBack(TAny* aPtr);
104 void TestInvalidFiles();
106 void TestFontStore();
107 void TestFontNameAlias();
108 void TestAddFontFile();
109 void TestBufferedFont();
110 void TestMultipleFont();
111 void TestCreateBitmap();
112 void TestLoadBitmap();
113 void TestQueryBitmap();
114 void TestRomBitmapL();
115 void TestMultiThread();
116 void TestHeapCompression();
117 void ExpandCleanupStackL();
118 void DeleteScanLineBuffer();
119 void AllocScanLineBuf();
120 void TestAllFontsLoaded();
121 void TestDefaultLanguageForMetrics();
122 void TestDuplicateFontFileEntries();
123 //COMMENTED OUT FOR NOW BECAUSE DEF084095 FIX MAKES THIS TEST REDUNDANT
124 //void TestShapeHeaderMemoryLeakAtClientDeath();
125 void TestBitmapHandleImmutable();
126 void TestBitmapBeginEnd();
127 void TestSingletonServer();
128 void TestNoVFCallsToGlobalObjects();
129 void TestFontSessionCacheLookupL();
130 void TestInvalidHandlesInIpcCallsL();
132 CFbsFontEx* SelectFont();
133 CFbsFontEx* SelectOpenTypeFont();
134 void DoResizeBitmap(TDisplayMode aDispMode);
135 void CheckResourceCount();
136 void CheckFontNameAlias(const TDesC& aFontAlias, const TDesC& aFontName, TInt& aSize);
137 TInt LoadOpenFontLibraries();
138 TBool CheckTypefacesSupport(const TTypefaceSupport& aInfo1, const TTypefaceSupport& aInfo2);
139 void LoadFontsL(const TDesC& aFontsDir);
140 void SecondThreadPanicInvalidHandleInIpcCallL();
141 void CreateSecondThreadAndCheckPanicL(void (CTFbs::*aMethodL)(), TInt aPanicCode, const TDesC& aPanicCategory, const TDesC &aThreadName);
142 static TInt MethodDelegatorThreadFunction(TAny* aDelegator);
147 CFbsTypefaceStore* iTs;
152 TFileName iTestBitmapName;
153 TBool iFlushCallbackReceived;
155 XTCallCounter<CFont> iFontCallCounter;
156 XTCallCounter<COpenFont> iOpenFontCallCounter;
161 class CTFbsStep : public CTGraphicsStep
166 //from CTGraphicsStep
167 virtual CTGraphicsBase* CreateTestL();
170 _LIT(KTFbsStep,"TFbs");