| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/test/scoped_task_environment.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "content/public/test/mock_special_storage_policy.h" | 14 #include "content/public/test/mock_special_storage_policy.h" |
| 14 #include "net/base/url_util.h" | 15 #include "net/base/url_util.h" |
| 15 #include "storage/browser/quota/usage_tracker.h" | 16 #include "storage/browser/quota/usage_tracker.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 using storage::kQuotaStatusOk; | 19 using storage::kQuotaStatusOk; |
| 19 using storage::kStorageTypeTemporary; | 20 using storage::kStorageTypeTemporary; |
| 20 using storage::QuotaClient; | 21 using storage::QuotaClient; |
| 21 using storage::QuotaClientList; | 22 using storage::QuotaClientList; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 quota_client_.id(), origin, enabled); | 199 quota_client_.id(), origin, enabled); |
| 199 } | 200 } |
| 200 | 201 |
| 201 private: | 202 private: |
| 202 QuotaClientList GetUsageTrackerList() { | 203 QuotaClientList GetUsageTrackerList() { |
| 203 QuotaClientList client_list; | 204 QuotaClientList client_list; |
| 204 client_list.push_back("a_client_); | 205 client_list.push_back("a_client_); |
| 205 return client_list; | 206 return client_list; |
| 206 } | 207 } |
| 207 | 208 |
| 208 base::MessageLoop message_loop_; | 209 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 209 | 210 |
| 210 scoped_refptr<MockSpecialStoragePolicy> storage_policy_; | 211 scoped_refptr<MockSpecialStoragePolicy> storage_policy_; |
| 211 MockQuotaClient quota_client_; | 212 MockQuotaClient quota_client_; |
| 212 UsageTracker usage_tracker_; | 213 UsageTracker usage_tracker_; |
| 213 | 214 |
| 214 DISALLOW_COPY_AND_ASSIGN(UsageTrackerTest); | 215 DISALLOW_COPY_AND_ASSIGN(UsageTrackerTest); |
| 215 }; | 216 }; |
| 216 | 217 |
| 217 TEST_F(UsageTrackerTest, GrantAndRevokeUnlimitedStorage) { | 218 TEST_F(UsageTrackerTest, GrantAndRevokeUnlimitedStorage) { |
| 218 int64_t usage = 0; | 219 int64_t usage = 0; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 330 |
| 330 GetGlobalLimitedUsage(&limited_usage); | 331 GetGlobalLimitedUsage(&limited_usage); |
| 331 GetGlobalUsage(&total_usage, &unlimited_usage); | 332 GetGlobalUsage(&total_usage, &unlimited_usage); |
| 332 EXPECT_EQ(1 + 16, limited_usage); | 333 EXPECT_EQ(1 + 16, limited_usage); |
| 333 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); | 334 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); |
| 334 EXPECT_EQ(2 + 32, unlimited_usage); | 335 EXPECT_EQ(2 + 32, unlimited_usage); |
| 335 } | 336 } |
| 336 | 337 |
| 337 | 338 |
| 338 } // namespace content | 339 } // namespace content |
| OLD | NEW |