| 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 OnEvent(&key_event); | 91 OnEvent(&key_event); |
| 92 EXPECT_FALSE(key_event.handled()); | 92 EXPECT_FALSE(key_event.handled()); |
| 93 EXPECT_EQ(now_.ToInternalValue(), | 93 EXPECT_EQ(now_.ToInternalValue(), |
| 94 detector_->last_activity_time().ToInternalValue()); | 94 detector_->last_activity_time().ToInternalValue()); |
| 95 EXPECT_EQ(1, observer_->num_invocations()); | 95 EXPECT_EQ(1, observer_->num_invocations()); |
| 96 observer_->reset_stats(); | 96 observer_->reset_stats(); |
| 97 | 97 |
| 98 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds( | 98 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds( |
| 99 UserActivityDetector::kNotifyIntervalMs); | 99 UserActivityDetector::kNotifyIntervalMs); |
| 100 AdvanceTime(advance_delta); | 100 AdvanceTime(advance_delta); |
| 101 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 101 ui::MouseEvent mouse_event( |
| 102 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 102 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 103 ui::EF_NONE, ui::EF_NONE, |
| 104 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 103 OnEvent(&mouse_event); | 105 OnEvent(&mouse_event); |
| 104 EXPECT_FALSE(mouse_event.handled()); | 106 EXPECT_FALSE(mouse_event.handled()); |
| 105 EXPECT_EQ(now_.ToInternalValue(), | 107 EXPECT_EQ(now_.ToInternalValue(), |
| 106 detector_->last_activity_time().ToInternalValue()); | 108 detector_->last_activity_time().ToInternalValue()); |
| 107 EXPECT_EQ(1, observer_->num_invocations()); | 109 EXPECT_EQ(1, observer_->num_invocations()); |
| 108 observer_->reset_stats(); | 110 observer_->reset_stats(); |
| 109 | 111 |
| 110 base::TimeTicks time_before_ignore = now_; | 112 base::TimeTicks time_before_ignore = now_; |
| 111 | 113 |
| 112 // Temporarily ignore mouse events when displays are turned on or off. | 114 // Temporarily ignore mouse events when displays are turned on or off. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 AdvanceTime(base::TimeDelta::FromMilliseconds( | 195 AdvanceTime(base::TimeDelta::FromMilliseconds( |
| 194 UserActivityDetector::kNotifyIntervalMs)); | 196 UserActivityDetector::kNotifyIntervalMs)); |
| 195 | 197 |
| 196 OnEvent(&event); | 198 OnEvent(&event); |
| 197 EXPECT_FALSE(event.handled()); | 199 EXPECT_FALSE(event.handled()); |
| 198 EXPECT_EQ(1, observer_->num_invocations()); | 200 EXPECT_EQ(1, observer_->num_invocations()); |
| 199 } | 201 } |
| 200 | 202 |
| 201 // Checks that the detector ignores synthetic mouse events. | 203 // Checks that the detector ignores synthetic mouse events. |
| 202 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { | 204 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { |
| 203 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 205 ui::MouseEvent mouse_event( |
| 204 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, | 206 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 205 ui::EF_NONE); | 207 ui::EF_IS_SYNTHESIZED, ui::EF_NONE, |
| 208 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 206 OnEvent(&mouse_event); | 209 OnEvent(&mouse_event); |
| 207 EXPECT_FALSE(mouse_event.handled()); | 210 EXPECT_FALSE(mouse_event.handled()); |
| 208 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 211 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
| 209 detector_->last_activity_time().ToInternalValue()); | 212 detector_->last_activity_time().ToInternalValue()); |
| 210 EXPECT_EQ(0, observer_->num_invocations()); | 213 EXPECT_EQ(0, observer_->num_invocations()); |
| 211 } | 214 } |
| 212 | 215 |
| 213 } // namespace ui | 216 } // namespace ui |
| OLD | NEW |