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