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/ui/webui/options/preferences_browsertest.h" | 5 #include "chrome/browser/ui/webui/options/preferences_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <iostream> | 9 #include <iostream> |
10 #include <memory> | 10 #include <memory> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 const base::DictionaryValue* dict = NULL; | 245 const base::DictionaryValue* dict = NULL; |
246 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); | 246 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); |
247 ASSERT_TRUE(pref->GetAsDictionary(&dict)); | 247 ASSERT_TRUE(pref->GetAsDictionary(&dict)); |
248 VerifyKeyValue(*dict, "value", *value); | 248 VerifyKeyValue(*dict, "value", *value); |
249 if (!controlledBy.empty()) | 249 if (!controlledBy.empty()) |
250 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); | 250 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); |
251 else | 251 else |
252 EXPECT_FALSE(dict->HasKey("controlledBy")); | 252 EXPECT_FALSE(dict->HasKey("controlledBy")); |
253 | 253 |
254 if (disabled) | 254 if (disabled) |
255 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true)); | 255 VerifyKeyValue(*dict, "disabled", base::Value(true)); |
256 else if (dict->HasKey("disabled")) | 256 else if (dict->HasKey("disabled")) |
257 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false)); | 257 VerifyKeyValue(*dict, "disabled", base::Value(false)); |
258 | 258 |
259 if (uncommitted) | 259 if (uncommitted) |
260 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true)); | 260 VerifyKeyValue(*dict, "uncommitted", base::Value(true)); |
261 else if (dict->HasKey("uncommitted")) | 261 else if (dict->HasKey("uncommitted")) |
262 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false)); | 262 VerifyKeyValue(*dict, "uncommitted", base::Value(false)); |
263 } | 263 } |
264 | 264 |
265 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json, | 265 void PreferencesBrowserTest::VerifyObservedPref(const std::string& json, |
266 const std::string& name, | 266 const std::string& name, |
267 const base::Value* value, | 267 const base::Value* value, |
268 const std::string& controlledBy, | 268 const std::string& controlledBy, |
269 bool disabled, | 269 bool disabled, |
270 bool uncommitted) { | 270 bool uncommitted) { |
271 std::unique_ptr<base::Value> observed_value_ptr = | 271 std::unique_ptr<base::Value> observed_value_ptr = |
272 base::JSONReader::Read(json); | 272 base::JSONReader::Read(json); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 observed_json = &temp_observed_json; | 345 observed_json = &temp_observed_json; |
346 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 346 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
347 render_view_host_, javascript.str(), observed_json)); | 347 render_view_host_, javascript.str(), observed_json)); |
348 } | 348 } |
349 | 349 |
350 void PreferencesBrowserTest::SetPref(const std::string& name, | 350 void PreferencesBrowserTest::SetPref(const std::string& name, |
351 const std::string& type, | 351 const std::string& type, |
352 const base::Value* value, | 352 const base::Value* value, |
353 bool commit, | 353 bool commit, |
354 std::string* observed_json) { | 354 std::string* observed_json) { |
355 std::unique_ptr<base::Value> commit_ptr(new base::FundamentalValue(commit)); | 355 std::unique_ptr<base::Value> commit_ptr(new base::Value(commit)); |
356 std::stringstream javascript; | 356 std::stringstream javascript; |
357 javascript << "testEnv.runAndReply(function() {" | 357 javascript << "testEnv.runAndReply(function() {" |
358 << " Preferences.set" << type << "Pref(" | 358 << " Preferences.set" << type << "Pref(" |
359 << " '" << name << "'," | 359 << " '" << name << "'," |
360 << " " << *value << "," | 360 << " " << *value << "," |
361 << " " << *commit_ptr << ");" | 361 << " " << *commit_ptr << ");" |
362 << "});"; | 362 << "});"; |
363 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 363 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
364 render_view_host_, javascript.str(), observed_json)); | 364 render_view_host_, javascript.str(), observed_json)); |
365 } | 365 } |
(...skipping 13 matching lines...) Expand all Loading... |
379 } | 379 } |
380 | 380 |
381 void PreferencesBrowserTest::VerifyClearPref(const std::string& name, | 381 void PreferencesBrowserTest::VerifyClearPref(const std::string& name, |
382 const base::Value* value, | 382 const base::Value* value, |
383 bool commit) { | 383 bool commit) { |
384 if (commit) | 384 if (commit) |
385 ExpectClearCommit(name); | 385 ExpectClearCommit(name); |
386 else | 386 else |
387 ExpectNoCommit(name); | 387 ExpectNoCommit(name); |
388 std::string commit_json; | 388 std::string commit_json; |
389 base::JSONWriter::Write(base::FundamentalValue(commit), &commit_json); | 389 base::JSONWriter::Write(base::Value(commit), &commit_json); |
390 std::stringstream javascript; | 390 std::stringstream javascript; |
391 javascript << "testEnv.runAndReply(function() {" | 391 javascript << "testEnv.runAndReply(function() {" |
392 << " Preferences.clearPref(" | 392 << " Preferences.clearPref(" |
393 << " '" << name.c_str() << "'," | 393 << " '" << name.c_str() << "'," |
394 << " " << commit_json.c_str() << ");});"; | 394 << " " << commit_json.c_str() << ");});"; |
395 std::string observed_json; | 395 std::string observed_json; |
396 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 396 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
397 render_view_host_, javascript.str(), &observed_json)); | 397 render_view_host_, javascript.str(), &observed_json)); |
398 VerifyObservedPref(observed_json, name, value, "recommended", false, !commit); | 398 VerifyObservedPref(observed_json, name, value, "recommended", false, !commit); |
399 VerifyAndClearExpectations(); | 399 VerifyAndClearExpectations(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 render_view_host_, | 451 render_view_host_, |
452 "testEnv.finishObservingAndReply();", | 452 "testEnv.finishObservingAndReply();", |
453 observed_json)); | 453 observed_json)); |
454 } | 454 } |
455 | 455 |
456 void PreferencesBrowserTest::UseDefaultTestPrefs(bool includeListPref) { | 456 void PreferencesBrowserTest::UseDefaultTestPrefs(bool includeListPref) { |
457 // Boolean pref. | 457 // Boolean pref. |
458 types_.push_back("Boolean"); | 458 types_.push_back("Boolean"); |
459 pref_names_.push_back(prefs::kAlternateErrorPagesEnabled); | 459 pref_names_.push_back(prefs::kAlternateErrorPagesEnabled); |
460 policy_names_.push_back(policy::key::kAlternateErrorPagesEnabled); | 460 policy_names_.push_back(policy::key::kAlternateErrorPagesEnabled); |
461 non_default_values_.push_back(new base::FundamentalValue(false)); | 461 non_default_values_.push_back(new base::Value(false)); |
462 | 462 |
463 // Integer pref. | 463 // Integer pref. |
464 types_.push_back("Integer"); | 464 types_.push_back("Integer"); |
465 pref_names_.push_back(prefs::kRestoreOnStartup); | 465 pref_names_.push_back(prefs::kRestoreOnStartup); |
466 policy_names_.push_back(policy::key::kRestoreOnStartup); | 466 policy_names_.push_back(policy::key::kRestoreOnStartup); |
467 non_default_values_.push_back(new base::FundamentalValue(4)); | 467 non_default_values_.push_back(new base::Value(4)); |
468 | 468 |
469 // List pref. | 469 // List pref. |
470 if (includeListPref) { | 470 if (includeListPref) { |
471 types_.push_back("List"); | 471 types_.push_back("List"); |
472 pref_names_.push_back(prefs::kURLsToRestoreOnStartup); | 472 pref_names_.push_back(prefs::kURLsToRestoreOnStartup); |
473 policy_names_.push_back(policy::key::kRestoreOnStartupURLs); | 473 policy_names_.push_back(policy::key::kRestoreOnStartupURLs); |
474 base::ListValue* list = new base::ListValue; | 474 base::ListValue* list = new base::ListValue; |
475 list->AppendString("http://www.example.com"); | 475 list->AppendString("http://www.example.com"); |
476 list->AppendString("http://example.com"); | 476 list->AppendString("http://example.com"); |
477 non_default_values_.push_back(list); | 477 non_default_values_.push_back(list); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 #if defined(OS_CHROMEOS) | 667 #if defined(OS_CHROMEOS) |
668 | 668 |
669 // Verifies that initializing the JavaScript Preferences class fires the correct | 669 // Verifies that initializing the JavaScript Preferences class fires the correct |
670 // notifications in JavaScript for pref values handled by the | 670 // notifications in JavaScript for pref values handled by the |
671 // CoreChromeOSOptionsHandler class. | 671 // CoreChromeOSOptionsHandler class. |
672 IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) { | 672 IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) { |
673 std::string observed_json; | 673 std::string observed_json; |
674 | 674 |
675 // Boolean pref. | 675 // Boolean pref. |
676 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); | 676 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); |
677 default_values_.push_back(new base::FundamentalValue(true)); | 677 default_values_.push_back(new base::Value(true)); |
678 | 678 |
679 // String pref. | 679 // String pref. |
680 pref_names_.push_back(chromeos::kReleaseChannel); | 680 pref_names_.push_back(chromeos::kReleaseChannel); |
681 default_values_.push_back(new base::StringValue("")); | 681 default_values_.push_back(new base::StringValue("")); |
682 | 682 |
683 // List pref. | 683 // List pref. |
684 pref_names_.push_back(chromeos::kAccountsPrefUsers); | 684 pref_names_.push_back(chromeos::kAccountsPrefUsers); |
685 default_values_.push_back(new base::ListValue); | 685 default_values_.push_back(new base::ListValue); |
686 | 686 |
687 // Verify notifications when default values are in effect. | 687 // Verify notifications when default values are in effect. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 // Verifies that initializing the JavaScript Preferences class fires the correct | 738 // Verifies that initializing the JavaScript Preferences class fires the correct |
739 // notifications in JavaScript for pref values handled by the | 739 // notifications in JavaScript for pref values handled by the |
740 // CoreChromeOSOptionsHandler class for a managed device. | 740 // CoreChromeOSOptionsHandler class for a managed device. |
741 IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest, | 741 IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest, |
742 ChromeOSDeviceFetchPrefs) { | 742 ChromeOSDeviceFetchPrefs) { |
743 ScopedVector<base::Value> decorated_non_default_values; | 743 ScopedVector<base::Value> decorated_non_default_values; |
744 std::string observed_json; | 744 std::string observed_json; |
745 | 745 |
746 // Boolean pref. | 746 // Boolean pref. |
747 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); | 747 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); |
748 non_default_values_.push_back(new base::FundamentalValue(false)); | 748 non_default_values_.push_back(new base::Value(false)); |
749 decorated_non_default_values.push_back( | 749 decorated_non_default_values.push_back( |
750 non_default_values_.back()->DeepCopy()); | 750 non_default_values_.back()->DeepCopy()); |
751 | 751 |
752 // String pref. | 752 // String pref. |
753 pref_names_.push_back(chromeos::kReleaseChannel); | 753 pref_names_.push_back(chromeos::kReleaseChannel); |
754 non_default_values_.push_back(new base::StringValue("stable-channel")); | 754 non_default_values_.push_back(new base::StringValue("stable-channel")); |
755 decorated_non_default_values.push_back( | 755 decorated_non_default_values.push_back( |
756 non_default_values_.back()->DeepCopy()); | 756 non_default_values_.back()->DeepCopy()); |
757 | 757 |
758 // List pref. | 758 // List pref. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 EXPECT_EQ(expected_server, actual_proxy_server); | 932 EXPECT_EQ(expected_server, actual_proxy_server); |
933 EXPECT_EQ(expected_source, actual_source); | 933 EXPECT_EQ(expected_source, actual_source); |
934 } | 934 } |
935 }; | 935 }; |
936 | 936 |
937 // Verifies that proxy settings are correctly pushed to JavaScript during | 937 // Verifies that proxy settings are correctly pushed to JavaScript during |
938 // initialization of the proxy settings page. | 938 // initialization of the proxy settings page. |
939 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { | 939 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { |
940 // Boolean pref. | 940 // Boolean pref. |
941 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle); | 941 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle); |
942 non_default_values_.push_back(new base::FundamentalValue(true)); | 942 non_default_values_.push_back(new base::Value(true)); |
943 | 943 |
944 // Integer prefs. | 944 // Integer prefs. |
945 pref_names_.push_back( | 945 pref_names_.push_back( |
946 chromeos::proxy_cros_settings_parser::kProxySingleHttpPort); | 946 chromeos::proxy_cros_settings_parser::kProxySingleHttpPort); |
947 non_default_values_.push_back(new base::FundamentalValue(8080)); | 947 non_default_values_.push_back(new base::Value(8080)); |
948 | 948 |
949 // String pref. | 949 // String pref. |
950 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp); | 950 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp); |
951 non_default_values_.push_back(new base::StringValue("127.0.0.1")); | 951 non_default_values_.push_back(new base::StringValue("127.0.0.1")); |
952 | 952 |
953 // List pref. | 953 // List pref. |
954 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList); | 954 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList); |
955 base::ListValue* list = new base::ListValue(); | 955 base::ListValue* list = new base::ListValue(); |
956 list->AppendString("*.google.com"); | 956 list->AppendString("*.google.com"); |
957 list->AppendString("1.2.3.4:22"); | 957 list->AppendString("1.2.3.4:22"); |
958 non_default_values_.push_back(list); | 958 non_default_values_.push_back(list); |
959 | 959 |
960 // Verify that no policy is presented to the UI. This must be verified on the | 960 // Verify that no policy is presented to the UI. This must be verified on the |
961 // kProxyType and the kUseSharedProxies prefs. | 961 // kProxyType and the kUseSharedProxies prefs. |
962 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 962 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
963 non_default_values_.push_back(new base::FundamentalValue(2)); | 963 non_default_values_.push_back(new base::Value(2)); |
964 | 964 |
965 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 965 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
966 non_default_values_.push_back(new base::FundamentalValue(false)); | 966 non_default_values_.push_back(new base::Value(false)); |
967 | 967 |
968 std::string observed_json; | 968 std::string observed_json; |
969 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 969 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
970 VerifyObservedPrefs( | 970 VerifyObservedPrefs( |
971 observed_json, pref_names_, non_default_values_.get(), "", false, false); | 971 observed_json, pref_names_, non_default_values_.get(), "", false, false); |
972 } | 972 } |
973 | 973 |
974 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) { | 974 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) { |
975 SetONCPolicy(policy::key::kOpenNetworkConfiguration, | 975 SetONCPolicy(policy::key::kOpenNetworkConfiguration, |
976 policy::POLICY_SCOPE_USER); | 976 policy::POLICY_SCOPE_USER); |
977 | 977 |
978 // Verify that per-network policy is presented to the UI. This must be | 978 // Verify that per-network policy is presented to the UI. This must be |
979 // verified on the kProxyType. | 979 // verified on the kProxyType. |
980 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 980 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
981 non_default_values_.push_back(new base::FundamentalValue(3)); | 981 non_default_values_.push_back(new base::Value(3)); |
982 | 982 |
983 std::string observed_json; | 983 std::string observed_json; |
984 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 984 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
985 VerifyObservedPrefs( | 985 VerifyObservedPrefs( |
986 observed_json, pref_names_, non_default_values_.get(), | 986 observed_json, pref_names_, non_default_values_.get(), |
987 "policy", true, false); | 987 "policy", true, false); |
988 | 988 |
989 // Verify that 'use-shared-proxies' is not affected by per-network policy. | 989 // Verify that 'use-shared-proxies' is not affected by per-network policy. |
990 pref_names_.clear(); | 990 pref_names_.clear(); |
991 non_default_values_.clear(); | 991 non_default_values_.clear(); |
992 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 992 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
993 non_default_values_.push_back(new base::FundamentalValue(false)); | 993 non_default_values_.push_back(new base::Value(false)); |
994 | 994 |
995 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 995 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
996 VerifyObservedPrefs( | 996 VerifyObservedPrefs( |
997 observed_json, pref_names_, non_default_values_.get(), "", false, false); | 997 observed_json, pref_names_, non_default_values_.get(), "", false, false); |
998 } | 998 } |
999 | 999 |
1000 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) { | 1000 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) { |
1001 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration, | 1001 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration, |
1002 policy::POLICY_SCOPE_MACHINE); | 1002 policy::POLICY_SCOPE_MACHINE); |
1003 | 1003 |
1004 // Verify that the policy is presented to the UI. This verification must be | 1004 // Verify that the policy is presented to the UI. This verification must be |
1005 // done on the kProxyType pref. | 1005 // done on the kProxyType pref. |
1006 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 1006 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
1007 non_default_values_.push_back(new base::FundamentalValue(3)); | 1007 non_default_values_.push_back(new base::Value(3)); |
1008 | 1008 |
1009 std::string observed_json; | 1009 std::string observed_json; |
1010 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1010 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
1011 VerifyObservedPrefs( | 1011 VerifyObservedPrefs( |
1012 observed_json, pref_names_, non_default_values_.get(), | 1012 observed_json, pref_names_, non_default_values_.get(), |
1013 "policy", true, false); | 1013 "policy", true, false); |
1014 | 1014 |
1015 // Verify that 'use-shared-proxies' is not affected by per-network policy. | 1015 // Verify that 'use-shared-proxies' is not affected by per-network policy. |
1016 pref_names_.clear(); | 1016 pref_names_.clear(); |
1017 non_default_values_.clear(); | 1017 non_default_values_.clear(); |
1018 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 1018 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
1019 non_default_values_.push_back(new base::FundamentalValue(false)); | 1019 non_default_values_.push_back(new base::Value(false)); |
1020 | 1020 |
1021 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1021 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
1022 VerifyObservedPrefs( | 1022 VerifyObservedPrefs( |
1023 observed_json, pref_names_, non_default_values_.get(), "", false, false); | 1023 observed_json, pref_names_, non_default_values_.get(), "", false, false); |
1024 } | 1024 } |
1025 | 1025 |
1026 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) { | 1026 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) { |
1027 policy_names_.push_back(policy::key::kProxyMode); | 1027 policy_names_.push_back(policy::key::kProxyMode); |
1028 default_values_.push_back( | 1028 default_values_.push_back( |
1029 new base::StringValue(ProxyPrefs::kAutoDetectProxyModeName)); | 1029 new base::StringValue(ProxyPrefs::kAutoDetectProxyModeName)); |
1030 SetUserPolicies( | 1030 SetUserPolicies( |
1031 policy_names_, default_values_.get(), policy::POLICY_LEVEL_MANDATORY); | 1031 policy_names_, default_values_.get(), policy::POLICY_LEVEL_MANDATORY); |
1032 content::RunAllPendingInMessageLoop(); | 1032 content::RunAllPendingInMessageLoop(); |
1033 | 1033 |
1034 // Verify that the policy is presented to the UI. This verification must be | 1034 // Verify that the policy is presented to the UI. This verification must be |
1035 // done on the kProxyType pref. | 1035 // done on the kProxyType pref. |
1036 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 1036 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
1037 non_default_values_.push_back(new base::FundamentalValue(3)); | 1037 non_default_values_.push_back(new base::Value(3)); |
1038 | 1038 |
1039 // Verify that 'use-shared-proxies' is controlled by the policy. | 1039 // Verify that 'use-shared-proxies' is controlled by the policy. |
1040 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 1040 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
1041 non_default_values_.push_back(new base::FundamentalValue(false)); | 1041 non_default_values_.push_back(new base::Value(false)); |
1042 | 1042 |
1043 std::string observed_json; | 1043 std::string observed_json; |
1044 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1044 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
1045 VerifyObservedPrefs( | 1045 VerifyObservedPrefs( |
1046 observed_json, pref_names_, non_default_values_.get(), | 1046 observed_json, pref_names_, non_default_values_.get(), |
1047 "policy", true, false); | 1047 "policy", true, false); |
1048 } | 1048 } |
1049 | 1049 |
1050 // Verifies that modifications to the proxy settings are correctly pushed from | 1050 // Verifies that modifications to the proxy settings are correctly pushed from |
1051 // JavaScript to the ProxyConfig property stored in the network configuration. | 1051 // JavaScript to the ProxyConfig property stored in the network configuration. |
1052 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) { | 1052 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) { |
1053 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); | 1053 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); |
1054 | 1054 |
1055 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttpPort, | 1055 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttpPort, |
1056 base::FundamentalValue(123)); | 1056 base::Value(123)); |
1057 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttp, | 1057 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttp, |
1058 base::StringValue("www.adomain.xy")); | 1058 base::StringValue("www.adomain.xy")); |
1059 | 1059 |
1060 VerifyCurrentProxyServer("www.adomain.xy:123", | 1060 VerifyCurrentProxyServer("www.adomain.xy:123", |
1061 onc::ONC_SOURCE_NONE); | 1061 onc::ONC_SOURCE_NONE); |
1062 } | 1062 } |
1063 | 1063 |
1064 // Verify that default proxy ports are used and that ports can be updated | 1064 // Verify that default proxy ports are used and that ports can be updated |
1065 // without affecting the previously set hosts. | 1065 // without affecting the previously set hosts. |
1066 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) { | 1066 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) { |
1067 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); | 1067 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); |
1068 | 1068 |
1069 // Set to manual, per scheme proxy. | 1069 // Set to manual, per scheme proxy. |
1070 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingle, | 1070 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingle, |
1071 base::FundamentalValue(false)); | 1071 base::Value(false)); |
1072 | 1072 |
1073 // Set hosts but no ports. | 1073 // Set hosts but no ports. |
1074 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpUrl, | 1074 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpUrl, |
1075 base::StringValue("a.com")); | 1075 base::StringValue("a.com")); |
1076 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsUrl, | 1076 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsUrl, |
1077 base::StringValue("4.3.2.1")); | 1077 base::StringValue("4.3.2.1")); |
1078 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpUrl, | 1078 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpUrl, |
1079 base::StringValue("c.com")); | 1079 base::StringValue("c.com")); |
1080 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocks, | 1080 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocks, |
1081 base::StringValue("d.com")); | 1081 base::StringValue("d.com")); |
1082 | 1082 |
1083 // Verify default ports. | 1083 // Verify default ports. |
1084 VerifyCurrentProxyServer( | 1084 VerifyCurrentProxyServer( |
1085 "http=a.com:80;https=4.3.2.1:80;ftp=c.com:80;socks=socks4://d.com:1080", | 1085 "http=a.com:80;https=4.3.2.1:80;ftp=c.com:80;socks=socks4://d.com:1080", |
1086 onc::ONC_SOURCE_NONE); | 1086 onc::ONC_SOURCE_NONE); |
1087 | 1087 |
1088 // Set and verify the ports. | 1088 // Set and verify the ports. |
1089 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpPort, | 1089 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpPort, |
1090 base::FundamentalValue(1)); | 1090 base::Value(1)); |
1091 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsPort, | 1091 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsPort, |
1092 base::FundamentalValue(2)); | 1092 base::Value(2)); |
1093 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpPort, | 1093 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpPort, |
1094 base::FundamentalValue(3)); | 1094 base::Value(3)); |
1095 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort, | 1095 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort, |
1096 base::FundamentalValue(4)); | 1096 base::Value(4)); |
1097 | 1097 |
1098 VerifyCurrentProxyServer( | 1098 VerifyCurrentProxyServer( |
1099 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", | 1099 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", |
1100 onc::ONC_SOURCE_NONE); | 1100 onc::ONC_SOURCE_NONE); |
1101 } | 1101 } |
1102 | 1102 |
1103 #endif | 1103 #endif |
OLD | NEW |