Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator_unittest.mm

Issue 2792823002: [ios] Unittest for TabGridMediator. (Closed)
Patch Set: Update Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.mm ('k') | ios/clean/chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.mm ('k') | ios/clean/chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698