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

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: rebase, review 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
Index: ui/aura/test/event_generator.cc
diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
index 573665ff1d3fef3793e7c730106109d4fe3f6710..880668b7d0723b0fdd8330928dab1e8e9aa8c663 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) {
@@ -90,6 +96,14 @@ void EventGenerator::DragMouseTo(const gfx::Point& point) {
ReleaseLeftButton();
}
+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:
@@ -113,6 +127,20 @@ void EventGenerator::Dispatch(Event& event) {
}
}
+void EventGenerator::DispatchKeyEvent(bool is_press,
+ ui::KeyboardCode key_code,
+ int flags) {
+ 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 /* is_char */);
+#else
+ KeyEvent keyev(type, key_code, flags);
+#endif
+ Dispatch(keyev);
+}
+
void EventGenerator::MoveMouseToCenterOf(Window* window) {
MoveMouseTo(CenterOfWindowInRootWindowCoordinate(window));
}

Powered by Google App Engine
This is Rietveld 408576698