Index: ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm |
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm |
index e87e1a3238672d30452b2b1eccbfe6c1468fe49c..5f7b5a9f30bc3cd142385c9e60c75f026773909c 100644 |
--- a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm |
+++ b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm |
@@ -7,7 +7,6 @@ |
#include <unordered_set> |
#import "base/mac/foundation_util.h" |
-#include "base/mac/scoped_nsobject.h" |
#include "base/memory/ptr_util.h" |
#include "base/single_thread_task_runner.h" |
#include "base/strings/sys_string_conversions.h" |
@@ -31,6 +30,10 @@ |
#import "third_party/ocmock/OCMock/OCMock.h" |
#import "third_party/ocmock/gtest_support.h" |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
using favicon::PostReply; |
using testing::_; |
@@ -43,11 +46,10 @@ class ReadingListCollectionViewControllerTest : public testing::Test { |
testing::StrictMock<favicon::MockFaviconService> mock_favicon_service_; |
std::unique_ptr<ReadingListModelImpl> reading_list_model_; |
- base::scoped_nsobject<ReadingListMediator> mediator_; |
+ ReadingListMediator* mediator_; |
std::unique_ptr<favicon::LargeIconService> large_icon_service_; |
- base::scoped_nsobject<ReadingListCollectionViewController> |
- reading_list_view_controller_; |
+ ReadingListCollectionViewController* reading_list_view_controller_; |
id mock_delegate_; |
stkhapugin
2017/06/02 09:52:33
This has gone from bare pointer to strong, is this
pkl (ping after 24h if needed)
2017/06/02 15:32:55
As discussed on IRC, mock_delegate_ should have be
|
void SetUp() override { |
@@ -59,16 +61,15 @@ class ReadingListCollectionViewControllerTest : public testing::Test { |
reading_list_model_.reset(new ReadingListModelImpl( |
nullptr, nullptr, base::MakeUnique<base::DefaultClock>())); |
- mediator_.reset( |
- [[ReadingListMediator alloc] initWithModel:reading_list_model_.get()]); |
+ mediator_ = |
+ [[ReadingListMediator alloc] initWithModel:reading_list_model_.get()]; |
large_icon_service_.reset(new favicon::LargeIconService( |
&mock_favicon_service_, base::ThreadTaskRunnerHandle::Get(), |
/*image_fetcher=*/nullptr)); |
- reading_list_view_controller_.reset( |
- [[ReadingListCollectionViewController alloc] |
- initWithDataSource:mediator_ |
- largeIconService:large_icon_service_.get() |
- toolbar:nil]); |
+ reading_list_view_controller_ = [[ReadingListCollectionViewController alloc] |
+ initWithDataSource:mediator_ |
+ largeIconService:large_icon_service_.get() |
+ toolbar:nil]; |
mock_delegate_ = [OCMockObject |
niceMockForProtocol:@protocol( |
@@ -96,14 +97,12 @@ TEST_F(ReadingListCollectionViewControllerTest, DisplaysItems) { |
[reading_list_view_controller_ view]; |
// There are two sections: Read and Unread. |
- DCHECK( |
- [reading_list_view_controller_.get().collectionView numberOfSections] == |
- 2); |
+ DCHECK([reading_list_view_controller_.collectionView numberOfSections] == 2); |
// There are two unread articles. |
- DCHECK([reading_list_view_controller_.get().collectionView |
+ DCHECK([reading_list_view_controller_.collectionView |
numberOfItemsInSection:0] == 2); |
// There is one read article. |
- DCHECK([reading_list_view_controller_.get().collectionView |
+ DCHECK([reading_list_view_controller_.collectionView |
numberOfItemsInSection:1] == 1); |
} |
@@ -113,13 +112,17 @@ TEST_F(ReadingListCollectionViewControllerTest, GetsDismissed) { |
[reading_list_view_controller_ view]; |
[[mock_delegate_ expect] |
- dismissReadingListCollectionViewController:reading_list_view_controller_ |
- .get()]; |
+ dismissReadingListCollectionViewController:reading_list_view_controller_]; |
// Simulate tap on "Done" button. |
UIBarButtonItem* done = |
- reading_list_view_controller_.get().navigationItem.rightBarButtonItem; |
+ reading_list_view_controller_.navigationItem.rightBarButtonItem; |
+#pragma clang diagnostic push |
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks" |
+ // Since @selector stored in done.action is a method returning void, there is |
+ // no potential for memory leak. It is OK to ignore this warning here. |
[done.target performSelector:done.action]; |
+#pragma clang diagnostic pop |
EXPECT_OCMOCK_VERIFY(mock_delegate_); |
} |
@@ -142,13 +145,12 @@ TEST_F(ReadingListCollectionViewControllerTest, OpensItems) { |
itemAtIndexPath:indexPath]); |
[[mock_delegate_ expect] |
- readingListCollectionViewController:reading_list_view_controller_.get() |
+ readingListCollectionViewController:reading_list_view_controller_ |
openItem:readingListItem]; |
// Simulate touch on second cell. |
[reading_list_view_controller_ |
- collectionView:reading_list_view_controller_.get() |
- .collectionView |
+ collectionView:reading_list_view_controller_.collectionView |
didSelectItemAtIndexPath:indexPath]; |
EXPECT_OCMOCK_VERIFY(mock_delegate_); |
@@ -165,7 +167,7 @@ TEST_F(ReadingListCollectionViewControllerTest, |
reading_list::ADDED_VIA_CURRENT_APP); |
// Load view. |
[reading_list_view_controller_ view]; |
- DCHECK([reading_list_view_controller_.get().collectionView |
+ DCHECK([reading_list_view_controller_.collectionView |
numberOfItemsInSection:0] == 1); |
NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; |
ReadingListCollectionViewItem* readingListItem = |
@@ -198,7 +200,7 @@ TEST_F(ReadingListCollectionViewControllerTest, |
size, base::Time::FromTimeT(100)); |
// Load view. |
[reading_list_view_controller_ view]; |
- DCHECK([reading_list_view_controller_.get().collectionView |
+ DCHECK([reading_list_view_controller_.collectionView |
numberOfItemsInSection:0] == 1); |
NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; |
ReadingListCollectionViewItem* readingListItem = |