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, see <http://www.gnu.org/licenses/>.
21 test_one_accel (const char *accel,
22 const char *exp_label,
31 gtk_accelerator_parse_with_keycode (accel,
39 GdkModifierType mods_2;
41 gtk_accelerator_parse (accel,
44 g_assert (accel_key == accel_key_2);
45 g_assert (mods == mods_2);
49 g_assert (accel_key != 0);
51 g_assert (keycodes[0] != 0);
53 label = gtk_accelerator_get_label_with_keycode (NULL,
58 g_assert_cmpstr (label, ==, exp_label);
60 name = gtk_accelerator_name_with_keycode (NULL,
64 g_assert_cmpstr (name, ==, accel);
74 test_one_accel ("0xb3", "0xb3", FALSE);
80 test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z", TRUE);
86 test_one_accel ("KP_7", "7", TRUE);
92 test_one_accel ("<Primary>KP_7", "Ctrl+7", TRUE);
98 test_one_accel ("<Shift>exclam", "Shift+!", TRUE);
104 g_assert (gdk_keyval_from_name ("KP_7") == GDK_KEY_KP_7);
111 setlocale (LC_ALL, "en_GB.UTF-8");
113 gtk_test_init (&argc, &argv);
115 g_test_add_func ("/keysyms", keysyms);
117 g_test_add_func ("/accel1", accel1);
118 g_test_add_func ("/accel2", accel2);
119 g_test_add_func ("/accel3", accel3);
120 g_test_add_func ("/accel4", accel4);
121 g_test_add_func ("/accel5", accel5);