summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2016-08-22 11:24:14 +0900
committerYoungbok Shin <youngb.shin@samsung.com>2016-08-22 11:24:14 +0900
commit5200acdbfd74b4eda74180a84ba3c53f170d95f0 (patch)
tree54583ba7d5a7ced507152dde121fd56264bfcb01 /test/api
parente684182ac634596bace621b0e84dfc98d2bc82c5 (diff)
downloadharfbuzz-5200acdbfd74b4eda74180a84ba3c53f170d95f0.tar.gz
harfbuzz-5200acdbfd74b4eda74180a84ba3c53f170d95f0.tar.bz2
harfbuzz-5200acdbfd74b4eda74180a84ba3c53f170d95f0.zip
Imported Upstream version 1.2.7
Diffstat (limited to 'test/api')
-rw-r--r--test/api/Makefile.am6
-rw-r--r--test/api/Makefile.in19
-rw-r--r--test/api/test-font.c58
-rw-r--r--test/api/test-object.c38
-rw-r--r--test/api/test-ot-tag.c7
-rw-r--r--test/api/test-shape.c45
6 files changed, 130 insertions, 43 deletions
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 4ff14fa..d7d40af 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -6,6 +6,10 @@ CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
+# Convenience targets:
+lib:
+ @$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src lib
+
if HAVE_GLIB
AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ -I$(top_builddir)/src/ $(GLIB_CFLAGS)
LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS)
@@ -34,7 +38,7 @@ test_unicode_CPPFLAGS += $(GLIB_CFLAGS)
endif
if HAVE_ICU
test_unicode_CPPFLAGS += $(ICU_CFLAGS)
-test_unicode_LDADD += $(top_builddir)/src/libharfbuzz-icu.la
+test_unicode_LDADD += $(top_builddir)/src/libharfbuzz-icu.la $(ICU_LIBS)
endif
diff --git a/test/api/Makefile.in b/test/api/Makefile.in
index 6faa95f..951a535 100644
--- a/test/api/Makefile.in
+++ b/test/api/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.14 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -84,7 +84,7 @@ host_triplet = @host@
@HAVE_GLIB_TRUE@check_PROGRAMS = $(am__EXEEXT_3)
@HAVE_GLIB_TRUE@noinst_PROGRAMS = $(am__EXEEXT_3)
@HAVE_GLIB_TRUE@@HAVE_ICU_TRUE@am__append_2 = $(ICU_CFLAGS)
-@HAVE_GLIB_TRUE@@HAVE_ICU_TRUE@am__append_3 = $(top_builddir)/src/libharfbuzz-icu.la
+@HAVE_GLIB_TRUE@@HAVE_ICU_TRUE@am__append_3 = $(top_builddir)/src/libharfbuzz-icu.la $(ICU_LIBS)
@HAVE_GLIB_TRUE@@HAVE_OT_TRUE@am__append_4 = \
@HAVE_GLIB_TRUE@@HAVE_OT_TRUE@ test-ot-tag \
@HAVE_GLIB_TRUE@@HAVE_OT_TRUE@ $(NULL)
@@ -195,8 +195,10 @@ test_unicode_OBJECTS = test_unicode-test-unicode.$(OBJEXT)
@HAVE_GLIB_TRUE@am__DEPENDENCIES_2 = \
@HAVE_GLIB_TRUE@ $(top_builddir)/src/libharfbuzz.la \
@HAVE_GLIB_TRUE@ $(am__DEPENDENCIES_1)
+@HAVE_GLIB_TRUE@@HAVE_ICU_TRUE@am__DEPENDENCIES_3 = $(top_builddir)/src/libharfbuzz-icu.la \
+@HAVE_GLIB_TRUE@@HAVE_ICU_TRUE@ $(am__DEPENDENCIES_1)
@HAVE_GLIB_TRUE@test_unicode_DEPENDENCIES = $(am__DEPENDENCIES_2) \
-@HAVE_GLIB_TRUE@ $(am__append_3)
+@HAVE_GLIB_TRUE@ $(am__DEPENDENCIES_3)
test_version_SOURCES = test-version.c
test_version_OBJECTS = test-version.$(OBJEXT)
test_version_LDADD = $(LDADD)
@@ -518,6 +520,8 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DIRECTWRITE_CXXFLAGS = @DIRECTWRITE_CXXFLAGS@
+DIRECTWRITE_LIBS = @DIRECTWRITE_LIBS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
@@ -527,15 +531,20 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_DEPS = @FREETYPE_DEPS@
FREETYPE_LIBS = @FREETYPE_LIBS@
GIT = @GIT@
GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_DEPS = @GLIB_DEPS@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_CFLAGS = @GOBJECT_CFLAGS@
GOBJECT_LIBS = @GOBJECT_LIBS@
GRAPHITE2_CFLAGS = @GRAPHITE2_CFLAGS@
+GRAPHITE2_DEPS = @GRAPHITE2_DEPS@
GRAPHITE2_LIBS = @GRAPHITE2_LIBS@
GREP = @GREP@
GTKDOC_CHECK = @GTKDOC_CHECK@
@@ -1365,6 +1374,10 @@ uninstall-am:
uninstall-am
+# Convenience targets:
+lib:
+ @$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src lib
+
# check-tool: Run tests under $(TOOL)
@HAVE_GLIB_TRUE@check-tool:
@HAVE_GLIB_TRUE@ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) check \
diff --git a/test/api/test-font.c b/test/api/test-font.c
index 6b6a503..34f6c74 100644
--- a/test/api/test-font.c
+++ b/test/api/test-font.c
@@ -36,8 +36,8 @@ static void
test_face_empty (void)
{
g_assert (hb_face_get_empty ());
- g_assert (hb_face_get_empty () == hb_face_create (hb_blob_get_empty (), 0));
- g_assert (hb_face_get_empty () == hb_face_create (NULL, 0));
+ g_assert (hb_face_get_empty () != hb_face_create (hb_blob_get_empty (), 0));
+ g_assert (hb_face_get_empty () != hb_face_create (NULL, 0));
g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
@@ -115,6 +115,7 @@ _test_font_nil_funcs (hb_font_t *font)
hb_codepoint_t glyph;
hb_position_t x, y;
hb_glyph_extents_t extents;
+ unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
x = y = 13;
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
@@ -122,7 +123,7 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert_cmpint (y, ==, 0);
x = hb_font_get_glyph_h_advance (font, 17);
- g_assert_cmpint (x, ==, 0);
+ g_assert_cmpint (x, ==, upem);
extents.x_bearing = extents.y_bearing = 13;
extents.width = extents.height = 15;
@@ -290,9 +291,22 @@ test_fontfuncs_subclassing (void)
x = hb_font_get_glyph_h_advance (font1, 2);
g_assert_cmpint (x, ==, 0);
-
+ /* creating sub-font doesn't make the parent font immutable;
+ * making a font immutable however makes it's lineage immutable.
+ */
font2 = hb_font_create_sub_font (font1);
+ font3 = hb_font_create_sub_font (font2);
+ g_assert (!hb_font_is_immutable (font1));
+ g_assert (!hb_font_is_immutable (font2));
+ g_assert (!hb_font_is_immutable (font3));
+ hb_font_make_immutable (font3);
g_assert (hb_font_is_immutable (font1));
+ g_assert (hb_font_is_immutable (font2));
+ g_assert (hb_font_is_immutable (font3));
+ hb_font_destroy (font2);
+ hb_font_destroy (font3);
+
+ font2 = hb_font_create_sub_font (font1);
hb_font_destroy (font1);
/* setup font2 to override some funcs */
@@ -316,12 +330,8 @@ test_fontfuncs_subclassing (void)
x = hb_font_get_glyph_h_advance (font2, 2);
g_assert_cmpint (x, ==, 0);
-
- font3 = hb_font_create_sub_font (font2);
- g_assert (hb_font_is_immutable (font2));
- hb_font_destroy (font2);
-
/* setup font3 to override scale */
+ font3 = hb_font_create_sub_font (font2);
hb_font_set_scale (font3, 20, 30);
x = y = 1;
@@ -348,9 +358,9 @@ static void
test_font_empty (void)
{
g_assert (hb_font_get_empty ());
- g_assert (hb_font_get_empty () == hb_font_create (hb_face_get_empty ()));
- g_assert (hb_font_get_empty () == hb_font_create (NULL));
- g_assert (hb_font_get_empty () == hb_font_create_sub_font (NULL));
+ g_assert (hb_font_get_empty () != hb_font_create (hb_face_get_empty ()));
+ g_assert (hb_font_get_empty () != hb_font_create (NULL));
+ g_assert (hb_font_get_empty () != hb_font_create_sub_font (NULL));
g_assert (hb_font_is_immutable (hb_font_get_empty ()));
g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
@@ -366,6 +376,7 @@ test_font_properties (void)
hb_font_t *subfont;
int x_scale, y_scale;
unsigned int x_ppem, y_ppem;
+ unsigned int upem;
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
face = hb_face_create (blob, 0);
@@ -375,22 +386,35 @@ test_font_properties (void)
g_assert (hb_font_get_face (font) == face);
- g_assert (hb_font_get_parent (font) == NULL);
+ g_assert (hb_font_get_parent (font) == hb_font_get_empty ());
+ subfont = hb_font_create_sub_font (font);
+ g_assert (hb_font_get_parent (subfont) == font);
+ hb_font_set_parent(subfont, NULL);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_set_parent(subfont, font);
+ g_assert (hb_font_get_parent (subfont) == font);
+ hb_font_set_parent(subfont, NULL);
+ hb_font_make_immutable (subfont);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_set_parent(subfont, font);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_destroy (subfont);
/* Check scale */
+ upem = hb_face_get_upem (hb_font_get_face (font));
hb_font_get_scale (font, NULL, NULL);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, NULL);
- g_assert_cmpint (x_scale, ==, 0);
+ g_assert_cmpint (x_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, NULL, &y_scale);
- g_assert_cmpint (y_scale, ==, 0);
+ g_assert_cmpint (y_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, &y_scale);
- g_assert_cmpint (x_scale, ==, 0);
- g_assert_cmpint (y_scale, ==, 0);
+ g_assert_cmpint (x_scale, ==, upem);
+ g_assert_cmpint (y_scale, ==, upem);
hb_font_set_scale (font, 17, 19);
diff --git a/test/api/test-object.c b/test/api/test-object.c
index 3afe6ae..02b9760 100644
--- a/test/api/test-object.c
+++ b/test/api/test-object.c
@@ -36,7 +36,7 @@ create_blob (void)
return hb_blob_create (data, sizeof (data), HB_MEMORY_MODE_READONLY, NULL, NULL);
}
static void *
-create_blob_inert (void)
+create_blob_from_inert (void)
{
return hb_blob_create (NULL, 0, HB_MEMORY_MODE_DUPLICATE, NULL, NULL);
}
@@ -47,7 +47,7 @@ create_buffer (void)
return hb_buffer_create ();
}
static void *
-create_buffer_inert (void)
+create_buffer_from_inert (void)
{
return NULL;
}
@@ -58,7 +58,7 @@ create_set (void)
return hb_set_create ();
}
static void *
-create_set_inert (void)
+create_set_from_inert (void)
{
return NULL;
}
@@ -72,7 +72,7 @@ create_face (void)
return face;
}
static void *
-create_face_inert (void)
+create_face_from_inert (void)
{
return hb_face_create (hb_blob_get_empty (), 0);
}
@@ -86,7 +86,7 @@ create_font (void)
return font;
}
static void *
-create_font_inert (void)
+create_font_from_inert (void)
{
return hb_font_create (hb_face_get_empty ());
}
@@ -97,7 +97,7 @@ create_font_funcs (void)
return hb_font_funcs_create ();
}
static void *
-create_font_funcs_inert (void)
+create_font_funcs_from_inert (void)
{
return NULL;
}
@@ -108,9 +108,9 @@ create_unicode_funcs (void)
return hb_unicode_funcs_create (NULL);
}
static void *
-create_unicode_funcs_inert (void)
+create_unicode_funcs_from_inert (void)
{
- return hb_unicode_funcs_get_default ();
+ return hb_unicode_funcs_create (hb_unicode_funcs_get_empty ());
}
@@ -125,7 +125,7 @@ typedef hb_bool_t (*is_immutable_func_t) (void *obj);
typedef struct {
create_func_t create;
- create_func_t create_inert;
+ create_func_t create_from_inert;
create_func_t get_empty;
reference_func_t reference;
destroy_func_t destroy;
@@ -139,7 +139,7 @@ typedef struct {
#define OBJECT_WITHOUT_IMMUTABILITY(name) \
{ \
(create_func_t) create_##name, \
- (create_func_t) create_##name##_inert, \
+ (create_func_t) create_##name##_from_inert, \
(create_func_t) hb_##name##_get_empty, \
(reference_func_t) hb_##name##_reference, \
(destroy_func_t) hb_##name##_destroy, \
@@ -152,7 +152,7 @@ typedef struct {
#define OBJECT_WITH_IMMUTABILITY(name) \
{ \
(create_func_t) create_##name, \
- (create_func_t) create_##name##_inert, \
+ (create_func_t) create_##name##_from_inert, \
(create_func_t) hb_##name##_get_empty, \
(reference_func_t) hb_##name##_reference, \
(destroy_func_t) hb_##name##_destroy, \
@@ -340,8 +340,8 @@ test_object (void)
{
data_t data[2] = {{MAGIC0, FALSE}, {MAGIC1, FALSE}};
- g_test_message ("->create_inert()");
- obj = o->create_inert ();
+ g_test_message ("->create_from_inert()");
+ obj = o->create_from_inert ();
if (!obj)
continue;
if (obj == o->get_empty ())
@@ -351,18 +351,14 @@ test_object (void)
o->destroy (obj);
if (o->is_immutable)
- g_assert (o->is_immutable (obj));
+ g_assert (!o->is_immutable (obj));
- g_assert (!o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
- g_assert (!o->get_user_data (obj, &key[0]));
+ g_assert (o->set_user_data (obj, &key[0], &data[0], free_up0, TRUE));
+ g_assert (o->get_user_data (obj, &key[0]));
o->destroy (obj);
- o->destroy (obj);
- o->destroy (obj);
- o->destroy (obj);
- o->destroy (obj);
- g_assert (!data[0].freed);
+ g_assert (data[0].freed);
}
}
}
diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c
index b667c7d..29e0aa2 100644
--- a/test/api/test-ot-tag.c
+++ b/test/api/test-ot-tag.c
@@ -222,6 +222,13 @@ test_ot_tag_language (void)
test_tag_from_language ("XYZ", "xyz"); /* Unknown ISO 639-3 */
test_tag_from_language ("XYZ", "xyz-qw"); /* Unknown ISO 639-3 */
+ /* International Phonetic Alphabet */
+ test_tag_from_language ("IPPH", "en-fonipa");
+ test_tag_from_language ("IPPH", "rm-CH-fonipa-sursilv-x-foobar");
+ test_tag_from_language ("IPPH", "und-fonipa");
+ test_tag_from_language ("IPPH", "zh-fonipa");
+ test_tag_to_language ("IPPH", "und-fonipa");
+
/* Test that x-hbot overrides the base language */
test_tag_from_language ("ABC", "fa-x-hbotabc-zxc");
test_tag_from_language ("ABC", "fa-ir-x-hbotabc-zxc");
diff --git a/test/api/test-shape.c b/test/api/test-shape.c
index ccf6eed..c274f0f 100644
--- a/test/api/test-shape.c
+++ b/test/api/test-shape.c
@@ -101,7 +101,7 @@ test_shape (void)
ffuncs = hb_font_funcs_create ();
hb_font_funcs_set_glyph_h_advance_func (ffuncs, glyph_h_advance_func, NULL, NULL);
- hb_font_funcs_set_glyph_func (ffuncs, glyph_func, NULL, NULL);
+ hb_font_funcs_set_glyph_func (ffuncs, glyph_func, malloc (10), free);
hb_font_funcs_set_glyph_h_kerning_func (ffuncs, glyph_h_kerning_func, NULL, NULL);
hb_font_set_funcs (font, ffuncs, NULL, NULL);
hb_font_funcs_destroy (ffuncs);
@@ -139,6 +139,48 @@ test_shape (void)
}
static void
+test_shape_clusters (void)
+{
+ hb_face_t *face;
+ hb_font_t *font;
+ hb_buffer_t *buffer;
+ unsigned int len;
+ hb_glyph_info_t *glyphs;
+
+ face = hb_face_create (NULL, 0);
+ font = hb_font_create (face);
+ hb_face_destroy (face);
+
+ buffer = hb_buffer_create ();
+ hb_buffer_set_direction (buffer, HB_DIRECTION_LTR);
+ {
+ /* https://code.google.com/p/chromium/issues/detail?id=497578 */
+ hb_codepoint_t test[] = {0xFFF1, 0xF0B6};
+ hb_buffer_add_utf32 (buffer, test, 2, 0, 2);
+ }
+
+ hb_shape (font, buffer, NULL, 0);
+
+ len = hb_buffer_get_length (buffer);
+ glyphs = hb_buffer_get_glyph_infos (buffer, NULL);
+
+ {
+ const hb_codepoint_t output_glyphs[] = {0};
+ const hb_position_t output_clusters[] = {0};
+ unsigned int i;
+ g_assert_cmpint (len, ==, 1);
+ for (i = 0; i < len; i++) {
+ g_assert_cmphex (glyphs[i].codepoint, ==, output_glyphs[i]);
+ g_assert_cmphex (glyphs[i].cluster, ==, output_clusters[i]);
+ }
+ }
+
+ hb_buffer_destroy (buffer);
+ hb_font_destroy (font);
+}
+
+
+static void
test_shape_list (void)
{
const char **shapers = hb_shape_list_shapers ();
@@ -157,6 +199,7 @@ main (int argc, char **argv)
hb_test_init (&argc, &argv);
hb_test_add (test_shape);
+ hb_test_add (test_shape_clusters);
/* TODO test fallback shaper */
/* TODO test shaper_full */
hb_test_add (test_shape_list);