| 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "net/base/io_buffer.h" | 7 #include "net/base/io_buffer.h" |
| 8 #include "net/disk_cache/disk_cache_test_util.h" | 8 #include "net/disk_cache/disk_cache_test_util.h" |
| 9 #include "net/disk_cache/flash/flash_cache_test_base.h" |
| 9 #include "net/disk_cache/flash/storage.h" | 10 #include "net/disk_cache/flash/storage.h" |
| 10 #include "net/disk_cache/flash/flash_cache_test_base.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const int32 kSizes[] = {512, 1024, 4096, 133, 1333, 13333}; | 15 const int32 kSizes[] = {512, 1024, 4096, 133, 1333, 13333}; |
| 16 const int32 kOffsets[] = {0, 1, 3333, 125, 12443, 4431}; | 16 const int32 kOffsets[] = {0, 1, 3333, 125, 12443, 4431}; |
| 17 const int32 kStorageSize = 16 * 1024 * 1024; | 17 const int32 kStorageSize = 16 * 1024 * 1024; |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 TEST_F(FlashCacheTest, StorageReadWrite) { | 21 TEST_F(FlashCacheTest, StorageReadWrite) { |
| 22 for (size_t i = 0; i < arraysize(kOffsets); ++i) { | 22 for (size_t i = 0; i < arraysize(kOffsets); ++i) { |
| 23 int32 size = kSizes[i]; | 23 int32 size = kSizes[i]; |
| 24 int32 offset = kOffsets[i]; | 24 int32 offset = kOffsets[i]; |
| 25 | 25 |
| 26 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size)); | 26 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size)); |
| 27 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size)); | 27 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size)); |
| 28 | 28 |
| 29 CacheTestFillBuffer(write_buffer->data(), size, false); | 29 CacheTestFillBuffer(write_buffer->data(), size, false); |
| 30 | 30 |
| 31 bool rv = storage_->Write(write_buffer->data(), size, offset); | 31 bool rv = storage_->Write(write_buffer->data(), size, offset); |
| 32 EXPECT_TRUE(rv); | 32 EXPECT_TRUE(rv); |
| 33 | 33 |
| 34 rv = storage_->Read(read_buffer->data(), size, offset); | 34 rv = storage_->Read(read_buffer->data(), size, offset); |
| 35 EXPECT_TRUE(rv); | 35 EXPECT_TRUE(rv); |
| 36 | 36 |
| 37 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size)); | 37 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size)); |
| 38 } | 38 } |
| 39 } | 39 } |
| OLD | NEW |