~sil2100/unity/precise-geis-rename

« back to all changes in this revision

Viewing changes to tests/test_keyboard_util.cpp

  • Committer: Sebastien Bacher
  • Date: 2012-07-20 17:36:06 UTC
  • mfrom: (702.1.1 precise)
  • Revision ID: seb128@ubuntu.com-20120720173606-e0oidd8chhfm427s
* New upstream release.
  - Unity launcher shows internal partitions after they have been unmounted 
    (LP: #994163)
  - can't click to dismiss hud in the area where dynamic hud results are 
    meant to appear (LP: #962651)
  - Spread/Scale should exit if Dash is invoked (LP: #944033)
  - Searching in the HUD freezes unity (LP: #1016239)
  - Dash - The search bar gets the focus when pressing invalid keys 
    (LP: #931393)
  - unity crashed with NameError in reset_unity_compiz_profile(): global name 
    'GError' is not defined (LP: #778470)
  - When number of workspaces is set to 1, the Spread no longer works 
    (LP: #996604)
  - compiz crashed with SIGSEGV in CompWindow::id() from getPaintMask() 
    from unity::UnityWindow::glPaint() (LP: #851982)
  - "Keyboard Shortcuts" overlay can cause annoyance (LP: #934062)
  - padding between last quicklist item and bottom edge is non-deterministic 
    (changes randomly) (LP: #955158)
  - HUD Draws improperly while searching for results (LP: #932531)
  - compiz crashed with SIGSEGV in 
    unity::ui::KeyboardUtil::GetKeycodeAboveKeySymbol() (LP: #920258)
  - Launcher - when a user starts dragging a item, any folded launcher icons 
    that are valid drop receptacles should unfold (LP: #839717)
  - Dragging image from firefox/chrome to dock causes lagg/freeze 
    (LP: #772445)
  - dash should open when pressing "super" in scale mode (LP: #1023811)
  - Multimonitor, Launcher - When the Launcher is set to autohide and 
    'Sticky edges' are turned off, 'Launcher Edge Stop Overcome Pressure' 
    seems to be broken when revealing the Launcher (LP: #987955)
  - Software Center add to launcher icon animation is delayed when the 
    launcher is in auto-hide mode (LP: #1012896)
  - Purchased items are not being added to the Unity launcher (LP: #925014)
  - Unity Launcher Fails To Auto-Hide When Enabled & Installing Commercial 
    Software (LP: #1002440)
  - Regression: shift+click on a launcher icon to open a new application 
    instance gone (LP: #754565)
  - Regression: Installing apps causes a terrible visual glitch-- have to 
    restart X.org. (LP: #981168)
  - Duplicated applications icons on quick application restart (LP: #1003574)
  - HUD - Formatting of text in the auto-complete is wrong (LP: #939436)
  - alt-backtick flickers between windows (LP: #987156)
  - [Hud] The result grid is not drawn in proximity of the search entry 
    (LP: #1008603)
  - Dash and Launcher - As soon as a user starts dragging a file from the 
    Dash, there is a 'flicker' before the Launcher icons that are valid drop 
    receptacles re-saturate (LP: #863230)
  - [hud] The last button is not rounded (LP: #1008656)
  - Hud flickers when show up (LP: #1011507)
  - Dash maximise button changed location (LP: #987674)
  - launcher reordering "line" doesn't go to the bottom slot (LP: #971421)
  - Dash/HUD should close on "Spread" (LP: #870284)
  - Nothing should be written into the dash/hud searchbar when holding super,
    ctrl or Alt (LP: #1013751)
  - Dash - when a file is dragged from the Dash (Dash home, file lens, or 
    music lens) and dropped on a Launcher icon, the Dash should automatically
    close (LP: #865168)
  - Wrong keyboard focus after opening workspace switcher via keyboard 
    navigation (LP: #962408)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
/*
 
3
 * Copyright (C) 2012 Canonical Ltd
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License version 3 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * This program 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
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
 
18
 */
 
19
 
 
20
#include <gtest/gtest.h>
 
21
#include <algorithm>
 
22
 
 
23
#include "KeyboardUtil.h"
 
24
 
 
25
using namespace unity::ui;
 
26
 
 
27
namespace
 
28
{
 
29
 
 
30
void test_key(KeyboardUtil const& key_util, Display* x_display, const char* key)
 
31
{
 
32
  unsigned int above_keycode = key_util.GetKeycodeAboveKeySymbol(XStringToKeysym(key));
 
33
  KeySym above_keysym = XkbKeycodeToKeysym(x_display, above_keycode, 0, 1);
 
34
  EXPECT_NE(above_keysym, NoSymbol);
 
35
}
 
36
 
 
37
TEST(TestKeyboardUtil, AboveKeySymbol)
 
38
{
 
39
  Display* x_display = XOpenDisplay(NULL);
 
40
 
 
41
  KeyboardUtil key_util(x_display);
 
42
  test_key(key_util, x_display, "Tab");
 
43
  test_key(key_util, x_display, "Shift_R");
 
44
  test_key(key_util, x_display, "Control_L");
 
45
  test_key(key_util, x_display, "space");
 
46
  test_key(key_util, x_display, "comma");
 
47
  test_key(key_util, x_display, "a");
 
48
  test_key(key_util, x_display, "b");
 
49
  test_key(key_util, x_display, "c");
 
50
  test_key(key_util, x_display, "d");
 
51
  test_key(key_util, x_display, "e");
 
52
  test_key(key_util, x_display, "f");
 
53
  test_key(key_util, x_display, "g");
 
54
  test_key(key_util, x_display, "h");
 
55
  test_key(key_util, x_display, "i");
 
56
  test_key(key_util, x_display, "j");
 
57
  test_key(key_util, x_display, "k");
 
58
  test_key(key_util, x_display, "l");
 
59
  test_key(key_util, x_display, "m");
 
60
  test_key(key_util, x_display, "n");
 
61
  test_key(key_util, x_display, "o");
 
62
  test_key(key_util, x_display, "p");
 
63
  test_key(key_util, x_display, "k");
 
64
  test_key(key_util, x_display, "r");
 
65
  test_key(key_util, x_display, "s");
 
66
  test_key(key_util, x_display, "t");
 
67
  test_key(key_util, x_display, "u");
 
68
  test_key(key_util, x_display, "v");
 
69
  test_key(key_util, x_display, "w");
 
70
  test_key(key_util, x_display, "x");
 
71
  test_key(key_util, x_display, "y");
 
72
  test_key(key_util, x_display, "z");
 
73
}
 
74
 
 
75
TEST(TestKeyboardUtil, PrintableKeySymbols)
 
76
{
 
77
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_Delete));
 
78
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_BackSpace));
 
79
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_space));
 
80
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_3));
 
81
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_v));
 
82
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_1));
 
83
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_ntilde));
 
84
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_0));
 
85
  EXPECT_TRUE(KeyboardUtil::IsPrintableKeySymbol(XK_exclam));
 
86
 
 
87
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_F1));
 
88
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Select));
 
89
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Hyper_R));
 
90
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Control_L));
 
91
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Shift_L));
 
92
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Super_L));
 
93
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Print));
 
94
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Insert));
 
95
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Num_Lock));
 
96
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_Caps_Lock));
 
97
  EXPECT_FALSE(KeyboardUtil::IsPrintableKeySymbol(XK_ISO_Level3_Shift));
 
98
}
 
99
 
 
100
TEST(TestKeyboardUtil, MoveKeySymbols)
 
101
{
 
102
  std::vector<KeySym> move_symbols { XK_Home, XK_Left, XK_Up, XK_Right, XK_Down,
 
103
                                     XK_Prior, XK_Page_Up, XK_Next, XK_Page_Down,
 
104
                                     XK_End, XK_Begin };
 
105
 
 
106
  for (KeySym sym = 0; sym < XK_VoidSymbol; ++sym)
 
107
  {
 
108
    if (std::find(move_symbols.begin(), move_symbols.end(), sym) != move_symbols.end())
 
109
      EXPECT_TRUE(KeyboardUtil::IsMoveKeySymbol(sym));
 
110
    else
 
111
      EXPECT_FALSE(KeyboardUtil::IsMoveKeySymbol(sym));
 
112
  }
 
113
}
 
114
 
 
115
} // Namespace