OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/offline_pages/offline_page_metadata_store.h" | 5 #include "components/offline_pages/offline_page_metadata_store.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 CheckThatOfflinePageCanBeSaved(std::move(store)); | 441 CheckThatOfflinePageCanBeSaved(std::move(store)); |
442 } | 442 } |
443 | 443 |
444 // Adds metadata of an offline page into a store and then opens the store | 444 // Adds metadata of an offline page into a store and then opens the store |
445 // again to make sure that stored metadata survives store restarts. | 445 // again to make sure that stored metadata survives store restarts. |
446 TEST_F(OfflinePageMetadataStoreTest, AddOfflinePage) { | 446 TEST_F(OfflinePageMetadataStoreTest, AddOfflinePage) { |
447 CheckThatOfflinePageCanBeSaved(BuildStore()); | 447 CheckThatOfflinePageCanBeSaved(BuildStore()); |
448 } | 448 } |
449 | 449 |
| 450 TEST_F(OfflinePageMetadataStoreTest, AddSameOfflinePageTwice) { |
| 451 std::unique_ptr<OfflinePageMetadataStore> store(BuildStore()); |
| 452 |
| 453 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestClientId1, |
| 454 base::FilePath(kFilePath), kFileSize); |
| 455 offline_page.title = base::UTF8ToUTF16("a title"); |
| 456 base::Time expiration_time = base::Time::Now(); |
| 457 offline_page.expiration_time = expiration_time; |
| 458 |
| 459 store->AddOfflinePage(offline_page, |
| 460 base::Bind(&OfflinePageMetadataStoreTest::AddCallback, |
| 461 base::Unretained(this))); |
| 462 PumpLoop(); |
| 463 EXPECT_EQ(ADD, last_called_callback_); |
| 464 EXPECT_EQ(STATUS_TRUE, last_status_); |
| 465 ClearResults(); |
| 466 |
| 467 store->AddOfflinePage(offline_page, |
| 468 base::Bind(&OfflinePageMetadataStoreTest::AddCallback, |
| 469 base::Unretained(this))); |
| 470 PumpLoop(); |
| 471 EXPECT_EQ(ADD, last_called_callback_); |
| 472 EXPECT_EQ(STATUS_FALSE, last_status_); |
| 473 } |
| 474 |
450 // Tests removing offline page metadata from the store, for which it first adds | 475 // Tests removing offline page metadata from the store, for which it first adds |
451 // metadata of an offline page. | 476 // metadata of an offline page. |
452 TEST_F(OfflinePageMetadataStoreTest, RemoveOfflinePage) { | 477 TEST_F(OfflinePageMetadataStoreTest, RemoveOfflinePage) { |
453 std::unique_ptr<OfflinePageMetadataStore> store(BuildStore()); | 478 std::unique_ptr<OfflinePageMetadataStore> store(BuildStore()); |
454 | 479 |
455 // Add an offline page. | 480 // Add an offline page. |
456 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestClientId1, | 481 OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestClientId1, |
457 base::FilePath(kFilePath), kFileSize); | 482 base::FilePath(kFilePath), kFileSize); |
458 store->AddOfflinePage(offline_page, | 483 store->AddOfflinePage(offline_page, |
459 base::Bind(&OfflinePageMetadataStoreTest::AddCallback, | 484 base::Bind(&OfflinePageMetadataStoreTest::AddCallback, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 base::Unretained(this))); | 719 base::Unretained(this))); |
695 PumpLoop(); | 720 PumpLoop(); |
696 | 721 |
697 EXPECT_EQ(LOAD, last_called_callback_); | 722 EXPECT_EQ(LOAD, last_called_callback_); |
698 EXPECT_EQ(STATUS_TRUE, last_status_); | 723 EXPECT_EQ(STATUS_TRUE, last_status_); |
699 ASSERT_EQ(0U, offline_pages_.size()); | 724 ASSERT_EQ(0U, offline_pages_.size()); |
700 } | 725 } |
701 | 726 |
702 } // namespace | 727 } // namespace |
703 } // namespace offline_pages | 728 } // namespace offline_pages |
OLD | NEW |