gtk object tests: run under local environment

Make sure that the tests don't access the host's session bus or
installed gsettings schemas.

Also disable tests for some classes that leak a connection to the
session bus.

https://bugzilla.gnome.org/show_bug.cgi?id=711715
This commit is contained in:
Lars Uebernickel
2013-11-09 01:15:33 +01:00
parent 9d8a32b07d
commit e5828073c2
5 changed files with 96 additions and 2 deletions

View File

@ -78,11 +78,28 @@ main (int argc, char **argv)
{
const GType *all_types;
guint n_types = 0, i;
gchar *schema_dir;
GTestDBus *bus;
gint result;
/* 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_build_filename must be called after gtk_test_init */
schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
/* Create one test bus for all tests, as we have a lot of very small
* and quick tests.
*/
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
g_test_dbus_up (bus);
all_types = gtk_test_list_all_types (&n_types);
for (i = 0; i < n_types; i++)
@ -110,5 +127,11 @@ main (int argc, char **argv)
}
}
return g_test_run();
result = g_test_run();
g_test_dbus_down (bus);
g_object_unref (bus);
g_free (schema_dir);
return result;
}