Index: ios/chrome/browser/ui/reading_list/reading_list_view_controller_unittest.mm |
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_view_controller_unittest.mm b/ios/chrome/browser/ui/reading_list/reading_list_view_controller_unittest.mm |
index d41a48d7d592fe8785c019663bcf878c8496fe50..0ba9882e8ad2001c8dbe11fc2b8b749aef232a52 100644 |
--- a/ios/chrome/browser/ui/reading_list/reading_list_view_controller_unittest.mm |
+++ b/ios/chrome/browser/ui/reading_list/reading_list_view_controller_unittest.mm |
@@ -7,9 +7,8 @@ |
#include "base/mac/scoped_nsobject.h" |
#include "base/memory/ptr_util.h" |
#include "base/threading/thread_task_runner_handle.h" |
-#include "components/favicon/core/favicon_client.h" |
-#include "components/favicon/core/favicon_service.h" |
#include "components/favicon/core/large_icon_service.h" |
+#include "components/favicon/core/test/mock_favicon_service.h" |
#include "components/reading_list/ios/reading_list_entry.h" |
#include "components/reading_list/ios/reading_list_model_impl.h" |
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
@@ -18,37 +17,14 @@ |
#import "ios/chrome/browser/ui/url_loader.h" |
#include "ios/web/public/referrer.h" |
#import "ios/web/public/test/web_test_with_web_state.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
#import "third_party/ocmock/OCMock/OCMock.h" |
#import "third_party/ocmock/gtest_support.h" |
#include "ui/base/page_transition_types.h" |
-namespace { |
- |
-#pragma mark - MockFaviconService |
- |
-// A mock FaviconService that emits an empty response. |
-class MockFaviconService : public favicon::FaviconService { |
- public: |
- MockFaviconService() : FaviconService(nullptr, nullptr) {} |
- |
- ~MockFaviconService() override {} |
- |
- base::CancelableTaskTracker::TaskId GetLargestRawFaviconForPageURL( |
- const GURL& page_url, |
- const std::vector<int>& icon_types, |
- int minimum_size_in_pixels, |
- const favicon_base::FaviconRawBitmapCallback& callback, |
- base::CancelableTaskTracker* tracker) override { |
- favicon_base::FaviconRawBitmapResult mock_result; |
- return tracker->PostTask(base::ThreadTaskRunnerHandle::Get().get(), |
- FROM_HERE, base::Bind(callback, mock_result)); |
- } |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(MockFaviconService); |
-}; |
- |
-} // namespace |
+using favicon::PostCallbackWithResult; |
+using testing::WithArg; |
+using testing::_; |
#pragma mark - UrlLoader |
@@ -116,17 +92,22 @@ class ReadingListViewControllerTest : public web::WebTestWithWebState { |
public: |
ReadingListViewControllerTest() { |
loader_mock_.reset([[UrlLoaderStub alloc] init]); |
- mock_favicon_service_.reset(new MockFaviconService()); |
reading_list_model_.reset(new ReadingListModelImpl(nullptr, nullptr)); |
large_icon_service_.reset(new favicon::LargeIconService( |
- mock_favicon_service_.get(), base::ThreadTaskRunnerHandle::Get())); |
+ &mock_favicon_service_, base::ThreadTaskRunnerHandle::Get())); |
container_.reset([[ReadingListViewController alloc] |
initWithModel:reading_list_model_.get() |
loader:loader_mock_ |
largeIconService:large_icon_service_.get() |
readingListDownloadService:nil]); |
+ |
+ EXPECT_CALL(mock_favicon_service_, |
+ GetLargestRawFaviconForPageURL(_, _, _, _, _)) |
+ .WillRepeatedly(WithArg<3>( |
+ PostCallbackWithResult(favicon_base::FaviconRawBitmapResult()))); |
} |
+ |
~ReadingListViewControllerTest() override {} |
ReadingListViewController* GetContainer() { return container_; } |
@@ -146,8 +127,8 @@ class ReadingListViewControllerTest : public web::WebTestWithWebState { |
base::scoped_nsobject<ReadingListViewController> container_; |
std::unique_ptr<ReadingListModelImpl> reading_list_model_; |
base::scoped_nsobject<UrlLoaderStub> loader_mock_; |
+ testing::StrictMock<favicon::MockFaviconService> mock_favicon_service_; |
std::unique_ptr<favicon::LargeIconService> large_icon_service_; |
- std::unique_ptr<MockFaviconService> mock_favicon_service_; |
}; |
// Tests that the implementation of ReadingListCollectionViewController |