forked from AuroraMiddleware/gtk
tests: Initialize dbus before gtk
These days initilizing gtk may create a connection to the sesson bus, so we have to initialize GTestDBus before initalizing gtk, or we'll use the address of the "real" session bus (and remember that in the global). To further muck things up, g_test_dbus_up() resets important env vars like DISPLAY and XDG_RUNTIME_DIR, which we have to re-set.
This commit is contained in:
parent
85e59220a5
commit
008eb04125
@ -423,14 +423,16 @@ main (int argc, char **argv)
|
||||
GTestDBus *bus;
|
||||
GMainLoop *loop;
|
||||
gint result;
|
||||
const char *display, *x_r_d;
|
||||
|
||||
/* These must be set before before gtk_test_init */
|
||||
g_setenv ("GIO_USE_VFS", "local", TRUE);
|
||||
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
||||
g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE);
|
||||
|
||||
gtk_test_init (&argc, &argv);
|
||||
gtk_test_register_all_types();
|
||||
/* g_test_dbus_up() helpfully clears these, so we have to re-set it */
|
||||
display = g_getenv ("DISPLAY");
|
||||
x_r_d = g_getenv ("XDG_RUNTIME_DIR");
|
||||
|
||||
/* Create one test bus for all tests, as we have a lot of very small
|
||||
* and quick tests.
|
||||
@ -438,6 +440,14 @@ main (int argc, char **argv)
|
||||
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
|
||||
g_test_dbus_up (bus);
|
||||
|
||||
if (display)
|
||||
g_setenv ("DISPLAY", display, TRUE);
|
||||
if (x_r_d)
|
||||
g_setenv ("XDG_RUNTIME_DIR", x_r_d, TRUE);
|
||||
|
||||
gtk_test_init (&argc, &argv);
|
||||
gtk_test_register_all_types();
|
||||
|
||||
otypes = gtk_test_list_all_types (NULL);
|
||||
for (i = 0; otypes[i]; i++)
|
||||
{
|
||||
|
@ -108,14 +108,15 @@ main (int argc, char **argv)
|
||||
guint n_types = 0, i;
|
||||
GTestDBus *bus;
|
||||
gint result;
|
||||
const char *display, *x_r_d;
|
||||
|
||||
/* These must be set before before gtk_test_init */
|
||||
g_setenv ("GIO_USE_VFS", "local", TRUE);
|
||||
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
||||
|
||||
/* initialize test program */
|
||||
gtk_test_init (&argc, &argv);
|
||||
gtk_test_register_all_types ();
|
||||
/* g_test_dbus_up() helpfully clears these, so we have to re-set it */
|
||||
display = g_getenv ("DISPLAY");
|
||||
x_r_d = g_getenv ("XDG_RUNTIME_DIR");
|
||||
|
||||
/* Create one test bus for all tests, as we have a lot of very small
|
||||
* and quick tests.
|
||||
@ -123,6 +124,16 @@ main (int argc, char **argv)
|
||||
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
|
||||
g_test_dbus_up (bus);
|
||||
|
||||
if (display)
|
||||
g_setenv ("DISPLAY", display, TRUE);
|
||||
if (x_r_d)
|
||||
g_setenv ("XDG_RUNTIME_DIR", x_r_d, TRUE);
|
||||
|
||||
/* initialize test program */
|
||||
gtk_test_init (&argc, &argv);
|
||||
gtk_test_register_all_types ();
|
||||
|
||||
|
||||
all_types = gtk_test_list_all_types (&n_types);
|
||||
|
||||
for (i = 0; i < n_types; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user