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.
5 #include "content/test/mock_keyboard.h"
7 #include "base/logging.h"
11 MockKeyboard::MockKeyboard()
12 : keyboard_layout_(LAYOUT_NULL),
13 keyboard_modifiers_(INVALID) {
16 MockKeyboard::~MockKeyboard() {
19 int MockKeyboard::GetCharacters(Layout layout,
22 std::wstring* output) {
25 // Change the keyboard layout only when we have to because it takes a lot of
26 // time to load a keyboard-layout driver.
27 // When we change the layout, we reset the modifier status to force updating
28 // the keyboard status.
29 if (layout != keyboard_layout_) {
30 if (!driver_.SetLayout(layout))
32 keyboard_layout_ = layout;
33 keyboard_modifiers_ = INVALID;
36 // Update the keyboard states.
37 if (modifiers != keyboard_modifiers_) {
38 if (!driver_.SetModifiers(modifiers))
40 keyboard_modifiers_ = modifiers;
43 // Retrieve Unicode characters associate with the key code.
44 return driver_.GetCharacters(key_code, output);
51 } // namespace content