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, | 142 0, 0, ui::EF_NONE, |
143 0, | |
144 ui::EF_NONE, | |
145 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), | 143 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), |
146 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 144 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0)); |
147 detector_->OnGestureEvent(&gesture_event); | 145 detector_->OnGestureEvent(&gesture_event); |
148 EXPECT_FALSE(gesture_event.handled()); | 146 EXPECT_FALSE(gesture_event.handled()); |
149 EXPECT_EQ(now_.ToInternalValue(), | 147 EXPECT_EQ(now_.ToInternalValue(), |
150 detector_->last_activity_time().ToInternalValue()); | 148 detector_->last_activity_time().ToInternalValue()); |
151 EXPECT_EQ(1, observer_->num_invocations()); | 149 EXPECT_EQ(1, observer_->num_invocations()); |
152 observer_->reset_stats(); | 150 observer_->reset_stats(); |
153 } | 151 } |
154 | 152 |
155 // Checks that observers aren't notified too frequently. | 153 // Checks that observers aren't notified too frequently. |
156 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { | 154 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED, | 191 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED, |
194 ui::EF_NONE); | 192 ui::EF_NONE); |
195 detector_->OnMouseEvent(&mouse_event); | 193 detector_->OnMouseEvent(&mouse_event); |
196 EXPECT_FALSE(mouse_event.handled()); | 194 EXPECT_FALSE(mouse_event.handled()); |
197 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 195 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
198 detector_->last_activity_time().ToInternalValue()); | 196 detector_->last_activity_time().ToInternalValue()); |
199 EXPECT_EQ(0, observer_->num_invocations()); | 197 EXPECT_EQ(0, observer_->num_invocations()); |
200 } | 198 } |
201 | 199 |
202 } // namespace wm | 200 } // namespace wm |
OLD | NEW |