OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/frame/browser_view.h" | 7 #include "chrome/browser/ui/views/frame/browser_view.h" |
8 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | 8 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" |
9 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" | 9 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" |
10 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 10 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 tab_strip_visible_ = visible; | 31 tab_strip_visible_ = visible; |
32 } | 32 } |
33 void set_toolbar_visible(bool visible) { | 33 void set_toolbar_visible(bool visible) { |
34 toolbar_visible_ = visible; | 34 toolbar_visible_ = visible; |
35 } | 35 } |
36 void set_bookmark_bar_visible(bool visible) { | 36 void set_bookmark_bar_visible(bool visible) { |
37 bookmark_bar_visible_ = visible; | 37 bookmark_bar_visible_ = visible; |
38 } | 38 } |
39 | 39 |
40 // BrowserViewLayout::Delegate overrides: | 40 // BrowserViewLayout::Delegate overrides: |
41 virtual views::View* GetContentsWebView() const OVERRIDE { | 41 virtual views::View* GetContentsWebView() const override { |
42 return contents_web_view_; | 42 return contents_web_view_; |
43 } | 43 } |
44 virtual bool IsTabStripVisible() const OVERRIDE { | 44 virtual bool IsTabStripVisible() const override { |
45 return tab_strip_visible_; | 45 return tab_strip_visible_; |
46 } | 46 } |
47 virtual gfx::Rect GetBoundsForTabStripInBrowserView() const OVERRIDE { | 47 virtual gfx::Rect GetBoundsForTabStripInBrowserView() const override { |
48 return gfx::Rect(); | 48 return gfx::Rect(); |
49 } | 49 } |
50 virtual int GetTopInsetInBrowserView() const OVERRIDE { | 50 virtual int GetTopInsetInBrowserView() const override { |
51 return 0; | 51 return 0; |
52 } | 52 } |
53 virtual int GetThemeBackgroundXInset() const OVERRIDE { | 53 virtual int GetThemeBackgroundXInset() const override { |
54 return 0; | 54 return 0; |
55 } | 55 } |
56 virtual bool IsToolbarVisible() const OVERRIDE { | 56 virtual bool IsToolbarVisible() const override { |
57 return toolbar_visible_; | 57 return toolbar_visible_; |
58 } | 58 } |
59 virtual bool IsBookmarkBarVisible() const OVERRIDE { | 59 virtual bool IsBookmarkBarVisible() const override { |
60 return bookmark_bar_visible_; | 60 return bookmark_bar_visible_; |
61 } | 61 } |
62 virtual bool DownloadShelfNeedsLayout() const OVERRIDE { | 62 virtual bool DownloadShelfNeedsLayout() const override { |
63 return download_shelf_needs_layout_; | 63 return download_shelf_needs_layout_; |
64 } | 64 } |
65 | 65 |
66 virtual FullscreenExitBubbleViews* GetFullscreenExitBubble() const OVERRIDE { | 66 virtual FullscreenExitBubbleViews* GetFullscreenExitBubble() const override { |
67 return NULL; | 67 return NULL; |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 views::View* contents_web_view_; | 71 views::View* contents_web_view_; |
72 bool tab_strip_visible_; | 72 bool tab_strip_visible_; |
73 bool toolbar_visible_; | 73 bool toolbar_visible_; |
74 bool bookmark_bar_visible_; | 74 bool bookmark_bar_visible_; |
75 bool download_shelf_needs_layout_; | 75 bool download_shelf_needs_layout_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(MockBrowserViewLayoutDelegate); | 77 DISALLOW_COPY_AND_ASSIGN(MockBrowserViewLayoutDelegate); |
78 }; | 78 }; |
79 | 79 |
80 /////////////////////////////////////////////////////////////////////////////// | 80 /////////////////////////////////////////////////////////////////////////////// |
81 | 81 |
82 // A simple view that prefers an initial size. | 82 // A simple view that prefers an initial size. |
83 class MockView : public views::View { | 83 class MockView : public views::View { |
84 public: | 84 public: |
85 explicit MockView(gfx::Size initial_size) | 85 explicit MockView(gfx::Size initial_size) |
86 : size_(initial_size) { | 86 : size_(initial_size) { |
87 SetBoundsRect(gfx::Rect(gfx::Point(), size_)); | 87 SetBoundsRect(gfx::Rect(gfx::Point(), size_)); |
88 } | 88 } |
89 virtual ~MockView() {} | 89 virtual ~MockView() {} |
90 | 90 |
91 // views::View overrides: | 91 // views::View overrides: |
92 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 92 virtual gfx::Size GetPreferredSize() const override { |
93 return size_; | 93 return size_; |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 gfx::Size size_; | 97 gfx::Size size_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(MockView); | 99 DISALLOW_COPY_AND_ASSIGN(MockView); |
100 }; | 100 }; |
101 | 101 |
102 /////////////////////////////////////////////////////////////////////////////// | 102 /////////////////////////////////////////////////////////////////////////////// |
103 | 103 |
104 class MockImmersiveModeController : public ImmersiveModeController { | 104 class MockImmersiveModeController : public ImmersiveModeController { |
105 public: | 105 public: |
106 MockImmersiveModeController() {} | 106 MockImmersiveModeController() {} |
107 virtual ~MockImmersiveModeController() {} | 107 virtual ~MockImmersiveModeController() {} |
108 | 108 |
109 // ImmersiveModeController overrides: | 109 // ImmersiveModeController overrides: |
110 virtual void Init(BrowserView* browser_view) OVERRIDE {} | 110 virtual void Init(BrowserView* browser_view) override {} |
111 virtual void SetEnabled(bool enabled) OVERRIDE {} | 111 virtual void SetEnabled(bool enabled) override {} |
112 virtual bool IsEnabled() const OVERRIDE { return false; } | 112 virtual bool IsEnabled() const override { return false; } |
113 virtual bool ShouldHideTabIndicators() const OVERRIDE { return false; } | 113 virtual bool ShouldHideTabIndicators() const override { return false; } |
114 virtual bool ShouldHideTopViews() const OVERRIDE { return false; } | 114 virtual bool ShouldHideTopViews() const override { return false; } |
115 virtual bool IsRevealed() const OVERRIDE { return false; } | 115 virtual bool IsRevealed() const override { return false; } |
116 virtual int GetTopContainerVerticalOffset( | 116 virtual int GetTopContainerVerticalOffset( |
117 const gfx::Size& top_container_size) const OVERRIDE { return 0; } | 117 const gfx::Size& top_container_size) const override { return 0; } |
118 virtual ImmersiveRevealedLock* GetRevealedLock( | 118 virtual ImmersiveRevealedLock* GetRevealedLock( |
119 AnimateReveal animate_reveal) OVERRIDE WARN_UNUSED_RESULT { return NULL; } | 119 AnimateReveal animate_reveal) override WARN_UNUSED_RESULT { return NULL; } |
120 virtual void OnFindBarVisibleBoundsChanged( | 120 virtual void OnFindBarVisibleBoundsChanged( |
121 const gfx::Rect& new_visible_bounds) OVERRIDE {} | 121 const gfx::Rect& new_visible_bounds) override {} |
122 virtual void SetupForTest() OVERRIDE {} | 122 virtual void SetupForTest() override {} |
123 | 123 |
124 private: | 124 private: |
125 DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeController); | 125 DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeController); |
126 }; | 126 }; |
127 | 127 |
128 /////////////////////////////////////////////////////////////////////////////// | 128 /////////////////////////////////////////////////////////////////////////////// |
129 // Tests of BrowserViewLayout. Runs tests without constructing a BrowserView. | 129 // Tests of BrowserViewLayout. Runs tests without constructing a BrowserView. |
130 class BrowserViewLayoutTest : public BrowserWithTestWindowTest { | 130 class BrowserViewLayoutTest : public BrowserWithTestWindowTest { |
131 public: | 131 public: |
132 BrowserViewLayoutTest() | 132 BrowserViewLayoutTest() |
(...skipping 10 matching lines...) Expand all Loading... |
143 BrowserViewLayout* layout() { return layout_.get(); } | 143 BrowserViewLayout* layout() { return layout_.get(); } |
144 MockBrowserViewLayoutDelegate* delegate() { return delegate_; } | 144 MockBrowserViewLayoutDelegate* delegate() { return delegate_; } |
145 MockView* root_view() { return root_view_.get(); } | 145 MockView* root_view() { return root_view_.get(); } |
146 MockView* top_container() { return top_container_; } | 146 MockView* top_container() { return top_container_; } |
147 TabStrip* tab_strip() { return tab_strip_; } | 147 TabStrip* tab_strip() { return tab_strip_; } |
148 MockView* toolbar() { return toolbar_; } | 148 MockView* toolbar() { return toolbar_; } |
149 InfoBarContainerView* infobar_container() { return infobar_container_; } | 149 InfoBarContainerView* infobar_container() { return infobar_container_; } |
150 MockView* contents_container() { return contents_container_; } | 150 MockView* contents_container() { return contents_container_; } |
151 | 151 |
152 // BrowserWithTestWindowTest overrides: | 152 // BrowserWithTestWindowTest overrides: |
153 virtual void SetUp() OVERRIDE { | 153 virtual void SetUp() override { |
154 BrowserWithTestWindowTest::SetUp(); | 154 BrowserWithTestWindowTest::SetUp(); |
155 | 155 |
156 root_view_.reset(new MockView(gfx::Size(800, 600))); | 156 root_view_.reset(new MockView(gfx::Size(800, 600))); |
157 | 157 |
158 immersive_mode_controller_.reset(new MockImmersiveModeController); | 158 immersive_mode_controller_.reset(new MockImmersiveModeController); |
159 | 159 |
160 top_container_ = new MockView(gfx::Size(800, 60)); | 160 top_container_ = new MockView(gfx::Size(800, 60)); |
161 tab_strip_ = new TabStrip(NULL); | 161 tab_strip_ = new TabStrip(NULL); |
162 top_container_->AddChildView(tab_strip_); | 162 top_container_->AddChildView(tab_strip_); |
163 toolbar_ = new MockView(gfx::Size(800, 30)); | 163 toolbar_ = new MockView(gfx::Size(800, 30)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 const int kBottom = 500; | 258 const int kBottom = 500; |
259 EXPECT_EQ(kBottom, layout()->LayoutDownloadShelf(kBottom)); | 259 EXPECT_EQ(kBottom, layout()->LayoutDownloadShelf(kBottom)); |
260 | 260 |
261 // Download shelf layout moves up the bottom edge and sets visibility. | 261 // Download shelf layout moves up the bottom edge and sets visibility. |
262 delegate()->set_download_shelf_needs_layout(true); | 262 delegate()->set_download_shelf_needs_layout(true); |
263 download_shelf->SetVisible(false); | 263 download_shelf->SetVisible(false); |
264 EXPECT_EQ(450, layout()->LayoutDownloadShelf(kBottom)); | 264 EXPECT_EQ(450, layout()->LayoutDownloadShelf(kBottom)); |
265 EXPECT_TRUE(download_shelf->visible()); | 265 EXPECT_TRUE(download_shelf->visible()); |
266 EXPECT_EQ("0,450 0x50", download_shelf->bounds().ToString()); | 266 EXPECT_EQ("0,450 0x50", download_shelf->bounds().ToString()); |
267 } | 267 } |
OLD | NEW |