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

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

Issue 2782233002: Drop ntp_snippets::kStudyName in chrome://flags (Closed)
Patch Set: rebase Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/remote_suggestions_fetcher.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 base::TimeDelta::FromMilliseconds(kTestJsonParsingLatencyMs)); 264 base::TimeDelta::FromMilliseconds(kTestJsonParsingLatencyMs));
265 } 265 }
266 266
267 } // namespace 267 } // namespace
268 268
269 class RemoteSuggestionsFetcherTestBase : public testing::Test { 269 class RemoteSuggestionsFetcherTestBase : public testing::Test {
270 public: 270 public:
271 explicit RemoteSuggestionsFetcherTestBase(const GURL& gurl) 271 explicit RemoteSuggestionsFetcherTestBase(const GURL& gurl)
272 : default_variation_params_( 272 : default_variation_params_(
273 {{"send_top_languages", "true"}, {"send_user_class", "true"}}), 273 {{"send_top_languages", "true"}, {"send_user_class", "true"}}),
274 params_manager_(ntp_snippets::kStudyName, 274 params_manager_(ntp_snippets::kArticleSuggestionsFeature.name,
275 default_variation_params_, 275 default_variation_params_,
276 {ntp_snippets::kArticleSuggestionsFeature.name}), 276 {ntp_snippets::kArticleSuggestionsFeature.name}),
277 mock_task_runner_(new base::TestMockTimeTaskRunner()), 277 mock_task_runner_(new base::TestMockTimeTaskRunner()),
278 mock_task_runner_handle_(mock_task_runner_), 278 mock_task_runner_handle_(mock_task_runner_),
279 test_url_(gurl) { 279 test_url_(gurl) {
280 UserClassifier::RegisterProfilePrefs(utils_.pref_service()->registry()); 280 UserClassifier::RegisterProfilePrefs(utils_.pref_service()->registry());
281 user_classifier_ = base::MakeUnique<UserClassifier>( 281 user_classifier_ = base::MakeUnique<UserClassifier>(
282 utils_.pref_service(), base::MakeUnique<base::DefaultClock>()); 282 utils_.pref_service(), base::MakeUnique<base::DefaultClock>());
283 // Increase initial time such that ticks are non-zero. 283 // Increase initial time such that ticks are non-zero.
284 mock_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(1234)); 284 mock_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(1234));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 fake_url_fetcher_factory_.reset(new net::FakeURLFetcherFactory( 351 fake_url_fetcher_factory_.reset(new net::FakeURLFetcherFactory(
352 /*default_factory=*/&failing_url_fetcher_factory_)); 352 /*default_factory=*/&failing_url_fetcher_factory_));
353 } 353 }
354 354
355 void SetVariationParam(std::string param_name, std::string value) { 355 void SetVariationParam(std::string param_name, std::string value) {
356 std::map<std::string, std::string> params = default_variation_params_; 356 std::map<std::string, std::string> params = default_variation_params_;
357 params[param_name] = value; 357 params[param_name] = value;
358 358
359 params_manager_.ClearAllVariationParams(); 359 params_manager_.ClearAllVariationParams();
360 params_manager_.SetVariationParamsWithFeatureAssociations( 360 params_manager_.SetVariationParamsWithFeatureAssociations(
361 ntp_snippets::kStudyName, params, 361 ntp_snippets::kArticleSuggestionsFeature.name, params,
362 {ntp_snippets::kArticleSuggestionsFeature.name}); 362 {ntp_snippets::kArticleSuggestionsFeature.name});
363 } 363 }
364 364
365 void SetFakeResponse(const std::string& response_data, 365 void SetFakeResponse(const std::string& response_data,
366 net::HttpStatusCode response_code, 366 net::HttpStatusCode response_code,
367 net::URLRequestStatus::Status status) { 367 net::URLRequestStatus::Status status) {
368 InitFakeURLFetcherFactory(); 368 InitFakeURLFetcherFactory();
369 fake_url_fetcher_factory_->SetFakeResponse(test_url_, response_data, 369 fake_url_fetcher_factory_->SetFakeResponse(test_url_, response_data,
370 response_code, status); 370 response_code, status);
371 } 371 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 fetched_categories) { 991 fetched_categories) {
992 if (fetched_categories) { 992 if (fetched_categories) {
993 // Matchers above aren't any more precise than this, so this is sufficient 993 // Matchers above aren't any more precise than this, so this is sufficient
994 // for test-failure diagnostics. 994 // for test-failure diagnostics.
995 return os << "list with " << fetched_categories->size() << " elements"; 995 return os << "list with " << fetched_categories->size() << " elements";
996 } 996 }
997 return os << "null"; 997 return os << "null";
998 } 998 }
999 999
1000 } // namespace ntp_snippets 1000 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698