diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2019-08-01 13:37:47 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2019-08-01 22:12:52 -0700 |
commit | 99db7d7fb3dbb9f4da416a21282aadf351eb3471 (patch) | |
tree | 9de6f70136b2f8dcb98a97b492a6b9d75b2f342a /tests/scanner/regress.c | |
parent | 3bdb82991f2767a2d43a8ee15251e48e46e82c3c (diff) | |
download | gobject-introspection-99db7d7fb3dbb9f4da416a21282aadf351eb3471.tar.gz |
regress: Add regression test for signal with GError param
This exercises the little-used code path where a signal is emitted with
a nullable GError as a parameter. It's modeled after
GstPbutils.Discoverer's 'discovered' signal.
See GNOME/gjs#262.
Diffstat (limited to 'tests/scanner/regress.c')
-rw-r--r-- | tests/scanner/regress.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index eca7cdd4..bc04079c 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -2300,6 +2300,7 @@ enum { REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET, REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INOUT_INT, + REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_GERROR, N_REGRESS_TEST_OBJ_SIGNALS }; @@ -2571,6 +2572,26 @@ regress_test_obj_class_init (RegressTestObjClass *klass) 1, G_TYPE_POINTER); + /** + * RegressTestObj::sig-with-gerror: + * @self: The object that emitted the signal + * @error: (nullable) (type GLib.Error): A #GError if something went wrong + * internally in @self. You must not free this #GError. + * + * This signal is modeled after #GstDiscoverer::discovered, and is added to + * exercise the path of a #GError being marshalled as a boxed type instead of + * an exception in the introspected language. + * + * Use via regress_test_obj_emit_sig_with_error() and + * regress_test_obj_emit_sig_with_null_error(), or emit via the introspected + * language. + */ + regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_GERROR] = + g_signal_new ("sig-with-gerror", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_generic, G_TYPE_NONE, 1, + G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE); + gobject_class->set_property = regress_test_obj_set_property; gobject_class->get_property = regress_test_obj_get_property; gobject_class->dispose = regress_test_obj_dispose; @@ -2872,6 +2893,29 @@ regress_test_obj_emit_sig_with_inout_int (RegressTestObj *obj) g_assert_cmpint (inout, ==, 43); } +/** + * regress_test_obj_emit_sig_with_error: + * @self: The object to emit the signal. + */ +void +regress_test_obj_emit_sig_with_error (RegressTestObj *self) +{ + GError *err = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, + "Something failed"); + g_signal_emit_by_name (self, "sig-with-gerror", err); + g_error_free (err); +} + +/** + * regress_test_obj_emit_sig_with_null_error: + * @self: The object to emit the signal. + */ +void +regress_test_obj_emit_sig_with_null_error (RegressTestObj *self) +{ + g_signal_emit_by_name (self, "sig-with-gerror", NULL); +} + int regress_test_obj_instance_method (RegressTestObj *obj G_GNUC_UNUSED) { |