Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / aura / test / event_generator.cc
index b62d3a8..422407d 100644 (file)
@@ -17,6 +17,8 @@
 #if defined(USE_X11)
 #include <X11/Xlib.h>
 #include "ui/base/x/x11_util.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/test/events_test_utils_x11.h"
 #endif
 
 #if defined(OS_WIN)
@@ -246,6 +248,18 @@ void EventGenerator::PressMoveAndReleaseTouchToCenterOf(Window* window) {
   PressMoveAndReleaseTouchTo(CenterOfWindow(window));
 }
 
+void EventGenerator::GestureEdgeSwipe() {
+  ui::GestureEvent gesture(
+      ui::ET_GESTURE_WIN8_EDGE_SWIPE,
+      0,
+      0,
+      0,
+      ui::EventTimeForNow(),
+      ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0),
+      0);
+  Dispatch(&gesture);
+}
+
 void EventGenerator::GestureTapAt(const gfx::Point& location) {
   const int kTouchId = 2;
   ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
@@ -496,6 +510,12 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
   MSG native_event =
       { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
   TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR);
+#elif defined(USE_X11)
+  ui::ScopedXI2Event xevent;
+  xevent.InitKeyEvent(is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
+                      key_code,
+                      flags);
+  ui::KeyEvent keyev(xevent, false);
 #else
   ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
   ui::KeyEvent keyev(type, key_code, flags, false);
@@ -587,23 +607,9 @@ void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) {
     }
     pending_events_.push_back(pending_event);
   } else {
-    WindowTreeHostDelegate* root_window_host_delegate =
-        current_root_window_->AsWindowTreeHostDelegate();
-    if (event->IsKeyEvent()) {
-      root_window_host_delegate->OnHostKeyEvent(
-          static_cast<ui::KeyEvent*>(event));
-    } else if (event->IsMouseEvent()) {
-      root_window_host_delegate->OnHostMouseEvent(
-          static_cast<ui::MouseEvent*>(event));
-    } else if (event->IsTouchEvent()) {
-      root_window_host_delegate->OnHostTouchEvent(
-          static_cast<ui::TouchEvent*>(event));
-    } else if (event->IsScrollEvent()) {
-      root_window_host_delegate->OnHostScrollEvent(
-          static_cast<ui::ScrollEvent*>(event));
-    } else {
-      NOTREACHED() << "Invalid event type";
-    }
+    ui::EventDispatchDetails details = current_root_window_->OnEventFromSource(
+        event);
+    CHECK(!details.dispatcher_destroyed);
   }
 }