| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 namespace policy { | 130 namespace policy { |
| 131 | 131 |
| 132 // Though it is a unit test, this test is linked with browser_tests so that it | 132 // Though it is a unit test, this test is linked with browser_tests so that it |
| 133 // runs in a separate process. The intention is to avoid overriding the timezone | 133 // runs in a separate process. The intention is to avoid overriding the timezone |
| 134 // environment variable for other tests. | 134 // environment variable for other tests. |
| 135 class DeviceStatusCollectorTest : public testing::Test { | 135 class DeviceStatusCollectorTest : public testing::Test { |
| 136 public: | 136 public: |
| 137 DeviceStatusCollectorTest() | 137 DeviceStatusCollectorTest() |
| 138 : message_loop_(MessageLoop::TYPE_UI), | 138 : message_loop_(base::MessageLoop::TYPE_UI), |
| 139 ui_thread_(content::BrowserThread::UI, &message_loop_), | 139 ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 140 file_thread_(content::BrowserThread::FILE, &message_loop_), | 140 file_thread_(content::BrowserThread::FILE, &message_loop_), |
| 141 io_thread_(content::BrowserThread::IO, &message_loop_) { | 141 io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 142 // Run this test with a well-known timezone so that Time::LocalMidnight() | 142 // Run this test with a well-known timezone so that Time::LocalMidnight() |
| 143 // returns the same values on all machines. | 143 // returns the same values on all machines. |
| 144 scoped_ptr<base::Environment> env(base::Environment::Create()); | 144 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 145 env->SetVar("TZ", "UTC"); | 145 env->SetVar("TZ", "UTC"); |
| 146 | 146 |
| 147 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); | 147 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); |
| 148 | 148 |
| 149 EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, NotNull())) | 149 EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, NotNull())) |
| 150 .WillRepeatedly(Return(false)); | 150 .WillRepeatedly(Return(false)); |
| 151 | 151 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, | 220 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, |
| 221 location.error_code()); | 221 location.error_code()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 protected: | 224 protected: |
| 225 // Convenience method. | 225 // Convenience method. |
| 226 int64 ActivePeriodMilliseconds() { | 226 int64 ActivePeriodMilliseconds() { |
| 227 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; | 227 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; |
| 228 } | 228 } |
| 229 | 229 |
| 230 MessageLoop message_loop_; | 230 base::MessageLoop message_loop_; |
| 231 content::TestBrowserThread ui_thread_; | 231 content::TestBrowserThread ui_thread_; |
| 232 content::TestBrowserThread file_thread_; | 232 content::TestBrowserThread file_thread_; |
| 233 content::TestBrowserThread io_thread_; | 233 content::TestBrowserThread io_thread_; |
| 234 | 234 |
| 235 TestingPrefServiceSimple prefs_; | 235 TestingPrefServiceSimple prefs_; |
| 236 chromeos::system::MockStatisticsProvider statistics_provider_; | 236 chromeos::system::MockStatisticsProvider statistics_provider_; |
| 237 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 237 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 238 chromeos::ScopedTestCrosSettings test_cros_settings_; | 238 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 239 chromeos::CrosSettings* cros_settings_; | 239 chromeos::CrosSettings* cros_settings_; |
| 240 chromeos::CrosSettingsProvider* device_settings_provider_; | 240 chromeos::CrosSettingsProvider* device_settings_provider_; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // Check that after enabling location reporting again, an error is reported | 567 // Check that after enabling location reporting again, an error is reported |
| 568 // if no valid fix is available. | 568 // if no valid fix is available. |
| 569 SetMockPositionToReturnNext(invalid_fix); | 569 SetMockPositionToReturnNext(invalid_fix); |
| 570 cros_settings_->SetBoolean(chromeos::kReportDeviceLocation, true); | 570 cros_settings_->SetBoolean(chromeos::kReportDeviceLocation, true); |
| 571 // Allow the new pref to propagate to the status collector. | 571 // Allow the new pref to propagate to the status collector. |
| 572 message_loop_.RunUntilIdle(); | 572 message_loop_.RunUntilIdle(); |
| 573 CheckThatALocationErrorIsReported(); | 573 CheckThatALocationErrorIsReported(); |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace policy | 576 } // namespace policy |
| OLD | NEW |