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/policy/device_status_collector.h" | 5 #include "chrome/browser/policy/device_status_collector.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "chrome/browser/idle.h" | 9 #include "chrome/browser/idle.h" |
10 #include "chrome/browser/chromeos/cros_settings.h" | 10 #include "chrome/browser/chromeos/cros_settings.h" |
11 #include "chrome/browser/chromeos/cros_settings_names.h" | 11 #include "chrome/browser/chromeos/cros_settings_names.h" |
12 #include "chrome/browser/chromeos/cros_settings_provider.h" | 12 #include "chrome/browser/chromeos/cros_settings_provider.h" |
13 #include "chrome/browser/chromeos/stub_cros_settings_provider.h" | 13 #include "chrome/browser/chromeos/stub_cros_settings_provider.h" |
14 #include "chrome/browser/chromeos/system/mock_statistics_provider.h" | 14 #include "chrome/browser/chromeos/system/mock_statistics_provider.h" |
15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/test/base/testing_pref_service.h" | 17 #include "chrome/test/base/testing_pref_service.h" |
18 #include "content/test/test_browser_thread.h" | 18 #include "content/test/test_browser_thread.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 using base::TimeDelta; | 22 using base::TimeDelta; |
23 using base::Time; | 23 using base::Time; |
24 | 24 |
25 namespace em = enterprise_management; | 25 namespace em = enterprise_management; |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
| 29 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000; |
| 30 |
29 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { | 31 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { |
30 public: | 32 public: |
31 TestingDeviceStatusCollector( | 33 TestingDeviceStatusCollector( |
32 PrefService* local_state, | 34 PrefService* local_state, |
33 chromeos::system::StatisticsProvider* provider) | 35 chromeos::system::StatisticsProvider* provider) |
34 : policy::DeviceStatusCollector(local_state, provider), | 36 : policy::DeviceStatusCollector(local_state, provider), |
35 local_state_(local_state), | 37 local_state_(local_state) { |
36 baseline_time_(Time::Now()) { | 38 // Set the baseline time to a fixed value (1 AM) to prevent test flakiness |
| 39 // due to a single activity period spanning two days. |
| 40 SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1)); |
37 } | 41 } |
38 | 42 |
39 void Simulate(IdleState* states, int len) { | 43 void Simulate(IdleState* states, int len) { |
40 for (int i = 0; i < len; i++) | 44 for (int i = 0; i < len; i++) |
41 IdleStateCallback(states[i]); | 45 IdleStateCallback(states[i]); |
42 } | 46 } |
43 | 47 |
44 void SimulateWithSleep(IdleState* states, int len, int ) { | 48 void set_max_stored_past_activity_days(unsigned int value) { |
45 for (int i = 0; i < len; i++) | 49 max_stored_past_activity_days_ = value; |
46 IdleStateCallback(states[i]); | |
47 } | 50 } |
48 | 51 |
49 void set_max_stored_active_periods(unsigned int value) { | 52 void set_max_stored_future_activity_days(unsigned int value) { |
50 max_stored_active_periods_ = value; | 53 max_stored_future_activity_days_ = value; |
| 54 } |
| 55 |
| 56 // Reset the baseline time. |
| 57 void SetBaselineTime(Time time) { |
| 58 baseline_time_ = time; |
| 59 baseline_offset_periods_ = 0; |
51 } | 60 } |
52 | 61 |
53 protected: | 62 protected: |
54 virtual void CheckIdleState() OVERRIDE { | 63 virtual void CheckIdleState() OVERRIDE { |
55 // This should never be called in testing, as it results in a dbus call. | 64 // This should never be called in testing, as it results in a dbus call. |
56 NOTREACHED(); | 65 NOTREACHED(); |
57 } | 66 } |
58 | 67 |
59 // Each time this is called, returns a time that is a fixed increment | 68 // Each time this is called, returns a time that is a fixed increment |
60 // later than the previous time. | 69 // later than the previous time. |
61 virtual Time GetCurrentTime() OVERRIDE { | 70 virtual Time GetCurrentTime() OVERRIDE { |
62 static int call_count = 0; | 71 int poll_interval = policy::DeviceStatusCollector::kPollIntervalSeconds; |
63 return baseline_time_ + TimeDelta::FromSeconds( | 72 return baseline_time_ + |
64 policy::DeviceStatusCollector::kPollIntervalSeconds * call_count++); | 73 TimeDelta::FromSeconds(poll_interval * baseline_offset_periods_++); |
65 } | 74 } |
66 | 75 |
67 private: | 76 private: |
68 PrefService* local_state_; | 77 PrefService* local_state_; |
69 | 78 |
70 // Baseline time for the fake times returned from GetCurrentTime(). | 79 // Baseline time for the fake times returned from GetCurrentTime(). |
71 // It doesn't really matter what this is, as long as it stays the same over | |
72 // the lifetime of the object. | |
73 Time baseline_time_; | 80 Time baseline_time_; |
| 81 |
| 82 // The number of simulated periods since the baseline time. |
| 83 int baseline_offset_periods_; |
74 }; | 84 }; |
75 | 85 |
76 // Return the total number of active milliseconds contained in a device | 86 // Return the total number of active milliseconds contained in a device |
77 // status report. | 87 // status report. |
78 int64 GetActiveMilliseconds(em::DeviceStatusReportRequest& status) { | 88 int64 GetActiveMilliseconds(em::DeviceStatusReportRequest& status) { |
79 int64 active_milliseconds = 0; | 89 int64 active_milliseconds = 0; |
80 for (int i = 0; i < status.active_time_size(); i++) { | 90 for (int i = 0; i < status.active_period_size(); i++) { |
81 const em::TimePeriod& period = status.active_time(i); | 91 active_milliseconds += status.active_period(i).active_duration(); |
82 active_milliseconds += period.end_timestamp() - period.start_timestamp(); | |
83 } | 92 } |
84 return active_milliseconds; | 93 return active_milliseconds; |
85 } | 94 } |
86 | 95 |
87 } // namespace | 96 } // namespace |
88 | 97 |
89 namespace policy { | 98 namespace policy { |
90 | 99 |
91 using ::testing::_; | 100 using ::testing::_; |
92 using ::testing::NotNull; | 101 using ::testing::NotNull; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 TEST_F(DeviceStatusCollectorTest, AllIdle) { | 154 TEST_F(DeviceStatusCollectorTest, AllIdle) { |
146 IdleState test_states[] = { | 155 IdleState test_states[] = { |
147 IDLE_STATE_IDLE, | 156 IDLE_STATE_IDLE, |
148 IDLE_STATE_IDLE, | 157 IDLE_STATE_IDLE, |
149 IDLE_STATE_IDLE | 158 IDLE_STATE_IDLE |
150 }; | 159 }; |
151 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 160 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
152 | 161 |
153 // Test reporting with no data. | 162 // Test reporting with no data. |
154 status_collector_.GetStatus(&status_); | 163 status_collector_.GetStatus(&status_); |
155 EXPECT_EQ(0, status_.active_time_size()); | 164 EXPECT_EQ(0, status_.active_period_size()); |
156 EXPECT_EQ(0, GetActiveMilliseconds(status_)); | 165 EXPECT_EQ(0, GetActiveMilliseconds(status_)); |
157 | 166 |
158 // Test reporting with a single idle sample. | 167 // Test reporting with a single idle sample. |
159 status_collector_.Simulate(test_states, 1); | 168 status_collector_.Simulate(test_states, 1); |
160 status_collector_.GetStatus(&status_); | 169 status_collector_.GetStatus(&status_); |
161 EXPECT_EQ(0, status_.active_time_size()); | 170 EXPECT_EQ(0, status_.active_period_size()); |
162 EXPECT_EQ(0, GetActiveMilliseconds(status_)); | 171 EXPECT_EQ(0, GetActiveMilliseconds(status_)); |
163 | 172 |
164 // Test reporting with multiple consecutive idle samples. | 173 // Test reporting with multiple consecutive idle samples. |
165 status_collector_.Simulate(test_states, | 174 status_collector_.Simulate(test_states, |
166 sizeof(test_states) / sizeof(IdleState)); | 175 sizeof(test_states) / sizeof(IdleState)); |
167 status_collector_.GetStatus(&status_); | 176 status_collector_.GetStatus(&status_); |
168 EXPECT_EQ(0, status_.active_time_size()); | 177 EXPECT_EQ(0, status_.active_period_size()); |
169 EXPECT_EQ(0, GetActiveMilliseconds(status_)); | 178 EXPECT_EQ(0, GetActiveMilliseconds(status_)); |
170 } | 179 } |
171 | 180 |
172 TEST_F(DeviceStatusCollectorTest, AllActive) { | 181 TEST_F(DeviceStatusCollectorTest, AllActive) { |
173 IdleState test_states[] = { | 182 IdleState test_states[] = { |
174 IDLE_STATE_ACTIVE, | 183 IDLE_STATE_ACTIVE, |
175 IDLE_STATE_ACTIVE, | 184 IDLE_STATE_ACTIVE, |
176 IDLE_STATE_ACTIVE | 185 IDLE_STATE_ACTIVE |
177 }; | 186 }; |
178 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 187 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
179 | 188 |
180 // Test a single active sample. | 189 // Test a single active sample. |
181 status_collector_.Simulate(test_states, 1); | 190 status_collector_.Simulate(test_states, 1); |
182 status_collector_.GetStatus(&status_); | 191 status_collector_.GetStatus(&status_); |
183 EXPECT_EQ(1, status_.active_time_size()); | 192 EXPECT_EQ(1, status_.active_period_size()); |
184 EXPECT_EQ(1 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); | 193 EXPECT_EQ(1 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); |
185 status_.clear_active_time(); // Clear the result protobuf. | 194 status_.clear_active_period(); // Clear the result protobuf. |
186 | 195 |
187 // Test multiple consecutive active samples -- they should be coalesced | 196 // Test multiple consecutive active samples. |
188 // into a single active period. | |
189 status_collector_.Simulate(test_states, | 197 status_collector_.Simulate(test_states, |
190 sizeof(test_states) / sizeof(IdleState)); | 198 sizeof(test_states) / sizeof(IdleState)); |
191 status_collector_.GetStatus(&status_); | 199 status_collector_.GetStatus(&status_); |
192 EXPECT_EQ(1, status_.active_time_size()); | 200 EXPECT_EQ(1, status_.active_period_size()); |
193 EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); | 201 EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); |
194 } | 202 } |
195 | 203 |
196 TEST_F(DeviceStatusCollectorTest, MixedStates) { | 204 TEST_F(DeviceStatusCollectorTest, MixedStates) { |
197 IdleState test_states[] = { | 205 IdleState test_states[] = { |
198 IDLE_STATE_ACTIVE, | 206 IDLE_STATE_ACTIVE, |
199 IDLE_STATE_IDLE, | 207 IDLE_STATE_IDLE, |
200 IDLE_STATE_ACTIVE, | 208 IDLE_STATE_ACTIVE, |
201 IDLE_STATE_ACTIVE, | 209 IDLE_STATE_ACTIVE, |
202 IDLE_STATE_IDLE, | 210 IDLE_STATE_IDLE, |
203 IDLE_STATE_IDLE, | 211 IDLE_STATE_IDLE, |
204 IDLE_STATE_ACTIVE | 212 IDLE_STATE_ACTIVE |
205 }; | 213 }; |
206 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 214 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
207 status_collector_.Simulate(test_states, | 215 status_collector_.Simulate(test_states, |
208 sizeof(test_states) / sizeof(IdleState)); | 216 sizeof(test_states) / sizeof(IdleState)); |
209 status_collector_.GetStatus(&status_); | 217 status_collector_.GetStatus(&status_); |
210 EXPECT_EQ(3, status_.active_time_size()); | |
211 EXPECT_EQ(4 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); | 218 EXPECT_EQ(4 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); |
212 } | 219 } |
213 | 220 |
214 TEST_F(DeviceStatusCollectorTest, StateKeptInPref) { | 221 TEST_F(DeviceStatusCollectorTest, StateKeptInPref) { |
215 IdleState test_states[] = { | 222 IdleState test_states[] = { |
216 IDLE_STATE_ACTIVE, | 223 IDLE_STATE_ACTIVE, |
217 IDLE_STATE_IDLE, | 224 IDLE_STATE_IDLE, |
218 IDLE_STATE_ACTIVE, | 225 IDLE_STATE_ACTIVE, |
219 IDLE_STATE_ACTIVE, | 226 IDLE_STATE_ACTIVE, |
220 IDLE_STATE_IDLE, | 227 IDLE_STATE_IDLE, |
221 IDLE_STATE_IDLE | 228 IDLE_STATE_IDLE |
222 }; | 229 }; |
223 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 230 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
224 status_collector_.Simulate(test_states, | 231 status_collector_.Simulate(test_states, |
225 sizeof(test_states) / sizeof(IdleState)); | 232 sizeof(test_states) / sizeof(IdleState)); |
226 | 233 |
227 // Process the list a second time with a different collector. | 234 // Process the list a second time with a different collector. |
228 // It should be able to count the active periods found by the first | 235 // It should be able to count the active periods found by the first |
229 // collector, because the results are stored in a pref. | 236 // collector, because the results are stored in a pref. |
230 TestingDeviceStatusCollector second_collector(&prefs_, | 237 TestingDeviceStatusCollector second_collector(&prefs_, |
231 &statistics_provider_); | 238 &statistics_provider_); |
232 second_collector.Simulate(test_states, | 239 second_collector.Simulate(test_states, |
233 sizeof(test_states) / sizeof(IdleState)); | 240 sizeof(test_states) / sizeof(IdleState)); |
234 | 241 |
235 second_collector.GetStatus(&status_); | 242 second_collector.GetStatus(&status_); |
236 EXPECT_EQ(4, status_.active_time_size()); | |
237 EXPECT_EQ(6 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); | 243 EXPECT_EQ(6 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); |
238 } | 244 } |
239 | 245 |
240 TEST_F(DeviceStatusCollectorTest, Times) { | 246 TEST_F(DeviceStatusCollectorTest, Times) { |
241 IdleState test_states[] = { | 247 IdleState test_states[] = { |
242 IDLE_STATE_ACTIVE, | 248 IDLE_STATE_ACTIVE, |
243 IDLE_STATE_IDLE, | 249 IDLE_STATE_IDLE, |
244 IDLE_STATE_ACTIVE, | 250 IDLE_STATE_ACTIVE, |
245 IDLE_STATE_ACTIVE, | 251 IDLE_STATE_ACTIVE, |
246 IDLE_STATE_IDLE, | 252 IDLE_STATE_IDLE, |
247 IDLE_STATE_IDLE | 253 IDLE_STATE_IDLE |
248 }; | 254 }; |
249 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 255 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
250 status_collector_.Simulate(test_states, | 256 status_collector_.Simulate(test_states, |
251 sizeof(test_states) / sizeof(IdleState)); | 257 sizeof(test_states) / sizeof(IdleState)); |
252 status_collector_.GetStatus(&status_); | 258 status_collector_.GetStatus(&status_); |
253 EXPECT_EQ(2, status_.active_time_size()); | |
254 | |
255 EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); | 259 EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_)); |
256 } | 260 } |
257 | 261 |
258 TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) { | 262 TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) { |
259 IdleState test_states[] = { | 263 IdleState test_states[] = { |
260 IDLE_STATE_ACTIVE, | 264 IDLE_STATE_ACTIVE, |
261 IDLE_STATE_IDLE | 265 IDLE_STATE_IDLE |
262 }; | 266 }; |
263 unsigned int max_periods = 10; | 267 unsigned int max_days = 10; |
264 | 268 |
265 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); | 269 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
266 status_collector_.set_max_stored_active_periods(max_periods); | 270 status_collector_.set_max_stored_past_activity_days(max_days - 1); |
| 271 status_collector_.set_max_stored_future_activity_days(1); |
| 272 Time baseline = Time::Now().LocalMidnight(); |
267 | 273 |
268 // Simulate 12 active periods. | 274 // Simulate 12 active periods. |
269 for (int i = 0; i < 12; i++) { | 275 for (int i = 0; i < static_cast<int>(max_days) + 2; i++) { |
270 status_collector_.Simulate(test_states, | 276 status_collector_.Simulate(test_states, |
271 sizeof(test_states) / sizeof(IdleState)); | 277 sizeof(test_states) / sizeof(IdleState)); |
| 278 // Advance the simulated clock by a day. |
| 279 baseline += TimeDelta::FromDays(1); |
| 280 status_collector_.SetBaselineTime(baseline); |
272 } | 281 } |
273 | 282 |
274 // Check that we don't exceed the max number of periods. | 283 // Check that we don't exceed the max number of periods. |
275 status_collector_.GetStatus(&status_); | 284 status_collector_.GetStatus(&status_); |
276 EXPECT_EQ(static_cast<int>(max_periods), status_.active_time_size()); | 285 EXPECT_EQ(static_cast<int>(max_days), status_.active_period_size()); |
| 286 |
| 287 // Simulate some future times. |
| 288 for (int i = 0; i < static_cast<int>(max_days) + 2; i++) { |
| 289 status_collector_.Simulate(test_states, |
| 290 sizeof(test_states) / sizeof(IdleState)); |
| 291 // Advance the simulated clock by a day. |
| 292 baseline += TimeDelta::FromDays(1); |
| 293 status_collector_.SetBaselineTime(baseline); |
| 294 } |
| 295 // Set the clock back so the previous simulated times are in the future. |
| 296 baseline -= TimeDelta::FromDays(20); |
| 297 status_collector_.SetBaselineTime(baseline); |
| 298 |
| 299 // Collect one more data point to trigger pruning. |
| 300 status_collector_.Simulate(test_states, 1); |
| 301 |
| 302 // Check that we don't exceed the max number of periods. |
| 303 status_.clear_active_period(); |
| 304 status_collector_.GetStatus(&status_); |
| 305 EXPECT_LT(status_.active_period_size(), static_cast<int>(max_days)); |
277 } | 306 } |
278 | 307 |
279 TEST_F(DeviceStatusCollectorTest, ActivityTimesDisabledByDefault) { | 308 TEST_F(DeviceStatusCollectorTest, ActivityTimesDisabledByDefault) { |
280 // If the pref for collecting device activity times isn't explicitly turned | 309 // If the pref for collecting device activity times isn't explicitly turned |
281 // on, no data on activity times should be reported. | 310 // on, no data on activity times should be reported. |
282 | 311 |
283 IdleState test_states[] = { | 312 IdleState test_states[] = { |
284 IDLE_STATE_ACTIVE, | 313 IDLE_STATE_ACTIVE, |
285 IDLE_STATE_ACTIVE, | 314 IDLE_STATE_ACTIVE, |
286 IDLE_STATE_ACTIVE | 315 IDLE_STATE_ACTIVE |
287 }; | 316 }; |
288 status_collector_.Simulate(test_states, | 317 status_collector_.Simulate(test_states, |
289 sizeof(test_states) / sizeof(IdleState)); | 318 sizeof(test_states) / sizeof(IdleState)); |
290 status_collector_.GetStatus(&status_); | 319 status_collector_.GetStatus(&status_); |
291 EXPECT_EQ(0, status_.active_time_size()); | 320 EXPECT_EQ(0, status_.active_period_size()); |
292 EXPECT_EQ(0, GetActiveMilliseconds(status_)); | 321 EXPECT_EQ(0, GetActiveMilliseconds(status_)); |
293 } | 322 } |
294 | 323 |
| 324 TEST_F(DeviceStatusCollectorTest, ActivityCrossingMidnight) { |
| 325 IdleState test_states[] = { |
| 326 IDLE_STATE_ACTIVE |
| 327 }; |
| 328 cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true); |
| 329 |
| 330 // Set the baseline time to 10 seconds after midnight. |
| 331 status_collector_.SetBaselineTime( |
| 332 Time::Now().LocalMidnight() + TimeDelta::FromSeconds(10)); |
| 333 |
| 334 status_collector_.Simulate(test_states, 1); |
| 335 status_collector_.GetStatus(&status_); |
| 336 ASSERT_EQ(2, status_.active_period_size()); |
| 337 |
| 338 em::ActiveTimePeriod period0 = status_.active_period(0); |
| 339 em::ActiveTimePeriod period1 = status_.active_period(1); |
| 340 EXPECT_EQ(ActivePeriodMilliseconds() - 10000, period0.active_duration()); |
| 341 EXPECT_EQ(10000, period1.active_duration()); |
| 342 |
| 343 em::TimePeriod time_period0 = period0.time_period(); |
| 344 em::TimePeriod time_period1 = period1.time_period(); |
| 345 |
| 346 EXPECT_EQ(time_period0.end_timestamp(), time_period1.start_timestamp()); |
| 347 |
| 348 // Ensure that the start and end times for the period are a day apart. |
| 349 EXPECT_EQ(time_period0.end_timestamp() - time_period0.start_timestamp(), |
| 350 kMillisecondsPerDay); |
| 351 EXPECT_EQ(time_period1.end_timestamp() - time_period1.start_timestamp(), |
| 352 kMillisecondsPerDay); |
| 353 } |
| 354 |
295 TEST_F(DeviceStatusCollectorTest, DevSwitchBootMode) { | 355 TEST_F(DeviceStatusCollectorTest, DevSwitchBootMode) { |
296 // Test that boot mode data is not reported if the pref is not turned on. | 356 // Test that boot mode data is not reported if the pref is not turned on. |
297 status_collector_.GetStatus(&status_); | 357 status_collector_.GetStatus(&status_); |
298 EXPECT_EQ(false, status_.has_boot_mode()); | 358 EXPECT_EQ(false, status_.has_boot_mode()); |
299 | 359 |
300 EXPECT_CALL(statistics_provider_, | 360 EXPECT_CALL(statistics_provider_, |
301 GetMachineStatistic("devsw_boot", NotNull())) | 361 GetMachineStatistic("devsw_boot", NotNull())) |
302 .WillRepeatedly(DoAll(SetArgPointee<1>("0"), Return(true))); | 362 .WillRepeatedly(DoAll(SetArgPointee<1>("0"), Return(true))); |
303 EXPECT_EQ(false, status_.has_boot_mode()); | 363 EXPECT_EQ(false, status_.has_boot_mode()); |
304 | 364 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 EXPECT_EQ(true, status_.has_os_version()); | 405 EXPECT_EQ(true, status_.has_os_version()); |
346 EXPECT_EQ(true, status_.has_firmware_version()); | 406 EXPECT_EQ(true, status_.has_firmware_version()); |
347 | 407 |
348 // Check that the browser version is not empty. OS version & firmware | 408 // Check that the browser version is not empty. OS version & firmware |
349 // don't have any reasonable values inside the unit test, so those | 409 // don't have any reasonable values inside the unit test, so those |
350 // aren't checked. | 410 // aren't checked. |
351 EXPECT_NE("", status_.browser_version()); | 411 EXPECT_NE("", status_.browser_version()); |
352 } | 412 } |
353 | 413 |
354 } // namespace policy | 414 } // namespace policy |
OLD | NEW |