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

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

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/aura/test/event_generator.h ('k') | ui/aura/test/test_activation_client.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
===================================================================
--- ui/aura/test/event_generator.cc (revision 150582)
+++ ui/aura/test/event_generator.cc (working copy)
@@ -5,8 +5,8 @@
#include "ui/aura/test/event_generator.h"
#include "base/memory/scoped_ptr.h"
-#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
+#include "ui/base/event.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
@@ -15,7 +15,7 @@
namespace {
-class TestKeyEvent : public aura::KeyEvent {
+class TestKeyEvent : public ui::KeyEvent {
public:
TestKeyEvent(const base::NativeEvent& native_event, int flags)
: KeyEvent(native_event, false /* is_char */) {
@@ -23,13 +23,13 @@
}
};
-class TestTouchEvent : public aura::TouchEvent {
+class TestTouchEvent : public ui::TouchEventImpl {
public:
TestTouchEvent(ui::EventType type,
const gfx::Point& root_location,
int flags)
- : TouchEvent(type, root_location, 0,
- base::Time::NowFromSystemTime() - base::Time()) {
+ : TouchEventImpl(type, root_location, 0,
+ base::Time::NowFromSystemTime() - base::Time()) {
set_flags(flags);
}
@@ -40,7 +40,7 @@
gfx::Point CenterOfWindowInRootWindowCoordinate(aura::RootWindow* root_window,
aura::Window* window) {
gfx::Point center = window->bounds().CenterPoint();
- aura::Window::ConvertPointToWindow(window->parent(), root_window, &center);
+ aura::Window::ConvertPointToTarget(window->parent(), root_window, &center);
return center;
}
@@ -73,16 +73,16 @@
void EventGenerator::PressLeftButton() {
if ((flags_ & ui::EF_LEFT_MOUSE_BUTTON) == 0) {
flags_ |= ui::EF_LEFT_MOUSE_BUTTON;
- MouseEvent mouseev(
- ui::ET_MOUSE_PRESSED, current_location_, current_location_, flags_);
+ ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, current_location_,
+ current_location_, flags_);
Dispatch(mouseev);
}
}
void EventGenerator::ReleaseLeftButton() {
if (flags_ & ui::EF_LEFT_MOUSE_BUTTON) {
- MouseEvent mouseev(
- ui::ET_MOUSE_RELEASED, current_location_, current_location_, flags_);
+ ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, current_location_,
+ current_location_, flags_);
Dispatch(mouseev);
flags_ ^= ui::EF_LEFT_MOUSE_BUTTON;
}
@@ -108,7 +108,7 @@
for (int i = 1; i <= count; i++) {
const gfx::Point move_point = current_location_.Add(
gfx::Point(diff.x() / count * i, diff.y() / count * i));
- MouseEvent mouseev(event_type, move_point, move_point, flags_);
+ ui::MouseEvent mouseev(event_type, move_point, move_point, flags_);
Dispatch(mouseev);
}
current_location_ = point;
@@ -117,7 +117,7 @@
void EventGenerator::MoveMouseRelativeTo(const Window* window,
const gfx::Point& point) {
gfx::Point root_point(point);
- aura::Window::ConvertPointToWindow(window, root_window_, &root_point);
+ Window::ConvertPointToTarget(window, root_window_, &root_point);
MoveMouseTo(root_point);
}
@@ -162,22 +162,25 @@
void EventGenerator::GestureTapAt(const gfx::Point& location) {
const int kTouchId = 2;
- TouchEvent press(ui::ET_TOUCH_PRESSED, location, kTouchId,
- base::Time::NowFromSystemTime() - base::Time());
+ ui::TouchEventImpl press(ui::ET_TOUCH_PRESSED, location, kTouchId,
+ base::Time::NowFromSystemTime() - base::Time());
Dispatch(press);
- TouchEvent release(ui::ET_TOUCH_RELEASED, location, kTouchId,
+ ui::TouchEventImpl release(
+ ui::ET_TOUCH_RELEASED, location, kTouchId,
press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
Dispatch(release);
}
void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) {
const int kTouchId = 3;
- TouchEvent press(ui::ET_TOUCH_PRESSED, location, kTouchId,
+ ui::TouchEventImpl press(
+ ui::ET_TOUCH_PRESSED, location, kTouchId,
base::Time::NowFromSystemTime() - base::Time());
Dispatch(press);
- TouchEvent release(ui::ET_TOUCH_RELEASED, location, kTouchId,
+ ui::TouchEventImpl release(
+ ui::ET_TOUCH_RELEASED, location, kTouchId,
press.time_stamp() + base::TimeDelta::FromMilliseconds(1000));
Dispatch(release);
}
@@ -188,7 +191,7 @@
int steps) {
const int kTouchId = 5;
base::TimeDelta timestamp = base::Time::NowFromSystemTime() - base::Time();
- TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp);
+ ui::TouchEventImpl press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp);
Dispatch(press);
int dx = (end.x() - start.x()) / steps;
@@ -197,11 +200,11 @@
for (int i = 0; i < steps; ++i) {
location.Offset(dx, dy);
timestamp += step_delay;
- TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp);
+ ui::TouchEventImpl move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp);
Dispatch(move);
}
- TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp);
+ ui::TouchEventImpl release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp);
Dispatch(release);
}
@@ -222,7 +225,7 @@
base::TimeDelta press_time = base::Time::NowFromSystemTime() - base::Time();
for (int i = 0; i < count; ++i) {
points[i] = start[i];
- TouchEvent press(ui::ET_TOUCH_PRESSED, points[i], i, press_time);
+ ui::TouchEventImpl press(ui::ET_TOUCH_PRESSED, points[i], i, press_time);
Dispatch(press);
}
@@ -231,7 +234,7 @@
base::TimeDelta::FromMilliseconds(event_separation_time_ms * step);
for (int i = 0; i < count; ++i) {
points[i].Offset(delta_x, delta_y);
- TouchEvent move(ui::ET_TOUCH_MOVED, points[i], i, move_time);
+ ui::TouchEventImpl move(ui::ET_TOUCH_MOVED, points[i], i, move_time);
Dispatch(move);
}
}
@@ -239,7 +242,8 @@
base::TimeDelta release_time = press_time +
base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps);
for (int i = 0; i < count; ++i) {
- TouchEvent release(ui::ET_TOUCH_RELEASED, points[i], i, release_time);
+ ui::TouchEventImpl release(
+ ui::ET_TOUCH_RELEASED, points[i], i, release_time);
Dispatch(release);
}
}
@@ -252,12 +256,12 @@
DispatchKeyEvent(false, key_code, flags);
}
-void EventGenerator::Dispatch(Event& event) {
+void EventGenerator::Dispatch(ui::Event& event) {
switch (event.type()) {
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED:
root_window_->AsRootWindowHostDelegate()->OnHostKeyEvent(
- static_cast<KeyEvent*>(&event));
+ static_cast<ui::KeyEvent*>(&event));
break;
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_DRAGGED:
@@ -267,7 +271,7 @@
case ui::ET_MOUSE_EXITED:
case ui::ET_MOUSEWHEEL:
root_window_->AsRootWindowHostDelegate()->OnHostMouseEvent(
- static_cast<MouseEvent*>(&event));
+ static_cast<ui::MouseEvent*>(&event));
break;
case ui::ET_TOUCH_RELEASED:
case ui::ET_TOUCH_PRESSED:
@@ -275,7 +279,7 @@
case ui::ET_TOUCH_STATIONARY:
case ui::ET_TOUCH_CANCELLED:
root_window_->AsRootWindowHostDelegate()->OnHostTouchEvent(
- static_cast<TouchEvent*>(&event));
+ static_cast<ui::TouchEventImpl*>(&event));
break;
default:
NOTIMPLEMENTED();
@@ -297,7 +301,7 @@
ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
TestKeyEvent keyev(native_event.get(), flags);
#else
- KeyEvent keyev(type, key_code, flags);
+ ui::KeyEvent keyev(type, key_code, flags);
#endif // USE_X11
#endif // OS_WIN
Dispatch(keyev);
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | ui/aura/test/test_activation_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698