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 <algorithm> | 5 #include <algorithm> |
6 #include <functional> | 6 #include <functional> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 EXPECT_LT(new_time - base::TimeDelta::FromSeconds(2), | 182 EXPECT_LT(new_time - base::TimeDelta::FromSeconds(2), |
183 entry_metadata.GetLastUsedTime()); | 183 entry_metadata.GetLastUsedTime()); |
184 EXPECT_GT(new_time + base::TimeDelta::FromSeconds(2), | 184 EXPECT_GT(new_time + base::TimeDelta::FromSeconds(2), |
185 entry_metadata.GetLastUsedTime()); | 185 entry_metadata.GetLastUsedTime()); |
186 } | 186 } |
187 | 187 |
188 TEST_F(EntryMetadataTest, Serialize) { | 188 TEST_F(EntryMetadataTest, Serialize) { |
189 EntryMetadata entry_metadata = NewEntryMetadataWithValues(); | 189 EntryMetadata entry_metadata = NewEntryMetadataWithValues(); |
190 | 190 |
191 Pickle pickle; | 191 base::Pickle pickle; |
192 entry_metadata.Serialize(&pickle); | 192 entry_metadata.Serialize(&pickle); |
193 | 193 |
194 PickleIterator it(pickle); | 194 base::PickleIterator it(pickle); |
195 EntryMetadata new_entry_metadata; | 195 EntryMetadata new_entry_metadata; |
196 new_entry_metadata.Deserialize(&it); | 196 new_entry_metadata.Deserialize(&it); |
197 CheckEntryMetadataValues(new_entry_metadata); | 197 CheckEntryMetadataValues(new_entry_metadata); |
198 } | 198 } |
199 | 199 |
200 TEST_F(SimpleIndexTest, IndexSizeCorrectOnMerge) { | 200 TEST_F(SimpleIndexTest, IndexSizeCorrectOnMerge) { |
201 index()->SetMaxSize(100); | 201 index()->SetMaxSize(100); |
202 index()->Insert(hashes_.at<2>()); | 202 index()->Insert(hashes_.at<2>()); |
203 index()->UpdateEntrySize(hashes_.at<2>(), 2); | 203 index()->UpdateEntrySize(hashes_.at<2>(), 2); |
204 index()->Insert(hashes_.at<3>()); | 204 index()->Insert(hashes_.at<3>()); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 WaitForTimeChange(); | 619 WaitForTimeChange(); |
620 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 620 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
621 index()->Insert(hashes_.at<2>()); | 621 index()->Insert(hashes_.at<2>()); |
622 index()->UpdateEntrySize(hashes_.at<2>(), 40); | 622 index()->UpdateEntrySize(hashes_.at<2>(), 40); |
623 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); | 623 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); |
624 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 624 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
625 index()->write_to_disk_timer_.Stop(); | 625 index()->write_to_disk_timer_.Stop(); |
626 } | 626 } |
627 | 627 |
628 } // namespace disk_cache | 628 } // namespace disk_cache |
OLD | NEW |