| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webdriver/webdriver_key_converter.h" | 5 #include "chrome/test/webdriver/webdriver_key_converter.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 std::string unmodified_text, modified_text; | 244 std::string unmodified_text, modified_text; |
| 245 int all_modifiers = sticky_modifiers; | 245 int all_modifiers = sticky_modifiers; |
| 246 | 246 |
| 247 // Get the key code, text, and modifiers for the given key. | 247 // Get the key code, text, and modifiers for the given key. |
| 248 bool should_skip = false; | 248 bool should_skip = false; |
| 249 if (KeyCodeFromSpecialWebDriverKey(key, &key_code) || | 249 if (KeyCodeFromSpecialWebDriverKey(key, &key_code) || |
| 250 KeyCodeFromShorthandKey(key, &key_code, &should_skip)) { | 250 KeyCodeFromShorthandKey(key, &key_code, &should_skip)) { |
| 251 if (should_skip) | 251 if (should_skip) |
| 252 continue; | 252 continue; |
| 253 if (key_code == ui::VKEY_UNKNOWN) { | 253 if (key_code == ui::VKEY_UNKNOWN) { |
| 254 *error_msg = StringPrintf( | 254 *error_msg = base::StringPrintf( |
| 255 "Unknown WebDriver key(%d) at string index (%" PRIuS ")", | 255 "Unknown WebDriver key(%d) at string index (%" PRIuS ")", |
| 256 static_cast<int>(key), | 256 static_cast<int>(key), |
| 257 i); | 257 i); |
| 258 return false; | 258 return false; |
| 259 } | 259 } |
| 260 if (key_code == ui::VKEY_RETURN) { | 260 if (key_code == ui::VKEY_RETURN) { |
| 261 // For some reason Chrome expects a carriage return for the return key. | 261 // For some reason Chrome expects a carriage return for the return key. |
| 262 modified_text = unmodified_text = "\r"; | 262 modified_text = unmodified_text = "\r"; |
| 263 } else { | 263 } else { |
| 264 // WebDriver assumes a numpad key should translate to the number, | 264 // WebDriver assumes a numpad key should translate to the number, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 CreateKeyUpEvent(kModifiers[i].key_code, sticky_modifiers)); | 318 CreateKeyUpEvent(kModifiers[i].key_code, sticky_modifiers)); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 client_key_events->swap(key_events); | 322 client_key_events->swap(key_events); |
| 323 *modifiers = sticky_modifiers; | 323 *modifiers = sticky_modifiers; |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace webdriver | 327 } // namespace webdriver |
| OLD | NEW |