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

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

Issue 182093002: Remove the flash specific disk cache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/flash/log_store_entry.cc ('k') | net/disk_cache/flash/log_store_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/memory/scoped_ptr.h"
6 #include "net/base/io_buffer.h"
7 #include "net/disk_cache/disk_cache_test_util.h"
8 #include "net/disk_cache/flash/flash_cache_test_base.h"
9 #include "net/disk_cache/flash/format.h"
10 #include "net/disk_cache/flash/log_store.h"
11 #include "net/disk_cache/flash/log_store_entry.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using disk_cache::LogStoreEntry;
15
16 // Tests the behavior of a LogStoreEntry with empty streams.
17 TEST_F(FlashCacheTest, LogStoreEntryEmpty) {
18 disk_cache::LogStore log_store(path_, kStorageSize);
19 ASSERT_TRUE(log_store.Init());
20
21 scoped_ptr<LogStoreEntry> entry(new LogStoreEntry(&log_store));
22 EXPECT_TRUE(entry->Init());
23 EXPECT_TRUE(entry->Close());
24
25 entry.reset(new LogStoreEntry(&log_store, entry->id()));
26 EXPECT_TRUE(entry->Init());
27
28 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
29 const int kSize = 1024;
30 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
31 EXPECT_EQ(0, entry->GetDataSize(i));
32 EXPECT_EQ(0, entry->ReadData(i, 0, buf.get(), kSize));
33 }
34 EXPECT_TRUE(entry->Close());
35 ASSERT_TRUE(log_store.Close());
36 }
37
38 TEST_F(FlashCacheTest, LogStoreEntryWriteRead) {
39 disk_cache::LogStore log_store(path_, kStorageSize);
40 ASSERT_TRUE(log_store.Init());
41
42 scoped_ptr<LogStoreEntry> entry(new LogStoreEntry(&log_store));
43 EXPECT_TRUE(entry->Init());
44
45 int sizes[disk_cache::kFlashLogStoreEntryNumStreams] = {333, 444, 555, 666};
46 scoped_refptr<net::IOBuffer> buffers[
47 disk_cache::kFlashLogStoreEntryNumStreams];
48
49 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
50 buffers[i] = new net::IOBuffer(sizes[i]);
51 CacheTestFillBuffer(buffers[i]->data(), sizes[i], false);
52 EXPECT_EQ(sizes[i], entry->WriteData(i, 0, buffers[i].get(), sizes[i]));
53 }
54 EXPECT_TRUE(entry->Close());
55
56 int32 id = entry->id();
57 entry.reset(new LogStoreEntry(&log_store, id));
58 EXPECT_TRUE(entry->Init());
59
60 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
61 EXPECT_EQ(sizes[i], entry->GetDataSize(i));
62 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(sizes[i]));
63 EXPECT_EQ(sizes[i], entry->ReadData(i, 0, buffer.get(), sizes[i]));
64 EXPECT_EQ(0, memcmp(buffers[i]->data(), buffer->data(), sizes[i]));
65 }
66 EXPECT_TRUE(entry->Close());
67 EXPECT_EQ(id, entry->id());
68 ASSERT_TRUE(log_store.Close());
69 }
OLDNEW
« no previous file with comments | « net/disk_cache/flash/log_store_entry.cc ('k') | net/disk_cache/flash/log_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698