Chromium Code Reviews| Index: net/disk_cache/backend_unittest.cc |
| diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc |
| index 0f3c8db01d2152944d4b6a4c1719af50ada30f60..58191896832b388ff07178ac0a4762b7d00d733f 100644 |
| --- a/net/disk_cache/backend_unittest.cc |
| +++ b/net/disk_cache/backend_unittest.cc |
| @@ -3998,3 +3998,47 @@ TEST_F(DiskCacheBackendTest, SimpleCacheLateDoom) { |
| EXPECT_EQ(disk_cache::SimpleIndex::INITIALIZE_METHOD_LOADED, |
| simple_cache_impl_->index()->init_method()); |
| } |
| + |
| +TEST_F(DiskCacheBackendTest, SimpleLastModified) { |
|
jkarlin
2017/04/21 13:48:33
Please add a comment describing what this test is
Maks Orlovich
2017/04/21 15:12:52
Done.
|
| + SetSimpleCacheMode(); |
| + InitCache(); |
| + std::string key1 = GenerateKey(true); |
| + std::string key2 = GenerateKey(true); |
| + |
| + disk_cache::Entry* entry1; |
| + ASSERT_THAT(CreateEntry(key1, &entry1), IsOk()); |
| + |
| + // Make the Create complete --- SimpleCache can handle it optimistically, |
| + // and if we let it go fully async then trying to flush the Close might just |
| + // flush the Create. |
| + disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + entry1->Close(); |
| + |
| + // Make the ::Close actually complete, since it is asynchronous. |
| + disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + Time entry1_timestamp = Time::NowFromSystemTime(); |
| + |
| + // Don't want AddDelay since it sleep 1s(!) for SimpleCache, and we don't |
| + // care about reduced precision in index here. |
| + while (base::Time::Now() <= |
|
jkarlin
2017/04/21 13:48:33
Also use NowFromSystemTime here?
Maks Orlovich
2017/04/21 15:12:52
Done.
|
| + (entry1_timestamp + base::TimeDelta::FromMilliseconds(10))) { |
| + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| + } |
| + |
| + disk_cache::Entry* entry2; |
| + ASSERT_THAT(CreateEntry(key2, &entry2), IsOk()); |
| + entry2->Close(); |
| + disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + disk_cache::Entry* reopen_entry1; |
| + ASSERT_THAT(OpenEntry(key1, &reopen_entry1), IsOk()); |
| + |
| + // This shouldn't pick up entry2's write time incorrectly. |
| + EXPECT_LE(reopen_entry1->GetLastModified(), entry1_timestamp); |
| + reopen_entry1->Close(); |
| +} |