summaryrefslogtreecommitdiff
path: root/testsuite/gdk/keysyms.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-05-14 16:13:16 +0200
committerBenjamin Otte <otte@redhat.com>2013-05-15 15:37:16 +0200
commit6ea4c144ddfdf1208b44845dee1a40c2eec91e65 (patch)
tree118f9802953b86bf99a83e086688cc253ca56d65 /testsuite/gdk/keysyms.c
parentac8f7f0703a9f43dfeeba8606ff76f12b7cf8e28 (diff)
downloadgtk+-6ea4c144ddfdf1208b44845dee1a40c2eec91e65.tar.gz
build: Move gdk/tests/ to testsuite/gdk/
This is a reorganization of the testsuite to be in the testsuite/ directory, so it can be installed from there.
Diffstat (limited to 'testsuite/gdk/keysyms.c')
-rw-r--r--testsuite/gdk/keysyms.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/gdk/keysyms.c b/testsuite/gdk/keysyms.c
new file mode 100644
index 0000000000..7d786f557c
--- /dev/null
+++ b/testsuite/gdk/keysyms.c
@@ -0,0 +1,69 @@
+#include <locale.h>
+#include <gdk/gdk.h>
+
+static void
+test_keysyms_basic (void)
+{
+ struct {
+ guint keyval;
+ const gchar *name;
+ const gchar *other_name;
+ } tests[] = {
+ { GDK_KEY_space, "space", NULL },
+ { GDK_KEY_a, "a", NULL },
+ { GDK_KEY_Thorn, "Thorn", "THORN" },
+ { GDK_KEY_Hangul_J_RieulTieut, "Hangul_J_RieulTieut", NULL },
+ { GDK_KEY_Page_Up, "Page_Up", NULL },
+ { GDK_KEY_KP_Multiply, "KP_Multiply", NULL },
+ { GDK_KEY_MonBrightnessUp, "MonBrightnessUp", NULL },
+ { 0, NULL }
+ };
+ gint i;
+
+ for (i = 0; tests[i].keyval != 0; i++)
+ {
+ g_assert_cmpstr (gdk_keyval_name (tests[i].keyval), ==, tests[i].name);
+ g_assert_cmpuint (gdk_keyval_from_name (tests[i].name), ==, tests[i].keyval);
+ if (tests[i].other_name)
+ g_assert_cmpuint (gdk_keyval_from_name (tests[i].other_name), ==, tests[i].keyval);
+ }
+}
+
+static void
+test_keysyms_void (void)
+{
+ g_assert_cmpuint (gdk_keyval_from_name ("NoSuchKeysym"), ==, GDK_KEY_VoidSymbol);
+ g_assert_cmpstr (gdk_keyval_name (GDK_KEY_VoidSymbol), ==, "0xffffff");
+}
+
+static void
+test_keysyms_xf86 (void)
+{
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86MonBrightnessUp"), ==, GDK_KEY_MonBrightnessUp);
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86MonBrightnessDown"), ==, GDK_KEY_MonBrightnessDown);
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86KbdBrightnessUp"), ==, GDK_KEY_KbdBrightnessUp);
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86KbdBrightnessDown"), ==, GDK_KEY_KbdBrightnessDown);
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86Battery"), ==, GDK_KEY_Battery);
+ g_assert_cmpuint (gdk_keyval_from_name ("XF86Display"), ==, GDK_KEY_Display);
+
+ g_assert_cmpuint (gdk_keyval_from_name ("MonBrightnessUp"), ==, GDK_KEY_MonBrightnessUp);
+ g_assert_cmpuint (gdk_keyval_from_name ("MonBrightnessDown"), ==, GDK_KEY_MonBrightnessDown);
+ g_assert_cmpuint (gdk_keyval_from_name ("KbdBrightnessUp"), ==, GDK_KEY_KbdBrightnessUp);
+ g_assert_cmpuint (gdk_keyval_from_name ("KbdBrightnessDown"), ==, GDK_KEY_KbdBrightnessDown);
+ g_assert_cmpuint (gdk_keyval_from_name ("Battery"), ==, GDK_KEY_Battery);
+ g_assert_cmpuint (gdk_keyval_from_name ("Display"), ==, GDK_KEY_Display);
+}
+
+int main (int argc, char *argv[])
+{
+ setlocale (LC_ALL, "");
+
+ g_test_init (&argc, &argv, NULL);
+ gdk_init (&argc, &argv);
+
+ g_test_add_func ("/keysyms/basic", test_keysyms_basic);
+ g_test_add_func ("/keysyms/void", test_keysyms_void);
+ g_test_add_func ("/keysyms/xf86", test_keysyms_xf86);
+
+ return g_test_run ();
+}