[pango/ellipsize-height] Add a test for !397
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/ellipsize-height] Add a test for !397
- Date: Wed, 7 Aug 2019 02:33:56 +0000 (UTC)
commit eaa8853d9a1faf1c6b7979482b3a9780f16955f8
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Aug 6 19:33:29 2019 -0700
Add a test for !397
tests/meson.build | 1 +
tests/test-ellipsize.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index c425665c..aa4b0c42 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -38,6 +38,7 @@ if cairo_dep.found()
test_cflags += '-DHAVE_CAIRO'
tests += [
[ 'testiter', [ 'testiter.c' ], [ libpangocairo_dep ] ],
+ [ 'test-ellipsize', [ 'test-ellipsize.c' ], [ libpangocairo_dep ] ],
[ 'markup-parse', [ 'markup-parse.c' , 'test-common.c' ], [ libpangocairo_dep ] ],
[ 'test-layout', [ 'test-layout.c', 'test-common.c' ], [ libpangocairo_dep ] ],
[ 'test-itemize', [ 'test-itemize.c', 'test-common.c' ], [ libpangocairo_dep ] ],
diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c
new file mode 100644
index 00000000..1c262aa1
--- /dev/null
+++ b/tests/test-ellipsize.c
@@ -0,0 +1,73 @@
+/* Pango
+ * test-ellipsize.c: Test Pango harfbuzz apis
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <pango/pango.h>
+#include <pango/pangocairo.h>
+#include "test-common.h"
+
+static PangoContext *context;
+
+/* Test that ellipsization does not change the
+ * height of a layout.
+ */
+static void
+test_ellipsize (void)
+{
+ PangoLayout *layout;
+ int height1, height2;
+ PangoFontDescription *desc;
+
+ layout = pango_layout_new (context);
+
+ desc = pango_font_description_from_string ("Fixed 7");
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+
+ pango_layout_set_text (layout, "some text that should be ellipsized", -1);
+ g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
+ pango_layout_get_pixel_size (layout, NULL, &height1);
+
+ pango_layout_set_width (layout, 100 * PANGO_SCALE);
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+
+ g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
+ g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, 1);
+ pango_layout_get_pixel_size (layout, NULL, &height2);
+
+ g_assert_cmpint (height1, ==, height2);
+
+ g_object_unref (layout);
+}
+
+int
+main (int argc, char *argv[])
+{
+ PangoFontMap *fontmap;
+
+ fontmap = pango_cairo_font_map_get_default ();
+ context = pango_font_map_create_context (fontmap);
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/layout/ellipsize", test_ellipsize);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]