OLD | NEW |
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" |
11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "net/base/cache_type.h" | 15 #include "net/base/cache_type.h" |
16 #include "net/disk_cache/simple/simple_entry_format.h" | 16 #include "net/disk_cache/simple/simple_entry_format.h" |
17 #include "net/disk_cache/simple/simple_index.h" | 17 #include "net/disk_cache/simple/simple_index.h" |
18 #include "net/disk_cache/simple/simple_index_file.h" | 18 #include "net/disk_cache/simple/simple_index_file.h" |
19 #include "net/disk_cache/simple/simple_util.h" | 19 #include "net/disk_cache/simple/simple_util.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 using base::Time; | 22 using base::Time; |
23 using disk_cache::SimpleIndexFile; | 23 using disk_cache::SimpleIndexFile; |
24 using disk_cache::SimpleIndex; | 24 using disk_cache::SimpleIndex; |
25 | 25 |
26 namespace disk_cache { | 26 namespace disk_cache { |
27 | 27 |
| 28 // The Simple Cache backend requires a few guarantees from the filesystem like |
| 29 // atomic renaming of recently open files. Those guarantees are not provided in |
| 30 // general on Windows. |
| 31 #if defined(OS_POSIX) |
| 32 |
28 TEST(IndexMetadataTest, Basics) { | 33 TEST(IndexMetadataTest, Basics) { |
29 SimpleIndexFile::IndexMetadata index_metadata; | 34 SimpleIndexFile::IndexMetadata index_metadata; |
30 | 35 |
31 EXPECT_EQ(disk_cache::kSimpleIndexMagicNumber, index_metadata.magic_number_); | 36 EXPECT_EQ(disk_cache::kSimpleIndexMagicNumber, index_metadata.magic_number_); |
32 EXPECT_EQ(disk_cache::kSimpleVersion, index_metadata.version_); | 37 EXPECT_EQ(disk_cache::kSimpleVersion, index_metadata.version_); |
33 EXPECT_EQ(0U, index_metadata.GetNumberOfEntries()); | 38 EXPECT_EQ(0U, index_metadata.GetNumberOfEntries()); |
34 EXPECT_EQ(0U, index_metadata.cache_size_); | 39 EXPECT_EQ(0U, index_metadata.cache_size_); |
35 | 40 |
36 EXPECT_TRUE(index_metadata.CheckIndexMetadata()); | 41 EXPECT_TRUE(index_metadata.CheckIndexMetadata()); |
37 } | 42 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 GetCallback(), | 240 GetCallback(), |
236 &load_index_result); | 241 &load_index_result); |
237 base::RunLoop().RunUntilIdle(); | 242 base::RunLoop().RunUntilIdle(); |
238 | 243 |
239 EXPECT_FALSE(base::PathExists(index_path)); | 244 EXPECT_FALSE(base::PathExists(index_path)); |
240 ASSERT_TRUE(callback_called()); | 245 ASSERT_TRUE(callback_called()); |
241 EXPECT_TRUE(load_index_result.did_load); | 246 EXPECT_TRUE(load_index_result.did_load); |
242 EXPECT_TRUE(load_index_result.flush_required); | 247 EXPECT_TRUE(load_index_result.flush_required); |
243 } | 248 } |
244 | 249 |
| 250 #endif // defined(OS_POSIX) |
| 251 |
245 } // namespace disk_cache | 252 } // namespace disk_cache |
OLD | NEW |