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

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

Issue 1910323002: Allow whitelisted prefs to be displayed in ChromeOS in chrome://local-state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/local_state/local_state_ui.h"
6
7 #include "base/values.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 TEST(LocalStateUiTest, FilterPrefs) {
11 std::vector<std::string> prefixes = {"foo", "bar", "baz"};
12
13 std::vector<std::string> invalid_pref_keys = {"fo", "ar", "afoo"};
14 std::vector<std::string> valid_pref_keys = {"foo", "foom", "bar.stuff"};
15
16 std::vector<std::string> all_pref_keys = invalid_pref_keys;
17 all_pref_keys.insert(all_pref_keys.end(), valid_pref_keys.begin(),
18 valid_pref_keys.end());
19
20 base::DictionaryValue prefs;
21 for (const std::string& key : all_pref_keys) {
22 prefs.Set(key, new base::StringValue(key + "_value"));
23 }
24
25 internal::FilterPrefs(prefixes, &prefs);
26
27 for (const std::string& invalid_key : invalid_pref_keys) {
28 std::string value;
29 EXPECT_FALSE(prefs.GetString(invalid_key, &value));
30 }
31
32 for (const std::string& valid_key : valid_pref_keys) {
33 std::string value;
34 EXPECT_TRUE(prefs.GetString(valid_key, &value));
35 EXPECT_EQ(valid_key + "_value", value);
36 }
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698