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

Unified Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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/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_++;
}
};
« no previous file with comments | « mojo/converters/blink/blink_input_events_type_converters_unittest.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698