| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 const base::DictionaryValue* dict = NULL; | 258 const base::DictionaryValue* dict = NULL; |
| 259 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); | 259 ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref)); |
| 260 ASSERT_TRUE(pref->GetAsDictionary(&dict)); | 260 ASSERT_TRUE(pref->GetAsDictionary(&dict)); |
| 261 VerifyKeyValue(*dict, "value", *value); | 261 VerifyKeyValue(*dict, "value", *value); |
| 262 if (!controlledBy.empty()) | 262 if (!controlledBy.empty()) |
| 263 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); | 263 VerifyKeyValue(*dict, "controlledBy", base::StringValue(controlledBy)); |
| 264 else | 264 else |
| 265 EXPECT_FALSE(dict->HasKey("controlledBy")); | 265 EXPECT_FALSE(dict->HasKey("controlledBy")); |
| 266 | 266 |
| 267 if (disabled) | 267 if (disabled) |
| 268 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(true)); | 268 VerifyKeyValue(*dict, "disabled", base::Value(true)); |
| 269 else if (dict->HasKey("disabled")) | 269 else if (dict->HasKey("disabled")) |
| 270 VerifyKeyValue(*dict, "disabled", base::FundamentalValue(false)); | 270 VerifyKeyValue(*dict, "disabled", base::Value(false)); |
| 271 | 271 |
| 272 if (uncommitted) | 272 if (uncommitted) |
| 273 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(true)); | 273 VerifyKeyValue(*dict, "uncommitted", base::Value(true)); |
| 274 else if (dict->HasKey("uncommitted")) | 274 else if (dict->HasKey("uncommitted")) |
| 275 VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false)); | 275 VerifyKeyValue(*dict, "uncommitted", base::Value(false)); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void PreferencesBrowserTest::VerifyObservedPref( | 278 void PreferencesBrowserTest::VerifyObservedPref( |
| 279 const std::string& json, | 279 const std::string& json, |
| 280 const std::string& name, | 280 const std::string& name, |
| 281 const std::unique_ptr<base::Value>& value, | 281 const std::unique_ptr<base::Value>& value, |
| 282 const std::string& controlledBy, | 282 const std::string& controlledBy, |
| 283 bool disabled, | 283 bool disabled, |
| 284 bool uncommitted) { | 284 bool uncommitted) { |
| 285 std::unique_ptr<base::Value> observed_value_ptr = | 285 std::unique_ptr<base::Value> observed_value_ptr = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 observed_json = &temp_observed_json; | 361 observed_json = &temp_observed_json; |
| 362 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 362 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 363 render_view_host_, javascript.str(), observed_json)); | 363 render_view_host_, javascript.str(), observed_json)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void PreferencesBrowserTest::SetPref(const std::string& name, | 366 void PreferencesBrowserTest::SetPref(const std::string& name, |
| 367 const std::string& type, | 367 const std::string& type, |
| 368 const std::unique_ptr<base::Value>& value, | 368 const std::unique_ptr<base::Value>& value, |
| 369 bool commit, | 369 bool commit, |
| 370 std::string* observed_json) { | 370 std::string* observed_json) { |
| 371 std::unique_ptr<base::Value> commit_ptr(new base::FundamentalValue(commit)); | 371 std::unique_ptr<base::Value> commit_ptr(new base::Value(commit)); |
| 372 std::stringstream javascript; | 372 std::stringstream javascript; |
| 373 javascript << "testEnv.runAndReply(function() {" | 373 javascript << "testEnv.runAndReply(function() {" |
| 374 << " Preferences.set" << type << "Pref(" | 374 << " Preferences.set" << type << "Pref(" |
| 375 << " '" << name << "'," | 375 << " '" << name << "'," |
| 376 << " " << *value << "," | 376 << " " << *value << "," |
| 377 << " " << *commit_ptr << ");" | 377 << " " << *commit_ptr << ");" |
| 378 << "});"; | 378 << "});"; |
| 379 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 379 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 380 render_view_host_, javascript.str(), observed_json)); | 380 render_view_host_, javascript.str(), observed_json)); |
| 381 } | 381 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 397 | 397 |
| 398 void PreferencesBrowserTest::VerifyClearPref( | 398 void PreferencesBrowserTest::VerifyClearPref( |
| 399 const std::string& name, | 399 const std::string& name, |
| 400 const std::unique_ptr<base::Value>& value, | 400 const std::unique_ptr<base::Value>& value, |
| 401 bool commit) { | 401 bool commit) { |
| 402 if (commit) | 402 if (commit) |
| 403 ExpectClearCommit(name); | 403 ExpectClearCommit(name); |
| 404 else | 404 else |
| 405 ExpectNoCommit(name); | 405 ExpectNoCommit(name); |
| 406 std::string commit_json; | 406 std::string commit_json; |
| 407 base::JSONWriter::Write(base::FundamentalValue(commit), &commit_json); | 407 base::JSONWriter::Write(base::Value(commit), &commit_json); |
| 408 std::stringstream javascript; | 408 std::stringstream javascript; |
| 409 javascript << "testEnv.runAndReply(function() {" | 409 javascript << "testEnv.runAndReply(function() {" |
| 410 << " Preferences.clearPref(" | 410 << " Preferences.clearPref(" |
| 411 << " '" << name.c_str() << "'," | 411 << " '" << name.c_str() << "'," |
| 412 << " " << commit_json.c_str() << ");});"; | 412 << " " << commit_json.c_str() << ");});"; |
| 413 std::string observed_json; | 413 std::string observed_json; |
| 414 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 414 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 415 render_view_host_, javascript.str(), &observed_json)); | 415 render_view_host_, javascript.str(), &observed_json)); |
| 416 VerifyObservedPref(observed_json, name, value, "recommended", false, !commit); | 416 VerifyObservedPref(observed_json, name, value, "recommended", false, !commit); |
| 417 VerifyAndClearExpectations(); | 417 VerifyAndClearExpectations(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 render_view_host_, | 473 render_view_host_, |
| 474 "testEnv.finishObservingAndReply();", | 474 "testEnv.finishObservingAndReply();", |
| 475 observed_json)); | 475 observed_json)); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void PreferencesBrowserTest::UseDefaultTestPrefs(bool includeListPref) { | 478 void PreferencesBrowserTest::UseDefaultTestPrefs(bool includeListPref) { |
| 479 // Boolean pref. | 479 // Boolean pref. |
| 480 types_.push_back("Boolean"); | 480 types_.push_back("Boolean"); |
| 481 pref_names_.push_back(prefs::kAlternateErrorPagesEnabled); | 481 pref_names_.push_back(prefs::kAlternateErrorPagesEnabled); |
| 482 policy_names_.push_back(policy::key::kAlternateErrorPagesEnabled); | 482 policy_names_.push_back(policy::key::kAlternateErrorPagesEnabled); |
| 483 non_default_values_.push_back( | 483 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 484 base::MakeUnique<base::FundamentalValue>(false)); | |
| 485 | 484 |
| 486 // Integer pref. | 485 // Integer pref. |
| 487 types_.push_back("Integer"); | 486 types_.push_back("Integer"); |
| 488 pref_names_.push_back(prefs::kRestoreOnStartup); | 487 pref_names_.push_back(prefs::kRestoreOnStartup); |
| 489 policy_names_.push_back(policy::key::kRestoreOnStartup); | 488 policy_names_.push_back(policy::key::kRestoreOnStartup); |
| 490 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(4)); | 489 non_default_values_.push_back(base::MakeUnique<base::Value>(4)); |
| 491 | 490 |
| 492 // List pref. | 491 // List pref. |
| 493 if (includeListPref) { | 492 if (includeListPref) { |
| 494 types_.push_back("List"); | 493 types_.push_back("List"); |
| 495 pref_names_.push_back(prefs::kURLsToRestoreOnStartup); | 494 pref_names_.push_back(prefs::kURLsToRestoreOnStartup); |
| 496 policy_names_.push_back(policy::key::kRestoreOnStartupURLs); | 495 policy_names_.push_back(policy::key::kRestoreOnStartupURLs); |
| 497 auto list = base::MakeUnique<base::ListValue>(); | 496 auto list = base::MakeUnique<base::ListValue>(); |
| 498 list->AppendString("http://www.example.com"); | 497 list->AppendString("http://www.example.com"); |
| 499 list->AppendString("http://example.com"); | 498 list->AppendString("http://example.com"); |
| 500 non_default_values_.push_back(std::move(list)); | 499 non_default_values_.push_back(std::move(list)); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 #if defined(OS_CHROMEOS) | 678 #if defined(OS_CHROMEOS) |
| 680 | 679 |
| 681 // Verifies that initializing the JavaScript Preferences class fires the correct | 680 // Verifies that initializing the JavaScript Preferences class fires the correct |
| 682 // notifications in JavaScript for pref values handled by the | 681 // notifications in JavaScript for pref values handled by the |
| 683 // CoreChromeOSOptionsHandler class. | 682 // CoreChromeOSOptionsHandler class. |
| 684 IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) { | 683 IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) { |
| 685 std::string observed_json; | 684 std::string observed_json; |
| 686 | 685 |
| 687 // Boolean pref. | 686 // Boolean pref. |
| 688 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); | 687 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); |
| 689 default_values_.push_back(base::MakeUnique<base::FundamentalValue>(true)); | 688 default_values_.push_back(base::MakeUnique<base::Value>(true)); |
| 690 | 689 |
| 691 // String pref. | 690 // String pref. |
| 692 pref_names_.push_back(chromeos::kReleaseChannel); | 691 pref_names_.push_back(chromeos::kReleaseChannel); |
| 693 default_values_.push_back(base::MakeUnique<base::StringValue>("")); | 692 default_values_.push_back(base::MakeUnique<base::StringValue>("")); |
| 694 | 693 |
| 695 // List pref. | 694 // List pref. |
| 696 pref_names_.push_back(chromeos::kAccountsPrefUsers); | 695 pref_names_.push_back(chromeos::kAccountsPrefUsers); |
| 697 default_values_.push_back(base::MakeUnique<base::ListValue>()); | 696 default_values_.push_back(base::MakeUnique<base::ListValue>()); |
| 698 | 697 |
| 699 // Verify notifications when default values are in effect. | 698 // Verify notifications when default values are in effect. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 // Verifies that initializing the JavaScript Preferences class fires the correct | 750 // Verifies that initializing the JavaScript Preferences class fires the correct |
| 752 // notifications in JavaScript for pref values handled by the | 751 // notifications in JavaScript for pref values handled by the |
| 753 // CoreChromeOSOptionsHandler class for a managed device. | 752 // CoreChromeOSOptionsHandler class for a managed device. |
| 754 IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest, | 753 IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest, |
| 755 ChromeOSDeviceFetchPrefs) { | 754 ChromeOSDeviceFetchPrefs) { |
| 756 std::vector<std::unique_ptr<base::Value>> decorated_non_default_values; | 755 std::vector<std::unique_ptr<base::Value>> decorated_non_default_values; |
| 757 std::string observed_json; | 756 std::string observed_json; |
| 758 | 757 |
| 759 // Boolean pref. | 758 // Boolean pref. |
| 760 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); | 759 pref_names_.push_back(chromeos::kAccountsPrefAllowGuest); |
| 761 non_default_values_.push_back( | 760 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 762 base::MakeUnique<base::FundamentalValue>(false)); | |
| 763 decorated_non_default_values.push_back( | 761 decorated_non_default_values.push_back( |
| 764 non_default_values_.back()->CreateDeepCopy()); | 762 non_default_values_.back()->CreateDeepCopy()); |
| 765 | 763 |
| 766 // String pref. | 764 // String pref. |
| 767 pref_names_.push_back(chromeos::kReleaseChannel); | 765 pref_names_.push_back(chromeos::kReleaseChannel); |
| 768 non_default_values_.push_back( | 766 non_default_values_.push_back( |
| 769 base::MakeUnique<base::StringValue>("stable-channel")); | 767 base::MakeUnique<base::StringValue>("stable-channel")); |
| 770 decorated_non_default_values.push_back( | 768 decorated_non_default_values.push_back( |
| 771 non_default_values_.back()->CreateDeepCopy()); | 769 non_default_values_.back()->CreateDeepCopy()); |
| 772 | 770 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 EXPECT_EQ(expected_server, actual_proxy_server); | 944 EXPECT_EQ(expected_server, actual_proxy_server); |
| 947 EXPECT_EQ(expected_source, actual_source); | 945 EXPECT_EQ(expected_source, actual_source); |
| 948 } | 946 } |
| 949 }; | 947 }; |
| 950 | 948 |
| 951 // Verifies that proxy settings are correctly pushed to JavaScript during | 949 // Verifies that proxy settings are correctly pushed to JavaScript during |
| 952 // initialization of the proxy settings page. | 950 // initialization of the proxy settings page. |
| 953 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { | 951 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { |
| 954 // Boolean pref. | 952 // Boolean pref. |
| 955 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle); | 953 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle); |
| 956 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(true)); | 954 non_default_values_.push_back(base::MakeUnique<base::Value>(true)); |
| 957 | 955 |
| 958 // Integer prefs. | 956 // Integer prefs. |
| 959 pref_names_.push_back( | 957 pref_names_.push_back( |
| 960 chromeos::proxy_cros_settings_parser::kProxySingleHttpPort); | 958 chromeos::proxy_cros_settings_parser::kProxySingleHttpPort); |
| 961 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(8080)); | 959 non_default_values_.push_back(base::MakeUnique<base::Value>(8080)); |
| 962 | 960 |
| 963 // String pref. | 961 // String pref. |
| 964 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp); | 962 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp); |
| 965 non_default_values_.push_back( | 963 non_default_values_.push_back( |
| 966 base::MakeUnique<base::StringValue>("127.0.0.1")); | 964 base::MakeUnique<base::StringValue>("127.0.0.1")); |
| 967 | 965 |
| 968 // List pref. | 966 // List pref. |
| 969 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList); | 967 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList); |
| 970 auto list = base::MakeUnique<base::ListValue>(); | 968 auto list = base::MakeUnique<base::ListValue>(); |
| 971 list->AppendString("*.google.com"); | 969 list->AppendString("*.google.com"); |
| 972 list->AppendString("1.2.3.4:22"); | 970 list->AppendString("1.2.3.4:22"); |
| 973 non_default_values_.push_back(std::move(list)); | 971 non_default_values_.push_back(std::move(list)); |
| 974 | 972 |
| 975 // Verify that no policy is presented to the UI. This must be verified on the | 973 // Verify that no policy is presented to the UI. This must be verified on the |
| 976 // kProxyType and the kUseSharedProxies prefs. | 974 // kProxyType and the kUseSharedProxies prefs. |
| 977 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 975 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
| 978 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(2)); | 976 non_default_values_.push_back(base::MakeUnique<base::Value>(2)); |
| 979 | 977 |
| 980 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 978 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
| 981 non_default_values_.push_back( | 979 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 982 base::MakeUnique<base::FundamentalValue>(false)); | |
| 983 | 980 |
| 984 std::string observed_json; | 981 std::string observed_json; |
| 985 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 982 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 986 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", | 983 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", |
| 987 false, false); | 984 false, false); |
| 988 } | 985 } |
| 989 | 986 |
| 990 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) { | 987 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) { |
| 991 SetONCPolicy(policy::key::kOpenNetworkConfiguration, | 988 SetONCPolicy(policy::key::kOpenNetworkConfiguration, |
| 992 policy::POLICY_SCOPE_USER); | 989 policy::POLICY_SCOPE_USER); |
| 993 | 990 |
| 994 // Verify that per-network policy is presented to the UI. This must be | 991 // Verify that per-network policy is presented to the UI. This must be |
| 995 // verified on the kProxyType. | 992 // verified on the kProxyType. |
| 996 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 993 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
| 997 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3)); | 994 non_default_values_.push_back(base::MakeUnique<base::Value>(3)); |
| 998 | 995 |
| 999 std::string observed_json; | 996 std::string observed_json; |
| 1000 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 997 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 1001 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", | 998 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", |
| 1002 true, false); | 999 true, false); |
| 1003 | 1000 |
| 1004 // Verify that 'use-shared-proxies' is not affected by per-network policy. | 1001 // Verify that 'use-shared-proxies' is not affected by per-network policy. |
| 1005 pref_names_.clear(); | 1002 pref_names_.clear(); |
| 1006 non_default_values_.clear(); | 1003 non_default_values_.clear(); |
| 1007 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 1004 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
| 1008 non_default_values_.push_back( | 1005 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 1009 base::MakeUnique<base::FundamentalValue>(false)); | |
| 1010 | 1006 |
| 1011 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1007 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 1012 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", | 1008 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", |
| 1013 false, false); | 1009 false, false); |
| 1014 } | 1010 } |
| 1015 | 1011 |
| 1016 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) { | 1012 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) { |
| 1017 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration, | 1013 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration, |
| 1018 policy::POLICY_SCOPE_MACHINE); | 1014 policy::POLICY_SCOPE_MACHINE); |
| 1019 | 1015 |
| 1020 // Verify that the policy is presented to the UI. This verification must be | 1016 // Verify that the policy is presented to the UI. This verification must be |
| 1021 // done on the kProxyType pref. | 1017 // done on the kProxyType pref. |
| 1022 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 1018 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
| 1023 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3)); | 1019 non_default_values_.push_back(base::MakeUnique<base::Value>(3)); |
| 1024 | 1020 |
| 1025 std::string observed_json; | 1021 std::string observed_json; |
| 1026 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1022 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 1027 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", | 1023 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", |
| 1028 true, false); | 1024 true, false); |
| 1029 | 1025 |
| 1030 // Verify that 'use-shared-proxies' is not affected by per-network policy. | 1026 // Verify that 'use-shared-proxies' is not affected by per-network policy. |
| 1031 pref_names_.clear(); | 1027 pref_names_.clear(); |
| 1032 non_default_values_.clear(); | 1028 non_default_values_.clear(); |
| 1033 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 1029 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
| 1034 non_default_values_.push_back( | 1030 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 1035 base::MakeUnique<base::FundamentalValue>(false)); | |
| 1036 | 1031 |
| 1037 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1032 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 1038 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", | 1033 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "", |
| 1039 false, false); | 1034 false, false); |
| 1040 } | 1035 } |
| 1041 | 1036 |
| 1042 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) { | 1037 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) { |
| 1043 policy_names_.push_back(policy::key::kProxyMode); | 1038 policy_names_.push_back(policy::key::kProxyMode); |
| 1044 default_values_.push_back(base::MakeUnique<base::StringValue>( | 1039 default_values_.push_back(base::MakeUnique<base::StringValue>( |
| 1045 ProxyPrefs::kAutoDetectProxyModeName)); | 1040 ProxyPrefs::kAutoDetectProxyModeName)); |
| 1046 SetUserPolicies(policy_names_, default_values_, | 1041 SetUserPolicies(policy_names_, default_values_, |
| 1047 policy::POLICY_LEVEL_MANDATORY); | 1042 policy::POLICY_LEVEL_MANDATORY); |
| 1048 content::RunAllPendingInMessageLoop(); | 1043 content::RunAllPendingInMessageLoop(); |
| 1049 | 1044 |
| 1050 // Verify that the policy is presented to the UI. This verification must be | 1045 // Verify that the policy is presented to the UI. This verification must be |
| 1051 // done on the kProxyType pref. | 1046 // done on the kProxyType pref. |
| 1052 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); | 1047 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType); |
| 1053 non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3)); | 1048 non_default_values_.push_back(base::MakeUnique<base::Value>(3)); |
| 1054 | 1049 |
| 1055 // Verify that 'use-shared-proxies' is controlled by the policy. | 1050 // Verify that 'use-shared-proxies' is controlled by the policy. |
| 1056 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); | 1051 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies); |
| 1057 non_default_values_.push_back( | 1052 non_default_values_.push_back(base::MakeUnique<base::Value>(false)); |
| 1058 base::MakeUnique<base::FundamentalValue>(false)); | |
| 1059 | 1053 |
| 1060 std::string observed_json; | 1054 std::string observed_json; |
| 1061 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 1055 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
| 1062 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", | 1056 VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy", |
| 1063 true, false); | 1057 true, false); |
| 1064 } | 1058 } |
| 1065 | 1059 |
| 1066 // Verifies that modifications to the proxy settings are correctly pushed from | 1060 // Verifies that modifications to the proxy settings are correctly pushed from |
| 1067 // JavaScript to the ProxyConfig property stored in the network configuration. | 1061 // JavaScript to the ProxyConfig property stored in the network configuration. |
| 1068 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) { | 1062 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) { |
| 1069 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); | 1063 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); |
| 1070 | 1064 |
| 1071 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttpPort, | 1065 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttpPort, |
| 1072 base::FundamentalValue(123)); | 1066 base::Value(123)); |
| 1073 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttp, | 1067 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttp, |
| 1074 base::StringValue("www.adomain.xy")); | 1068 base::StringValue("www.adomain.xy")); |
| 1075 | 1069 |
| 1076 VerifyCurrentProxyServer("www.adomain.xy:123", | 1070 VerifyCurrentProxyServer("www.adomain.xy:123", |
| 1077 onc::ONC_SOURCE_NONE); | 1071 onc::ONC_SOURCE_NONE); |
| 1078 } | 1072 } |
| 1079 | 1073 |
| 1080 // Verify that default proxy ports are used and that ports can be updated | 1074 // Verify that default proxy ports are used and that ports can be updated |
| 1081 // without affecting the previously set hosts. | 1075 // without affecting the previously set hosts. |
| 1082 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) { | 1076 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) { |
| 1083 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); | 1077 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); |
| 1084 | 1078 |
| 1085 // Set to manual, per scheme proxy. | 1079 // Set to manual, per scheme proxy. |
| 1086 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingle, | 1080 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingle, |
| 1087 base::FundamentalValue(false)); | 1081 base::Value(false)); |
| 1088 | 1082 |
| 1089 // Set hosts but no ports. | 1083 // Set hosts but no ports. |
| 1090 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpUrl, | 1084 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpUrl, |
| 1091 base::StringValue("a.com")); | 1085 base::StringValue("a.com")); |
| 1092 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsUrl, | 1086 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsUrl, |
| 1093 base::StringValue("4.3.2.1")); | 1087 base::StringValue("4.3.2.1")); |
| 1094 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpUrl, | 1088 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpUrl, |
| 1095 base::StringValue("c.com")); | 1089 base::StringValue("c.com")); |
| 1096 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocks, | 1090 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocks, |
| 1097 base::StringValue("d.com")); | 1091 base::StringValue("d.com")); |
| 1098 | 1092 |
| 1099 // Verify default ports. | 1093 // Verify default ports. |
| 1100 VerifyCurrentProxyServer( | 1094 VerifyCurrentProxyServer( |
| 1101 "http=a.com:80;https=4.3.2.1:80;ftp=c.com:80;socks=socks4://d.com:1080", | 1095 "http=a.com:80;https=4.3.2.1:80;ftp=c.com:80;socks=socks4://d.com:1080", |
| 1102 onc::ONC_SOURCE_NONE); | 1096 onc::ONC_SOURCE_NONE); |
| 1103 | 1097 |
| 1104 // Set and verify the ports. | 1098 // Set and verify the ports. |
| 1105 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpPort, | 1099 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpPort, |
| 1106 base::FundamentalValue(1)); | 1100 base::Value(1)); |
| 1107 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsPort, | 1101 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsPort, |
| 1108 base::FundamentalValue(2)); | 1102 base::Value(2)); |
| 1109 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpPort, | 1103 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpPort, |
| 1110 base::FundamentalValue(3)); | 1104 base::Value(3)); |
| 1111 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort, | 1105 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort, |
| 1112 base::FundamentalValue(4)); | 1106 base::Value(4)); |
| 1113 | 1107 |
| 1114 VerifyCurrentProxyServer( | 1108 VerifyCurrentProxyServer( |
| 1115 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", | 1109 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", |
| 1116 onc::ONC_SOURCE_NONE); | 1110 onc::ONC_SOURCE_NONE); |
| 1117 } | 1111 } |
| 1118 | 1112 |
| 1119 #endif | 1113 #endif |
| OLD | NEW |