| Index: ui/events/test/event_generator.cc
|
| diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc
|
| index 3bddbda7bd09641bf452e97e663de68b2f754280..b7b01d44d6cf481f215c335761825d33bdf9120b 100644
|
| --- a/ui/events/test/event_generator.cc
|
| +++ b/ui/events/test/event_generator.cc
|
| @@ -105,7 +105,7 @@ class TestTouchEvent : public ui::TouchEvent {
|
| const gfx::Point& root_location,
|
| int touch_id,
|
| int flags,
|
| - base::TimeDelta timestamp)
|
| + base::TimeTicks timestamp)
|
| : TouchEvent(type,
|
| root_location,
|
| flags,
|
| @@ -222,7 +222,7 @@ void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host,
|
| ui::ScopedXI2Event xevent;
|
| xevent.InitMotionEvent(point_in_host, point_for_native, flags_);
|
| static_cast<XEvent*>(xevent)->xmotion.time =
|
| - Now().InMilliseconds() & UINT32_MAX;
|
| + (Now() - base::TimeTicks()).InMilliseconds() & UINT32_MAX;
|
| ui::MouseEvent mouseev(xevent);
|
| #elif defined(USE_OZONE)
|
| // Ozone uses the location in native event as a system location.
|
| @@ -401,7 +401,7 @@ void EventGenerator::GestureScrollSequenceWithCallback(
|
| int steps,
|
| const ScrollStepCallback& callback) {
|
| const int kTouchId = 5;
|
| - base::TimeDelta timestamp = Now();
|
| + base::TimeTicks timestamp = Now();
|
| ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, 0, kTouchId,
|
| timestamp, 5.0f, 5.0f, 0.0f, 1.0f);
|
| Dispatch(&press);
|
| @@ -461,8 +461,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays(
|
| points[i] = start[i];
|
| }
|
|
|
| - base::TimeDelta press_time_first = Now();
|
| - base::TimeDelta press_time[kMaxTouchPoints];
|
| + base::TimeTicks press_time_first = Now();
|
| + base::TimeTicks press_time[kMaxTouchPoints];
|
| bool pressed[kMaxTouchPoints];
|
| for (int i = 0; i < count; ++i) {
|
| pressed[i] = false;
|
| @@ -472,7 +472,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays(
|
|
|
| int last_id = 0;
|
| for (int step = 0; step < steps; ++step) {
|
| - base::TimeDelta move_time = press_time_first +
|
| + base::TimeTicks move_time =
|
| + press_time_first +
|
| base::TimeDelta::FromMilliseconds(event_separation_time_ms * step);
|
|
|
| while (last_id < count &&
|
| @@ -496,7 +497,8 @@ void EventGenerator::GestureMultiFingerScrollWithDelays(
|
| }
|
| }
|
|
|
| - base::TimeDelta release_time = press_time_first +
|
| + base::TimeTicks release_time =
|
| + press_time_first +
|
| base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps);
|
| for (int i = 0; i < last_id; ++i) {
|
| ui::TouchEvent release(
|
| @@ -511,7 +513,7 @@ void EventGenerator::ScrollSequence(const gfx::Point& start,
|
| float y_offset,
|
| int steps,
|
| int num_fingers) {
|
| - base::TimeDelta timestamp = Now();
|
| + base::TimeTicks timestamp = Now();
|
| ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
|
| start,
|
| timestamp,
|
| @@ -550,7 +552,7 @@ void EventGenerator::ScrollSequence(const gfx::Point& start,
|
| const std::vector<gfx::PointF>& offsets,
|
| int num_fingers) {
|
| size_t steps = offsets.size();
|
| - base::TimeDelta timestamp = Now();
|
| + base::TimeTicks timestamp = Now();
|
| ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
|
| start,
|
| timestamp,
|
| @@ -603,11 +605,10 @@ void EventGenerator::SetTickClock(std::unique_ptr<base::TickClock> tick_clock) {
|
| tick_clock_ = clonable->Clone();
|
| }
|
|
|
| -base::TimeDelta EventGenerator::Now() {
|
| +base::TimeTicks EventGenerator::Now() {
|
| // This is the same as what EventTimeForNow() does, but here we do it
|
| // with a tick clock that can be replaced with a simulated clock for tests.
|
| - return base::TimeDelta::FromInternalValue(
|
| - tick_clock_->NowTicks().ToInternalValue());
|
| + return tick_clock_->NowTicks();
|
| }
|
|
|
| void EventGenerator::Init(gfx::NativeWindow root_window,
|
| @@ -637,14 +638,15 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
|
| }
|
| MSG native_event =
|
| { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
|
| - native_event.time = Now().InMicroseconds();
|
| + native_event.time = (Now() - base::TimeTicks()).InMicroseconds();
|
| TestKeyEvent keyev(native_event, flags);
|
| #elif defined(USE_X11)
|
| ui::ScopedXI2Event xevent;
|
| xevent.InitKeyEvent(is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
|
| key_code,
|
| flags);
|
| - static_cast<XEvent*>(xevent)->xkey.time = Now().InMilliseconds() & UINT32_MAX;
|
| + static_cast<XEvent*>(xevent)->xkey.time =
|
| + (Now() - base::TimeTicks()).InMilliseconds() & UINT32_MAX;
|
| ui::KeyEvent keyev(xevent);
|
| #else
|
| ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
|
|
|