Home | History | Annotate | Download | only in webdriver
      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.
      4 
      5 #ifndef CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_
      6 #define CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/strings/string16.h"
     12 #include "chrome/test/webdriver/webdriver_automation.h"
     13 #include "ui/base/keycodes/keyboard_codes.h"
     14 
     15 namespace webdriver {
     16 
     17 class Logger;
     18 
     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,
     24                             int modifiers);
     25 
     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,
     33                                const Logger& logger,
     34                                bool release_modifiers,
     35                                int* modifiers,
     36                                std::vector<WebKeyEvent>* key_events,
     37                                std::string* error_msg);
     38 
     39 }  // namespace webdriver
     40 
     41 #endif  // CHROME_TEST_WEBDRIVER_WEBDRIVER_KEY_CONVERTER_H_
     42