[gtk+] Add some minimal test for X error traps
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add some minimal test for X error traps
- Date: Sat, 18 Sep 2010 22:21:33 +0000 (UTC)
commit 4f3e5e6ebc837d2f805efc73d79cbd2d0a9df4f7
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 18 18:18:36 2010 -0400
Add some minimal test for X error traps
tests/Makefile.am | 8 ++++--
tests/testerrors.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 3 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ccec905..38d3ae4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -94,7 +94,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testwrapbox
if USE_X11
-noinst_PROGRAMS += testapplication
+noinst_PROGRAMS += testapplication testerrors
endif
if HAVE_CXX
@@ -122,7 +122,6 @@ testadjustsize_DEPENDENCIES = $(TEST_DEPS)
testassistant_DEPENDENCIES = $(TEST_DEPS)
testbbox_DEPENDENCIES = $(TEST_DEPS)
testbuttons_DEPENDENCIES = $(TEST_DEPS)
-testframe_DEPENDENCIES = $(TEST_DEPS)
testcairo_DEPENDENCIES = $(TEST_DEPS)
testcalendar_DEPENDENCIES = $(TEST_DEPS)
testcombo_DEPENDENCIES = $(TEST_DEPS)
@@ -133,8 +132,10 @@ testdnd_DEPENDENCIES = $(TEST_DEPS)
testellipsise_DEPENDENCIES = $(TEST_DEPS)
testentrycompletion_DEPENDENCIES = $(TEST_DEPS)
testentryicons_DEPENDENCIES = $(TEST_DEPS)
+testerrors_DEPENDENCIES = $(TEST_DEPS)
testfilechooser_DEPENDENCIES = $(TEST_DEPS)
testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
+testframe_DEPENDENCIES = $(TEST_DEPS)
testgtk_DEPENDENCIES = $(TEST_DEPS)
testinput_DEPENDENCIES = $(TEST_DEPS)
testimage_DEPENDENCIES = $(TEST_DEPS)
@@ -186,7 +187,6 @@ testapplication_LDADD = $(LDADDS)
testassistant_LDADD = $(LDADDS)
testbbox_LDADD = $(LDADDS)
testbuttons_LDADD = $(LDADDS)
-testframe_LDADD = $(LDADDS)
testcairo_LDADD = $(LDADDS)
testcalendar_LDADD = $(LDADDS)
testcombo_LDADD = $(LDADDS)
@@ -197,8 +197,10 @@ testdnd_LDADD = $(LDADDS)
testellipsise_LDADD = $(LDADDS)
testentrycompletion_LDADD = $(LDADDS)
testentryicons_LDADD = $(LDADDS)
+testerrors_LDADD = $(LDADDS)
testfilechooser_LDADD = $(LDADDS)
testfilechooserbutton_LDADD = $(LDADDS)
+testframe_LDADD = $(LDADDS)
testgtk_LDADD = $(LDADDS)
testheightforwidth_LDADD = $(LDADDS)
testicontheme_LDADD = $(LDADDS)
diff --git a/tests/testerrors.c b/tests/testerrors.c
new file mode 100755
index 0000000..63b98cc
--- /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;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]