Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: net/disk_cache/flash/storage_unittest.cc

Issue 14265009: FlashCache refactorings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More refactorings. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/flash/segment_unittest.cc ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/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/flash_cache_test_base.h"
10 #include "net/disk_cache/flash/storage.h" 10 #include "net/disk_cache/flash/storage.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;
18 17
19 } // namespace 18 } // namespace
20 19
21 TEST_F(FlashCacheTest, StorageReadWrite) { 20 TEST_F(FlashCacheTest, StorageReadWrite) {
21 disk_cache::Storage storage(path_, kStorageSize);
22 EXPECT_TRUE(storage.Init());
23
22 for (size_t i = 0; i < arraysize(kOffsets); ++i) { 24 for (size_t i = 0; i < arraysize(kOffsets); ++i) {
23 int32 size = kSizes[i]; 25 int32 size = kSizes[i];
24 int32 offset = kOffsets[i]; 26 int32 offset = kOffsets[i];
25 27
26 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size)); 28 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size));
27 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size)); 29 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size));
28 30
29 CacheTestFillBuffer(write_buffer->data(), size, false); 31 CacheTestFillBuffer(write_buffer->data(), size, false);
30 32
31 bool rv = storage_->Write(write_buffer->data(), size, offset); 33 bool rv = storage.Write(write_buffer->data(), size, offset);
32 EXPECT_TRUE(rv); 34 EXPECT_TRUE(rv);
33 35
34 rv = storage_->Read(read_buffer->data(), size, offset); 36 rv = storage.Read(read_buffer->data(), size, offset);
35 EXPECT_TRUE(rv); 37 EXPECT_TRUE(rv);
36 38
37 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size)); 39 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size));
38 } 40 }
39 } 41 }
OLDNEW
« no previous file with comments | « net/disk_cache/flash/segment_unittest.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698