| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <sstream> | 11 #include <sstream> |
| 12 #include <tuple> | 12 #include <tuple> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
| 24 #include "base/test/histogram_tester.h" | 24 #include "base/test/histogram_tester.h" |
| 25 #include "base/test/scoped_task_environment.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 27 #include "content/public/test/mock_special_storage_policy.h" | 28 #include "content/public/test/mock_special_storage_policy.h" |
| 28 #include "content/public/test/mock_storage_client.h" | 29 #include "content/public/test/mock_storage_client.h" |
| 29 #include "storage/browser/quota/quota_database.h" | 30 #include "storage/browser/quota/quota_database.h" |
| 30 #include "storage/browser/quota/quota_manager.h" | 31 #include "storage/browser/quota/quota_manager.h" |
| 31 #include "storage/browser/quota/quota_manager_proxy.h" | 32 #include "storage/browser/quota/quota_manager_proxy.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 34 | 35 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 base::FilePath profile_path() const { return data_dir_.GetPath(); } | 439 base::FilePath profile_path() const { return data_dir_.GetPath(); } |
| 439 int status_callback_count() const { return status_callback_count_; } | 440 int status_callback_count() const { return status_callback_count_; } |
| 440 void reset_status_callback_count() { status_callback_count_ = 0; } | 441 void reset_status_callback_count() { status_callback_count_ = 0; } |
| 441 | 442 |
| 442 private: | 443 private: |
| 443 base::Time IncrementMockTime() { | 444 base::Time IncrementMockTime() { |
| 444 ++mock_time_counter_; | 445 ++mock_time_counter_; |
| 445 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); | 446 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); |
| 446 } | 447 } |
| 447 | 448 |
| 448 base::MessageLoop message_loop_; | 449 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 449 base::ScopedTempDir data_dir_; | 450 base::ScopedTempDir data_dir_; |
| 450 | 451 |
| 451 scoped_refptr<QuotaManager> quota_manager_; | 452 scoped_refptr<QuotaManager> quota_manager_; |
| 452 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; | 453 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; |
| 453 | 454 |
| 454 QuotaStatusCode quota_status_; | 455 QuotaStatusCode quota_status_; |
| 455 UsageInfoEntries usage_info_; | 456 UsageInfoEntries usage_info_; |
| 456 int64_t usage_; | 457 int64_t usage_; |
| 457 int64_t limited_usage_; | 458 int64_t limited_usage_; |
| 458 int64_t unlimited_usage_; | 459 int64_t unlimited_usage_; |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 EXPECT_EQ(available_space() + usage(), quota()); | 2247 EXPECT_EQ(available_space() + usage(), quota()); |
| 2247 | 2248 |
| 2248 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2249 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2249 base::RunLoop().RunUntilIdle(); | 2250 base::RunLoop().RunUntilIdle(); |
| 2250 EXPECT_EQ(kQuotaStatusOk, status()); | 2251 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2251 EXPECT_EQ(10, usage()); | 2252 EXPECT_EQ(10, usage()); |
| 2252 EXPECT_EQ(available_space() + usage(), quota()); | 2253 EXPECT_EQ(available_space() + usage(), quota()); |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 } // namespace content | 2256 } // namespace content |
| OLD | NEW |