Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator_unittest.mm |
| diff --git a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator_unittest.mm b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator_unittest.mm |
| index 01adf284cb4c7267eb47d52e3f7dfda80d7a7905..5865ebfdd4d47b71ecf6f4d27a257b8b3687027b 100644 |
| --- a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator_unittest.mm |
| +++ b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator_unittest.mm |
| @@ -28,7 +28,8 @@ class TabCollectionMediatorTest : public PlatformTest { |
| SetUpWebStateList(); |
| mediator_ = [[TabCollectionMediator alloc] init]; |
| mediator_.webStateList = web_state_list_.get(); |
| - consumer_ = [OCMockObject mockForProtocol:@protocol(TabCollectionConsumer)]; |
| + consumer_ = |
| + [OCMockObject niceMockForProtocol:@protocol(TabCollectionConsumer)]; |
|
sczs
2017/05/18 16:11:02
nit: What about using OCMProtocolMock(@protocol(Ta
edchin
2017/05/18 17:30:26
Done.
|
| mediator_.consumer = consumer_; |
| } |
| ~TabCollectionMediatorTest() override { [mediator_ disconnect]; } |
| @@ -60,67 +61,37 @@ class TabCollectionMediatorTest : public PlatformTest { |
| id consumer_; |
| }; |
| -// Tests that -numberOfTabs returns the expected number of elements from |
| -// web_state_list_. |
| -TEST_F(TabCollectionMediatorTest, TestNumberOfTabs) { |
| - EXPECT_EQ(3, [mediator_ numberOfTabs]); |
| -} |
| - |
| -// Tests that -indexOfActiveTab returns the expected active_index from |
| -// web_state_list_. |
| -TEST_F(TabCollectionMediatorTest, TestActiveTabIndex) { |
| - EXPECT_EQ(0, [mediator_ indexOfActiveTab]); |
| -} |
| - |
| -// Tests that -titleAtIndex: returns the expected title from web_state_list_. |
| -TEST_F(TabCollectionMediatorTest, TestTitleAtIndex) { |
| - EXPECT_NSEQ(@"http://test/0", [mediator_ titleAtIndex:0]); |
| -} |
| - |
| // Tests that the consumer is notified of an insert into webStateList. |
| TEST_F(TabCollectionMediatorTest, TestInsertWebState) { |
| - [[consumer_ expect] insertItemAtIndex:2]; |
| InsertWebState(2); |
| - EXPECT_OCMOCK_VERIFY(consumer_); |
| + [[consumer_ verify] insertItem:[OCMArg any] atIndex:2]; |
| } |
| // Tests that the consumer is notified that a web state has been moved in |
| // webStateList. |
| TEST_F(TabCollectionMediatorTest, TestMoveWebState) { |
| - NSMutableIndexSet* indexes = [NSMutableIndexSet indexSet]; |
| - [indexes addIndex:0]; |
| - [indexes addIndex:1]; |
| - [indexes addIndex:2]; |
| - [[consumer_ expect] reloadItemsAtIndexes:indexes]; |
| web_state_list_->MoveWebStateAt(0, 2); |
| - EXPECT_OCMOCK_VERIFY(consumer_); |
| + [[consumer_ verify] moveItemFromIndex:0 toIndex:2]; |
| } |
| // Tests that the consumer is notified that a web state has been replaced in |
| // webStateList. |
| TEST_F(TabCollectionMediatorTest, TestReplaceWebState) { |
| - NSIndexSet* indexes = [NSIndexSet indexSetWithIndex:1]; |
| - [[consumer_ expect] reloadItemsAtIndexes:indexes]; |
| auto different_web_state = base::MakeUnique<web::TestWebState>(); |
| web_state_list_->ReplaceWebStateAt(1, std::move(different_web_state)); |
| - EXPECT_OCMOCK_VERIFY(consumer_); |
| + [[consumer_ verify] replaceItemAtIndex:1 withItem:[OCMArg any]]; |
| } |
| // Tests that the consumer is notified that a web state has been deleted from |
| // webStateList. |
| TEST_F(TabCollectionMediatorTest, TestDetachWebState) { |
| - [[consumer_ expect] deleteItemAtIndex:1]; |
| web_state_list_->CloseWebStateAt(1); |
| - EXPECT_OCMOCK_VERIFY(consumer_); |
| + [[consumer_ verify] deleteItemAtIndex:1]; |
| } |
| // Tests that the consumer is notified that the active web state has changed in |
| // webStateList. |
| TEST_F(TabCollectionMediatorTest, TestChangeActiveWebState) { |
| - NSMutableIndexSet* indexes = [NSMutableIndexSet indexSet]; |
| - [indexes addIndex:0]; |
| - [indexes addIndex:2]; |
| - [[consumer_ expect] reloadItemsAtIndexes:indexes]; |
| web_state_list_->ActivateWebStateAt(2); |
| - EXPECT_OCMOCK_VERIFY(consumer_); |
| + [[consumer_ verify] selectItemAtIndex:2]; |
| } |