diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 17:28:23 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 17:28:23 +0000 |
commit | c6d068ff599527ce4fccd39fd593099aada24d67 (patch) | |
tree | 5923cd9a4583780ce8d3384c24ec1a972156add9 /content/test/mock_keyboard.cc | |
parent | 595bfa8b392c172ff1b70c0d329d2bc1102ec242 (diff) | |
download | chromium_src-c6d068ff599527ce4fccd39fd593099aada24d67.zip chromium_src-c6d068ff599527ce4fccd39fd593099aada24d67.tar.gz chromium_src-c6d068ff599527ce4fccd39fd593099aada24d67.tar.bz2 |
Split most of RenderViewTest and associated classes into content.
BUG=99224
TEST=existing browser_tests, unit_tests
Review URL: http://codereview.chromium.org/8230034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test/mock_keyboard.cc')
-rw-r--r-- | content/test/mock_keyboard.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/content/test/mock_keyboard.cc b/content/test/mock_keyboard.cc new file mode 100644 index 0000000..0862a31 --- /dev/null +++ b/content/test/mock_keyboard.cc @@ -0,0 +1,47 @@ +// 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. + +#include "content/test/mock_keyboard.h" + +#include "base/logging.h" + +MockKeyboard::MockKeyboard() + : keyboard_layout_(LAYOUT_NULL), + keyboard_modifiers_(INVALID) { +} + +MockKeyboard::~MockKeyboard() { +} + +int MockKeyboard::GetCharacters(Layout layout, + int key_code, + Modifiers modifiers, + std::wstring* output) { +#if defined(OS_WIN) + CHECK(output); + // Change the keyboard layout only when we have to because it takes a lot of + // time to load a keyboard-layout driver. + // When we change the layout, we reset the modifier status to force updating + // the keyboard status. + if (layout != keyboard_layout_) { + if (!driver_.SetLayout(layout)) + return -1; + keyboard_layout_ = layout; + keyboard_modifiers_ = INVALID; + } + + // Update the keyboard states. + if (modifiers != keyboard_modifiers_) { + if (!driver_.SetModifiers(modifiers)) + return -1; + keyboard_modifiers_ = modifiers; + } + + // Retrieve Unicode characters associate with the key code. + return driver_.GetCharacters(key_code, output); +#else + NOTIMPLEMENTED(); + return -1; +#endif +} |