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

Unified Diff: chrome/browser/ui/views/frame/browser_view_layout_unittest.cc

Issue 14348011: Add a unit test for BrowserViewLayout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « chrome/browser/ui/views/frame/browser_view_layout.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
diff --git a/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc b/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e748d432a53b8aae1e75310f2417e680ca476292
--- /dev/null
+++ b/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
@@ -0,0 +1,58 @@
+// Copyright 2013 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.
+
+#include "chrome/browser/ui/views/frame/browser_view_layout.h"
+
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Tests of the LayoutManger for BrowserView.
+class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
+ public:
+ BrowserViewLayoutTest() : layout_(NULL) {}
+ virtual ~BrowserViewLayoutTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ // BrowserWithTestWindowTest takes ownership of BrowserView via |window_|.
+ BrowserView* browser_view = new BrowserView;
+ set_window(browser_view);
+
+ // Creates a Browser using |browser_view| as its BrowserWindow.
+ BrowserWithTestWindowTest::SetUp();
+
+ // Memory ownership is tricky here. BrowserView needs ownership of
+ // |browser|, so BrowserWithTestWindowTest cannot continue to own it.
+ Browser* browser = release_browser();
+ browser_view->Init(browser);
+
+ // BrowserView also takes ownership of |layout_|.
+ layout_ = new BrowserViewLayout(browser);
+ browser_view->SetLayoutManager(layout_);
+ }
+
+ BrowserViewLayout* layout() { return layout_; }
+
+ private:
+ BrowserViewLayout* layout_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserViewLayoutTest);
+};
+
+// Test basic construction and initialization.
+TEST_F(BrowserViewLayoutTest, BrowserViewLayout) {
+ EXPECT_TRUE(layout()->browser());
+ EXPECT_TRUE(layout()->GetWebContentsModalDialogHost());
+ EXPECT_EQ(BrowserViewLayout::kInstantUINone, layout()->GetInstantUIState());
+ // TODO(jamescook): Add more as we break dependencies.
+}
+
+// Test the core layout functions.
+TEST_F(BrowserViewLayoutTest, Layout) {
+ // We don't have a bookmark bar yet, so no contents offset is required.
+ EXPECT_EQ(0, layout()->GetContentsOffsetForBookmarkBar());
+ EXPECT_EQ(0, layout()->GetTopMarginForActiveContent());
+ EXPECT_EQ(0, layout()->GetTopMarginForOverlayContent());
+ // TODO(jamescook): Add more as we break dependencies.
+}
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698