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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/local_state/local_state_ui_unittest.cc
diff --git a/chrome/browser/ui/webui/local_state/local_state_ui_unittest.cc b/chrome/browser/ui/webui/local_state/local_state_ui_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2fc8de3a22d52b1eab75ef8d0046372e4cb5ea7f
--- /dev/null
+++ b/chrome/browser/ui/webui/local_state/local_state_ui_unittest.cc
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/local_state/local_state_ui.h"
+
+#include "base/values.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(LocalStateUiTest, FilterPrefs) {
+ std::vector<std::string> prefixes = {"foo", "bar", "baz"};
+
+ std::vector<std::string> invalid_pref_keys = {"fo", "ar", "afoo"};
+ std::vector<std::string> valid_pref_keys = {"foo", "foom", "bar.stuff"};
+
+ std::vector<std::string> all_pref_keys = invalid_pref_keys;
+ all_pref_keys.insert(all_pref_keys.end(), valid_pref_keys.begin(),
+ valid_pref_keys.end());
+
+ base::DictionaryValue prefs;
+ for (const std::string& key : all_pref_keys) {
+ prefs.Set(key, new base::StringValue(key + "_value"));
+ }
+
+ internal::FilterPrefs(prefixes, &prefs);
+
+ for (const std::string& invalid_key : invalid_pref_keys) {
+ std::string value;
+ EXPECT_FALSE(prefs.GetString(invalid_key, &value));
+ }
+
+ for (const std::string& valid_key : valid_pref_keys) {
+ std::string value;
+ EXPECT_TRUE(prefs.GetString(valid_key, &value));
+ EXPECT_EQ(valid_key + "_value", value);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698