[pygobject] tests: Port to new introspection tests



commit 720e614acdbcf734d4bcccc403e639b5a5bcae24
Author: Colin Walters <walters verbum org>
Date:   Fri Aug 20 10:58:48 2010 -0400

    tests: Port to new introspection tests
    
    Everything is renamed "Regress", and both it and GIMarshallingTests
    are now in source form, so we compile them.
    
    The scanner now adds "static methods" to objects, structs, and unions,
    so update the test code to use those.
    
    In the tests, remove broken (inout) cases - the person writing these
    tests misunderstood the semantics of (inout).  It's not acceptable for
    a C API to mutate e.g. a GSList* passed in, or unref an object.
    
    The invocation code needed to be updated for this - remove some
    broken hacks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=627878

 configure.ac             |    5 +-
 gi/pygi-argument.c       |    9 +--
 gi/pygi-invoke.c         |  147 +++++----------------------------------------
 tests/Makefile.am        |   42 ++++++++++++-
 tests/test_everything.py |    6 +-
 tests/test_gi.py         |  151 +++++++++-------------------------------------
 6 files changed, 93 insertions(+), 267 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f963ee2..41e694b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ m4_define(pygobject_micro_version, 6)
 m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version)
 
 dnl versions of packages we require ...
-m4_define(introspection_required_version, 0.9.1)
+m4_define(introspection_required_version, 0.9.5)
 m4_define(pycairo_required_version, 1.0.2)
 m4_define(glib_required_version, 2.22.4)
 m4_define(gio_required_version, 2.22.4)
@@ -220,6 +220,9 @@ if test "$enable_introspection" != no; then
         gobject-introspection-1.0 >= introspection_required_version
     )
 
+    GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
+    AC_SUBST(GI_DATADIR)
+
     if test "$enable_cairo" != no; then
         PKG_CHECK_MODULES(PYCAIRO,
             pycairo >= pycairo_required_version
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index b66ea1e..d198158 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -603,12 +603,6 @@ _pygi_argument_to_array (GArgument  *arg,
             length_arg_pos = g_type_info_get_array_length (type_info);
             g_assert (length_arg_pos >= 0);
 
-            if (is_method) {
-                length_arg_pos--;
-            }
-
-            g_assert (length_arg_pos >= 0);
-
             /* FIXME: Take into account the type of the argument. */
             length = args[length_arg_pos]->v_int;
         }
@@ -1592,6 +1586,7 @@ _pygi_argument_release (GArgument   *arg,
                         GIDirection  direction)
 {
     GITypeTag type_tag;
+    gboolean is_out = (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT);
 
     type_tag = g_type_info_get_tag (type_info);
 
@@ -1719,7 +1714,7 @@ _pygi_argument_release (GArgument   *arg,
                     if (arg->v_pointer == NULL) {
                         return;
                     }
-                    if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING) {
+                    if (is_out && transfer == GI_TRANSFER_EVERYTHING) {
                         g_object_unref (arg->v_pointer);
                     }
                     break;
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index d8e4b35..ba331f3 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -154,18 +154,14 @@ _prepare_invocation_state (struct invocation_state *state,
 
         if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) {
             state->n_in_args += 1;
-            if (transfer == GI_TRANSFER_CONTAINER) {
-                state->n_backup_args += 1;
-            }
         }
+	if (direction == GI_DIRECTION_INOUT) {
+	    state->n_backup_args += 1;
+	}
         if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) {
             state->n_out_args += 1;
         }
 
-        if (direction == GI_DIRECTION_INOUT && transfer == GI_TRANSFER_NOTHING) {
-            state->n_backup_args += 1;
-        }
-
         switch (arg_type_tag) {
             case GI_TYPE_TAG_ARRAY:
             {
@@ -173,13 +169,16 @@ _prepare_invocation_state (struct invocation_state *state,
 
                 length_arg_pos = g_type_info_get_array_length (state->arg_type_infos[i]);
 
-                if (state->is_method)
-                    length_arg_pos--; // length_arg_pos refers to C args
-
                 if (length_arg_pos < 0) {
                     break;
                 }
 
+		/* For array lengths, we're going to delete the length argument; so remove the
+		 * extra backup we just added above */
+		if (direction == GI_DIRECTION_INOUT) {
+		    state->n_backup_args -= 1;
+		}
+
                 g_assert (length_arg_pos < state->n_args);
                 state->args_is_auxiliary[length_arg_pos] = TRUE;
 
@@ -208,9 +207,6 @@ _prepare_invocation_state (struct invocation_state *state,
         gint length_arg_pos;
         length_arg_pos = g_type_info_get_array_length (state->return_type_info);
 
-        if (state->is_method)
-            length_arg_pos--; // length_arg_pos refers to C args
-
         if (length_arg_pos >= 0) {
             g_assert (length_arg_pos < state->n_args);
             state->args_is_auxiliary[length_arg_pos] = TRUE;
@@ -483,61 +479,11 @@ _prepare_invocation_state (struct invocation_state *state,
                     return FALSE;
                 }
 
-                if (direction == GI_DIRECTION_INOUT && transfer == GI_TRANSFER_NOTHING) {
+                if (direction == GI_DIRECTION_INOUT) {
                     /* We need to keep a copy of the argument to be able to release it later. */
                     g_assert (backup_args_pos < state->n_backup_args);
                     state->backup_args[backup_args_pos] = *state->args[i];
                     backup_args_pos += 1;
-                } else if (transfer == GI_TRANSFER_CONTAINER) {
-                    /* We need to keep a copy of the items to be able to release them later. */
-                    switch (arg_type_tag) {
-                        case GI_TYPE_TAG_ARRAY:
-                        {
-                            GArray *array;
-                            gsize item_size;
-                            GArray *new_array;
-
-                            array = state->args[i]->v_pointer;
-
-                            item_size = g_array_get_element_size (array);
-
-                            new_array = g_array_sized_new (FALSE, FALSE, item_size, array->len);
-                            g_array_append_vals (new_array, array->data, array->len);
-
-                            g_assert (backup_args_pos < state->n_backup_args);
-                            state->backup_args[backup_args_pos].v_pointer = new_array;
-
-                            break;
-                        }
-                        case GI_TYPE_TAG_GLIST:
-                            g_assert (backup_args_pos < state->n_backup_args);
-                            state->backup_args[backup_args_pos].v_pointer = g_list_copy (state->args[i]->v_pointer);
-                            break;
-                        case GI_TYPE_TAG_GSLIST:
-                            g_assert (backup_args_pos < state->n_backup_args);
-                            state->backup_args[backup_args_pos].v_pointer = g_slist_copy (state->args[i]->v_pointer);
-                            break;
-                        case GI_TYPE_TAG_GHASH:
-                        {
-                            GHashTable *hash_table;
-                            GList *keys;
-                            GList *values;
-
-                            hash_table = state->args[i]->v_pointer;
-
-                            keys = g_hash_table_get_keys (hash_table);
-                            values = g_hash_table_get_values (hash_table);
-
-                            g_assert (backup_args_pos < state->n_backup_args);
-                            state->backup_args[backup_args_pos].v_pointer = g_list_concat (keys, values);
-
-                            break;
-                        }
-                        default:
-                            g_warn_if_reached();
-                    }
-
-                    backup_args_pos += 1;
                 }
 
                 if (arg_type_tag == GI_TYPE_TAG_ARRAY) {
@@ -547,8 +493,6 @@ _prepare_invocation_state (struct invocation_state *state,
                     array = state->args[i]->v_pointer;
 
                     length_arg_pos = g_type_info_get_array_length (state->arg_type_infos[i]);
-                    if (state->is_method)
-                        length_arg_pos--; // length_arg_pos refers to C args
                     if (length_arg_pos >= 0) {
                         int len = 0;
                         /* Set the auxiliary argument holding the length. */
@@ -841,71 +785,12 @@ _process_invocation_state (struct invocation_state *state,
 
             /* Release the argument. */
 
-            if ( (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT)
-                    && transfer == GI_TRANSFER_CONTAINER) {
-                /* Release the items we kept in another container. */
-                switch (type_tag) {
-                    case GI_TYPE_TAG_ARRAY:
-                    case GI_TYPE_TAG_GLIST:
-                    case GI_TYPE_TAG_GSLIST:
-                        g_assert (backup_args_pos < state->n_backup_args);
-                        _pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i],
-                                                transfer, GI_DIRECTION_IN);
-                        break;
-                    case GI_TYPE_TAG_GHASH:
-                    {
-                        GITypeInfo *key_type_info;
-                        GITypeInfo *value_type_info;
-                        GList *item;
-                        gsize length;
-                        gsize j;
-
-                        key_type_info = g_type_info_get_param_type (state->arg_type_infos[i], 0);
-                        value_type_info = g_type_info_get_param_type (state->arg_type_infos[i], 1);
-
-                        g_assert (backup_args_pos < state->n_backup_args);
-                        item = state->backup_args[backup_args_pos].v_pointer;
-
-                        length = g_list_length (item) / 2;
-
-                        for (j = 0; j < length; j++, item = g_list_next (item)) {
-                            _pygi_argument_release ( (GArgument *) &item->data, key_type_info,
-                                                     GI_TRANSFER_NOTHING, GI_DIRECTION_IN);
-                        }
-
-                        for (j = 0; j < length; j++, item = g_list_next (item)) {
-                            _pygi_argument_release ( (GArgument *) &item->data, value_type_info,
-                                                     GI_TRANSFER_NOTHING, GI_DIRECTION_IN);
-                        }
-
-                        g_list_free (state->backup_args[backup_args_pos].v_pointer);
-
-                        break;
-                    }
-                    default:
-                        g_warn_if_reached();
-                }
-
-                if (direction == GI_DIRECTION_INOUT) {
-                    /* Release the output argument. */
-                    _pygi_argument_release (state->args[i], state->arg_type_infos[i], GI_TRANSFER_CONTAINER,
-                                            GI_DIRECTION_OUT);
-                }
-
-                backup_args_pos += 1;
-            } else if (direction == GI_DIRECTION_INOUT) {
-                if (transfer == GI_TRANSFER_NOTHING) {
-                    g_assert (backup_args_pos < state->n_backup_args);
-                    _pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i],
-                                            GI_TRANSFER_NOTHING, GI_DIRECTION_IN);
-                    backup_args_pos += 1;
-                }
-
-                _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer,
-                                        GI_DIRECTION_OUT);
-            } else {
-                _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer, direction);
-            }
+            if (direction == GI_DIRECTION_INOUT) {
+		_pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i],
+					transfer, GI_DIRECTION_IN);
+		backup_args_pos += 1;
+	    }
+	    _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer, direction);
 
             if (type_tag == GI_TYPE_TAG_ARRAY
                     && (direction != GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3325f5f..0ca5bb5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,41 @@
+CLEANFILES =
+
+# noinst_ always builds a static library
+testlib_LTLIBRARIES = libregress.la libgimarshallingtests.la
+testlibdir = $(prefix)/unused
+install-testlibLTLIBRARIES: # prevent it from being installed
+
+libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
+libregress_la_CFLAGS = $(GIO_CFLAGS) $(PYCAIRO_CFLAGS)
+libregress_la_LDFLAGS = -avoid-version $(GIO_LIBS) $(PYCAIRO_LIBS)
+libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h
+libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS)
+libgimarshallingtests_la_LDFLAGS = -avoid-version $(GLIB_LIBS)
+
+# g-i doesn't ship these as shared libraries anymore; we build them here
+Regress-1.0.gir: libregress.la Makefile
+	$(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \
+	--namespace=Regress --nsversion=1.0 \
+	--warn-all --warn-error \
+	--library=libregress.la \
+	--libtool="$(top_builddir)/libtool" \
+	--output $@ \
+	$(libregress_la_SOURCES)
+Regress-1.0.typelib: Regress-1.0.gir Makefile
+	$(AM_V_GEN) g-ir-compiler $< -o $@
+
+GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile
+	$(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \
+	--namespace=GIMarshallingTests --nsversion=1.0 --symbol-prefix=gi_marshalling_tests \
+	--warn-all --warn-error \
+	--library=libgimarshallingtests.la \
+	--libtool="$(top_builddir)/libtool" \
+	--output $@ \
+	$(libgimarshallingtests_la_SOURCES)
+GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile
+	$(AM_V_GEN) g-ir-compiler $< -o $@
+
+CLEANFILES += Regress-1.0.gir Regress-1.0.typelib GIMarshallingTests-1.0.gir GIMarshallingTests-1.0.typelib
 
 noinst_LTLIBRARIES = testhelper.la
 
@@ -56,8 +94,8 @@ clean-local:
 	rm -f $(LTLIBRARIES:.la=.so)
 
 
-check-local: $(LTLIBRARIES:.la=.so)
-	PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
+check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib
+	PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(builddir) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
 
 check.gdb:
 	EXEC_NAME="gdb --args" $(MAKE) check
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 0b7455a..5d8c12b 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -11,7 +11,7 @@ import cairo
 
 from gi.repository import GObject
 from gi.repository import GLib
-from gi.repository import Everything
+from gi.repository import Regress as Everything
 
 class TestEverything(unittest.TestCase):
 
@@ -138,7 +138,7 @@ class TestNullableArgs(unittest.TestCase):
         Everything.test_utf8_null_in(None)
 
     def test_in_nullable_object(self):
-        Everything.test_object_null_in(None)
+        Everything.TestObj.null_in(None)
 
     def test_out_nullable_hash(self):
         self.assertEqual(None, Everything.test_ghash_null_out())
@@ -154,7 +154,7 @@ class TestNullableArgs(unittest.TestCase):
         self.assertEqual(None, Everything.test_utf8_null_out())
 
     def test_out_nullable_object(self):
-        self.assertEqual(None, Everything.test_object_null_out())
+        self.assertEqual(None, Everything.TestObj.null_out())
 
 
 class TestCallbacks(unittest.TestCase):
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 08caf48..b7cf733 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -614,9 +614,6 @@ class TestUtf8(unittest.TestCase):
         self.assertRaises(TypeError, GIMarshallingTests.utf8_none_in, CONSTANT_NUMBER)
         self.assertRaises(TypeError, GIMarshallingTests.utf8_none_in, None)
 
-    def test_utf8_full_in(self):
-        GIMarshallingTests.utf8_full_in(CONSTANT_UTF8)
-
     def test_utf8_none_out(self):
         self.assertEquals(CONSTANT_UTF8, GIMarshallingTests.utf8_none_out())
 
@@ -751,12 +748,6 @@ class TestGArray(unittest.TestCase):
     def test_garray_utf8_none_in(self):
         GIMarshallingTests.garray_utf8_none_in(Sequence(['0', '1', '2']))
 
-    def test_garray_utf8_container_in(self):
-        GIMarshallingTests.garray_utf8_container_in(Sequence(['0', '1', '2']))
-
-    def test_garray_utf8_full_in(self):
-        GIMarshallingTests.garray_utf8_full_in(Sequence(['0', '1', '2']))
-
     def test_garray_utf8_none_out(self):
         self.assertEquals(['0', '1', '2'], GIMarshallingTests.garray_utf8_none_out())
 
@@ -801,12 +792,6 @@ class TestGList(unittest.TestCase):
     def test_glist_utf8_none_in(self):
         GIMarshallingTests.glist_utf8_none_in(Sequence(('0', '1', '2')))
 
-    def test_glist_utf8_container_in(self):
-        GIMarshallingTests.glist_utf8_container_in(Sequence(('0', '1', '2')))
-
-    def test_glist_utf8_full_in(self):
-        GIMarshallingTests.glist_utf8_full_in(Sequence(('0', '1', '2')))
-
     def test_glist_utf8_none_out(self):
         self.assertEquals(['0', '1', '2'], GIMarshallingTests.glist_utf8_none_out())
 
@@ -851,12 +836,6 @@ class TestGSList(unittest.TestCase):
     def test_gslist_utf8_none_in(self):
         GIMarshallingTests.gslist_utf8_none_in(Sequence(('0', '1', '2')))
 
-    def test_gslist_utf8_container_in(self):
-        GIMarshallingTests.gslist_utf8_container_in(Sequence(('0', '1', '2')))
-
-    def test_gslist_utf8_full_in(self):
-        GIMarshallingTests.gslist_utf8_full_in(Sequence(('0', '1', '2')))
-
     def test_gslist_utf8_none_out(self):
         self.assertEquals(['0', '1', '2'], GIMarshallingTests.gslist_utf8_none_out())
 
@@ -902,12 +881,6 @@ class TestGHashTable(unittest.TestCase):
     def test_ghashtable_utf8_none_in(self):
         GIMarshallingTests.ghashtable_utf8_none_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'})
 
-    def test_ghashtable_utf8_container_in(self):
-        GIMarshallingTests.ghashtable_utf8_container_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'})
-
-    def test_ghashtable_utf8_full_in(self):
-        GIMarshallingTests.ghashtable_utf8_full_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'})
-
     def test_ghashtable_utf8_none_out(self):
         self.assertEquals({'-1': '1', '0': '0', '1': '-1', '2': '-2'}, GIMarshallingTests.ghashtable_utf8_none_out())
 
@@ -1075,7 +1048,7 @@ class TestStructure(unittest.TestCase):
         self.assertEquals(None, struct.pointer)
 
     def test_simple_struct_return(self):
-        struct = GIMarshallingTests.simple_struct_return()
+        struct = GIMarshallingTests.SimpleStruct.returnv()
 
         self.assertTrue(isinstance(struct, GIMarshallingTests.SimpleStruct))
         self.assertEquals(6, struct.long_)
@@ -1088,40 +1061,17 @@ class TestStructure(unittest.TestCase):
         struct.long_ = 6
         struct.int8 = 7
 
-        GIMarshallingTests.simple_struct_in(struct)
+        GIMarshallingTests.SimpleStruct.inv(struct)
 
         del struct
 
         struct = GIMarshallingTests.NestedStruct()
 
-        self.assertRaises(TypeError, GIMarshallingTests.simple_struct_in, struct)
-
-        del struct
-
-        self.assertRaises(TypeError, GIMarshallingTests.simple_struct_in, None)
-
-    def test_simple_struct_out(self):
-        struct = GIMarshallingTests.simple_struct_out()
-
-        self.assertTrue(isinstance(struct, GIMarshallingTests.SimpleStruct))
-        self.assertEquals(6, struct.long_)
-        self.assertEquals(7, struct.int8)
+        self.assertRaises(TypeError, GIMarshallingTests.SimpleStruct.inv, struct)
 
         del struct
 
-    def test_simple_struct_inout(self):
-        in_struct = GIMarshallingTests.SimpleStruct()
-        in_struct.long_ = 6
-        in_struct.int8 = 7
-
-        out_struct = GIMarshallingTests.simple_struct_inout(in_struct)
-
-        self.assertTrue(isinstance(out_struct, GIMarshallingTests.SimpleStruct))
-        self.assertEquals(7, out_struct.long_)
-        self.assertEquals(6, out_struct.int8)
-
-        del in_struct
-        del out_struct
+        self.assertRaises(TypeError, GIMarshallingTests.SimpleStruct.inv, None)
 
     def test_simple_struct_method(self):
         struct = GIMarshallingTests.SimpleStruct()
@@ -1144,7 +1094,7 @@ class TestStructure(unittest.TestCase):
         del struct
 
     def test_pointer_struct_return(self):
-        struct = GIMarshallingTests.pointer_struct_return()
+        struct = GIMarshallingTests.PointerStruct.returnv()
 
         self.assertTrue(isinstance(struct, GIMarshallingTests.PointerStruct))
         self.assertEquals(42, struct.long_)
@@ -1155,30 +1105,10 @@ class TestStructure(unittest.TestCase):
         struct = GIMarshallingTests.PointerStruct()
         struct.long_ = 42
 
-        GIMarshallingTests.pointer_struct_in(struct)
+        struct.inv()
 
         del struct
 
-    def test_pointer_struct_out(self):
-        struct = GIMarshallingTests.pointer_struct_out()
-
-        self.assertTrue(isinstance(struct, GIMarshallingTests.PointerStruct))
-        self.assertEquals(42, struct.long_)
-
-        del struct
-
-    def test_pointer_struct_inout(self):
-        in_struct = GIMarshallingTests.PointerStruct()
-        in_struct.long_ = 42
-
-        out_struct = GIMarshallingTests.pointer_struct_inout(in_struct)
-
-        self.assertTrue(isinstance(out_struct, GIMarshallingTests.PointerStruct))
-        self.assertEquals(0, out_struct.long_)
-
-        del in_struct
-        del out_struct
-
     def test_boxed_struct(self):
         self.assertTrue(issubclass(GIMarshallingTests.BoxedStruct, GObject.GBoxed))
 
@@ -1206,7 +1136,7 @@ class TestStructure(unittest.TestCase):
         del struct
 
     def test_boxed_struct_return(self):
-        struct = GIMarshallingTests.boxed_struct_return()
+        struct = GIMarshallingTests.BoxedStruct.returnv()
 
         self.assertTrue(isinstance(struct, GIMarshallingTests.BoxedStruct))
         self.assertEquals(42, struct.long_)
@@ -1218,12 +1148,12 @@ class TestStructure(unittest.TestCase):
         struct = GIMarshallingTests.BoxedStruct()
         struct.long_ = 42
 
-        GIMarshallingTests.boxed_struct_in(struct)
+        struct.inv()
 
         del struct
 
     def test_boxed_struct_out(self):
-        struct = GIMarshallingTests.boxed_struct_out()
+        struct = GIMarshallingTests.BoxedStruct.out()
 
         self.assertTrue(isinstance(struct, GIMarshallingTests.BoxedStruct))
         self.assertEquals(42, struct.long_)
@@ -1234,7 +1164,7 @@ class TestStructure(unittest.TestCase):
         in_struct = GIMarshallingTests.BoxedStruct()
         in_struct.long_ = 42
 
-        out_struct = GIMarshallingTests.boxed_struct_inout(in_struct)
+        out_struct = GIMarshallingTests.BoxedStruct.inout(in_struct)
 
         self.assertTrue(isinstance(out_struct, GIMarshallingTests.BoxedStruct))
         self.assertEquals(0, out_struct.long_)
@@ -1254,7 +1184,7 @@ class TestStructure(unittest.TestCase):
         del new_union
 
     def test_union_return(self):
-        union = GIMarshallingTests.union_return()
+        union = GIMarshallingTests.Union.returnv()
 
         self.assertTrue(isinstance(union, GIMarshallingTests.Union))
         self.assertEquals(42, union.long_)
@@ -1265,30 +1195,10 @@ class TestStructure(unittest.TestCase):
         union = GIMarshallingTests.Union()
         union.long_ = 42
 
-        GIMarshallingTests.union_in(union)
+        union.inv()
 
         del union
 
-    def test_union_out(self):
-        union = GIMarshallingTests.union_out()
-
-        self.assertTrue(isinstance(union, GIMarshallingTests.Union))
-        self.assertEquals(42, union.long_)
-
-        del union
-
-    def test_union_inout(self):
-        in_union = GIMarshallingTests.Union()
-        in_union.long_ = 42
-
-        out_union = GIMarshallingTests.union_inout(in_union)
-
-        self.assertTrue(isinstance(out_union, GIMarshallingTests.Union))
-        self.assertEquals(0, out_union.long_)
-
-        del in_union
-        del out_union
-
     def test_union_method(self):
         union = GIMarshallingTests.Union()
         union.long_ = 42
@@ -1364,49 +1274,44 @@ class TestGObject(unittest.TestCase):
 #        self.assertEquals(object_.int_, 42)
 
     def test_object_none_return(self):
-        object_ = GIMarshallingTests.object_none_return()
+        object_ = GIMarshallingTests.Object.none_return()
         self.assertTrue(isinstance(object_, GIMarshallingTests.Object))
         self.assertEquals(object_.__grefcount__, 2)
 
     def test_object_full_return(self):
-        object_ = GIMarshallingTests.object_full_return()
+        object_ = GIMarshallingTests.Object.full_return()
         self.assertTrue(isinstance(object_, GIMarshallingTests.Object))
         self.assertEquals(object_.__grefcount__, 1)
 
     def test_object_none_in(self):
         object_ = GIMarshallingTests.Object(int = 42)
-        GIMarshallingTests.object_none_in(object_)
+        GIMarshallingTests.Object.none_in(object_)
         self.assertEquals(object_.__grefcount__, 1)
 
         object_ = GIMarshallingTests.SubObject(int = 42)
-        GIMarshallingTests.object_none_in(object_)
+        GIMarshallingTests.Object.none_in(object_)
 
         object_ = GObject.GObject()
-        self.assertRaises(TypeError, GIMarshallingTests.object_none_in, object_)
-
-        self.assertRaises(TypeError, GIMarshallingTests.object_none_in, None)
+        self.assertRaises(TypeError, GIMarshallingTests.Object.none_in, object_)
 
-    def test_object_full_in(self):
-        object_ = GIMarshallingTests.Object(int = 42)
-        GIMarshallingTests.object_full_in(object_)
-        self.assertEquals(object_.__grefcount__, 1)
+        self.assertRaises(TypeError, GIMarshallingTests.Object.none_in, None)
 
     def test_object_none_out(self):
-        object_ = GIMarshallingTests.object_none_out()
+        object_ = GIMarshallingTests.Object.none_out()
         self.assertTrue(isinstance(object_, GIMarshallingTests.Object))
         self.assertEquals(object_.__grefcount__, 2)
 
-        new_object = GIMarshallingTests.object_none_out()
+        new_object = GIMarshallingTests.Object.none_out()
         self.assertTrue(new_object is object_)
 
     def test_object_full_out(self):
-        object_ = GIMarshallingTests.object_full_out()
+        object_ = GIMarshallingTests.Object.full_out()
         self.assertTrue(isinstance(object_, GIMarshallingTests.Object))
         self.assertEquals(object_.__grefcount__, 1)
 
     def test_object_none_inout(self):
         object_ = GIMarshallingTests.Object(int = 42)
-        new_object = GIMarshallingTests.object_none_inout(object_)
+        new_object = GIMarshallingTests.Object.none_inout(object_)
 
         self.assertTrue(isinstance(new_object, GIMarshallingTests.Object))
 
@@ -1415,20 +1320,20 @@ class TestGObject(unittest.TestCase):
         self.assertEquals(object_.__grefcount__, 1)
         self.assertEquals(new_object.__grefcount__, 2)
 
-        new_new_object = GIMarshallingTests.object_none_inout(object_)
+        new_new_object = GIMarshallingTests.Object.none_inout(object_)
         self.assertTrue(new_new_object is new_object)
 
-        GIMarshallingTests.object_none_inout(GIMarshallingTests.SubObject(int = 42))
+        GIMarshallingTests.Object.none_inout(GIMarshallingTests.SubObject(int = 42))
 
     def test_object_full_inout(self):
         object_ = GIMarshallingTests.Object(int = 42)
-        new_object = GIMarshallingTests.object_full_inout(object_)
+        new_object = GIMarshallingTests.Object.full_inout(object_)
 
         self.assertTrue(isinstance(new_object, GIMarshallingTests.Object))
 
         self.assertFalse(object_ is new_object)
 
-        self.assertEquals(object_.__grefcount__, 1)
+        self.assertEquals(object_.__grefcount__, 2)
         self.assertEquals(new_object.__grefcount__, 1)
 
 # FIXME: Doesn't actually return the same object.
@@ -1572,7 +1477,7 @@ class TestOverrides(unittest.TestCase):
         del struct
 
         # Test that the overrides wrapper has been registered.
-        struct = GIMarshallingTests.overrides_struct_return()
+        struct = GIMarshallingTests.OverridesStruct.returnv()
 
         self.assertTrue(isinstance(struct, GIMarshallingTests.OverridesStruct))
 
@@ -1593,7 +1498,7 @@ class TestOverrides(unittest.TestCase):
         self.assertEquals(6, object_.method())
 
         # Test that the overrides wrapper has been registered.
-        object_ = GIMarshallingTests.overrides_object_return()
+        object_ = GIMarshallingTests.OverridesObject.returnv()
 
         self.assertTrue(isinstance(object_, GIMarshallingTests.OverridesObject))
 



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