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

Unified Diff: ui/aura/test/event_generator.cc

Issue 8576005: IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move to ash/ime/ Created 9 years 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/aura/test/event_generator.h ('k') | ui/base/events.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/event_generator.cc
diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
index c21e1ad83f9f628843fdf62b6f6490672fc3174f..59d2854c1c3477e31dc98b4668381f705b078f85 100644
--- a/ui/aura/test/event_generator.cc
+++ b/ui/aura/test/event_generator.cc
@@ -4,9 +4,15 @@
#include "ui/aura/test/event_generator.h"
+#include "base/memory/scoped_ptr.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
+#if defined(USE_X11)
+#include <X11/Xlib.h>
+#include "ui/base/x/x11_util.h"
+#endif
+
namespace {
gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) {
@@ -119,6 +125,14 @@ void EventGenerator::PressMoveAndReleaseTouchToCenterOf(Window* window) {
PressMoveAndReleaseTouchTo(CenterOfWindowInRootWindowCoordinate(window));
}
+void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) {
+ DispatchKeyEvent(true, key_code, flags);
+}
+
+void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) {
+ DispatchKeyEvent(false, key_code, flags);
+}
+
void EventGenerator::Dispatch(Event& event) {
switch (event.type()) {
case ui::ET_KEY_PRESSED:
@@ -150,5 +164,25 @@ void EventGenerator::Dispatch(Event& event) {
}
}
+void EventGenerator::DispatchKeyEvent(bool is_press,
+ ui::KeyboardCode key_code,
+ int flags) {
+#if defined(OS_WIN)
+ MSG native_event =
+ { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, flags };
+ KeyEvent keyev(native_event, false /* is_char */);
+#else
+ ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
+#if defined(USE_X11)
+ scoped_ptr<XEvent> native_event(new XEvent);
+ ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
+ KeyEvent keyev(native_event.get(), false);
+#else
+ KeyEvent keyev(type, key_code, flags);
+#endif // USE_X11
+#endif // OS_WIN
+ Dispatch(keyev);
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | ui/base/events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698