diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-09-18 18:18:36 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-09-18 18:18:36 -0400 |
commit | 4f3e5e6ebc837d2f805efc73d79cbd2d0a9df4f7 (patch) | |
tree | 1793150b41347f96f0a2dae710a5540ff3bb45f3 /tests/testerrors.c | |
parent | 8d5b4e9f6ef130e64945606e5e120be803e9fe1b (diff) | |
download | gtk+-4f3e5e6ebc837d2f805efc73d79cbd2d0a9df4f7.tar.gz |
Add some minimal test for X error traps
Diffstat (limited to 'tests/testerrors.c')
-rwxr-xr-x | tests/testerrors.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/testerrors.c b/tests/testerrors.c new file mode 100755 index 0000000000..63b98cc772 --- /dev/null +++ b/tests/testerrors.c @@ -0,0 +1,63 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Red Hat, Inc. + * Author: Matthias Clasen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include <X11/Xlib.h> +#include <gtk/gtk.h> +#include "x11/gdkx.h" + +gint +main (gint argc, gchar *argv[]) +{ + Display *d; + int dummy; + int error; + + gtk_init (&argc, &argv); + + d = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + + /* verify that we can catch errors */ + gdk_error_trap_push (); + XListProperties (d, 0, &dummy); + error = gdk_error_trap_pop (); + g_assert (error == BadWindow); + + gdk_error_trap_push (); + XSetCloseDownMode (d, 12345); + XSetCloseDownMode (d, DestroyAll); + error = gdk_error_trap_pop (); + g_assert (error == BadValue); + + /* try the same without sync */ + gdk_error_trap_push (); + XListProperties (d, 0, &dummy); + gdk_error_trap_pop_ignored (); + + gdk_error_trap_push (); + XSetCloseDownMode (d, 12345); + XSetCloseDownMode (d, DestroyAll); + gdk_error_trap_pop_ignored (); + + XSync (d, TRUE); + + return 0; +} + |