| Index: components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
|
| diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc b/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
|
| index 5d889af37e17ef983cb1e042599f5c3ef8b7ea5c..0ebd3158cd281387d07bcdcd95cf846e3f33aacf 100644
|
| --- a/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
|
| +++ b/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
|
| @@ -164,8 +164,8 @@ class NTPSnippetsFetcherTest : public testing::Test {
|
| fake_signin_manager_.get(), fake_token_service_.get(),
|
| scoped_refptr<net::TestURLRequestContextGetter>(
|
| new net::TestURLRequestContextGetter(mock_task_runner_.get())),
|
| - pref_service_.get(), &category_factory_, base::Bind(&ParseJsonDelayed),
|
| - kAPIKey);
|
| + pref_service_.get(), &category_factory_, nullptr,
|
| + base::Bind(&ParseJsonDelayed), kAPIKey);
|
|
|
| snippets_fetcher_->SetCallback(
|
| base::Bind(&MockSnippetsAvailableCallback::WrappedRun,
|
| @@ -308,7 +308,6 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestUnauthenticated) {
|
| params.excluded_ids = {};
|
| params.interactive_request = true;
|
|
|
| -
|
| params.fetch_api = NTPSnippetsFetcher::CHROME_READER_API;
|
| EXPECT_THAT(params.BuildRequest(),
|
| EqualsJSON("{"
|
| @@ -392,6 +391,80 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestExcludedIds) {
|
| "}"));
|
| }
|
|
|
| +TEST_F(NTPSnippetsFetcherTest, BuildRequestWithTwoLanguages) {
|
| + NTPSnippetsFetcher::RequestParams params;
|
| + params.only_return_personalized_results = false;
|
| + params.host_restricts = {};
|
| + params.count_to_fetch = 10;
|
| + params.interactive_request = true;
|
| + params.ui_language.language_code = "en";
|
| + params.ui_language.frequency = 0.5f;
|
| + params.other_top_language.language_code = "de";
|
| + params.other_top_language.frequency = 0.5f;
|
| +
|
| + params.fetch_api = NTPSnippetsFetcher::CHROME_CONTENT_SUGGESTIONS_API;
|
| + EXPECT_THAT(params.BuildRequest(),
|
| + EqualsJSON("{"
|
| + " \"regularlyVisitedHostNames\": [],"
|
| + " \"priority\": \"USER_ACTION\","
|
| + " \"excludedSuggestionIds\": [],"
|
| + " \"top_languages\": ["
|
| + " {"
|
| + " \"language\" : \"en\","
|
| + " \"frequency\" : 0.5"
|
| + " },"
|
| + " {"
|
| + " \"language\" : \"de\","
|
| + " \"frequency\" : 0.5"
|
| + " }"
|
| + " ]"
|
| + "}"));
|
| +}
|
| +
|
| +TEST_F(NTPSnippetsFetcherTest, BuildRequestWithUILanguageOnly) {
|
| + NTPSnippetsFetcher::RequestParams params;
|
| + params.only_return_personalized_results = false;
|
| + params.host_restricts = {};
|
| + params.count_to_fetch = 10;
|
| + params.interactive_request = true;
|
| + params.ui_language.language_code = "en";
|
| + params.ui_language.frequency = 0.5f;
|
| +
|
| + params.fetch_api = NTPSnippetsFetcher::CHROME_CONTENT_SUGGESTIONS_API;
|
| + EXPECT_THAT(params.BuildRequest(),
|
| + EqualsJSON("{"
|
| + " \"regularlyVisitedHostNames\": [],"
|
| + " \"priority\": \"USER_ACTION\","
|
| + " \"excludedSuggestionIds\": [],"
|
| + " \"top_languages\": [{"
|
| + " \"language\" : \"en\","
|
| + " \"frequency\" : 0.5"
|
| + " }]"
|
| + "}"));
|
| +}
|
| +
|
| +TEST_F(NTPSnippetsFetcherTest, BuildRequestWithOtherLanguageOnly) {
|
| + NTPSnippetsFetcher::RequestParams params;
|
| + params.only_return_personalized_results = false;
|
| + params.host_restricts = {};
|
| + params.count_to_fetch = 10;
|
| + params.interactive_request = true;
|
| + params.other_top_language.language_code = "de";
|
| + params.other_top_language.frequency = 0.5f;
|
| +
|
| + params.fetch_api = NTPSnippetsFetcher::CHROME_CONTENT_SUGGESTIONS_API;
|
| + EXPECT_THAT(params.BuildRequest(),
|
| + EqualsJSON("{"
|
| + " \"regularlyVisitedHostNames\": [],"
|
| + " \"priority\": \"USER_ACTION\","
|
| + " \"excludedSuggestionIds\": [],"
|
| + " \"top_languages\": [{"
|
| + " \"language\" : \"de\","
|
| + " \"frequency\" : 0.5"
|
| + " }]"
|
| + "}"));
|
| +}
|
| +
|
| TEST_F(NTPSnippetsFetcherTest, ShouldNotFetchOnCreation) {
|
| // The lack of registered baked in responses would cause any fetch to fail.
|
| FastForwardUntilNoTasksRemain();
|
|
|