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

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: 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 | base/test/data/prefs/remove.golden.json » ('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 119a29cd96c94eede7e15a9a81c14f3db3dcdfa0..ebc67fb79016482718fc626b71685df5a230bd62 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -257,6 +257,29 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
EXPECT_TRUE(DictionaryValue().Equals(result));
}
+TEST_F(JsonPrefStoreTest, Remove) {
+ ASSERT_TRUE(base::CopyFile(data_dir_.AppendASCII("remove.original.json"),
+ temp_dir_.path().AppendASCII("remove.json")));
+ base::FilePath input_output_file =
+ temp_dir_.path().AppendASCII("remove.json");
+ ASSERT_TRUE(PathExists(input_output_file));
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_output_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
+ ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
+ ASSERT_FALSE(pref_store->ReadOnly());
Mattias Nissler (ping if slow) 2014/01/23 09:07:54 Reading this code, I have no idea what the test is
+
+ pref_store->RemoveValue("long_int.pref");
+
+ pref_store->CommitPendingWrite();
+ RunLoop().RunUntilIdle();
+
+ base::FilePath golden_output_file =
+ data_dir_.AppendASCII("remove.golden.json");
+ EXPECT_TRUE(TextContentsEqual(golden_output_file, input_output_file));
+}
+
// 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 | base/test/data/prefs/remove.golden.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698