[glib: 2/3] gobject/tests: Add test to verify that custom dispatch is called on init
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] gobject/tests: Add test to verify that custom dispatch is called on init
- Date: Fri, 8 Jul 2022 23:16:47 +0000 (UTC)
commit 28dc989fc14637ba9c665afe61f450f711f40314
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Jul 8 23:50:48 2022 +0200
gobject/tests: Add test to verify that custom dispatch is called on init
As per this, rename the old test so that it's more in line with the
new one and with what it does.
gobject/tests/custom-dispatch.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/gobject/tests/custom-dispatch.c b/gobject/tests/custom-dispatch.c
index ae56c0ae5b..64120d2699 100644
--- a/gobject/tests/custom-dispatch.c
+++ b/gobject/tests/custom-dispatch.c
@@ -139,6 +139,26 @@ object_has_notify_signal_handlers (gpointer instance)
return g_signal_handler_find (instance, G_SIGNAL_MATCH_ID, signal_id, 0, NULL, NULL, NULL) != 0;
}
+static void
+test_custom_dispatch_init (void)
+{
+ TestObject *obj;
+
+ g_test_summary ("Test that custom dispatch_properties_changed is called "
+ "on initialization");
+
+ dispatch_properties_called = 0;
+ obj = g_object_new (test_object_get_type (), "foo", 5, NULL);
+
+ g_assert_false (object_has_notify_signal_handlers (obj));
+
+ g_assert_cmpint (dispatch_properties_called, ==, 1);
+ g_object_set (obj, "foo", 11, NULL);
+ g_assert_cmpint (dispatch_properties_called, ==, 2);
+
+ g_object_unref (obj);
+}
+
/* This instance init behavior is the thing we are testing:
*
* 1. Don't connect any notify handlers
@@ -146,12 +166,13 @@ object_has_notify_signal_handlers (gpointer instance)
* 3. Verify that our custom dispatch_properties_changed is called
*/
static void
-test_custom_dispatch (void)
+test_custom_dispatch_set (void)
{
TestObject *obj;
g_test_summary ("Test that custom dispatch_properties_changed is called regardless of connected notify
handlers");
+ dispatch_properties_called = 0;
obj = g_object_new (test_object_get_type (), NULL);
g_assert_false (object_has_notify_signal_handlers (obj));
@@ -170,7 +191,8 @@ main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/properties/custom-dispatch", test_custom_dispatch);
+ g_test_add_func ("/properties/custom-dispatch/init", test_custom_dispatch_init);
+ g_test_add_func ("/properties/custom-dispatch/set", test_custom_dispatch_set);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]