OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/test/events_test_utils_x11.h" | 5 #include "ui/events/test/events_test_utils_x11.h" |
6 | 6 |
7 #include <X11/extensions/XI2.h> | 7 #include <X11/extensions/XI2.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/X.h> | 9 #include <X11/X.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 default: | 56 default: |
57 NOTREACHED(); | 57 NOTREACHED(); |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 // Converts KeyboardCode to XKeyEvent keycode. | 62 // Converts KeyboardCode to XKeyEvent keycode. |
63 unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code, | 63 unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code, |
64 int flags, | 64 int flags, |
65 XDisplay* display) { | 65 XDisplay* display) { |
66 const int keysym = XKeysymForWindowsKeyCode(key_code, | 66 // XKeyEvent keycode is hardware keycode which doesn't consider SHIFT state. |
67 flags & ui::EF_SHIFT_DOWN); | 67 // There are bugs in XKeysymToKeycode that it returns wrong keycode for keysym |
68 // Tests assume the keycode for XK_less is equal to the one of XK_comma, | 68 // with SHIFT state. e.g. XK_less should return 59 but returns 94; |
69 // but XKeysymToKeycode returns 94 for XK_less while it returns 59 for | 69 // XK_parenright should return 19 but returns 188; etc. |
70 // XK_comma. Here we convert the value for XK_less to the value for XK_comma. | 70 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); |
71 return (keysym == XK_less) ? 59 : XKeysymToKeycode(display, keysym); | |
72 } | 71 } |
73 | 72 |
74 // Converts Aura event type and flag to X button event. | 73 // Converts Aura event type and flag to X button event. |
75 unsigned int XButtonEventButton(ui::EventType type, | 74 unsigned int XButtonEventButton(ui::EventType type, |
76 int flags) { | 75 int flags) { |
77 // Aura events don't keep track of mouse wheel button, so just return | 76 // Aura events don't keep track of mouse wheel button, so just return |
78 // the first mouse wheel button. | 77 // the first mouse wheel button. |
79 if (type == ui::ET_MOUSEWHEEL) | 78 if (type == ui::ET_MOUSEWHEEL) |
80 return Button4; | 79 return Button4; |
81 | 80 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); | 277 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); |
279 } | 278 } |
280 | 279 |
281 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { | 280 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { |
282 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); | 281 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); |
283 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); | 282 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
284 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); | 283 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); |
285 } | 284 } |
286 | 285 |
287 } // namespace ui | 286 } // namespace ui |
OLD | NEW |