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

Side by Side Diff: webkit/browser/fileapi/quota/quota_backend_impl_unittest.cc

Issue 145693005: [FileAPI] Replace default leveldb::Env with leveldb::MemEnv in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/quota/quota_backend_impl.h" 5 #include "webkit/browser/fileapi/quota/quota_backend_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
13 #include "third_party/leveldatabase/src/include/leveldb/env.h"
12 #include "webkit/browser/fileapi/file_system_usage_cache.h" 14 #include "webkit/browser/fileapi/file_system_usage_cache.h"
13 #include "webkit/browser/fileapi/obfuscated_file_util.h" 15 #include "webkit/browser/fileapi/obfuscated_file_util.h"
14 #include "webkit/browser/quota/quota_manager_proxy.h" 16 #include "webkit/browser/quota/quota_manager_proxy.h"
15 17
16 namespace fileapi { 18 namespace fileapi {
17 19
18 namespace { 20 namespace {
19 21
20 const char kOrigin[] = "http://example.com"; 22 const char kOrigin[] = "http://example.com";
21 23
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } // namespace 81 } // namespace
80 82
81 class QuotaBackendImplTest : public testing::Test { 83 class QuotaBackendImplTest : public testing::Test {
82 public: 84 public:
83 QuotaBackendImplTest() 85 QuotaBackendImplTest()
84 : file_system_usage_cache_(file_task_runner()), 86 : file_system_usage_cache_(file_task_runner()),
85 quota_manager_proxy_(new MockQuotaManagerProxy) {} 87 quota_manager_proxy_(new MockQuotaManagerProxy) {}
86 88
87 virtual void SetUp() OVERRIDE { 89 virtual void SetUp() OVERRIDE {
88 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 90 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
91 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
89 file_util_.reset(ObfuscatedFileUtil::CreateForTesting( 92 file_util_.reset(ObfuscatedFileUtil::CreateForTesting(
90 NULL, data_dir_.path(), file_task_runner())); 93 NULL, data_dir_.path(), in_memory_env_.get(), file_task_runner()));
91 backend_.reset(new QuotaBackendImpl(file_task_runner(), 94 backend_.reset(new QuotaBackendImpl(file_task_runner(),
92 file_util_.get(), 95 file_util_.get(),
93 &file_system_usage_cache_, 96 &file_system_usage_cache_,
94 quota_manager_proxy_.get())); 97 quota_manager_proxy_.get()));
95 } 98 }
96 99
97 virtual void TearDown() OVERRIDE { 100 virtual void TearDown() OVERRIDE {
98 backend_.reset(); 101 backend_.reset();
99 quota_manager_proxy_ = NULL; 102 quota_manager_proxy_ = NULL;
100 file_util_.reset(); 103 file_util_.reset();
(...skipping 24 matching lines...) Expand all
125 base::FilePath path; 128 base::FilePath path;
126 base::File::Error error = 129 base::File::Error error =
127 backend_->GetUsageCachePath(origin, type, &path); 130 backend_->GetUsageCachePath(origin, type, &path);
128 EXPECT_EQ(base::File::FILE_OK, error); 131 EXPECT_EQ(base::File::FILE_OK, error);
129 EXPECT_FALSE(path.empty()); 132 EXPECT_FALSE(path.empty());
130 return path; 133 return path;
131 } 134 }
132 135
133 base::MessageLoop message_loop_; 136 base::MessageLoop message_loop_;
134 base::ScopedTempDir data_dir_; 137 base::ScopedTempDir data_dir_;
138 scoped_ptr<leveldb::Env> in_memory_env_;
135 scoped_ptr<ObfuscatedFileUtil> file_util_; 139 scoped_ptr<ObfuscatedFileUtil> file_util_;
136 FileSystemUsageCache file_system_usage_cache_; 140 FileSystemUsageCache file_system_usage_cache_;
137 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; 141 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
138 scoped_ptr<QuotaBackendImpl> backend_; 142 scoped_ptr<QuotaBackendImpl> backend_;
139 143
140 private: 144 private:
141 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest); 145 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest);
142 }; 146 };
143 147
144 TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) { 148 TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 uint32 dirty = 0; 243 uint32 dirty = 0;
240 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); 244 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
241 EXPECT_EQ(1u, dirty); 245 EXPECT_EQ(1u, dirty);
242 246
243 backend_->DecrementDirtyCount(GURL(kOrigin), type); 247 backend_->DecrementDirtyCount(GURL(kOrigin), type);
244 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); 248 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
245 EXPECT_EQ(0u, dirty); 249 EXPECT_EQ(0u, dirty);
246 } 250 }
247 251
248 } // namespace fileapi 252 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/plugin_private_file_system_backend.cc ('k') | webkit/browser/fileapi/sandbox_directory_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698