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

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

Issue 11269008: Cache backend for devices with flash storage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: test Created 8 years, 1 month 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/scoped_temp_dir.h" 6 #include "base/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/storage.h" 9 #include "net/disk_cache/flash/storage.h"
10 #include "net/disk_cache/flash/flash_cache_test_base.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace { 13 namespace {
13 14
14 const int32 kSizes[] = {512, 1024, 4096, 133, 1333, 13333}; 15 const int32 kSizes[] = {512, 1024, 4096, 133, 1333, 13333};
15 const int32 kOffsets[] = {0, 1, 3333, 125, 12443, 4431}; 16 const int32 kOffsets[] = {0, 1, 3333, 125, 12443, 4431};
16 const int32 kStorageSize = 16 * 1024 * 1024; 17 const int32 kStorageSize = 16 * 1024 * 1024;
17 18
18 } // namespace 19 } // namespace
19 20
20 TEST(FlashCacheTest, StorageReadWrite) { 21 TEST_F(FlashCacheTest, StorageReadWrite) {
21 ScopedTempDir tempdir;
22 ASSERT_TRUE(tempdir.CreateUniqueTempDir());
23 const FilePath path(tempdir.path().Append(FILE_PATH_LITERAL("cache")));
24
25 disk_cache::Storage storage(path, kStorageSize);
26 EXPECT_TRUE(storage.Init());
27
28 for (size_t i = 0; i < arraysize(kOffsets); ++i) { 22 for (size_t i = 0; i < arraysize(kOffsets); ++i) {
29 int32 size = kSizes[i]; 23 int32 size = kSizes[i];
30 int32 offset = kOffsets[i]; 24 int32 offset = kOffsets[i];
31 25
32 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size)); 26 scoped_refptr<net::IOBuffer> write_buffer(new net::IOBuffer(size));
33 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size)); 27 scoped_refptr<net::IOBuffer> read_buffer(new net::IOBuffer(size));
34 28
35 CacheTestFillBuffer(write_buffer->data(), size, false); 29 CacheTestFillBuffer(write_buffer->data(), size, false);
36 30
37 bool rv = storage.Write(write_buffer->data(), size, offset); 31 bool rv = storage_->Write(write_buffer->data(), size, offset);
38 EXPECT_TRUE(rv); 32 EXPECT_TRUE(rv);
39 33
40 rv = storage.Read(read_buffer->data(), size, offset); 34 rv = storage_->Read(read_buffer->data(), size, offset);
41 EXPECT_TRUE(rv); 35 EXPECT_TRUE(rv);
42 36
43 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size)); 37 EXPECT_EQ(0, memcmp(read_buffer->data(), write_buffer->data(), size));
44 } 38 }
45 } 39 }
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