summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-07-13 15:32:33 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-07-13 15:32:33 +0000
commitde096a1371a47949778e8644b9a82f0f3646bd2a (patch)
treed9202a9caa5892f68222886d54f04ff09eebc74e /tests
parentf09aea39c70eb9d5a752c36a987b9d7ccf02eaa7 (diff)
downloadpygtk-de096a1371a47949778e8644b9a82f0f3646bd2a.tar.gz
new container tests by Lorenzo Gil Sanchez
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/test_container.py56
2 files changed, 58 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e95c6d7e..9724d474 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,7 +10,8 @@ tests = \
test_pango.py \
test_radiobutton.py \
test_style.py \
- test_textview.py
+ test_textview.py \
+ test_container.py
GTK_PY_FILES = __init__.py _lazyutils.py compat.py deprecation.py keysyms.py
diff --git a/tests/test_container.py b/tests/test_container.py
new file mode 100644
index 00000000..a970fa44
--- /dev/null
+++ b/tests/test_container.py
@@ -0,0 +1,56 @@
+import unittest
+
+from common import gtk, gobject
+
+class MyContainer(gtk.Container):
+ __gtype_name__ = 'MyContainer'
+ def __init__(self):
+ gtk.Container.__init__(self)
+ self.children = []
+ self.props = {}
+
+ def do_add(self, child):
+ child.set_parent(self)
+ self.children.append(child)
+ self.props[child] = '' # we just have one child property
+
+ def do_remove(self, child):
+ widget_was_visible = child.flags() & gtk.VISIBLE
+ child.unparent()
+ self.children.remove(child)
+ del self.props[child]
+
+ if widget_was_visible:
+ self.queue_resize()
+
+ def do_forall(self, internal, callback, data):
+ for child in self.children:
+ callback(child, data)
+
+ def do_set_child_property(self, child, property_id, value, pspec):
+ if pspec.name == 'dumb-prop':
+ self.props[child] = value
+
+ def do_get_child_property(self, child, property_id, pspec):
+ if pspec.name == 'dumb-prop':
+ return self.props[child]
+
+MyContainer.install_child_property(1,
+ ('dumb_prop',
+ gobject.TYPE_STRING,
+ 'Dumb Prop',
+ 'Dumb Property for testing purposes',
+ '', gobject.PARAM_READWRITE))
+
+class ContainerTest(unittest.TestCase):
+
+ def testChildProperties(self):
+ obj = MyContainer()
+ label = gtk.Label()
+ obj.add(label)
+ v = 'dumb value'
+ obj.child_set_property(label, 'dumb_prop', v)
+ self.assertEqual(v, obj.child_get_property(label, 'dumb_prop'))
+
+if __name__ == '__main__':
+ unittest.main()