Chromium Code Reviews| 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 "content/browser/cache_storage/cache_storage_manager.h" | 5 #include "content/browser/cache_storage/cache_storage_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 if (!MemoryOnly()) | 105 if (!MemoryOnly()) |
| 106 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 106 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 107 | 107 |
| 108 CreateStorageManager(); | 108 CreateStorageManager(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void TearDown() override { DestroyStorageManager(); } | 111 void TearDown() override { DestroyStorageManager(); } |
| 112 | 112 |
| 113 virtual bool MemoryOnly() { return false; } | 113 virtual bool MemoryOnly() { return false; } |
| 114 | 114 |
| 115 virtual bool PadResources() const { return false; } | |
|
jkarlin
2017/06/09 15:26:20
This isn't used anywhere?
cmumford
2017/06/12 18:09:32
Not meaningfully, so I reverted it.
| |
| 116 | |
| 115 void BoolCallback(base::RunLoop* run_loop, bool value) { | 117 void BoolCallback(base::RunLoop* run_loop, bool value) { |
| 116 callback_bool_ = value; | 118 callback_bool_ = value; |
| 117 run_loop->Quit(); | 119 run_loop->Quit(); |
| 118 } | 120 } |
| 119 | 121 |
| 120 void BoolAndErrorCallback(base::RunLoop* run_loop, | 122 void BoolAndErrorCallback(base::RunLoop* run_loop, |
| 121 bool value, | 123 bool value, |
| 122 CacheStorageError error) { | 124 CacheStorageError error) { |
| 123 callback_bool_ = value; | 125 callback_bool_ = value; |
| 124 callback_error_ = error; | 126 callback_error_ = error; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 | 499 |
| 498 private: | 500 private: |
| 499 DISALLOW_COPY_AND_ASSIGN(CacheStorageManagerTest); | 501 DISALLOW_COPY_AND_ASSIGN(CacheStorageManagerTest); |
| 500 }; | 502 }; |
| 501 | 503 |
| 502 class CacheStorageManagerMemoryOnlyTest : public CacheStorageManagerTest { | 504 class CacheStorageManagerMemoryOnlyTest : public CacheStorageManagerTest { |
| 503 public: | 505 public: |
| 504 bool MemoryOnly() override { return true; } | 506 bool MemoryOnly() override { return true; } |
| 505 }; | 507 }; |
| 506 | 508 |
| 509 enum class CacheLocation { IN_MEMORY, ON_DISK }; | |
| 510 | |
| 511 enum class PadType { ADD_PADDING, NO_PADDING }; | |
| 512 | |
| 507 class CacheStorageManagerTestP : public CacheStorageManagerTest, | 513 class CacheStorageManagerTestP : public CacheStorageManagerTest, |
| 508 public testing::WithParamInterface<bool> { | 514 public testing::WithParamInterface< |
| 515 testing::tuple<CacheLocation, PadType>> { | |
| 509 public: | 516 public: |
| 510 bool MemoryOnly() override { return !GetParam(); } | 517 bool MemoryOnly() override { |
| 518 return testing::get<0>(GetParam()) == CacheLocation::IN_MEMORY; | |
| 519 } | |
| 520 | |
| 521 bool PadResources() const override { | |
| 522 return testing::get<1>(GetParam()) == PadType::ADD_PADDING; | |
| 523 } | |
| 511 }; | 524 }; |
| 512 | 525 |
| 513 TEST_F(CacheStorageManagerTest, TestsRunOnIOThread) { | 526 TEST_F(CacheStorageManagerTest, TestsRunOnIOThread) { |
| 514 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 527 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 515 } | 528 } |
| 516 | 529 |
| 517 TEST_P(CacheStorageManagerTestP, OpenCache) { | 530 TEST_P(CacheStorageManagerTestP, OpenCache) { |
| 518 EXPECT_TRUE(Open(origin1_, "foo")); | 531 EXPECT_TRUE(Open(origin1_, "foo")); |
| 519 } | 532 } |
| 520 | 533 |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1401 | 1414 |
| 1402 private: | 1415 private: |
| 1403 DISALLOW_COPY_AND_ASSIGN(CacheStorageQuotaClientTest); | 1416 DISALLOW_COPY_AND_ASSIGN(CacheStorageQuotaClientTest); |
| 1404 }; | 1417 }; |
| 1405 | 1418 |
| 1406 class CacheStorageQuotaClientDiskOnlyTest : public CacheStorageQuotaClientTest { | 1419 class CacheStorageQuotaClientDiskOnlyTest : public CacheStorageQuotaClientTest { |
| 1407 public: | 1420 public: |
| 1408 bool MemoryOnly() override { return false; } | 1421 bool MemoryOnly() override { return false; } |
| 1409 }; | 1422 }; |
| 1410 | 1423 |
| 1411 class CacheStorageQuotaClientTestP : public CacheStorageQuotaClientTest, | 1424 class CacheStorageQuotaClientTestP |
| 1412 public testing::WithParamInterface<bool> { | 1425 : public CacheStorageQuotaClientTest, |
| 1413 bool MemoryOnly() override { return !GetParam(); } | 1426 public testing::WithParamInterface< |
| 1427 testing::tuple<CacheLocation, PadType>> { | |
| 1428 bool MemoryOnly() override { | |
| 1429 return testing::get<0>(GetParam()) == CacheLocation::IN_MEMORY; | |
| 1430 } | |
| 1431 | |
| 1432 bool PadResources() const override { | |
| 1433 return testing::get<1>(GetParam()) == PadType::ADD_PADDING; | |
| 1434 } | |
| 1414 }; | 1435 }; |
| 1415 | 1436 |
| 1416 TEST_P(CacheStorageQuotaClientTestP, QuotaID) { | 1437 TEST_P(CacheStorageQuotaClientTestP, QuotaID) { |
| 1417 EXPECT_EQ(storage::QuotaClient::kServiceWorkerCache, quota_client_->id()); | 1438 EXPECT_EQ(storage::QuotaClient::kServiceWorkerCache, quota_client_->id()); |
| 1418 } | 1439 } |
| 1419 | 1440 |
| 1420 TEST_P(CacheStorageQuotaClientTestP, QuotaGetOriginUsage) { | 1441 TEST_P(CacheStorageQuotaClientTestP, QuotaGetOriginUsage) { |
| 1421 EXPECT_EQ(0, QuotaGetOriginUsage(origin1_)); | 1442 EXPECT_EQ(0, QuotaGetOriginUsage(origin1_)); |
| 1422 EXPECT_TRUE(Open(origin1_, "foo")); | 1443 EXPECT_TRUE(Open(origin1_, "foo")); |
| 1423 EXPECT_TRUE(CachePut(callback_cache_handle_->value(), | 1444 EXPECT_TRUE(CachePut(callback_cache_handle_->value(), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 } | 1514 } |
| 1494 | 1515 |
| 1495 TEST_P(CacheStorageQuotaClientTestP, QuotaDoesSupport) { | 1516 TEST_P(CacheStorageQuotaClientTestP, QuotaDoesSupport) { |
| 1496 EXPECT_TRUE(QuotaDoesSupport(storage::kStorageTypeTemporary)); | 1517 EXPECT_TRUE(QuotaDoesSupport(storage::kStorageTypeTemporary)); |
| 1497 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypePersistent)); | 1518 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypePersistent)); |
| 1498 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeSyncable)); | 1519 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeSyncable)); |
| 1499 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeQuotaNotManaged)); | 1520 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeQuotaNotManaged)); |
| 1500 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeUnknown)); | 1521 EXPECT_FALSE(QuotaDoesSupport(storage::kStorageTypeUnknown)); |
| 1501 } | 1522 } |
| 1502 | 1523 |
| 1503 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, | 1524 INSTANTIATE_TEST_CASE_P( |
| 1504 CacheStorageManagerTestP, | 1525 CacheStorageManagerTests, |
| 1505 ::testing::Values(false, true)); | 1526 CacheStorageManagerTestP, |
| 1527 ::testing::Combine( | |
| 1528 ::testing::Values(CacheLocation::IN_MEMORY, CacheLocation::ON_DISK), | |
| 1529 ::testing::Values(PadType::ADD_PADDING, PadType::NO_PADDING))); | |
| 1506 | 1530 |
| 1507 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, | 1531 INSTANTIATE_TEST_CASE_P( |
| 1508 CacheStorageQuotaClientTestP, | 1532 CacheStorageQuotaClientTests, |
| 1509 ::testing::Values(false, true)); | 1533 CacheStorageQuotaClientTestP, |
| 1534 ::testing::Combine( | |
| 1535 ::testing::Values(CacheLocation::IN_MEMORY, CacheLocation::ON_DISK), | |
| 1536 ::testing::Values(PadType::ADD_PADDING, PadType::NO_PADDING))); | |
| 1510 | 1537 |
| 1511 } // namespace content | 1538 } // namespace content |
| OLD | NEW |