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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "base/test/scoped_task_environment.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
20 #include "storage/browser/fileapi/quota/open_file_handle.h" | 21 #include "storage/browser/fileapi/quota/open_file_handle.h" |
21 #include "storage/browser/fileapi/quota/quota_reservation.h" | 22 #include "storage/browser/fileapi/quota/quota_reservation.h" |
22 #include "storage/browser/fileapi/quota/quota_reservation_manager.h" | 23 #include "storage/browser/fileapi/quota/quota_reservation_manager.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
25 using storage::kFileSystemTypeTemporary; | 26 using storage::kFileSystemTypeTemporary; |
26 using storage::OpenFileHandle; | 27 using storage::OpenFileHandle; |
27 using storage::QuotaReservation; | 28 using storage::QuotaReservation; |
28 using storage::QuotaReservationManager; | 29 using storage::QuotaReservationManager; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return static_cast<FakeBackend*>(reservation_manager_->backend_.get()); | 202 return static_cast<FakeBackend*>(reservation_manager_->backend_.get()); |
202 } | 203 } |
203 | 204 |
204 QuotaReservationManager* reservation_manager() { | 205 QuotaReservationManager* reservation_manager() { |
205 return reservation_manager_.get(); | 206 return reservation_manager_.get(); |
206 } | 207 } |
207 | 208 |
208 const base::FilePath& file_path() const { return file_path_; } | 209 const base::FilePath& file_path() const { return file_path_; } |
209 | 210 |
210 private: | 211 private: |
211 base::MessageLoop message_loop_; | 212 base::test::ScopedTaskEnvironment scoped_task_environment_; |
212 base::ScopedTempDir work_dir_; | 213 base::ScopedTempDir work_dir_; |
213 base::FilePath file_path_; | 214 base::FilePath file_path_; |
214 std::unique_ptr<QuotaReservationManager> reservation_manager_; | 215 std::unique_ptr<QuotaReservationManager> reservation_manager_; |
215 | 216 |
216 DISALLOW_COPY_AND_ASSIGN(QuotaReservationManagerTest); | 217 DISALLOW_COPY_AND_ASSIGN(QuotaReservationManagerTest); |
217 }; | 218 }; |
218 | 219 |
219 TEST_F(QuotaReservationManagerTest, BasicTest) { | 220 TEST_F(QuotaReservationManagerTest, BasicTest) { |
220 scoped_refptr<QuotaReservation> reservation = | 221 scoped_refptr<QuotaReservation> reservation = |
221 reservation_manager()->CreateReservation(GURL(kOrigin), kType); | 222 reservation_manager()->CreateReservation(GURL(kOrigin), kType); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); | 360 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); |
360 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); | 361 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); |
361 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); | 362 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); |
362 | 363 |
363 reservation2 = NULL; | 364 reservation2 = NULL; |
364 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); | 365 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); |
365 } | 366 } |
366 | 367 |
367 } // namespace content | 368 } // namespace content |
OLD | NEW |