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

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. Created 7 years, 2 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 const std::vector<base::Value*>& values) { 224 const std::vector<base::Value*>& values) {
225 for (size_t i = 0; i < names.size(); ++i) 225 for (size_t i = 0; i < names.size(); ++i)
226 pref_service_->Set(names[i].c_str(), *values[i]); 226 pref_service_->Set(names[i].c_str(), *values[i]);
227 } 227 }
228 228
229 void PreferencesBrowserTest::VerifyKeyValue(const base::DictionaryValue& dict, 229 void PreferencesBrowserTest::VerifyKeyValue(const base::DictionaryValue& dict,
230 const std::string& key, 230 const std::string& key,
231 const base::Value& expected) { 231 const base::Value& expected) {
232 const base::Value* actual = NULL; 232 const base::Value* actual = NULL;
233 EXPECT_TRUE(dict.Get(key, &actual)) << "Was checking key: " << key; 233 EXPECT_TRUE(dict.Get(key, &actual)) << "Was checking key: " << key;
234 EXPECT_EQ(expected, *actual) << "Was checking key: " << key; 234 if (actual)
235 EXPECT_EQ(expected, *actual) << "Was checking key: " << key;
235 } 236 }
236 237
237 void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs, 238 void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs,
238 const std::string& name, 239 const std::string& name,
239 const base::Value* value, 240 const base::Value* value,
240 const std::string& controlledBy, 241 const std::string& controlledBy,
241 bool disabled, 242 bool disabled,
242 bool uncommitted) { 243 bool uncommitted) {
243 const base::Value* pref; 244 const base::Value* pref = NULL;
244 const base::DictionaryValue* dict; 245 const base::DictionaryValue* dict = NULL;
245 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); 246 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref));
246 ASSERT_TRUE(pref->GetAsDictionary(&dict)); 247 ASSERT_TRUE(pref->GetAsDictionary(&dict));
247 VerifyKeyValue(*dict, "value", *value); 248 VerifyKeyValue(*dict, "value", *value);
248 if (!controlledBy.empty()) { 249 if (!controlledBy.empty())
249 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); 250 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy));
250 } else { 251 else
251 EXPECT_FALSE(dict->HasKey("controlledBy")); 252 EXPECT_FALSE(dict->HasKey("controlledBy"));
252 } 253
253 if (disabled) 254 if (disabled)
254 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true)); 255 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true));
255 else if (dict->HasKey("disabled")) 256 else if (dict->HasKey("disabled"))
256 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false)); 257 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false));
258
257 if (uncommitted) 259 if (uncommitted)
258 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true)); 260 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true));
259 else if (dict->HasKey("uncommitted")) 261 else if (dict->HasKey("uncommitted"))
260 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false)); 262 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false));
261 } 263 }
262 264
263 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json, 265 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json,
264 const std::string& name, 266 const std::string& name,
265 const base::Value* value, 267 const base::Value* value,
266 const std::string& controlledBy, 268 const std::string& controlledBy,
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 838
837 void VerifyCurrentProxyServer(const std::string& expected_server, 839 void VerifyCurrentProxyServer(const std::string& expected_server,
838 chromeos::onc::ONCSource expected_source) { 840 chromeos::onc::ONCSource expected_source) {
839 chromeos::onc::ONCSource actual_source; 841 chromeos::onc::ONCSource actual_source;
840 scoped_ptr<ProxyConfigDictionary> proxy_dict = 842 scoped_ptr<ProxyConfigDictionary> proxy_dict =
841 chromeos::proxy_config::GetProxyConfigForFavoriteNetwork( 843 chromeos::proxy_config::GetProxyConfigForFavoriteNetwork(
842 pref_service_, 844 pref_service_,
843 g_browser_process->local_state(), 845 g_browser_process->local_state(),
844 *GetDefaultFavoriteNetwork(), 846 *GetDefaultFavoriteNetwork(),
845 &actual_source); 847 &actual_source);
848 ASSERT_TRUE(proxy_dict);
846 std::string actual_proxy_server; 849 std::string actual_proxy_server;
847 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server)); 850 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server));
848 EXPECT_EQ(expected_server, actual_proxy_server); 851 EXPECT_EQ(expected_server, actual_proxy_server);
849 EXPECT_EQ(expected_source, actual_source); 852 EXPECT_EQ(expected_source, actual_source);
850 } 853 }
851 }; 854 };
852 855
853 // Verifies that proxy settings are correctly pushed to JavaScript during 856 // Verifies that proxy settings are correctly pushed to JavaScript during
854 // initialization of the proxy settings page. 857 // initialization of the proxy settings page.
855 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { 858 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); 998 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2));
996 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); 999 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3));
997 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); 1000 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4));
998 1001
999 VerifyCurrentProxyServer( 1002 VerifyCurrentProxyServer(
1000 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", 1003 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4",
1001 chromeos::onc::ONC_SOURCE_NONE); 1004 chromeos::onc::ONC_SOURCE_NONE);
1002 } 1005 }
1003 1006
1004 #endif 1007 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698