OLD | NEW |
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/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 using image_fetcher::ImageFetcher; | 47 using image_fetcher::ImageFetcher; |
48 using image_fetcher::ImageFetcherDelegate; | 48 using image_fetcher::ImageFetcherDelegate; |
49 using testing::ElementsAre; | 49 using testing::ElementsAre; |
50 using testing::Eq; | 50 using testing::Eq; |
51 using testing::InSequence; | 51 using testing::InSequence; |
52 using testing::Invoke; | 52 using testing::Invoke; |
53 using testing::IsEmpty; | 53 using testing::IsEmpty; |
54 using testing::Mock; | 54 using testing::Mock; |
55 using testing::MockFunction; | 55 using testing::MockFunction; |
56 using testing::NiceMock; | 56 using testing::NiceMock; |
57 using testing::Return; | |
58 using testing::SaveArg; | 57 using testing::SaveArg; |
59 using testing::SizeIs; | 58 using testing::SizeIs; |
60 using testing::StartsWith; | 59 using testing::StartsWith; |
61 using testing::WithArgs; | 60 using testing::WithArgs; |
62 using testing::_; | 61 using testing::_; |
63 | 62 |
64 namespace ntp_snippets { | 63 namespace ntp_snippets { |
65 | 64 |
66 namespace { | 65 namespace { |
67 | 66 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } // namespace | 342 } // namespace |
344 | 343 |
345 class NTPSnippetsServiceTest : public ::testing::Test { | 344 class NTPSnippetsServiceTest : public ::testing::Test { |
346 public: | 345 public: |
347 NTPSnippetsServiceTest() | 346 NTPSnippetsServiceTest() |
348 : params_manager_(ntp_snippets::kStudyName, | 347 : params_manager_(ntp_snippets::kStudyName, |
349 {{"content_suggestions_backend", | 348 {{"content_suggestions_backend", |
350 kTestContentSuggestionsServerEndpoint}}), | 349 kTestContentSuggestionsServerEndpoint}}), |
351 fake_url_fetcher_factory_( | 350 fake_url_fetcher_factory_( |
352 /*default_factory=*/&failing_url_fetcher_factory_), | 351 /*default_factory=*/&failing_url_fetcher_factory_), |
353 test_url_(kTestContentSuggestionsServerWithAPIKey) { | 352 test_url_(kTestContentSuggestionsServerWithAPIKey), |
| 353 image_fetcher_(nullptr) { |
354 NTPSnippetsService::RegisterProfilePrefs(utils_.pref_service()->registry()); | 354 NTPSnippetsService::RegisterProfilePrefs(utils_.pref_service()->registry()); |
355 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); | 355 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); |
356 | 356 |
357 // Since no SuggestionsService is injected in tests, we need to force the | 357 // Since no SuggestionsService is injected in tests, we need to force the |
358 // service to fetch from all hosts. | 358 // service to fetch from all hosts. |
359 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 359 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
360 switches::kDontRestrict); | 360 switches::kDontRestrict); |
361 EXPECT_TRUE(database_dir_.CreateUniqueTempDir()); | 361 EXPECT_TRUE(database_dir_.CreateUniqueTempDir()); |
362 } | 362 } |
363 | 363 |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 end = base::Time::FromTimeT(456); | 1038 end = base::Time::FromTimeT(456); |
1039 base::Callback<bool(const GURL& url)> filter; | 1039 base::Callback<bool(const GURL& url)> filter; |
1040 service->ClearHistory(begin, end, filter); | 1040 service->ClearHistory(begin, end, filter); |
1041 | 1041 |
1042 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), IsEmpty()); | 1042 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), IsEmpty()); |
1043 EXPECT_THAT(service->GetDismissedSnippetsForTesting(articles_category()), | 1043 EXPECT_THAT(service->GetDismissedSnippetsForTesting(articles_category()), |
1044 IsEmpty()); | 1044 IsEmpty()); |
1045 } | 1045 } |
1046 | 1046 |
1047 } // namespace ntp_snippets | 1047 } // namespace ntp_snippets |
OLD | NEW |