summaryrefslogtreecommitdiffstats
path: root/chrome/test/webdriver/keycode_text_conversion.h
blob: c1f7e33683374150e560d8386084cd0fd6027211 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_WEBDRIVER_KEYCODE_TEXT_CONVERSION_H_
#define CHROME_TEST_WEBDRIVER_KEYCODE_TEXT_CONVERSION_H_

#include <string>

#include "base/strings/string16.h"
#include "ui/base/keycodes/keyboard_codes.h"

namespace webdriver {

// These functions only support conversion of characters in the BMP
// (Basic Multilingual Plane).

// Returns the text in UTF8 that would be produced from the given key code and
// modifiers with the current keyboard layout, or "" if no character would
// be produced. This will return "" if the produced text contains characters
// outside the BMP.
std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers);

// Converts a character to the key code and modifiers that would produce
// the character using the current keyboard layout. Returns true on success.
bool ConvertCharToKeyCode(
    char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers);

}  // namespace webdriver

#endif  // CHROME_TEST_WEBDRIVER_KEYCODE_TEXT_CONVERSION_H_