OLD | NEW |
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 <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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 }; | 86 }; |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 class QuotaBackendImplTest : public testing::Test { | 90 class QuotaBackendImplTest : public testing::Test { |
91 public: | 91 public: |
92 QuotaBackendImplTest() | 92 QuotaBackendImplTest() |
93 : file_system_usage_cache_(file_task_runner()), | 93 : file_system_usage_cache_(file_task_runner()), |
94 quota_manager_proxy_(new MockQuotaManagerProxy) {} | 94 quota_manager_proxy_(new MockQuotaManagerProxy) {} |
95 | 95 |
96 virtual void SetUp() override { | 96 void SetUp() override { |
97 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 97 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
98 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 98 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
99 file_util_.reset(ObfuscatedFileUtil::CreateForTesting( | 99 file_util_.reset(ObfuscatedFileUtil::CreateForTesting( |
100 NULL, data_dir_.path(), in_memory_env_.get(), file_task_runner())); | 100 NULL, data_dir_.path(), in_memory_env_.get(), file_task_runner())); |
101 backend_.reset(new QuotaBackendImpl(file_task_runner(), | 101 backend_.reset(new QuotaBackendImpl(file_task_runner(), |
102 file_util_.get(), | 102 file_util_.get(), |
103 &file_system_usage_cache_, | 103 &file_system_usage_cache_, |
104 quota_manager_proxy_.get())); | 104 quota_manager_proxy_.get())); |
105 } | 105 } |
106 | 106 |
107 virtual void TearDown() override { | 107 void TearDown() override { |
108 backend_.reset(); | 108 backend_.reset(); |
109 quota_manager_proxy_ = NULL; | 109 quota_manager_proxy_ = NULL; |
110 file_util_.reset(); | 110 file_util_.reset(); |
111 message_loop_.RunUntilIdle(); | 111 message_loop_.RunUntilIdle(); |
112 } | 112 } |
113 | 113 |
114 protected: | 114 protected: |
115 void InitializeForOriginAndType(const GURL& origin, | 115 void InitializeForOriginAndType(const GURL& origin, |
116 storage::FileSystemType type) { | 116 storage::FileSystemType type) { |
117 ASSERT_TRUE(file_util_->InitOriginDatabase(origin, true /* create */)); | 117 ASSERT_TRUE(file_util_->InitOriginDatabase(origin, true /* create */)); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 uint32 dirty = 0; | 262 uint32 dirty = 0; |
263 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 263 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
264 EXPECT_EQ(1u, dirty); | 264 EXPECT_EQ(1u, dirty); |
265 | 265 |
266 backend_->DecrementDirtyCount(GURL(kOrigin), type); | 266 backend_->DecrementDirtyCount(GURL(kOrigin), type); |
267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
268 EXPECT_EQ(0u, dirty); | 268 EXPECT_EQ(0u, dirty); |
269 } | 269 } |
270 | 270 |
271 } // namespace content | 271 } // namespace content |
OLD | NEW |