| Index: ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator_unittest.mm
|
| diff --git a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator_unittest.mm b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator_unittest.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ef8e2871a7872ccfd97a4eac86f79e82898d3b25
|
| --- /dev/null
|
| +++ b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator_unittest.mm
|
| @@ -0,0 +1,74 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.h"
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_consumer.h"
|
| +#include "ios/shared/chrome/browser/tabs/fake_web_state_list_delegate.h"
|
| +#include "ios/shared/chrome/browser/tabs/web_state_list.h"
|
| +#import "ios/shared/chrome/browser/tabs/web_state_list_observer_bridge.h"
|
| +#import "ios/web/public/test/fakes/test_navigation_manager.h"
|
| +#import "ios/web/public/test/fakes/test_web_state.h"
|
| +#include "testing/platform_test.h"
|
| +#import "third_party/ocmock/OCMock/OCMock.h"
|
| +#include "third_party/ocmock/gtest_support.h"
|
| +
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| +namespace {
|
| +
|
| +class TabGridMediatorTest : public PlatformTest {
|
| + public:
|
| + TabGridMediatorTest() {
|
| + SetUpEmptyWebStateList();
|
| + mediator_ = [[TabGridMediator alloc] init];
|
| + mediator_.webStateList = web_state_list_.get();
|
| + }
|
| + ~TabGridMediatorTest() override { [mediator_ disconnect]; }
|
| +
|
| + protected:
|
| + void SetUpEmptyWebStateList() {
|
| + web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_);
|
| + }
|
| +
|
| + void InsertWebStateAt(int index) {
|
| + auto web_state = base::MakeUnique<web::TestWebState>();
|
| + web_state_list_->InsertWebState(index, std::move(web_state));
|
| + }
|
| +
|
| + void SetConsumer() {
|
| + consumer_ = [OCMockObject mockForProtocol:@protocol(TabGridConsumer)];
|
| + mediator_.consumer = consumer_;
|
| + }
|
| +
|
| + TabGridMediator* mediator_;
|
| + std::unique_ptr<WebStateList> web_state_list_;
|
| + FakeWebStateListDelegate web_state_list_delegate_;
|
| + id consumer_;
|
| +};
|
| +
|
| +// Tests that the noTabsOverlay is removed when a web state is inserted when
|
| +// the list is empty.
|
| +TEST_F(TabGridMediatorTest, TestRemoveNoTabsOverlay) {
|
| + SetConsumer();
|
| + [[consumer_ expect] insertItemAtIndex:0];
|
| + [[consumer_ expect] removeNoTabsOverlay];
|
| + InsertWebStateAt(0);
|
| + EXPECT_OCMOCK_VERIFY(consumer_);
|
| +}
|
| +
|
| +// Tests that the noTabsOverlay is added when the web state list becomes empty.
|
| +TEST_F(TabGridMediatorTest, TestAddNoTabsOverlay) {
|
| + InsertWebStateAt(0);
|
| + SetConsumer();
|
| + [[consumer_ expect] deleteItemAtIndex:0];
|
| + [[consumer_ expect] addNoTabsOverlay];
|
| + web_state_list_->CloseWebStateAt(0);
|
| + EXPECT_OCMOCK_VERIFY(consumer_);
|
| +}
|
| +
|
| +} // namespace
|
|
|