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

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

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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/internal_entry.cc ('k') | net/disk_cache/in_flight_backend_io.cc » ('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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "net/base/io_buffer.h" 6 #include "net/base/io_buffer.h"
7 #include "net/disk_cache/disk_cache_test_util.h" 7 #include "net/disk_cache/disk_cache_test_util.h"
8 #include "net/disk_cache/flash/flash_cache_test_base.h" 8 #include "net/disk_cache/flash/flash_cache_test_base.h"
9 #include "net/disk_cache/flash/format.h" 9 #include "net/disk_cache/flash/format.h"
10 #include "net/disk_cache/flash/log_store.h" 10 #include "net/disk_cache/flash/log_store.h"
(...skipping 11 matching lines...) Expand all
22 EXPECT_TRUE(entry->Init()); 22 EXPECT_TRUE(entry->Init());
23 EXPECT_TRUE(entry->Close()); 23 EXPECT_TRUE(entry->Close());
24 24
25 entry.reset(new LogStoreEntry(&log_store, entry->id())); 25 entry.reset(new LogStoreEntry(&log_store, entry->id()));
26 EXPECT_TRUE(entry->Init()); 26 EXPECT_TRUE(entry->Init());
27 27
28 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) { 28 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
29 const int kSize = 1024; 29 const int kSize = 1024;
30 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); 30 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
31 EXPECT_EQ(0, entry->GetDataSize(i)); 31 EXPECT_EQ(0, entry->GetDataSize(i));
32 EXPECT_EQ(0, entry->ReadData(i, 0, buf, kSize)); 32 EXPECT_EQ(0, entry->ReadData(i, 0, buf.get(), kSize));
33 } 33 }
34 EXPECT_TRUE(entry->Close()); 34 EXPECT_TRUE(entry->Close());
35 ASSERT_TRUE(log_store.Close()); 35 ASSERT_TRUE(log_store.Close());
36 } 36 }
37 37
38 TEST_F(FlashCacheTest, LogStoreEntryWriteRead) { 38 TEST_F(FlashCacheTest, LogStoreEntryWriteRead) {
39 disk_cache::LogStore log_store(path_, kStorageSize); 39 disk_cache::LogStore log_store(path_, kStorageSize);
40 ASSERT_TRUE(log_store.Init()); 40 ASSERT_TRUE(log_store.Init());
41 41
42 scoped_ptr<LogStoreEntry> entry(new LogStoreEntry(&log_store)); 42 scoped_ptr<LogStoreEntry> entry(new LogStoreEntry(&log_store));
43 EXPECT_TRUE(entry->Init()); 43 EXPECT_TRUE(entry->Init());
44 44
45 int sizes[disk_cache::kFlashLogStoreEntryNumStreams] = {333, 444, 555, 666}; 45 int sizes[disk_cache::kFlashLogStoreEntryNumStreams] = {333, 444, 555, 666};
46 scoped_refptr<net::IOBuffer> buffers[ 46 scoped_refptr<net::IOBuffer> buffers[
47 disk_cache::kFlashLogStoreEntryNumStreams]; 47 disk_cache::kFlashLogStoreEntryNumStreams];
48 48
49 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) { 49 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
50 buffers[i] = new net::IOBuffer(sizes[i]); 50 buffers[i] = new net::IOBuffer(sizes[i]);
51 CacheTestFillBuffer(buffers[i]->data(), sizes[i], false); 51 CacheTestFillBuffer(buffers[i]->data(), sizes[i], false);
52 EXPECT_EQ(sizes[i], entry->WriteData(i, 0, buffers[i], sizes[i])); 52 EXPECT_EQ(sizes[i], entry->WriteData(i, 0, buffers[i].get(), sizes[i]));
53 } 53 }
54 EXPECT_TRUE(entry->Close()); 54 EXPECT_TRUE(entry->Close());
55 55
56 int32 id = entry->id(); 56 int32 id = entry->id();
57 entry.reset(new LogStoreEntry(&log_store, id)); 57 entry.reset(new LogStoreEntry(&log_store, id));
58 EXPECT_TRUE(entry->Init()); 58 EXPECT_TRUE(entry->Init());
59 59
60 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) { 60 for (int i = 0; i < disk_cache::kFlashLogStoreEntryNumStreams; ++i) {
61 EXPECT_EQ(sizes[i], entry->GetDataSize(i)); 61 EXPECT_EQ(sizes[i], entry->GetDataSize(i));
62 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(sizes[i])); 62 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(sizes[i]));
63 EXPECT_EQ(sizes[i], entry->ReadData(i, 0, buffer, 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])); 64 EXPECT_EQ(0, memcmp(buffers[i]->data(), buffer->data(), sizes[i]));
65 } 65 }
66 EXPECT_TRUE(entry->Close()); 66 EXPECT_TRUE(entry->Close());
67 EXPECT_EQ(id, entry->id()); 67 EXPECT_EQ(id, entry->id());
68 ASSERT_TRUE(log_store.Close()); 68 ASSERT_TRUE(log_store.Close());
69 } 69 }
OLDNEW
« no previous file with comments | « net/disk_cache/flash/internal_entry.cc ('k') | net/disk_cache/in_flight_backend_io.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698