| 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 daf478dc81fd72b09b5340c17358d1e411f699a0..c47bb9dc02392c4127e7322fd817acfd76259796 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"
|
| @@ -163,13 +164,15 @@ class NTPSnippetsFetcherTest : public testing::Test {
|
| test_lang_("en-US"),
|
| test_url_(gurl) {
|
| RequestThrottler::RegisterProfilePrefs(pref_service_->registry());
|
| + UserClassifier::RegisterProfilePrefs(pref_service_->registry());
|
| + user_classifier_ = base::MakeUnique<UserClassifier>(pref_service_.get());
|
|
|
| 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_.get());
|
|
|
| snippets_fetcher_->SetCallback(
|
| base::Bind(&MockSnippetsAvailableCallback::WrappedRun,
|
| @@ -222,6 +225,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_;
|
| + std::unique_ptr<UserClassifier> user_classifier_;
|
| CategoryFactory category_factory_;
|
| MockSnippetsAvailableCallback mock_callback_;
|
| const std::string test_lang_;
|
| @@ -250,6 +254,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(),
|
| @@ -300,7 +305,8 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestAuthenticated) {
|
| " ],"
|
| " \"excludedSuggestionIds\": ["
|
| " \"1234567890\""
|
| - " ]"
|
| + " ],"
|
| + " \"user_activeness_class\": \"ACTIVE_NTP_USER\""
|
| "}"));
|
| }
|
|
|
| @@ -311,6 +317,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;
|
| @@ -350,7 +357,8 @@ TEST_F(NTPSnippetsFetcherTest, BuildRequestUnauthenticated) {
|
| EqualsJSON("{"
|
| " \"regularlyVisitedHostNames\": [],"
|
| " \"priority\": \"USER_ACTION\","
|
| - " \"excludedSuggestionIds\": []"
|
| + " \"excludedSuggestionIds\": [],"
|
| + " \"user_activeness_class\": \"ACTIVE_NTP_USER\""
|
| "}"));
|
| }
|
|
|
| @@ -363,6 +371,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(),
|
| @@ -392,7 +401,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\""
|
| "}"));
|
| }
|
|
|
|
|