Commit de5e5216 authored by Yukawa@chromium.org's avatar Yukawa@chromium.org

Simplify InputMethodBridgeUnitTest

This is a refactoring CL as a preparation to fix focus handling on
Win-Aura environment. This CL does not change any behavior of
production binaries.

Currently InputMethodBridgeUnitTest internally defines a custom
dummy class of ui::InputMethod. However this is not necessary
because we already have ui::FakeInputMethod.

This CL replaces the custom dummy class with
ui::FakeInputMethod by using DummyInputMethodDelegate.
We can reuse ui::DummyInputMethodDelegate later in other
unit tests.

BUG=287620
TEST=unit test

Review URL: https://chromiumcodereview.appspot.com/23875014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222255 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b20fdc5
// Copyright 2013 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 "ui/base/ime/dummy_input_method_delegate.h"
namespace ui {
namespace internal {
DummyInputMethodDelegate::DummyInputMethodDelegate() {}
DummyInputMethodDelegate::~DummyInputMethodDelegate() {}
bool DummyInputMethodDelegate::DispatchKeyEventPostIME(
const base::NativeEvent& native_key_event) {
return true;
}
bool DummyInputMethodDelegate::DispatchFabricatedKeyEventPostIME(
ui::EventType type,
ui::KeyboardCode key_code,
int flags) {
return true;
}
} // namespace internal
} // namespace ui
// Copyright 2013 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.
#ifndef UI_BASE_IME_DUMMY_INPUT_METHOD_DELEGATE_H_
#define UI_BASE_IME_DUMMY_INPUT_METHOD_DELEGATE_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/base/ime/input_method_delegate.h"
#include "ui/base/ui_export.h"
namespace ui {
namespace internal {
class UI_EXPORT DummyInputMethodDelegate
: NON_EXPORTED_BASE(public InputMethodDelegate) {
public:
DummyInputMethodDelegate();
virtual ~DummyInputMethodDelegate();
// InputMethodDelegate overrides:
virtual bool DispatchKeyEventPostIME(
const base::NativeEvent& native_key_event) OVERRIDE;
virtual bool DispatchFabricatedKeyEventPostIME(ui::EventType type,
ui::KeyboardCode key_code,
int flags) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DummyInputMethodDelegate);
};
} // namespace internal
} // namespace ui
#endif // UI_BASE_IME_DUMMY_INPUT_METHOD_DELEGATE_H_
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
'composition_text.cc', 'composition_text.cc',
'composition_text.h', 'composition_text.h',
'composition_underline.h', 'composition_underline.h',
'dummy_input_method_delegate.cc',
'dummy_input_method_delegate.h',
'input_method.h', 'input_method.h',
'input_method_base.cc', 'input_method_base.cc',
'input_method_base.h', 'input_method_base.h',
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/ime/dummy_input_method.h" #include "ui/base/ime/dummy_input_method_delegate.h"
#include "ui/base/ime/fake_input_method.h"
#include "ui/base/ime/text_input_client.h" #include "ui/base/ime/text_input_client.h"
#include "ui/views/ime/input_method.h" #include "ui/views/ime/input_method.h"
#include "ui/views/test/views_test_base.h" #include "ui/views/test/views_test_base.h"
...@@ -16,41 +17,10 @@ namespace views { ...@@ -16,41 +17,10 @@ namespace views {
typedef ViewsTestBase InputMethodBridgeTest; typedef ViewsTestBase InputMethodBridgeTest;
namespace {
class TestInputMethod : public ui::DummyInputMethod {
public:
TestInputMethod();
virtual ~TestInputMethod();
virtual void SetFocusedTextInputClient(ui::TextInputClient* client) OVERRIDE;
virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE;
private:
ui::TextInputClient* text_input_client_;
DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
};
TestInputMethod::TestInputMethod() : text_input_client_(NULL) {}
TestInputMethod::~TestInputMethod() {}
void TestInputMethod::SetFocusedTextInputClient(ui::TextInputClient* client) {
// This simulates what the real InputMethod implementation does.
if (text_input_client_)
text_input_client_->GetTextInputType();
text_input_client_ = client;
}
ui::TextInputClient* TestInputMethod::GetTextInputClient() const {
return text_input_client_;
}
} // namespace
TEST_F(InputMethodBridgeTest, DestructTest) { TEST_F(InputMethodBridgeTest, DestructTest) {
TestInputMethod input_method; ui::internal::DummyInputMethodDelegate input_method_delegate;
ui::FakeInputMethod input_method(&input_method_delegate);
GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey, GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
static_cast<ui::InputMethod*>(&input_method)); static_cast<ui::InputMethod*>(&input_method));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment