browser_view_layout_unittest.cc revision a93a17c8d99d686bd4a1511e5504e5e6cc9fcadf
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/views/frame/browser_view_layout.h"
6
7#include "chrome/browser/ui/views/frame/browser_view.h"
8#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
9#include "chrome/test/base/browser_with_test_window_test.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12// Tests of BrowserViewLayout. Runs tests without constructing a BrowserView.
13class BrowserViewLayoutTest : public BrowserWithTestWindowTest {
14 public:
15  BrowserViewLayoutTest() {}
16  virtual ~BrowserViewLayoutTest() {}
17
18  virtual void SetUp() OVERRIDE {
19    BrowserWithTestWindowTest::SetUp();
20
21    // Because we have a TestBrowserWindow, not a BrowserView, |layout_| is
22    // not attached to a host view.
23    layout_.reset(new BrowserViewLayout);
24    infobar_container_.reset(new InfoBarContainerView(NULL, NULL));
25    layout_->Init(browser(),
26                  NULL,
27                  infobar_container_.get(),
28                  NULL,
29                  NULL,
30                  NULL);
31  }
32
33  BrowserViewLayout* layout() { return layout_.get(); }
34
35 private:
36  scoped_ptr<BrowserViewLayout> layout_;
37  scoped_ptr<InfoBarContainerView> infobar_container_;
38
39  DISALLOW_COPY_AND_ASSIGN(BrowserViewLayoutTest);
40};
41
42// Test basic construction and initialization.
43TEST_F(BrowserViewLayoutTest, BrowserViewLayout) {
44  EXPECT_TRUE(layout()->browser());
45  EXPECT_TRUE(layout()->GetWebContentsModalDialogHost());
46  EXPECT_EQ(BrowserViewLayout::kInstantUINone, layout()->GetInstantUIState());
47  EXPECT_FALSE(layout()->InfobarVisible());
48  // TODO(jamescook): Add more as we break dependencies.
49}
50
51// Test the core layout functions.
52TEST_F(BrowserViewLayoutTest, Layout) {
53  // We don't have a bookmark bar yet, so no contents offset is required.
54  EXPECT_EQ(0, layout()->GetContentsOffsetForBookmarkBar());
55  EXPECT_EQ(0, layout()->GetTopMarginForActiveContent());
56  // TODO(jamescook): Add more as we break dependencies.
57}
58