2011-01-18 14:36:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
#include <gtk/gtk.h>
|
2011-01-18 14:36:24 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2021-04-12 12:16:45 +00:00
|
|
|
g_assert_false (gtk_init_check ());
|
2013-05-30 01:11:14 +00:00
|
|
|
manager = gdk_display_manager_get ();
|
2021-04-12 12:16:45 +00:00
|
|
|
g_assert_nonnull (manager);
|
|
|
|
g_assert_null (gdk_display_manager_get_default_display (manager));
|
2013-05-30 01:11:14 +00:00
|
|
|
}
|
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
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2013-05-30 01:11:14 +00:00
|
|
|
}
|
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
|
|
|
|
2021-04-12 12:16:45 +00:00
|
|
|
g_assert_false (gtk_init_check ());
|
2013-05-30 01:11:14 +00:00
|
|
|
manager = gdk_display_manager_get ();
|
2021-04-12 12:16:45 +00:00
|
|
|
g_assert_nonnull (manager);
|
|
|
|
g_assert_null (gdk_display_manager_get_default_display (manager));
|
2013-05-30 01:11:14 +00:00
|
|
|
}
|
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);
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2013-05-30 01:11:14 +00:00
|
|
|
}
|
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[])
|
|
|
|
{
|
2021-04-13 01:22:04 +00:00
|
|
|
(g_test_init) (&argc, &argv, NULL);
|
2011-01-18 14:36:24 +00:00
|
|
|
|
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 ();
|
|
|
|
}
|