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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_service_unittest.cc

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: Rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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/ntp_snippets_service.h" 5 #include "components/ntp_snippets/remote/ntp_snippets_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 scoped_refptr<base::SingleThreadTaskRunner> task_runner( 399 scoped_refptr<base::SingleThreadTaskRunner> task_runner(
400 base::ThreadTaskRunnerHandle::Get()); 400 base::ThreadTaskRunnerHandle::Get());
401 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter = 401 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter =
402 new net::TestURLRequestContextGetter(task_runner.get()); 402 new net::TestURLRequestContextGetter(task_runner.get());
403 403
404 utils_.ResetSigninManager(); 404 utils_.ResetSigninManager();
405 std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher = 405 std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher =
406 base::MakeUnique<NTPSnippetsFetcher>( 406 base::MakeUnique<NTPSnippetsFetcher>(
407 utils_.fake_signin_manager(), fake_token_service_.get(), 407 utils_.fake_signin_manager(), fake_token_service_.get(),
408 std::move(request_context_getter), utils_.pref_service(), 408 std::move(request_context_getter), utils_.pref_service(),
409 &category_factory_, base::Bind(&ParseJson), kAPIKey); 409 &category_factory_, base::Bind(&ParseJson), kAPIKey,
410 &user_classifier_);
410 411
411 utils_.fake_signin_manager()->SignIn("foo@bar.com"); 412 utils_.fake_signin_manager()->SignIn("foo@bar.com");
412 snippets_fetcher->SetPersonalizationForTesting( 413 snippets_fetcher->SetPersonalizationForTesting(
413 NTPSnippetsFetcher::Personalization::kNonPersonal); 414 NTPSnippetsFetcher::Personalization::kNonPersonal);
414 415
415 auto image_fetcher = base::MakeUnique<NiceMock<MockImageFetcher>>(); 416 auto image_fetcher = base::MakeUnique<NiceMock<MockImageFetcher>>();
416 417
417 image_fetcher_ = image_fetcher.get(); 418 image_fetcher_ = image_fetcher.get();
418 EXPECT_CALL(*image_fetcher, SetImageFetcherDelegate(_)); 419 EXPECT_CALL(*image_fetcher, SetImageFetcherDelegate(_));
419 auto image_decoder = base::MakeUnique<FakeImageDecoder>(); 420 auto image_decoder = base::MakeUnique<FakeImageDecoder>();
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 base::StringPrintf("http://localhost/snippet-id-%d", i))); 1182 base::StringPrintf("http://localhost/snippet-id-%d", i)));
1182 } 1183 }
1183 LoadFromJSONString(service.get(), GetTestJson(suggestions)); 1184 LoadFromJSONString(service.get(), GetTestJson(suggestions));
1184 // TODO(tschumann): We should probably trim out any additional results and 1185 // TODO(tschumann): We should probably trim out any additional results and
1185 // only serve the MaxSnippetCount items. 1186 // only serve the MaxSnippetCount items.
1186 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), 1187 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()),
1187 SizeIs(service->GetMaxSnippetCountForTesting() + 1)); 1188 SizeIs(service->GetMaxSnippetCountForTesting() + 1));
1188 } 1189 }
1189 1190
1190 } // namespace ntp_snippets 1191 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698