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

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

Issue 2445153002: Move onc and proxy pref names to components. (Closed)
Patch Set: ONC_EXPORT Created 4 years, 1 month 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/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 45 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
46 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" 46 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h"
47 #include "chrome/browser/chromeos/settings/cros_settings.h" 47 #include "chrome/browser/chromeos/settings/cros_settings.h"
48 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" 48 #include "chrome/browser/chromeos/settings/stub_install_attributes.h"
49 #include "chromeos/dbus/dbus_thread_manager.h" 49 #include "chromeos/dbus/dbus_thread_manager.h"
50 #include "chromeos/dbus/shill_profile_client.h" 50 #include "chromeos/dbus/shill_profile_client.h"
51 #include "chromeos/dbus/shill_service_client.h" 51 #include "chromeos/dbus/shill_service_client.h"
52 #include "chromeos/network/network_state.h" 52 #include "chromeos/network/network_state.h"
53 #include "chromeos/network/network_state_handler.h" 53 #include "chromeos/network/network_state_handler.h"
54 #include "chromeos/settings/cros_settings_names.h" 54 #include "chromeos/settings/cros_settings_names.h"
55 #include "components/onc/onc_pref_names.h"
55 #include "components/proxy_config/proxy_config_dictionary.h" 56 #include "components/proxy_config/proxy_config_dictionary.h"
57 #include "components/proxy_config/proxy_config_pref_names.h"
56 #include "content/public/test/test_utils.h" 58 #include "content/public/test/test_utils.h"
57 #include "third_party/cros_system_api/dbus/service_constants.h" 59 #include "third_party/cros_system_api/dbus/service_constants.h"
58 #endif 60 #endif
59 61
60 using testing::AllOf; 62 using testing::AllOf;
61 using testing::Mock; 63 using testing::Mock;
62 using testing::Property; 64 using testing::Property;
63 using testing::Return; 65 using testing::Return;
64 using testing::_; 66 using testing::_;
65 67
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server)); 931 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server));
930 EXPECT_EQ(expected_server, actual_proxy_server); 932 EXPECT_EQ(expected_server, actual_proxy_server);
931 EXPECT_EQ(expected_source, actual_source); 933 EXPECT_EQ(expected_source, actual_source);
932 } 934 }
933 }; 935 };
934 936
935 // Verifies that proxy settings are correctly pushed to JavaScript during 937 // Verifies that proxy settings are correctly pushed to JavaScript during
936 // initialization of the proxy settings page. 938 // initialization of the proxy settings page.
937 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) { 939 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) {
938 // Boolean pref. 940 // Boolean pref.
939 pref_names_.push_back(chromeos::kProxySingle); 941 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle);
940 non_default_values_.push_back(new base::FundamentalValue(true)); 942 non_default_values_.push_back(new base::FundamentalValue(true));
941 943
942 // Integer prefs. 944 // Integer prefs.
943 pref_names_.push_back(chromeos::kProxySingleHttpPort); 945 pref_names_.push_back(
946 chromeos::proxy_cros_settings_parser::kProxySingleHttpPort);
944 non_default_values_.push_back(new base::FundamentalValue(8080)); 947 non_default_values_.push_back(new base::FundamentalValue(8080));
945 948
946 // String pref. 949 // String pref.
947 pref_names_.push_back(chromeos::kProxySingleHttp); 950 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp);
948 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"));
949 952
950 // List pref. 953 // List pref.
951 pref_names_.push_back(chromeos::kProxyIgnoreList); 954 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList);
952 base::ListValue* list = new base::ListValue(); 955 base::ListValue* list = new base::ListValue();
953 list->AppendString("*.google.com"); 956 list->AppendString("*.google.com");
954 list->AppendString("1.2.3.4:22"); 957 list->AppendString("1.2.3.4:22");
955 non_default_values_.push_back(list); 958 non_default_values_.push_back(list);
956 959
957 // 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
958 // kProxyType and the kUseSharedProxies prefs. 961 // kProxyType and the kUseSharedProxies prefs.
959 pref_names_.push_back(chromeos::kProxyType); 962 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
960 non_default_values_.push_back(new base::FundamentalValue(2)); 963 non_default_values_.push_back(new base::FundamentalValue(2));
961 964
962 pref_names_.push_back(prefs::kUseSharedProxies); 965 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
963 non_default_values_.push_back(new base::FundamentalValue(false)); 966 non_default_values_.push_back(new base::FundamentalValue(false));
964 967
965 std::string observed_json; 968 std::string observed_json;
966 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 969 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
967 VerifyObservedPrefs( 970 VerifyObservedPrefs(
968 observed_json, pref_names_, non_default_values_.get(), "", false, false); 971 observed_json, pref_names_, non_default_values_.get(), "", false, false);
969 } 972 }
970 973
971 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) { 974 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) {
972 SetONCPolicy(policy::key::kOpenNetworkConfiguration, 975 SetONCPolicy(policy::key::kOpenNetworkConfiguration,
973 policy::POLICY_SCOPE_USER); 976 policy::POLICY_SCOPE_USER);
974 977
975 // 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
976 // verified on the kProxyType. 979 // verified on the kProxyType.
977 pref_names_.push_back(chromeos::kProxyType); 980 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
978 non_default_values_.push_back(new base::FundamentalValue(3)); 981 non_default_values_.push_back(new base::FundamentalValue(3));
979 982
980 std::string observed_json; 983 std::string observed_json;
981 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 984 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
982 VerifyObservedPrefs( 985 VerifyObservedPrefs(
983 observed_json, pref_names_, non_default_values_.get(), 986 observed_json, pref_names_, non_default_values_.get(),
984 "policy", true, false); 987 "policy", true, false);
985 988
986 // 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.
987 pref_names_.clear(); 990 pref_names_.clear();
988 non_default_values_.clear(); 991 non_default_values_.clear();
989 pref_names_.push_back(prefs::kUseSharedProxies); 992 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
990 non_default_values_.push_back(new base::FundamentalValue(false)); 993 non_default_values_.push_back(new base::FundamentalValue(false));
991 994
992 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 995 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
993 VerifyObservedPrefs( 996 VerifyObservedPrefs(
994 observed_json, pref_names_, non_default_values_.get(), "", false, false); 997 observed_json, pref_names_, non_default_values_.get(), "", false, false);
995 } 998 }
996 999
997 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) { 1000 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) {
998 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration, 1001 SetONCPolicy(policy::key::kDeviceOpenNetworkConfiguration,
999 policy::POLICY_SCOPE_MACHINE); 1002 policy::POLICY_SCOPE_MACHINE);
1000 1003
1001 // 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
1002 // done on the kProxyType pref. 1005 // done on the kProxyType pref.
1003 pref_names_.push_back(chromeos::kProxyType); 1006 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
1004 non_default_values_.push_back(new base::FundamentalValue(3)); 1007 non_default_values_.push_back(new base::FundamentalValue(3));
1005 1008
1006 std::string observed_json; 1009 std::string observed_json;
1007 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 1010 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
1008 VerifyObservedPrefs( 1011 VerifyObservedPrefs(
1009 observed_json, pref_names_, non_default_values_.get(), 1012 observed_json, pref_names_, non_default_values_.get(),
1010 "policy", true, false); 1013 "policy", true, false);
1011 1014
1012 // 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.
1013 pref_names_.clear(); 1016 pref_names_.clear();
1014 non_default_values_.clear(); 1017 non_default_values_.clear();
1015 pref_names_.push_back(prefs::kUseSharedProxies); 1018 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
1016 non_default_values_.push_back(new base::FundamentalValue(false)); 1019 non_default_values_.push_back(new base::FundamentalValue(false));
1017 1020
1018 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 1021 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
1019 VerifyObservedPrefs( 1022 VerifyObservedPrefs(
1020 observed_json, pref_names_, non_default_values_.get(), "", false, false); 1023 observed_json, pref_names_, non_default_values_.get(), "", false, false);
1021 } 1024 }
1022 1025
1023 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) { 1026 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) {
1024 policy_names_.push_back(policy::key::kProxyMode); 1027 policy_names_.push_back(policy::key::kProxyMode);
1025 default_values_.push_back( 1028 default_values_.push_back(
1026 new base::StringValue(ProxyPrefs::kAutoDetectProxyModeName)); 1029 new base::StringValue(ProxyPrefs::kAutoDetectProxyModeName));
1027 SetUserPolicies( 1030 SetUserPolicies(
1028 policy_names_, default_values_.get(), policy::POLICY_LEVEL_MANDATORY); 1031 policy_names_, default_values_.get(), policy::POLICY_LEVEL_MANDATORY);
1029 content::RunAllPendingInMessageLoop(); 1032 content::RunAllPendingInMessageLoop();
1030 1033
1031 // 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
1032 // done on the kProxyType pref. 1035 // done on the kProxyType pref.
1033 pref_names_.push_back(chromeos::kProxyType); 1036 pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
1034 non_default_values_.push_back(new base::FundamentalValue(3)); 1037 non_default_values_.push_back(new base::FundamentalValue(3));
1035 1038
1036 // Verify that 'use-shared-proxies' is controlled by the policy. 1039 // Verify that 'use-shared-proxies' is controlled by the policy.
1037 pref_names_.push_back(prefs::kUseSharedProxies); 1040 pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
1038 non_default_values_.push_back(new base::FundamentalValue(false)); 1041 non_default_values_.push_back(new base::FundamentalValue(false));
1039 1042
1040 std::string observed_json; 1043 std::string observed_json;
1041 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 1044 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
1042 VerifyObservedPrefs( 1045 VerifyObservedPrefs(
1043 observed_json, pref_names_, non_default_values_.get(), 1046 observed_json, pref_names_, non_default_values_.get(),
1044 "policy", true, false); 1047 "policy", true, false);
1045 } 1048 }
1046 1049
1047 // Verifies that modifications to the proxy settings are correctly pushed from 1050 // Verifies that modifications to the proxy settings are correctly pushed from
1048 // JavaScript to the ProxyConfig property stored in the network configuration. 1051 // JavaScript to the ProxyConfig property stored in the network configuration.
1049 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) { 1052 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSSetProxy) {
1050 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); 1053 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
1051 1054
1052 SetProxyPref(chromeos::kProxySingleHttpPort, base::FundamentalValue(123)); 1055 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttpPort,
1053 SetProxyPref(chromeos::kProxySingleHttp, base::StringValue("www.adomain.xy")); 1056 base::FundamentalValue(123));
1057 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingleHttp,
1058 base::StringValue("www.adomain.xy"));
1054 1059
1055 VerifyCurrentProxyServer("www.adomain.xy:123", 1060 VerifyCurrentProxyServer("www.adomain.xy:123",
1056 onc::ONC_SOURCE_NONE); 1061 onc::ONC_SOURCE_NONE);
1057 } 1062 }
1058 1063
1059 // 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
1060 // without affecting the previously set hosts. 1065 // without affecting the previously set hosts.
1061 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) { 1066 IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSProxyDefaultPorts) {
1062 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL)); 1067 ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
1063 1068
1064 // Set to manual, per scheme proxy. 1069 // Set to manual, per scheme proxy.
1065 SetProxyPref(chromeos::kProxySingle, base::FundamentalValue(false)); 1070 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySingle,
1071 base::FundamentalValue(false));
1066 1072
1067 // Set hosts but no ports. 1073 // Set hosts but no ports.
1068 SetProxyPref(chromeos::kProxyHttpUrl, base::StringValue("a.com")); 1074 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpUrl,
1069 SetProxyPref(chromeos::kProxyHttpsUrl, base::StringValue("4.3.2.1")); 1075 base::StringValue("a.com"));
1070 SetProxyPref(chromeos::kProxyFtpUrl, base::StringValue("c.com")); 1076 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsUrl,
1071 SetProxyPref(chromeos::kProxySocks, base::StringValue("d.com")); 1077 base::StringValue("4.3.2.1"));
1078 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpUrl,
1079 base::StringValue("c.com"));
1080 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocks,
1081 base::StringValue("d.com"));
1072 1082
1073 // Verify default ports. 1083 // Verify default ports.
1074 VerifyCurrentProxyServer( 1084 VerifyCurrentProxyServer(
1075 "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",
1076 onc::ONC_SOURCE_NONE); 1086 onc::ONC_SOURCE_NONE);
1077 1087
1078 // Set and verify the ports. 1088 // Set and verify the ports.
1079 SetProxyPref(chromeos::kProxyHttpPort, base::FundamentalValue(1)); 1089 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpPort,
1080 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); 1090 base::FundamentalValue(1));
1081 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); 1091 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyHttpsPort,
1082 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); 1092 base::FundamentalValue(2));
1093 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxyFtpPort,
1094 base::FundamentalValue(3));
1095 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort,
1096 base::FundamentalValue(4));
1083 1097
1084 VerifyCurrentProxyServer( 1098 VerifyCurrentProxyServer(
1085 "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",
1086 onc::ONC_SOURCE_NONE); 1100 onc::ONC_SOURCE_NONE);
1087 } 1101 }
1088 1102
1089 #endif 1103 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698