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.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
10 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 10 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
11 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | 11 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" |
12 #include "chrome/browser/ui/views/frame/top_container_view.h" | 12 #include "chrome/browser/ui/views/frame/top_container_view.h" |
13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 14 #include "chrome/browser/ui/views/layout_constants.h" |
14 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 15 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
15 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
17 #include "ui/views/controls/single_split_view.h" | 18 #include "ui/views/controls/single_split_view.h" |
18 #include "ui/views/controls/webview/webview.h" | 19 #include "ui/views/controls/webview/webview.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Tab strip bounds depend on the window frame sizes. | 23 // Tab strip bounds depend on the window frame sizes. |
23 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { | 24 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 87 |
87 // Verify basic layout. | 88 // Verify basic layout. |
88 EXPECT_EQ(0, top_container->x()); | 89 EXPECT_EQ(0, top_container->x()); |
89 EXPECT_EQ(0, top_container->y()); | 90 EXPECT_EQ(0, top_container->y()); |
90 EXPECT_EQ(browser_view()->width(), top_container->width()); | 91 EXPECT_EQ(browser_view()->width(), top_container->width()); |
91 // Tabstrip layout varies based on window frame sizes. | 92 // Tabstrip layout varies based on window frame sizes. |
92 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); | 93 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); |
93 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); | 94 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); |
94 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); | 95 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); |
95 EXPECT_EQ(0, toolbar->x()); | 96 EXPECT_EQ(0, toolbar->x()); |
96 EXPECT_EQ( | 97 const int overlap = GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP); |
97 tabstrip->bounds().bottom() - | 98 EXPECT_EQ(tabstrip->bounds().bottom() - overlap, toolbar->y()); |
98 BrowserViewLayout::kToolbarTabStripVerticalOverlap, | |
99 toolbar->y()); | |
100 EXPECT_EQ(0, contents_container->x()); | 99 EXPECT_EQ(0, contents_container->x()); |
101 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); | 100 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); |
102 EXPECT_EQ(top_container->bounds().bottom(), contents_container->y()); | 101 EXPECT_EQ(top_container->bounds().bottom(), contents_container->y()); |
103 EXPECT_EQ(0, devtools_web_view->x()); | 102 EXPECT_EQ(0, devtools_web_view->x()); |
104 EXPECT_EQ(0, devtools_web_view->y()); | 103 EXPECT_EQ(0, devtools_web_view->y()); |
105 EXPECT_EQ(0, contents_web_view->x()); | 104 EXPECT_EQ(0, contents_web_view->x()); |
106 EXPECT_EQ(0, contents_web_view->y()); | 105 EXPECT_EQ(0, contents_web_view->y()); |
107 | 106 |
108 // Verify bookmark bar visibility. | 107 // Verify bookmark bar visibility. |
109 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); | 108 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); |
(...skipping 16 matching lines...) Expand all Loading... |
126 // Find bar host is still at the front of the view hierarchy, followed by | 125 // Find bar host is still at the front of the view hierarchy, followed by |
127 // the top container. | 126 // the top container. |
128 EXPECT_EQ(browser_view()->child_count() - 1, | 127 EXPECT_EQ(browser_view()->child_count() - 1, |
129 browser_view()->GetIndexOf(browser_view()->find_bar_host_view())); | 128 browser_view()->GetIndexOf(browser_view()->find_bar_host_view())); |
130 EXPECT_EQ(browser_view()->child_count() - 2, | 129 EXPECT_EQ(browser_view()->child_count() - 2, |
131 browser_view()->GetIndexOf(top_container)); | 130 browser_view()->GetIndexOf(top_container)); |
132 | 131 |
133 // Bookmark bar layout on NTP. | 132 // Bookmark bar layout on NTP. |
134 EXPECT_EQ(0, bookmark_bar->x()); | 133 EXPECT_EQ(0, bookmark_bar->x()); |
135 EXPECT_EQ( | 134 EXPECT_EQ( |
136 tabstrip->bounds().bottom() + | 135 tabstrip->bounds().bottom() + toolbar->height() - overlap - |
137 toolbar->height() - | |
138 BrowserViewLayout::kToolbarTabStripVerticalOverlap - | |
139 views::NonClientFrameView::kClientEdgeThickness, | 136 views::NonClientFrameView::kClientEdgeThickness, |
140 bookmark_bar->y()); | 137 bookmark_bar->y()); |
141 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); | 138 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); |
142 // Contents view has a "top margin" pushing it below the bookmark bar. | 139 // Contents view has a "top margin" pushing it below the bookmark bar. |
143 EXPECT_EQ(bookmark_bar->height() - | 140 EXPECT_EQ(bookmark_bar->height() - |
144 views::NonClientFrameView::kClientEdgeThickness, | 141 views::NonClientFrameView::kClientEdgeThickness, |
145 devtools_web_view->y()); | 142 devtools_web_view->y()); |
146 EXPECT_EQ(bookmark_bar->height() - | 143 EXPECT_EQ(bookmark_bar->height() - |
147 views::NonClientFrameView::kClientEdgeThickness, | 144 views::NonClientFrameView::kClientEdgeThickness, |
148 contents_web_view->y()); | 145 contents_web_view->y()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 header_offset.y(); | 197 header_offset.y(); |
201 | 198 |
202 // The web contents should be flush with the bottom of the header. | 199 // The web contents should be flush with the bottom of the header. |
203 EXPECT_EQ(bottom_of_header, contents_container->y()); | 200 EXPECT_EQ(bottom_of_header, contents_container->y()); |
204 | 201 |
205 // The find bar should overlap the 1px header/web-contents separator at the | 202 // The find bar should overlap the 1px header/web-contents separator at the |
206 // bottom of the header. | 203 // bottom of the header. |
207 EXPECT_EQ(browser_view()->frame()->GetTopInset() - 1, | 204 EXPECT_EQ(browser_view()->frame()->GetTopInset() - 1, |
208 browser_view()->GetFindBarBoundingBox().y()); | 205 browser_view()->GetFindBarBoundingBox().y()); |
209 } | 206 } |
OLD | NEW |