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

Unified Diff: net/disk_cache/flash/flash_entry_unittest.cc

Issue 12847012: Adding disk_cache::Entry implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/flash/flash_entry_unittest.cc
diff --git a/net/disk_cache/flash/flash_entry_unittest.cc b/net/disk_cache/flash/flash_entry_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c44cfafe960f66e0378d71e12754d7f7fe1eb53
--- /dev/null
+++ b/net/disk_cache/flash/flash_entry_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/ref_counted.h"
+#include "base/string_util.h"
+#include "base/threading/thread.h"
+#include "base/threading/thread_restrictions.h"
+#include "net/base/io_buffer.h"
+#include "net/base/net_errors.h"
+#include "net/disk_cache/disk_cache_test_util.h"
+#include "net/disk_cache/flash/flash_cache_test_base.h"
+#include "net/disk_cache/flash/flash_entry_impl.h"
+#include "net/disk_cache/flash/format.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using net::CompletionCallback;
+
+TEST_F(FlashCacheTest, FlashEntryCreate) {
+ base::Thread cache_thread("CacheThread");
+ ASSERT_TRUE(cache_thread.StartWithOptions(
+ base::Thread::Options(MessageLoop::TYPE_IO, 0)));
+
+ const std::string key = "foo.com";
+ disk_cache::FlashEntryImpl* entry =
+ new disk_cache::FlashEntryImpl(key,
+ log_store_.get(),
+ cache_thread.message_loop_proxy());
+ entry->AddRef();
+ EXPECT_EQ(net::OK, entry->Init(CompletionCallback()));
+ EXPECT_EQ(key, entry->GetKey());
+ EXPECT_EQ(0, entry->GetDataSize(0));
+ EXPECT_EQ(0, entry->GetDataSize(1));
+ EXPECT_EQ(0, entry->GetDataSize(2));
+
+ const int kSize1 = 100;
+ scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize1));
+ CacheTestFillBuffer(buffer1->data(), kSize1, false);
+ EXPECT_EQ(0, entry->ReadData(0, 0, buffer1, kSize1, CompletionCallback()));
+ base::strlcpy(buffer1->data(), "the data", kSize1);
+ EXPECT_EQ(kSize1, entry->WriteData(
rvargas (doing something else) 2013/04/06 01:25:23 nit: indent under the first arg
agayev 2013/04/06 03:24:29 Done.
+ 0, 0, buffer1, kSize1, net::CompletionCallback(), false));
+ memset(buffer1->data(), 0, kSize1);
+ EXPECT_EQ(kSize1, entry->ReadData(
+ 0, 0, buffer1, kSize1, net::CompletionCallback()));
+ EXPECT_STREQ("the data", buffer1->data());
+ entry->Close();
+}

Powered by Google App Engine
This is Rietveld 408576698