summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-08-27 12:02:33 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-08-27 12:02:33 +0000
commitd05fccab23aef7fa4c406352552262782bf1066c (patch)
tree0e35f797d3aaacf586384e343120ea06f8ae5358 /tests
parent3938273dfd085dc75f64ce44706cf508fd971099 (diff)
downloadpygobject-d05fccab23aef7fa4c406352552262782bf1066c.tar.gz
pygobject-d05fccab23aef7fa4c406352552262782bf1066c.tar.xz
pygobject-d05fccab23aef7fa4c406352552262782bf1066c.zip
interface fixes and tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test-unknown.c62
-rw-r--r--tests/test_interface.py30
2 files changed, 89 insertions, 3 deletions
diff --git a/tests/test-unknown.c b/tests/test-unknown.c
index 2602b4a..4a569fa 100644
--- a/tests/test-unknown.c
+++ b/tests/test-unknown.c
@@ -1,5 +1,28 @@
#include "test-unknown.h"
+enum {
+ PROP_SOME_PROPERTY = 1,
+};
+
+
+static void
+test_interface_base_init (gpointer g_iface)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ g_object_interface_install_property (g_iface,
+ g_param_spec_string ("some-property",
+ "some-property",
+ "A simple test property",
+ NULL,
+ G_PARAM_READWRITE));
+ initialized = TRUE;
+ }
+}
+
+
GType
test_interface_get_type (void)
{
@@ -10,7 +33,7 @@ test_interface_get_type (void)
static const GTypeInfo info =
{
sizeof (TestInterfaceIface), /* class_size */
- NULL, /* base_init */
+ test_interface_base_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
@@ -45,7 +68,42 @@ G_DEFINE_TYPE_WITH_CODE (TestUnknown, test_unknown, G_TYPE_OBJECT,
test_unknown_test_interface_init));
static void test_unknown_init (TestUnknown *self) {}
-static void test_unknown_class_init (TestUnknownClass *klass) {}
+
+
+static void
+test_unknown_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+
+}
+
+static void
+test_unknown_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+
+}
+
+static void test_unknown_class_init (TestUnknownClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+
+ gobject_class->get_property = test_unknown_get_property;
+ gobject_class->set_property = test_unknown_set_property;
+
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ PROP_SOME_PROPERTY,
+ g_param_spec_string ("some-property",
+ "some-property",
+ "A simple test property",
+ NULL,
+ G_PARAM_READWRITE));
+}
void test_interface_iface_method (TestInterface *instance)
{
diff --git a/tests/test_interface.py b/tests/test_interface.py
index 2e45e1d..d54515d 100644
--- a/tests/test_interface.py
+++ b/tests/test_interface.py
@@ -8,6 +8,11 @@ GUnknown = gobject.type_from_name("TestUnknown")
Unknown = GUnknown.pytype
class MyUnknown(Unknown, testhelper.Interface):
+ __gproperties__ = {
+ 'some-property': (str, 'blurb', 'description', 'default',
+ gobject.PARAM_READWRITE),
+ }
+
def __init__(self):
Unknown.__init__(self)
self.called = False
@@ -18,8 +23,31 @@ class MyUnknown(Unknown, testhelper.Interface):
gobject.type_register(MyUnknown)
+class MyObject(gobject.GObject, testhelper.Interface):
+ __gproperties__ = {
+ 'some-property': (str, 'blurb', 'description', 'default',
+ gobject.PARAM_READWRITE),
+ }
+
+ def __init__(self):
+ GObject.__init__(self)
+ self.called = False
+
+ def do_iface_method(self):
+ self.called = True
+
+gobject.type_register(MyObject)
+
+
class TestIfaceImpl(unittest.TestCase):
- def testMethodCall(self):
+
+ def testReImplementInterface(self):
m = MyUnknown()
m.iface_method()
self.assertEqual(m.called, True)
+
+ def testImplementInterface(self):
+ m = MyObject()
+ m.iface_method()
+ self.assertEqual(m.called, True)
+