summaryrefslogtreecommitdiff
path: root/tests/test_overrides_pango.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:45:23 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:45:27 +0900
commitee6939d73fd96606a92eee870014c58eafee5e63 (patch)
tree6a3526fab8e841879fbcab05749fcb4a91a4f580 /tests/test_overrides_pango.py
parent0df45a72dc2a72275a5c49c38b87f73341987192 (diff)
downloadpygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.tar.gz
pygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.tar.bz2
pygobject2-ee6939d73fd96606a92eee870014c58eafee5e63.zip
Imported Upstream version 3.20.0
Change-Id: I8106882e9a0d7a8fb554f9549e7c2cde111c104b Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'tests/test_overrides_pango.py')
-rw-r--r--tests/test_overrides_pango.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_overrides_pango.py b/tests/test_overrides_pango.py
new file mode 100644
index 0000000..5177213
--- /dev/null
+++ b/tests/test_overrides_pango.py
@@ -0,0 +1,52 @@
+# -*- Mode: Python; py-indent-offset: 4 -*-
+# vim: tabstop=4 shiftwidth=4 expandtab
+
+import unittest
+
+try:
+ import gi
+ gi.require_version('Pango', '1.0')
+ gi.require_version('PangoCairo', '1.0')
+ from gi.repository import Pango
+ from gi.repository import PangoCairo
+ Pango
+ PangoCairo
+except (ValueError, ImportError):
+ Pango = None
+ PangoCairo = None
+
+
+@unittest.skipUnless(Pango, 'Pango not available')
+class TestPango(unittest.TestCase):
+
+ def test_default_font_description(self):
+ desc = Pango.FontDescription()
+ self.assertEqual(desc.get_variant(), Pango.Variant.NORMAL)
+
+ def test_font_description(self):
+ desc = Pango.FontDescription('monospace')
+ self.assertEqual(desc.get_family(), 'monospace')
+ self.assertEqual(desc.get_variant(), Pango.Variant.NORMAL)
+
+ def test_layout(self):
+ self.assertRaises(TypeError, Pango.Layout)
+ context = Pango.Context()
+ layout = Pango.Layout(context)
+ self.assertEqual(layout.get_context(), context)
+
+ layout.set_markup("Foobar")
+ self.assertEqual(layout.get_text(), "Foobar")
+
+ def test_break_keyword_escape(self):
+ # https://bugzilla.gnome.org/show_bug.cgi?id=697363
+ self.assertTrue(hasattr(Pango, 'break_'))
+ self.assertTrue(Pango.break_ is not None)
+
+ def test_context_get_metrics(self):
+ # Test default "language" argument
+ font_map = PangoCairo.font_map_get_default()
+ context = font_map.create_context()
+ desc = Pango.FontDescription('monospace')
+ metrics1 = context.get_metrics(desc)
+ metrics2 = context.get_metrics(desc, context.get_language())
+ self.assertEqual(metrics1.get_ascent(), metrics2.get_ascent())