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

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

Issue 2776273002: Move some quota tests next to the files they cover. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "storage/browser/fileapi/quota/quota_backend_impl.h" 5 #include "storage/browser/fileapi/quota/quota_backend_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 30 matching lines...) Expand all
41 *error_out = error; 41 *error_out = error;
42 *delta_out = delta; 42 *delta_out = delta;
43 return accepted; 43 return accepted;
44 } 44 }
45 45
46 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { 46 class MockQuotaManagerProxy : public storage::QuotaManagerProxy {
47 public: 47 public:
48 MockQuotaManagerProxy() 48 MockQuotaManagerProxy()
49 : QuotaManagerProxy(NULL, NULL), 49 : QuotaManagerProxy(NULL, NULL),
50 storage_modified_count_(0), 50 storage_modified_count_(0),
51 usage_(0), quota_(0) {} 51 usage_(0),
52 quota_(0) {}
52 53
53 // We don't mock them. 54 // We don't mock them.
54 void NotifyOriginInUse(const GURL& origin) override {} 55 void NotifyOriginInUse(const GURL& origin) override {}
55 void NotifyOriginNoLongerInUse(const GURL& origin) override {} 56 void NotifyOriginNoLongerInUse(const GURL& origin) override {}
56 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, 57 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id,
57 const GURL& origin, 58 const GURL& origin,
58 storage::StorageType type, 59 storage::StorageType type,
59 bool enabled) override {} 60 bool enabled) override {}
60 61
61 void NotifyStorageModified(storage::QuotaClient::ID client_id, 62 void NotifyStorageModified(storage::QuotaClient::ID client_id,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 public: 97 public:
97 QuotaBackendImplTest() 98 QuotaBackendImplTest()
98 : file_system_usage_cache_(file_task_runner()), 99 : file_system_usage_cache_(file_task_runner()),
99 quota_manager_proxy_(new MockQuotaManagerProxy) {} 100 quota_manager_proxy_(new MockQuotaManagerProxy) {}
100 101
101 void SetUp() override { 102 void SetUp() override {
102 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 103 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
103 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 104 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
104 file_util_.reset(ObfuscatedFileUtil::CreateForTesting( 105 file_util_.reset(ObfuscatedFileUtil::CreateForTesting(
105 NULL, data_dir_.GetPath(), in_memory_env_.get(), file_task_runner())); 106 NULL, data_dir_.GetPath(), in_memory_env_.get(), file_task_runner()));
106 backend_.reset(new QuotaBackendImpl(file_task_runner(), 107 backend_.reset(new QuotaBackendImpl(file_task_runner(), file_util_.get(),
107 file_util_.get(),
108 &file_system_usage_cache_, 108 &file_system_usage_cache_,
109 quota_manager_proxy_.get())); 109 quota_manager_proxy_.get()));
110 } 110 }
111 111
112 void TearDown() override { 112 void TearDown() override {
113 backend_.reset(); 113 backend_.reset();
114 quota_manager_proxy_ = NULL; 114 quota_manager_proxy_ = NULL;
115 file_util_.reset(); 115 file_util_.reset();
116 base::RunLoop().RunUntilIdle(); 116 base::RunLoop().RunUntilIdle();
117 } 117 }
(...skipping 15 matching lines...) Expand all
133 GetUsageCachePath(origin, type), 0)); 133 GetUsageCachePath(origin, type), 0));
134 } 134 }
135 135
136 base::SequencedTaskRunner* file_task_runner() { 136 base::SequencedTaskRunner* file_task_runner() {
137 return base::ThreadTaskRunnerHandle::Get().get(); 137 return base::ThreadTaskRunnerHandle::Get().get();
138 } 138 }
139 139
140 base::FilePath GetUsageCachePath(const GURL& origin, 140 base::FilePath GetUsageCachePath(const GURL& origin,
141 storage::FileSystemType type) { 141 storage::FileSystemType type) {
142 base::FilePath path; 142 base::FilePath path;
143 base::File::Error error = 143 base::File::Error error = backend_->GetUsageCachePath(origin, type, &path);
144 backend_->GetUsageCachePath(origin, type, &path);
145 EXPECT_EQ(base::File::FILE_OK, error); 144 EXPECT_EQ(base::File::FILE_OK, error);
146 EXPECT_FALSE(path.empty()); 145 EXPECT_FALSE(path.empty());
147 return path; 146 return path;
148 } 147 }
149 148
150 base::MessageLoop message_loop_; 149 base::MessageLoop message_loop_;
151 base::ScopedTempDir data_dir_; 150 base::ScopedTempDir data_dir_;
152 std::unique_ptr<leveldb::Env> in_memory_env_; 151 std::unique_ptr<leveldb::Env> in_memory_env_;
153 std::unique_ptr<ObfuscatedFileUtil> file_util_; 152 std::unique_ptr<ObfuscatedFileUtil> file_util_;
154 FileSystemUsageCache file_system_usage_cache_; 153 FileSystemUsageCache file_system_usage_cache_;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 uint32_t dirty = 0; 266 uint32_t dirty = 0;
268 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
269 EXPECT_EQ(1u, dirty); 268 EXPECT_EQ(1u, dirty);
270 269
271 backend_->DecrementDirtyCount(GURL(kOrigin), type); 270 backend_->DecrementDirtyCount(GURL(kOrigin), type);
272 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); 271 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
273 EXPECT_EQ(0u, dirty); 272 EXPECT_EQ(0u, dirty);
274 } 273 }
275 274
276 } // namespace content 275 } // namespace content
OLDNEW
« no previous file with comments | « storage/browser/BUILD.gn ('k') | storage/browser/fileapi/quota/quota_reservation_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698