OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/user_activity/user_activity_detector.h" | 5 #include "ui/base/user_activity/user_activity_detector.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // After enough time has passed, mouse events should be reported again. | 134 // After enough time has passed, mouse events should be reported again. |
135 AdvanceTime(std::max(kIgnoreMouseTime, advance_delta)); | 135 AdvanceTime(std::max(kIgnoreMouseTime, advance_delta)); |
136 OnEvent(&mouse_event); | 136 OnEvent(&mouse_event); |
137 EXPECT_FALSE(mouse_event.handled()); | 137 EXPECT_FALSE(mouse_event.handled()); |
138 EXPECT_EQ(now_.ToInternalValue(), | 138 EXPECT_EQ(now_.ToInternalValue(), |
139 detector_->last_activity_time().ToInternalValue()); | 139 detector_->last_activity_time().ToInternalValue()); |
140 EXPECT_EQ(1, observer_->num_invocations()); | 140 EXPECT_EQ(1, observer_->num_invocations()); |
141 observer_->reset_stats(); | 141 observer_->reset_stats(); |
142 | 142 |
143 AdvanceTime(advance_delta); | 143 AdvanceTime(advance_delta); |
144 ui::TouchEvent touch_event( | 144 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(), 0, |
145 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); | 145 base::TimeTicks()); |
146 OnEvent(&touch_event); | 146 OnEvent(&touch_event); |
147 EXPECT_FALSE(touch_event.handled()); | 147 EXPECT_FALSE(touch_event.handled()); |
148 EXPECT_EQ(now_.ToInternalValue(), | 148 EXPECT_EQ(now_.ToInternalValue(), |
149 detector_->last_activity_time().ToInternalValue()); | 149 detector_->last_activity_time().ToInternalValue()); |
150 EXPECT_EQ(1, observer_->num_invocations()); | 150 EXPECT_EQ(1, observer_->num_invocations()); |
151 observer_->reset_stats(); | 151 observer_->reset_stats(); |
152 | 152 |
153 AdvanceTime(advance_delta); | 153 AdvanceTime(advance_delta); |
154 ui::GestureEvent gesture_event( | 154 ui::GestureEvent gesture_event(0, 0, ui::EF_NONE, base::TimeTicks::Now(), |
155 0, | 155 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
156 0, | |
157 ui::EF_NONE, | |
158 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), | |
159 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | |
160 OnEvent(&gesture_event); | 156 OnEvent(&gesture_event); |
161 EXPECT_FALSE(gesture_event.handled()); | 157 EXPECT_FALSE(gesture_event.handled()); |
162 EXPECT_EQ(now_.ToInternalValue(), | 158 EXPECT_EQ(now_.ToInternalValue(), |
163 detector_->last_activity_time().ToInternalValue()); | 159 detector_->last_activity_time().ToInternalValue()); |
164 EXPECT_EQ(1, observer_->num_invocations()); | 160 EXPECT_EQ(1, observer_->num_invocations()); |
165 observer_->reset_stats(); | 161 observer_->reset_stats(); |
166 } | 162 } |
167 | 163 |
168 // Checks that observers aren't notified too frequently. | 164 // Checks that observers aren't notified too frequently. |
169 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { | 165 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, | 202 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, |
207 ui::EF_NONE); | 203 ui::EF_NONE); |
208 OnEvent(&mouse_event); | 204 OnEvent(&mouse_event); |
209 EXPECT_FALSE(mouse_event.handled()); | 205 EXPECT_FALSE(mouse_event.handled()); |
210 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 206 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
211 detector_->last_activity_time().ToInternalValue()); | 207 detector_->last_activity_time().ToInternalValue()); |
212 EXPECT_EQ(0, observer_->num_invocations()); | 208 EXPECT_EQ(0, observer_->num_invocations()); |
213 } | 209 } |
214 | 210 |
215 } // namespace ui | 211 } // namespace ui |
OLD | NEW |