Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_provider_impl_unittest.cc

Issue 2786023002: [Remote suggestions] Remove the unique_ptr wrapper around callbacks (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 void SetUpHttpError() { 550 void SetUpHttpError() {
551 fake_url_fetcher_factory_.SetFakeResponse(test_url_, /*json=*/std::string(), 551 fake_url_fetcher_factory_.SetFakeResponse(test_url_, /*json=*/std::string(),
552 net::HTTP_NOT_FOUND, 552 net::HTTP_NOT_FOUND,
553 net::URLRequestStatus::SUCCESS); 553 net::URLRequestStatus::SUCCESS);
554 } 554 }
555 555
556 void LoadFromJSONString(RemoteSuggestionsProviderImpl* service, 556 void LoadFromJSONString(RemoteSuggestionsProviderImpl* service,
557 const std::string& json) { 557 const std::string& json) {
558 SetUpFetchResponse(json); 558 SetUpFetchResponse(json);
559 service->FetchSuggestions(/*interactive_request=*/true, 559 service->FetchSuggestions(/*interactive_request=*/true,
560 /*callback=*/nullptr); 560 RemoteSuggestionsProvider::FetchStatusCallback());
561 base::RunLoop().RunUntilIdle(); 561 base::RunLoop().RunUntilIdle();
562 } 562 }
563 563
564 void LoadMoreFromJSONString(RemoteSuggestionsProviderImpl* service, 564 void LoadMoreFromJSONString(RemoteSuggestionsProviderImpl* service,
565 const Category& category, 565 const Category& category,
566 const std::string& json, 566 const std::string& json,
567 const std::set<std::string>& known_ids, 567 const std::set<std::string>& known_ids,
568 FetchDoneCallback callback) { 568 FetchDoneCallback callback) {
569 SetUpFetchResponse(json); 569 SetUpFetchResponse(json);
570 EXPECT_CALL(*scheduler(), AcquireQuotaForInteractiveFetch()) 570 EXPECT_CALL(*scheduler(), AcquireQuotaForInteractiveFetch())
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 WaitForSuggestionsProviderInitialization(service.get(), 1724 WaitForSuggestionsProviderInitialization(service.get(),
1725 /*set_empty_response=*/true); 1725 /*set_empty_response=*/true);
1726 EXPECT_EQ( 1726 EXPECT_EQ(
1727 simple_test_clock_ptr->Now().ToInternalValue(), 1727 simple_test_clock_ptr->Now().ToInternalValue(),
1728 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime)); 1728 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime));
1729 1729
1730 // Advance the time and check whether the time was updated correctly after the 1730 // Advance the time and check whether the time was updated correctly after the
1731 // background fetch. 1731 // background fetch.
1732 simple_test_clock_ptr->Advance(TimeDelta::FromHours(1)); 1732 simple_test_clock_ptr->Advance(TimeDelta::FromHours(1));
1733 1733
1734 service->RefetchInTheBackground(/*callback=*/nullptr); 1734 service->RefetchInTheBackground(
1735 RemoteSuggestionsProvider::FetchStatusCallback());
1735 base::RunLoop().RunUntilIdle(); 1736 base::RunLoop().RunUntilIdle();
1736 // TODO(jkrcal): Move together with the pref storage into the scheduler. 1737 // TODO(jkrcal): Move together with the pref storage into the scheduler.
1737 EXPECT_EQ( 1738 EXPECT_EQ(
1738 simple_test_clock_ptr->Now().ToInternalValue(), 1739 simple_test_clock_ptr->Now().ToInternalValue(),
1739 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime)); 1740 pref_service()->GetInt64(prefs::kLastSuccessfulBackgroundFetchTime));
1740 // TODO(markusheintz): Add a test that simulates a browser restart once the 1741 // TODO(markusheintz): Add a test that simulates a browser restart once the
1741 // scheduler refactoring is done (crbug.com/672434). 1742 // scheduler refactoring is done (crbug.com/672434).
1742 } 1743 }
1743 1744
1744 TEST_F(RemoteSuggestionsProviderImplTest, CallsSchedulerWhenReady) { 1745 TEST_F(RemoteSuggestionsProviderImplTest, CallsSchedulerWhenReady) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 WaitForSuggestionsProviderInitialization(service.get(), 1812 WaitForSuggestionsProviderInitialization(service.get(),
1812 /*set_empty_response=*/true); 1813 /*set_empty_response=*/true);
1813 1814
1814 // The scheduler should be notified of clearing the history. 1815 // The scheduler should be notified of clearing the history.
1815 EXPECT_CALL(*scheduler(), OnSuggestionsCleared()); 1816 EXPECT_CALL(*scheduler(), OnSuggestionsCleared());
1816 service->OnStatusChanged(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT, 1817 service->OnStatusChanged(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT,
1817 RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN); 1818 RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN);
1818 } 1819 }
1819 1820
1820 } // namespace ntp_snippets 1821 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698