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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc

Issue 2485933003: Fixes an invalidated pointer access in NTPSnipppetsFetcher. (Closed)
Patch Set: adressed other comments from https://codereview.chromium.org/2473483006/ Created 4 years, 1 month 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
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 7ab373ea72bb673eefd54d6e766f05f7886a361a..350f8cac8e1d7340af12e545195d5d5eeb8e49cd 100644
--- a/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
@@ -684,6 +684,21 @@ TEST_F(NTPSnippetsContentSuggestionsFetcherTest, ExclusiveCategoryOnly) {
" \"ampUrl\" : \"http://localhost/amp\","
" \"faviconUrl\" : \"http://localhost/favicon.ico\" "
" }]"
+ "}, {"
+ " \"id\": 3,"
+ " \"localizedTitle\": \"Articles for Anybody\","
+ " \"suggestions\" : [{"
+ " \"ids\" : [\"http://localhost/foo3\"],"
+ " \"title\" : \"Foo Barred from Baz\","
+ " \"snippet\" : \"...\","
+ " \"fullPageUrl\" : \"http://localhost/foo3\","
+ " \"creationTime\" : \"2016-06-30T11:01:37.000Z\","
+ " \"expirationTime\" : \"2016-07-01T11:01:37.000Z\","
+ " \"attribution\" : \"Foo News\","
+ " \"imageUrl\" : \"http://localhost/foo3.jpg\","
+ " \"ampUrl\" : \"http://localhost/amp\","
+ " \"faviconUrl\" : \"http://localhost/favicon.ico\" "
+ " }]"
"}]}";
SetFakeResponse(/*response_data=*/kJsonStr, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
@@ -693,7 +708,7 @@ TEST_F(NTPSnippetsContentSuggestionsFetcherTest, ExclusiveCategoryOnly) {
NTPSnippetsFetcher::Params params = test_params();
params.exclusive_category = base::Optional<Category>(
- CategoryFactory().FromKnownCategory(KnownCategories::ARTICLES));
+ CategoryFactory().FromRemoteCategory(2));
snippets_fetcher().FetchSnippets(
params, ToSnippetsAvailableCallback(&mock_callback()));
FastForwardUntilNoTasksRemain();
@@ -702,10 +717,10 @@ TEST_F(NTPSnippetsContentSuggestionsFetcherTest, ExclusiveCategoryOnly) {
ASSERT_THAT(fetched_categories->size(), Eq(1u));
const auto& category = (*fetched_categories)[0];
EXPECT_THAT(category.category.id(),
- Eq(static_cast<int>(KnownCategories::ARTICLES)));
+ Eq(CategoryFactory().FromRemoteCategory(2).id()));
ASSERT_THAT(category.snippets.size(), Eq(1u));
EXPECT_THAT(category.snippets[0]->best_source().url.spec(),
- Eq("http://localhost/foobar"));
+ Eq("http://localhost/foo2"));
}
TEST_F(NTPSnippetsFetcherTest, ShouldFetchSuccessfullyEmptyList) {
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_fetcher.cc ('k') | components/ntp_snippets/remote/ntp_snippets_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698