1 /* accel.c - test accel parsing
2 * Copyright (C) 2011 Bastien Nocera <hadess@hadess.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 test_one_accel (const char *accel,
24 const char *exp_label,
33 gtk_accelerator_parse_with_keycode (accel,
41 GdkModifierType mods_2;
43 gtk_accelerator_parse (accel,
46 g_assert (accel_key == accel_key_2);
47 g_assert (mods == mods_2);
51 g_assert (accel_key != 0);
53 g_assert (keycodes[0] != 0);
55 label = gtk_accelerator_get_label_with_keycode (NULL,
60 g_assert_cmpstr (label, ==, exp_label);
62 name = gtk_accelerator_name_with_keycode (NULL,
66 g_assert_cmpstr (name, ==, accel);
76 test_one_accel ("0xb3", "0xb3", FALSE);
82 test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z", TRUE);
88 test_one_accel ("KP_7", "7", TRUE);
94 test_one_accel ("<Primary>KP_7", "Ctrl+7", TRUE);
100 test_one_accel ("<Shift>exclam", "Shift+!", TRUE);
106 g_assert (gdk_keyval_from_name ("KP_7") == GDK_KEY_KP_7);
113 setlocale (LC_ALL, "en_GB.UTF-8");
115 gtk_test_init (&argc, &argv);
117 g_test_add_func ("/keysyms", keysyms);
119 g_test_add_func ("/accel1", accel1);
120 g_test_add_func ("/accel2", accel2);
121 g_test_add_func ("/accel3", accel3);
122 g_test_add_func ("/accel4", accel4);
123 g_test_add_func ("/accel5", accel5);