Implement FromDict/IntoDict for BackgroundTracingConfig.
[chromium-blink-merge.git] / content / test / mock_keyboard.h
bloba77875b4dcb1aeedf856faaed26fe5284e717da2
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_MOCK_KEYBOARD_H_
6 #define CONTENT_TEST_MOCK_KEYBOARD_H_
8 #include <string>
10 #include "base/basictypes.h"
12 #if defined(OS_WIN)
13 #include "content/test/mock_keyboard_driver_win.h"
14 #endif
16 namespace content {
18 // A mock keyboard interface.
19 // This class defines a pseudo keyboard device, which implements mappings from
20 // a tuple (layout, key code, modifiers) to Unicode characters so that
21 // engineers can write RenderViewTest cases without taking care of such
22 // mappings. (This mapping is not trivial when using non-US keyboards.)
23 // A pseudo keyboard device consists of two parts: a platform-independent part
24 // and a platform-dependent part. This class implements the platform-independent
25 // part. The platform-dependet part is implemented in the MockKeyboardWin class.
26 // This class is usually called from RenderViewTest::SendKeyEvent().
27 class MockKeyboard {
28 public:
29 // Represents keyboard-layouts.
30 enum Layout {
31 LAYOUT_NULL,
32 LAYOUT_ARABIC,
33 LAYOUT_BULGARIAN,
34 LAYOUT_CHINESE_TRADITIONAL,
35 LAYOUT_CZECH,
36 LAYOUT_DANISH,
37 LAYOUT_GERMAN,
38 LAYOUT_GREEK,
39 LAYOUT_UNITED_STATES,
40 LAYOUT_SPANISH,
41 LAYOUT_FINNISH,
42 LAYOUT_FRENCH,
43 LAYOUT_HEBREW,
44 LAYOUT_HUNGARIAN,
45 LAYOUT_ICELANDIC,
46 LAYOUT_ITALIAN,
47 LAYOUT_JAPANESE,
48 LAYOUT_KOREAN,
49 LAYOUT_POLISH,
50 LAYOUT_PORTUGUESE_BRAZILIAN,
51 LAYOUT_ROMANIAN,
52 LAYOUT_RUSSIAN,
53 LAYOUT_CROATIAN,
54 LAYOUT_SLOVAK,
55 LAYOUT_THAI,
56 LAYOUT_SWEDISH,
57 LAYOUT_TURKISH_Q,
58 LAYOUT_VIETNAMESE,
59 LAYOUT_DEVANAGARI_INSCRIPT,
60 LAYOUT_PORTUGUESE,
61 LAYOUT_UNITED_STATES_DVORAK,
62 LAYOUT_CANADIAN_FRENCH,
65 // Enumerates keyboard modifiers.
66 // These modifiers explicitly distinguish left-keys and right-keys because we
67 // should emulate AltGr (right-alt) key, used by many European keyboards to
68 // input alternate graph characters.
69 enum Modifiers {
70 INVALID = -1,
71 NONE = 0,
72 LEFT_SHIFT = 1 << 0,
73 LEFT_CONTROL = 1 << 1,
74 LEFT_ALT = 1 << 2,
75 LEFT_META = 1 << 3,
76 RIGHT_SHIFT = 1 << 4,
77 RIGHT_CONTROL = 1 << 5,
78 RIGHT_ALT = 1 << 6,
79 RIGHT_META = 1 << 7,
80 KEYPAD = 1 << 8,
81 AUTOREPEAAT = 1 << 9,
84 MockKeyboard();
85 ~MockKeyboard();
87 // Retrieves Unicode characters composed from the the specified keyboard
88 // layout, key code, and modifiers, i.e. characters returned when we type
89 // specified keys on a specified layout.
90 // This function returns the length of Unicode characters filled in the
91 // |output| parameter.
92 int GetCharacters(Layout layout,
93 int key_code,
94 Modifiers modifiers,
95 std::wstring* output);
97 private:
98 Layout keyboard_layout_;
99 Modifiers keyboard_modifiers_;
101 #if defined(OS_WIN)
102 MockKeyboardDriverWin driver_;
103 #endif
105 DISALLOW_COPY_AND_ASSIGN(MockKeyboard);
108 } // namespace content
110 #endif // CONTENT_TEST_MOCK_KEYBOARD_H_