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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 201 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
202 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, | 202 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, |
203 ui::EF_NONE); | 203 ui::EF_NONE); |
204 OnEvent(&mouse_event); | 204 OnEvent(&mouse_event); |
205 EXPECT_FALSE(mouse_event.handled()); | 205 EXPECT_FALSE(mouse_event.handled()); |
206 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 206 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
207 detector_->last_activity_time().ToInternalValue()); | 207 detector_->last_activity_time().ToInternalValue()); |
208 EXPECT_EQ(0, observer_->num_invocations()); | 208 EXPECT_EQ(0, observer_->num_invocations()); |
209 } | 209 } |
210 | 210 |
| 211 // Checks that observers are notified about externally-reported user activity. |
| 212 TEST_F(UserActivityDetectorTest, HandleExternalUserActivity) { |
| 213 detector_->HandleExternalUserActivity(); |
| 214 EXPECT_EQ(1, observer_->num_invocations()); |
| 215 observer_->reset_stats(); |
| 216 |
| 217 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds( |
| 218 UserActivityDetector::kNotifyIntervalMs); |
| 219 AdvanceTime(advance_delta); |
| 220 detector_->HandleExternalUserActivity(); |
| 221 EXPECT_EQ(1, observer_->num_invocations()); |
| 222 observer_->reset_stats(); |
| 223 |
| 224 base::TimeDelta half_advance_delta = base::TimeDelta::FromMilliseconds( |
| 225 UserActivityDetector::kNotifyIntervalMs / 2); |
| 226 AdvanceTime(half_advance_delta); |
| 227 detector_->HandleExternalUserActivity(); |
| 228 EXPECT_EQ(0, observer_->num_invocations()); |
| 229 |
| 230 AdvanceTime(half_advance_delta); |
| 231 detector_->HandleExternalUserActivity(); |
| 232 EXPECT_EQ(1, observer_->num_invocations()); |
| 233 } |
| 234 |
211 } // namespace ui | 235 } // namespace ui |
OLD | NEW |