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

Unified Diff: base/prefs/json_pref_store_unittest.cc

Issue 144633002: Add a unit test for JsonPrefStore::Remove. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update name and add comment Created 6 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 | « no previous file | no next file » | 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 119a29cd96c94eede7e15a9a81c14f3db3dcdfa0..f4e1e5190dd903bb4c69ffab8f0d003106f987c0 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -257,6 +257,27 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
EXPECT_TRUE(DictionaryValue().Equals(result));
}
+// This test is just documenting some potentially non-obvious behavior. It
+// shouldn't be taken as normative.
+TEST_F(JsonPrefStoreTest, RemoveClearsEmptyParent) {
+ FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
+
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ pref_file,
+ message_loop_.message_loop_proxy(),
+ scoped_ptr<PrefFilter>());
+
+ base::DictionaryValue* dict = new base::DictionaryValue;
+ dict->SetString("key", "value");
+ pref_store->SetValue("dict", dict);
+
+ pref_store->RemoveValue("dict.key");
+
+ const base::Value* retrieved_dict = NULL;
+ bool has_dict = pref_store->GetValue("dict", &retrieved_dict);
+ EXPECT_FALSE(has_dict);
+}
+
// Tests asynchronous reading of the file when there is no file.
TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) {
base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698