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_
10 #include "base/basictypes.h"
13 #include "content/test/mock_keyboard_driver_win.h"
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().
29 // Represents keyboard-layouts.
34 LAYOUT_CHINESE_TRADITIONAL
,
50 LAYOUT_PORTUGUESE_BRAZILIAN
,
59 LAYOUT_DEVANAGARI_INSCRIPT
,
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.
73 LEFT_CONTROL
= 1 << 1,
77 RIGHT_CONTROL
= 1 << 5,
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
,
95 std::wstring
* output
);
98 Layout keyboard_layout_
;
99 Modifiers keyboard_modifiers_
;
102 MockKeyboardDriverWin driver_
;
105 DISALLOW_COPY_AND_ASSIGN(MockKeyboard
);
108 } // namespace content
110 #endif // CONTENT_TEST_MOCK_KEYBOARD_H_