os/graphics/fbs/fontandbitmapserver/tfbs/TFBS.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     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 
    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");
    29 
    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");
    35 
    36 // Panic Category for FBServ panics
    37 _LIT(KFbsPanicCategory, "FBSERV");
    38 
    39 enum TTfbs
    40 	{
    41 	ETfbs,
    42 	ETblank
    43 	};
    44 
    45 class CFbsFontEx : public CFbsFont
    46 	{
    47 public:
    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;}
    54 	};
    55 
    56 /**
    57 Test utility class whose sole aim is to provide public access to CBitmapFont* from CFbsFont.
    58  */
    59 class CTFbsFont : public CFbsFont
    60     {
    61 public:
    62     static CBitmapFont* FontAddress(CFbsFont* aFont) { return static_cast<CTFbsFont*>(aFont)->Address(); }
    63     };
    64 
    65 class CFbsBitmapEx : public CFbsBitmap
    66 	{
    67 public:
    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;}
    72 	};
    73 
    74 #ifdef __WINS__
    75 template<class C> class XTCallCounter : public MShellcode
    76 	{
    77 public:
    78 	XTCallCounter(CTGraphicsBase& aTestBase);
    79 private:
    80 	// From MShellcode
    81 	void ExecuteShellcode(TInt aFromFunction);
    82 private:
    83 	CTGraphicsBase& iTestBase;
    84 public:
    85 	XVtableInjector<C> iInjector;
    86 	TInt iVFCallsOutsideFBServ;
    87 	};
    88 #endif
    89 
    90 class CTFbs : public CTGraphicsBase
    91 	{
    92 public:
    93 	CTFbs(CTestStep* aStep);
    94 	~CTFbs();
    95 protected:
    96 //from 	CTGraphicsStep
    97 	virtual void RunTestCaseL(TInt aCurTestCase);
    98 	void ConstructL();
    99 	
   100 	void TestConstruction();
   101 	void TestConnection();
   102 	void TestFlushCallBack();
   103 	static TInt FlushCallBack(TAny* aPtr);
   104 	void TestInvalidFiles();
   105 	void TestGetFont();
   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();
   131 private:
   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);
   143 
   144 private:
   145 	TInt iHandle;
   146 	RFbsSession* iFbs;
   147 	CFbsTypefaceStore* iTs;
   148 	RHeap* iHeap;
   149 	CFontStore *iFs;
   150 	TInt iResourceCount;
   151 	TInt iAllocs;
   152 	TFileName iTestBitmapName;
   153 	TBool iFlushCallbackReceived;
   154 #ifdef __WINS__
   155 	XTCallCounter<CFont> iFontCallCounter;
   156 	XTCallCounter<COpenFont> iOpenFontCallCounter;
   157 #endif
   158     
   159 	};
   160 
   161 class CTFbsStep : public CTGraphicsStep
   162 	{
   163 public:
   164 	CTFbsStep();
   165 protected:	
   166 	//from CTGraphicsStep
   167 	virtual CTGraphicsBase* CreateTestL();
   168 	};
   169 
   170 _LIT(KTFbsStep,"TFbs");
   171 
   172 
   173 
   174 #endif