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

Unified Diff: ios/chrome/browser/ui/browser_container_view_unittest.mm

Issue 2588713002: Upstream Chrome on iOS source code [4/11]. (Closed)
Patch Set: Created 4 years 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/chrome/browser/ui/browser_container_view.mm ('k') | ios/chrome/browser/ui/browser_ios.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/browser_container_view_unittest.mm
diff --git a/ios/chrome/browser/ui/browser_container_view_unittest.mm b/ios/chrome/browser/ui/browser_container_view_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f0daef1caadd19e0c002aae9f59bc9603f2b598d
--- /dev/null
+++ b/ios/chrome/browser/ui/browser_container_view_unittest.mm
@@ -0,0 +1,57 @@
+// Copyright 2015 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/chrome/browser/ui/browser_container_view.h"
+
+#import "base/mac/scoped_nsobject.h"
+#include "testing/platform_test.h"
+
+// Fixture for BrowserContainerView testing.
+class BrowserContainerViewTest : public PlatformTest {
+ protected:
+ void SetUp() override {
+ PlatformTest::SetUp();
+
+ browser_container_view_.reset([[BrowserContainerView alloc] init]);
+ ASSERT_TRUE(browser_container_view_);
+ content_view_.reset([[UIView alloc] init]);
+ ASSERT_TRUE(content_view_);
+ }
+ base::scoped_nsobject<BrowserContainerView> browser_container_view_;
+ base::scoped_nsobject<UIView> content_view_;
+};
+
+// Tests adding a new content view when BrowserContainerView does not currently
+// have a content view.
+TEST_F(BrowserContainerViewTest, AddingContentView) {
+ ASSERT_FALSE([content_view_ superview]);
+
+ [browser_container_view_ displayContentView:content_view_];
+ EXPECT_EQ(static_cast<UIView*>(browser_container_view_),
+ [content_view_ superview]);
+}
+
+// Tests removing previously added content view.
+TEST_F(BrowserContainerViewTest, RemovingContentView) {
+ [browser_container_view_ displayContentView:content_view_];
+ ASSERT_EQ(static_cast<UIView*>(browser_container_view_),
+ [content_view_ superview]);
+
+ [browser_container_view_ displayContentView:nil];
+ EXPECT_FALSE([content_view_ superview]);
+}
+
+// Tests adding a new content view when BrowserContainerView already has a
+// content view.
+TEST_F(BrowserContainerViewTest, ReplacingContentView) {
+ [browser_container_view_ displayContentView:content_view_];
+ ASSERT_EQ(static_cast<UIView*>(browser_container_view_),
+ [content_view_ superview]);
+
+ base::scoped_nsobject<UIView> content_view2([[UIView alloc] init]);
+ [browser_container_view_ displayContentView:content_view2];
+ EXPECT_FALSE([content_view_ superview]);
+ EXPECT_EQ(static_cast<UIView*>(browser_container_view_),
+ [content_view2 superview]);
+}
« no previous file with comments | « ios/chrome/browser/ui/browser_container_view.mm ('k') | ios/chrome/browser/ui/browser_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698