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

Side by Side Diff: ui/base/user_activity/user_activity_detector_unittest.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 months 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
OLDNEW
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/base/user_activity/user_activity_detector.h" 5 #include "ui/base/user_activity/user_activity_detector.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 OnEvent(&key_event); 93 OnEvent(&key_event);
94 EXPECT_FALSE(key_event.handled()); 94 EXPECT_FALSE(key_event.handled());
95 EXPECT_EQ(now_.ToInternalValue(), 95 EXPECT_EQ(now_.ToInternalValue(),
96 detector_->last_activity_time().ToInternalValue()); 96 detector_->last_activity_time().ToInternalValue());
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 = base::TimeDelta::FromMilliseconds( 100 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds(
101 UserActivityDetector::kNotifyIntervalMs); 101 UserActivityDetector::kNotifyIntervalMs);
102 AdvanceTime(advance_delta); 102 AdvanceTime(advance_delta);
103 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 103 ui::MouseEvent mouse_event(
104 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 104 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
105 ui::EF_NONE, ui::EF_NONE,
106 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
105 OnEvent(&mouse_event); 107 OnEvent(&mouse_event);
106 EXPECT_FALSE(mouse_event.handled()); 108 EXPECT_FALSE(mouse_event.handled());
107 EXPECT_EQ(now_.ToInternalValue(), 109 EXPECT_EQ(now_.ToInternalValue(),
108 detector_->last_activity_time().ToInternalValue()); 110 detector_->last_activity_time().ToInternalValue());
109 EXPECT_EQ(1, observer_->num_invocations()); 111 EXPECT_EQ(1, observer_->num_invocations());
110 observer_->reset_stats(); 112 observer_->reset_stats();
111 113
112 base::TimeTicks time_before_ignore = now_; 114 base::TimeTicks time_before_ignore = now_;
113 115
114 // Temporarily ignore mouse events when displays are turned on or off. 116 // Temporarily ignore mouse events when displays are turned on or off.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 AdvanceTime(base::TimeDelta::FromMilliseconds( 194 AdvanceTime(base::TimeDelta::FromMilliseconds(
193 UserActivityDetector::kNotifyIntervalMs)); 195 UserActivityDetector::kNotifyIntervalMs));
194 196
195 OnEvent(&event); 197 OnEvent(&event);
196 EXPECT_FALSE(event.handled()); 198 EXPECT_FALSE(event.handled());
197 EXPECT_EQ(1, observer_->num_invocations()); 199 EXPECT_EQ(1, observer_->num_invocations());
198 } 200 }
199 201
200 // Checks that the detector ignores synthetic mouse events. 202 // Checks that the detector ignores synthetic mouse events.
201 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { 203 TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) {
202 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 204 ui::MouseEvent mouse_event(
203 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 205 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
204 ui::EF_NONE); 206 ui::EF_IS_SYNTHESIZED, ui::EF_NONE,
207 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
205 OnEvent(&mouse_event); 208 OnEvent(&mouse_event);
206 EXPECT_FALSE(mouse_event.handled()); 209 EXPECT_FALSE(mouse_event.handled());
207 EXPECT_EQ(base::TimeTicks().ToInternalValue(), 210 EXPECT_EQ(base::TimeTicks().ToInternalValue(),
208 detector_->last_activity_time().ToInternalValue()); 211 detector_->last_activity_time().ToInternalValue());
209 EXPECT_EQ(0, observer_->num_invocations()); 212 EXPECT_EQ(0, observer_->num_invocations());
210 } 213 }
211 214
212 // Checks that observers are notified about externally-reported user activity. 215 // Checks that observers are notified about externally-reported user activity.
213 TEST_F(UserActivityDetectorTest, HandleExternalUserActivity) { 216 TEST_F(UserActivityDetectorTest, HandleExternalUserActivity) {
214 detector_->HandleExternalUserActivity(); 217 detector_->HandleExternalUserActivity();
(...skipping 12 matching lines...) Expand all
227 AdvanceTime(half_advance_delta); 230 AdvanceTime(half_advance_delta);
228 detector_->HandleExternalUserActivity(); 231 detector_->HandleExternalUserActivity();
229 EXPECT_EQ(0, observer_->num_invocations()); 232 EXPECT_EQ(0, observer_->num_invocations());
230 233
231 AdvanceTime(half_advance_delta); 234 AdvanceTime(half_advance_delta);
232 detector_->HandleExternalUserActivity(); 235 detector_->HandleExternalUserActivity();
233 EXPECT_EQ(1, observer_->num_invocations()); 236 EXPECT_EQ(1, observer_->num_invocations());
234 } 237 }
235 238
236 } // namespace ui 239 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698