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/power/session_length_limiter.h" | 5 #include "chrome/browser/chromeos/power/session_length_limiter.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 } // namespace | 93 } // namespace |
94 | 94 |
95 class SessionLengthLimiterTest : public testing::Test { | 95 class SessionLengthLimiterTest : public testing::Test { |
96 protected: | 96 protected: |
97 SessionLengthLimiterTest() : delegate_(NULL) { | 97 SessionLengthLimiterTest() : delegate_(NULL) { |
98 } | 98 } |
99 | 99 |
100 virtual void SetUp() { | 100 virtual void SetUp() { |
101 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 101 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
102 SessionLengthLimiter::RegisterPrefs(&local_state_); | 102 SessionLengthLimiter::RegisterPrefs(local_state_.registry()); |
103 | 103 |
104 delegate_ = new NiceMock<MockSessionLengthLimiterDelegate>; | 104 delegate_ = new NiceMock<MockSessionLengthLimiterDelegate>; |
105 ON_CALL(*delegate_, GetCurrentTime()) | 105 ON_CALL(*delegate_, GetCurrentTime()) |
106 .WillByDefault(Invoke(this, &SessionLengthLimiterTest::GetCurrentTime)); | 106 .WillByDefault(Invoke(this, &SessionLengthLimiterTest::GetCurrentTime)); |
107 EXPECT_CALL(*delegate_, StopSession()).Times(0); | 107 EXPECT_CALL(*delegate_, StopSession()).Times(0); |
108 runner_ = new ImmediateSingleThreadTaskRunner; | 108 runner_ = new ImmediateSingleThreadTaskRunner; |
109 | 109 |
110 // Initialize the mock clock to a fixed value, ensuring that timezone | 110 // Initialize the mock clock to a fixed value, ensuring that timezone |
111 // differences or DST changes do not affect the test. | 111 // differences or DST changes do not affect the test. |
112 now_ = base::Time::UnixEpoch() + base::TimeDelta::FromDays(40 * 365); | 112 now_ = base::Time::UnixEpoch() + base::TimeDelta::FromDays(40 * 365); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 remaining_.reset(new base::TimeDelta(kZeroTimeDelta)); | 374 remaining_.reset(new base::TimeDelta(kZeroTimeDelta)); |
375 } | 375 } |
376 | 376 |
377 // Check that the next timer tick does not lead to the session being | 377 // Check that the next timer tick does not lead to the session being |
378 // terminated. | 378 // terminated. |
379 now_ += kSessionLengthLimitTimerInterval; | 379 now_ += kSessionLengthLimitTimerInterval; |
380 runner_->RunTasks(); | 380 runner_->RunTasks(); |
381 } | 381 } |
382 | 382 |
383 } // namespace chromeos | 383 } // namespace chromeos |
OLD | NEW |