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

Side by Side Diff: net/disk_cache/simple/simple_index_file_unittest.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | « net/disk_cache/simple/simple_index_file.cc ('k') | net/dns/dns_hosts.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/hash.h" 7 #include "base/hash.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EntryMetadata(Time::FromInternalValue(hash), hash); 189 EntryMetadata(Time::FromInternalValue(hash), hash);
190 SimpleIndex::InsertInEntrySet(hash, metadata_entries[i], &entries); 190 SimpleIndex::InsertInEntrySet(hash, metadata_entries[i], &entries);
191 } 191 }
192 192
193 const uint64 kCacheSize = 456U; 193 const uint64 kCacheSize = 456U;
194 { 194 {
195 WrappedSimpleIndexFile simple_index_file(temp_dir.path()); 195 WrappedSimpleIndexFile simple_index_file(temp_dir.path());
196 simple_index_file.WriteToDisk(entries, kCacheSize, 196 simple_index_file.WriteToDisk(entries, kCacheSize,
197 base::TimeTicks(), false); 197 base::TimeTicks(), false);
198 base::RunLoop().RunUntilIdle(); 198 base::RunLoop().RunUntilIdle();
199 EXPECT_TRUE(file_util::PathExists(index_path)); 199 EXPECT_TRUE(base::PathExists(index_path));
200 } 200 }
201 201
202 WrappedSimpleIndexFile simple_index_file(temp_dir.path()); 202 WrappedSimpleIndexFile simple_index_file(temp_dir.path());
203 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current(), 203 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current(),
204 GetCallback()); 204 GetCallback());
205 base::RunLoop().RunUntilIdle(); 205 base::RunLoop().RunUntilIdle();
206 206
207 EXPECT_TRUE(file_util::PathExists(index_path)); 207 EXPECT_TRUE(base::PathExists(index_path));
208 ASSERT_TRUE(callback_result()); 208 ASSERT_TRUE(callback_result());
209 EXPECT_FALSE(callback_result()->force_index_flush); 209 EXPECT_FALSE(callback_result()->force_index_flush);
210 const SimpleIndex::EntrySet* read_entries = 210 const SimpleIndex::EntrySet* read_entries =
211 callback_result()->index_file_entries.get(); 211 callback_result()->index_file_entries.get();
212 ASSERT_TRUE(read_entries); 212 ASSERT_TRUE(read_entries);
213 213
214 EXPECT_EQ(kNumHashes, read_entries->size()); 214 EXPECT_EQ(kNumHashes, read_entries->size());
215 for (size_t i = 0; i < kNumHashes; ++i) 215 for (size_t i = 0; i < kNumHashes; ++i)
216 EXPECT_EQ(1U, read_entries->count(kHashes[i])); 216 EXPECT_EQ(1U, read_entries->count(kHashes[i]));
217 } 217 }
(...skipping 10 matching lines...) Expand all
228 file_util::WriteFile(index_path, 228 file_util::WriteFile(index_path,
229 kDummyData.data(), 229 kDummyData.data(),
230 kDummyData.size())); 230 kDummyData.size()));
231 EXPECT_FALSE(WrappedSimpleIndexFile::IsIndexFileStale(index_path)); 231 EXPECT_FALSE(WrappedSimpleIndexFile::IsIndexFileStale(index_path));
232 232
233 WrappedSimpleIndexFile simple_index_file(temp_dir.path()); 233 WrappedSimpleIndexFile simple_index_file(temp_dir.path());
234 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current().get(), 234 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current().get(),
235 GetCallback()); 235 GetCallback());
236 base::RunLoop().RunUntilIdle(); 236 base::RunLoop().RunUntilIdle();
237 237
238 EXPECT_FALSE(file_util::PathExists(index_path)); 238 EXPECT_FALSE(base::PathExists(index_path));
239 ASSERT_TRUE(callback_result()); 239 ASSERT_TRUE(callback_result());
240 EXPECT_TRUE(callback_result()->force_index_flush); 240 EXPECT_TRUE(callback_result()->force_index_flush);
241 EXPECT_TRUE(callback_result()->index_file_entries); 241 EXPECT_TRUE(callback_result()->index_file_entries);
242 } 242 }
243 243
244 } // namespace disk_cache 244 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file.cc ('k') | net/dns/dns_hosts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698