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/remote/remote_suggestions_provider.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 728 |
729 const ContentSuggestion& suggestion = | 729 const ContentSuggestion& suggestion = |
730 observer().SuggestionsForCategory(articles_category()).front(); | 730 observer().SuggestionsForCategory(articles_category()).front(); |
731 | 731 |
732 EXPECT_EQ(MakeArticleID(kSnippetUrl), suggestion.id()); | 732 EXPECT_EQ(MakeArticleID(kSnippetUrl), suggestion.id()); |
733 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); | 733 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); |
734 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); | 734 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); |
735 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); | 735 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); |
736 EXPECT_EQ(kSnippetPublisherName, | 736 EXPECT_EQ(kSnippetPublisherName, |
737 base::UTF16ToUTF8(suggestion.publisher_name())); | 737 base::UTF16ToUTF8(suggestion.publisher_name())); |
738 EXPECT_EQ(GURL(kSnippetAmpUrl), suggestion.amp_url()); | |
739 } | 738 } |
740 | 739 |
741 TEST_F(RemoteSuggestionsProviderTest, CategoryTitle) { | 740 TEST_F(RemoteSuggestionsProviderTest, CategoryTitle) { |
742 const base::string16 test_default_title = | 741 const base::string16 test_default_title = |
743 base::UTF8ToUTF16(kTestJsonDefaultCategoryTitle); | 742 base::UTF8ToUTF16(kTestJsonDefaultCategoryTitle); |
744 | 743 |
745 // Don't send an initial response -- we want to test what happens without any | 744 // Don't send an initial response -- we want to test what happens without any |
746 // server status. | 745 // server status. |
747 auto service = MakeSnippetsService(/*set_empty_response=*/false); | 746 auto service = MakeSnippetsService(/*set_empty_response=*/false); |
748 | 747 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 797 |
799 { | 798 { |
800 const ContentSuggestion& suggestion = | 799 const ContentSuggestion& suggestion = |
801 observer().SuggestionsForCategory(articles_category()).front(); | 800 observer().SuggestionsForCategory(articles_category()).front(); |
802 EXPECT_EQ(MakeArticleID(std::string(kSnippetUrl) + "/0"), suggestion.id()); | 801 EXPECT_EQ(MakeArticleID(std::string(kSnippetUrl) + "/0"), suggestion.id()); |
803 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); | 802 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); |
804 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); | 803 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); |
805 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); | 804 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); |
806 EXPECT_EQ(kSnippetPublisherName, | 805 EXPECT_EQ(kSnippetPublisherName, |
807 base::UTF16ToUTF8(suggestion.publisher_name())); | 806 base::UTF16ToUTF8(suggestion.publisher_name())); |
808 EXPECT_EQ(GURL(kSnippetAmpUrl), suggestion.amp_url()); | |
809 } | 807 } |
810 | 808 |
811 { | 809 { |
812 const ContentSuggestion& suggestion = | 810 const ContentSuggestion& suggestion = |
813 observer().SuggestionsForCategory(other_category()).front(); | 811 observer().SuggestionsForCategory(other_category()).front(); |
814 EXPECT_EQ(MakeOtherID(std::string(kSnippetUrl) + "/1"), suggestion.id()); | 812 EXPECT_EQ(MakeOtherID(std::string(kSnippetUrl) + "/1"), suggestion.id()); |
815 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); | 813 EXPECT_EQ(kSnippetTitle, base::UTF16ToUTF8(suggestion.title())); |
816 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); | 814 EXPECT_EQ(kSnippetText, base::UTF16ToUTF8(suggestion.snippet_text())); |
817 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); | 815 EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); |
818 EXPECT_EQ(kSnippetPublisherName, | 816 EXPECT_EQ(kSnippetPublisherName, |
819 base::UTF16ToUTF8(suggestion.publisher_name())); | 817 base::UTF16ToUTF8(suggestion.publisher_name())); |
820 EXPECT_EQ(GURL(kSnippetAmpUrl), suggestion.amp_url()); | |
821 } | 818 } |
822 } | 819 } |
823 | 820 |
824 TEST_F(RemoteSuggestionsProviderTest, ArticleCategoryInfo) { | 821 TEST_F(RemoteSuggestionsProviderTest, ArticleCategoryInfo) { |
825 auto service = MakeSnippetsService(); | 822 auto service = MakeSnippetsService(); |
826 CategoryInfo article_info = service->GetCategoryInfo(articles_category()); | 823 CategoryInfo article_info = service->GetCategoryInfo(articles_category()); |
827 EXPECT_THAT(article_info.has_more_action(), Eq(true)); | 824 EXPECT_THAT(article_info.has_more_action(), Eq(true)); |
828 EXPECT_THAT(article_info.has_reload_action(), Eq(true)); | 825 EXPECT_THAT(article_info.has_reload_action(), Eq(true)); |
829 EXPECT_THAT(article_info.has_view_all_action(), Eq(false)); | 826 EXPECT_THAT(article_info.has_view_all_action(), Eq(false)); |
830 EXPECT_THAT(article_info.show_if_empty(), Eq(true)); | 827 EXPECT_THAT(article_info.show_if_empty(), Eq(true)); |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 service->FetchSnippetsInTheBackground(); | 1821 service->FetchSnippetsInTheBackground(); |
1825 base::RunLoop().RunUntilIdle(); | 1822 base::RunLoop().RunUntilIdle(); |
1826 EXPECT_EQ( | 1823 EXPECT_EQ( |
1827 simple_test_clock_ptr->Now().ToInternalValue(), | 1824 simple_test_clock_ptr->Now().ToInternalValue(), |
1828 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime)); | 1825 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime)); |
1829 // TODO(markusheintz): Add a test that simulates a browser restart once the | 1826 // TODO(markusheintz): Add a test that simulates a browser restart once the |
1830 // scheduler refactoring is done (crbug.com/672434). | 1827 // scheduler refactoring is done (crbug.com/672434). |
1831 } | 1828 } |
1832 | 1829 |
1833 } // namespace ntp_snippets | 1830 } // namespace ntp_snippets |
OLD | NEW |