Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: ui/wm/core/input_method_event_filter_unittest.cc

Issue 298893003: Supports fake key events for setComposition/commitText by on-screen keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ash/shell.cc ('K') | « ui/wm/core/input_method_event_filter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/input_method_event_filter_unittest.cc
diff --git a/ui/wm/core/input_method_event_filter_unittest.cc b/ui/wm/core/input_method_event_filter_unittest.cc
index c5daa677ff726f319b6c74f616e7c475fb300f10..6a349c6f73873fd6692e8f1b058b02be9df0fec4 100644
--- a/ui/wm/core/input_method_event_filter_unittest.cc
+++ b/ui/wm/core/input_method_event_filter_unittest.cc
@@ -10,6 +10,9 @@
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/events/event.h"
+#include "ui/events/event_processor.h"
#include "ui/events/test/test_event_handler.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/default_activation_client.h"
@@ -56,6 +59,8 @@ TEST_F(InputMethodEventFilterTest, TestInputMethodKeyEventPropagation) {
InputMethodEventFilter input_method_event_filter(
host()->GetAcceleratedWidget());
root_filter.AddHandler(&input_method_event_filter);
+ input_method_event_filter.UpdateTargetDispatcher(
+ root_window()->GetHost()->event_processor());
// Add TestEventFilter to the RootWindow.
ui::test::TestEventHandler test_filter;
@@ -91,4 +96,41 @@ TEST_F(InputMethodEventFilterTest, TestInputMethodKeyEventPropagation) {
root_window()->RemovePreTargetHandler(&root_filter);
}
+// Tests event dispathching for IME composing.
+TEST_F(InputMethodEventFilterTest, TestEventDispatching) {
+ CompoundEventFilter root_filter;
+ root_window()->AddPreTargetHandler(&root_filter);
+
+ InputMethodEventFilter input_method_event_filter(
+ host()->GetAcceleratedWidget());
+ root_filter.AddHandler(&input_method_event_filter);
+
+ // Add TestEventFilter to the RootWindow.
+ ui::test::TestEventHandler test_filter;
+ root_filter.AddHandler(&test_filter);
+
+ ui::KeyEvent evt(ui::ET_KEY_PRESSED,
+ ui::VKEY_PROCESSKEY,
+ ui::EF_IME_FABRICATED_KEY,
+ false);
+ // Without onKeyEvent() being called, and no event processor, calls
+ // DispatchKeyEventPostIME().
+ input_method_event_filter.input_method()->DispatchKeyEvent(evt);
+ // Verifies no key event happened because InputMethodEventFilter::
+ // DispatchKeyEventPostIME() returns false.
+ EXPECT_EQ(0, test_filter.num_key_events());
+
+ // Without onKeyEvent() being called, update event processor, calls
+ // DispatchKeyEventPostIME().
+ input_method_event_filter.UpdateTargetDispatcher(
+ root_window()->GetHost()->event_processor());
+ input_method_event_filter.input_method()->DispatchKeyEvent(evt);
+ // Verifies 1 key event happened because InputMethodEventFilter::
+ // DispatchKeyEventPostIME() returns true.
+ EXPECT_EQ(1, test_filter.num_key_events());
+
+ root_filter.RemoveHandler(&input_method_event_filter);
+ root_window()->RemovePreTargetHandler(&root_filter);
+}
+
} // namespace wm
« ash/shell.cc ('K') | « ui/wm/core/input_method_event_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698