| 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/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 EXPECT_EQ(snippet.best_source().publisher_name, kSnippetPublisherName); | 407 EXPECT_EQ(snippet.best_source().publisher_name, kSnippetPublisherName); |
| 408 EXPECT_EQ(snippet.best_source().amp_url, GURL(kSnippetAmpUrl)); | 408 EXPECT_EQ(snippet.best_source().amp_url, GURL(kSnippetAmpUrl)); |
| 409 } | 409 } |
| 410 | 410 |
| 411 TEST_F(NTPSnippetsServiceTest, Clear) { | 411 TEST_F(NTPSnippetsServiceTest, Clear) { |
| 412 std::string json_str(GetTestJson({GetSnippet()})); | 412 std::string json_str(GetTestJson({GetSnippet()})); |
| 413 | 413 |
| 414 LoadFromJSONString(json_str); | 414 LoadFromJSONString(json_str); |
| 415 EXPECT_THAT(service()->snippets(), SizeIs(1)); | 415 EXPECT_THAT(service()->snippets(), SizeIs(1)); |
| 416 | 416 |
| 417 service()->ClearSnippets(); | 417 service()->ClearCachedSuggestionsForDebugging(); |
| 418 EXPECT_THAT(service()->snippets(), IsEmpty()); | 418 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 419 } | 419 } |
| 420 | 420 |
| 421 TEST_F(NTPSnippetsServiceTest, InsertAtFront) { | 421 TEST_F(NTPSnippetsServiceTest, InsertAtFront) { |
| 422 std::string first("http://first"); | 422 std::string first("http://first"); |
| 423 LoadFromJSONString(GetTestJson({GetSnippetWithUrl(first)})); | 423 LoadFromJSONString(GetTestJson({GetSnippetWithUrl(first)})); |
| 424 EXPECT_THAT(service()->snippets(), ElementsAre(IdEq(first))); | 424 EXPECT_THAT(service()->snippets(), ElementsAre(IdEq(first))); |
| 425 | 425 |
| 426 std::string second("http://second"); | 426 std::string second("http://second"); |
| 427 LoadFromJSONString(GetTestJson({GetSnippetWithUrl(second)})); | 427 LoadFromJSONString(GetTestJson({GetSnippetWithUrl(second)})); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 publishers.push_back(std::string("Source 1")); | 492 publishers.push_back(std::string("Source 1")); |
| 493 amp_urls.push_back(std::string()); | 493 amp_urls.push_back(std::string()); |
| 494 std::string json_str( | 494 std::string json_str( |
| 495 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)})); | 495 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)})); |
| 496 | 496 |
| 497 LoadFromJSONString(json_str); | 497 LoadFromJSONString(json_str); |
| 498 | 498 |
| 499 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 499 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| 500 | 500 |
| 501 // Discarding a non-existent snippet shouldn't do anything. | 501 // Discarding a non-existent snippet shouldn't do anything. |
| 502 EXPECT_FALSE(service()->DiscardSnippet("http://othersite.com")); | 502 service()->DiscardSuggestion("http://othersite.com"); |
| 503 EXPECT_THAT(service()->snippets(), SizeIs(1)); | 503 EXPECT_THAT(service()->snippets(), SizeIs(1)); |
| 504 | 504 |
| 505 // Discard the snippet. | 505 // Discard the snippet. |
| 506 EXPECT_TRUE(service()->DiscardSnippet(kSnippetUrl)); | 506 service()->DiscardSuggestion(kSnippetUrl); |
| 507 EXPECT_THAT(service()->snippets(), IsEmpty()); | 507 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 508 | 508 |
| 509 // Make sure that fetching the same snippet again does not re-add it. | 509 // Make sure that fetching the same snippet again does not re-add it. |
| 510 LoadFromJSONString(json_str); | 510 LoadFromJSONString(json_str); |
| 511 EXPECT_THAT(service()->snippets(), IsEmpty()); | 511 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 512 | 512 |
| 513 // The snippet should stay discarded even after re-creating the service. | 513 // The snippet should stay discarded even after re-creating the service. |
| 514 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); | 514 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); |
| 515 CreateSnippetsService(/*enabled=*/true); | 515 CreateSnippetsService(/*enabled=*/true); |
| 516 LoadFromJSONString(json_str); | 516 LoadFromJSONString(json_str); |
| 517 EXPECT_THAT(service()->snippets(), IsEmpty()); | 517 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 518 | 518 |
| 519 // The snippet can be added again after clearing discarded snippets. | 519 // The snippet can be added again after clearing discarded snippets. |
| 520 service()->ClearDiscardedSnippets(); | 520 service()->ClearDiscardedSuggestionsForDebugging(); |
| 521 EXPECT_THAT(service()->snippets(), IsEmpty()); | 521 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 522 LoadFromJSONString(json_str); | 522 LoadFromJSONString(json_str); |
| 523 EXPECT_THAT(service()->snippets(), SizeIs(1)); | 523 EXPECT_THAT(service()->snippets(), SizeIs(1)); |
| 524 } | 524 } |
| 525 | 525 |
| 526 TEST_F(NTPSnippetsServiceTest, GetDiscarded) { | 526 TEST_F(NTPSnippetsServiceTest, GetDiscarded) { |
| 527 LoadFromJSONString(GetTestJson({GetSnippet()})); | 527 LoadFromJSONString(GetTestJson({GetSnippet()})); |
| 528 | 528 |
| 529 // For the test, we need the snippet to get discarded. | 529 service()->DiscardSuggestion(kSnippetUrl); |
| 530 ASSERT_TRUE(service()->DiscardSnippet(kSnippetUrl)); | |
| 531 const NTPSnippet::PtrVector& snippets = service()->discarded_snippets(); | 530 const NTPSnippet::PtrVector& snippets = service()->discarded_snippets(); |
| 532 EXPECT_EQ(1u, snippets.size()); | 531 EXPECT_EQ(1u, snippets.size()); |
| 533 for (auto& snippet : snippets) { | 532 for (auto& snippet : snippets) { |
| 534 EXPECT_EQ(kSnippetUrl, snippet->id()); | 533 EXPECT_EQ(kSnippetUrl, snippet->id()); |
| 535 } | 534 } |
| 536 | 535 |
| 537 // There should be no discarded snippet after clearing the list. | 536 // There should be no discarded snippet after clearing the list. |
| 538 service()->ClearDiscardedSnippets(); | 537 service()->ClearDiscardedSuggestionsForDebugging(); |
| 539 EXPECT_EQ(0u, service()->discarded_snippets().size()); | 538 EXPECT_EQ(0u, service()->discarded_snippets().size()); |
| 540 } | 539 } |
| 541 | 540 |
| 542 TEST_F(NTPSnippetsServiceTest, CreationTimestampParseFail) { | 541 TEST_F(NTPSnippetsServiceTest, CreationTimestampParseFail) { |
| 543 std::string json_str(GetTestJson({GetSnippetWithTimes( | 542 std::string json_str(GetTestJson({GetSnippetWithTimes( |
| 544 "aaa1448459205", | 543 "aaa1448459205", |
| 545 NTPSnippet::TimeToJsonString(GetDefaultExpirationTime()))})); | 544 NTPSnippet::TimeToJsonString(GetDefaultExpirationTime()))})); |
| 546 | 545 |
| 547 LoadFromJSONString(json_str); | 546 LoadFromJSONString(json_str); |
| 548 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 547 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 640 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| 642 { | 641 { |
| 643 const NTPSnippet& snippet = *service()->snippets().front(); | 642 const NTPSnippet& snippet = *service()->snippets().front(); |
| 644 EXPECT_EQ(snippet.sources().size(), 2u); | 643 EXPECT_EQ(snippet.sources().size(), 2u); |
| 645 EXPECT_EQ(snippet.id(), kSnippetUrl); | 644 EXPECT_EQ(snippet.id(), kSnippetUrl); |
| 646 EXPECT_EQ(snippet.best_source().url, GURL("http://source2.com")); | 645 EXPECT_EQ(snippet.best_source().url, GURL("http://source2.com")); |
| 647 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 2")); | 646 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 2")); |
| 648 EXPECT_EQ(snippet.best_source().amp_url, GURL()); | 647 EXPECT_EQ(snippet.best_source().amp_url, GURL()); |
| 649 } | 648 } |
| 650 | 649 |
| 651 service()->ClearSnippets(); | 650 service()->ClearCachedSuggestionsForDebugging(); |
| 652 // Set Source 1 to have no AMP url, and Source 2 to have no publisher name | 651 // Set Source 1 to have no AMP url, and Source 2 to have no publisher name |
| 653 // Source 1 should win in this case since we prefer publisher name to AMP url | 652 // Source 1 should win in this case since we prefer publisher name to AMP url |
| 654 source_urls.clear(); | 653 source_urls.clear(); |
| 655 source_urls.push_back(std::string("http://source1.com")); | 654 source_urls.push_back(std::string("http://source1.com")); |
| 656 source_urls.push_back(std::string("http://source2.com")); | 655 source_urls.push_back(std::string("http://source2.com")); |
| 657 publishers.clear(); | 656 publishers.clear(); |
| 658 publishers.push_back(std::string("Source 1")); | 657 publishers.push_back(std::string("Source 1")); |
| 659 publishers.push_back(std::string()); | 658 publishers.push_back(std::string()); |
| 660 amp_urls.clear(); | 659 amp_urls.clear(); |
| 661 amp_urls.push_back(std::string()); | 660 amp_urls.push_back(std::string()); |
| 662 amp_urls.push_back(std::string("http://source2.amp.com")); | 661 amp_urls.push_back(std::string("http://source2.amp.com")); |
| 663 json_str = | 662 json_str = |
| 664 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)}); | 663 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)}); |
| 665 | 664 |
| 666 LoadFromJSONString(json_str); | 665 LoadFromJSONString(json_str); |
| 667 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 666 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| 668 { | 667 { |
| 669 const NTPSnippet& snippet = *service()->snippets().front(); | 668 const NTPSnippet& snippet = *service()->snippets().front(); |
| 670 EXPECT_EQ(snippet.sources().size(), 2u); | 669 EXPECT_EQ(snippet.sources().size(), 2u); |
| 671 EXPECT_EQ(snippet.id(), kSnippetUrl); | 670 EXPECT_EQ(snippet.id(), kSnippetUrl); |
| 672 EXPECT_EQ(snippet.best_source().url, GURL("http://source1.com")); | 671 EXPECT_EQ(snippet.best_source().url, GURL("http://source1.com")); |
| 673 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 1")); | 672 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 1")); |
| 674 EXPECT_EQ(snippet.best_source().amp_url, GURL()); | 673 EXPECT_EQ(snippet.best_source().amp_url, GURL()); |
| 675 } | 674 } |
| 676 | 675 |
| 677 service()->ClearSnippets(); | 676 service()->ClearCachedSuggestionsForDebugging(); |
| 678 // Set source 1 to have no AMP url and no source, and source 2 to only have | 677 // Set source 1 to have no AMP url and no source, and source 2 to only have |
| 679 // amp url. There should be no snippets since we only add sources we consider | 678 // amp url. There should be no snippets since we only add sources we consider |
| 680 // complete | 679 // complete |
| 681 source_urls.clear(); | 680 source_urls.clear(); |
| 682 source_urls.push_back(std::string("http://source1.com")); | 681 source_urls.push_back(std::string("http://source1.com")); |
| 683 source_urls.push_back(std::string("http://source2.com")); | 682 source_urls.push_back(std::string("http://source2.com")); |
| 684 publishers.clear(); | 683 publishers.clear(); |
| 685 publishers.push_back(std::string()); | 684 publishers.push_back(std::string()); |
| 686 publishers.push_back(std::string()); | 685 publishers.push_back(std::string()); |
| 687 amp_urls.clear(); | 686 amp_urls.clear(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 714 { | 713 { |
| 715 const NTPSnippet& snippet = *service()->snippets().front(); | 714 const NTPSnippet& snippet = *service()->snippets().front(); |
| 716 EXPECT_EQ(snippet.sources().size(), 3u); | 715 EXPECT_EQ(snippet.sources().size(), 3u); |
| 717 EXPECT_EQ(snippet.id(), kSnippetUrl); | 716 EXPECT_EQ(snippet.id(), kSnippetUrl); |
| 718 EXPECT_EQ(snippet.best_source().url, GURL("http://source1.com")); | 717 EXPECT_EQ(snippet.best_source().url, GURL("http://source1.com")); |
| 719 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 1")); | 718 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 1")); |
| 720 EXPECT_EQ(snippet.best_source().amp_url, GURL("http://source1.amp.com")); | 719 EXPECT_EQ(snippet.best_source().amp_url, GURL("http://source1.amp.com")); |
| 721 } | 720 } |
| 722 | 721 |
| 723 // Test 2 complete sources, we should choose the first complete source | 722 // Test 2 complete sources, we should choose the first complete source |
| 724 service()->ClearSnippets(); | 723 service()->ClearCachedSuggestionsForDebugging(); |
| 725 source_urls.clear(); | 724 source_urls.clear(); |
| 726 source_urls.push_back(std::string("http://source1.com")); | 725 source_urls.push_back(std::string("http://source1.com")); |
| 727 source_urls.push_back(std::string("http://source2.com")); | 726 source_urls.push_back(std::string("http://source2.com")); |
| 728 source_urls.push_back(std::string("http://source3.com")); | 727 source_urls.push_back(std::string("http://source3.com")); |
| 729 publishers.clear(); | 728 publishers.clear(); |
| 730 publishers.push_back(std::string()); | 729 publishers.push_back(std::string()); |
| 731 publishers.push_back(std::string("Source 2")); | 730 publishers.push_back(std::string("Source 2")); |
| 732 publishers.push_back(std::string("Source 3")); | 731 publishers.push_back(std::string("Source 3")); |
| 733 amp_urls.clear(); | 732 amp_urls.clear(); |
| 734 amp_urls.push_back(std::string("http://source1.amp.com")); | 733 amp_urls.push_back(std::string("http://source1.amp.com")); |
| 735 amp_urls.push_back(std::string("http://source2.amp.com")); | 734 amp_urls.push_back(std::string("http://source2.amp.com")); |
| 736 amp_urls.push_back(std::string("http://source3.amp.com")); | 735 amp_urls.push_back(std::string("http://source3.amp.com")); |
| 737 json_str = | 736 json_str = |
| 738 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)}); | 737 GetTestJson({GetSnippetWithSources(source_urls, publishers, amp_urls)}); |
| 739 | 738 |
| 740 LoadFromJSONString(json_str); | 739 LoadFromJSONString(json_str); |
| 741 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 740 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| 742 { | 741 { |
| 743 const NTPSnippet& snippet = *service()->snippets().front(); | 742 const NTPSnippet& snippet = *service()->snippets().front(); |
| 744 EXPECT_EQ(snippet.sources().size(), 3u); | 743 EXPECT_EQ(snippet.sources().size(), 3u); |
| 745 EXPECT_EQ(snippet.id(), kSnippetUrl); | 744 EXPECT_EQ(snippet.id(), kSnippetUrl); |
| 746 EXPECT_EQ(snippet.best_source().url, GURL("http://source2.com")); | 745 EXPECT_EQ(snippet.best_source().url, GURL("http://source2.com")); |
| 747 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 2")); | 746 EXPECT_EQ(snippet.best_source().publisher_name, std::string("Source 2")); |
| 748 EXPECT_EQ(snippet.best_source().amp_url, GURL("http://source2.amp.com")); | 747 EXPECT_EQ(snippet.best_source().amp_url, GURL("http://source2.amp.com")); |
| 749 } | 748 } |
| 750 | 749 |
| 751 // Test 3 complete sources, we should choose the first complete source | 750 // Test 3 complete sources, we should choose the first complete source |
| 752 service()->ClearSnippets(); | 751 service()->ClearCachedSuggestionsForDebugging(); |
| 753 source_urls.clear(); | 752 source_urls.clear(); |
| 754 source_urls.push_back(std::string("http://source1.com")); | 753 source_urls.push_back(std::string("http://source1.com")); |
| 755 source_urls.push_back(std::string("http://source2.com")); | 754 source_urls.push_back(std::string("http://source2.com")); |
| 756 source_urls.push_back(std::string("http://source3.com")); | 755 source_urls.push_back(std::string("http://source3.com")); |
| 757 publishers.clear(); | 756 publishers.clear(); |
| 758 publishers.push_back(std::string("Source 1")); | 757 publishers.push_back(std::string("Source 1")); |
| 759 publishers.push_back(std::string("Source 2")); | 758 publishers.push_back(std::string("Source 2")); |
| 760 publishers.push_back(std::string("Source 3")); | 759 publishers.push_back(std::string("Source 3")); |
| 761 amp_urls.clear(); | 760 amp_urls.clear(); |
| 762 amp_urls.push_back(std::string()); | 761 amp_urls.push_back(std::string()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 ElementsAre(base::Bucket(/*min=*/0, /*count=*/2), | 805 ElementsAre(base::Bucket(/*min=*/0, /*count=*/2), |
| 807 base::Bucket(/*min=*/1, /*count=*/2))); | 806 base::Bucket(/*min=*/1, /*count=*/2))); |
| 808 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticlesFetched"), | 807 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticlesFetched"), |
| 809 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1), | 808 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1), |
| 810 base::Bucket(/*min=*/1, /*count=*/2))); | 809 base::Bucket(/*min=*/1, /*count=*/2))); |
| 811 EXPECT_THAT( | 810 EXPECT_THAT( |
| 812 tester.GetAllSamples("NewTabPage.Snippets.NumArticlesZeroDueToDiscarded"), | 811 tester.GetAllSamples("NewTabPage.Snippets.NumArticlesZeroDueToDiscarded"), |
| 813 IsEmpty()); | 812 IsEmpty()); |
| 814 // Discarding a snippet should decrease the list size. This will only be | 813 // Discarding a snippet should decrease the list size. This will only be |
| 815 // logged after the next fetch. | 814 // logged after the next fetch. |
| 816 EXPECT_TRUE(service()->DiscardSnippet(kSnippetUrl)); | 815 service()->DiscardSuggestion(kSnippetUrl); |
| 817 LoadFromJSONString(GetTestJson({GetSnippet()})); | 816 LoadFromJSONString(GetTestJson({GetSnippet()})); |
| 818 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticles"), | 817 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticles"), |
| 819 ElementsAre(base::Bucket(/*min=*/0, /*count=*/3), | 818 ElementsAre(base::Bucket(/*min=*/0, /*count=*/3), |
| 820 base::Bucket(/*min=*/1, /*count=*/2))); | 819 base::Bucket(/*min=*/1, /*count=*/2))); |
| 821 // Discarded snippets shouldn't influence NumArticlesFetched. | 820 // Discarded snippets shouldn't influence NumArticlesFetched. |
| 822 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticlesFetched"), | 821 EXPECT_THAT(tester.GetAllSamples("NewTabPage.Snippets.NumArticlesFetched"), |
| 823 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1), | 822 ElementsAre(base::Bucket(/*min=*/0, /*count=*/1), |
| 824 base::Bucket(/*min=*/1, /*count=*/3))); | 823 base::Bucket(/*min=*/1, /*count=*/3))); |
| 825 EXPECT_THAT( | 824 EXPECT_THAT( |
| 826 tester.GetAllSamples("NewTabPage.Snippets.NumArticlesZeroDueToDiscarded"), | 825 tester.GetAllSamples("NewTabPage.Snippets.NumArticlesZeroDueToDiscarded"), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 845 const std::vector<std::string> amp_urls = { | 844 const std::vector<std::string> amp_urls = { |
| 846 "http://mashable-amphtml.googleusercontent.com/1", | 845 "http://mashable-amphtml.googleusercontent.com/1", |
| 847 "http://t2.gstatic.com/images?q=tbn:3", | 846 "http://t2.gstatic.com/images?q=tbn:3", |
| 848 "http://t2.gstatic.com/images?q=tbn:3"}; | 847 "http://t2.gstatic.com/images?q=tbn:3"}; |
| 849 | 848 |
| 850 // Add the snippet from the mashable domain. | 849 // Add the snippet from the mashable domain. |
| 851 LoadFromJSONString(GetTestJson({GetSnippetWithUrlAndTimesAndSources( | 850 LoadFromJSONString(GetTestJson({GetSnippetWithUrlAndTimesAndSources( |
| 852 source_urls[0], creation, expiry, source_urls, publishers, amp_urls)})); | 851 source_urls[0], creation, expiry, source_urls, publishers, amp_urls)})); |
| 853 ASSERT_THAT(service()->snippets(), SizeIs(1)); | 852 ASSERT_THAT(service()->snippets(), SizeIs(1)); |
| 854 // Discard the snippet via the mashable source corpus ID. | 853 // Discard the snippet via the mashable source corpus ID. |
| 855 EXPECT_TRUE(service()->DiscardSnippet(source_urls[0])); | 854 service()->DiscardSuggestion(source_urls[0]); |
| 856 EXPECT_THAT(service()->snippets(), IsEmpty()); | 855 EXPECT_THAT(service()->snippets(), IsEmpty()); |
| 857 | 856 |
| 858 // The same article from the AOL domain should now be detected as discarded. | 857 // The same article from the AOL domain should now be detected as discarded. |
| 859 LoadFromJSONString(GetTestJson({GetSnippetWithUrlAndTimesAndSources( | 858 LoadFromJSONString(GetTestJson({GetSnippetWithUrlAndTimesAndSources( |
| 860 source_urls[1], creation, expiry, source_urls, publishers, amp_urls)})); | 859 source_urls[1], creation, expiry, source_urls, publishers, amp_urls)})); |
| 861 ASSERT_THAT(service()->snippets(), IsEmpty()); | 860 ASSERT_THAT(service()->snippets(), IsEmpty()); |
| 862 } | 861 } |
| 863 | 862 |
| 864 TEST_F(NTPSnippetsServiceTest, HistorySyncStateChanges) { | 863 TEST_F(NTPSnippetsServiceTest, HistorySyncStateChanges) { |
| 865 MockServiceObserver mock_observer; | 864 MockServiceObserver mock_observer; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 881 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); | 880 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); |
| 882 service()->UpdateStateForStatus(DisabledReason::NONE); | 881 service()->UpdateStateForStatus(DisabledReason::NONE); |
| 883 base::RunLoop().RunUntilIdle(); | 882 base::RunLoop().RunUntilIdle(); |
| 884 EXPECT_EQ(NTPSnippetsService::State::READY, service()->state_); | 883 EXPECT_EQ(NTPSnippetsService::State::READY, service()->state_); |
| 885 EXPECT_FALSE(service()->snippets().empty()); | 884 EXPECT_FALSE(service()->snippets().empty()); |
| 886 | 885 |
| 887 service()->RemoveObserver(&mock_observer); | 886 service()->RemoveObserver(&mock_observer); |
| 888 } | 887 } |
| 889 | 888 |
| 890 } // namespace ntp_snippets | 889 } // namespace ntp_snippets |
| OLD | NEW |