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

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, 8 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 "testing/gtest/include/gtest/gtest.h"
8
9 TEST(LocalStateUiTest, FilterPrefs) {
10 std::vector<std::string> prefixes = {"foo", "bar", "baz"};
11
12 std::vector<std::string> invalid_pref_keys = {"fo", "ar", "afoo"};
13 std::vector<std::string> valid_pref_keys = {"foo", "foom", "bar.stuff"};
14
15 std::vector<std::string> all_pref_keys = invalid_pref_keys;
16 all_pref_keys.insert(all_pref_keys.end(), valid_pref_keys.begin(),
17 valid_pref_keys.end());
18
19 base::DictionaryValue prefs;
20 for (const std::string& key : all_pref_keys) {
21 prefs.Set(key, new base::StringValue(key + "_value"));
22 }
23
24 internal::FilterPrefs(prefixes, &prefs);
25
26 for (const std::string& invalid_key : invalid_pref_keys) {
27 std::string value;
28 EXPECT_FALSE(prefs.GetString(invalid_key, &value));
29 }
30
31 for (const std::string& valid_key : valid_pref_keys) {
32 std::string value;
33 EXPECT_TRUE(prefs.GetString(valid_key, &value));
34 EXPECT_EQ(valid_key + "_value", value);
35 }
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698