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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider_unittest.cc

Issue 1052673002: Expose kDeviceLoginScreenDomainAutoComplete through CrosSettings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/settings/device_settings_provider.h" 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 for (const auto& setting : reporting_settings) { 135 for (const auto& setting : reporting_settings) {
136 EXPECT_TRUE(base::Value::Equals(provider_->Get(setting), 136 EXPECT_TRUE(base::Value::Equals(provider_->Get(setting),
137 &expected_enable_value)) 137 &expected_enable_value))
138 << "Value for " << setting << " does not match expected"; 138 << "Value for " << setting << " does not match expected";
139 } 139 }
140 const base::FundamentalValue expected_frequency_value(expected_frequency); 140 const base::FundamentalValue expected_frequency_value(expected_frequency);
141 EXPECT_TRUE(base::Value::Equals(provider_->Get(kReportUploadFrequency), 141 EXPECT_TRUE(base::Value::Equals(provider_->Get(kReportUploadFrequency),
142 &expected_frequency_value)); 142 &expected_frequency_value));
143 } 143 }
144 144
145 // Helper routine to set LoginScreenDomainAutoComplete policy.
146 void SetDomainAutoComplete(const std::string& domain) {
147 EXPECT_CALL(*this, SettingChanged(_)).Times(AtLeast(1));
148 em::LoginScreenDomainAutoCompleteProto* proto =
149 device_policy_.payload().mutable_login_screen_domain_auto_complete();
150 proto->set_login_screen_domain_auto_complete(domain);
151 device_policy_.Build();
152 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
153 ReloadDeviceSettings();
154 Mock::VerifyAndClearExpectations(this);
155 }
156
157 // Helper routine to check value of the LoginScreenDomainAutoComplete policy.
158 void VerifyDomainAutoComplete(
159 const base::StringValue* const ptr_to_expected_value) {
160 EXPECT_TRUE(base::Value::Equals(
161 provider_->Get(kAccountsPrefLoginScreenDomainAutoComplete),
162 ptr_to_expected_value));
163 }
164
145 ScopedTestingLocalState local_state_; 165 ScopedTestingLocalState local_state_;
146 166
147 scoped_ptr<DeviceSettingsProvider> provider_; 167 scoped_ptr<DeviceSettingsProvider> provider_;
148 168
149 base::ScopedPathOverride user_data_dir_override_; 169 base::ScopedPathOverride user_data_dir_override_;
150 170
151 private: 171 private:
152 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProviderTest); 172 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsProviderTest);
153 }; 173 };
154 174
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 const int heartbeat_frequency = 50000; 458 const int heartbeat_frequency = 50000;
439 SetHeartbeatSettings(true, heartbeat_frequency); 459 SetHeartbeatSettings(true, heartbeat_frequency);
440 VerifyHeartbeatSettings(true, heartbeat_frequency); 460 VerifyHeartbeatSettings(true, heartbeat_frequency);
441 461
442 // Turn off all reporting and verify that the settings are decoded 462 // Turn off all reporting and verify that the settings are decoded
443 // correctly. 463 // correctly.
444 SetHeartbeatSettings(false, heartbeat_frequency); 464 SetHeartbeatSettings(false, heartbeat_frequency);
445 VerifyHeartbeatSettings(false, heartbeat_frequency); 465 VerifyHeartbeatSettings(false, heartbeat_frequency);
446 } 466 }
447 467
468 TEST_F(DeviceSettingsProviderTest, DecodeDomainAutoComplete) {
469 // By default LoginScreenDomainAutoComplete policy should not be set.
470 VerifyDomainAutoComplete(nullptr);
471
472 // Empty string means that the policy is not set.
473 SetDomainAutoComplete("");
474 VerifyDomainAutoComplete(nullptr);
475
476 // Check some meaningful value. Policy should be set.
477 const std::string domain = "domain.test";
478 const base::StringValue domain_value(domain);
479 SetDomainAutoComplete(domain);
480 VerifyDomainAutoComplete(&domain_value);
481 }
482
448 } // namespace chromeos 483 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698