Index: components/ntp_snippets/offline_pages/offline_page_suggestions_provider_unittest.cc |
diff --git a/components/ntp_snippets/offline_pages/offline_page_suggestions_provider_unittest.cc b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider_unittest.cc |
index bdceafd23489f3695232dba18db693e0f91036ba..8d48b457ed168c23eb365c340e3f876e2a7f8281 100644 |
--- a/components/ntp_snippets/offline_pages/offline_page_suggestions_provider_unittest.cc |
+++ b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider_unittest.cc |
@@ -75,6 +75,13 @@ OfflinePageItem CreateDummyDownload(int id) { |
return CreateDummyItem(offline_pages::kAsyncNamespace, id); |
} |
+void CaptureDismissedSuggestions( |
+ std::vector<ContentSuggestion>* captured_suggestions, |
+ std::vector<ContentSuggestion> dismissed_suggestions) { |
+ std::move(dismissed_suggestions.begin(), dismissed_suggestions.end(), |
+ std::back_inserter(*captured_suggestions)); |
+} |
+ |
} // namespace |
class MockOfflinePageModel : public StubOfflinePageModel { |
tschumann
2016/08/29 15:47:00
nit: while we're at it. This is more a fake than a
Philipp Keck
2016/08/29 17:04:15
Done.
|
@@ -153,17 +160,6 @@ class OfflinePageSuggestionsProviderTest : public testing::Test { |
return provider_->ReadDismissedIDsFromPrefs(category); |
} |
- // Workaround to realize a DismissedSuggestionsCallback. Because gMock can't |
- // handle non-movable parameters, a helper method is needed to forward the |
- // call to the actual MOCK_METHOD. |
- void DismissedSuggestionsHelper( |
- std::vector<ContentSuggestion> dismissed_suggestions) { |
- ReceivedDismissedSuggestions(dismissed_suggestions); |
- } |
- MOCK_METHOD1( |
- ReceivedDismissedSuggestions, |
- void(const std::vector<ContentSuggestion>& dismissed_suggestions)); |
- |
ContentSuggestionsProvider* provider() { return provider_.get(); } |
MockOfflinePageModel* model() { return &model_; } |
MockContentSuggestionsProviderObserver* observer() { return &observer_; } |
@@ -308,38 +304,33 @@ TEST_F(OfflinePageSuggestionsProviderTest, ShouldDismiss) { |
Mock::VerifyAndClearExpectations(observer()); |
// And appear in the dismissed suggestions for the right category. |
- EXPECT_CALL(*this, ReceivedDismissedSuggestions(UnorderedElementsAre( |
- Property(&ContentSuggestion::url, |
- GURL("file:///some/folder/test2.mhtml")), |
- Property(&ContentSuggestion::url, |
- GURL("file:///some/folder/test3.mhtml"))))); |
+ std::vector<ContentSuggestion> dismissed_suggestions; |
provider()->GetDismissedSuggestionsForDebugging( |
recent_tabs_category(), |
- base::Bind( |
- &OfflinePageSuggestionsProviderTest::DismissedSuggestionsHelper, |
- base::Unretained(this))); |
- Mock::VerifyAndClearExpectations(this); |
+ base::Bind(&CaptureDismissedSuggestions, &dismissed_suggestions)); |
+ EXPECT_THAT( |
+ dismissed_suggestions, |
+ UnorderedElementsAre(Property(&ContentSuggestion::url, |
+ GURL("file:///some/folder/test2.mhtml")), |
+ Property(&ContentSuggestion::url, |
+ GURL("file:///some/folder/test3.mhtml")))); |
// The other category should have no dismissed suggestions. |
- EXPECT_CALL(*this, ReceivedDismissedSuggestions(IsEmpty())); |
+ dismissed_suggestions.clear(); |
provider()->GetDismissedSuggestionsForDebugging( |
downloads_category(), |
- base::Bind( |
- &OfflinePageSuggestionsProviderTest::DismissedSuggestionsHelper, |
- base::Unretained(this))); |
- Mock::VerifyAndClearExpectations(this); |
+ base::Bind(&CaptureDismissedSuggestions, &dismissed_suggestions)); |
+ EXPECT_THAT(dismissed_suggestions, IsEmpty()); |
// Clear dismissed suggestions. |
provider()->ClearDismissedSuggestionsForDebugging(recent_tabs_category()); |
// They should be gone from the dismissed suggestions. |
- EXPECT_CALL(*this, ReceivedDismissedSuggestions(IsEmpty())); |
+ dismissed_suggestions.clear(); |
provider()->GetDismissedSuggestionsForDebugging( |
recent_tabs_category(), |
- base::Bind( |
- &OfflinePageSuggestionsProviderTest::DismissedSuggestionsHelper, |
- base::Unretained(this))); |
- Mock::VerifyAndClearExpectations(this); |
+ base::Bind(&CaptureDismissedSuggestions, &dismissed_suggestions)); |
+ EXPECT_THAT(dismissed_suggestions, IsEmpty()); |
// And appear in the reported suggestions for the category again. |
EXPECT_CALL(*observer(), |