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> |
11 #include <sstream> | 11 #include <sstream> |
| 12 #include <utility> |
12 | 13 |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
15 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 750 |
750 // String pref. | 751 // String pref. |
751 pref_names_.push_back(chromeos::kReleaseChannel); | 752 pref_names_.push_back(chromeos::kReleaseChannel); |
752 non_default_values_.push_back(new base::StringValue("stable-channel")); | 753 non_default_values_.push_back(new base::StringValue("stable-channel")); |
753 decorated_non_default_values.push_back( | 754 decorated_non_default_values.push_back( |
754 non_default_values_.back()->DeepCopy()); | 755 non_default_values_.back()->DeepCopy()); |
755 | 756 |
756 // List pref. | 757 // List pref. |
757 pref_names_.push_back(chromeos::kAccountsPrefUsers); | 758 pref_names_.push_back(chromeos::kAccountsPrefUsers); |
758 base::ListValue* list = new base::ListValue; | 759 base::ListValue* list = new base::ListValue; |
759 list->Append(new base::StringValue("me@google.com")); | 760 list->AppendString("me@google.com"); |
760 list->Append(new base::StringValue("you@google.com")); | 761 list->AppendString("you@google.com"); |
761 non_default_values_.push_back(list); | 762 non_default_values_.push_back(list); |
762 list = new base::ListValue; | 763 list = new base::ListValue; |
763 base::DictionaryValue* dict = new base::DictionaryValue; | 764 auto dict = base::MakeUnique<base::DictionaryValue>(); |
764 dict->SetString("username", "me@google.com"); | 765 dict->SetString("username", "me@google.com"); |
765 dict->SetString("name", "me@google.com"); | 766 dict->SetString("name", "me@google.com"); |
766 dict->SetString("email", ""); | 767 dict->SetString("email", ""); |
767 dict->SetBoolean("owner", false); | 768 dict->SetBoolean("owner", false); |
768 list->Append(dict); | 769 list->Append(std::move(dict)); |
769 dict = new base::DictionaryValue; | 770 dict = base::MakeUnique<base::DictionaryValue>(); |
770 dict->SetString("username", "you@google.com"); | 771 dict->SetString("username", "you@google.com"); |
771 dict->SetString("name", "you@google.com"); | 772 dict->SetString("name", "you@google.com"); |
772 dict->SetString("email", ""); | 773 dict->SetString("email", ""); |
773 dict->SetBoolean("owner", false); | 774 dict->SetBoolean("owner", false); |
774 list->Append(dict); | 775 list->Append(std::move(dict)); |
775 decorated_non_default_values.push_back(list); | 776 decorated_non_default_values.push_back(list); |
776 | 777 |
777 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); | 778 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); |
778 for (size_t i = 0; i < pref_names_.size(); ++i) { | 779 for (size_t i = 0; i < pref_names_.size(); ++i) { |
779 cros_settings->Set(pref_names_[i], *non_default_values_[i]); | 780 cros_settings->Set(pref_names_[i], *non_default_values_[i]); |
780 } | 781 } |
781 | 782 |
782 // Verify notifications when mandatory values are in effect. | 783 // Verify notifications when mandatory values are in effect. |
783 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); | 784 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); |
784 VerifyObservedPrefs(observed_json, pref_names_, | 785 VerifyObservedPrefs(observed_json, pref_names_, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 pref_names_.push_back(chromeos::kProxySingleHttpPort); | 944 pref_names_.push_back(chromeos::kProxySingleHttpPort); |
944 non_default_values_.push_back(new base::FundamentalValue(8080)); | 945 non_default_values_.push_back(new base::FundamentalValue(8080)); |
945 | 946 |
946 // String pref. | 947 // String pref. |
947 pref_names_.push_back(chromeos::kProxySingleHttp); | 948 pref_names_.push_back(chromeos::kProxySingleHttp); |
948 non_default_values_.push_back(new base::StringValue("127.0.0.1")); | 949 non_default_values_.push_back(new base::StringValue("127.0.0.1")); |
949 | 950 |
950 // List pref. | 951 // List pref. |
951 pref_names_.push_back(chromeos::kProxyIgnoreList); | 952 pref_names_.push_back(chromeos::kProxyIgnoreList); |
952 base::ListValue* list = new base::ListValue(); | 953 base::ListValue* list = new base::ListValue(); |
953 list->Append(new base::StringValue("*.google.com")); | 954 list->AppendString("*.google.com"); |
954 list->Append(new base::StringValue("1.2.3.4:22")); | 955 list->AppendString("1.2.3.4:22"); |
955 non_default_values_.push_back(list); | 956 non_default_values_.push_back(list); |
956 | 957 |
957 // Verify that no policy is presented to the UI. This must be verified on the | 958 // Verify that no policy is presented to the UI. This must be verified on the |
958 // kProxyType and the kUseSharedProxies prefs. | 959 // kProxyType and the kUseSharedProxies prefs. |
959 pref_names_.push_back(chromeos::kProxyType); | 960 pref_names_.push_back(chromeos::kProxyType); |
960 non_default_values_.push_back(new base::FundamentalValue(2)); | 961 non_default_values_.push_back(new base::FundamentalValue(2)); |
961 | 962 |
962 pref_names_.push_back(prefs::kUseSharedProxies); | 963 pref_names_.push_back(prefs::kUseSharedProxies); |
963 non_default_values_.push_back(new base::FundamentalValue(false)); | 964 non_default_values_.push_back(new base::FundamentalValue(false)); |
964 | 965 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); | 1081 SetProxyPref(chromeos::kProxyHttpsPort, base::FundamentalValue(2)); |
1081 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); | 1082 SetProxyPref(chromeos::kProxyFtpPort, base::FundamentalValue(3)); |
1082 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); | 1083 SetProxyPref(chromeos::kProxySocksPort, base::FundamentalValue(4)); |
1083 | 1084 |
1084 VerifyCurrentProxyServer( | 1085 VerifyCurrentProxyServer( |
1085 "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", |
1086 onc::ONC_SOURCE_NONE); | 1087 onc::ONC_SOURCE_NONE); |
1087 } | 1088 } |
1088 | 1089 |
1089 #endif | 1090 #endif |
OLD | NEW |