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> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 void SessionLengthLimiterTest::TearDown() { | 98 void SessionLengthLimiterTest::TearDown() { |
99 session_length_limiter_.reset(); | 99 session_length_limiter_.reset(); |
100 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); | 100 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); |
101 } | 101 } |
102 | 102 |
103 void SessionLengthLimiterTest::SetSessionUserActivitySeenPref( | 103 void SessionLengthLimiterTest::SetSessionUserActivitySeenPref( |
104 bool user_activity_seen) { | 104 bool user_activity_seen) { |
105 local_state_.SetUserPref(prefs::kSessionUserActivitySeen, | 105 local_state_.SetUserPref(prefs::kSessionUserActivitySeen, |
106 new base::FundamentalValue(user_activity_seen)); | 106 new base::Value(user_activity_seen)); |
107 } | 107 } |
108 | 108 |
109 void SessionLengthLimiterTest::ClearSessionUserActivitySeenPref() { | 109 void SessionLengthLimiterTest::ClearSessionUserActivitySeenPref() { |
110 local_state_.ClearPref(prefs::kSessionUserActivitySeen); | 110 local_state_.ClearPref(prefs::kSessionUserActivitySeen); |
111 } | 111 } |
112 | 112 |
113 bool SessionLengthLimiterTest::IsSessionUserActivitySeenPrefSet() { | 113 bool SessionLengthLimiterTest::IsSessionUserActivitySeenPrefSet() { |
114 return local_state_.HasPrefPath(prefs::kSessionUserActivitySeen); | 114 return local_state_.HasPrefPath(prefs::kSessionUserActivitySeen); |
115 } | 115 } |
116 | 116 |
(...skipping 19 matching lines...) Expand all Loading... |
136 } | 136 } |
137 | 137 |
138 base::TimeTicks SessionLengthLimiterTest::GetSessionStartTimePref() { | 138 base::TimeTicks SessionLengthLimiterTest::GetSessionStartTimePref() { |
139 EXPECT_TRUE(IsSessionStartTimePrefSet()); | 139 EXPECT_TRUE(IsSessionStartTimePrefSet()); |
140 return base::TimeTicks::FromInternalValue( | 140 return base::TimeTicks::FromInternalValue( |
141 local_state_.GetInt64(prefs::kSessionStartTime)); | 141 local_state_.GetInt64(prefs::kSessionStartTime)); |
142 } | 142 } |
143 | 143 |
144 void SessionLengthLimiterTest::SetSessionLengthLimitPref( | 144 void SessionLengthLimiterTest::SetSessionLengthLimitPref( |
145 const base::TimeDelta& session_length_limit) { | 145 const base::TimeDelta& session_length_limit) { |
146 local_state_.SetUserPref(prefs::kSessionLengthLimit, | 146 local_state_.SetUserPref( |
147 new base::FundamentalValue( | 147 prefs::kSessionLengthLimit, |
148 static_cast<int>(session_length_limit.InMilliseconds()))); | 148 new base::Value(static_cast<int>(session_length_limit.InMilliseconds()))); |
149 UpdateSessionStartTimeIfWaitingForUserActivity(); | 149 UpdateSessionStartTimeIfWaitingForUserActivity(); |
150 } | 150 } |
151 | 151 |
152 void SessionLengthLimiterTest::ClearSessionLengthLimitPref() { | 152 void SessionLengthLimiterTest::ClearSessionLengthLimitPref() { |
153 local_state_.RemoveUserPref(prefs::kSessionLengthLimit); | 153 local_state_.RemoveUserPref(prefs::kSessionLengthLimit); |
154 UpdateSessionStartTimeIfWaitingForUserActivity(); | 154 UpdateSessionStartTimeIfWaitingForUserActivity(); |
155 } | 155 } |
156 | 156 |
157 void SessionLengthLimiterTest::SetWaitForInitialUserActivityPref( | 157 void SessionLengthLimiterTest::SetWaitForInitialUserActivityPref( |
158 bool wait_for_initial_user_activity) { | 158 bool wait_for_initial_user_activity) { |
159 UpdateSessionStartTimeIfWaitingForUserActivity(); | 159 UpdateSessionStartTimeIfWaitingForUserActivity(); |
160 local_state_.SetUserPref( | 160 local_state_.SetUserPref(prefs::kSessionWaitForInitialUserActivity, |
161 prefs::kSessionWaitForInitialUserActivity, | 161 new base::Value(wait_for_initial_user_activity)); |
162 new base::FundamentalValue(wait_for_initial_user_activity)); | |
163 } | 162 } |
164 | 163 |
165 void SessionLengthLimiterTest::SimulateUserActivity() { | 164 void SessionLengthLimiterTest::SimulateUserActivity() { |
166 if (session_length_limiter_) | 165 if (session_length_limiter_) |
167 session_length_limiter_->OnUserActivity(NULL); | 166 session_length_limiter_->OnUserActivity(NULL); |
168 UpdateSessionStartTimeIfWaitingForUserActivity(); | 167 UpdateSessionStartTimeIfWaitingForUserActivity(); |
169 user_activity_seen_ = true; | 168 user_activity_seen_ = true; |
170 } | 169 } |
171 | 170 |
172 void SessionLengthLimiterTest:: | 171 void SessionLengthLimiterTest:: |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); | 731 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); |
733 | 732 |
734 // Remove the session length limit. | 733 // Remove the session length limit. |
735 ClearSessionLengthLimitPref(); | 734 ClearSessionLengthLimitPref(); |
736 | 735 |
737 // Verify that no timer fires to terminate the session. | 736 // Verify that no timer fires to terminate the session. |
738 runner_->FastForwardUntilNoTasksRemain(); | 737 runner_->FastForwardUntilNoTasksRemain(); |
739 } | 738 } |
740 | 739 |
741 } // namespace chromeos | 740 } // namespace chromeos |
OLD | NEW |