1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_
6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_
11 #include "base/string16.h"
12 #include "chrome/test/webdriver/webdriver_automation.h"
13 #include "ui/base/keycodes/keyboard_codes.h"
19 // Convenience functions for creating |WebKeyEvent|s. Used by unittests.
20 WebKeyEvent
CreateKeyDownEvent(ui::KeyboardCode key_code
, int modifiers
);
21 WebKeyEvent
CreateKeyUpEvent(ui::KeyboardCode key_code
, int modifiers
);
22 WebKeyEvent
CreateCharEvent(const std::string
& unmodified_text
,
23 const std::string
& modified_text
,
26 // Converts keys into appropriate |WebKeyEvent|s. This will do a best effort
27 // conversion. However, if the input is invalid it will return false and set
28 // an error message. If |release_modifiers| is true, add an implicit NULL
29 // character to the end of the input to depress all modifiers. |modifiers|
30 // acts both an input and an output, however, only when the conversion
31 // process is successful will |modifiers| be changed.
32 bool ConvertKeysToWebKeyEvents(const string16
& keys
,
34 bool release_modifiers
,
36 std::vector
<WebKeyEvent
>* key_events
,
37 std::string
* error_msg
);
39 } // namespace webdriver
41 #endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_