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

Side by Side Diff: extensions/browser/value_store/leveldb_value_store_unittest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « courgette/third_party/bsdiff_apply.cc ('k') | extensions/common/extension_resource_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/value_store/value_store_unittest.h" 5 #include "extensions/browser/value_store/value_store_unittest.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ->HasError()); 159 ->HasError());
160 } 160 }
161 161
162 // Close it (so we remove the lock), and replace all files with LolCats. 162 // Close it (so we remove the lock), and replace all files with LolCats.
163 CloseStore(); 163 CloseStore();
164 base::FileEnumerator enumerator( 164 base::FileEnumerator enumerator(
165 database_path(), true /* recursive */, base::FileEnumerator::FILES); 165 database_path(), true /* recursive */, base::FileEnumerator::FILES);
166 for (base::FilePath file = enumerator.Next(); !file.empty(); 166 for (base::FilePath file = enumerator.Next(); !file.empty();
167 file = enumerator.Next()) { 167 file = enumerator.Next()) {
168 // WriteFile() failure is a result of -1. 168 // WriteFile() failure is a result of -1.
169 ASSERT_NE(file_util::WriteFile(file, kLolCats.c_str(), kLolCats.length()), 169 ASSERT_NE(base::WriteFile(file, kLolCats.c_str(), kLolCats.length()),
170 -1); 170 -1);
171 } 171 }
172 OpenStore(); 172 OpenStore();
173 173
174 // We should definitely have an error. 174 // We should definitely have an error.
175 ValueStore::ReadResult result = store()->Get(); 175 ValueStore::ReadResult result = store()->Get();
176 ASSERT_TRUE(result->HasError()); 176 ASSERT_TRUE(result->HasError());
177 ASSERT_EQ(ValueStore::CORRUPTION, result->error().code); 177 ASSERT_EQ(ValueStore::CORRUPTION, result->error().code);
178 178
179 ASSERT_TRUE(store()->Restore()); 179 ASSERT_TRUE(store()->Restore());
180 result = store()->Get(); 180 result = store()->Get();
181 EXPECT_FALSE(result->HasError()); 181 EXPECT_FALSE(result->HasError());
182 // We couldn't recover anything, but we should be in a sane state again. 182 // We couldn't recover anything, but we should be in a sane state again.
183 EXPECT_EQ(0u, result->settings().size()); 183 EXPECT_EQ(0u, result->settings().size());
184 } 184 }
OLDNEW
« no previous file with comments | « courgette/third_party/bsdiff_apply.cc ('k') | extensions/common/extension_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698