|
1 // Copyright (c) 1995-2009 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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __TFBS_H__ |
|
17 #define __TFBS_H__ |
|
18 |
|
19 #include <fbs.h> |
|
20 #include <gdi.h> |
|
21 #include <test/fontinjector.h> |
|
22 #include <test/TGraphicsHarness.h> |
|
23 #include "tfbsmultithread.h" |
|
24 |
|
25 _LIT(KTempFilename,"c:\\temp.mbm"); |
|
26 _LIT(KTestBitmapOnZ,"z:\\system\\data\\tfbs.mbm"); |
|
27 _LIT(KTestBitmapOnC,"c:\\tfbs.mbm"); |
|
28 _LIT(KFail1Filename,"c:\\testfailed_bitmap1.mbm"); |
|
29 _LIT(KFail2Filename,"c:\\testfailed_bitmap2.mbm"); |
|
30 |
|
31 // Mostly to test bitmap compression |
|
32 _LIT(KRomNotCompressed,"z:\\system\\data\\rom.mbm"); |
|
33 _LIT(KRomCompressed,"z:\\system\\data\\romcomp.mbm"); |
|
34 _LIT(KFileNotCompressed,"z:\\system\\data\\file.mbm"); |
|
35 _LIT(KFileCompressed,"z:\\system\\data\\filecomp.mbm"); |
|
36 |
|
37 // Panic Category for FBServ panics |
|
38 _LIT(KFbsPanicCategory, "FBSERV"); |
|
39 |
|
40 enum TTfbs |
|
41 { |
|
42 ETfbs, |
|
43 ETblank |
|
44 }; |
|
45 |
|
46 class CFbsFontEx : public CFbsFont |
|
47 { |
|
48 public: |
|
49 CFbsFontEx(): CFbsFont() { iHandle=0; iAddressPointer=NULL; } |
|
50 void Reset() { CFbsFont::Reset(); } |
|
51 void SetHandle() { iHandle = 1; } |
|
52 TInt Duplicate(TInt aHandle) { return(CFbsFont::Duplicate(aHandle)); } |
|
53 CBitmapFont* Address() const { return CFbsFont::Address(); } |
|
54 TInt FontHandle() const {return iHandle;} |
|
55 }; |
|
56 |
|
57 /** |
|
58 Test utility class whose sole aim is to provide public access to CBitmapFont* from CFbsFont. |
|
59 */ |
|
60 class CTFbsFont : public CFbsFont |
|
61 { |
|
62 public: |
|
63 static CBitmapFont* FontAddress(CFbsFont* aFont) { return static_cast<CTFbsFont*>(aFont)->Address(); } |
|
64 }; |
|
65 |
|
66 class CFbsBitmapEx : public CFbsBitmap |
|
67 { |
|
68 public: |
|
69 CBitwiseBitmap* BitmapAddress() { if (!iHandle) return NULL; return iAddressPointer; } |
|
70 void LockHeap() const { CFbsBitmap::LockHeap(); } |
|
71 void UnlockHeap() const { CFbsBitmap::UnlockHeap(); } |
|
72 TInt BitmapHandle() const {return iHandle;} |
|
73 }; |
|
74 |
|
75 #ifdef __WINS__ |
|
76 template<class C> class XTCallCounter : public MShellcode |
|
77 { |
|
78 public: |
|
79 XTCallCounter(CTGraphicsBase& aTestBase); |
|
80 private: |
|
81 // From MShellcode |
|
82 void ExecuteShellcode(TInt aFromFunction); |
|
83 private: |
|
84 CTGraphicsBase& iTestBase; |
|
85 public: |
|
86 XVtableInjector<C> iInjector; |
|
87 TInt iVFCallsOutsideFBServ; |
|
88 }; |
|
89 #endif |
|
90 |
|
91 class CTFbs : public CTGraphicsBase |
|
92 { |
|
93 public: |
|
94 CTFbs(CTestStep* aStep); |
|
95 ~CTFbs(); |
|
96 protected: |
|
97 //from CTGraphicsStep |
|
98 virtual void RunTestCaseL(TInt aCurTestCase); |
|
99 void ConstructL(); |
|
100 |
|
101 void TestConstruction(); |
|
102 void TestConnection(); |
|
103 void TestFlushCallBack(); |
|
104 static TInt FlushCallBack(TAny* aPtr); |
|
105 void TestInvalidFiles(); |
|
106 void TestGetFont(); |
|
107 void TestFontStore(); |
|
108 void TestFontNameAlias(); |
|
109 void TestAddFontFile(); |
|
110 void TestBufferedFont(); |
|
111 void TestMultipleFont(); |
|
112 void TestCreateBitmap(); |
|
113 void TestLoadBitmap(); |
|
114 void TestQueryBitmap(); |
|
115 void TestRomBitmapL(); |
|
116 void TestMultiThread(); |
|
117 void TestHeapCompression(); |
|
118 void ExpandCleanupStackL(); |
|
119 void DeleteScanLineBuffer(); |
|
120 void AllocScanLineBuf(); |
|
121 void TestAllFontsLoaded(); |
|
122 void TestDefaultLanguageForMetrics(); |
|
123 void TestDuplicateFontFileEntries(); |
|
124 //COMMENTED OUT FOR NOW BECAUSE DEF084095 FIX MAKES THIS TEST REDUNDANT |
|
125 //void TestShapeHeaderMemoryLeakAtClientDeath(); |
|
126 void TestBitmapHandleImmutable(); |
|
127 void TestBitmapBeginEnd(); |
|
128 void TestSingletonServer(); |
|
129 void TestNoVFCallsToGlobalObjects(); |
|
130 void TestFontSessionCacheLookupL(); |
|
131 void TestInvalidHandlesInIpcCallsL(); |
|
132 private: |
|
133 CFbsFontEx* SelectFont(); |
|
134 CFbsFontEx* SelectOpenTypeFont(); |
|
135 void DoResizeBitmap(TDisplayMode aDispMode); |
|
136 void CheckResourceCount(); |
|
137 void CheckFontNameAlias(const TDesC& aFontAlias, const TDesC& aFontName, TInt& aSize); |
|
138 TInt LoadOpenFontLibraries(); |
|
139 TBool CheckTypefacesSupport(const TTypefaceSupport& aInfo1, const TTypefaceSupport& aInfo2); |
|
140 void LoadFontsL(const TDesC& aFontsDir); |
|
141 void CreateSecondThreadAndCheckPanicL(TFbsTestThreadInfo& aTestCase, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName); |
|
142 static TInt SecondThreadStart(TAny* aTestInfo); |
|
143 static TInt SecondThreadMainL(TFbsTestThreadInfo* aTestInfo); |
|
144 static TInt SecondThreadPanicInvalidHandleInIpcCall(); |
|
145 |
|
146 private: |
|
147 TInt iHandle; |
|
148 RFbsSession* iFbs; |
|
149 CFbsTypefaceStore* iTs; |
|
150 RHeap* iHeap; |
|
151 CFontStore *iFs; |
|
152 TInt iResourceCount; |
|
153 TInt iAllocs; |
|
154 TFileName iTestBitmapName; |
|
155 TBool iFlushCallbackReceived; |
|
156 #ifdef __WINS__ |
|
157 XTCallCounter<CFont> iFontCallCounter; |
|
158 XTCallCounter<COpenFont> iOpenFontCallCounter; |
|
159 #endif |
|
160 |
|
161 }; |
|
162 |
|
163 class CTFbsStep : public CTGraphicsStep |
|
164 { |
|
165 public: |
|
166 CTFbsStep(); |
|
167 protected: |
|
168 //from CTGraphicsStep |
|
169 virtual CTGraphicsBase* CreateTestL(); |
|
170 }; |
|
171 |
|
172 _LIT(KTFbsStep,"TFbs"); |
|
173 |
|
174 |
|
175 |
|
176 #endif |