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

Side by Side Diff: chrome/browser/ui/webui/options/preferences_browsertest.cc

Issue 23451044: Add an Ethernet EAP policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on NetworkStateBase removal and addressed comments. Created 7 years, 3 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 | Annotate | Revision Log
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/ui/webui/options/preferences_browsertest.h" 5 #include "chrome/browser/ui/webui/options/preferences_browsertest.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const std::vector<base::Value*>& values) { 223 const std::vector<base::Value*>& values) {
224 for (size_t i = 0; i < names.size(); ++i) 224 for (size_t i = 0; i < names.size(); ++i)
225 pref_service_->Set(names[i].c_str(), *values[i]); 225 pref_service_->Set(names[i].c_str(), *values[i]);
226 } 226 }
227 227
228 void PreferencesBrowserTest::VerifyKeyValue(const base::DictionaryValue& dict, 228 void PreferencesBrowserTest::VerifyKeyValue(const base::DictionaryValue& dict,
229 const std::string& key, 229 const std::string& key,
230 const base::Value& expected) { 230 const base::Value& expected) {
231 const base::Value* actual = NULL; 231 const base::Value* actual = NULL;
232 EXPECT_TRUE(dict.Get(key, &actual)) << "Was checking key: " << key; 232 EXPECT_TRUE(dict.Get(key, &actual)) << "Was checking key: " << key;
233 EXPECT_EQ(expected, *actual) << "Was checking key: " << key; 233 if (actual)
234 EXPECT_EQ(expected, *actual) << "Was checking key: " << key;
234 } 235 }
235 236
236 void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs, 237 void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs,
237 const std::string& name, 238 const std::string& name,
238 const base::Value* value, 239 const base::Value* value,
239 const std::string& controlledBy, 240 const std::string& controlledBy,
240 bool disabled, 241 bool disabled,
241 bool uncommitted) { 242 bool uncommitted) {
242 const base::Value* pref; 243 const base::Value* pref = NULL;
243 const base::DictionaryValue* dict; 244 const base::DictionaryValue* dict = NULL;
244 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); 245 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref));
245 ASSERT_TRUE(pref->GetAsDictionary(&dict)); 246 ASSERT_TRUE(pref->GetAsDictionary(&dict));
246 VerifyKeyValue(*dict, "value", *value); 247 VerifyKeyValue(*dict, "value", *value);
247 if (!controlledBy.empty()) { 248 if (!controlledBy.empty())
248 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); 249 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy));
249 } else { 250 else
250 EXPECT_FALSE(dict->HasKey("controlledBy")); 251 EXPECT_FALSE(dict->HasKey("controlledBy"));
251 } 252
252 if (disabled) 253 if (disabled)
253 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true)); 254 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true));
254 else if (dict->HasKey("disabled")) 255 else if (dict->HasKey("disabled"))
255 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false)); 256 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false));
257
256 if (uncommitted) 258 if (uncommitted)
257 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true)); 259 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true));
258 else if (dict->HasKey("uncommitted")) 260 else if (dict->HasKey("uncommitted"))
259 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false)); 261 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false));
260 } 262 }
261 263
262 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json, 264 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json,
263 const std::string& name, 265 const std::string& name,
264 const base::Value* value, 266 const base::Value* value,
265 const std::string& controlledBy, 267 const std::string& controlledBy,
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 830
829 void VerifyCurrentProxyServer(const std::string& expected_server, 831 void VerifyCurrentProxyServer(const std::string& expected_server,
830 chromeos::onc::ONCSource expected_source) { 832 chromeos::onc::ONCSource expected_source) {
831 chromeos::onc::ONCSource actual_source; 833 chromeos::onc::ONCSource actual_source;
832 scoped_ptr<ProxyConfigDictionary> proxy_dict = 834 scoped_ptr<ProxyConfigDictionary> proxy_dict =
833 chromeos::proxy_config::GetProxyConfigForNetwork( 835 chromeos::proxy_config::GetProxyConfigForNetwork(
834 pref_service_, 836 pref_service_,
835 g_browser_process->local_state(), 837 g_browser_process->local_state(),
836 *GetDefaultNetwork(), 838 *GetDefaultNetwork(),
837 &actual_source); 839 &actual_source);
840 ASSERT_TRUE(proxy_dict);
838 std::string actual_proxy_server; 841 std::string actual_proxy_server;
839 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server)); 842 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server));
840 EXPECT_EQ(expected_server, actual_proxy_server); 843 EXPECT_EQ(expected_server, actual_proxy_server);
841 EXPECT_EQ(expected_source, actual_source); 844 EXPECT_EQ(expected_source, actual_source);
842 } 845 }
843 }; 846 };
844 847
845 // Verifies that proxy settings are correctly pushed to JavaScript during 848 // Verifies that proxy settings are correctly pushed to JavaScript during
846 // initialization of the proxy settings page. 849 // initialization of the proxy settings page.
847 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { 850 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); 990 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2));
988 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); 991 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3));
989 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); 992 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4));
990 993
991 VerifyCurrentProxyServer( 994 VerifyCurrentProxyServer(
992 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", 995 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4",
993 chromeos::onc::ONC_SOURCE_NONE); 996 chromeos::onc::ONC_SOURCE_NONE);
994 } 997 }
995 998
996 #endif 999 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698