OLD | NEW |
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> |
| 8 |
7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/base/user_activity/user_activity_observer.h" | 13 #include "ui/base/user_activity/user_activity_observer.h" |
13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
15 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 17 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/events/platform/platform_event_source.h" | 18 #include "ui/events/platform/platform_event_source.h" |
18 #include "ui/gfx/geometry/point.h" | 19 #include "ui/gfx/geometry/point.h" |
19 | 20 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Move |detector_|'s idea of the current time forward by |delta|. | 69 // Move |detector_|'s idea of the current time forward by |delta|. |
69 void AdvanceTime(base::TimeDelta delta) { | 70 void AdvanceTime(base::TimeDelta delta) { |
70 now_ += delta; | 71 now_ += delta; |
71 detector_->set_now_for_test(now_); | 72 detector_->set_now_for_test(now_); |
72 } | 73 } |
73 | 74 |
74 void OnEvent(const ui::Event* event) { | 75 void OnEvent(const ui::Event* event) { |
75 detector_->ProcessReceivedEvent(event); | 76 detector_->ProcessReceivedEvent(event); |
76 } | 77 } |
77 | 78 |
78 scoped_ptr<TestPlatformEventSource> platform_event_source_; | 79 std::unique_ptr<TestPlatformEventSource> platform_event_source_; |
79 scoped_ptr<UserActivityDetector> detector_; | 80 std::unique_ptr<UserActivityDetector> detector_; |
80 scoped_ptr<TestUserActivityObserver> observer_; | 81 std::unique_ptr<TestUserActivityObserver> observer_; |
81 | 82 |
82 base::TimeTicks now_; | 83 base::TimeTicks now_; |
83 | 84 |
84 private: | 85 private: |
85 DISALLOW_COPY_AND_ASSIGN(UserActivityDetectorTest); | 86 DISALLOW_COPY_AND_ASSIGN(UserActivityDetectorTest); |
86 }; | 87 }; |
87 | 88 |
88 // Checks that the observer is notified in response to different types of input | 89 // Checks that the observer is notified in response to different types of input |
89 // events. | 90 // events. |
90 TEST_F(UserActivityDetectorTest, Basic) { | 91 TEST_F(UserActivityDetectorTest, Basic) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, | 206 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, |
206 ui::EF_NONE); | 207 ui::EF_NONE); |
207 OnEvent(&mouse_event); | 208 OnEvent(&mouse_event); |
208 EXPECT_FALSE(mouse_event.handled()); | 209 EXPECT_FALSE(mouse_event.handled()); |
209 EXPECT_EQ(base::TimeTicks().ToInternalValue(), | 210 EXPECT_EQ(base::TimeTicks().ToInternalValue(), |
210 detector_->last_activity_time().ToInternalValue()); | 211 detector_->last_activity_time().ToInternalValue()); |
211 EXPECT_EQ(0, observer_->num_invocations()); | 212 EXPECT_EQ(0, observer_->num_invocations()); |
212 } | 213 } |
213 | 214 |
214 } // namespace ui | 215 } // namespace ui |
OLD | NEW |