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

Side by Side Diff: net/disk_cache/flash/flash_entry_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/flash_cache_test_base.cc ('k') | net/disk_cache/flash/log_store.h » ('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/ref_counted.h"
6 #include "base/string_util.h"
7 #include "base/threading/thread.h"
8 #include "base/threading/thread_restrictions.h"
9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h"
11 #include "net/disk_cache/disk_cache_test_util.h"
12 #include "net/disk_cache/flash/flash_cache_test_base.h"
13 #include "net/disk_cache/flash/flash_entry_impl.h"
14 #include "net/disk_cache/flash/format.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 using net::CompletionCallback;
18
19 TEST_F(FlashCacheTest, FlashEntryCreate) {
20 base::Thread cache_thread("CacheThread");
21 ASSERT_TRUE(cache_thread.StartWithOptions(
22 base::Thread::Options(MessageLoop::TYPE_IO, 0)));
23
24 const std::string key = "foo.com";
25 disk_cache::FlashEntryImpl* entry =
26 new disk_cache::FlashEntryImpl(key,
27 log_store_.get(),
28 cache_thread.message_loop_proxy());
29 entry->AddRef();
30 EXPECT_EQ(net::OK, entry->Init(CompletionCallback()));
31 EXPECT_EQ(key, entry->GetKey());
32 EXPECT_EQ(0, entry->GetDataSize(0));
33 EXPECT_EQ(0, entry->GetDataSize(1));
34 EXPECT_EQ(0, entry->GetDataSize(2));
35
36 const int kSize1 = 100;
37 scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize1));
38 CacheTestFillBuffer(buffer1->data(), kSize1, false);
39 EXPECT_EQ(0, entry->ReadData(0, 0, buffer1, kSize1, CompletionCallback()));
40 base::strlcpy(buffer1->data(), "the data", kSize1);
41 EXPECT_EQ(kSize1, entry->WriteData(0, 0, buffer1, kSize1,
42 CompletionCallback(), false));
43 memset(buffer1->data(), 0, kSize1);
44 EXPECT_EQ(kSize1, entry->ReadData(0, 0, buffer1, kSize1,
45 CompletionCallback()));
46 EXPECT_STREQ("the data", buffer1->data());
47 entry->Close();
48 }
OLDNEW
« no previous file with comments | « net/disk_cache/flash/flash_cache_test_base.cc ('k') | net/disk_cache/flash/log_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698