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

Unified Diff: base/prefs/json_pref_store_unittest.cc

Issue 12092021: Remove PersistentPrefStore::MarkNeedsEmptyValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some tests. Created 7 years, 11 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 | « base/prefs/json_pref_store.cc ('k') | base/prefs/overlay_user_pref_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/json_pref_store_unittest.cc
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index dc6f95ebf1d4644812fc7e8d20e0fa8fb481cf0b..c655410306582e800954abe02d49d7a12a45d9a2 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -249,52 +249,32 @@ TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) {
EXPECT_FALSE(pref_store->ReadOnly());
}
-TEST_F(JsonPrefStoreTest, NeedsEmptyValue) {
- FilePath pref_file = temp_dir_.path().AppendASCII("write.json");
-
- ASSERT_TRUE(file_util::CopyFile(
- data_dir_.AppendASCII("read.need_empty_value.json"),
- pref_file));
+TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
+ FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
// Test that the persistent value can be loaded.
- ASSERT_TRUE(file_util::PathExists(pref_file));
scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(
- pref_file, message_loop_.message_loop_proxy());
- ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
- ASSERT_FALSE(pref_store->ReadOnly());
+ new JsonPrefStore(pref_file, message_loop_.message_loop_proxy());
- // The JSON file looks like this:
- // {
- // "list": [ 1 ],
- // "list_needs_empty_value": [ 2 ],
- // "dict": {
- // "dummy": true,
- // },
- // "dict_needs_empty_value": {
- // "dummy": true,
- // },
- // }
-
- // Set flag to preserve empty values for the following keys.
- pref_store->MarkNeedsEmptyValue("list_needs_empty_value");
- pref_store->MarkNeedsEmptyValue("dict_needs_empty_value");
-
- // Set all keys to empty values.
+ // Set some keys with empty values.
pref_store->SetValue("list", new base::ListValue);
- pref_store->SetValue("list_needs_empty_value", new base::ListValue);
pref_store->SetValue("dict", new base::DictionaryValue);
- pref_store->SetValue("dict_needs_empty_value", new base::DictionaryValue);
// Write to file.
pref_store->CommitPendingWrite();
MessageLoop::current()->RunUntilIdle();
- // Compare to expected output.
- FilePath golden_output_file =
- data_dir_.AppendASCII("write.golden.need_empty_value.json");
- ASSERT_TRUE(file_util::PathExists(golden_output_file));
- EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file));
+ // Reload.
+ pref_store = new JsonPrefStore(pref_file, message_loop_.message_loop_proxy());
+ ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
+ ASSERT_FALSE(pref_store->ReadOnly());
+
+ // Check values.
+ const Value* result = NULL;
+ EXPECT_TRUE(pref_store->GetValue("list", &result));
+ ListValue().Equals(result);
+ EXPECT_TRUE(pref_store->GetValue("dict", &result));
+ DictionaryValue().Equals(result);
}
} // namespace base
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | base/prefs/overlay_user_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698