~tatokis/unity/gcc-72-errors

« back to all changes in this revision

Viewing changes to tests/TestKeyboardUtil.cpp

  • Committer: Jason Smith
  • Date: 2011-08-27 06:44:37 UTC
  • mfrom: (1402.3.4 unity.keyboard-util)
  • Revision ID: jason.smith@canonical.com-20110827064437-td3j9s526j5088cw
merge keyboard utils branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * version 3 along with this program.  If not, see
 
15
 * <http://www.gnu.org/licenses/>
 
16
 *
 
17
 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
 
18
 *
 
19
 */
 
20
 
 
21
#include <gtk/gtk.h>
 
22
#include <gdk/gdk.h>
 
23
#include <gdk/gdkx.h>
 
24
#include <dbus/dbus-glib.h>
 
25
 
 
26
#include <X11/Xlib.h>
 
27
 
 
28
#include "KeyboardUtil.h"
 
29
 
 
30
using namespace unity::ui;
 
31
 
 
32
void testKey (KeyboardUtil & key_util, Display *x_display, const char *key)
 
33
{
 
34
  guint above_keycode = key_util.GetKeycodeAboveKeySymbol (XStringToKeysym(key));
 
35
 
 
36
  KeySym above_keysym = XKeycodeToKeysym (x_display, above_keycode, 0);
 
37
  if (above_keysym != NoSymbol)
 
38
    printf ("Key above %s is %s\n", key, XKeysymToString(above_keysym));
 
39
  else
 
40
    printf ("Could not find key above %s!\n", key);
 
41
}
 
42
 
 
43
int main(int argc, char** argv)
 
44
{
 
45
  Display* x_display = XOpenDisplay (NULL);
 
46
 
 
47
  KeyboardUtil key_util (x_display);
 
48
  testKey (key_util, x_display, "Tab");
 
49
  testKey (key_util, x_display, "Shift_R");
 
50
  testKey (key_util, x_display, "Control_L");
 
51
  testKey (key_util, x_display, "space");
 
52
  testKey (key_util, x_display, "comma");
 
53
  testKey (key_util, x_display, "a");
 
54
  testKey (key_util, x_display, "b");
 
55
  testKey (key_util, x_display, "c");
 
56
  testKey (key_util, x_display, "d");
 
57
  testKey (key_util, x_display, "e");
 
58
  testKey (key_util, x_display, "f");
 
59
  testKey (key_util, x_display, "g");
 
60
  testKey (key_util, x_display, "h");
 
61
  testKey (key_util, x_display, "i");
 
62
  testKey (key_util, x_display, "j");
 
63
  testKey (key_util, x_display, "k");
 
64
  testKey (key_util, x_display, "l");
 
65
  testKey (key_util, x_display, "m");
 
66
  testKey (key_util, x_display, "n");
 
67
  testKey (key_util, x_display, "o");
 
68
  testKey (key_util, x_display, "p");
 
69
  testKey (key_util, x_display, "k");
 
70
  testKey (key_util, x_display, "r");
 
71
  testKey (key_util, x_display, "s");
 
72
  testKey (key_util, x_display, "t");
 
73
  testKey (key_util, x_display, "u");
 
74
  testKey (key_util, x_display, "v");
 
75
  testKey (key_util, x_display, "w");
 
76
  testKey (key_util, x_display, "x");
 
77
  testKey (key_util, x_display, "y");
 
78
  testKey (key_util, x_display, "z");
 
79
 
 
80
  return 0;
 
81
}
 
 
b'\\ No newline at end of file'