| OLD | NEW |
| 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 "chrome/browser/chromeos/session_length_limiter.h" | 5 #include "chrome/browser/chromeos/session_length_limiter.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/test/test_mock_time_task_runner.h" | 12 #include "base/test/test_mock_time_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "components/prefs/testing_pref_service.h" | 17 #include "components/prefs/testing_pref_service.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 scoped_refptr<base::TestMockTimeTaskRunner> runner_; | 73 scoped_refptr<base::TestMockTimeTaskRunner> runner_; |
| 73 base::TimeTicks session_start_time_; | 74 base::TimeTicks session_start_time_; |
| 74 base::TimeTicks session_stop_time_; | 75 base::TimeTicks session_stop_time_; |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 TestingPrefServiceSimple local_state_; | 78 TestingPrefServiceSimple local_state_; |
| 78 bool user_activity_seen_; | 79 bool user_activity_seen_; |
| 79 | 80 |
| 80 MockSessionLengthLimiterDelegate* delegate_; // Owned by | 81 MockSessionLengthLimiterDelegate* delegate_; // Owned by |
| 81 // session_length_limiter_. | 82 // session_length_limiter_. |
| 82 scoped_ptr<SessionLengthLimiter> session_length_limiter_; | 83 std::unique_ptr<SessionLengthLimiter> session_length_limiter_; |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 SessionLengthLimiterTest::SessionLengthLimiterTest() | 86 SessionLengthLimiterTest::SessionLengthLimiterTest() |
| 86 : user_activity_seen_(false), | 87 : user_activity_seen_(false), |
| 87 delegate_(NULL) { | 88 delegate_(NULL) { |
| 88 } | 89 } |
| 89 | 90 |
| 90 void SessionLengthLimiterTest::SetUp() { | 91 void SessionLengthLimiterTest::SetUp() { |
| 91 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 92 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
| 92 SessionLengthLimiter::RegisterPrefs(local_state_.registry()); | 93 SessionLengthLimiter::RegisterPrefs(local_state_.registry()); |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); | 732 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); |
| 732 | 733 |
| 733 // Remove the session length limit. | 734 // Remove the session length limit. |
| 734 ClearSessionLengthLimitPref(); | 735 ClearSessionLengthLimitPref(); |
| 735 | 736 |
| 736 // Verify that no timer fires to terminate the session. | 737 // Verify that no timer fires to terminate the session. |
| 737 runner_->FastForwardUntilNoTasksRemain(); | 738 runner_->FastForwardUntilNoTasksRemain(); |
| 738 } | 739 } |
| 739 | 740 |
| 740 } // namespace chromeos | 741 } // namespace chromeos |
| OLD | NEW |