| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 EXPECT_FALSE(key_event.handled()); | 96 EXPECT_FALSE(key_event.handled()); |
| 97 EXPECT_EQ(1, observer_->num_invocations()); | 97 EXPECT_EQ(1, observer_->num_invocations()); |
| 98 observer_->reset_stats(); | 98 observer_->reset_stats(); |
| 99 | 99 |
| 100 base::TimeDelta advance_delta = | 100 base::TimeDelta advance_delta = |
| 101 base::TimeDelta::FromSeconds(UserActivityDetector::kNotifyIntervalMs); | 101 base::TimeDelta::FromSeconds(UserActivityDetector::kNotifyIntervalMs); |
| 102 AdvanceTime(advance_delta); | 102 AdvanceTime(advance_delta); |
| 103 ui::MouseEvent mouse_event( | 103 ui::MouseEvent mouse_event( |
| 104 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_NONE); | 104 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_NONE); |
| 105 SetEventTarget(window.get(), &mouse_event); | 105 SetEventTarget(window.get(), &mouse_event); |
| 106 EXPECT_FALSE(detector_->OnMouseEvent(&mouse_event)); | 106 detector_->OnMouseEvent(&mouse_event); |
| 107 EXPECT_FALSE(mouse_event.handled()); |
| 107 EXPECT_EQ(1, observer_->num_invocations()); | 108 EXPECT_EQ(1, observer_->num_invocations()); |
| 108 observer_->reset_stats(); | 109 observer_->reset_stats(); |
| 109 | 110 |
| 110 // Ignore one mouse event when all displays are turned off. | 111 // Ignore one mouse event when all displays are turned off. |
| 111 detector_->OnAllOutputsTurnedOff(); | 112 detector_->OnAllOutputsTurnedOff(); |
| 112 AdvanceTime(advance_delta); | 113 AdvanceTime(advance_delta); |
| 113 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnMouseEvent(&mouse_event)); | 114 detector_->OnMouseEvent(&mouse_event); |
| 115 EXPECT_FALSE(mouse_event.handled()); |
| 114 EXPECT_EQ(0, observer_->num_invocations()); | 116 EXPECT_EQ(0, observer_->num_invocations()); |
| 115 observer_->reset_stats(); | 117 observer_->reset_stats(); |
| 116 | 118 |
| 117 AdvanceTime(advance_delta); | 119 AdvanceTime(advance_delta); |
| 118 ui::TouchEvent touch_event( | 120 ui::TouchEvent touch_event( |
| 119 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); | 121 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); |
| 120 SetEventTarget(window.get(), &touch_event); | 122 SetEventTarget(window.get(), &touch_event); |
| 121 detector_->OnTouchEvent(&touch_event); | 123 detector_->OnTouchEvent(&touch_event); |
| 122 EXPECT_FALSE(touch_event.handled()); | 124 EXPECT_FALSE(touch_event.handled()); |
| 123 EXPECT_EQ(1, observer_->num_invocations()); | 125 EXPECT_EQ(1, observer_->num_invocations()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 EXPECT_FALSE(event.handled()); | 174 EXPECT_FALSE(event.handled()); |
| 173 EXPECT_EQ(1, observer_->num_invocations()); | 175 EXPECT_EQ(1, observer_->num_invocations()); |
| 174 } | 176 } |
| 175 | 177 |
| 176 // Checks that the detector ignores synthetic mouse events. | 178 // Checks that the detector ignores synthetic mouse events. |
| 177 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { | 179 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { |
| 178 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); | 180 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); |
| 179 ui::MouseEvent mouse_event( | 181 ui::MouseEvent mouse_event( |
| 180 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED); | 182 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED); |
| 181 SetEventTarget(window.get(), &mouse_event); | 183 SetEventTarget(window.get(), &mouse_event); |
| 182 EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnMouseEvent(&mouse_event)); | 184 detector_->OnMouseEvent(&mouse_event); |
| 185 EXPECT_FALSE(mouse_event.handled()); |
| 183 EXPECT_EQ(0, observer_->num_invocations()); | 186 EXPECT_EQ(0, observer_->num_invocations()); |
| 184 } | 187 } |
| 185 | 188 |
| 186 } // namespace test | 189 } // namespace test |
| 187 } // namespace ash | 190 } // namespace ash |
| OLD | NEW |