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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/prefs/json_pref_store.h" 5 #include "base/prefs/json_pref_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 WriteablePrefStore::LOSSY_PREF_WRITE_FLAG); 921 WriteablePrefStore::LOSSY_PREF_WRITE_FLAG);
922 ASSERT_TRUE(file_writer->HasPendingWrite()); 922 ASSERT_TRUE(file_writer->HasPendingWrite());
923 923
924 // Call DoScheduledWrite and check both prefs get written. 924 // Call DoScheduledWrite and check both prefs get written.
925 file_writer->DoScheduledWrite(); 925 file_writer->DoScheduledWrite();
926 ASSERT_EQ("{\"lossy\":\"lossy\",\"normal\":\"normal\"}", 926 ASSERT_EQ("{\"lossy\":\"lossy\",\"normal\":\"normal\"}",
927 GetTestFileContents()); 927 GetTestFileContents());
928 ASSERT_FALSE(file_writer->HasPendingWrite()); 928 ASSERT_FALSE(file_writer->HasPendingWrite());
929 } 929 }
930 930
931 TEST_F(JsonPrefStoreLossyWriteTest, ScheduleLossyWrite) {
932 scoped_refptr<JsonPrefStore> pref_store = CreatePrefStore();
933 ImportantFileWriter* file_writer = GetImportantFileWriter(pref_store);
934
935 // Set a lossy pref and check that it is not scheduled to be written.
936 pref_store->SetValue("lossy", new base::StringValue("lossy"),
937 WriteablePrefStore::LOSSY_PREF_WRITE_FLAG);
938 ASSERT_FALSE(file_writer->HasPendingWrite());
939
940 // Schedule pending lossy writes and check that it is scheduled.
941 pref_store->SchedulePendingLossyWrites();
942 ASSERT_TRUE(file_writer->HasPendingWrite());
943
944 // Call CommitPendingWrite and check that the lossy pref is there with the
945 // last value set above.
946 pref_store->CommitPendingWrite();
947 ASSERT_FALSE(file_writer->HasPendingWrite());
948 ASSERT_EQ("{\"lossy\":\"lossy\"}", GetTestFileContents());
949 }
950
931 } // namespace base 951 } // namespace base
OLDNEW
« 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