| Index: ui/aura/test/event_generator.cc
|
| diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
|
| index ecfa63becdef9535a9a8fc13d97a57bc24d3c661..a10736ce88a25ef5232da384c1278dee9c17730b 100644
|
| --- a/ui/aura/test/event_generator.cc
|
| +++ b/ui/aura/test/event_generator.cc
|
| @@ -69,8 +69,9 @@ class TestTouchEvent : public ui::TouchEvent {
|
| TestTouchEvent(ui::EventType type,
|
| const gfx::Point& root_location,
|
| int touch_id,
|
| - int flags)
|
| - : TouchEvent(type, root_location, flags, touch_id, ui::EventTimeForNow(),
|
| + int flags,
|
| + base::TimeDelta timestamp)
|
| + : TouchEvent(type, root_location, flags, touch_id, timestamp,
|
| 1.0f, 1.0f, 1.0f, 1.0f) {
|
| }
|
|
|
| @@ -87,7 +88,8 @@ EventGenerator::EventGenerator(Window* root_window)
|
| current_host_(delegate_->GetHostAt(current_location_)),
|
| flags_(0),
|
| grab_(false),
|
| - async_(false) {
|
| + async_(false),
|
| + use_simulated_time_(false) {
|
| }
|
|
|
| EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point)
|
| @@ -96,7 +98,8 @@ EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point)
|
| current_host_(delegate_->GetHostAt(current_location_)),
|
| flags_(0),
|
| grab_(false),
|
| - async_(false) {
|
| + async_(false),
|
| + use_simulated_time_(false) {
|
| }
|
|
|
| EventGenerator::EventGenerator(Window* root_window, Window* window)
|
| @@ -105,7 +108,8 @@ EventGenerator::EventGenerator(Window* root_window, Window* window)
|
| current_host_(delegate_->GetHostAt(current_location_)),
|
| flags_(0),
|
| grab_(false),
|
| - async_(false) {
|
| + async_(false),
|
| + use_simulated_time_(false) {
|
| }
|
|
|
| EventGenerator::EventGenerator(EventGeneratorDelegate* delegate)
|
| @@ -113,7 +117,8 @@ EventGenerator::EventGenerator(EventGeneratorDelegate* delegate)
|
| current_host_(delegate_->GetHostAt(current_location_)),
|
| flags_(0),
|
| grab_(false),
|
| - async_(false) {
|
| + async_(false),
|
| + use_simulated_time_(false) {
|
| }
|
|
|
| EventGenerator::~EventGenerator() {
|
| @@ -219,7 +224,8 @@ void EventGenerator::PressTouch() {
|
|
|
| void EventGenerator::PressTouchId(int touch_id) {
|
| TestTouchEvent touchev(
|
| - ui::ET_TOUCH_PRESSED, GetLocationInCurrentRoot(), touch_id, flags_);
|
| + ui::ET_TOUCH_PRESSED, GetLocationInCurrentRoot(), touch_id, flags_,
|
| + Now());
|
| Dispatch(&touchev);
|
| }
|
|
|
| @@ -230,7 +236,7 @@ void EventGenerator::MoveTouch(const gfx::Point& point) {
|
| void EventGenerator::MoveTouchId(const gfx::Point& point, int touch_id) {
|
| current_location_ = point;
|
| TestTouchEvent touchev(
|
| - ui::ET_TOUCH_MOVED, GetLocationInCurrentRoot(), touch_id, flags_);
|
| + ui::ET_TOUCH_MOVED, GetLocationInCurrentRoot(), touch_id, flags_, Now());
|
| Dispatch(&touchev);
|
|
|
| if (!grab_)
|
| @@ -243,7 +249,8 @@ void EventGenerator::ReleaseTouch() {
|
|
|
| void EventGenerator::ReleaseTouchId(int touch_id) {
|
| TestTouchEvent touchev(
|
| - ui::ET_TOUCH_RELEASED, GetLocationInCurrentRoot(), touch_id, flags_);
|
| + ui::ET_TOUCH_RELEASED, GetLocationInCurrentRoot(), touch_id, flags_,
|
| + Now());
|
| Dispatch(&touchev);
|
| }
|
|
|
| @@ -263,7 +270,7 @@ void EventGenerator::GestureEdgeSwipe() {
|
| 0,
|
| 0,
|
| 0,
|
| - ui::EventTimeForNow(),
|
| + Now(),
|
| ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0),
|
| 0);
|
| Dispatch(&gesture);
|
| @@ -274,7 +281,7 @@ void EventGenerator::GestureTapAt(const gfx::Point& location) {
|
| ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
|
| location,
|
| kTouchId,
|
| - ui::EventTimeForNow());
|
| + Now());
|
| Dispatch(&press);
|
|
|
| ui::TouchEvent release(
|
| @@ -288,7 +295,7 @@ void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) {
|
| ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
|
| location,
|
| kTouchId,
|
| - ui::EventTimeForNow());
|
| + Now());
|
| Dispatch(&press);
|
|
|
| ui::TouchEvent release(
|
| @@ -312,7 +319,7 @@ void EventGenerator::GestureScrollSequenceWithCallback(
|
| int steps,
|
| const ScrollStepCallback& callback) {
|
| const int kTouchId = 5;
|
| - base::TimeDelta timestamp = ui::EventTimeForNow();
|
| + base::TimeDelta timestamp = Now();
|
| ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp);
|
| Dispatch(&press);
|
|
|
| @@ -367,7 +374,7 @@ void EventGenerator::GestureMultiFingerScrollWithDelays(
|
| points[i] = start[i];
|
| }
|
|
|
| - base::TimeDelta press_time_first = ui::EventTimeForNow();
|
| + base::TimeDelta press_time_first = Now();
|
| base::TimeDelta press_time[kMaxTouchPoints];
|
| bool pressed[kMaxTouchPoints];
|
| for (int i = 0; i < count; ++i) {
|
| @@ -417,8 +424,7 @@ void EventGenerator::ScrollSequence(const gfx::Point& start,
|
| float y_offset,
|
| int steps,
|
| int num_fingers) {
|
| - base::TimeDelta timestamp = base::TimeDelta::FromInternalValue(
|
| - base::TimeTicks::Now().ToInternalValue());
|
| + base::TimeDelta timestamp = Now();
|
| ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
|
| start,
|
| timestamp,
|
| @@ -457,7 +463,7 @@ void EventGenerator::ScrollSequence(const gfx::Point& start,
|
| const std::vector<gfx::Point>& offsets,
|
| int num_fingers) {
|
| int steps = offsets.size();
|
| - base::TimeDelta timestamp = ui::EventTimeForNow();
|
| + base::TimeDelta timestamp = Now();
|
| ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
|
| start,
|
| timestamp,
|
| @@ -501,6 +507,20 @@ void EventGenerator::Dispatch(ui::Event* event) {
|
| DoDispatchEvent(event, async_);
|
| }
|
|
|
| +void EventGenerator::UseSimulatedTime() {
|
| + use_simulated_time_ = true;
|
| +}
|
| +
|
| +void EventGenerator::AdvanceSimulatedTimeBy(base::TimeDelta delta) {
|
| + simulated_time_ += delta;
|
| +}
|
| +
|
| +base::TimeDelta EventGenerator::Now() {
|
| + if (use_simulated_time_)
|
| + return simulated_time_;
|
| + return ui::EventTimeForNow();
|
| +}
|
| +
|
| void EventGenerator::DispatchKeyEvent(bool is_press,
|
| ui::KeyboardCode key_code,
|
| int flags) {
|
| @@ -638,6 +658,5 @@ void EventGenerator::DispatchNextPendingEvent() {
|
| }
|
| }
|
|
|
| -
|
| } // namespace test
|
| } // namespace aura
|
|
|