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

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

Issue 2759423003: [UserClassifier] Inject a clock (Closed)
Patch Set: Created 3 years, 9 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/remote_suggestions_provider_impl.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/test/histogram_tester.h" 22 #include "base/test/histogram_tester.h"
23 #include "base/test/simple_test_clock.h" 23 #include "base/test/simple_test_clock.h"
24 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
25 #include "base/time/default_clock.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "components/image_fetcher/image_decoder.h" 27 #include "components/image_fetcher/image_decoder.h"
27 #include "components/image_fetcher/image_fetcher.h" 28 #include "components/image_fetcher/image_fetcher.h"
28 #include "components/image_fetcher/image_fetcher_delegate.h" 29 #include "components/image_fetcher/image_fetcher_delegate.h"
29 #include "components/image_fetcher/request_metadata.h" 30 #include "components/image_fetcher/request_metadata.h"
30 #include "components/ntp_snippets/category.h" 31 #include "components/ntp_snippets/category.h"
31 #include "components/ntp_snippets/category_info.h" 32 #include "components/ntp_snippets/category_info.h"
32 #include "components/ntp_snippets/category_rankers/category_ranker.h" 33 #include "components/ntp_snippets/category_rankers/category_ranker.h"
33 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h" 34 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
34 #include "components/ntp_snippets/category_rankers/mock_category_ranker.h" 35 #include "components/ntp_snippets/category_rankers/mock_category_ranker.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 public: 395 public:
395 RemoteSuggestionsProviderImplTest() 396 RemoteSuggestionsProviderImplTest()
396 : params_manager_(ntp_snippets::kStudyName, 397 : params_manager_(ntp_snippets::kStudyName,
397 {{"content_suggestions_backend", 398 {{"content_suggestions_backend",
398 kTestContentSuggestionsServerEndpoint}}, 399 kTestContentSuggestionsServerEndpoint}},
399 {ntp_snippets::kArticleSuggestionsFeature.name}), 400 {ntp_snippets::kArticleSuggestionsFeature.name}),
400 fake_url_fetcher_factory_( 401 fake_url_fetcher_factory_(
401 /*default_factory=*/&failing_url_fetcher_factory_), 402 /*default_factory=*/&failing_url_fetcher_factory_),
402 test_url_(kTestContentSuggestionsServerWithAPIKey), 403 test_url_(kTestContentSuggestionsServerWithAPIKey),
403 category_ranker_(base::MakeUnique<ConstantCategoryRanker>()), 404 category_ranker_(base::MakeUnique<ConstantCategoryRanker>()),
404 user_classifier_(/*pref_service=*/nullptr), 405 user_classifier_(/*pref_service=*/nullptr,
406 base::MakeUnique<base::DefaultClock>()),
405 suggestions_fetcher_(nullptr), 407 suggestions_fetcher_(nullptr),
406 image_fetcher_(nullptr), 408 image_fetcher_(nullptr),
407 database_(nullptr) { 409 database_(nullptr) {
408 RemoteSuggestionsProviderImpl::RegisterProfilePrefs( 410 RemoteSuggestionsProviderImpl::RegisterProfilePrefs(
409 utils_.pref_service()->registry()); 411 utils_.pref_service()->registry());
410 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); 412 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry());
411 413
412 EXPECT_TRUE(database_dir_.CreateUniqueTempDir()); 414 EXPECT_TRUE(database_dir_.CreateUniqueTempDir());
413 } 415 }
414 416
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 EXPECT_CALL(scheduler, OnProviderActivated()); 1813 EXPECT_CALL(scheduler, OnProviderActivated());
1812 // The scheduler should be notified of clearing the history. 1814 // The scheduler should be notified of clearing the history.
1813 EXPECT_CALL(scheduler, OnSuggestionsCleared()); 1815 EXPECT_CALL(scheduler, OnSuggestionsCleared());
1814 1816
1815 service->SetRemoteSuggestionsScheduler(&scheduler); 1817 service->SetRemoteSuggestionsScheduler(&scheduler);
1816 service->OnStatusChanged(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT, 1818 service->OnStatusChanged(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT,
1817 RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN); 1819 RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN);
1818 } 1820 }
1819 1821
1820 } // namespace ntp_snippets 1822 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698