Commit 75ae75c4 authored by Mikhail Montsev's avatar Mikhail Montsev Committed by Commit Bot

Fix UB in events_unittests

Use ui::test::ScopedEventTestTickClock instead of
SetEventTickClockForTesting.

EventsXTest did not call SetEventTickClockForTesting(nullptr) and,
eventually, GestureProviderAuraTest suffered from that.

It's better to use RAII idiom in this case because RAII makes impossible
to forget to call SetEventTickClockForTesting(nullptr).

Change-Id: I80b079ef37a77618d76f14912f7d6c40d39ab66b
Reviewed-on: https://chromium-review.googlesource.com/1030108
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569607}
parent 78adb83d
......@@ -21,6 +21,7 @@
#include "ui/events/event_utils.h"
#include "ui/events/test/events_test_utils.h"
#include "ui/events/test/events_test_utils_x11.h"
#include "ui/events/test/scoped_event_test_tick_clock.h"
#include "ui/events/x/events_x_utils.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
......@@ -554,9 +555,8 @@ TEST_F(EventsXTest, TimestampRolloverAndAdjustWhenDecreasing) {
XEvent event;
InitButtonEvent(&event, true, gfx::Point(5, 10), 1, 0);
base::SimpleTestTickClock clock;
test::ScopedEventTestTickClock clock;
clock.SetNowTicks(TimeTicksFromMillis(0x100000001));
SetEventTickClockForTesting(&clock);
ResetTimestampRolloverCountersForTesting();
event.xbutton.time = 0xFFFFFFFF;
......@@ -574,9 +574,8 @@ TEST_F(EventsXTest, NoTimestampRolloverWhenMonotonicIncreasing) {
XEvent event;
InitButtonEvent(&event, true, gfx::Point(5, 10), 1, 0);
base::SimpleTestTickClock clock;
test::ScopedEventTestTickClock clock;
clock.SetNowTicks(TimeTicksFromMillis(10));
SetEventTickClockForTesting(&clock);
ResetTimestampRolloverCountersForTesting();
event.xbutton.time = 6;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment