Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/renderer/mock_keyboard.h

Issue 92122: Implements keyboard events for RenderViewTest.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/renderer/mock_keyboard.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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_RENDERER_MOCK_KEYBOARD_H_
6 #define CHROME_RENDERER_MOCK_KEYBOARD_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 #if defined(OS_WIN)
13 #include "chrome/renderer/mock_keyboard_driver_win.h"
14 #endif
15
16 // A mock keyboard interface.
17 // This class defines a pseudo keyboard device, which implements mappings from
18 // a tuple (layout, key code, modifiers) to Unicode characters so that
19 // engineers can write RenderViewTest cases without taking care of such
20 // mappings. (This mapping is not trivial when using non-US keyboards.)
21 // A pseudo keyboard device consists of two parts: a platform-independent part
22 // and a platform-dependent part. This class implements the platform-independent
23 // part. The platform-dependet part is implemented in the MockKeyboardWin class.
24 // This class is usually called from RenderViewTest::SendKeyEvent().
25 class MockKeyboard {
26 public:
27 // Represents keyboard-layouts.
28 enum Layout {
29 LAYOUT_NULL,
30 LAYOUT_ARABIC,
31 LAYOUT_BULGARIAN,
32 LAYOUT_CHINESE_TRADITIONAL,
33 LAYOUT_CZECH,
34 LAYOUT_DANISH,
35 LAYOUT_GERMAN,
36 LAYOUT_GREEK,
37 LAYOUT_UNITED_STATES,
38 LAYOUT_SPANISH,
39 LAYOUT_FINNISH,
40 LAYOUT_FRENCH,
41 LAYOUT_HEBREW,
42 LAYOUT_HUNGARIAN,
43 LAYOUT_ICELANDIC,
44 LAYOUT_ITALIAN,
45 LAYOUT_JAPANESE,
46 LAYOUT_KOREAN,
47 LAYOUT_POLISH,
48 LAYOUT_PORTUGUESE_BRAZILIAN,
49 LAYOUT_ROMANIAN,
50 LAYOUT_RUSSIAN,
51 LAYOUT_CROATIAN,
52 LAYOUT_SLOVAK,
53 LAYOUT_THAI,
54 LAYOUT_SWEDISH,
55 LAYOUT_TURKISH_Q,
56 LAYOUT_VIETNAMESE,
57 LAYOUT_DEVANAGARI_INSCRIPT,
58 LAYOUT_PORTUGUESE,
59 LAYOUT_UNITED_STATES_DVORAK,
60 LAYOUT_CANADIAN_FRENCH,
61 };
62
63 // Enumerates keyboard modifiers.
64 // These modifiers explicitly distinguish left-keys and right-keys because we
65 // should emulate AltGr (right-alt) key, used by many European keyboards to
66 // input alternate graph characters.
67 enum Modifiers {
68 INVALID = -1,
69 NONE = 0,
70 LEFT_SHIFT = 1 << 0,
71 LEFT_CONTROL = 1 << 1,
72 LEFT_ALT = 1 << 2,
73 LEFT_META = 1 << 3,
74 RIGHT_SHIFT = 1 << 4,
75 RIGHT_CONTROL = 1 << 5,
76 RIGHT_ALT = 1 << 6,
77 RIGHT_META = 1 << 7,
78 KEYPAD = 1 << 8,
79 AUTOREPEAAT = 1 << 9,
80 };
81
82 MockKeyboard();
83 ~MockKeyboard();
84
85 // Retrieves Unicode characters composed from the the specified keyboard
86 // layout, key code, and modifiers, i.e. characters returned when we type
87 // specified keys on a specified layout.
88 // This function returns the length of Unicode characters filled in the
89 // |output| parameter.
90 int GetCharacters(Layout layout,
91 int key_code,
92 Modifiers modifiers,
93 std::wstring* output);
94
95 private:
96 Layout keyboard_layout_;
97 Modifiers keyboard_modifiers_;
98
99 #if defined(OS_WIN)
100 MockKeyboardDriverWin driver_;
101 #endif
102
103 DISALLOW_COPY_AND_ASSIGN(MockKeyboard);
104 };
105
106 #endif // CHROME_RENDERER_MOCK_KEYBOARD_H_
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/renderer/mock_keyboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698