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

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: Modify comment. 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
« no previous file with comments | « ui/events/test/cocoa_test_event_utils.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b40de20b5fcd77bc9c8f7729fefcd4de45fcdb0c..5db243c102d15b554ea7c75f3dab2c7736bc75d7 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -147,6 +147,16 @@ bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
}
void MockInputMethod::DispatchKeyEvent(ui::KeyEvent* key) {
+// On Mac, emulate InputMethodMac behavior for character events. Composition
+// still needs to be mocked, since it's not possible to generate test events
+// which trigger the appropriate NSResponder action messages for composition.
+#if defined(OS_MACOSX)
+ if (key->is_char()) {
+ 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 +520,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);
+#else
input_method_->DispatchKeyEvent(&event);
+#endif
}
}
« no previous file with comments | « 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