OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/base_event_utils.h" | 5 #include "ui/events/base_event_utils.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
14 #include "ui/events/event_switches.h" | 14 #include "ui/events/event_switches.h" |
15 | 15 |
16 bool g_no_mock_time = false; | |
17 | |
16 namespace ui { | 18 namespace ui { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
21 const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN; | 23 const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN; |
22 #else | 24 #else |
23 const int kSystemKeyModifierMask = EF_ALT_DOWN; | 25 const int kSystemKeyModifierMask = EF_ALT_DOWN; |
24 #endif // defined(OS_CHROMEOS) | 26 #endif // defined(OS_CHROMEOS) |
25 | 27 |
(...skipping 15 matching lines...) Expand all Loading... | |
41 // AltGr modifier is used to type alternative keys on certain keyboard layouts | 43 // AltGr modifier is used to type alternative keys on certain keyboard layouts |
42 // so we don't consider keys with the AltGr modifier as a system key. | 44 // so we don't consider keys with the AltGr modifier as a system key. |
43 return (kSystemKeyModifierMask & flags) != 0 && | 45 return (kSystemKeyModifierMask & flags) != 0 && |
44 (EF_ALTGR_DOWN & flags) == 0; | 46 (EF_ALTGR_DOWN & flags) == 0; |
45 } | 47 } |
46 | 48 |
47 base::LazyInstance<std::unique_ptr<base::TickClock>>::Leaky g_tick_clock = | 49 base::LazyInstance<std::unique_ptr<base::TickClock>>::Leaky g_tick_clock = |
48 LAZY_INSTANCE_INITIALIZER; | 50 LAZY_INSTANCE_INITIALIZER; |
49 | 51 |
50 base::TimeTicks EventTimeForNow() { | 52 base::TimeTicks EventTimeForNow() { |
53 if (g_no_mock_time) | |
54 DCHECK(!g_tick_clock.Get()); | |
tapted
2016/06/30 07:02:49
So I got this to fail at [ RUN ] MenuRunnerCo
| |
51 return g_tick_clock.Get() ? g_tick_clock.Get()->NowTicks() | 55 return g_tick_clock.Get() ? g_tick_clock.Get()->NowTicks() |
52 : base::TimeTicks::Now(); | 56 : base::TimeTicks::Now(); |
53 } | 57 } |
54 | 58 |
55 void SetEventTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) { | 59 void SetEventTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) { |
60 DCHECK(!g_no_mock_time); | |
56 g_tick_clock.Get() = std::move(tick_clock); | 61 g_tick_clock.Get() = std::move(tick_clock); |
57 } | 62 } |
58 | 63 |
59 double EventTimeStampToSeconds(base::TimeTicks time_stamp) { | 64 double EventTimeStampToSeconds(base::TimeTicks time_stamp) { |
60 return (time_stamp - base::TimeTicks()).InSecondsF(); | 65 return (time_stamp - base::TimeTicks()).InSecondsF(); |
61 } | 66 } |
62 | 67 |
63 base::TimeTicks EventTimeStampFromSeconds(double time_stamp_seconds) { | 68 base::TimeTicks EventTimeStampFromSeconds(double time_stamp_seconds) { |
64 return base::TimeTicks() + base::TimeDelta::FromSecondsD(time_stamp_seconds); | 69 return base::TimeTicks() + base::TimeDelta::FromSecondsD(time_stamp_seconds); |
65 } | 70 } |
66 | 71 |
67 } // namespace ui | 72 } // namespace ui |
68 | 73 |
OLD | NEW |