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

Unified Diff: base/prefs/json_pref_store_unittest.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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 67a8adbb4d4f93bca61d964ace97353736345f3f..4c7bc1ff4603c93baaee90289995f0c58cd043b8 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -928,4 +928,24 @@ TEST_F(JsonPrefStoreLossyWriteTest, LossyWriteMixedLossySecond) {
ASSERT_FALSE(file_writer->HasPendingWrite());
}
+TEST_F(JsonPrefStoreLossyWriteTest, ScheduleLossyWrite) {
+ scoped_refptr<JsonPrefStore> pref_store = CreatePrefStore();
+ ImportantFileWriter* file_writer = GetImportantFileWriter(pref_store);
+
+ // Set a lossy pref and check that it is not scheduled to be written.
+ pref_store->SetValue("lossy", new base::StringValue("lossy"),
+ WriteablePrefStore::LOSSY_PREF_WRITE_FLAG);
+ ASSERT_FALSE(file_writer->HasPendingWrite());
+
+ // Schedule pending lossy writes and check that it is scheduled.
+ pref_store->SchedulePendingLossyWrites();
+ ASSERT_TRUE(file_writer->HasPendingWrite());
+
+ // Call CommitPendingWrite and check that the lossy pref is there with the
+ // last value set above.
+ pref_store->CommitPendingWrite();
+ ASSERT_FALSE(file_writer->HasPendingWrite());
+ ASSERT_EQ("{\"lossy\":\"lossy\"}", GetTestFileContents());
+}
+
} // 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