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_reservation_manager.h" | 5 #include "storage/browser/fileapi/quota/quota_reservation_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 reservation->RefreshReservation(size, base::Bind(&ExpectSuccess, &done)); | 173 reservation->RefreshReservation(size, base::Bind(&ExpectSuccess, &done)); |
174 base::RunLoop().RunUntilIdle(); | 174 base::RunLoop().RunUntilIdle(); |
175 EXPECT_TRUE(done); | 175 EXPECT_TRUE(done); |
176 } | 176 } |
177 | 177 |
178 } // namespace | 178 } // namespace |
179 | 179 |
180 class QuotaReservationManagerTest : public testing::Test { | 180 class QuotaReservationManagerTest : public testing::Test { |
181 public: | 181 public: |
182 QuotaReservationManagerTest() {} | 182 QuotaReservationManagerTest() {} |
183 virtual ~QuotaReservationManagerTest() {} | 183 ~QuotaReservationManagerTest() override {} |
184 | 184 |
185 virtual void SetUp() override { | 185 void SetUp() override { |
186 ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); | 186 ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); |
187 file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge")); | 187 file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge")); |
188 SetFileSize(file_path_, kInitialFileSize); | 188 SetFileSize(file_path_, kInitialFileSize); |
189 | 189 |
190 scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend); | 190 scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend); |
191 reservation_manager_.reset(new QuotaReservationManager(backend.Pass())); | 191 reservation_manager_.reset(new QuotaReservationManager(backend.Pass())); |
192 } | 192 } |
193 | 193 |
194 virtual void TearDown() override { | 194 void TearDown() override { reservation_manager_.reset(); } |
195 reservation_manager_.reset(); | |
196 } | |
197 | 195 |
198 FakeBackend* fake_backend() { | 196 FakeBackend* fake_backend() { |
199 return static_cast<FakeBackend*>(reservation_manager_->backend_.get()); | 197 return static_cast<FakeBackend*>(reservation_manager_->backend_.get()); |
200 } | 198 } |
201 | 199 |
202 QuotaReservationManager* reservation_manager() { | 200 QuotaReservationManager* reservation_manager() { |
203 return reservation_manager_.get(); | 201 return reservation_manager_.get(); |
204 } | 202 } |
205 | 203 |
206 const base::FilePath& file_path() const { | 204 const base::FilePath& file_path() const { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 356 |
359 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); | 357 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); |
360 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); | 358 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); |
361 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); | 359 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); |
362 | 360 |
363 reservation2 = NULL; | 361 reservation2 = NULL; |
364 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); | 362 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); |
365 } | 363 } |
366 | 364 |
367 } // namespace content | 365 } // namespace content |
OLD | NEW |