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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_TEST_CHROMEDRIVER_KEY_CONVERTER_H_ 6 #define CHROME_TEST_CHROMEDRIVER_KEY_CONVERTER_H_ 7 8 #include <list> 9 #include <string> 10 11 #include "base/strings/string16.h" 12 #include "ui/events/keycodes/keyboard_codes.h" 13 14 struct KeyEvent; 15 class Status; 16 17 // Convenience functions for creating |KeyEvent|s. Used by unittests. 18 KeyEvent CreateKeyDownEvent(ui::KeyboardCode key_code, int modifiers); 19 KeyEvent CreateKeyUpEvent(ui::KeyboardCode key_code, int modifiers); 20 KeyEvent CreateCharEvent(const std::string& unmodified_text, 21 const std::string& modified_text, 22 int modifiers); 23 24 // Converts keys into appropriate |KeyEvent|s. This will do a best effort 25 // conversion. However, if the input is invalid it will return a status with 26 // an error message. If |release_modifiers| is true, all modifiers would be 27 // depressed. |modifiers| acts both an input and an output, however, only when 28 // the conversion process is successful will |modifiers| be changed. 29 Status ConvertKeysToKeyEvents(const string16& keys, 30 bool release_modifiers, 31 int* modifiers, 32 std::list<KeyEvent>* key_events); 33 34 #endif // CHROME_TEST_CHROMEDRIVER_KEY_CONVERTER_H_ 35