Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher_unittest.cc

Issue 2279483002: Allow category["suggestions"] to be absent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc b/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
index de2e1ccd3bf94f7e2f2fecab6c5213ee85228574..277f5391edccb561be4199fa1611a817c8573616 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
@@ -426,6 +426,29 @@ TEST_F(NTPSnippetsContentSuggestionsFetcherTest, ShouldFetchSuccessfully) {
/*count=*/1)));
}
+TEST_F(NTPSnippetsContentSuggestionsFetcherTest, EmptyCategoryIsOK) {
+ const std::string kJsonStr =
+ "{\"categories\" : [{"
+ " \"id\": 1,"
+ " \"localizedTitle\": \"Articles for You\""
+ "}]}";
+ SetFakeResponse(/*data=*/kJsonStr, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+ EXPECT_CALL(mock_callback(), Run(IsEmptyArticleList()));
+ snippets_fetcher().FetchSnippetsFromHosts(test_hosts(), test_lang(),
+ /*count=*/1,
+ /*interactive_request=*/true);
+ FastForwardUntilNoTasksRemain();
+ EXPECT_THAT(snippets_fetcher().last_status(), Eq("OK"));
+ EXPECT_THAT(snippets_fetcher().last_json(), Eq(kJsonStr));
+ EXPECT_THAT(histogram_tester().GetAllSamples(
+ "NewTabPage.Snippets.FetchHttpResponseOrErrorCode"),
+ ElementsAre(base::Bucket(/*min=*/200, /*count=*/1)));
+ EXPECT_THAT(histogram_tester().GetAllSamples("NewTabPage.Snippets.FetchTime"),
+ ElementsAre(base::Bucket(/*min=*/kTestJsonParsingLatencyMs,
+ /*count=*/1)));
+}
+
TEST_F(NTPSnippetsContentSuggestionsFetcherTest, ServerCategories) {
const std::string kJsonStr =
"{\"categories\" : [{"
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698