[gtk+] Add a test for cursor names
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a test for cursor names
- Date: Mon, 17 Oct 2016 23:11:54 +0000 (UTC)
commit dfb45f4396aec7b42958b4e150b42321ed3a235d
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 17 15:28:29 2016 -0400
Add a test for cursor names
This tests both that all standard cusor yield a cursor, and that
unknown cursor names yield NULL.
testsuite/gdk/Makefile.am | 1 +
testsuite/gdk/cursor.c | 92 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/gdk/Makefile.am b/testsuite/gdk/Makefile.am
index ce67755..98a7688 100644
--- a/testsuite/gdk/Makefile.am
+++ b/testsuite/gdk/Makefile.am
@@ -19,6 +19,7 @@ LDADD = \
TEST_PROGS += \
cairo \
+ cursor \
display \
encoding \
keysyms \
diff --git a/testsuite/gdk/cursor.c b/testsuite/gdk/cursor.c
new file mode 100644
index 0000000..5ae3bc0
--- /dev/null
+++ b/testsuite/gdk/cursor.c
@@ -0,0 +1,92 @@
+#include <gdk/gdk.h>
+
+static char *cursor_names[] = {
+ "none",
+ "default",
+ "help",
+ "pointer",
+ "context-menu",
+ "progress",
+ "wait",
+ "cell",
+ "crosshair",
+ "text",
+ "vertical-text",
+ "alias",
+ "copy",
+ "no-drop",
+ "move",
+ "not-allowed",
+ "grab",
+ "grabbing",
+ "all-scroll",
+ "col-resize",
+ "row-resize",
+ "n-resize",
+ "e-resize",
+ "s-resize",
+ "w-resize",
+ "ne-resize",
+ "nw-resize",
+ "sw-resize",
+ "se-resize",
+ "ew-resize",
+ "ns-resize",
+ "nesw-resize",
+ "nwse-resize",
+ "zoom-in",
+ "zoom-out",
+ "dnd-ask",
+};
+
+static void
+test_cursor_existence (gconstpointer name)
+{
+ GdkDisplay *display;
+ GdkCursor *cursor;
+
+ display = gdk_display_get_default ();
+ cursor = gdk_cursor_new_from_name (display, name);
+ g_assert (cursor != NULL);
+ g_object_unref (cursor);
+}
+
+static void
+test_cursor_nonexistence_subprocess (void)
+{
+ GdkDisplay *display;
+ GdkCursor *cursor;
+
+ display = gdk_display_get_default ();
+ cursor = gdk_cursor_new_from_name (display, "non-existing-cursor");
+ g_assert (cursor == NULL);
+}
+
+static void
+test_cursor_nonexistence (void)
+{
+ g_test_trap_subprocess ("/non-existing-cursors/subprocess/non-existing-cursor", 0, 0);
+ g_test_trap_assert_passed ();
+}
+
+int
+main (int argc, char *argv[])
+{
+ guint i;
+ char *test_name;
+
+ g_test_init (&argc, &argv, NULL);
+ gdk_init (NULL, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (cursor_names); i++)
+ {
+ test_name = g_strdup_printf ("/standard-cursor-names/%s", cursor_names[i]);
+ g_test_add_data_func (test_name, cursor_names[i], test_cursor_existence);
+ g_free (test_name);
+ }
+
+ g_test_add_func ("/non-existing-cursors/subprocess/non-existing-cursor",
test_cursor_nonexistence_subprocess);
+ g_test_add_func ("/non-existing-cursors/non-existing-cursor", test_cursor_nonexistence);
+
+ return g_test_run();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]