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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_unittest.cc

Issue 160093006: Fix find bar positioning for hosted app windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); 96 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view());
97 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); 97 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x());
98 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); 98 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y());
99 EXPECT_EQ(0, toolbar->x()); 99 EXPECT_EQ(0, toolbar->x());
100 EXPECT_EQ( 100 EXPECT_EQ(
101 tabstrip->bounds().bottom() - 101 tabstrip->bounds().bottom() -
102 BrowserViewLayout::kToolbarTabStripVerticalOverlap, 102 BrowserViewLayout::kToolbarTabStripVerticalOverlap,
103 toolbar->y()); 103 toolbar->y());
104 EXPECT_EQ(0, contents_container->x()); 104 EXPECT_EQ(0, contents_container->x());
105 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); 105 EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y());
106 EXPECT_EQ(top_container->bounds().bottom(), contents_container->y());
106 EXPECT_EQ(0, devtools_web_view->x()); 107 EXPECT_EQ(0, devtools_web_view->x());
107 EXPECT_EQ(0, devtools_web_view->y()); 108 EXPECT_EQ(0, devtools_web_view->y());
108 EXPECT_EQ(0, contents_web_view->x()); 109 EXPECT_EQ(0, contents_web_view->x());
109 EXPECT_EQ(0, contents_web_view->y()); 110 EXPECT_EQ(0, contents_web_view->y());
110 111
111 // Verify bookmark bar visibility. 112 // Verify bookmark bar visibility.
112 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); 113 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView();
113 EXPECT_FALSE(bookmark_bar->visible()); 114 EXPECT_FALSE(bookmark_bar->visible());
114 EXPECT_FALSE(bookmark_bar->IsDetached()); 115 EXPECT_FALSE(bookmark_bar->IsDetached());
115 chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR); 116 chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_FALSE(bookmark_bar->visible()); 158 EXPECT_FALSE(bookmark_bar->visible());
158 EXPECT_FALSE(bookmark_bar->IsDetached()); 159 EXPECT_FALSE(bookmark_bar->IsDetached());
159 EXPECT_EQ(top_container, bookmark_bar->parent()); 160 EXPECT_EQ(top_container, bookmark_bar->parent());
160 // Top container is still second from front. 161 // Top container is still second from front.
161 EXPECT_EQ(browser_view()->child_count() - 2, 162 EXPECT_EQ(browser_view()->child_count() - 2,
162 browser_view()->GetIndexOf(top_container)); 163 browser_view()->GetIndexOf(top_container));
163 164
164 BookmarkBarView::DisableAnimationsForTesting(false); 165 BookmarkBarView::DisableAnimationsForTesting(false);
165 } 166 }
166 167
168 class BrowserViewHostedAppTest : public TestWithBrowserView {
169 public:
170 BrowserViewHostedAppTest()
171 : TestWithBrowserView(Browser::TYPE_POPUP,
172 chrome::HOST_DESKTOP_TYPE_NATIVE,
173 true) {
174 }
175 virtual ~BrowserViewHostedAppTest() {
176 }
177
178 private:
179 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest);
180 };
181
182 // Test basic layout for hosted apps.
183 TEST_F(BrowserViewHostedAppTest, Layout) {
184 // Add a tab because the browser starts out without any tabs at all.
185 AddTab(browser(), GURL("about:blank"));
186
187 views::View* contents_container =
188 browser_view()->GetContentsContainerForTest();
189
190 // The tabstrip, toolbar and bookmark bar should not be visible for hosted
191 // apps.
192 EXPECT_FALSE(browser_view()->tabstrip()->visible());
193 EXPECT_FALSE(browser_view()->toolbar()->visible());
194 EXPECT_FALSE(browser_view()->IsBookmarkBarVisible());
195
196 gfx::Point header_offset;
197 views::View::ConvertPointToTarget(
198 browser_view(),
199 browser_view()->frame()->non_client_view()->frame_view(),
200 &header_offset);
201
202 // The position of the bottom of the header (the bar with the window
203 // controls) in the coordinates of BrowserView.
204 int bottom_of_header = browser_view()->frame()->GetTopInset() -
205 header_offset.y();
206
207 // The web contents should be flush with the bottom of the header.
208 EXPECT_EQ(bottom_of_header, contents_container->y());
209
210 // The find bar should overlap the 1px header/web-contents separator at the
211 // bottom of the header.
212 EXPECT_EQ(browser_view()->frame()->GetTopInset() - 1,
213 browser_view()->GetFindBarBoundingBox().y());
214 }
215
167 #if defined(OS_WIN) 216 #if defined(OS_WIN)
168 217
169 // This class provides functionality to test the incognito window/normal window 218 // This class provides functionality to test the incognito window/normal window
170 // switcher button which is added to Windows 8 metro Chrome. 219 // switcher button which is added to Windows 8 metro Chrome.
171 // We create the BrowserView ourselves in the 220 // We create the BrowserView ourselves in the
172 // BrowserWithTestWindowTest::CreateBrowserWindow function override and add the 221 // BrowserWithTestWindowTest::CreateBrowserWindow function override and add the
173 // switcher button to the view. We also provide an incognito profile to ensure 222 // switcher button to the view. We also provide an incognito profile to ensure
174 // that the switcher button is visible. 223 // that the switcher button is visible.
175 class BrowserViewIncognitoSwitcherTest : public TestWithBrowserView { 224 class BrowserViewIncognitoSwitcherTest : public TestWithBrowserView {
176 public: 225 public:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Test initial state. 307 // Test initial state.
259 EXPECT_TRUE(browser_view()->IsTabStripVisible()); 308 EXPECT_TRUE(browser_view()->IsTabStripVisible());
260 // Validate whether the window switcher button is the target for the position 309 // Validate whether the window switcher button is the target for the position
261 // passed in. 310 // passed in.
262 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2, 311 gfx::Point switcher_point(browser_view()->window_switcher_button()->x() + 2,
263 browser_view()->window_switcher_button()->y()); 312 browser_view()->window_switcher_button()->y());
264 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point), 313 EXPECT_EQ(browser_view()->GetEventHandlerForPoint(switcher_point),
265 browser_view()->window_switcher_button()); 314 browser_view()->window_switcher_button());
266 } 315 }
267 #endif 316 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.cc ('k') | chrome/browser/ui/views/frame/top_container_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698