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/remote/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/remote/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" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 user_classifier_ = base::MakeUnique<UserClassifier>(pref_service_.get()); | 168 user_classifier_ = base::MakeUnique<UserClassifier>(pref_service_.get()); |
169 | 169 |
170 snippets_fetcher_ = base::MakeUnique<NTPSnippetsFetcher>( | 170 snippets_fetcher_ = base::MakeUnique<NTPSnippetsFetcher>( |
171 fake_signin_manager_.get(), fake_token_service_.get(), | 171 fake_signin_manager_.get(), fake_token_service_.get(), |
172 scoped_refptr<net::TestURLRequestContextGetter>( | 172 scoped_refptr<net::TestURLRequestContextGetter>( |
173 new net::TestURLRequestContextGetter(mock_task_runner_.get())), | 173 new net::TestURLRequestContextGetter(mock_task_runner_.get())), |
174 pref_service_.get(), &category_factory_, nullptr, | 174 pref_service_.get(), &category_factory_, nullptr, |
175 base::Bind(&ParseJsonDelayed), kAPIKey, user_classifier_.get()); | 175 base::Bind(&ParseJsonDelayed), kAPIKey, user_classifier_.get()); |
176 | 176 |
177 snippets_fetcher_->SetCallback( | 177 snippets_fetcher_->SetCallback( |
178 base::Bind(&MockSnippetsAvailableCallback::WrappedRun, | 178 base::BindOnce(&MockSnippetsAvailableCallback::WrappedRun, |
179 base::Unretained(&mock_callback_))); | 179 base::Unretained(&mock_callback_))); |
180 snippets_fetcher_->SetTickClockForTesting( | 180 snippets_fetcher_->SetTickClockForTesting( |
181 mock_task_runner_->GetMockTickClock()); | 181 mock_task_runner_->GetMockTickClock()); |
182 test_excluded_.insert("1234567890"); | 182 test_excluded_.insert("1234567890"); |
183 // Increase initial time such that ticks are non-zero. | 183 // Increase initial time such that ticks are non-zero. |
184 mock_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(1234)); | 184 mock_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(1234)); |
185 } | 185 } |
186 | 186 |
187 NTPSnippetsFetcher& snippets_fetcher() { return *snippets_fetcher_; } | 187 NTPSnippetsFetcher& snippets_fetcher() { return *snippets_fetcher_; } |
188 MockSnippetsAvailableCallback& mock_callback() { return mock_callback_; } | 188 MockSnippetsAvailableCallback& mock_callback() { return mock_callback_; } |
189 void FastForwardUntilNoTasksRemain() { | 189 void FastForwardUntilNoTasksRemain() { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 const NTPSnippetsFetcher::OptionalFetchedCategories& fetched_categories) { | 882 const NTPSnippetsFetcher::OptionalFetchedCategories& fetched_categories) { |
883 if (fetched_categories) { | 883 if (fetched_categories) { |
884 // Matchers above aren't any more precise than this, so this is sufficient | 884 // Matchers above aren't any more precise than this, so this is sufficient |
885 // for test-failure diagnostics. | 885 // for test-failure diagnostics. |
886 return os << "list with " << fetched_categories->size() << " elements"; | 886 return os << "list with " << fetched_categories->size() << " elements"; |
887 } | 887 } |
888 return os << "null"; | 888 return os << "null"; |
889 } | 889 } |
890 | 890 |
891 } // namespace ntp_snippets | 891 } // namespace ntp_snippets |
OLD | NEW |