| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 4202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4213 scoped_refptr<net::IOBuffer> check_stream_1_data( | 4213 scoped_refptr<net::IOBuffer> check_stream_1_data( |
| 4214 new net::IOBuffer(stream_1_data.size())); | 4214 new net::IOBuffer(stream_1_data.size())); |
| 4215 EXPECT_EQ( | 4215 EXPECT_EQ( |
| 4216 static_cast<int>(stream_1_data.size()), | 4216 static_cast<int>(stream_1_data.size()), |
| 4217 ReadData(entry, 1, 0, check_stream_1_data.get(), stream_1_data.size())); | 4217 ReadData(entry, 1, 0, check_stream_1_data.get(), stream_1_data.size())); |
| 4218 EXPECT_EQ(0, stream_1_data.compare(0, std::string::npos, | 4218 EXPECT_EQ(0, stream_1_data.compare(0, std::string::npos, |
| 4219 check_stream_1_data->data(), | 4219 check_stream_1_data->data(), |
| 4220 stream_1_data.size())); | 4220 stream_1_data.size())); |
| 4221 } | 4221 } |
| 4222 | 4222 |
| 4223 TEST_F(DiskCacheEntryTest, SimpleCacheDoubleOpenWithoutKeySHA256) { |
| 4224 // This test runs as APP_CACHE to make operations more synchronous. |
| 4225 SetCacheType(net::APP_CACHE); |
| 4226 SetSimpleCacheMode(); |
| 4227 InitCache(); |
| 4228 disk_cache::Entry* entry; |
| 4229 std::string key("a key"); |
| 4230 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
| 4231 entry->Close(); |
| 4232 |
| 4233 base::RunLoop().RunUntilIdle(); |
| 4234 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 4235 base::RunLoop().RunUntilIdle(); |
| 4236 |
| 4237 EXPECT_TRUE( |
| 4238 disk_cache::simple_util::RemoveKeySHA256FromEntry(key, cache_path_)); |
| 4239 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
| 4240 entry->Close(); |
| 4241 |
| 4242 base::RunLoop().RunUntilIdle(); |
| 4243 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 4244 base::RunLoop().RunUntilIdle(); |
| 4245 |
| 4246 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
| 4247 entry->Close(); |
| 4248 } |
| 4249 |
| 4223 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptKeySHA256) { | 4250 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptKeySHA256) { |
| 4224 // This test runs as APP_CACHE to make operations more synchronous. | 4251 // This test runs as APP_CACHE to make operations more synchronous. |
| 4225 SetCacheType(net::APP_CACHE); | 4252 SetCacheType(net::APP_CACHE); |
| 4226 SetSimpleCacheMode(); | 4253 SetSimpleCacheMode(); |
| 4227 InitCache(); | 4254 InitCache(); |
| 4228 disk_cache::Entry* entry; | 4255 disk_cache::Entry* entry; |
| 4229 std::string key("a key"); | 4256 std::string key("a key"); |
| 4230 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); | 4257 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
| 4231 entry->Close(); | 4258 entry->Close(); |
| 4232 | 4259 |
| 4233 base::RunLoop().RunUntilIdle(); | 4260 base::RunLoop().RunUntilIdle(); |
| 4234 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 4261 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 4235 base::RunLoop().RunUntilIdle(); | 4262 base::RunLoop().RunUntilIdle(); |
| 4236 | 4263 |
| 4237 EXPECT_TRUE( | 4264 EXPECT_TRUE( |
| 4238 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_)); | 4265 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_)); |
| 4239 EXPECT_NE(net::OK, OpenEntry(key, &entry)); | 4266 EXPECT_NE(net::OK, OpenEntry(key, &entry)); |
| 4240 } | 4267 } |
| OLD | NEW |