| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/hash.h" | 6 #include "base/hash.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 EXPECT_EQ(14U, index()->cache_size_); | 190 EXPECT_EQ(14U, index()->cache_size_); |
| 191 { | 191 { |
| 192 scoped_ptr<SimpleIndexLoadResult> result(new SimpleIndexLoadResult()); | 192 scoped_ptr<SimpleIndexLoadResult> result(new SimpleIndexLoadResult()); |
| 193 result->did_load = true; | 193 result->did_load = true; |
| 194 index()->MergeInitializingSet(result.Pass()); | 194 index()->MergeInitializingSet(result.Pass()); |
| 195 } | 195 } |
| 196 EXPECT_EQ(14U, index()->cache_size_); | 196 EXPECT_EQ(14U, index()->cache_size_); |
| 197 { | 197 { |
| 198 scoped_ptr<SimpleIndexLoadResult> result(new SimpleIndexLoadResult()); | 198 scoped_ptr<SimpleIndexLoadResult> result(new SimpleIndexLoadResult()); |
| 199 result->did_load = true; | 199 result->did_load = true; |
| 200 const uint64 hash_key = simple_util::GetEntryHashKey("eleven"); | 200 const uint64 new_hash_key = simple_util::GetEntryHashKey("eleven"); |
| 201 result->entries.insert( | 201 result->entries.insert( |
| 202 std::make_pair(hash_key, EntryMetadata(base::Time::Now(), 11))); | 202 std::make_pair(new_hash_key, EntryMetadata(base::Time::Now(), 11))); |
| 203 const uint64 redundant_hash_key = simple_util::GetEntryHashKey("seven"); |
| 204 result->entries.insert(std::make_pair(redundant_hash_key, |
| 205 EntryMetadata(base::Time::Now(), 7))); |
| 203 index()->MergeInitializingSet(result.Pass()); | 206 index()->MergeInitializingSet(result.Pass()); |
| 204 } | 207 } |
| 205 EXPECT_EQ(25U, index()->cache_size_); | 208 EXPECT_EQ(2U + 5U + 7U + 11U, index()->cache_size_); |
| 206 } | 209 } |
| 207 | 210 |
| 208 // State of index changes as expected with an insert and a remove. | 211 // State of index changes as expected with an insert and a remove. |
| 209 TEST_F(SimpleIndexTest, BasicInsertRemove) { | 212 TEST_F(SimpleIndexTest, BasicInsertRemove) { |
| 210 // Confirm blank state. | 213 // Confirm blank state. |
| 211 EntryMetadata metadata; | 214 EntryMetadata metadata; |
| 212 EXPECT_EQ(base::Time(), metadata.GetLastUsedTime()); | 215 EXPECT_EQ(base::Time(), metadata.GetLastUsedTime()); |
| 213 EXPECT_EQ(0ul, metadata.GetEntrySize()); | 216 EXPECT_EQ(0ul, metadata.GetEntrySize()); |
| 214 | 217 |
| 215 // Confirm state after insert. | 218 // Confirm state after insert. |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 WaitForTimeChange(); | 572 WaitForTimeChange(); |
| 570 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 573 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 571 index()->Insert("key2"); | 574 index()->Insert("key2"); |
| 572 index()->UpdateEntrySize("key2", 40); | 575 index()->UpdateEntrySize("key2", 40); |
| 573 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); | 576 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); |
| 574 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 577 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 575 index()->write_to_disk_timer_.Stop(); | 578 index()->write_to_disk_timer_.Stop(); |
| 576 } | 579 } |
| 577 | 580 |
| 578 } // namespace disk_cache | 581 } // namespace disk_cache |
| OLD | NEW |