| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/user_activity_monitor.h" | 5 #include "services/ui/ws/user_activity_monitor.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
| 10 #include "base/test/test_mock_time_task_runner.h" | 10 #include "base/test/test_mock_time_task_runner.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 task_runner_->FastForwardBy(delta); | 85 task_runner_->FastForwardBy(delta); |
| 86 } | 86 } |
| 87 void RunUntilIdle() { task_runner_->RunUntilIdle(); } | 87 void RunUntilIdle() { task_runner_->RunUntilIdle(); } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 // testing::Test: | 90 // testing::Test: |
| 91 void SetUp() override { | 91 void SetUp() override { |
| 92 task_runner_ = make_scoped_refptr(new base::TestMockTimeTaskRunner( | 92 task_runner_ = make_scoped_refptr(new base::TestMockTimeTaskRunner( |
| 93 base::Time::Now(), base::TimeTicks::Now())); | 93 base::Time::Now(), base::TimeTicks::Now())); |
| 94 message_loop_.SetTaskRunner(task_runner_); | 94 message_loop_.SetTaskRunner(task_runner_); |
| 95 monitor_.reset(new UserActivityMonitor(task_runner_->GetMockTickClock())); | 95 monitor_ = |
| 96 base::MakeUnique<UserActivityMonitor>(task_runner_->GetMockTickClock()); |
| 96 } | 97 } |
| 97 | 98 |
| 98 base::MessageLoop message_loop_; | 99 base::MessageLoop message_loop_; |
| 99 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; | 100 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; |
| 100 std::unique_ptr<UserActivityMonitor> monitor_; | 101 std::unique_ptr<UserActivityMonitor> monitor_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(UserActivityMonitorTest); | 103 DISALLOW_COPY_AND_ASSIGN(UserActivityMonitorTest); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 TEST_F(UserActivityMonitorTest, UserActivityObserver) { | 106 TEST_F(UserActivityMonitorTest, UserActivityObserver) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 RunUntilIdle(); | 210 RunUntilIdle(); |
| 210 EXPECT_FALSE(first_observer.GetAndResetIdleState(&idle_state)); | 211 EXPECT_FALSE(first_observer.GetAndResetIdleState(&idle_state)); |
| 211 EXPECT_FALSE(second_observer.GetAndResetIdleState(&idle_state)); | 212 EXPECT_FALSE(second_observer.GetAndResetIdleState(&idle_state)); |
| 212 EXPECT_FALSE(third_observer.GetAndResetIdleState(&idle_state)); | 213 EXPECT_FALSE(third_observer.GetAndResetIdleState(&idle_state)); |
| 213 EXPECT_FALSE(fourth_observer.GetAndResetIdleState(&idle_state)); | 214 EXPECT_FALSE(fourth_observer.GetAndResetIdleState(&idle_state)); |
| 214 } | 215 } |
| 215 | 216 |
| 216 } // namespace test | 217 } // namespace test |
| 217 } // namespace ws | 218 } // namespace ws |
| 218 } // namespace ui | 219 } // namespace ui |
| OLD | NEW |