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

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

Issue 2639703004: mus: Forward user activity from window server to detector. (Closed)
Patch Set: avoid dereferencing null connector in mash_unittests Created 3 years, 11 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 201 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
202 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 202 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED,
203 ui::EF_NONE); 203 ui::EF_NONE);
204 OnEvent(&mouse_event); 204 OnEvent(&mouse_event);
205 EXPECT_FALSE(mouse_event.handled()); 205 EXPECT_FALSE(mouse_event.handled());
206 EXPECT_EQ(base::TimeTicks().ToInternalValue(), 206 EXPECT_EQ(base::TimeTicks().ToInternalValue(),
207 detector_->last_activity_time().ToInternalValue()); 207 detector_->last_activity_time().ToInternalValue());
208 EXPECT_EQ(0, observer_->num_invocations()); 208 EXPECT_EQ(0, observer_->num_invocations());
209 } 209 }
210 210
211 // Checks that observers are notified about externally-reported user activity.
212 TEST_F(UserActivityDetectorTest, HandleExternalUserActivity) {
213 detector_->HandleExternalUserActivity();
214 EXPECT_EQ(1, observer_->num_invocations());
215 observer_->reset_stats();
216
217 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds(
218 UserActivityDetector::kNotifyIntervalMs);
219 AdvanceTime(advance_delta);
220 detector_->HandleExternalUserActivity();
221 EXPECT_EQ(1, observer_->num_invocations());
222 observer_->reset_stats();
223
224 base::TimeDelta half_advance_delta = base::TimeDelta::FromMilliseconds(
225 UserActivityDetector::kNotifyIntervalMs / 2);
226 AdvanceTime(half_advance_delta);
227 detector_->HandleExternalUserActivity();
228 EXPECT_EQ(0, observer_->num_invocations());
229
230 AdvanceTime(half_advance_delta);
231 detector_->HandleExternalUserActivity();
232 EXPECT_EQ(1, observer_->num_invocations());
233 }
James Cook 2017/01/18 17:01:38 Nice test, easy to read.
234
211 } // namespace ui 235 } // namespace ui
OLDNEW
« ash/mus/user_activity_forwarder.cc ('K') | « ui/base/user_activity/user_activity_detector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698