OLD | NEW |
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/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
14 #include "base/test/test_mock_time_task_runner.h" | 14 #include "base/test/test_mock_time_task_runner.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "components/ntp_snippets/category_factory.h" | 18 #include "components/ntp_snippets/category_factory.h" |
19 #include "components/ntp_snippets/ntp_snippet.h" | 19 #include "components/ntp_snippets/ntp_snippet.h" |
20 #include "components/ntp_snippets/ntp_snippets_constants.h" | 20 #include "components/ntp_snippets/ntp_snippets_constants.h" |
21 #include "components/prefs/testing_pref_service.h" | 21 #include "components/prefs/testing_pref_service.h" |
22 #include "components/signin/core/browser/account_tracker_service.h" | 22 #include "components/signin/core/browser/account_tracker_service.h" |
23 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 23 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
24 #include "components/signin/core/browser/fake_signin_manager.h" | 24 #include "components/signin/core/browser/fake_signin_manager.h" |
25 #include "components/signin/core/browser/test_signin_client.h" | 25 #include "components/signin/core/browser/test_signin_client.h" |
26 #include "components/variations/entropy_provider.h" | 26 #include "components/variations/entropy_provider.h" |
27 #include "components/variations/variations_associated_data.h" | 27 #include "components/variations/variations_params_manager.h" |
28 #include "google_apis/google_api_keys.h" | 28 #include "google_apis/google_api_keys.h" |
29 #include "net/url_request/test_url_fetcher_factory.h" | 29 #include "net/url_request/test_url_fetcher_factory.h" |
30 #include "net/url_request/url_request_test_util.h" | 30 #include "net/url_request/url_request_test_util.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
33 | 33 |
34 namespace ntp_snippets { | 34 namespace ntp_snippets { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } // namespace | 146 } // namespace |
147 | 147 |
148 class NTPSnippetsFetcherTest : public testing::Test { | 148 class NTPSnippetsFetcherTest : public testing::Test { |
149 public: | 149 public: |
150 NTPSnippetsFetcherTest() | 150 NTPSnippetsFetcherTest() |
151 : NTPSnippetsFetcherTest(GetFetcherUrl(kTestChromeReaderUrlFormat), | 151 : NTPSnippetsFetcherTest(GetFetcherUrl(kTestChromeReaderUrlFormat), |
152 std::map<std::string, std::string>()) {} | 152 std::map<std::string, std::string>()) {} |
153 | 153 |
154 NTPSnippetsFetcherTest(const GURL& gurl, | 154 NTPSnippetsFetcherTest(const GURL& gurl, |
155 const std::map<std::string, std::string>& params) | 155 const std::map<std::string, std::string>& params) |
156 : params_manager_(ntp_snippets::kStudyName, params), | 156 : params_manager_(ntp_snippets::kStudyName, params, {}), |
157 mock_task_runner_(new base::TestMockTimeTaskRunner()), | 157 mock_task_runner_(new base::TestMockTimeTaskRunner()), |
158 mock_task_runner_handle_(mock_task_runner_), | 158 mock_task_runner_handle_(mock_task_runner_), |
159 signin_client_(new TestSigninClient(nullptr)), | 159 signin_client_(new TestSigninClient(nullptr)), |
160 account_tracker_(new AccountTrackerService()), | 160 account_tracker_(new AccountTrackerService()), |
161 fake_signin_manager_(new FakeSigninManagerBase(signin_client_.get(), | 161 fake_signin_manager_(new FakeSigninManagerBase(signin_client_.get(), |
162 account_tracker_.get())), | 162 account_tracker_.get())), |
163 fake_token_service_(new FakeProfileOAuth2TokenService()), | 163 fake_token_service_(new FakeProfileOAuth2TokenService()), |
164 pref_service_(new TestingPrefServiceSimple()), | 164 pref_service_(new TestingPrefServiceSimple()), |
165 test_lang_("en-US"), | 165 test_lang_("en-US"), |
166 test_url_(gurl) { | 166 test_url_(gurl) { |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (snippets) { | 806 if (snippets) { |
807 // Matchers above aren't any more precise than this, so this is sufficient | 807 // Matchers above aren't any more precise than this, so this is sufficient |
808 // for test-failure diagnostics. | 808 // for test-failure diagnostics. |
809 return os << "list with " << snippets->size() << " elements"; | 809 return os << "list with " << snippets->size() << " elements"; |
810 } else { | 810 } else { |
811 return os << "null"; | 811 return os << "null"; |
812 } | 812 } |
813 } | 813 } |
814 | 814 |
815 } // namespace ntp_snippets | 815 } // namespace ntp_snippets |
OLD | NEW |