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

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

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 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
Index: ui/events/test/event_generator.cc
diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc
index 6e619d0d71128bed66c474edfeb8b5f4347f50a3..12e7c4c75bd1415e709c19709014e87f4da80493 100644
--- a/ui/events/test/event_generator.cc
+++ b/ui/events/test/event_generator.cc
@@ -62,9 +62,18 @@ class TestTouchEvent : public ui::TouchEvent {
int touch_id,
int flags,
base::TimeDelta timestamp)
- : TouchEvent(type, root_location, flags, touch_id, timestamp,
- 1.0f, 1.0f, 0.0f, 0.0f) {
- }
+ : TouchEvent(type,
+ root_location,
+ flags,
+ touch_id,
+ timestamp,
+ 0.0f,
+ PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ 1.0f,
+ 1.0f,
+ 0.0f,
+ 0.0f,
+ 0.0f)) {}
private:
DISALLOW_COPY_AND_ASSIGN(TestTouchEvent);
@@ -159,8 +168,9 @@ void EventGenerator::ReleaseRightButton() {
void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) {
gfx::Point location = GetLocationInCurrentRoot();
- ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location,
- ui::EventTimeForNow(), flags_, 0);
+ ui::MouseEvent mouseev(
+ ui::ET_MOUSEWHEEL, location, location, ui::EventTimeForNow(), flags_, 0,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y);
Dispatch(&wheelev);
}
@@ -168,8 +178,10 @@ void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) {
void EventGenerator::SendMouseExit() {
gfx::Point exit_location(current_location_);
delegate()->ConvertPointToTarget(current_target_, &exit_location);
- ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location,
- ui::EventTimeForNow(), flags_, 0);
+ ui::MouseEvent mouseev(
+ ui::ET_MOUSE_EXITED, exit_location, exit_location, ui::EventTimeForNow(),
+ flags_, 0,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
Dispatch(&mouseev);
}
@@ -186,12 +198,14 @@ void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host,
// to the non native event, then update the native event with the native
// (root) one.
scoped_ptr<ui::MouseEvent> native_event(new ui::MouseEvent(
- ui::ET_MOUSE_MOVED, point_in_host, point_in_host, Now(), flags_, 0));
+ ui::ET_MOUSE_MOVED, point_in_host, point_in_host, Now(), flags_, 0,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
ui::MouseEvent mouseev(native_event.get());
native_event->set_location(point_for_native);
#else
- ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, point_in_host, point_for_native,
- Now(), flags_, 0);
+ ui::MouseEvent mouseev(
+ ui::ET_MOUSE_MOVED, point_in_host, point_for_native, Now(), flags_, 0,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
LOG(FATAL)
<< "Generating a native motion event is not supported on this platform";
#endif
@@ -204,8 +218,9 @@ void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host,
void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
- ui::MouseEvent mouseev(event_type, point_in_host, point_in_host,
- ui::EventTimeForNow(), flags_, 0);
+ ui::MouseEvent mouseev(
+ event_type, point_in_host, point_in_host, ui::EventTimeForNow(), flags_,
+ 0, ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
Dispatch(&mouseev);
current_location_ = point_in_host;
@@ -226,8 +241,9 @@ void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
if (!grab_)
UpdateCurrentDispatcher(move_point);
delegate()->ConvertPointToTarget(current_target_, &move_point);
- ui::MouseEvent mouseev(event_type, move_point, move_point,
- ui::EventTimeForNow(), flags_, 0);
+ ui::MouseEvent mouseev(
+ event_type, move_point, move_point, ui::EventTimeForNow(), flags_, 0,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
Dispatch(&mouseev);
}
current_location_ = point_in_screen;
@@ -605,8 +621,10 @@ void EventGenerator::PressButton(int flag) {
flags_ |= flag;
grab_ = (flags_ & kAllButtonMask) != 0;
gfx::Point location = GetLocationInCurrentRoot();
- ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location,
- ui::EventTimeForNow(), flags_, flag);
+ ui::MouseEvent mouseev(
+ ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), flags_,
+ flag,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
Dispatch(&mouseev);
}
}
@@ -614,8 +632,10 @@ void EventGenerator::PressButton(int flag) {
void EventGenerator::ReleaseButton(int flag) {
if (flags_ & flag) {
gfx::Point location = GetLocationInCurrentRoot();
- ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, location,
- ui::EventTimeForNow(), flags_, flag);
+ ui::MouseEvent mouseev(
+ ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(),
+ flags_, flag,
+ ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
Dispatch(&mouseev);
flags_ ^= flag;
}

Powered by Google App Engine
This is Rietveld 408576698