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_grid/tab_grid_mediator.h" | 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_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 23 matching lines...) Expand all Loading... |
34 void SetUpEmptyWebStateList() { | 34 void SetUpEmptyWebStateList() { |
35 web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_); | 35 web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_); |
36 } | 36 } |
37 | 37 |
38 void InsertWebStateAt(int index) { | 38 void InsertWebStateAt(int index) { |
39 auto web_state = base::MakeUnique<web::TestWebState>(); | 39 auto web_state = base::MakeUnique<web::TestWebState>(); |
40 web_state_list_->InsertWebState(index, std::move(web_state)); | 40 web_state_list_->InsertWebState(index, std::move(web_state)); |
41 } | 41 } |
42 | 42 |
43 void SetConsumer() { | 43 void SetConsumer() { |
44 consumer_ = [OCMockObject mockForProtocol:@protocol(TabGridConsumer)]; | 44 consumer_ = OCMProtocolMock(@protocol(TabGridConsumer)); |
45 mediator_.consumer = consumer_; | 45 mediator_.consumer = consumer_; |
46 } | 46 } |
47 | 47 |
48 TabGridMediator* mediator_; | 48 TabGridMediator* mediator_; |
49 std::unique_ptr<WebStateList> web_state_list_; | 49 std::unique_ptr<WebStateList> web_state_list_; |
50 FakeWebStateListDelegate web_state_list_delegate_; | 50 FakeWebStateListDelegate web_state_list_delegate_; |
51 id consumer_; | 51 id consumer_; |
52 }; | 52 }; |
53 | 53 |
54 // Tests that the noTabsOverlay is removed when a web state is inserted when | 54 // Tests that the noTabsOverlay is removed when a web state is inserted when |
55 // the list is empty. | 55 // the list is empty. |
56 TEST_F(TabGridMediatorTest, TestRemoveNoTabsOverlay) { | 56 TEST_F(TabGridMediatorTest, TestRemoveNoTabsOverlay) { |
57 SetConsumer(); | 57 SetConsumer(); |
58 [[consumer_ expect] insertItemAtIndex:0]; | |
59 [[consumer_ expect] removeNoTabsOverlay]; | |
60 InsertWebStateAt(0); | 58 InsertWebStateAt(0); |
61 EXPECT_OCMOCK_VERIFY(consumer_); | 59 [[consumer_ verify] removeNoTabsOverlay]; |
62 } | 60 } |
63 | 61 |
64 // Tests that the noTabsOverlay is added when the web state list becomes empty. | 62 // Tests that the noTabsOverlay is added when the web state list becomes empty. |
65 TEST_F(TabGridMediatorTest, TestAddNoTabsOverlay) { | 63 TEST_F(TabGridMediatorTest, TestAddNoTabsOverlay) { |
| 64 SetConsumer(); |
66 InsertWebStateAt(0); | 65 InsertWebStateAt(0); |
67 SetConsumer(); | |
68 [[consumer_ expect] deleteItemAtIndex:0]; | |
69 [[consumer_ expect] addNoTabsOverlay]; | |
70 web_state_list_->CloseWebStateAt(0); | 66 web_state_list_->CloseWebStateAt(0); |
71 EXPECT_OCMOCK_VERIFY(consumer_); | 67 [[consumer_ verify] addNoTabsOverlay]; |
72 } | 68 } |
73 | 69 |
74 } // namespace | 70 } // namespace |
OLD | NEW |