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

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

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: A minor fix 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 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 b5934c737c3d681af283c271baeb5093f0603bce..7308c72b4ab6d3108e6b8a7c0d56be7ccb144c0c 100644
--- a/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc
@@ -18,6 +18,7 @@
#include "components/ntp_snippets/category_factory.h"
#include "components/ntp_snippets/ntp_snippets_constants.h"
#include "components/ntp_snippets/remote/ntp_snippet.h"
+#include "components/ntp_snippets/user_classifier.h"
#include "components/prefs/testing_pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
@@ -156,16 +157,18 @@ class NTPSnippetsFetcherTest : public testing::Test {
account_tracker_.get())),
fake_token_service_(new FakeProfileOAuth2TokenService()),
pref_service_(new TestingPrefServiceSimple()),
+ user_classifier_(nullptr /* pref_service_ */),
Marc Treib 2016/10/06 14:54:37 Any reason for not passing in a pref service?
jkrcal 2016/10/06 15:18:41 Done.
test_lang_("en-US"),
test_url_(gurl) {
RequestThrottler::RegisterProfilePrefs(pref_service_->registry());
+ UserClassifier::RegisterProfilePrefs(pref_service_->registry());
snippets_fetcher_ = base::MakeUnique<NTPSnippetsFetcher>(
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);
+ kAPIKey, &user_classifier_);
snippets_fetcher_->SetCallback(
base::Bind(&MockSnippetsAvailableCallback::WrappedRun,
@@ -219,6 +222,7 @@ class NTPSnippetsFetcherTest : public testing::Test {
std::unique_ptr<OAuth2TokenService> fake_token_service_;
std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher_;
std::unique_ptr<TestingPrefServiceSimple> pref_service_;
+ UserClassifier user_classifier_;
CategoryFactory category_factory_;
MockSnippetsAvailableCallback mock_callback_;
const std::string test_lang_;
@@ -254,6 +258,7 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestAuthenticated) {
params.excluded_ids = {"1234567890"};
params.count_to_fetch = 25;
params.interactive_request = false;
+ params.user_class = "ACTIVE_NTP_USER";
params.fetch_api = NTPSnippetsFetcher::CHROME_READER_API;
EXPECT_THAT(params.BuildRequest(),
@@ -304,7 +309,8 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestAuthenticated) {
" ],"
" \"excludedSuggestionIds\": ["
" \"1234567890\""
- " ]"
+ " ],"
+ " \"user_activeness_class\": \"ACTIVE_NTP_USER\""
"}"));
}
@@ -315,6 +321,7 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestUnauthenticated) {
params.count_to_fetch = 10;
params.excluded_ids = {};
params.interactive_request = true;
+ params.user_class = "ACTIVE_NTP_USER";
params.fetch_api = NTPSnippetsFetcher::CHROME_READER_API;
@@ -354,7 +361,8 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestUnauthenticated) {
EqualsJSON("{"
" \"regularlyVisitedHostNames\": [],"
" \"priority\": \"USER_ACTION\","
- " \"excludedSuggestionIds\": []"
+ " \"excludedSuggestionIds\": [],"
+ " \"user_activeness_class\": \"ACTIVE_NTP_USER\""
"}"));
}
@@ -367,6 +375,7 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestExcludedIds) {
for (int i = 0; i < 200; ++i) {
params.excluded_ids.insert(base::StringPrintf("%03d", i));
}
+ params.user_class = "ACTIVE_NTP_USER";
params.fetch_api = NTPSnippetsFetcher::CHROME_CONTENT_SUGGESTIONS_API;
EXPECT_THAT(params.BuildRequest(),
@@ -396,7 +405,8 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestExcludedIds) {
" \"095\", \"096\", \"097\", \"098\", \"099\""
// Truncated to 100 entries. Currently, they happen to
// be those lexically first.
- " ]"
+ " ],"
+ " \"user_activeness_class\": \"ACTIVE_NTP_USER\""
"}"));
}

Powered by Google App Engine
This is Rietveld 408576698