[pygobject/pango-layout-set-text-override] overrides: add Pango.Layout.set_text() override. Fixes #259



commit 020383f338c26760ef76502273f15f3ae91e83e7
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Sep 22 21:58:15 2018 +0200

    overrides: add Pango.Layout.set_text() override. Fixes #259

 gi/overrides/Pango.py         |  3 +++
 tests/test_overrides_pango.py | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/gi/overrides/Pango.py b/gi/overrides/Pango.py
index 067a628c..7d0d8cfb 100644
--- a/gi/overrides/Pango.py
+++ b/gi/overrides/Pango.py
@@ -50,6 +50,9 @@ class Layout(Pango.Layout):
     def set_markup(self, text, length=-1):
         super(Layout, self).set_markup(text, length)
 
+    def set_text(self, text, length=-1):
+        super(Layout, self).set_text(text, length)
+
 
 Layout = override(Layout)
 __all__.append('Layout')
diff --git a/tests/test_overrides_pango.py b/tests/test_overrides_pango.py
index a789715d..a08880bd 100644
--- a/tests/test_overrides_pango.py
+++ b/tests/test_overrides_pango.py
@@ -34,6 +34,26 @@ class TestPango(unittest.TestCase):
         layout.set_markup("Foobar")
         self.assertEqual(layout.get_text(), "Foobar")
 
+    def test_layout_set_markup(self):
+        context = Pango.Context()
+        layout = Pango.Layout(context)
+        layout.set_markup("abc")
+        assert layout.get_text() == "abc"
+        layout.set_markup("abc", -1)
+        assert layout.get_text() == "abc"
+        layout.set_markup("abc", 2)
+        assert layout.get_text() == "ab"
+
+    def test_layout_set_test(self):
+        context = Pango.Context()
+        layout = Pango.Layout(context)
+        layout.set_text("abc")
+        assert layout.get_text() == "abc"
+        layout.set_text("abc", -1)
+        assert layout.get_text() == "abc"
+        layout.set_text("abc", 2)
+        assert layout.get_text() == "ab"
+
     def test_break_keyword_escape(self):
         # https://bugzilla.gnome.org/show_bug.cgi?id=697363
         self.assertTrue(hasattr(Pango, 'break_'))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]