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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 // atomic renaming of recently open files. Those guarantees are not provided in | 2335 // atomic renaming of recently open files. Those guarantees are not provided in |
2336 // general on Windows. | 2336 // general on Windows. |
2337 #if defined(OS_POSIX) | 2337 #if defined(OS_POSIX) |
2338 | 2338 |
2339 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) { | 2339 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) { |
2340 SetSimpleCacheMode(); | 2340 SetSimpleCacheMode(); |
2341 InitCache(); | 2341 InitCache(); |
2342 InternalAsyncIO(); | 2342 InternalAsyncIO(); |
2343 } | 2343 } |
2344 | 2344 |
| 2345 TEST_F(DiskCacheEntryTest, SimpleCacheStress) { |
| 2346 SetSimpleCacheMode(); |
| 2347 InitCache(); |
| 2348 |
| 2349 disk_cache::Entry* entry = NULL; |
| 2350 |
| 2351 std::string stream0 = "0"; |
| 2352 std::string stream1 = "1"; |
| 2353 scoped_refptr<net::StringIOBuffer> buff0(new net::StringIOBuffer(stream0)); |
| 2354 scoped_refptr<net::StringIOBuffer> buff1(new net::StringIOBuffer(stream1)); |
| 2355 |
| 2356 for (int i = 0; i < 100; ++i) { |
| 2357 ASSERT_EQ(net::OK, CreateEntry("foo", &entry)); |
| 2358 EXPECT_EQ(buff0->size(), |
| 2359 WriteData(entry, 0, 0, buff0.get(), buff0->size(), false)); |
| 2360 EXPECT_EQ(buff1->size(), |
| 2361 WriteData(entry, 1, 0, buff1.get(), buff1->size(), false)); |
| 2362 entry->Close(); |
| 2363 entry = NULL; |
| 2364 |
| 2365 ASSERT_EQ(net::OK, OpenEntry("foo", &entry)); |
| 2366 entry->Doom(); |
| 2367 entry->Close(); |
| 2368 entry = NULL; |
| 2369 } |
| 2370 } |
| 2371 |
2345 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) { | 2372 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) { |
2346 SetSimpleCacheMode(); | 2373 SetSimpleCacheMode(); |
2347 InitCache(); | 2374 InitCache(); |
2348 ExternalAsyncIO(); | 2375 ExternalAsyncIO(); |
2349 } | 2376 } |
2350 | 2377 |
2351 TEST_F(DiskCacheEntryTest, SimpleCacheReleaseBuffer) { | 2378 TEST_F(DiskCacheEntryTest, SimpleCacheReleaseBuffer) { |
2352 SetSimpleCacheMode(); | 2379 SetSimpleCacheMode(); |
2353 InitCache(); | 2380 InitCache(); |
2354 for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) { | 2381 for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) { |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3962 EXPECT_EQ(kSize, callback.GetResult(ret)); | 3989 EXPECT_EQ(kSize, callback.GetResult(ret)); |
3963 | 3990 |
3964 // Make sure the first range was removed when the second was written. | 3991 // Make sure the first range was removed when the second was written. |
3965 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback()); | 3992 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback()); |
3966 EXPECT_EQ(0, callback.GetResult(ret)); | 3993 EXPECT_EQ(0, callback.GetResult(ret)); |
3967 | 3994 |
3968 entry->Close(); | 3995 entry->Close(); |
3969 } | 3996 } |
3970 | 3997 |
3971 #endif // defined(OS_POSIX) | 3998 #endif // defined(OS_POSIX) |
OLD | NEW |