summaryrefslogtreecommitdiff
path: root/tests/test_properties.py
diff options
context:
space:
mode:
authorGarrett Regier <garrettregier@gmail.com>2013-07-02 06:07:15 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2013-07-02 16:16:57 -0700
commitb96a6dc968566d339a2dfd7dd631ae52d812302a (patch)
tree0dbe206ff61b27bedbf23f82458c56ddbb3c8f53 /tests/test_properties.py
parent61b268e44af63d6d78feae42578bf75aa5cfd511 (diff)
downloadpygobject-b96a6dc968566d339a2dfd7dd631ae52d812302a.tar.gz
Add support for properties of type GInterface
Add support for G_TYPE_INTERFACE/GInterface to switch statement which handles G_TYPE_OBJECT based properties. Signed-off-by: Simon Feltman <sfeltman@src.gnome.org> https://bugzilla.gnome.org/show_bug.cgi?id=703456
Diffstat (limited to 'tests/test_properties.py')
-rw-r--r--tests/test_properties.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 4b128f39..ef6b8674 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -69,6 +69,9 @@ class PropertyObject(GObject.GObject):
type=TYPE_VARIANT, flags=PARAM_READWRITE | PARAM_CONSTRUCT,
default=GLib.Variant('i', 42))
+ interface = GObject.Property(
+ type=Gio.File, flags=PARAM_READWRITE | PARAM_CONSTRUCT)
+
class PropertyInheritanceObject(Regress.TestObj):
# override property from the base class, with a different type
@@ -133,6 +136,7 @@ class TestPropertyObject(unittest.TestCase):
'enum',
'flags',
'gtype',
+ 'interface',
'normal',
'strings',
'uint64',
@@ -389,6 +393,17 @@ class TestPropertyObject(unittest.TestCase):
obj = new(PropertyObject, variant_def=GLib.Variant('u', 5))
self.assertEqual(obj.props.variant_def.print_(True), 'uint32 5')
+ def test_interface(self):
+ obj = new(PropertyObject)
+
+ file = Gio.File.new_for_path('/some/path')
+ obj.props.interface = file
+ self.assertEqual(obj.props.interface.get_path(), '/some/path')
+ self.assertEqual(obj.interface.get_path(), '/some/path')
+
+ self.assertRaises(TypeError, setattr, obj, 'interface', 'foo')
+ self.assertRaises(TypeError, setattr, obj, 'interface', object())
+
def test_range(self):
# kiwi code
def max(c):
@@ -827,6 +842,7 @@ class TestProperty(unittest.TestCase):
self.assertEqual(tester._type_from_python(GObject.GEnum), GObject.GEnum.__gtype__)
self.assertEqual(tester._type_from_python(GObject.GFlags), GObject.GFlags.__gtype__)
self.assertEqual(tester._type_from_python(GObject.GBoxed), GObject.GBoxed.__gtype__)
+ self.assertEqual(tester._type_from_python(GObject.GInterface), GObject.GInterface.__gtype__)
for type_ in [TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR,
TYPE_INT, TYPE_UINT, TYPE_BOOLEAN, TYPE_LONG,