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 18 matching lines...) Expand all Loading... |
29 #include "components/ntp_snippets/ntp_snippet.h" | 29 #include "components/ntp_snippets/ntp_snippet.h" |
30 #include "components/ntp_snippets/ntp_snippets_constants.h" | 30 #include "components/ntp_snippets/ntp_snippets_constants.h" |
31 #include "components/ntp_snippets/ntp_snippets_database.h" | 31 #include "components/ntp_snippets/ntp_snippets_database.h" |
32 #include "components/ntp_snippets/ntp_snippets_fetcher.h" | 32 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
33 #include "components/ntp_snippets/ntp_snippets_scheduler.h" | 33 #include "components/ntp_snippets/ntp_snippets_scheduler.h" |
34 #include "components/ntp_snippets/ntp_snippets_test_utils.h" | 34 #include "components/ntp_snippets/ntp_snippets_test_utils.h" |
35 #include "components/ntp_snippets/switches.h" | 35 #include "components/ntp_snippets/switches.h" |
36 #include "components/prefs/testing_pref_service.h" | 36 #include "components/prefs/testing_pref_service.h" |
37 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
38 #include "components/signin/core/browser/fake_signin_manager.h" | 38 #include "components/signin/core/browser/fake_signin_manager.h" |
39 #include "components/variations/variations_associated_data.h" | 39 #include "components/variations/variations_params_manager.h" |
40 #include "google_apis/google_api_keys.h" | 40 #include "google_apis/google_api_keys.h" |
41 #include "net/url_request/test_url_fetcher_factory.h" | 41 #include "net/url_request/test_url_fetcher_factory.h" |
42 #include "net/url_request/url_request_test_util.h" | 42 #include "net/url_request/url_request_test_util.h" |
43 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
45 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
46 #include "ui/gfx/image/image_unittest_util.h" | 46 #include "ui/gfx/image/image_unittest_util.h" |
47 | 47 |
48 using image_fetcher::ImageFetcher; | 48 using image_fetcher::ImageFetcher; |
49 using image_fetcher::ImageFetcherDelegate; | 49 using image_fetcher::ImageFetcherDelegate; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 DISALLOW_COPY_AND_ASSIGN(FakeContentSuggestionsProviderObserver); | 338 DISALLOW_COPY_AND_ASSIGN(FakeContentSuggestionsProviderObserver); |
339 }; | 339 }; |
340 | 340 |
341 } // namespace | 341 } // namespace |
342 | 342 |
343 class NTPSnippetsServiceTest : public ::testing::Test { | 343 class NTPSnippetsServiceTest : public ::testing::Test { |
344 public: | 344 public: |
345 NTPSnippetsServiceTest() | 345 NTPSnippetsServiceTest() |
346 : params_manager_(ntp_snippets::kStudyName, | 346 : params_manager_(ntp_snippets::kStudyName, |
347 {{"content_suggestions_backend", | 347 {{"content_suggestions_backend", |
348 kTestContentSuggestionsServerEndpoint}}), | 348 kTestContentSuggestionsServerEndpoint}}, {}), |
349 fake_url_fetcher_factory_( | 349 fake_url_fetcher_factory_( |
350 /*default_factory=*/&failing_url_fetcher_factory_), | 350 /*default_factory=*/&failing_url_fetcher_factory_), |
351 test_url_(base::StringPrintf(kTestContentSuggestionsServerFormat, | 351 test_url_(base::StringPrintf(kTestContentSuggestionsServerFormat, |
352 google_apis::GetAPIKey().c_str())), | 352 google_apis::GetAPIKey().c_str())), |
353 | 353 |
354 observer_(base::MakeUnique<FakeContentSuggestionsProviderObserver>()) { | 354 observer_(base::MakeUnique<FakeContentSuggestionsProviderObserver>()) { |
355 NTPSnippetsService::RegisterProfilePrefs(utils_.pref_service()->registry()); | 355 NTPSnippetsService::RegisterProfilePrefs(utils_.pref_service()->registry()); |
356 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); | 356 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); |
357 | 357 |
358 // Since no SuggestionsService is injected in tests, we need to force the | 358 // Since no SuggestionsService is injected in tests, we need to force the |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 end = base::Time::FromTimeT(456); | 978 end = base::Time::FromTimeT(456); |
979 base::Callback<bool(const GURL& url)> filter; | 979 base::Callback<bool(const GURL& url)> filter; |
980 service->ClearHistory(begin, end, filter); | 980 service->ClearHistory(begin, end, filter); |
981 | 981 |
982 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), IsEmpty()); | 982 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), IsEmpty()); |
983 EXPECT_THAT(service->GetDismissedSnippetsForTesting(articles_category()), | 983 EXPECT_THAT(service->GetDismissedSnippetsForTesting(articles_category()), |
984 IsEmpty()); | 984 IsEmpty()); |
985 } | 985 } |
986 | 986 |
987 } // namespace ntp_snippets | 987 } // namespace ntp_snippets |
OLD | NEW |