| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 entry->Close(); | 235 entry->Close(); |
| 236 | 236 |
| 237 // The cache destructor will see one pending operation here. | 237 // The cache destructor will see one pending operation here. |
| 238 delete cache; | 238 delete cache; |
| 239 } | 239 } |
| 240 | 240 |
| 241 MessageLoop::current()->RunAllPending(); | 241 MessageLoop::current()->RunAllPending(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 #if defined(OS_WIN) || defined(OS_MACOSX) | |
| 245 // This test fails on linux. TODO(rvargas): Find out why (bug 41563). | |
| 246 TEST_F(DiskCacheTest, TruncatedIndex) { | 244 TEST_F(DiskCacheTest, TruncatedIndex) { |
| 247 FilePath path = GetCacheFilePath(); | 245 FilePath path = GetCacheFilePath(); |
| 248 ASSERT_TRUE(DeleteCache(path)); | 246 ASSERT_TRUE(DeleteCache(path)); |
| 249 FilePath index = path.AppendASCII("Index"); | 247 FilePath index = path.AppendASCII("index"); |
| 250 ASSERT_EQ(5, file_util::WriteFile(index, "hello", 5)); | 248 ASSERT_EQ(5, file_util::WriteFile(index, "hello", 5)); |
| 251 scoped_ptr<disk_cache::Backend> backend; | 249 scoped_ptr<disk_cache::Backend> backend; |
| 252 backend.reset(disk_cache::BackendImpl::CreateBackend(path, false, 0, | 250 backend.reset(disk_cache::BackendImpl::CreateBackend(path, false, 0, |
| 253 net::DISK_CACHE, | 251 net::DISK_CACHE, |
| 254 disk_cache::kNone)); | 252 disk_cache::kNone)); |
| 255 ASSERT_TRUE(backend.get() == NULL); | 253 ASSERT_TRUE(backend.get() == NULL); |
| 256 } | 254 } |
| 257 #endif | |
| 258 | 255 |
| 259 void DiskCacheBackendTest::BackendSetSize() { | 256 void DiskCacheBackendTest::BackendSetSize() { |
| 260 SetDirectMode(); | 257 SetDirectMode(); |
| 261 const int cache_size = 0x10000; // 64 kB | 258 const int cache_size = 0x10000; // 64 kB |
| 262 SetMaxSize(cache_size); | 259 SetMaxSize(cache_size); |
| 263 InitCache(); | 260 InitCache(); |
| 264 | 261 |
| 265 std::string first("some key"); | 262 std::string first("some key"); |
| 266 std::string second("something else"); | 263 std::string second("something else"); |
| 267 disk_cache::Entry* entry; | 264 disk_cache::Entry* entry; |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 disk_cache::PreferedCacheSize(large_size * 250)); | 1612 disk_cache::PreferedCacheSize(large_size * 250)); |
| 1616 EXPECT_EQ(kint32max - 1, | 1613 EXPECT_EQ(kint32max - 1, |
| 1617 disk_cache::PreferedCacheSize(largest_size * 100 - 1)); | 1614 disk_cache::PreferedCacheSize(largest_size * 100 - 1)); |
| 1618 | 1615 |
| 1619 // Region 6: expected = kint32max | 1616 // Region 6: expected = kint32max |
| 1620 EXPECT_EQ(kint32max, | 1617 EXPECT_EQ(kint32max, |
| 1621 disk_cache::PreferedCacheSize(largest_size * 100)); | 1618 disk_cache::PreferedCacheSize(largest_size * 100)); |
| 1622 EXPECT_EQ(kint32max, | 1619 EXPECT_EQ(kint32max, |
| 1623 disk_cache::PreferedCacheSize(largest_size * 10000)); | 1620 disk_cache::PreferedCacheSize(largest_size * 10000)); |
| 1624 } | 1621 } |
| OLD | NEW |