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

Unified Diff: components/user_prefs/tracked/segregated_pref_store_unittest.cc

Issue 2692203007: Add PrefStore::GetValues (Closed)
Patch Set: Add GetValues to FilesystemJsonPrefStore Created 3 years, 10 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
« no previous file with comments | « components/user_prefs/tracked/segregated_pref_store.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/user_prefs/tracked/segregated_pref_store_unittest.cc
diff --git a/components/user_prefs/tracked/segregated_pref_store_unittest.cc b/components/user_prefs/tracked/segregated_pref_store_unittest.cc
index 5d32d027d5e4803a3692e5c93242e43a6901cc5e..4c685cc319abf3ff0240b58180e1c72f49844c17 100644
--- a/components/user_prefs/tracked/segregated_pref_store_unittest.cc
+++ b/components/user_prefs/tracked/segregated_pref_store_unittest.cc
@@ -24,6 +24,7 @@ namespace {
const char kSelectedPref[] = "selected_pref";
const char kUnselectedPref[] = "unselected_pref";
+const char kSharedPref[] = "shared_pref";
const char kValue1[] = "value1";
const char kValue2[] = "value2";
@@ -70,6 +71,7 @@ class SegregatedPrefStoreTest : public testing::Test {
std::set<std::string> selected_pref_names;
selected_pref_names.insert(kSelectedPref);
+ selected_pref_names.insert(kSharedPref);
segregated_store_ = new SegregatedPrefStore(default_store_, selected_store_,
selected_pref_names);
@@ -274,3 +276,31 @@ TEST_F(SegregatedPrefStoreTest, IsInitializationCompleteAsync) {
default_store_->SetBlockAsyncRead(false);
EXPECT_TRUE(segregated_store_->IsInitializationComplete());
}
+
+TEST_F(SegregatedPrefStoreTest, GetValues) {
+ // To check merge behavior, create selected and default stores so each has a
+ // key the other doesn't have and they have one key in common.
+ selected_store_->SetValue(kSelectedPref,
+ base::MakeUnique<base::StringValue>(kValue1),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ default_store_->SetValue(kUnselectedPref,
+ base::MakeUnique<base::StringValue>(kValue2),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ selected_store_->SetValue(kSharedPref,
+ base::MakeUnique<base::StringValue>(kValue1),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+
+ auto values = segregated_store_->GetValues();
+ const base::Value* value = nullptr;
+ // Check that a selected preference is returned.
+ ASSERT_TRUE(values->Get(kSelectedPref, &value));
+ EXPECT_TRUE(base::FundamentalValue(kValue1).Equals(value));
+
+ // Check that a a default preference is returned.
+ ASSERT_TRUE(values->Get(kUnselectedPref, &value));
+ EXPECT_TRUE(base::FundamentalValue(kValue2).Equals(value));
+
+ // Check that the selected preference is preferred.
+ ASSERT_TRUE(values->Get(kSharedPref, &value));
+ EXPECT_TRUE(base::FundamentalValue(kValue1).Equals(value));
+}
« no previous file with comments | « components/user_prefs/tracked/segregated_pref_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698