Index: ui/aura/window_event_dispatcher_unittest.cc |
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc |
index ba60827254a60784a50b041be3daed725f854c2d..458ebea4137de8813441e7da4ad05f066bf78e8a 100644 |
--- a/ui/aura/window_event_dispatcher_unittest.cc |
+++ b/ui/aura/window_event_dispatcher_unittest.cc |
@@ -89,16 +89,22 @@ class NonClientDelegate : public test::TestWindowDelegate { |
// A simple event handler that consumes key events. |
class ConsumeKeyHandler : public ui::test::TestEventHandler { |
public: |
- ConsumeKeyHandler() {} |
+ ConsumeKeyHandler() : num_post_ime_key_events_(0) {} |
~ConsumeKeyHandler() override {} |
+ int num_post_ime_key_events() const { return num_post_ime_key_events_; } |
+ |
// Overridden from ui::EventHandler: |
void OnKeyEvent(ui::KeyEvent* event) override { |
ui::test::TestEventHandler::OnKeyEvent(event); |
event->StopPropagation(); |
+ if (event->should_skip_ime()) |
+ num_post_ime_key_events_++; |
} |
private: |
+ int num_post_ime_key_events_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler); |
}; |
@@ -420,6 +426,21 @@ TEST_P(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { |
w1->RemovePreTargetHandler(&handler); |
} |
+TEST_P(WindowEventDispatcherTest, KeyEventsSentToIME) { |
+ ConsumeKeyHandler handler; |
+ root_window()->AddPostTargetHandler(&handler); |
+ |
+ // Ctrl-C should be sent to Input Method. Since it cannot handle it, it will |
+ // be sent to DispatchKeyEventPostIME() and handled by |handler|. |
+ ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_C, ui::EF_CONTROL_DOWN); |
+ DispatchEventUsingWindowDispatcher(&key_press); |
+ EXPECT_TRUE(key_press.handled()); |
+ EXPECT_EQ(1, handler.num_key_events()); |
+ EXPECT_EQ(1, handler.num_post_ime_key_events()); |
+ |
+ root_window()->RemovePostTargetHandler(&handler); |
+} |
+ |
// Tests that touch-events that are beyond the bounds of the root-window do get |
// propagated to the event filters correctly with the root as the target. |
TEST_P(WindowEventDispatcherTest, TouchEventsOutsideBounds) { |