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

Unified Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 2095283002: MacViews: Don't handle character events in textfield_unittest's MockInputMethod::DispatchKeyEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
Index: ui/views/controls/textfield/textfield_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index 4de82b0a20be2f97ede82427d5dcb64d62d9a632..7c26892d4c69602992fa9cac1f8a0edd8ec1ba22 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -147,6 +147,12 @@ bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
}
void MockInputMethod::DispatchKeyEvent(ui::KeyEvent* key) {
+// On Mac, emulate InputMethodMac behavior.
+#if defined(OS_MACOSX)
+ ignore_result(DispatchKeyEventPostIME(key));
+ return;
+#endif
+
// Checks whether the key event is from EventGenerator on Windows which will
// generate key event for WM_CHAR.
// The MockInputMethod will insert char on WM_KEYDOWN so ignore WM_CHAR here.
@@ -510,9 +516,15 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
SendKeyEvent(code);
} else {
// For unicode characters, assume they come from IME rather than the
- // keyboard. So they are dispatched directly to the input method.
+ // keyboard. So they are dispatched directly to the input method. But on
+ // Mac, key events don't pass through InputMethod. Hence they are
+ // dispatched regularly.
ui::KeyEvent event(ch, ui::VKEY_UNKNOWN, ui::EF_NONE);
+#if defined(OS_MACOSX)
+ event_generator_->Dispatch(&event);
tapted 2016/06/29 07:21:39 can you explain (in the CL description perhaps) wh
karandeepb 2016/06/29 07:54:07 Done.
+#else
input_method_->DispatchKeyEvent(&event);
karandeepb 2016/06/29 01:42:41 Not sure if the event needs to be dispatched direc
tapted 2016/06/29 07:21:39 This looks ok.. Event dispatch can be a bit crazy,
+#endif
}
}
« ui/events/test/cocoa_test_event_utils.mm ('K') | « ui/events/test/cocoa_test_event_utils.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698