mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Add GTestDBus object
This is a helper to write unit tests using a private dbus-daemon. session_bus_up/down() are now just wrappers around a GTestDBus singleton. https://bugzilla.gnome.org/show_bug.cgi?id=672985
This commit is contained in:
committed by
David Zeuthen
parent
f8a8e90398
commit
1b5f70b5b0
@@ -462,7 +462,7 @@ test_bus_own_name (void)
|
||||
*
|
||||
*/
|
||||
data.expect_null_connection = TRUE;
|
||||
session_bus_down ();
|
||||
session_bus_stop ();
|
||||
while (data.num_lost != 2)
|
||||
g_main_loop_run (loop);
|
||||
g_assert_cmpint (data.num_acquired, ==, 2);
|
||||
@@ -473,6 +473,8 @@ test_bus_own_name (void)
|
||||
_g_object_wait_for_single_ref (c);
|
||||
g_object_unref (c);
|
||||
g_object_unref (c2);
|
||||
|
||||
session_bus_down ();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@@ -696,7 +698,7 @@ test_bus_watch_name (void)
|
||||
* Nuke the bus and check that the name vanishes and is lost.
|
||||
*/
|
||||
data.expect_null_connection = TRUE;
|
||||
session_bus_down ();
|
||||
session_bus_stop ();
|
||||
g_main_loop_run (loop);
|
||||
g_assert_cmpint (data.num_lost, ==, 1);
|
||||
g_assert_cmpint (data.num_vanished, ==, 2);
|
||||
@@ -707,6 +709,7 @@ test_bus_watch_name (void)
|
||||
g_bus_unown_name (owner_id);
|
||||
g_assert_cmpint (data.num_free_func, ==, 2);
|
||||
|
||||
session_bus_down ();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@@ -772,11 +775,7 @@ main (int argc,
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
/* all the tests use a session bus with a well-known address that we can bring up and down
|
||||
* using session_bus_up() and session_bus_down().
|
||||
*/
|
||||
g_unsetenv ("DISPLAY");
|
||||
g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE);
|
||||
g_test_dbus_unset ();
|
||||
|
||||
g_test_add_func ("/gdbus/validate-names", test_validate_names);
|
||||
g_test_add_func ("/gdbus/bus-own-name", test_bus_own_name);
|
||||
|
Reference in New Issue
Block a user