gecko/gfx/tests/gfxFontSelectionTests.h
Zack Weinberg 00dd731d9b Bug 571989 part 4: Reorganize all the tests directories below gfx/. r=joedrew
--HG--
rename : gfx/thebes/crashtests/122875-1.html => gfx/tests/crashtests/122875-1.html
rename : gfx/thebes/crashtests/156882-1.html => gfx/tests/crashtests/156882-1.html
rename : gfx/thebes/crashtests/157320-1.html => gfx/tests/crashtests/157320-1.html
rename : gfx/thebes/crashtests/199379-1.html => gfx/tests/crashtests/199379-1.html
rename : gfx/thebes/crashtests/206561-1.html => gfx/tests/crashtests/206561-1.html
rename : gfx/thebes/crashtests/248518-1.html => gfx/tests/crashtests/248518-1.html
rename : gfx/thebes/crashtests/306649-1.xml => gfx/tests/crashtests/306649-1.xml
rename : gfx/src/thebes/crashtests/306902-1.xml => gfx/tests/crashtests/306902-1.xml
rename : gfx/thebes/crashtests/333861-1.html => gfx/tests/crashtests/333861-1.html
rename : gfx/thebes/crashtests/334735-1.html => gfx/tests/crashtests/334735-1.html
rename : gfx/thebes/crashtests/345576-1.html => gfx/tests/crashtests/345576-1.html
rename : gfx/thebes/crashtests/345629-1.html => gfx/tests/crashtests/345629-1.html
rename : gfx/thebes/crashtests/348462-1.html => gfx/tests/crashtests/348462-1.html
rename : gfx/thebes/crashtests/348462-2.html => gfx/tests/crashtests/348462-2.html
rename : gfx/thebes/crashtests/369688-1.html => gfx/tests/crashtests/369688-1.html
rename : gfx/thebes/crashtests/369947-1.html => gfx/tests/crashtests/369947-1.html
rename : gfx/thebes/crashtests/372094-1.xhtml => gfx/tests/crashtests/372094-1.xhtml
rename : gfx/thebes/crashtests/376627-1.html => gfx/tests/crashtests/376627-1.html
rename : gfx/thebes/crashtests/377231-1.html => gfx/tests/crashtests/377231-1.html
rename : gfx/thebes/crashtests/377232-1.xhtml => gfx/tests/crashtests/377232-1.xhtml
rename : gfx/thebes/crashtests/377461-1.xhtml => gfx/tests/crashtests/377461-1.xhtml
rename : gfx/thebes/crashtests/383473-1.html => gfx/tests/crashtests/383473-1.html
rename : gfx/src/thebes/crashtests/383872-1.svg => gfx/tests/crashtests/383872-1.svg
rename : gfx/thebes/crashtests/385228-1.svg => gfx/tests/crashtests/385228-1.svg
rename : gfx/thebes/crashtests/385228-2.svg => gfx/tests/crashtests/385228-2.svg
rename : gfx/thebes/crashtests/385289-1.xhtml => gfx/tests/crashtests/385289-1.xhtml
rename : gfx/thebes/crashtests/385417-1.html => gfx/tests/crashtests/385417-1.html
rename : gfx/thebes/crashtests/385417-2.html => gfx/tests/crashtests/385417-2.html
rename : gfx/thebes/crashtests/385423-1.html => gfx/tests/crashtests/385423-1.html
rename : gfx/thebes/crashtests/385423-2.html => gfx/tests/crashtests/385423-2.html
rename : gfx/thebes/crashtests/385719-1.html => gfx/tests/crashtests/385719-1.html
rename : gfx/thebes/crashtests/389326-1-inner.xhtml => gfx/tests/crashtests/389326-1-inner.xhtml
rename : gfx/thebes/crashtests/389326-1.html => gfx/tests/crashtests/389326-1.html
rename : gfx/thebes/crashtests/393746-1.xhtml => gfx/tests/crashtests/393746-1.xhtml
rename : gfx/thebes/crashtests/393749-1.html => gfx/tests/crashtests/393749-1.html
rename : gfx/thebes/crashtests/393822-1.html => gfx/tests/crashtests/393822-1.html
rename : gfx/thebes/crashtests/394246-1.html => gfx/tests/crashtests/394246-1.html
rename : gfx/thebes/crashtests/394246-2.html => gfx/tests/crashtests/394246-2.html
rename : gfx/thebes/crashtests/394384-1.html => gfx/tests/crashtests/394384-1.html
rename : gfx/thebes/crashtests/395335-1.xhtml => gfx/tests/crashtests/395335-1.xhtml
rename : gfx/thebes/crashtests/395458-1.html => gfx/tests/crashtests/395458-1.html
rename : gfx/thebes/crashtests/396321-1.svg => gfx/tests/crashtests/396321-1.svg
rename : gfx/thebes/crashtests/398042-1.xhtml => gfx/tests/crashtests/398042-1.xhtml
rename : gfx/thebes/crashtests/398042-2.xhtml => gfx/tests/crashtests/398042-2.xhtml
rename : gfx/thebes/crashtests/402307-1.html => gfx/tests/crashtests/402307-1.html
rename : gfx/thebes/crashtests/403464-1.html => gfx/tests/crashtests/403464-1.html
rename : gfx/thebes/crashtests/404112-1.html => gfx/tests/crashtests/404112-1.html
rename : gfx/thebes/crashtests/404112-2.html => gfx/tests/crashtests/404112-2.html
rename : gfx/thebes/crashtests/405268-1.xhtml => gfx/tests/crashtests/405268-1.xhtml
rename : gfx/thebes/crashtests/407761-1.html => gfx/tests/crashtests/407761-1.html
rename : gfx/thebes/crashtests/407842.html => gfx/tests/crashtests/407842.html
rename : gfx/thebes/crashtests/408754-1.html => gfx/tests/crashtests/408754-1.html
rename : gfx/thebes/crashtests/410728-1.xml => gfx/tests/crashtests/410728-1.xml
rename : gfx/thebes/crashtests/416637-1.html => gfx/tests/crashtests/416637-1.html
rename : gfx/thebes/crashtests/419095-1.html => gfx/tests/crashtests/419095-1.html
rename : gfx/thebes/crashtests/419255-1.html => gfx/tests/crashtests/419255-1.html
rename : gfx/thebes/crashtests/420945-1.html => gfx/tests/crashtests/420945-1.html
rename : gfx/thebes/crashtests/420962-1.html => gfx/tests/crashtests/420962-1.html
rename : gfx/thebes/crashtests/421393-1.html => gfx/tests/crashtests/421393-1.html
rename : gfx/thebes/crashtests/421813-1.html => gfx/tests/crashtests/421813-1.html
rename : gfx/src/thebes/crashtests/423110-1.xhtml => gfx/tests/crashtests/423110-1.xhtml
rename : gfx/thebes/crashtests/423270-1.html => gfx/tests/crashtests/423270-1.html
rename : gfx/thebes/crashtests/429899-1.html => gfx/tests/crashtests/429899-1.html
rename : gfx/thebes/crashtests/441360.html => gfx/tests/crashtests/441360.html
rename : gfx/thebes/crashtests/441360_data.gif => gfx/tests/crashtests/441360_data.gif
rename : gfx/src/thebes/crashtests/445711.html => gfx/tests/crashtests/445711.html
rename : gfx/thebes/crashtests/463307-1.html => gfx/tests/crashtests/463307-1.html
rename : gfx/thebes/crashtests/467703-1.xhtml => gfx/tests/crashtests/467703-1.xhtml
rename : gfx/thebes/crashtests/467873-1.html => gfx/tests/crashtests/467873-1.html
rename : gfx/thebes/crashtests/470418-1.html => gfx/tests/crashtests/470418-1.html
rename : gfx/thebes/crashtests/474410-1.html => gfx/tests/crashtests/474410-1.html
rename : gfx/thebes/crashtests/483120-1.xhtml => gfx/tests/crashtests/483120-1.xhtml
rename : gfx/thebes/crashtests/483120-2.xhtml => gfx/tests/crashtests/483120-2.xhtml
rename : gfx/thebes/crashtests/487549-1.html => gfx/tests/crashtests/487549-1.html
rename : gfx/thebes/crashtests/487549-bad_kern_table.ttf => gfx/tests/crashtests/487549-bad_kern_table.ttf
rename : gfx/thebes/crashtests/487724-1.html => gfx/tests/crashtests/487724-1.html
rename : gfx/thebes/crashtests/490777-1.html => gfx/tests/crashtests/490777-1.html
rename : gfx/thebes/crashtests/532726-1.html => gfx/tests/crashtests/532726-1.html
rename : gfx/thebes/crashtests/538065-1.html => gfx/tests/crashtests/538065-1.html
rename : gfx/thebes/crashtests/546870-1.html => gfx/tests/crashtests/546870-1.html
rename : gfx/thebes/crashtests/balinese-letter-spacing.html => gfx/tests/crashtests/balinese-letter-spacing.html
rename : gfx/thebes/crashtests/crashtests.list => gfx/tests/crashtests/crashtests.list
rename : gfx/thebes/test/gfxColorManagementTest.cmtest => gfx/tests/gfxColorManagementTest.cmtest
rename : gfx/thebes/test/gfxColorManagementTest.cpp => gfx/tests/gfxColorManagementTest.cpp
rename : gfx/thebes/test/gfxFontSelectionTest.cpp => gfx/tests/gfxFontSelectionTest.cpp
rename : gfx/thebes/test/gfxFontSelectionTests.h => gfx/tests/gfxFontSelectionTests.h
rename : gfx/thebes/test/gfxSurfaceRefCountTest.cpp => gfx/tests/gfxSurfaceRefCountTest.cpp
rename : gfx/thebes/test/gfxTestCocoaHelper.h => gfx/tests/gfxTestCocoaHelper.h
rename : gfx/thebes/test/gfxTestCocoaHelper.mm => gfx/tests/gfxTestCocoaHelper.mm
rename : gfx/thebes/test/gfxTextRunPerfTest.cpp => gfx/tests/gfxTextRunPerfTest.cpp
rename : gfx/thebes/test/gfxWordCacheTest.cpp => gfx/tests/gfxWordCacheTest.cpp
rename : gfx/thebes/mochitest/test_bug509244.html => gfx/tests/mochitest/test_bug509244.html
rename : gfx/thebes/mochitest/test_bug513439.html => gfx/tests/mochitest/test_bug513439.html
rename : gfx/thebes/test/per-word-runs.h => gfx/tests/per-word-runs.h
rename : gfx/thebes/test/process-textruns.pl => gfx/tests/process-textruns.pl
rename : gfx/thebes/test/testprofiles/DELL2407WFP-2B283C91.icc => gfx/tests/testprofiles/DELL2407WFP-2B283C91.icc
rename : gfx/thebes/test/testprofiles/G22LWk-2489A79.icc => gfx/tests/testprofiles/G22LWk-2489A79.icc
rename : gfx/thebes/test/testprofiles/MBP20080419-1.icc => gfx/tests/testprofiles/MBP20080419-1.icc
rename : gfx/thebes/test/testprofiles/PhLCD17a.icm => gfx/tests/testprofiles/PhLCD17a.icm
rename : gfx/thebes/test/testprofiles/identity.icc => gfx/tests/testprofiles/identity.icc
rename : gfx/thebes/test/testprofiles/murphy.icc => gfx/tests/testprofiles/murphy.icc
rename : gfx/thebes/test/testprofiles/sRGB_IEC61966-2-1_noBPC.icc => gfx/tests/testprofiles/sRGB_IEC61966-2-1_noBPC.icc
rename : gfx/thebes/test/testprofiles/sRGB_IEC61966-2-1_withBPC.icc => gfx/tests/testprofiles/sRGB_IEC61966-2-1_withBPC.icc
rename : gfx/thebes/test/testprofiles/sRGB_v4_ICC_preference.icc => gfx/tests/testprofiles/sRGB_v4_ICC_preference.icc
2010-07-13 14:54:18 -07:00

240 lines
9.8 KiB
C

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
*
* This file is #included directly by gfxFontSelectionTest.cpp, and as
* such does not need any #include files or similar. (However, should
* any extra ones be required, it should be ok to do so, as well as
* defining new functions, etc.
*
* To add a new test, call AddTest with the following arguments: the
* CSS font-family string, the gfxFontStyle, an enum (either S_ASCII
* or S_UTF8) indicating the string type, and then the text string
* itself as a string literal. Unfortunately there is no good way to
* embed UTF8 directly into C code, so hex literals will need to be
* placed in the string. Because of the way \x is parsed things like
* "\xabcd" won't work -- you have to do "\xab""cd". "\xab\x01\x03"
* will work fine, though.
*
* The result of AddTest should be assigned to the variable t; after
* AddTest, one or more calls to t->Expect() should be added to define
* the expected result. Multiple Expect() calls in a row for the same
* platform mean that the resulting glyph/font selection items needs
* to have as many items as there are Expect() calls. (See below for
* examples.)
*
* The arguments to Expect are:
*
* platform - a string identifying the platform.
* Valid strings are "win32", "macosx", and "gtk2-pango".
* font - a string (UTF8) giving the unique name of the font.
* See below for how the unique name is constructed.
* glyphs - a set of glyph IDs that are expected.
* This array is constructed using a GLYPHS() macro.
*
* GLYPHS() is just a #define for LiteralArray, which is defined
* in gfxFontSelectionTest.cpp -- if you need more array elements
* than available, just extend LiteralArray with a new constructor
* with the required number of unsigned longs.
*
* The unique font name is a platform-specific constructed string for
* (mostly) identifying a font. On Mac, it's created by taking the
* Postscript name of the font. On Windows, it's created by taking
* the family name, and then appending attributes such as ":Bold",
* ":Italic", etc.
*
* The easiest way to create a test is to add a call to AddTest, and
* then run the test. The output will include a list like:
*
* ==== Test 1
* expected:
* Run[ 0]: 'Verdana' 73 82 82
* Run[ 1]: 'MS UI Gothic' 19401
* Run[ 2]: 'Verdana' 69 68 85
* Test 1 failed
*
* This gives you the information needed for the calls to Expect() --
* the unique name, and the glyphs. Appropriate calls to expect for
* the above would be:
*
* t->Expect ("win32", "Verdana", GLYPHS(73, 82, 82));
* t->Expect ("win32", "MS UI Gothic", GLYPHS(19401));
* t->Expect ("win32", "Verdana", GLYPHS(69, 68, 85));
*
*/
void
SetupTests()
{
TestEntry *t;
/* some common styles */
gfxFontStyle style_western_normal_16 (FONT_STYLE_NORMAL,
NS_FONT_STRETCH_NORMAL,
400,
16.0,
NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
0.0,
PR_FALSE, PR_FALSE, PR_FALSE,
NS_LITERAL_STRING(""),
NS_LITERAL_STRING(""));
gfxFontStyle style_western_bold_16 (FONT_STYLE_NORMAL,
NS_FONT_STRETCH_NORMAL,
700,
16.0,
NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
0.0,
PR_FALSE, PR_FALSE, PR_FALSE,
NS_LITERAL_STRING(""),
NS_LITERAL_STRING(""));
/* Test 0 */
t = AddTest ("sans-serif",
style_western_normal_16,
S_ASCII,
"ABCD");
t->Expect ("win32", "Arial", GLYPHS(36, 37, 38, 39));
t->Expect ("macosx", "Helvetica", GLYPHS(36, 37, 38, 39));
t->Expect ("gtk2-pango", "Albany AMT", GLYPHS(36, 37, 38, 39));
/* Test 1 */
t = AddTest ("verdana,sans-serif",
style_western_normal_16,
S_UTF8,
"foo\xe2\x80\x91""bar");
t->Expect ("win32", "Verdana", GLYPHS(73, 82, 82));
t->Expect ("win32", "Arial Unicode MS", GLYPHS(3236));
t->Expect ("win32", "Verdana", GLYPHS(69, 68, 85));
t->Expect ("macosx", "Verdana", GLYPHS(73, 82, 82));
t->Expect ("macosx", "Helvetica", GLYPHS(587));
t->Expect ("macosx", "Verdana", GLYPHS(69, 68, 85));
/* Test 2 */
t = AddTest ("sans-serif",
style_western_bold_16,
S_ASCII,
"ABCD");
t->Expect ("win32", "Arial:700", GLYPHS(36, 37, 38, 39));
t->Expect ("macosx", "Helvetica-Bold", GLYPHS(36, 37, 38, 39));
t->Expect ("gtk2-pango", "Albany AMT Bold", GLYPHS(36, 37, 38, 39));
/* Test 3: RTL Arabic with a ligature and leading and trailing whitespace */
t = AddTest ("sans-serif",
style_western_normal_16,
S_UTF8,
" \xd8\xaa\xd9\x85 ");
t->SetRTL();
t->Expect ("macosx", "Helvetica", GLYPHS(3));
t->Expect ("macosx", "AlBayan", GLYPHS(47));
t->Expect ("macosx", "Helvetica", GLYPHS(3));
t->Expect ("win32", "Arial", GLYPHS(3, 919, 994, 3));
/* Test 4: LTR Arabic with leading and trailing whitespace */
t = AddTest ("sans-serif",
style_western_normal_16,
S_UTF8,
" \xd9\x85\xd8\xaa ");
t->Expect ("macosx", "Helvetica", GLYPHS(3));
t->Expect ("macosx", "AlBayan", GLYPHS(2, 47));
t->Expect ("macosx", "Helvetica", GLYPHS(3));
t->Expect ("win32", "Arial", GLYPHS(3, 994, 919, 3));
/* Test 5: RTL ASCII with leading whitespace */
t = AddTest ("sans-serif",
style_western_normal_16,
S_ASCII,
" ab");
t->SetRTL();
t->Expect ("macosx", "Helvetica", GLYPHS(3, 68, 69));
t->Expect ("win32", "Arial", GLYPHS(3, 68, 69));
t->Expect ("gtk2-pango", "Albany AMT", GLYPHS(3, 68, 69));
/* Test 6: RTL ASCII with trailing whitespace */
t = AddTest ("sans-serif",
style_western_normal_16,
S_ASCII,
"ab ");
t->SetRTL();
t->Expect ("macosx", "Helvetica", GLYPHS(68, 69, 3));
t->Expect ("win32", "Arial", GLYPHS(68, 69, 3));
t->Expect ("gtk2-pango", "Albany AMT", GLYPHS(68, 69, 3));
/* Test 7: Simple ASCII ligature */
/* Do we have a Windows font with ligatures? Can we use DejaVu Sans? */
t = AddTest ("sans-serif",
style_western_normal_16,
S_ASCII,
"fi");
t->Expect ("macosx", "Helvetica", GLYPHS(192));
t->Expect ("win32", "Arial", GLYPHS(73, 76));
/* Test 8: DEVANAGARI VOWEL I reordering */
/* The glyph for DEVANAGARI VOWEL I 2367 (101) is displayed before the glyph for 2361 (99) */
t = AddTest ("sans-serif",
style_western_normal_16,
S_UTF8,
"\xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\x8f"); // 2330 2366 2361 2367 2319
t->Expect ("macosx", "DevanagariMT", GLYPHS(71, 100, 101, 99, 60));
t->Expect ("win32", "Mangal", GLYPHS(133, 545, 465, 161, 102));
/* Test 9: NWJ test */
t = AddTest ("Kartika",
style_western_normal_16,
S_UTF8,
"\xe0\xb4\xb3\xe0\xb5\x8d\xe2\x80\x8d");
t->Expect ("win32", "Kartika", GLYPHS(332));
/* Test 10: NWJ fallback test */
/* it isn't clear what we should actually do in this case. Ideally
we would have the same results as the previous test, but because
we use sans-serif (i.e. Arial) CSS says we should should really
use Arial for U+200D.
*/
t = AddTest ("sans-serif",
style_western_normal_16,
S_UTF8,
"\xe0\xb4\xb3\xe0\xb5\x8d\xe2\x80\x8d");
t->Expect ("win32", "Kartika", GLYPHS(332));
}