Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: ash/wm/user_activity_detector_unittest.cc

Issue 11592011: events: Update mouse-event handlers to not return EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/user_activity_detector.cc ('k') | ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ash/wm/user_activity_detector.cc ('k') | ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698