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

Side by Side Diff: chrome/browser/chromeos/power/session_length_limiter_unittest.cc

Issue 11759019: Update other unittests to use newly added TestingBrowserProcess::GetGlobal(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simpler codez Created 7 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 | Annotate | Revision Log
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 }; 91 };
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 static_cast<TestingBrowserProcess*>(g_browser_process)-> 101 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
102 SetLocalState(&local_state_);
103 SessionLengthLimiter::RegisterPrefs(&local_state_); 102 SessionLengthLimiter::RegisterPrefs(&local_state_);
104 103
105 delegate_ = new NiceMock<MockSessionLengthLimiterDelegate>; 104 delegate_ = new NiceMock<MockSessionLengthLimiterDelegate>;
106 ON_CALL(*delegate_, GetCurrentTime()) 105 ON_CALL(*delegate_, GetCurrentTime())
107 .WillByDefault(Invoke(this, &SessionLengthLimiterTest::GetCurrentTime)); 106 .WillByDefault(Invoke(this, &SessionLengthLimiterTest::GetCurrentTime));
108 EXPECT_CALL(*delegate_, StopSession()).Times(0); 107 EXPECT_CALL(*delegate_, StopSession()).Times(0);
109 runner_ = new ImmediateSingleThreadTaskRunner; 108 runner_ = new ImmediateSingleThreadTaskRunner;
110 109
111 // Initialize the mock clock to a fixed value, ensuring that timezone 110 // Initialize the mock clock to a fixed value, ensuring that timezone
112 // differences or DST changes do not affect the test. 111 // differences or DST changes do not affect the test.
113 now_ = base::Time::UnixEpoch() + base::TimeDelta::FromDays(40 * 365); 112 now_ = base::Time::UnixEpoch() + base::TimeDelta::FromDays(40 * 365);
114 session_start_time_ = now_; 113 session_start_time_ = now_;
115 } 114 }
116 115
117 virtual void TearDown() { 116 virtual void TearDown() {
118 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL); 117 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
119 } 118 }
120 119
121 void SetSessionStartTimePref(int64 session_start_time) { 120 void SetSessionStartTimePref(int64 session_start_time) {
122 local_state_.SetUserPref(prefs::kSessionStartTime, 121 local_state_.SetUserPref(prefs::kSessionStartTime,
123 base::Value::CreateStringValue( 122 base::Value::CreateStringValue(
124 base::Int64ToString(session_start_time))); 123 base::Int64ToString(session_start_time)));
125 } 124 }
126 125
127 void VerifySessionStartTimePref() { 126 void VerifySessionStartTimePref() {
128 base::Time session_start_time(base::Time::FromInternalValue( 127 base::Time session_start_time(base::Time::FromInternalValue(
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 remaining_.reset(new base::TimeDelta(kZeroTimeDelta)); 374 remaining_.reset(new base::TimeDelta(kZeroTimeDelta));
376 } 375 }
377 376
378 // 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
379 // terminated. 378 // terminated.
380 now_ += kSessionLengthLimitTimerInterval; 379 now_ += kSessionLengthLimitTimerInterval;
381 runner_->RunTasks(); 380 runner_->RunTasks();
382 } 381 }
383 382
384 } // namespace chromeos 383 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils_browsertest.cc ('k') | chrome/browser/chromeos/settings/cros_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698