summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-04 09:16:53 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-04 09:16:53 +0000
commit17eb63f3488ff0815fc5e0cc5586dde88c544219 (patch)
tree8e8507c97f0834e3e02715226ae5f2d6a971bdd0 /ui
parent2edc0fd774ad547df7dbcdb3cb18e407b791514e (diff)
downloadchromium_src-17eb63f3488ff0815fc5e0cc5586dde88c544219.zip
chromium_src-17eb63f3488ff0815fc5e0cc5586dde88c544219.tar.gz
chromium_src-17eb63f3488ff0815fc5e0cc5586dde88c544219.tar.bz2
Revert 180360
> Introduce TextInputBrowsertest. > > This test verifies that the TextInputType should change expected value when the focused node is changed by JavaScript. > > This CL is a pilot change to check interactive_ui_tests can perform text input related testing. > We can't use browser_tests because text input related tests require unique focus and UI interaction. > If this patch works fine, I will introduce more tests to increase test coverage. > > BUG=173951 > TEST=try bots > > Review URL: https://chromiumcodereview.appspot.com/12093105 TBR=nona@chromium.org Review URL: https://codereview.chromium.org/12178014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/ime/fake_input_method.cc124
-rw-r--r--ui/base/ime/fake_input_method.h54
-rw-r--r--ui/base/ime/ime.gypi2
-rw-r--r--ui/base/ime/input_method_factory.cc15
-rw-r--r--ui/base/ime/input_method_factory.h3
-rw-r--r--ui/base/ime/mock_input_method.cc121
-rw-r--r--ui/base/ime/mock_input_method.h71
7 files changed, 75 insertions, 315 deletions
diff --git a/ui/base/ime/fake_input_method.cc b/ui/base/ime/fake_input_method.cc
deleted file mode 100644
index ffc73b1..0000000
--- a/ui/base/ime/fake_input_method.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2012 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/fake_input_method.h"
-
-#include "base/logging.h"
-#include "base/string16.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_constants.h"
-#include "ui/base/events/event_utils.h"
-#include "ui/base/glib/glib_integers.h"
-#include "ui/base/ime/input_method_delegate.h"
-#include "ui/base/ime/text_input_client.h"
-#include "ui/base/keycodes/keyboard_code_conversion.h"
-
-#if defined(USE_X11)
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "ui/base/keycodes/keyboard_code_conversion_x.h"
-#endif
-
-namespace {
-
-#if defined(USE_X11)
-uint32 EventFlagsFromXFlags(unsigned int flags) {
- return (flags & LockMask ? ui::EF_CAPS_LOCK_DOWN : 0U) |
- (flags & ControlMask ? ui::EF_CONTROL_DOWN : 0U) |
- (flags & ShiftMask ? ui::EF_SHIFT_DOWN : 0U) |
- (flags & Mod1Mask ? ui::EF_ALT_DOWN : 0U);
-}
-#endif
-
-} // namespace
-
-namespace ui {
-
-FakeInputMethod::FakeInputMethod(internal::InputMethodDelegate* delegate)
- : delegate_(NULL),
- text_input_client_(NULL) {
- SetDelegate(delegate);
-}
-
-FakeInputMethod::~FakeInputMethod() {
-}
-
-void FakeInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
- delegate_ = delegate;
-}
-
-void FakeInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
- text_input_client_ = client;
-}
-
-TextInputClient* FakeInputMethod::GetTextInputClient() const {
- return text_input_client_;
-}
-
-void FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
-#if defined(OS_WIN)
- if (native_event.message == WM_CHAR) {
- if (text_input_client_) {
- text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event),
- ui::EventFlagsFromNative(native_event));
- }
- } else {
- delegate_->DispatchKeyEventPostIME(native_event);
- }
-#elif defined(USE_X11)
- DCHECK(native_event);
- if (native_event->type == KeyRelease) {
- // On key release, just dispatch it.
- delegate_->DispatchKeyEventPostIME(native_event);
- } else {
- const uint32 state = EventFlagsFromXFlags(native_event->xkey.state);
- // Send a RawKeyDown event first,
- delegate_->DispatchKeyEventPostIME(native_event);
- if (text_input_client_) {
- // then send a Char event via ui::TextInputClient.
- const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event);
- uint16 ch = 0;
- if (!(state & ui::EF_CONTROL_DOWN))
- ch = ui::GetCharacterFromXEvent(native_event);
- if (!ch)
- ch = ui::GetCharacterFromKeyCode(key_code, state);
- if (ch)
- text_input_client_->InsertChar(ch, state);
- }
- }
-#else
- // TODO(yusukes): Support other platforms. Call InsertChar() when necessary.
- delegate_->DispatchKeyEventPostIME(native_event);
-#endif
-}
-
-void FakeInputMethod::Init(bool focused) {}
-void FakeInputMethod::OnFocus() {}
-void FakeInputMethod::OnBlur() {}
-void FakeInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {}
-void FakeInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {}
-void FakeInputMethod::CancelComposition(const TextInputClient* client) {}
-
-std::string FakeInputMethod::GetInputLocale() {
- return "";
-}
-
-base::i18n::TextDirection FakeInputMethod::GetInputTextDirection() {
- return base::i18n::UNKNOWN_DIRECTION;
-}
-
-bool FakeInputMethod::IsActive() {
- return true;
-}
-
-ui::TextInputType FakeInputMethod::GetTextInputType() const {
- return ui::TEXT_INPUT_TYPE_NONE;
-}
-
-bool FakeInputMethod::CanComposeInline() const {
- return true;
-}
-
-} // namespace ui
diff --git a/ui/base/ime/fake_input_method.h b/ui/base/ime/fake_input_method.h
deleted file mode 100644
index 596c4af..0000000
--- a/ui/base/ime/fake_input_method.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2012 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_FAKE_INPUT_METHOD_H_
-#define UI_BASE_IME_FAKE_INPUT_METHOD_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/base/ime/input_method.h"
-#include "ui/base/ui_export.h"
-
-namespace ui {
-
-class KeyEvent;
-class TextInputClient;
-
-// A fake ui::InputMethod implementation for minimum input support.
-class UI_EXPORT FakeInputMethod : NON_EXPORTED_BASE(public InputMethod) {
- public:
- explicit FakeInputMethod(internal::InputMethodDelegate* delegate);
- virtual ~FakeInputMethod();
-
- // Overriden from InputMethod.
- virtual void SetDelegate(internal::InputMethodDelegate* delegate) OVERRIDE;
- virtual void Init(bool focused) OVERRIDE;
- virtual void OnFocus() OVERRIDE;
- virtual void OnBlur() OVERRIDE;
- virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE;
- virtual TextInputClient* GetTextInputClient() const OVERRIDE;
- virtual void DispatchKeyEvent(const base::NativeEvent& native_event) OVERRIDE;
- virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE {
- }
- virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
- virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
- virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
- virtual std::string GetInputLocale() OVERRIDE;
- virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
- virtual bool IsActive() OVERRIDE;
- virtual ui::TextInputType GetTextInputType() const OVERRIDE;
- virtual bool CanComposeInline() const OVERRIDE;
-
- private:
- internal::InputMethodDelegate* delegate_;
- TextInputClient* text_input_client_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeInputMethod);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_IME_FAKE_INPUT_METHOD_H_
diff --git a/ui/base/ime/ime.gypi b/ui/base/ime/ime.gypi
index 95ae3c4..bd242b4 100644
--- a/ui/base/ime/ime.gypi
+++ b/ui/base/ime/ime.gypi
@@ -22,8 +22,6 @@
'input_method_win.h',
'mock_input_method.cc',
'mock_input_method.h',
- 'fake_input_method.cc',
- 'fake_input_method.h',
'text_input_client.cc',
'text_input_client.h',
'text_input_type.h',
diff --git a/ui/base/ime/input_method_factory.cc b/ui/base/ime/input_method_factory.cc
index ec97bbe..5bb5be0 100644
--- a/ui/base/ime/input_method_factory.cc
+++ b/ui/base/ime/input_method_factory.cc
@@ -5,37 +5,26 @@
#include "ui/base/ime/input_method_factory.h"
#include "ui/base/ime/input_method_delegate.h"
-#include "ui/base/ime/mock_input_method.h"
#if defined(OS_CHROMEOS)
#include "ui/base/ime/input_method_ibus.h"
#elif defined(OS_WIN)
#include "ui/base/ime/input_method_win.h"
#else
-#include "ui/base/ime/fake_input_method.h"
+#include "ui/base/ime/mock_input_method.h"
#endif
namespace ui {
-namespace {
-static bool g_input_method_set_for_testing = false;
-}
-
InputMethod* CreateInputMethod(internal::InputMethodDelegate* delegate,
gfx::AcceleratedWidget widget) {
- if (g_input_method_set_for_testing)
- return new MockInputMethod(delegate);
#if defined(OS_CHROMEOS)
return new InputMethodIBus(delegate);
#elif defined(OS_WIN)
return new InputMethodWin(delegate, widget);
#else
- return new FakeInputMethod(delegate);
+ return new MockInputMethod(delegate);
#endif
}
-void SetUpInputMethodFacotryForTesting() {
- g_input_method_set_for_testing = true;
-}
-
} // namespace ui
diff --git a/ui/base/ime/input_method_factory.h b/ui/base/ime/input_method_factory.h
index 0543edc..db56bf74 100644
--- a/ui/base/ime/input_method_factory.h
+++ b/ui/base/ime/input_method_factory.h
@@ -22,9 +22,6 @@ UI_EXPORT InputMethod* CreateInputMethod(
internal::InputMethodDelegate* delegate,
gfx::AcceleratedWidget widget);
-// With calling this function, CreateInputMethod will return MockInputMethod.
-UI_EXPORT void SetUpInputMethodFacotryForTesting();
-
} // namespace ui;
#endif // UI_BASE_IME_INPUT_METHOD_FACTORY_H_
diff --git a/ui/base/ime/mock_input_method.cc b/ui/base/ime/mock_input_method.cc
index 3a8e57e..62cd847 100644
--- a/ui/base/ime/mock_input_method.cc
+++ b/ui/base/ime/mock_input_method.cc
@@ -4,26 +4,41 @@
#include "ui/base/ime/mock_input_method.h"
+#include "base/logging.h"
+#include "base/string16.h"
+#include "ui/base/events/event.h"
+#include "ui/base/events/event_constants.h"
+#include "ui/base/events/event_utils.h"
+#include "ui/base/glib/glib_integers.h"
+#include "ui/base/ime/input_method_delegate.h"
#include "ui/base/ime/text_input_client.h"
+#include "ui/base/keycodes/keyboard_code_conversion.h"
+
+#if defined(USE_X11)
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "ui/base/keycodes/keyboard_code_conversion_x.h"
+#endif
+
+namespace {
+
+#if defined(USE_X11)
+uint32 EventFlagsFromXFlags(unsigned int flags) {
+ return (flags & LockMask ? ui::EF_CAPS_LOCK_DOWN : 0U) |
+ (flags & ControlMask ? ui::EF_CONTROL_DOWN : 0U) |
+ (flags & ShiftMask ? ui::EF_SHIFT_DOWN : 0U) |
+ (flags & Mod1Mask ? ui::EF_ALT_DOWN : 0U);
+}
+#endif
+
+} // namespace
namespace ui {
MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
: delegate_(NULL),
- text_input_client_(NULL),
- init_callcount_(0),
- on_focus_callcount_(0),
- on_blur_callcaount_(0),
- set_focused_text_input_client_callcount_(0),
- dispatch_keyevent_callcount_(0),
- dispatch_fabricated_keyevent_callcount_(0),
- on_text_input_type_changed_callcount_(0),
- on_caret_bounds_changed_callcount_(0),
- cancel_composition_callcount_(0),
- get_input_locale_callcount_(0),
- get_input_text_direction_callcount_(0),
- is_active_callcount_(0),
- latest_text_input_type_(ui::TEXT_INPUT_TYPE_NONE) {
+ text_input_client_(NULL) {
SetDelegate(delegate);
}
@@ -36,7 +51,6 @@ void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
text_input_client_ = client;
- ++set_focused_text_input_client_callcount_;
}
TextInputClient* MockInputMethod::GetTextInputClient() const {
@@ -44,51 +58,58 @@ TextInputClient* MockInputMethod::GetTextInputClient() const {
}
void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
- ++dispatch_keyevent_callcount_;
-}
-
-void MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
- ++dispatch_fabricated_keyevent_callcount_;
-}
-
-void MockInputMethod::Init(bool focused) {
- ++init_callcount_;
-}
-
-void MockInputMethod::OnFocus() {
- ++on_focus_callcount_;
-}
-
-void MockInputMethod::OnBlur() {
- ++on_blur_callcaount_;
-}
-
-void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
- ++on_text_input_type_changed_callcount_;
- latest_text_input_type_ = client->GetTextInputType();
-}
-
-void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
- ++on_caret_bounds_changed_callcount_;
-}
-
-void MockInputMethod::CancelComposition(const TextInputClient* client) {
- ++cancel_composition_callcount_;
-}
-
+#if defined(OS_WIN)
+ if (native_event.message == WM_CHAR) {
+ if (text_input_client_) {
+ text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event),
+ ui::EventFlagsFromNative(native_event));
+ }
+ } else {
+ delegate_->DispatchKeyEventPostIME(native_event);
+ }
+#elif defined(USE_X11)
+ DCHECK(native_event);
+ if (native_event->type == KeyRelease) {
+ // On key release, just dispatch it.
+ delegate_->DispatchKeyEventPostIME(native_event);
+ } else {
+ const uint32 state = EventFlagsFromXFlags(native_event->xkey.state);
+ // Send a RawKeyDown event first,
+ delegate_->DispatchKeyEventPostIME(native_event);
+ if (text_input_client_) {
+ // then send a Char event via ui::TextInputClient.
+ const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event);
+ uint16 ch = 0;
+ if (!(state & ui::EF_CONTROL_DOWN))
+ ch = ui::GetCharacterFromXEvent(native_event);
+ if (!ch)
+ ch = ui::GetCharacterFromKeyCode(key_code, state);
+ if (ch)
+ text_input_client_->InsertChar(ch, state);
+ }
+ }
+#else
+ // TODO(yusukes): Support other platforms. Call InsertChar() when necessary.
+ delegate_->DispatchKeyEventPostIME(native_event);
+#endif
+}
+
+void MockInputMethod::Init(bool focused) {}
+void MockInputMethod::OnFocus() {}
+void MockInputMethod::OnBlur() {}
+void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {}
+void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {}
+void MockInputMethod::CancelComposition(const TextInputClient* client) {}
std::string MockInputMethod::GetInputLocale() {
- ++get_input_locale_callcount_;
return "";
}
base::i18n::TextDirection MockInputMethod::GetInputTextDirection() {
- ++get_input_text_direction_callcount_;
return base::i18n::UNKNOWN_DIRECTION;
}
bool MockInputMethod::IsActive() {
- ++is_active_callcount_;
return true;
}
diff --git a/ui/base/ime/mock_input_method.h b/ui/base/ime/mock_input_method.h
index e34ffe0..d9085b1 100644
--- a/ui/base/ime/mock_input_method.h
+++ b/ui/base/ime/mock_input_method.h
@@ -31,7 +31,8 @@ class UI_EXPORT MockInputMethod : NON_EXPORTED_BASE(public InputMethod) {
virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE;
virtual TextInputClient* GetTextInputClient() const OVERRIDE;
virtual void DispatchKeyEvent(const base::NativeEvent& native_event) OVERRIDE;
- virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
+ virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE {
+ }
virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
@@ -41,78 +42,10 @@ class UI_EXPORT MockInputMethod : NON_EXPORTED_BASE(public InputMethod) {
virtual ui::TextInputType GetTextInputType() const OVERRIDE;
virtual bool CanComposeInline() const OVERRIDE;
- int init_callcount() const {
- return init_callcount_;
- }
-
- int on_focus_callcount() const {
- return on_focus_callcount_;
- }
-
- int on_blur_callcaount() const {
- return on_blur_callcaount_;
- }
-
- int set_focused_text_input_client_callcount() const {
- return set_focused_text_input_client_callcount_;
- }
-
- int dispatch_keyevent_callcount() const {
- return dispatch_keyevent_callcount_;
- }
-
- int dispatch_fabricated_keyevent_callcount() const {
- return dispatch_fabricated_keyevent_callcount_;
- }
-
- int on_text_input_type_changed_callcount() const {
- return on_text_input_type_changed_callcount_;
- }
-
- int on_caret_bounds_changed_callcount() const {
- return on_caret_bounds_changed_callcount_;
- }
-
- int cancel_composition_callcount() const {
- return cancel_composition_callcount_;
- }
-
- int get_input_locale_callcount() const {
- return get_input_locale_callcount_;
- }
-
- int get_input_text_direction_callcount() const {
- return get_input_text_direction_callcount_;
- }
-
- int is_active_callcount() const {
- return is_active_callcount_;
- }
-
- ui::TextInputType latest_text_input_type() const {
- return latest_text_input_type_;
- }
-
private:
internal::InputMethodDelegate* delegate_;
TextInputClient* text_input_client_;
- int init_callcount_;
- int on_focus_callcount_;
- int on_blur_callcaount_;
- int set_focused_text_input_client_callcount_;
- int get_text_input_client_callcount_;
- int dispatch_keyevent_callcount_;
- int dispatch_fabricated_keyevent_callcount_;
- int on_text_input_type_changed_callcount_;
- int on_caret_bounds_changed_callcount_;
- int cancel_composition_callcount_;
- int get_input_locale_callcount_;
- int get_input_text_direction_callcount_;
- int is_active_callcount_;
-
- ui::TextInputType latest_text_input_type_;
-
DISALLOW_COPY_AND_ASSIGN(MockInputMethod);
};