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

Unified Diff: ui/events/test/event_generator.cc

Issue 1017323002: make IsRepeated work even when a KeyEvent is created from the same native event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« ui/events/event_unittest.cc ('K') | « ui/events/event_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ae3bcb6d667a786c82a7e55a47d290835d3c1898 100644
--- a/ui/events/test/event_generator.cc
+++ b/ui/events/test/event_generator.cc
@@ -9,7 +9,7 @@
#include "base/memory/scoped_ptr.h"
#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 +32,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;
sadrul 2015/03/19 10:36:53 Oh, does the style guide allow this?
oshima 2015/03/19 16:41:57 Yep, see "Non-Static Class Member Initializers" in
+
+ DISALLOW_COPY_AND_ASSIGN(TestTickClock);
+};
+
class TestKeyEvent : public ui::KeyEvent {
public:
TestKeyEvent(const base::NativeEvent& native_event, int flags)
@@ -67,7 +82,7 @@ EventGenerator::EventGenerator(gfx::NativeWindow root_window)
grab_(false),
async_(false),
targeting_application_(false),
- tick_clock_(new base::DefaultTickClock()) {
+ tick_clock_(new TestTickClock()) {
Init(root_window, NULL);
}
@@ -79,7 +94,7 @@ EventGenerator::EventGenerator(gfx::NativeWindow root_window,
grab_(false),
async_(false),
targeting_application_(false),
- tick_clock_(new base::DefaultTickClock()) {
+ tick_clock_(new TestTickClock()) {
Init(root_window, NULL);
}
@@ -90,7 +105,7 @@ EventGenerator::EventGenerator(gfx::NativeWindow root_window,
grab_(false),
async_(false),
targeting_application_(false),
- tick_clock_(new base::DefaultTickClock()) {
+ tick_clock_(new TestTickClock()) {
Init(root_window, window);
}
@@ -101,7 +116,7 @@ EventGenerator::EventGenerator(EventGeneratorDelegate* delegate)
grab_(false),
async_(false),
targeting_application_(false),
- tick_clock_(new base::DefaultTickClock()) {
+ tick_clock_(new TestTickClock()) {
Init(NULL, NULL);
}
@@ -537,12 +552,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;
« ui/events/event_unittest.cc ('K') | « ui/events/event_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698