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

Unified Diff: net/disk_cache/memory/memory_unittest.cc

Issue 127083002: **STILLBAKING** Decouple disk cache tests from backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upstream rebase Created 6 years, 10 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
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/memory/memory_unittest.cc
diff --git a/net/disk_cache/memory/memory_unittest.cc b/net/disk_cache/memory/memory_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..86a5567d97936c54085984e465304ad6492a84fc
--- /dev/null
+++ b/net/disk_cache/memory/memory_unittest.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2014 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 <string>
+
+#include "net/base/io_buffer.h"
+#include "net/base/net_errors.h"
+#include "net/disk_cache/disk_cache.h"
+#include "net/disk_cache/disk_cache_test_util.h"
+#include "net/disk_cache/backend_tests.h"
+#include "net/disk_cache/entry_sync_tests.h"
+#include "net/disk_cache/entry_tests.h"
+#include "net/disk_cache/memory/mem_entry_impl.h"
+#include "net/disk_cache/memory/mem_backend_impl.h"
+
+namespace disk_cache {
+
+namespace {
+
+class MemoryCacheBackendTraits : public BackendTestTraits {
+ public:
+ MemoryCacheBackendTraits() {}
+
+ virtual ~MemoryCacheBackendTraits() {}
+
+ virtual Backend* CreateBackend(
+ const CreateBackendExtraData* extra_data,
+ const base::FilePath& cache_path,
+ int max_size,
+ base::MessageLoopProxy* task_runner) const OVERRIDE {
+ scoped_ptr<MemBackendImpl> mem_backend(new MemBackendImpl(NULL));
+ if (max_size)
+ mem_backend->SetMaxSize(max_size);
+ if (!mem_backend->Init())
+ return NULL;
+ return mem_backend.release();
+ }
+
+ virtual bool EnumerationsAreLexicographicByKey() const OVERRIDE {
+ return true;
+ }
+
+ virtual bool UsesCacheThread() const OVERRIDE { return false; }
+
+ virtual bool SetMaxSize(Backend* backend, int size) const OVERRIDE {
+ return static_cast<MemBackendImpl*>(backend)->SetMaxSize(size);
+ }
+
+ static const BackendTestTraits* Get() {
+ static MemoryCacheBackendTraits traits;
+ return &traits;
+ }
+};
+
+INSTANTIATE_TEST_CASE_P(MemoryOnlyCache, DiskCacheEntryTest,
+ ::testing::Values(MemoryCacheBackendTraits::Get()));
+
+INSTANTIATE_TEST_CASE_P(MemoryOnlyCache, DiskCacheEntrySyncTest,
+ ::testing::Values(MemoryCacheBackendTraits::Get()));
+
+INSTANTIATE_TEST_CASE_P(MemoryOnlyCache, DiskCacheBackendTest,
+ ::testing::Values(MemoryCacheBackendTraits::Get()));
+
+class DiskCacheMemoryBackendTest : public DiskCacheBackendTest {};
+
+INSTANTIATE_TEST_CASE_P(MemoryOnlyCache, DiskCacheMemoryBackendTest,
+ ::testing::Values(MemoryCacheBackendTraits::Get()));
+
+TEST_P(DiskCacheMemoryBackendTest, CreateBackend) {
+ // Test the private factory method(s).
+ scoped_ptr<disk_cache::Backend> cache;
+ cache = disk_cache::MemBackendImpl::CreateBackend(0, NULL);
+ ASSERT_TRUE(cache.get());
+ cache.reset();
+}
+
+} // namespace
+
+} // namespace disk_cache
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698