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/wm/core/user_activity_detector.h" | 5 #include "ui/wm/core/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 "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); | 132 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); |
133 detector_->OnTouchEvent(&touch_event); | 133 detector_->OnTouchEvent(&touch_event); |
134 EXPECT_FALSE(touch_event.handled()); | 134 EXPECT_FALSE(touch_event.handled()); |
135 EXPECT_EQ(now_.ToInternalValue(), | 135 EXPECT_EQ(now_.ToInternalValue(), |
136 detector_->last_activity_time().ToInternalValue()); | 136 detector_->last_activity_time().ToInternalValue()); |
137 EXPECT_EQ(1, observer_->num_invocations()); | 137 EXPECT_EQ(1, observer_->num_invocations()); |
138 observer_->reset_stats(); | 138 observer_->reset_stats(); |
139 | 139 |
140 AdvanceTime(advance_delta); | 140 AdvanceTime(advance_delta); |
141 ui::GestureEvent gesture_event( | 141 ui::GestureEvent gesture_event( |
142 0, 0, ui::EF_NONE, | 142 0, |
| 143 0, |
| 144 ui::EF_NONE, |
143 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), | 145 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), |
144 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0)); | 146 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
145 detector_->OnGestureEvent(&gesture_event); | 147 detector_->OnGestureEvent(&gesture_event); |
146 EXPECT_FALSE(gesture_event.handled()); | 148 EXPECT_FALSE(gesture_event.handled()); |
147 EXPECT_EQ(now_.ToInternalValue(), | 149 EXPECT_EQ(now_.ToInternalValue(), |
148 detector_->last_activity_time().ToInternalValue()); | 150 detector_->last_activity_time().ToInternalValue()); |
149 EXPECT_EQ(1, observer_->num_invocations()); | 151 EXPECT_EQ(1, observer_->num_invocations()); |
150 observer_->reset_stats(); | 152 observer_->reset_stats(); |
151 } | 153 } |
152 | 154 |
153 // Checks that observers aren't notified too frequently. | 155 // Checks that observers aren't notified too frequently. |
154 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { | 156 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED, | 193 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED, |
192 ui::EF_NONE); | 194 ui::EF_NONE); |
193 detector_->OnMouseEvent(&mouse_event); | 195 detector_->OnMouseEvent(&mouse_event); |
194 EXPECT_FALSE(mouse_event.handled()); | 196 EXPECT_FALSE(mouse_event.handled()); |
195 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 197 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
196 detector_->last_activity_time().ToInternalValue()); | 198 detector_->last_activity_time().ToInternalValue()); |
197 EXPECT_EQ(0, observer_->num_invocations()); | 199 EXPECT_EQ(0, observer_->num_invocations()); |
198 } | 200 } |
199 | 201 |
200 } // namespace wm | 202 } // namespace wm |
OLD | NEW |