| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/test/chromedriver/keycode_text_conversion.h" | 5 #include "chrome/test/chromedriver/keycode_text_conversion.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
| 9 #include <X11/XKBlib.h> | 9 #include <X11/XKBlib.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 uint16 character = ui::GetCharacterFromXEvent(&event); | 222 uint16 character = ui::GetCharacterFromXEvent(&event); |
| 223 | 223 |
| 224 if (!character) | 224 if (!character) |
| 225 *text = std::string(); | 225 *text = std::string(); |
| 226 else | 226 else |
| 227 *text = base::UTF16ToUTF8(base::string16(1, character)); | 227 *text = base::UTF16ToUTF8(base::string16(1, character)); |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool ConvertCharToKeyCode( | 231 bool ConvertCharToKeyCode( |
| 232 char16 key, | 232 base::char16 key, |
| 233 ui::KeyboardCode* key_code, | 233 ui::KeyboardCode* key_code, |
| 234 int* necessary_modifiers, | 234 int* necessary_modifiers, |
| 235 std::string* error_msg) { | 235 std::string* error_msg) { |
| 236 std::string key_string(base::UTF16ToUTF8(base::string16(1, key))); | 236 std::string key_string(base::UTF16ToUTF8(base::string16(1, key))); |
| 237 bool found = false; | 237 bool found = false; |
| 238 ui::KeyboardCode test_code; | 238 ui::KeyboardCode test_code; |
| 239 int test_modifiers; | 239 int test_modifiers; |
| 240 *error_msg = std::string(); | 240 *error_msg = std::string(); |
| 241 std::string conv_string; | 241 std::string conv_string; |
| 242 for (size_t i = 0; i < arraysize(kKeyCodeToXKeyCode); ++i) { | 242 for (size_t i = 0; i < arraysize(kKeyCodeToXKeyCode); ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 260 found = true; | 260 found = true; |
| 261 break; | 261 break; |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 if (found) { | 264 if (found) { |
| 265 *key_code = test_code; | 265 *key_code = test_code; |
| 266 *necessary_modifiers = test_modifiers; | 266 *necessary_modifiers = test_modifiers; |
| 267 } | 267 } |
| 268 return found; | 268 return found; |
| 269 } | 269 } |
| OLD | NEW |