| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/user_activity_detector.h" | 5 #include "ash/wm/user_activity_detector.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/wm/user_activity_observer.h" | 9 #include "ash/wm/user_activity_observer.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnTouchEvent(&touch_event)); | 120 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnTouchEvent(&touch_event)); |
| 121 EXPECT_EQ(1, observer_->num_invocations()); | 121 EXPECT_EQ(1, observer_->num_invocations()); |
| 122 observer_->reset_stats(); | 122 observer_->reset_stats(); |
| 123 | 123 |
| 124 AdvanceTime(advance_delta); | 124 AdvanceTime(advance_delta); |
| 125 ui::GestureEvent gesture_event( | 125 ui::GestureEvent gesture_event( |
| 126 ui::ET_GESTURE_TAP, 0, 0, ui::EF_NONE, | 126 ui::ET_GESTURE_TAP, 0, 0, ui::EF_NONE, |
| 127 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), | 127 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), |
| 128 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0), 0U); | 128 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0), 0U); |
| 129 SetEventTarget(window.get(), &gesture_event); | 129 SetEventTarget(window.get(), &gesture_event); |
| 130 EXPECT_FALSE(detector_->OnGestureEvent(&gesture_event)); | 130 detector_->OnGestureEvent(&gesture_event); |
| 131 EXPECT_FALSE(gesture_event.handled()); |
| 131 EXPECT_EQ(1, observer_->num_invocations()); | 132 EXPECT_EQ(1, observer_->num_invocations()); |
| 132 observer_->reset_stats(); | 133 observer_->reset_stats(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 // Checks that observers aren't notified too frequently. | 136 // Checks that observers aren't notified too frequently. |
| 136 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { | 137 TEST_F(UserActivityDetectorTest, RateLimitNotifications) { |
| 137 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); | 138 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); |
| 138 | 139 |
| 139 // The observer should be notified about a key event. | 140 // The observer should be notified about a key event. |
| 140 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false); | 141 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 171 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); | 172 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); |
| 172 ui::MouseEvent mouse_event( | 173 ui::MouseEvent mouse_event( |
| 173 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED); | 174 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED); |
| 174 SetEventTarget(window.get(), &mouse_event); | 175 SetEventTarget(window.get(), &mouse_event); |
| 175 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnMouseEvent(&mouse_event)); | 176 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnMouseEvent(&mouse_event)); |
| 176 EXPECT_EQ(0, observer_->num_invocations()); | 177 EXPECT_EQ(0, observer_->num_invocations()); |
| 177 } | 178 } |
| 178 | 179 |
| 179 } // namespace test | 180 } // namespace test |
| 180 } // namespace ash | 181 } // namespace ash |
| OLD | NEW |