diff options
Diffstat (limited to 'gobject/tests/signals.c')
-rw-r--r-- | gobject/tests/signals.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c index ea9a778bf..ef52255cd 100644 --- a/gobject/tests/signals.c +++ b/gobject/tests/signals.c @@ -1109,8 +1109,10 @@ test_destroy_target_object (void) sender = g_object_new (test_get_type (), NULL); target1 = g_object_new (test_get_type (), NULL); target2 = g_object_new (test_get_type (), NULL); - g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler1), target1, 0); - g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler2), target2, 0); + g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler1), + target1, G_CONNECT_DEFAULT); + g_signal_connect_object (sender, "simple", G_CALLBACK (simple_handler2), + target2, G_CONNECT_DEFAULT); g_signal_emit_by_name (sender, "simple"); g_object_unref (sender); } @@ -1485,6 +1487,36 @@ test_block_handler (void) g_signal_handlers_unblock_matched (test2, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, test_handler, NULL); + /* Test match by signal ID. */ + g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_ID, simple_id, 0, NULL, NULL, NULL), ==, 1); + + g_signal_emit_by_name (test1, "simple"); + g_signal_emit_by_name (test2, "simple"); + + g_assert_cmpint (count1, ==, 3); + g_assert_cmpint (count2, ==, 4); + + g_assert_cmpuint (g_signal_handlers_unblock_matched (test1, G_SIGNAL_MATCH_ID, simple_id, 0, NULL, NULL, NULL), ==, 1); + + /* Match types are conjunctive */ + g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, test_handler, "will not match"), ==, 0); + g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, test_handler, &count1), ==, 1); + g_assert_cmpuint (g_signal_handlers_unblock_matched (test1, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, test_handler, &count1), ==, 1); + + /* Test g_signal_handlers_disconnect_matched for G_SIGNAL_MATCH_ID match */ + g_assert_cmpuint (g_signal_handlers_disconnect_matched (test1, + G_SIGNAL_MATCH_ID, + simple_id, 0, + NULL, NULL, NULL), + ==, + 1); + g_assert_cmpuint (g_signal_handler_find (test1, + G_SIGNAL_MATCH_ID, + simple_id, 0, + NULL, NULL, NULL), + ==, + 0); + g_object_unref (test1); g_object_unref (test2); } @@ -1544,13 +1576,13 @@ test_signal_disconnect_wrong_object (void) NULL); /* disconnect from the wrong object (same type), should warn */ - g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, + g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_CRITICAL, "*: instance '*' has no handler with id '*'"); g_signal_handler_disconnect (object2, signal_id); g_test_assert_expected_messages (); /* and from an object of the wrong type */ - g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, + g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_CRITICAL, "*: instance '*' has no handler with id '*'"); g_signal_handler_disconnect (object3, signal_id); g_test_assert_expected_messages (); @@ -1584,7 +1616,7 @@ test_clear_signal_handler (void) if (g_test_undefined ()) { handler = g_random_int_range (0x01, 0xFF); - g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, + g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*instance '* has no handler with id *'"); g_clear_signal_handler (&handler, test_obj); g_assert_cmpuint (handler, ==, 0); @@ -1638,9 +1670,9 @@ test_lookup_invalid (void) return; } - g_test_trap_subprocess (NULL, 0, 0); + g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_DEFAULT); g_test_trap_assert_failed (); - g_test_trap_assert_stderr ("*WARNING*unable to look up invalid signal name*"); + g_test_trap_assert_stderr ("*CRITICAL*unable to look up invalid signal name*"); } static void @@ -1755,7 +1787,7 @@ test_signals_invalid_name (gconstpointer test_data) return; } - g_test_trap_subprocess (NULL, 0, 0); + g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_DEFAULT); g_test_trap_assert_failed (); g_test_trap_assert_stderr ("*CRITICAL*g_signal_is_valid_name (signal_name)*"); } |