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 <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/test/scoped_task_environment.h" |
17 #include "content/public/test/mock_storage_client.h" | 18 #include "content/public/test/mock_storage_client.h" |
18 #include "storage/browser/quota/quota_manager.h" | 19 #include "storage/browser/quota/quota_manager.h" |
19 #include "storage/browser/quota/quota_temporary_storage_evictor.h" | 20 #include "storage/browser/quota/quota_temporary_storage_evictor.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using storage::QuotaTemporaryStorageEvictor; | 23 using storage::QuotaTemporaryStorageEvictor; |
23 using storage::StorageType; | 24 using storage::StorageType; |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 203 } |
203 | 204 |
204 void disable_timer_for_testing() const { | 205 void disable_timer_for_testing() const { |
205 temporary_storage_evictor_->timer_disabled_for_testing_ = true; | 206 temporary_storage_evictor_->timer_disabled_for_testing_ = true; |
206 } | 207 } |
207 | 208 |
208 int num_get_usage_and_quota_for_eviction() const { | 209 int num_get_usage_and_quota_for_eviction() const { |
209 return num_get_usage_and_quota_for_eviction_; | 210 return num_get_usage_and_quota_for_eviction_; |
210 } | 211 } |
211 | 212 |
212 base::MessageLoop message_loop_; | 213 base::test::ScopedTaskEnvironment scoped_task_environment_; |
213 std::unique_ptr<MockQuotaEvictionHandler> quota_eviction_handler_; | 214 std::unique_ptr<MockQuotaEvictionHandler> quota_eviction_handler_; |
214 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; | 215 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; |
215 int num_get_usage_and_quota_for_eviction_; | 216 int num_get_usage_and_quota_for_eviction_; |
216 base::WeakPtrFactory<QuotaTemporaryStorageEvictorTest> weak_factory_; | 217 base::WeakPtrFactory<QuotaTemporaryStorageEvictorTest> weak_factory_; |
217 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictorTest); | 218 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictorTest); |
218 }; | 219 }; |
219 | 220 |
220 TEST_F(QuotaTemporaryStorageEvictorTest, SimpleEvictionTest) { | 221 TEST_F(QuotaTemporaryStorageEvictorTest, SimpleEvictionTest) { |
221 quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 3000); | 222 quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 3000); |
222 quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 200); | 223 quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 200); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage()); | 393 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage()); |
393 | 394 |
394 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin); | 395 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin); |
395 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota); | 396 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota); |
396 EXPECT_EQ(2, statistics().num_evicted_origins); | 397 EXPECT_EQ(2, statistics().num_evicted_origins); |
397 EXPECT_EQ(1, statistics().num_eviction_rounds); | 398 EXPECT_EQ(1, statistics().num_eviction_rounds); |
398 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds); // FIXME? | 399 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds); // FIXME? |
399 } | 400 } |
400 | 401 |
401 } // namespace content | 402 } // namespace content |
OLD | NEW |