Index: ui/aura/gestures/gesture_recognizer_unittest.cc |
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc |
index fc4e584211587bf10149fbaf7b6b23f60715cd44..2e692129ea8a1499dfd542a144ed05bdf72eaddc 100644 |
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc |
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "base/macros.h" |
#include "base/run_loop.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/test/simple_test_tick_clock.h" |
#include "base/timer/timer.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/aura/env.h" |
@@ -481,27 +482,29 @@ class ScopedGestureRecognizerSetter { |
class TimedEvents { |
private: |
- int simulated_now_; |
+ base::SimpleTestTickClock tick_clock_; |
public: |
// Use a non-zero start time to pass DCHECKs which ensure events have had a |
// time assigned. |
- TimedEvents() : simulated_now_(1) { |
+ TimedEvents() { |
+ tick_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); |
} |
- base::TimeDelta Now() { |
- base::TimeDelta t = base::TimeDelta::FromMilliseconds(simulated_now_); |
- simulated_now_++; |
+ base::TimeTicks Now() { |
+ base::TimeTicks t = tick_clock_.NowTicks(); |
+ tick_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); |
return t; |
} |
- base::TimeDelta LeapForward(int time_in_millis) { |
- simulated_now_ += time_in_millis; |
- return base::TimeDelta::FromMilliseconds(simulated_now_); |
+ base::TimeTicks LeapForward(int time_in_millis) { |
+ tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_in_millis)); |
+ return tick_clock_.NowTicks(); |
} |
- base::TimeDelta InFuture(int time_in_millis) { |
- return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); |
+ base::TimeTicks InFuture(int time_in_millis) { |
+ return tick_clock_.NowTicks() + |
+ base::TimeDelta::FromMilliseconds(time_in_millis); |
} |
void SendScrollEvents(ui::EventProcessor* dispatcher, |
@@ -510,7 +513,7 @@ class TimedEvents { |
int dx, |
int dy, |
int touch_id, |
- int time_step, |
+ int time_step_ms, |
int num_steps, |
GestureEventConsumeDelegate* delegate) { |
float x = x_start; |
@@ -520,10 +523,10 @@ class TimedEvents { |
x += dx; |
y += dy; |
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id, |
- base::TimeDelta::FromMilliseconds(simulated_now_)); |
+ tick_clock_.NowTicks()); |
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
ASSERT_FALSE(details.dispatcher_destroyed); |
- simulated_now_ += time_step; |
+ tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_step_ms)); |
} |
} |
@@ -534,12 +537,11 @@ class TimedEvents { |
GestureEventConsumeDelegate* delegate) { |
delegate->Reset(); |
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), touch_id, |
- base::TimeDelta::FromMilliseconds(simulated_now_)); |
+ Now()); |
move.set_location_f(gfx::PointF(x, y)); |
move.set_root_location_f(gfx::PointF(x, y)); |
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
ASSERT_FALSE(details.dispatcher_destroyed); |
- simulated_now_++; |
} |
}; |