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/contents_container.h" |
| 12 #include "chrome/browser/ui/views/frame/devtools_container.h" |
11 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | 13 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" |
12 #include "chrome/browser/ui/views/frame/top_container_view.h" | 14 #include "chrome/browser/ui/views/frame/top_container_view.h" |
13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
14 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 16 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
15 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
17 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
18 #include "ui/views/controls/single_split_view.h" | 20 #include "ui/views/controls/single_split_view.h" |
19 #include "ui/views/controls/webview/webview.h" | 21 #include "ui/views/controls/webview/webview.h" |
20 | 22 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 62 |
61 // Test layout of the top-of-window UI. | 63 // Test layout of the top-of-window UI. |
62 TEST_F(BrowserViewTest, BrowserViewLayout) { | 64 TEST_F(BrowserViewTest, BrowserViewLayout) { |
63 BookmarkBarView::DisableAnimationsForTesting(true); | 65 BookmarkBarView::DisableAnimationsForTesting(true); |
64 | 66 |
65 // |browser_view_| owns the Browser, not the test class. | 67 // |browser_view_| owns the Browser, not the test class. |
66 Browser* browser = browser_view()->browser(); | 68 Browser* browser = browser_view()->browser(); |
67 TopContainerView* top_container = browser_view()->top_container(); | 69 TopContainerView* top_container = browser_view()->top_container(); |
68 TabStrip* tabstrip = browser_view()->tabstrip(); | 70 TabStrip* tabstrip = browser_view()->tabstrip(); |
69 ToolbarView* toolbar = browser_view()->toolbar(); | 71 ToolbarView* toolbar = browser_view()->toolbar(); |
70 views::SingleSplitView* contents_split = | 72 ContentsContainer* contents_container = |
71 browser_view()->GetContentsSplitForTest(); | 73 browser_view()->GetContentsContainerForTest(); |
| 74 DevToolsContainer* devtools_container = |
| 75 browser_view()->GetDevToolsContainerForTest(); |
72 views::WebView* contents_web_view = | 76 views::WebView* contents_web_view = |
73 browser_view()->GetContentsWebViewForTest(); | 77 browser_view()->GetContentsWebViewForTest(); |
74 | 78 |
75 // Start with a single tab open to a normal page. | 79 // Start with a single tab open to a normal page. |
76 AddTab(browser, GURL("about:blank")); | 80 AddTab(browser, GURL("about:blank")); |
77 | 81 |
78 // Verify the view hierarchy. | 82 // Verify the view hierarchy. |
79 EXPECT_EQ(top_container, browser_view()->tabstrip()->parent()); | 83 EXPECT_EQ(top_container, browser_view()->tabstrip()->parent()); |
80 EXPECT_EQ(top_container, browser_view()->toolbar()->parent()); | 84 EXPECT_EQ(top_container, browser_view()->toolbar()->parent()); |
81 EXPECT_EQ(top_container, browser_view()->GetBookmarkBarView()->parent()); | 85 EXPECT_EQ(top_container, browser_view()->GetBookmarkBarView()->parent()); |
(...skipping 12 matching lines...) Expand all Loading... |
94 EXPECT_EQ(browser_view()->width(), top_container->width()); | 98 EXPECT_EQ(browser_view()->width(), top_container->width()); |
95 // Tabstrip layout varies based on window frame sizes. | 99 // Tabstrip layout varies based on window frame sizes. |
96 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); | 100 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); |
97 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); | 101 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); |
98 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); | 102 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); |
99 EXPECT_EQ(0, toolbar->x()); | 103 EXPECT_EQ(0, toolbar->x()); |
100 EXPECT_EQ( | 104 EXPECT_EQ( |
101 tabstrip->bounds().bottom() - | 105 tabstrip->bounds().bottom() - |
102 BrowserViewLayout::kToolbarTabStripVerticalOverlap, | 106 BrowserViewLayout::kToolbarTabStripVerticalOverlap, |
103 toolbar->y()); | 107 toolbar->y()); |
104 EXPECT_EQ(0, contents_split->x()); | 108 EXPECT_EQ(0, contents_container->x()); |
105 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y()); | 109 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); |
| 110 EXPECT_EQ(0, devtools_container->x()); |
| 111 EXPECT_EQ(0, devtools_container->y()); |
106 EXPECT_EQ(0, contents_web_view->x()); | 112 EXPECT_EQ(0, contents_web_view->x()); |
107 EXPECT_EQ(0, contents_web_view->y()); | 113 EXPECT_EQ(0, contents_web_view->y()); |
108 | 114 |
109 // Verify bookmark bar visibility. | 115 // Verify bookmark bar visibility. |
110 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); | 116 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); |
111 EXPECT_FALSE(bookmark_bar->visible()); | 117 EXPECT_FALSE(bookmark_bar->visible()); |
112 EXPECT_FALSE(bookmark_bar->IsDetached()); | 118 EXPECT_FALSE(bookmark_bar->IsDetached()); |
113 chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR); | 119 chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR); |
114 EXPECT_TRUE(bookmark_bar->visible()); | 120 EXPECT_TRUE(bookmark_bar->visible()); |
115 EXPECT_FALSE(bookmark_bar->IsDetached()); | 121 EXPECT_FALSE(bookmark_bar->IsDetached()); |
(...skipping 16 matching lines...) Expand all Loading... |
132 browser_view()->GetIndexOf(top_container)); | 138 browser_view()->GetIndexOf(top_container)); |
133 | 139 |
134 // Bookmark bar layout on NTP. | 140 // Bookmark bar layout on NTP. |
135 EXPECT_EQ(0, bookmark_bar->x()); | 141 EXPECT_EQ(0, bookmark_bar->x()); |
136 EXPECT_EQ( | 142 EXPECT_EQ( |
137 tabstrip->bounds().bottom() + | 143 tabstrip->bounds().bottom() + |
138 toolbar->height() - | 144 toolbar->height() - |
139 BrowserViewLayout::kToolbarTabStripVerticalOverlap - | 145 BrowserViewLayout::kToolbarTabStripVerticalOverlap - |
140 views::NonClientFrameView::kClientEdgeThickness, | 146 views::NonClientFrameView::kClientEdgeThickness, |
141 bookmark_bar->y()); | 147 bookmark_bar->y()); |
142 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y()); | 148 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); |
143 // Contents view has a "top margin" pushing it below the bookmark bar. | 149 // Contents view has a "top margin" pushing it below the bookmark bar. |
144 EXPECT_EQ(bookmark_bar->height() - | 150 EXPECT_EQ(bookmark_bar->height() - |
145 views::NonClientFrameView::kClientEdgeThickness, | 151 views::NonClientFrameView::kClientEdgeThickness, |
146 contents_web_view->y()); | 152 devtools_container->y()); |
| 153 EXPECT_EQ(0, contents_web_view->y()); |
147 | 154 |
148 // Bookmark bar is parented back to top container on normal page. | 155 // Bookmark bar is parented back to top container on normal page. |
149 NavigateAndCommitActiveTabWithTitle(browser, | 156 NavigateAndCommitActiveTabWithTitle(browser, |
150 GURL("about:blank"), | 157 GURL("about:blank"), |
151 string16()); | 158 string16()); |
152 EXPECT_FALSE(bookmark_bar->visible()); | 159 EXPECT_FALSE(bookmark_bar->visible()); |
153 EXPECT_FALSE(bookmark_bar->IsDetached()); | 160 EXPECT_FALSE(bookmark_bar->IsDetached()); |
154 EXPECT_EQ(top_container, bookmark_bar->parent()); | 161 EXPECT_EQ(top_container, bookmark_bar->parent()); |
155 // Top container is still second from front. | 162 // Top container is still second from front. |
156 EXPECT_EQ(browser_view()->child_count() - 2, | 163 EXPECT_EQ(browser_view()->child_count() - 2, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Test initial state. | 247 // Test initial state. |
241 EXPECT_TRUE(browser_view()->IsTabStripVisible()); | 248 EXPECT_TRUE(browser_view()->IsTabStripVisible()); |
242 // Validate whether the window switcher button is the target for the position | 249 // Validate whether the window switcher button is the target for the position |
243 // passed in. | 250 // passed in. |
244 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2, | 251 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2, |
245 browser_view()->window_switcher_button()->y()); | 252 browser_view()->window_switcher_button()->y()); |
246 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point), | 253 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point), |
247 browser_view()->window_switcher_button()); | 254 browser_view()->window_switcher_button()); |
248 } | 255 } |
249 #endif | 256 #endif |
OLD | NEW |