From ee6939d73fd96606a92eee870014c58eafee5e63 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 12 Jul 2017 08:45:23 +0900 Subject: Imported Upstream version 3.20.0 Change-Id: I8106882e9a0d7a8fb554f9549e7c2cde111c104b Signed-off-by: DongHun Kwak --- tests/test_overrides_pango.py | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/test_overrides_pango.py (limited to 'tests/test_overrides_pango.py') 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()) -- cgit v1.2.3