| 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 <iostream> | 7 #include <iostream> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "chrome/browser/browser_process.h" | 38 #include "chrome/browser/browser_process.h" |
| 39 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | 39 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
| 40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 41 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 41 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
| 42 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" | 42 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" |
| 43 #include "chrome/browser/chromeos/settings/cros_settings.h" | 43 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 44 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 44 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 45 #include "chromeos/dbus/dbus_thread_manager.h" | 45 #include "chromeos/dbus/dbus_thread_manager.h" |
| 46 #include "chromeos/dbus/shill_profile_client.h" | 46 #include "chromeos/dbus/shill_profile_client.h" |
| 47 #include "chromeos/dbus/shill_service_client.h" | 47 #include "chromeos/dbus/shill_service_client.h" |
| 48 #include "chromeos/network/favorite_state.h" | |
| 49 #include "chromeos/network/network_state.h" | 48 #include "chromeos/network/network_state.h" |
| 50 #include "chromeos/network/network_state_handler.h" | 49 #include "chromeos/network/network_state_handler.h" |
| 51 #include "chromeos/settings/cros_settings_names.h" | 50 #include "chromeos/settings/cros_settings_names.h" |
| 52 #include "content/public/test/test_utils.h" | 51 #include "content/public/test/test_utils.h" |
| 53 #include "third_party/cros_system_api/dbus/service_constants.h" | 52 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 54 #endif | 53 #endif |
| 55 | 54 |
| 56 using testing::AllOf; | 55 using testing::AllOf; |
| 57 using testing::Mock; | 56 using testing::Mock; |
| 58 using testing::Property; | 57 using testing::Property; |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 virtual void SetUpOnMainThread() OVERRIDE { | 816 virtual void SetUpOnMainThread() OVERRIDE { |
| 818 SetupNetworkEnvironment(); | 817 SetupNetworkEnvironment(); |
| 819 content::RunAllPendingInMessageLoop(); | 818 content::RunAllPendingInMessageLoop(); |
| 820 | 819 |
| 821 scoped_ptr<base::DictionaryValue> proxy_config_dict( | 820 scoped_ptr<base::DictionaryValue> proxy_config_dict( |
| 822 ProxyConfigDictionary::CreateFixedServers("127.0.0.1:8080", | 821 ProxyConfigDictionary::CreateFixedServers("127.0.0.1:8080", |
| 823 "*.google.com, 1.2.3.4:22")); | 822 "*.google.com, 1.2.3.4:22")); |
| 824 | 823 |
| 825 ProxyConfigDictionary proxy_config(proxy_config_dict.get()); | 824 ProxyConfigDictionary proxy_config(proxy_config_dict.get()); |
| 826 | 825 |
| 827 const chromeos::FavoriteState* network = GetDefaultFavoriteNetwork(); | 826 const chromeos::NetworkState* network = GetDefaultNetwork(); |
| 828 ASSERT_TRUE(network); | 827 ASSERT_TRUE(network); |
| 829 chromeos::proxy_config::SetProxyConfigForFavoriteNetwork(proxy_config, | 828 chromeos::proxy_config::SetProxyConfigForNetwork(proxy_config, *network); |
| 830 *network); | |
| 831 | 829 |
| 832 std::string url = base::StringPrintf("%s?network=%s", | 830 std::string url = base::StringPrintf("%s?network=%s", |
| 833 chrome::kChromeUIProxySettingsURL, | 831 chrome::kChromeUIProxySettingsURL, |
| 834 network->path().c_str()); | 832 network->path().c_str()); |
| 835 | 833 |
| 836 ui_test_utils::NavigateToURL(browser(), GURL(url)); | 834 ui_test_utils::NavigateToURL(browser(), GURL(url)); |
| 837 SetUpPrefs(); | 835 SetUpPrefs(); |
| 838 } | 836 } |
| 839 | 837 |
| 840 protected: | 838 protected: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 map.Set(policy_name, | 881 map.Set(policy_name, |
| 884 policy::POLICY_LEVEL_MANDATORY, | 882 policy::POLICY_LEVEL_MANDATORY, |
| 885 scope, | 883 scope, |
| 886 new base::StringValue(onc_policy), | 884 new base::StringValue(onc_policy), |
| 887 NULL); | 885 NULL); |
| 888 policy_provider_.UpdateChromePolicy(map); | 886 policy_provider_.UpdateChromePolicy(map); |
| 889 | 887 |
| 890 content::RunAllPendingInMessageLoop(); | 888 content::RunAllPendingInMessageLoop(); |
| 891 } | 889 } |
| 892 | 890 |
| 893 const chromeos::FavoriteState* GetDefaultFavoriteNetwork() { | 891 const chromeos::NetworkState* GetDefaultNetwork() { |
| 894 chromeos::NetworkStateHandler* handler = | 892 chromeos::NetworkStateHandler* handler = |
| 895 chromeos::NetworkHandler::Get()->network_state_handler(); | 893 chromeos::NetworkHandler::Get()->network_state_handler(); |
| 896 return handler->DefaultFavoriteNetwork(); | 894 return handler->DefaultNetwork(); |
| 897 } | 895 } |
| 898 | 896 |
| 899 void SetProxyPref(const std::string& name, const base::Value& value) { | 897 void SetProxyPref(const std::string& name, const base::Value& value) { |
| 900 std::string type; | 898 std::string type; |
| 901 switch (value.GetType()) { | 899 switch (value.GetType()) { |
| 902 case base::Value::TYPE_BOOLEAN: | 900 case base::Value::TYPE_BOOLEAN: |
| 903 type = "Boolean"; | 901 type = "Boolean"; |
| 904 break; | 902 break; |
| 905 case base::Value::TYPE_INTEGER: | 903 case base::Value::TYPE_INTEGER: |
| 906 type = "Integer"; | 904 type = "Integer"; |
| 907 break; | 905 break; |
| 908 case base::Value::TYPE_STRING: | 906 case base::Value::TYPE_STRING: |
| 909 type = "String"; | 907 type = "String"; |
| 910 break; | 908 break; |
| 911 default: | 909 default: |
| 912 ASSERT_TRUE(false); | 910 ASSERT_TRUE(false); |
| 913 } | 911 } |
| 914 | 912 |
| 915 std::string observed_json; | 913 std::string observed_json; |
| 916 SetPref(name, type, &value, true, &observed_json); | 914 SetPref(name, type, &value, true, &observed_json); |
| 917 } | 915 } |
| 918 | 916 |
| 919 void VerifyCurrentProxyServer(const std::string& expected_server, | 917 void VerifyCurrentProxyServer(const std::string& expected_server, |
| 920 onc::ONCSource expected_source) { | 918 onc::ONCSource expected_source) { |
| 921 const chromeos::FavoriteState* network = GetDefaultFavoriteNetwork(); | 919 const chromeos::NetworkState* network = GetDefaultNetwork(); |
| 922 ASSERT_TRUE(network); | 920 ASSERT_TRUE(network); |
| 923 onc::ONCSource actual_source; | 921 onc::ONCSource actual_source; |
| 924 scoped_ptr<ProxyConfigDictionary> proxy_dict = | 922 scoped_ptr<ProxyConfigDictionary> proxy_dict = |
| 925 chromeos::proxy_config::GetProxyConfigForFavoriteNetwork( | 923 chromeos::proxy_config::GetProxyConfigForNetwork( |
| 926 pref_service_, | 924 pref_service_, |
| 927 g_browser_process->local_state(), | 925 g_browser_process->local_state(), |
| 928 *network, | 926 *network, |
| 929 &actual_source); | 927 &actual_source); |
| 930 ASSERT_TRUE(proxy_dict); | 928 ASSERT_TRUE(proxy_dict); |
| 931 std::string actual_proxy_server; | 929 std::string actual_proxy_server; |
| 932 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server)); | 930 EXPECT_TRUE(proxy_dict->GetProxyServer(&actual_proxy_server)); |
| 933 EXPECT_EQ(expected_server, actual_proxy_server); | 931 EXPECT_EQ(expected_server, actual_proxy_server); |
| 934 EXPECT_EQ(expected_source, actual_source); | 932 EXPECT_EQ(expected_source, actual_source); |
| 935 } | 933 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); | 1081 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); |
| 1084 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); | 1082 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); |
| 1085 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); | 1083 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); |
| 1086 | 1084 |
| 1087 VerifyCurrentProxyServer( | 1085 VerifyCurrentProxyServer( |
| 1088 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", | 1086 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", |
| 1089 onc::ONC_SOURCE_NONE); | 1087 onc::ONC_SOURCE_NONE); |
| 1090 } | 1088 } |
| 1091 | 1089 |
| 1092 #endif | 1090 #endif |
| OLD | NEW |