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