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

Side by Side Diff: chrome/browser/ui/webui/local_state/local_state_ui_unittest.cc

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/local_state/local_state_ui.h" 5 #include "chrome/browser/ui/webui/local_state/local_state_ui.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 TEST(LocalStateUiTest, FilterPrefs) { 10 TEST(LocalStateUiTest, FilterPrefs) {
11 std::vector<std::string> prefixes = {"foo", "bar", "baz"}; 11 std::vector<std::string> prefixes = {"foo", "bar", "baz"};
12 12
13 std::vector<std::string> invalid_pref_keys = {"fo", "ar", "afoo"}; 13 std::vector<std::string> invalid_pref_keys = {"fo", "ar", "afoo"};
14 std::vector<std::string> valid_pref_keys = {"foo", "foom", "bar.stuff"}; 14 std::vector<std::string> valid_pref_keys = {"foo", "foom", "bar.stuff"};
15 15
16 std::vector<std::string> all_pref_keys = invalid_pref_keys; 16 std::vector<std::string> all_pref_keys = invalid_pref_keys;
17 all_pref_keys.insert(all_pref_keys.end(), valid_pref_keys.begin(), 17 all_pref_keys.insert(all_pref_keys.end(), valid_pref_keys.begin(),
18 valid_pref_keys.end()); 18 valid_pref_keys.end());
19 19
20 base::DictionaryValue prefs; 20 base::DictionaryValue prefs;
21 for (const std::string& key : all_pref_keys) { 21 for (const std::string& key : all_pref_keys) {
22 prefs.Set(key, new base::Value(key + "_value")); 22 prefs.SetString(key, key + "_value");
23 } 23 }
24 24
25 internal::FilterPrefs(prefixes, &prefs); 25 internal::FilterPrefs(prefixes, &prefs);
26 26
27 for (const std::string& invalid_key : invalid_pref_keys) { 27 for (const std::string& invalid_key : invalid_pref_keys) {
28 std::string value; 28 std::string value;
29 EXPECT_FALSE(prefs.GetString(invalid_key, &value)); 29 EXPECT_FALSE(prefs.GetString(invalid_key, &value));
30 } 30 }
31 31
32 for (const std::string& valid_key : valid_pref_keys) { 32 for (const std::string& valid_key : valid_pref_keys) {
33 std::string value; 33 std::string value;
34 EXPECT_TRUE(prefs.GetString(valid_key, &value)); 34 EXPECT_TRUE(prefs.GetString(valid_key, &value));
35 EXPECT_EQ(valid_key + "_value", value); 35 EXPECT_EQ(valid_key + "_value", value);
36 } 36 }
37 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698