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

Unified Diff: chrome/browser/ui/webui/options/preferences_browsertest.cc

Issue 2606293002: Remove ScopedVector from chrome/browser/ui. (Closed)
Patch Set: one last fix Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/preferences_browsertest.cc
diff --git a/chrome/browser/ui/webui/options/preferences_browsertest.cc b/chrome/browser/ui/webui/options/preferences_browsertest.cc
index ce8e297fa2a5a75049ab230b4082246ecb842795..3ae4ac8ffc510ac7b4fb4676c68d42f9c9718de5 100644
--- a/chrome/browser/ui/webui/options/preferences_browsertest.cc
+++ b/chrome/browser/ui/webui/options/preferences_browsertest.cc
@@ -215,7 +215,7 @@ void PreferencesBrowserTest::SetUpInProcessBrowserTestFixture() {
void PreferencesBrowserTest::SetUserPolicies(
const std::vector<std::string>& names,
- const std::vector<base::Value*>& values,
+ const std::vector<std::unique_ptr<base::Value>>& values,
policy::PolicyLevel level) {
policy::PolicyMap map;
for (size_t i = 0; i < names.size(); ++i) {
@@ -232,7 +232,7 @@ void PreferencesBrowserTest::ClearUserPolicies() {
void PreferencesBrowserTest::SetUserValues(
const std::vector<std::string>& names,
- const std::vector<base::Value*>& values) {
+ const std::vector<std::unique_ptr<base::Value>>& values) {
for (size_t i = 0; i < names.size(); ++i) {
pref_service()->Set(names[i].c_str(), *values[i]);
}
@@ -247,12 +247,13 @@ void PreferencesBrowserTest::VerifyKeyValue(const base::DictionaryValue& dict,
EXPECT_EQ(expected, *actual) << "Was checking key: " << key;
}
-void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs,
- const std::string& name,
- const base::Value* value,
- const std::string& controlledBy,
- bool disabled,
- bool uncommitted) {
+void PreferencesBrowserTest::VerifyPref(
+ const base::DictionaryValue* prefs,
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value,
+ const std::string& controlledBy,
+ bool disabled,
+ bool uncommitted) {
const base::Value* pref = NULL;
const base::DictionaryValue* dict = NULL;
ASSERT_TRUE(prefs->GetWithoutPathExpansion(name, &pref));
@@ -274,12 +275,13 @@ void PreferencesBrowserTest::VerifyPref(const base::DictionaryValue* prefs,
VerifyKeyValue(*dict, "uncommitted", base::FundamentalValue(false));
}
-void PreferencesBrowserTest::VerifyObservedPref(const std::string& json,
- const std::string& name,
- const base::Value* value,
- const std::string& controlledBy,
- bool disabled,
- bool uncommitted) {
+void PreferencesBrowserTest::VerifyObservedPref(
+ const std::string& json,
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value,
+ const std::string& controlledBy,
+ bool disabled,
+ bool uncommitted) {
std::unique_ptr<base::Value> observed_value_ptr =
base::JSONReader::Read(json);
const base::DictionaryValue* observed_dict;
@@ -291,7 +293,7 @@ void PreferencesBrowserTest::VerifyObservedPref(const std::string& json,
void PreferencesBrowserTest::VerifyObservedPrefs(
const std::string& json,
const std::vector<std::string>& names,
- const std::vector<base::Value*>& values,
+ const std::vector<std::unique_ptr<base::Value>>& values,
const std::string& controlledBy,
bool disabled,
bool uncommitted) {
@@ -315,16 +317,19 @@ void PreferencesBrowserTest::ExpectNoCommit(const std::string& name) {
.Times(0);
}
-void PreferencesBrowserTest::ExpectSetCommit(const std::string& name,
- const base::Value* value) {
+void PreferencesBrowserTest::ExpectSetCommit(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value) {
pref_change_registrar_->Add(
name.c_str(),
base::Bind(&PreferencesBrowserTest::OnPreferenceChanged,
base::Unretained(this)));
- EXPECT_CALL(*this, OnCommit(AllOf(
- Property(&PrefService::Preference::name, name),
- Property(&PrefService::Preference::IsUserControlled, true),
- Property(&PrefService::Preference::GetValue, EqualsValue(value)))));
+ EXPECT_CALL(
+ *this,
+ OnCommit(AllOf(Property(&PrefService::Preference::name, name),
+ Property(&PrefService::Preference::IsUserControlled, true),
+ Property(&PrefService::Preference::GetValue,
+ EqualsValue(value.get())))));
}
void PreferencesBrowserTest::ExpectClearCommit(const std::string& name) {
@@ -347,8 +352,7 @@ void PreferencesBrowserTest::SetupJavaScriptTestEnvironment(
std::string* observed_json) const {
std::stringstream javascript;
javascript << "var testEnv = new TestEnv();";
- for (std::vector<std::string>::const_iterator name = pref_names.begin();
- name != pref_names.end(); ++name) {
+ for (auto name = pref_names.begin(); name != pref_names.end(); ++name) {
stevenjb 2017/01/04 17:56:16 nit: const auto&
Avi (use Gerrit) 2017/01/04 18:44:39 Done.
javascript << "testEnv.addPref('" << name->c_str() << "');";
}
javascript << "testEnv.setupAndReply();";
@@ -361,7 +365,7 @@ void PreferencesBrowserTest::SetupJavaScriptTestEnvironment(
void PreferencesBrowserTest::SetPref(const std::string& name,
const std::string& type,
- const base::Value* value,
+ const std::unique_ptr<base::Value>& value,
bool commit,
std::string* observed_json) {
std::unique_ptr<base::Value> commit_ptr(new base::FundamentalValue(commit));
@@ -376,10 +380,11 @@ void PreferencesBrowserTest::SetPref(const std::string& name,
render_view_host_, javascript.str(), observed_json));
}
-void PreferencesBrowserTest::VerifySetPref(const std::string& name,
- const std::string& type,
- const base::Value* value,
- bool commit) {
+void PreferencesBrowserTest::VerifySetPref(
+ const std::string& name,
+ const std::string& type,
+ const std::unique_ptr<base::Value>& value,
+ bool commit) {
if (commit)
ExpectSetCommit(name, value);
else
@@ -390,9 +395,10 @@ void PreferencesBrowserTest::VerifySetPref(const std::string& name,
VerifyAndClearExpectations();
}
-void PreferencesBrowserTest::VerifyClearPref(const std::string& name,
- const base::Value* value,
- bool commit) {
+void PreferencesBrowserTest::VerifyClearPref(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value,
+ bool commit) {
if (commit)
ExpectClearCommit(name);
else
@@ -411,9 +417,10 @@ void PreferencesBrowserTest::VerifyClearPref(const std::string& name,
VerifyAndClearExpectations();
}
-void PreferencesBrowserTest::VerifyCommit(const std::string& name,
- const base::Value* value,
- const std::string& controlledBy) {
+void PreferencesBrowserTest::VerifyCommit(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value,
+ const std::string& controlledBy) {
std::stringstream javascript;
javascript << "testEnv.runAndReply(function() {"
<< " Preferences.getInstance().commitPref("
@@ -424,23 +431,26 @@ void PreferencesBrowserTest::VerifyCommit(const std::string& name,
VerifyObservedPref(observed_json, name, value, controlledBy, false, false);
}
-void PreferencesBrowserTest::VerifySetCommit(const std::string& name,
- const base::Value* value) {
+void PreferencesBrowserTest::VerifySetCommit(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value) {
ExpectSetCommit(name, value);
VerifyCommit(name, value, std::string());
VerifyAndClearExpectations();
}
-void PreferencesBrowserTest::VerifyClearCommit(const std::string& name,
- const base::Value* value) {
+void PreferencesBrowserTest::VerifyClearCommit(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value) {
ExpectClearCommit(name);
VerifyCommit(name, value, "recommended");
VerifyAndClearExpectations();
}
-void PreferencesBrowserTest::VerifyRollback(const std::string& name,
- const base::Value* value,
- const std::string& controlledBy) {
+void PreferencesBrowserTest::VerifyRollback(
+ const std::string& name,
+ const std::unique_ptr<base::Value>& value,
+ const std::string& controlledBy) {
ExpectNoCommit(name);
std::stringstream javascript;
javascript << "testEnv.runAndReply(function() {"
@@ -470,30 +480,30 @@ void PreferencesBrowserTest::UseDefaultTestPrefs(bool includeListPref) {
types_.push_back("Boolean");
pref_names_.push_back(prefs::kAlternateErrorPagesEnabled);
policy_names_.push_back(policy::key::kAlternateErrorPagesEnabled);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
// Integer pref.
types_.push_back("Integer");
pref_names_.push_back(prefs::kRestoreOnStartup);
policy_names_.push_back(policy::key::kRestoreOnStartup);
- non_default_values_.push_back(new base::FundamentalValue(4));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(4));
// List pref.
if (includeListPref) {
types_.push_back("List");
pref_names_.push_back(prefs::kURLsToRestoreOnStartup);
policy_names_.push_back(policy::key::kRestoreOnStartupURLs);
- base::ListValue* list = new base::ListValue;
+ std::unique_ptr<base::ListValue> list = base::MakeUnique<base::ListValue>();
stevenjb 2017/01/04 17:56:16 nit: auto
Avi (use Gerrit) 2017/01/04 18:44:39 Done here and elsewhere.
list->AppendString("http://www.example.com");
list->AppendString("http://example.com");
- non_default_values_.push_back(list);
+ non_default_values_.push_back(std::move(list));
}
// Retrieve default values.
- for (std::vector<std::string>::const_iterator name = pref_names_.begin();
- name != pref_names_.end(); ++name) {
+ for (auto name = pref_names_.begin(); name != pref_names_.end(); ++name) {
stevenjb 2017/01/04 17:56:16 const&
Avi (use Gerrit) 2017/01/04 18:44:39 Done.
default_values_.push_back(
- pref_service()->GetDefaultPrefValue(name->c_str())->DeepCopy());
+ pref_service()->GetDefaultPrefValue(name->c_str())->CreateDeepCopy());
}
}
@@ -505,34 +515,29 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, FetchPrefs) {
// Verify notifications when default values are in effect.
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, default_values_.get(),
- std::string(), false, false);
+ VerifyObservedPrefs(observed_json, pref_names_, default_values_,
+ std::string(), false, false);
// Verify notifications when recommended values are in effect.
- SetUserPolicies(policy_names_, non_default_values_.get(),
+ SetUserPolicies(policy_names_, non_default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, non_default_values_.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_,
"recommended", false, false);
// Verify notifications when mandatory values are in effect.
- SetUserPolicies(policy_names_, non_default_values_.get(),
+ SetUserPolicies(policy_names_, non_default_values_,
policy::POLICY_LEVEL_MANDATORY);
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, non_default_values_.get(),
- "policy", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy",
+ true, false);
// Verify notifications when user-modified values are in effect.
ClearUserPolicies();
- SetUserValues(pref_names_, non_default_values_.get());
+ SetUserValues(pref_names_, non_default_values_);
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json,
- pref_names_,
- non_default_values_.get(),
- std::string(),
- false,
- false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_,
+ std::string(), false, false);
}
// Verifies that setting a user-modified pref value through the JavaScript
@@ -553,9 +558,9 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, SetPrefs) {
IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ClearPrefs) {
UseDefaultTestPrefs(false);
- SetUserPolicies(policy_names_, default_values_.get(),
+ SetUserPolicies(policy_names_, default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
- SetUserValues(pref_names_, non_default_values_.get());
+ SetUserValues(pref_names_, non_default_values_);
ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
for (size_t i = 0; i < pref_names_.size(); ++i) {
VerifyClearPref(pref_names_[i], default_values_[i], true);
@@ -590,7 +595,7 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, DialogPrefsSetRollback) {
}
// Verify behavior when recommended values are in effect.
- SetUserPolicies(policy_names_, default_values_.get(),
+ SetUserPolicies(policy_names_, default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
for (size_t i = 0; i < pref_names_.size(); ++i) {
@@ -606,9 +611,9 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, DialogPrefsSetRollback) {
IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, DialogPrefsClearCommit) {
UseDefaultTestPrefs(false);
- SetUserPolicies(policy_names_, default_values_.get(),
+ SetUserPolicies(policy_names_, default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
- SetUserValues(pref_names_, non_default_values_.get());
+ SetUserValues(pref_names_, non_default_values_);
ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
for (size_t i = 0; i < pref_names_.size(); ++i) {
VerifyClearPref(pref_names_[i], default_values_[i], false);
@@ -622,9 +627,9 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, DialogPrefsClearCommit) {
IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, DialogPrefsClearRollback) {
UseDefaultTestPrefs(false);
- SetUserPolicies(policy_names_, default_values_.get(),
+ SetUserPolicies(policy_names_, default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
- SetUserValues(pref_names_, non_default_values_.get());
+ SetUserValues(pref_names_, non_default_values_);
ASSERT_NO_FATAL_FAILURE(SetupJavaScriptTestEnvironment(pref_names_, NULL));
for (size_t i = 0; i < pref_names_.size(); ++i) {
VerifyClearPref(pref_names_[i], default_values_[i], false);
@@ -642,38 +647,33 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, NotificationsOnBackendChanges) {
// Verify notifications when recommended values come into effect.
StartObserving();
- SetUserPolicies(policy_names_, non_default_values_.get(),
+ SetUserPolicies(policy_names_, non_default_values_,
policy::POLICY_LEVEL_RECOMMENDED);
FinishObserving(&observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, non_default_values_.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_,
"recommended", false, false);
// Verify notifications when mandatory values come into effect.
StartObserving();
- SetUserPolicies(policy_names_, non_default_values_.get(),
+ SetUserPolicies(policy_names_, non_default_values_,
policy::POLICY_LEVEL_MANDATORY);
FinishObserving(&observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, non_default_values_.get(),
- "policy", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy",
+ true, false);
// Verify notifications when default values come into effect.
StartObserving();
ClearUserPolicies();
FinishObserving(&observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, default_values_.get(),
- std::string(), false, false);
+ VerifyObservedPrefs(observed_json, pref_names_, default_values_,
+ std::string(), false, false);
// Verify notifications when user-modified values come into effect.
StartObserving();
- SetUserValues(pref_names_, non_default_values_.get());
+ SetUserValues(pref_names_, non_default_values_);
FinishObserving(&observed_json);
- VerifyObservedPrefs(observed_json,
- pref_names_,
- non_default_values_.get(),
- std::string(),
- false,
- false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_,
+ std::string(), false, false);
}
#if defined(OS_CHROMEOS)
@@ -686,20 +686,20 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) {
// Boolean pref.
pref_names_.push_back(chromeos::kAccountsPrefAllowGuest);
- default_values_.push_back(new base::FundamentalValue(true));
+ default_values_.push_back(base::MakeUnique<base::FundamentalValue>(true));
// String pref.
pref_names_.push_back(chromeos::kReleaseChannel);
- default_values_.push_back(new base::StringValue(""));
+ default_values_.push_back(base::MakeUnique<base::StringValue>(""));
// List pref.
pref_names_.push_back(chromeos::kAccountsPrefUsers);
- default_values_.push_back(new base::ListValue);
+ default_values_.push_back(base::MakeUnique<base::ListValue>());
// Verify notifications when default values are in effect.
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, default_values_.get(),
- "owner", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, default_values_, "owner",
+ true, false);
}
// Verifies that initializing the JavaScript Preferences class fires the correct
@@ -707,19 +707,21 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest, ChromeOSDeviceFetchPrefs) {
// CoreChromeOSOptionsHandler class.
IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest,
ChromeOSDeviceFetchNonPrivilegedPrefs) {
- ScopedVector<base::Value> decorated_non_default_values;
+ std::vector<std::unique_ptr<base::Value>> decorated_non_default_values;
std::string observed_json;
// Non-privileged string pref.
pref_names_.push_back(chromeos::kSystemTimezone);
- default_values_.push_back(new base::StringValue("America/Los_Angeles"));
- non_default_values_.push_back(new base::StringValue("America/New_York"));
+ default_values_.push_back(
+ base::MakeUnique<base::StringValue>("America/Los_Angeles"));
+ non_default_values_.push_back(
+ base::MakeUnique<base::StringValue>("America/New_York"));
decorated_non_default_values.push_back(
- non_default_values_.back()->DeepCopy());
+ non_default_values_.back()->CreateDeepCopy());
// Verify notifications when default values are in effect.
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_, default_values_.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, default_values_,
std::string(), false, false);
chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
@@ -727,8 +729,7 @@ IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest,
// Verify notifications when non-default values are in effect.
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_,
- decorated_non_default_values.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
std::string(), false, false);
}
@@ -752,28 +753,30 @@ class ManagedPreferencesBrowserTest : public PreferencesBrowserTest {
// CoreChromeOSOptionsHandler class for a managed device.
IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
ChromeOSDeviceFetchPrefs) {
- ScopedVector<base::Value> decorated_non_default_values;
+ std::vector<std::unique_ptr<base::Value>> decorated_non_default_values;
std::string observed_json;
// Boolean pref.
pref_names_.push_back(chromeos::kAccountsPrefAllowGuest);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
decorated_non_default_values.push_back(
- non_default_values_.back()->DeepCopy());
+ non_default_values_.back()->CreateDeepCopy());
// String pref.
pref_names_.push_back(chromeos::kReleaseChannel);
- non_default_values_.push_back(new base::StringValue("stable-channel"));
+ non_default_values_.push_back(
+ base::MakeUnique<base::StringValue>("stable-channel"));
decorated_non_default_values.push_back(
- non_default_values_.back()->DeepCopy());
+ non_default_values_.back()->CreateDeepCopy());
// List pref.
pref_names_.push_back(chromeos::kAccountsPrefUsers);
- base::ListValue* list = new base::ListValue;
+ std::unique_ptr<base::ListValue> list = base::MakeUnique<base::ListValue>();
list->AppendString("me@google.com");
list->AppendString("you@google.com");
- non_default_values_.push_back(list);
- list = new base::ListValue;
+ non_default_values_.push_back(std::move(list));
+ list = base::MakeUnique<base::ListValue>();
auto dict = base::MakeUnique<base::DictionaryValue>();
dict->SetString("username", "me@google.com");
dict->SetString("name", "me@google.com");
@@ -786,7 +789,7 @@ IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
dict->SetString("email", "");
dict->SetBoolean("owner", false);
list->Append(std::move(dict));
- decorated_non_default_values.push_back(list);
+ decorated_non_default_values.push_back(std::move(list));
chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
for (size_t i = 0; i < pref_names_.size(); ++i) {
@@ -795,8 +798,7 @@ IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
// Verify notifications when mandatory values are in effect.
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_,
- decorated_non_default_values.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
"policy", true, false);
}
@@ -805,22 +807,22 @@ IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
// CoreChromeOSOptionsHandler class for a managed device.
IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
ChromeOSDeviceFetchNonPrivilegedPrefs) {
- ScopedVector<base::Value> decorated_non_default_values;
+ std::vector<std::unique_ptr<base::Value>> decorated_non_default_values;
std::string observed_json;
// Non-privileged string pref.
pref_names_.push_back(chromeos::kSystemTimezone);
- non_default_values_.push_back(new base::StringValue("America/New_York"));
+ non_default_values_.push_back(
+ base::MakeUnique<base::StringValue>("America/New_York"));
decorated_non_default_values.push_back(
- non_default_values_.back()->DeepCopy());
+ non_default_values_.back()->CreateDeepCopy());
// Verify notifications when mandatory values are in effect.
chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
cros_settings->Set(pref_names_[0], *non_default_values_[0]);
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(observed_json, pref_names_,
- decorated_non_default_values.get(),
+ VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
std::string(), false, false);
}
@@ -926,7 +928,7 @@ class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
}
std::string observed_json;
- SetPref(name, type, &value, true, &observed_json);
+ SetPref(name, type, value.CreateDeepCopy(), true, &observed_json);
}
void VerifyCurrentProxyServer(const std::string& expected_server,
@@ -951,36 +953,38 @@ class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ChromeOSInitializeProxy) {
// Boolean pref.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingle);
- non_default_values_.push_back(new base::FundamentalValue(true));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(true));
// Integer prefs.
pref_names_.push_back(
chromeos::proxy_cros_settings_parser::kProxySingleHttpPort);
- non_default_values_.push_back(new base::FundamentalValue(8080));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(8080));
// String pref.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxySingleHttp);
- non_default_values_.push_back(new base::StringValue("127.0.0.1"));
+ non_default_values_.push_back(
+ base::MakeUnique<base::StringValue>("127.0.0.1"));
// List pref.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyIgnoreList);
- base::ListValue* list = new base::ListValue();
+ std::unique_ptr<base::ListValue> list = base::MakeUnique<base::ListValue>();
stevenjb 2017/01/04 17:56:16 auto
Avi (use Gerrit) 2017/01/04 18:44:39 Done.
list->AppendString("*.google.com");
list->AppendString("1.2.3.4:22");
- non_default_values_.push_back(list);
+ non_default_values_.push_back(std::move(list));
// Verify that no policy is presented to the UI. This must be verified on the
// kProxyType and the kUseSharedProxies prefs.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
- non_default_values_.push_back(new base::FundamentalValue(2));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(2));
pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
std::string observed_json;
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(), "", false, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "",
+ false, false);
}
IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) {
@@ -990,23 +994,23 @@ IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, ONCPolicy) {
// Verify that per-network policy is presented to the UI. This must be
// verified on the kProxyType.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
- non_default_values_.push_back(new base::FundamentalValue(3));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3));
std::string observed_json;
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(),
- "policy", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy",
+ true, false);
// Verify that 'use-shared-proxies' is not affected by per-network policy.
pref_names_.clear();
non_default_values_.clear();
pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(), "", false, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "",
+ false, false);
}
IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) {
@@ -1016,47 +1020,47 @@ IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, DeviceONCPolicy) {
// Verify that the policy is presented to the UI. This verification must be
// done on the kProxyType pref.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
- non_default_values_.push_back(new base::FundamentalValue(3));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3));
std::string observed_json;
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(),
- "policy", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy",
+ true, false);
// Verify that 'use-shared-proxies' is not affected by per-network policy.
pref_names_.clear();
non_default_values_.clear();
pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(), "", false, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "",
+ false, false);
}
IN_PROC_BROWSER_TEST_F(ProxyPreferencesBrowserTest, UserProxyPolicy) {
policy_names_.push_back(policy::key::kProxyMode);
- default_values_.push_back(
- new base::StringValue(ProxyPrefs::kAutoDetectProxyModeName));
- SetUserPolicies(
- policy_names_, default_values_.get(), policy::POLICY_LEVEL_MANDATORY);
+ default_values_.push_back(base::MakeUnique<base::StringValue>(
+ ProxyPrefs::kAutoDetectProxyModeName));
+ SetUserPolicies(policy_names_, default_values_,
+ policy::POLICY_LEVEL_MANDATORY);
content::RunAllPendingInMessageLoop();
// Verify that the policy is presented to the UI. This verification must be
// done on the kProxyType pref.
pref_names_.push_back(chromeos::proxy_cros_settings_parser::kProxyType);
- non_default_values_.push_back(new base::FundamentalValue(3));
+ non_default_values_.push_back(base::MakeUnique<base::FundamentalValue>(3));
// Verify that 'use-shared-proxies' is controlled by the policy.
pref_names_.push_back(proxy_config::prefs::kUseSharedProxies);
- non_default_values_.push_back(new base::FundamentalValue(false));
+ non_default_values_.push_back(
+ base::MakeUnique<base::FundamentalValue>(false));
std::string observed_json;
SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
- VerifyObservedPrefs(
- observed_json, pref_names_, non_default_values_.get(),
- "policy", true, false);
+ VerifyObservedPrefs(observed_json, pref_names_, non_default_values_, "policy",
+ true, false);
}
// Verifies that modifications to the proxy settings are correctly pushed from

Powered by Google App Engine
This is Rietveld 408576698