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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc

Issue 255873002: Revert of Add ScopedStubEnterpriseInstallAttributes for tests to set test install attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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/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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 // Though it is a unit test, this test is linked with browser_tests so that it 146 // Though it is a unit test, this test is linked with browser_tests so that it
147 // runs in a separate process. The intention is to avoid overriding the timezone 147 // runs in a separate process. The intention is to avoid overriding the timezone
148 // environment variable for other tests. 148 // environment variable for other tests.
149 class DeviceStatusCollectorTest : public testing::Test { 149 class DeviceStatusCollectorTest : public testing::Test {
150 public: 150 public:
151 DeviceStatusCollectorTest() 151 DeviceStatusCollectorTest()
152 : ui_thread_(content::BrowserThread::UI, &message_loop_), 152 : ui_thread_(content::BrowserThread::UI, &message_loop_),
153 file_thread_(content::BrowserThread::FILE, &message_loop_), 153 file_thread_(content::BrowserThread::FILE, &message_loop_),
154 io_thread_(content::BrowserThread::IO, &message_loop_), 154 io_thread_(content::BrowserThread::IO, &message_loop_),
155 install_attributes_("managed.com",
156 "user@managed.com",
157 "device_id",
158 DEVICE_MODE_ENTERPRISE),
159 user_manager_(new chromeos::MockUserManager()), 155 user_manager_(new chromeos::MockUserManager()),
160 user_manager_enabler_(user_manager_) { 156 user_manager_enabler_(user_manager_) {
161 // Run this test with a well-known timezone so that Time::LocalMidnight() 157 // Run this test with a well-known timezone so that Time::LocalMidnight()
162 // returns the same values on all machines. 158 // returns the same values on all machines.
163 scoped_ptr<base::Environment> env(base::Environment::Create()); 159 scoped_ptr<base::Environment> env(base::Environment::Create());
164 env->SetVar("TZ", "UTC"); 160 env->SetVar("TZ", "UTC");
165 161
166 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry()); 162 TestingDeviceStatusCollector::RegisterPrefs(prefs_.registry());
167 163
168 EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, NotNull())) 164 EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, NotNull()))
169 .WillRepeatedly(Return(false)); 165 .WillRepeatedly(Return(false));
170 166
171 // Remove the real DeviceSettingsProvider and replace it with a stub. 167 // Remove the real DeviceSettingsProvider and replace it with a stub.
172 cros_settings_ = chromeos::CrosSettings::Get(); 168 cros_settings_ = chromeos::CrosSettings::Get();
173 device_settings_provider_ = 169 device_settings_provider_ =
174 cros_settings_->GetProvider(chromeos::kReportDeviceVersionInfo); 170 cros_settings_->GetProvider(chromeos::kReportDeviceVersionInfo);
175 EXPECT_TRUE(device_settings_provider_ != NULL); 171 EXPECT_TRUE(device_settings_provider_ != NULL);
176 EXPECT_TRUE( 172 EXPECT_TRUE(
177 cros_settings_->RemoveSettingsProvider(device_settings_provider_)); 173 cros_settings_->RemoveSettingsProvider(device_settings_provider_));
178 cros_settings_->AddSettingsProvider(&stub_settings_provider_); 174 cros_settings_->AddSettingsProvider(&stub_settings_provider_);
179 175
176 // Set up fake install attributes.
177 StubEnterpriseInstallAttributes* attributes =
178 new StubEnterpriseInstallAttributes();
179 attributes->SetDomain("managed.com");
180 attributes->SetRegistrationUser("user@managed.com");
181 BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting(attributes);
182
180 RestartStatusCollector(); 183 RestartStatusCollector();
181 } 184 }
182 185
183 virtual ~DeviceStatusCollectorTest() { 186 virtual ~DeviceStatusCollectorTest() {
184 // Finish pending tasks. 187 // Finish pending tasks.
185 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 188 content::BrowserThread::GetBlockingPool()->FlushForTesting();
186 message_loop_.RunUntilIdle(); 189 message_loop_.RunUntilIdle();
187 190
188 // Restore the real DeviceSettingsProvider. 191 // Restore the real DeviceSettingsProvider.
189 EXPECT_TRUE( 192 EXPECT_TRUE(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 254 }
252 255
253 // Since this is a unit test running in browser_tests we must do additional 256 // Since this is a unit test running in browser_tests we must do additional
254 // unit test setup and make a TestingBrowserProcess. Must be first member. 257 // unit test setup and make a TestingBrowserProcess. Must be first member.
255 TestingBrowserProcessInitializer initializer_; 258 TestingBrowserProcessInitializer initializer_;
256 base::MessageLoopForUI message_loop_; 259 base::MessageLoopForUI message_loop_;
257 content::TestBrowserThread ui_thread_; 260 content::TestBrowserThread ui_thread_;
258 content::TestBrowserThread file_thread_; 261 content::TestBrowserThread file_thread_;
259 content::TestBrowserThread io_thread_; 262 content::TestBrowserThread io_thread_;
260 263
261 ScopedStubEnterpriseInstallAttributes install_attributes_;
262 TestingPrefServiceSimple prefs_; 264 TestingPrefServiceSimple prefs_;
263 chromeos::system::MockStatisticsProvider statistics_provider_; 265 chromeos::system::MockStatisticsProvider statistics_provider_;
264 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 266 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
265 chromeos::ScopedTestCrosSettings test_cros_settings_; 267 chromeos::ScopedTestCrosSettings test_cros_settings_;
266 chromeos::CrosSettings* cros_settings_; 268 chromeos::CrosSettings* cros_settings_;
267 chromeos::CrosSettingsProvider* device_settings_provider_; 269 chromeos::CrosSettingsProvider* device_settings_provider_;
268 chromeos::StubCrosSettingsProvider stub_settings_provider_; 270 chromeos::StubCrosSettingsProvider stub_settings_provider_;
269 chromeos::MockUserManager* user_manager_; 271 chromeos::MockUserManager* user_manager_;
270 chromeos::ScopedUserManagerEnabler user_manager_enabler_; 272 chromeos::ScopedUserManagerEnabler user_manager_enabler_;
271 em::DeviceStatusReportRequest status_; 273 em::DeviceStatusReportRequest status_;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 767 }
766 768
767 EXPECT_TRUE(found_match) << "No matching interface for fake device " << i; 769 EXPECT_TRUE(found_match) << "No matching interface for fake device " << i;
768 count++; 770 count++;
769 } 771 }
770 772
771 EXPECT_EQ(count, status_.network_interface_size()); 773 EXPECT_EQ(count, status_.network_interface_size());
772 } 774 }
773 775
774 } // namespace policy 776 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698