| 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/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 6 | 6 |
| 7 #include "base/environment.h" | 7 #include "base/environment.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } // namespace | 133 } // namespace |
| 134 | 134 |
| 135 namespace policy { | 135 namespace policy { |
| 136 | 136 |
| 137 // Though it is a unit test, this test is linked with browser_tests so that it | 137 // Though it is a unit test, this test is linked with browser_tests so that it |
| 138 // runs in a separate process. The intention is to avoid overriding the timezone | 138 // runs in a separate process. The intention is to avoid overriding the timezone |
| 139 // environment variable for other tests. | 139 // environment variable for other tests. |
| 140 class DeviceStatusCollectorTest : public testing::Test { | 140 class DeviceStatusCollectorTest : public testing::Test { |
| 141 public: | 141 public: |
| 142 DeviceStatusCollectorTest() | 142 DeviceStatusCollectorTest() |
| 143 : message_loop_(MessageLoop::TYPE_UI), | 143 : message_loop_(base::MessageLoop::TYPE_UI), |
| 144 ui_thread_(content::BrowserThread::UI, &message_loop_), | 144 ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 145 file_thread_(content::BrowserThread::FILE, &message_loop_), | 145 file_thread_(content::BrowserThread::FILE, &message_loop_), |
| 146 io_thread_(content::BrowserThread::IO, &message_loop_) { | 146 io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 147 // Run this test with a well-known timezone so that Time::LocalMidnight() | 147 // Run this test with a well-known timezone so that Time::LocalMidnight() |
| 148 // returns the same values on all machines. | 148 // returns the same values on all machines. |
| 149 scoped_ptr<base::Environment> env(base::Environment::Create()); | 149 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 150 env->SetVar("TZ", "UTC"); | 150 env->SetVar("TZ", "UTC"); |
| 151 | 151 |
| 152 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); | 152 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); |
| 153 | 153 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, | 229 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, |
| 230 location.error_code()); | 230 location.error_code()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 protected: | 233 protected: |
| 234 // Convenience method. | 234 // Convenience method. |
| 235 int64 ActivePeriodMilliseconds() { | 235 int64 ActivePeriodMilliseconds() { |
| 236 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; | 236 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; |
| 237 } | 237 } |
| 238 | 238 |
| 239 MessageLoop message_loop_; | 239 base::MessageLoop message_loop_; |
| 240 content::TestBrowserThread ui_thread_; | 240 content::TestBrowserThread ui_thread_; |
| 241 content::TestBrowserThread file_thread_; | 241 content::TestBrowserThread file_thread_; |
| 242 content::TestBrowserThread io_thread_; | 242 content::TestBrowserThread io_thread_; |
| 243 | 243 |
| 244 TestingPrefServiceSimple prefs_; | 244 TestingPrefServiceSimple prefs_; |
| 245 chromeos::system::MockStatisticsProvider statistics_provider_; | 245 chromeos::system::MockStatisticsProvider statistics_provider_; |
| 246 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 246 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 247 chromeos::ScopedTestCrosSettings test_cros_settings_; | 247 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 248 chromeos::CrosSettings* cros_settings_; | 248 chromeos::CrosSettings* cros_settings_; |
| 249 chromeos::CrosSettingsProvider* device_settings_provider_; | 249 chromeos::CrosSettingsProvider* device_settings_provider_; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 // Check that after enabling location reporting again, an error is reported | 576 // Check that after enabling location reporting again, an error is reported |
| 577 // if no valid fix is available. | 577 // if no valid fix is available. |
| 578 SetMockPositionToReturnNext(invalid_fix); | 578 SetMockPositionToReturnNext(invalid_fix); |
| 579 cros_settings_->SetBoolean(chromeos::kReportDeviceLocation, true); | 579 cros_settings_->SetBoolean(chromeos::kReportDeviceLocation, true); |
| 580 // Allow the new pref to propagate to the status collector. | 580 // Allow the new pref to propagate to the status collector. |
| 581 message_loop_.RunUntilIdle(); | 581 message_loop_.RunUntilIdle(); |
| 582 CheckThatALocationErrorIsReported(); | 582 CheckThatALocationErrorIsReported(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 } // namespace policy | 585 } // namespace policy |
| OLD | NEW |