2011-01-18 14:36:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
static void
|
2013-05-30 01:11:14 +00:00
|
|
|
test_unset_display_subprocess1 (void)
|
2011-01-18 14:36:24 +00:00
|
|
|
{
|
2013-05-30 01:11:14 +00:00
|
|
|
GdkDisplayManager *manager;
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_unsetenv ("DISPLAY");
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_assert (!gdk_init_check (NULL, NULL));
|
|
|
|
manager = gdk_display_manager_get ();
|
|
|
|
g_assert (manager != NULL);
|
|
|
|
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
|
|
|
}
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
static void
|
|
|
|
test_unset_display_subprocess2 (void)
|
|
|
|
{
|
|
|
|
g_unsetenv ("DISPLAY");
|
2015-08-28 16:26:25 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
gdk_init (NULL, NULL);
|
|
|
|
}
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
static void
|
|
|
|
test_unset_display (void)
|
|
|
|
{
|
|
|
|
g_test_trap_subprocess ("/display/unset-display/subprocess/1", 0, 0);
|
|
|
|
g_test_trap_assert_passed ();
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_test_trap_subprocess ("/display/unset-display/subprocess/2", 0, 0);
|
2011-01-18 14:36:24 +00:00
|
|
|
g_test_trap_assert_failed ();
|
|
|
|
g_test_trap_assert_stderr ("*cannot open display*");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-30 01:11:14 +00:00
|
|
|
test_bad_display_subprocess1 (void)
|
2011-01-18 14:36:24 +00:00
|
|
|
{
|
2013-05-30 01:11:14 +00:00
|
|
|
GdkDisplayManager *manager;
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_setenv ("DISPLAY", "poo", TRUE);
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_assert (!gdk_init_check (NULL, NULL));
|
|
|
|
manager = gdk_display_manager_get ();
|
|
|
|
g_assert (manager != NULL);
|
|
|
|
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
|
|
|
}
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
static void
|
|
|
|
test_bad_display_subprocess2 (void)
|
|
|
|
{
|
|
|
|
g_setenv ("DISPLAY", "poo", TRUE);
|
|
|
|
gdk_init (NULL, NULL);
|
|
|
|
}
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
static void
|
|
|
|
test_bad_display (void)
|
|
|
|
{
|
|
|
|
g_test_trap_subprocess ("/display/bad-display/subprocess/1", 0, 0);
|
|
|
|
g_test_trap_assert_passed ();
|
2011-01-18 14:36:24 +00:00
|
|
|
|
2013-05-30 01:11:14 +00:00
|
|
|
g_test_trap_subprocess ("/display/bad-display/subprocess/2", 0, 0);
|
2011-01-18 14:36:24 +00:00
|
|
|
g_test_trap_assert_failed ();
|
|
|
|
g_test_trap_assert_stderr ("*cannot open display*");
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
|
2015-08-28 16:26:25 +00:00
|
|
|
gdk_set_allowed_backends ("x11");
|
|
|
|
|
2011-01-18 14:36:24 +00:00
|
|
|
g_test_add_func ("/display/unset-display", test_unset_display);
|
2013-05-30 01:11:14 +00:00
|
|
|
g_test_add_func ("/display/unset-display/subprocess/1", test_unset_display_subprocess1);
|
|
|
|
g_test_add_func ("/display/unset-display/subprocess/2", test_unset_display_subprocess2);
|
2011-01-18 14:36:24 +00:00
|
|
|
g_test_add_func ("/display/bad-display", test_bad_display);
|
2013-05-30 01:11:14 +00:00
|
|
|
g_test_add_func ("/display/bad-display/subprocess/1", test_bad_display_subprocess1);
|
|
|
|
g_test_add_func ("/display/bad-display/subprocess/2", test_bad_display_subprocess2);
|
2011-01-18 14:36:24 +00:00
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
}
|