summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/engine-2.3.1/test/RegressionTest/TestCase.h
blob: 68258929a1f98fe84da8cd0bfb027b5a2d3ab4df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 2004 SIL International. All rights reserved.

Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.

File: TestCase.h
Responsibility: Sharon Correll
Last reviewed: Not yet.

Description:
    Definition of TestCase class for Graphite regression test program.
-------------------------------------------------------------------------------*//*:End Ignore*/

#ifdef _MSC_VER
#pragma once
#endif
#ifndef TESTCASE_H
#define TESTCASE_H 1

#define NO_EXCEPTIONS 1

class TestCase
{
public:
	//	Methods to set up test cases.
	void SetupSimpleTest();
	void SetupSimpleBacktrackTest();
	void SetupSurrogateTest();	// TODO: add a test for UTF-8
	void SetupBurmese1();
	void SetupBurmese2();
	void SetupBurmese3();
	void SetupBurmese4();
	void SetupRoman();
	void SetupRomanFeatures();
	void SetupStackingAndBridging();
	void SetupNoWhiteSpace();
	void SetupNoWhiteSpaceNoSeg();
	void SetupOnlyWhiteSpace();
	void SetupCrossLine1();
	void SetupCrossLine2();
	void SetupCrossLine3();
	void SetupCrossLine4();
	void SetupArabic1();
	void SetupArabic2();
	void SetupTaiViet1();
	void SetupTaiViet2();
	void SetupDumbFallback1();
	void SetupDumbFallback2();
	void SetupBadFont();
	void SetupBugTest();
	//	*** Add more methods here. ***

protected:
	//	Auxiliary functions to set up test cases.
	void SetupBurmeseAux(int charCount, int glyphCount, int clickTestCount);
	void SetupArabicAux(int charCount, int glyphCount);
	std::wstring BurmeseText();
	std::wstring RomanText();
	std::wstring CrossLineText();
	std::wstring ArabicText();
	std::wstring TaiVietText();

public:
	const static int kAbsent = -100;	// not present in data

public:
	//	constructor:
	TestCase();
	//	destructor:
	~TestCase();

	static int SetupTests(TestCase **);
	static void DeleteTests();

	//	Getters:
	std::string TestName()			{ return m_testName; }
	bool RunDebugger()				{ return m_debug; }
	bool TraceLog()					{ return m_traceLog; }
	bool Skip()						{ return m_skip; }

	std::wstring Text()				{ return m_text; }
	std::wstring FontName()			{ return m_fontName; }
	std::string FontFile()			{ return m_fontFile; }
	size_t FontSize()				{ return m_fontSize; }
	LineBrk PrefBreak()				{ return m_prefBreak; }
	LineBrk WorstBreak()			{ return m_worstBreak; }
	int FeatureID(int i)			{ return m_fset[i].id; }
	int FeatureValue(int i)			{ return m_fset[i].value; }
	FeatureSetting * Features()		{ return m_fset; }
	int AvailWidth()				{ return m_availWidth; }
	bool Backtrack()				{ return m_backtrack; }
	TrWsHandling Twsh()				{ return m_twsh; }
	bool Rtl()						{ return m_rtl; }
	bool ParaRtl()					{ return m_paraRtl; }
	size_t FirstChar()				{ return m_firstChar; }
	bool DumbFallback()				{ return m_dumbFallback; }
	size_t InputContextBlock(gr::byte ** ppContextBlock)
	{
		*ppContextBlock = m_contextBlockIn;
		return m_contextBlockInSize;
	}

	bool InitWithPrevSeg()			{ return m_initWithPrev; }
	bool BadFont()					{ return m_badFont; }
	bool NoSegment()				{ return m_noSegment; }
	int SegWidth()					{ return m_segWidth; }
	int CharCount()					{ return m_charCount; }
	int GlyphCount()				{ return m_glyphCount; }

	int GlyphID(int i)				{ return m_glyphArray[i]; }
	int XPos(int i)					{ return m_xPositions[i]; }
	int YPos(int i)					{ return m_yPositions[i]; }
	int AdvWidth(int i)				{ return m_advWidths[i]; }
	int BbLeft(int i)				{ return m_bbLefts[i]; }
	int BbRight(int i)				{ return m_bbRights[i]; }
	int BbTop(int i)				{ return m_bbTops[i]; }
	int BbBottom(int i)				{ return m_bbBottoms[i]; }
	bool BbTests()					{ return (m_bbLefts != NULL); }

	int InsPtFlag(int i)			{ return m_insPointFlags[i]; }

	int CharToGlyphCount()			{ return m_c2gCount; }
	int CharToGlyphItem(int i)		{ return m_charsToGlyphs[i]; }
	int AttachedGlyphCount()		{ return m_attGCount; }	// that is, the lenght of the data
	int AttachedGlyphItem(int i)	{ return m_attGlyphs[i]; }

	int NumberOfClickTests()		{ return m_clickTestCount; }
	int XClick(int i)				{ return m_clickTests[i].xClick; }
	int YClick(int i)				{ return m_clickTests[i].yClick; }
	int ClickCharIndex(int i)		{ return m_clickTests[i].charIndex; }
	bool ClickAssocPrev(int i)		{ return (bool)m_clickTests[i].assocPrev; }
	int Sel1Top(int i)				{ return m_clickTests[i].sel1Top; }
	int Sel1Bottom(int i)			{ return m_clickTests[i].sel1Bottom; }
	int Sel1Left(int i)				{ return m_clickTests[i].sel1Left; }
	int Sel2Top(int i)				{ return m_clickTests[i].sel2Top; }
	int Sel2Bottom(int i)			{ return m_clickTests[i].sel2Bottom; }
	int Sel2Left(int i)				{ return m_clickTests[i].sel2Left; }
	size_t OutputContextBlockSize()	{ return m_contextBlockOutSize; }
	bool CompareContextBlock(gr::byte * pResult)
	{
		for (size_t i = 0; i < m_contextBlockOutSize; i++)
		{
			if (m_contextBlockOut[i] != pResult[i])
				return false;
		}
		return true;
	}

	struct ClickTest
	{
		int xClick;
		int yClick;
		int charIndex;
		int assocPrev;	// boolean: 0 or 1
		int sel1Top;
		int sel1Bottom;
		int sel1Left;	// we only need left or right, not both
		int sel2Top;
		int sel2Bottom;
		int sel2Left;

		const static int fieldCnt = 10;
	};

protected:
	std::string m_testName;
	bool m_debug;		// break into the debugger when running this test
	bool m_traceLog;	// generate a logging file (tracelog.txt) for this test; if this is turned on for
						// more than one test, the tests will be appended
	bool m_skip;

#define MAXFEAT 10

	//	Input parameters:
	std::wstring m_text;			// default: none
	std::wstring m_fontName;		// default: empty
	std::string m_fontFile;			// default: empty
	size_t m_fontSize;				// default: 12
	LineBrk m_prefBreak;			// default: word-break
	LineBrk m_worstBreak;			// default: clip-break
	FeatureSetting m_fset[MAXFEAT];	// default: none
	int m_availWidth;				// default: 100
	bool m_bold;					// default: false
	bool m_italic;					// default: false
	bool m_rtl;						// default: false
	bool m_backtrack;				// default: false
	TrWsHandling m_twsh;			// default: ktwshAll
	bool m_paraRtl;					// default: false
	size_t m_firstChar;				// default: 0
	size_t m_contextBlockInSize;	// default: 0
	gr::byte * m_contextBlockIn;	// default: NULL -- DELETE
	bool m_initWithPrev;			// default: false
	bool m_dumbFallback;			// default: true
	// start of line flag
	// resolution
	// justification

	//	Output:
	bool m_badFont;			// default: false
	bool m_noSegment;		// no segment should be generated
	int m_segWidth;
	int m_charCount;
	int m_glyphCount;
	gid16 * m_glyphArray;
	int * m_xPositions;
	int * m_yPositions;
	int * m_advWidths;
	int * m_bbLefts;
	int * m_bbRights;
	int * m_bbTops;
	int * m_bbBottoms;
	bool * m_insPointFlags;
	int * m_charsToGlyphs;	// char-to-glyph mappings
	int m_c2gCount;
	int * m_attGlyphs;		// attachment clusters
	int m_attGCount;
	int m_clickTestCount;
	ClickTest * m_clickTests;
	size_t m_contextBlockOutSize;
	gr::byte * m_contextBlockOut;
	// glyphs-to-chars
	// pdichwContext
	// arrow key behavior
	// etc.

	//	Setters:
	void SetCharCount(int charCount);
	void SetGlyphCount(int glyphCount);
	void SetGlyphList(gid16 * glyphList);
	void SetXPositions(int * posList);
	void SetYPositions(int * posList);
	void SetAdvWidths(int * advWidths);
	void SetBBs(int * bbLefts, int * bbRights, int * bbTops, int * bbBottoms);
	void SetInsPtFlags(bool * flags);
	void SetCharsToGlyphs(int * stuff, int count);
	void SetAttachedClusters(int * stuff, int count);
	void SetClickTests(int clickTestCount, int * clickStuff);
	void SetInputContextBlock(int contextBlockInSize, gr::byte * contextBlockIn);
	void SetOutputContextBlock(int contextBlockOutSize, gr::byte * contextBlockIn);
};


#endif // !TESTCASE_H