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/remote/remote_suggestions_provider.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 base::MakeUnique<NTPSnippetsStatusService>(utils_.fake_signin_manager(), | 458 base::MakeUnique<NTPSnippetsStatusService>(utils_.fake_signin_manager(), |
459 utils_.pref_service())); | 459 utils_.pref_service())); |
460 } | 460 } |
461 | 461 |
462 void WaitForSnippetsServiceInitialization(RemoteSuggestionsProvider* service, | 462 void WaitForSnippetsServiceInitialization(RemoteSuggestionsProvider* service, |
463 bool set_empty_response) { | 463 bool set_empty_response) { |
464 EXPECT_EQ(RemoteSuggestionsProvider::State::NOT_INITED, service->state_); | 464 EXPECT_EQ(RemoteSuggestionsProvider::State::NOT_INITED, service->state_); |
465 | 465 |
466 // Add an initial fetch response, as the service tries to fetch when there | 466 // Add an initial fetch response, as the service tries to fetch when there |
467 // is nothing in the DB. | 467 // is nothing in the DB. |
468 if (set_empty_response) | 468 if (set_empty_response) { |
469 SetUpFetchResponse(GetTestJson(std::vector<std::string>())); | 469 SetUpFetchResponse(GetTestJson(std::vector<std::string>())); |
| 470 } |
470 | 471 |
471 // TODO(treib): Find a better way to wait for initialization to finish. | 472 // TODO(treib): Find a better way to wait for initialization to finish. |
472 base::RunLoop().RunUntilIdle(); | 473 base::RunLoop().RunUntilIdle(); |
473 EXPECT_NE(RemoteSuggestionsProvider::State::NOT_INITED, service->state_); | 474 EXPECT_NE(RemoteSuggestionsProvider::State::NOT_INITED, service->state_); |
474 } | 475 } |
475 | 476 |
476 void ResetSnippetsService( | 477 void ResetSnippetsService( |
477 std::unique_ptr<RemoteSuggestionsProvider>* service) { | 478 std::unique_ptr<RemoteSuggestionsProvider>* service) { |
478 service->reset(); | 479 service->reset(); |
479 observer_.reset(); | 480 observer_.reset(); |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 base::StringPrintf("http://localhost/snippet-id-%d", i))); | 1587 base::StringPrintf("http://localhost/snippet-id-%d", i))); |
1587 } | 1588 } |
1588 LoadFromJSONString(service.get(), GetTestJson(suggestions)); | 1589 LoadFromJSONString(service.get(), GetTestJson(suggestions)); |
1589 // TODO(tschumann): We should probably trim out any additional results and | 1590 // TODO(tschumann): We should probably trim out any additional results and |
1590 // only serve the MaxSnippetCount items. | 1591 // only serve the MaxSnippetCount items. |
1591 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), | 1592 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), |
1592 SizeIs(service->GetMaxSnippetCountForTesting() + 1)); | 1593 SizeIs(service->GetMaxSnippetCountForTesting() + 1)); |
1593 } | 1594 } |
1594 | 1595 |
1595 } // namespace ntp_snippets | 1596 } // namespace ntp_snippets |
OLD | NEW |