OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.h" | 5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" | 8 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" |
9 #include "ios/chrome/browser/web_state_list/web_state_list.h" | 9 #include "ios/chrome/browser/web_state_list/web_state_list.h" |
10 #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" | 10 #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 TabCollectionMediator* mediator_; | 57 TabCollectionMediator* mediator_; |
58 std::unique_ptr<WebStateList> web_state_list_; | 58 std::unique_ptr<WebStateList> web_state_list_; |
59 FakeWebStateListDelegate web_state_list_delegate_; | 59 FakeWebStateListDelegate web_state_list_delegate_; |
60 id consumer_; | 60 id consumer_; |
61 }; | 61 }; |
62 | 62 |
63 // Tests that the consumer is notified of an insert into webStateList. | 63 // Tests that the consumer is notified of an insert into webStateList. |
64 TEST_F(TabCollectionMediatorTest, TestInsertWebState) { | 64 TEST_F(TabCollectionMediatorTest, TestInsertWebState) { |
65 InsertWebState(2); | 65 InsertWebState(2); |
66 [[consumer_ verify] insertItem:[OCMArg any] atIndex:2]; | 66 [[consumer_ verify] insertItem:[OCMArg any] atIndex:2 selectedIndex:0]; |
67 } | 67 } |
68 | 68 |
69 // Tests that the consumer is notified that a web state has been moved in | 69 // Tests that the consumer is notified that a web state has been moved in |
70 // webStateList. | 70 // webStateList. |
71 TEST_F(TabCollectionMediatorTest, TestMoveWebState) { | 71 TEST_F(TabCollectionMediatorTest, TestMoveWebState) { |
72 web_state_list_->MoveWebStateAt(0, 2); | 72 web_state_list_->MoveWebStateAt(0, 2); |
73 [[consumer_ verify] moveItemFromIndex:0 toIndex:2]; | 73 [[consumer_ verify] moveItemFromIndex:0 toIndex:2 selectedIndex:2]; |
74 } | 74 } |
75 | 75 |
76 // Tests that the consumer is notified that a web state has been replaced in | 76 // Tests that the consumer is notified that a web state has been replaced in |
77 // webStateList. | 77 // webStateList. |
78 TEST_F(TabCollectionMediatorTest, TestReplaceWebState) { | 78 TEST_F(TabCollectionMediatorTest, TestReplaceWebState) { |
79 auto different_web_state = base::MakeUnique<web::TestWebState>(); | 79 auto different_web_state = base::MakeUnique<web::TestWebState>(); |
80 web_state_list_->ReplaceWebStateAt(1, std::move(different_web_state)); | 80 web_state_list_->ReplaceWebStateAt(1, std::move(different_web_state)); |
81 [[consumer_ verify] replaceItemAtIndex:1 withItem:[OCMArg any]]; | 81 [[consumer_ verify] replaceItemAtIndex:1 withItem:[OCMArg any]]; |
82 } | 82 } |
83 | 83 |
84 // Tests that the consumer is notified that a web state has been deleted from | 84 // Tests that the consumer is notified that a web state has been deleted from |
85 // webStateList. | 85 // webStateList. |
86 TEST_F(TabCollectionMediatorTest, TestDetachWebState) { | 86 TEST_F(TabCollectionMediatorTest, TestDetachWebState) { |
87 web_state_list_->CloseWebStateAt(1); | 87 web_state_list_->CloseWebStateAt(1); |
88 [[consumer_ verify] deleteItemAtIndex:1]; | 88 [[consumer_ verify] deleteItemAtIndex:1 selectedIndex:0]; |
89 } | 89 } |
90 | 90 |
91 // Tests that the consumer is notified that the active web state has changed in | 91 // Tests that the consumer is notified that the active web state has changed in |
92 // webStateList. | 92 // webStateList. |
93 TEST_F(TabCollectionMediatorTest, TestChangeActiveWebState) { | 93 TEST_F(TabCollectionMediatorTest, TestChangeActiveWebState) { |
94 web_state_list_->ActivateWebStateAt(2); | 94 web_state_list_->ActivateWebStateAt(2); |
95 [[consumer_ verify] selectItemAtIndex:2]; | 95 [[consumer_ verify] selectItemAtIndex:2]; |
96 } | 96 } |
OLD | NEW |