| 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
|
|
|