Chromium Code Reviews| Index: ui/events/test/event_generator.cc |
| diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc |
| index 84b53ab97a01c7dcc6e7556c9672459654bb68df..04bb760dee16995f5e529d4121542b5d87026b46 100644 |
| --- a/ui/events/test/event_generator.cc |
| +++ b/ui/events/test/event_generator.cc |
| @@ -174,8 +174,9 @@ 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, gfx::PointF(exit_location), |
| + gfx::PointF(exit_location), ui::EventTimeForNow(), |
| + flags_, 0); |
| Dispatch(&mouseev); |
| } |
| @@ -191,13 +192,14 @@ void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host, |
| // Create a fake event with the point in host, which will be passed |
| // 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)); |
| + scoped_ptr<ui::MouseEvent> native_event( |
| + new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::PointF(point_in_host), |
| + gfx::PointF(point_in_host), Now(), flags_, 0)); |
| 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, gfx::PointF(point_in_host), |
| + gfx::PointF(point_for_native), Now(), flags_, 0); |
| LOG(FATAL) |
| << "Generating a native motion event is not supported on this platform"; |
| #endif |
| @@ -210,8 +212,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, gfx::PointF(point_in_host), |
| + gfx::PointF(point_in_host), ui::EventTimeForNow(), |
| + flags_, 0); |
| Dispatch(&mouseev); |
| current_location_ = point_in_host; |
| @@ -232,8 +235,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, gfx::PointF(move_point), |
| + gfx::PointF(move_point), ui::EventTimeForNow(), |
| + flags_, 0); |
| Dispatch(&mouseev); |
| } |
| current_location_ = point_in_screen; |
| @@ -311,28 +315,24 @@ void EventGenerator::GestureEdgeSwipe() { |
| void EventGenerator::GestureTapAt(const gfx::Point& location) { |
| const int kTouchId = 2; |
| - ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| - location, |
| - kTouchId, |
| + ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), kTouchId, |
| Now()); |
| Dispatch(&press); |
| ui::TouchEvent release( |
| - ui::ET_TOUCH_RELEASED, location, kTouchId, |
| + ui::ET_TOUCH_RELEASED, gfx::PointF(location), kTouchId, |
| press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); |
| Dispatch(&release); |
| } |
| void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) { |
| const int kTouchId = 3; |
| - ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| - location, |
| - kTouchId, |
| + ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), kTouchId, |
| Now()); |
| Dispatch(&press); |
| ui::TouchEvent release( |
| - ui::ET_TOUCH_RELEASED, location, kTouchId, |
| + ui::ET_TOUCH_RELEASED, gfx::PointF(location), kTouchId, |
| press.time_stamp() + base::TimeDelta::FromMilliseconds(1000)); |
| Dispatch(&release); |
| } |
| @@ -362,15 +362,15 @@ void EventGenerator::GestureScrollSequenceWithCallback( |
| int steps, |
| const ScrollStepCallback& callback) { |
| const int kTouchId = 5; |
| + gfx::PointF location(start); |
|
danakj
2015/10/23 21:46:10
I could cast |start| in the TouchEvent directly, b
|
| base::TimeDelta timestamp = Now(); |
| - ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp); |
| + ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, kTouchId, timestamp); |
| Dispatch(&press); |
| callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF()); |
| float dx = static_cast<float>(end.x() - start.x()) / steps; |
| float dy = static_cast<float>(end.y() - start.y()) / steps; |
| - gfx::PointF location = start; |
| for (int i = 0; i < steps; ++i) { |
| location.Offset(dx, dy); |
| timestamp += step_delay; |
| @@ -379,7 +379,8 @@ void EventGenerator::GestureScrollSequenceWithCallback( |
| callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy)); |
| } |
| - ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp); |
| + ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(end), kTouchId, |
| + timestamp); |
| Dispatch(&release); |
| callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF()); |
| @@ -434,10 +435,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays( |
| while (last_id < count && |
| !pressed[last_id] && |
| move_time >= press_time[last_id]) { |
| - ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| - points[last_id], |
| - last_id, |
| - press_time[last_id]); |
| + ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(points[last_id]), |
| + last_id, press_time[last_id]); |
| Dispatch(&press); |
| pressed[last_id] = true; |
| last_id++; |
| @@ -447,7 +446,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays( |
| points[i].Offset(delta_x, delta_y); |
| if (i >= last_id) |
| continue; |
| - ui::TouchEvent move(ui::ET_TOUCH_MOVED, points[i], i, move_time); |
| + ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(points[i]), i, |
| + move_time); |
| Dispatch(&move); |
| } |
| } |
| @@ -455,8 +455,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays( |
| base::TimeDelta release_time = press_time_first + |
| base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps); |
| for (int i = 0; i < last_id; ++i) { |
| - ui::TouchEvent release( |
| - ui::ET_TOUCH_RELEASED, points[i], i, release_time); |
| + ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(points[i]), i, |
| + release_time); |
| Dispatch(&release); |
| } |
| } |
| @@ -468,36 +468,22 @@ void EventGenerator::ScrollSequence(const gfx::Point& start, |
| int steps, |
| int num_fingers) { |
| base::TimeDelta timestamp = Now(); |
| - ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| - start, |
| - timestamp, |
| - 0, |
| - 0, 0, |
| - 0, 0, |
| - num_fingers); |
| + ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, gfx::PointF(start), |
| + timestamp, 0, 0, 0, 0, 0, num_fingers); |
| Dispatch(&fling_cancel); |
| float dx = x_offset / steps; |
| float dy = y_offset / steps; |
| for (int i = 0; i < steps; ++i) { |
| timestamp += step_delay; |
| - ui::ScrollEvent move(ui::ET_SCROLL, |
| - start, |
| - timestamp, |
| - 0, |
| - dx, dy, |
| - dx, dy, |
| - num_fingers); |
| + ui::ScrollEvent move(ui::ET_SCROLL, gfx::PointF(start), timestamp, 0, dx, |
| + dy, dx, dy, num_fingers); |
| Dispatch(&move); |
| } |
| - ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| - start, |
| - timestamp, |
| - 0, |
| - x_offset, y_offset, |
| - x_offset, y_offset, |
| - num_fingers); |
| + ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, gfx::PointF(start), |
| + timestamp, 0, x_offset, y_offset, x_offset, |
| + y_offset, num_fingers); |
| Dispatch(&fling_start); |
| } |
| @@ -507,34 +493,22 @@ void EventGenerator::ScrollSequence(const gfx::Point& start, |
| int num_fingers) { |
| size_t steps = offsets.size(); |
| base::TimeDelta timestamp = Now(); |
| - ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| - start, |
| - timestamp, |
| - 0, |
| - 0, 0, |
| - 0, 0, |
| - num_fingers); |
| + ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, gfx::PointF(start), |
| + timestamp, 0, 0, 0, 0, 0, num_fingers); |
| Dispatch(&fling_cancel); |
| for (size_t i = 0; i < steps; ++i) { |
| timestamp += step_delay; |
| - ui::ScrollEvent scroll(ui::ET_SCROLL, |
| - start, |
| - timestamp, |
| - 0, |
| - offsets[i].x(), offsets[i].y(), |
| - offsets[i].x(), offsets[i].y(), |
| - num_fingers); |
| + ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::PointF(start), timestamp, 0, |
| + offsets[i].x(), offsets[i].y(), offsets[i].x(), |
| + offsets[i].y(), num_fingers); |
| Dispatch(&scroll); |
| } |
| - ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| - start, |
| - timestamp, |
| - 0, |
| - offsets[steps - 1].x(), offsets[steps - 1].y(), |
| - offsets[steps - 1].x(), offsets[steps - 1].y(), |
| - num_fingers); |
| + ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, gfx::PointF(start), |
| + timestamp, 0, offsets[steps - 1].x(), |
| + offsets[steps - 1].y(), offsets[steps - 1].x(), |
| + offsets[steps - 1].y(), num_fingers); |
| Dispatch(&fling_start); |
| } |
| @@ -611,7 +585,7 @@ void EventGenerator::PressButton(int flag) { |
| if (!(flags_ & flag)) { |
| flags_ |= flag; |
| grab_ = (flags_ & kAllButtonMask) != 0; |
| - gfx::Point location = GetLocationInCurrentRoot(); |
| + auto location = gfx::PointF(GetLocationInCurrentRoot()); |
| ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, |
| ui::EventTimeForNow(), flags_, flag); |
| Dispatch(&mouseev); |
| @@ -620,7 +594,7 @@ void EventGenerator::PressButton(int flag) { |
| void EventGenerator::ReleaseButton(int flag) { |
| if (flags_ & flag) { |
| - gfx::Point location = GetLocationInCurrentRoot(); |
| + auto location = gfx::PointF(GetLocationInCurrentRoot()); |
| ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, location, |
| ui::EventTimeForNow(), flags_, flag); |
| Dispatch(&mouseev); |