X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=test%2Frelay.c;h=ecfe4c82586327d160fc3e4d1cbd2d88a78e7f1a;hb=16ed767007722d7450e6f5a4e23fff0166f466dc;hp=f4129d0a826dc0defb07e0fafd45ec276a9c1894;hpb=88498b706a39bbe520f9591d8d52b54fb1f8e378;p=platform%2Fupstream%2Fdbus.git diff --git a/test/relay.c b/test/relay.c index f4129d0..ecfe4c8 100644 --- a/test/relay.c +++ b/test/relay.c @@ -29,7 +29,8 @@ #include #include -#include + +#include "test-utils.h" /* This is basically a miniature dbus-daemon. We relay messages from the client * on the left to the client on the right. @@ -43,6 +44,7 @@ */ typedef struct { + TestMainContext *ctx; DBusError e; DBusServer *server; @@ -113,13 +115,14 @@ new_conn_cb (DBusServer *server, f->right_server_conn = dbus_connection_ref (server_conn); } - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); } static void setup (Fixture *f, gconstpointer data G_GNUC_UNUSED) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->messages); @@ -129,7 +132,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -148,25 +151,25 @@ test_connect (Fixture *f, f->left_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->left_client_conn != NULL); - dbus_connection_setup_with_g_main (f->left_client_conn, NULL); + test_connection_setup (f->ctx, f->left_client_conn); while (f->left_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } f->right_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->right_client_conn != NULL); - dbus_connection_setup_with_g_main (f->right_client_conn, NULL); + test_connection_setup (f->ctx, f->right_client_conn); dbus_free (address); while (f->right_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } have_mem = dbus_connection_add_filter (f->right_client_conn, @@ -208,7 +211,7 @@ test_relay (Fixture *f, while (g_queue_get_length (&f->messages) < 2) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->messages), ==, 2); @@ -237,7 +240,7 @@ test_limit (Fixture *f, /* This was an attempt to reproduce fd.o #34393. It didn't work. */ g_test_bug ("34393"); dbus_connection_set_max_received_size (f->left_server_conn, 1); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); for (i = 0; i < MANY; i++) { @@ -253,7 +256,7 @@ test_limit (Fixture *f, { while (g_queue_is_empty (&f->messages)) { - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } while ((incoming = g_queue_pop_head (&f->messages)) != NULL) @@ -302,6 +305,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int