[glib/wip/otte/interface-types: 37/37] Add a test for signals returning interface types
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/otte/interface-types: 37/37] Add a test for signals returning interface types
- Date: Mon, 2 Nov 2020 17:36:27 +0000 (UTC)
commit 0b1f9096914ece19aa3290669ca174b37b4e58ce
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 28 12:37:37 2020 -0400
Add a test for signals returning interface types
Add a test for a signal returning interface types, using
the generic marshaller. This will hopefully exercise newly
added code in value_from_ffi_type().
gobject/tests/signals.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
---
diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c
index 08b54d0fa..120f90b5c 100644
--- a/gobject/tests/signals.c
+++ b/gobject/tests/signals.c
@@ -135,6 +135,47 @@ static GType flags_type;
static guint simple_id;
static guint simple2_id;
+typedef struct {
+ GTypeInterface g_iface;
+} FooInterface;
+
+GType foo_get_type (void);
+
+G_DEFINE_INTERFACE (Foo, foo, G_TYPE_OBJECT)
+
+static void
+foo_default_init (FooInterface *iface)
+{
+}
+
+typedef struct {
+ GObject parent;
+} Baa;
+
+typedef struct {
+ GObjectClass parent_class;
+} BaaClass;
+
+static void
+baa_init_foo (FooInterface *iface)
+{
+}
+
+GType baa_get_type (void);
+
+G_DEFINE_TYPE_WITH_CODE (Baa, baa, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (foo_get_type (), baa_init_foo))
+
+static void
+baa_init (Baa *baa)
+{
+}
+
+static void
+baa_class_init (BaaClass *class)
+{
+}
+
typedef struct _Test Test;
typedef struct _TestClass TestClass;
@@ -257,6 +298,14 @@ test_class_init (TestClass *klass)
NULL,
G_TYPE_UINT,
0);
+ g_signal_new ("generic-marshaller-interface-return",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ foo_get_type (),
+ 0);
s = g_signal_new ("va-marshaller-uint-return",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -754,6 +803,35 @@ test_generic_marshaller_signal_uint_return (void)
g_object_unref (test);
}
+static gpointer
+on_generic_marshaller_interface_return (Test *test)
+{
+ return g_object_new (baa_get_type (), NULL);
+}
+
+static void
+test_generic_marshaller_signal_interface_return (void)
+{
+ Test *test;
+ guint id;
+ gpointer retval;
+
+ test = g_object_new (test_get_type (), NULL);
+
+ /* Test return value -30 */
+ id = g_signal_connect (test,
+ "generic-marshaller-interface-return",
+ G_CALLBACK (on_generic_marshaller_interface_return),
+ NULL);
+ g_signal_emit_by_name (test, "generic-marshaller-interface-return", &retval);
+ g_assert_true (g_type_check_instance_is_a ((GTypeInstance*)retval, foo_get_type ()));
+ g_object_unref (retval);
+
+ g_signal_handler_disconnect (test, id);
+
+ g_object_unref (test);
+}
+
static const GSignalInvocationHint dont_use_this = { 0, };
static void
@@ -1082,6 +1160,7 @@ test_introspection (void)
"generic-marshaller-int-return",
"va-marshaller-int-return",
"generic-marshaller-uint-return",
+ "generic-marshaller-interface-return",
"va-marshaller-uint-return",
"variant-changed-no-slot",
"variant-changed",
@@ -1495,6 +1574,7 @@ main (int argc,
g_test_add_func ("/gobject/signals/generic-marshaller-enum-return-unsigned",
test_generic_marshaller_signal_enum_return_unsigned);
g_test_add_func ("/gobject/signals/generic-marshaller-int-return",
test_generic_marshaller_signal_int_return);
g_test_add_func ("/gobject/signals/generic-marshaller-uint-return",
test_generic_marshaller_signal_uint_return);
+ g_test_add_func ("/gobject/signals/generic-marshaller-interface-return",
test_generic_marshaller_signal_interface_return);
g_test_add_func ("/gobject/signals/custom-marshaller", test_custom_marshaller);
g_test_add_func ("/gobject/signals/connect", test_connect);
g_test_add_func ("/gobject/signals/emission-hook", test_emission_hook);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]