| Index: ui/events/test/event_generator.cc
|
| diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc
|
| index f743ba18408f9b98626ff2859a806d2a53225577..26df7b43877c69ec3110d2093f971320f117f4ea 100644
|
| --- a/ui/events/test/event_generator.cc
|
| +++ b/ui/events/test/event_generator.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "base/time/default_tick_clock.h"
|
| +#include "base/time/tick_clock.h"
|
| #include "ui/events/event.h"
|
| #include "ui/events/event_source.h"
|
| #include "ui/events/event_utils.h"
|
| @@ -32,6 +33,21 @@ namespace {
|
| void DummyCallback(EventType, const gfx::Vector2dF&) {
|
| }
|
|
|
| +class TestTickClock : public base::TickClock {
|
| + public:
|
| + // Starts off with a clock set to TimeTicks().
|
| + TestTickClock() {}
|
| +
|
| + base::TimeTicks NowTicks() override {
|
| + return base::TimeTicks::FromInternalValue(ticks_++ * 1000);
|
| + }
|
| +
|
| + private:
|
| + int64 ticks_ = 1;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestTickClock);
|
| +};
|
| +
|
| class TestKeyEvent : public ui::KeyEvent {
|
| public:
|
| TestKeyEvent(const base::NativeEvent& native_event, int flags)
|
| @@ -518,6 +534,9 @@ void EventGenerator::Init(gfx::NativeWindow root_window,
|
| if (window_context)
|
| current_location_ = delegate()->CenterOfWindow(window_context);
|
| current_target_ = delegate()->GetTargetAt(current_location_);
|
| +
|
| + scoped_ptr<base::TickClock> clock(new TestTickClock);
|
| + SetTickClock(clock.Pass());
|
| }
|
|
|
| void EventGenerator::DispatchKeyEvent(bool is_press,
|
| @@ -537,12 +556,14 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
|
| }
|
| MSG native_event =
|
| { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
|
| + native_event.time = Now().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().InMicroseconds();
|
| ui::KeyEvent keyev(xevent);
|
| #else
|
| ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
|
|
|