| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 char buffer1[kSize]; | 2111 char buffer1[kSize]; |
| 2112 char buffer2[kSize]; | 2112 char buffer2[kSize]; |
| 2113 memset(buffer1, 't', kSize); | 2113 memset(buffer1, 't', kSize); |
| 2114 memset(buffer2, 0, kSize); | 2114 memset(buffer2, 0, kSize); |
| 2115 EXPECT_TRUE(file->Write(buffer1, kSize, 0)); | 2115 EXPECT_TRUE(file->Write(buffer1, kSize, 0)); |
| 2116 EXPECT_TRUE(file->Read(buffer2, kSize, 0)); | 2116 EXPECT_TRUE(file->Read(buffer2, kSize, 0)); |
| 2117 EXPECT_EQ(0, memcmp(buffer1, buffer2, kSize)); | 2117 EXPECT_EQ(0, memcmp(buffer1, buffer2, kSize)); |
| 2118 | 2118 |
| 2119 EXPECT_TRUE(disk_cache::DeleteCacheFile(name)); | 2119 EXPECT_TRUE(disk_cache::DeleteCacheFile(name)); |
| 2120 } | 2120 } |
| 2121 |
| 2122 TEST_F(DiskCacheBackendTest, UpdateRankForExternalCacheHit) { |
| 2123 SetDirectMode(); |
| 2124 InitCache(); |
| 2125 |
| 2126 disk_cache::Entry* entry; |
| 2127 |
| 2128 for (int i = 0; i < 2; ++i) { |
| 2129 std::string key = StringPrintf("key%d", i); |
| 2130 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
| 2131 entry->Close(); |
| 2132 } |
| 2133 |
| 2134 // Ping the oldest entry. |
| 2135 cache_->OnExternalCacheHit("key0"); |
| 2136 |
| 2137 TrimForTest(false); |
| 2138 |
| 2139 // Make sure the older key remains. |
| 2140 EXPECT_EQ(1, cache_->GetEntryCount()); |
| 2141 ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); |
| 2142 entry->Close(); |
| 2143 } |
| OLD | NEW |