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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 555243002: mac: Refactor browser_window_controller layout logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fullscreen_layout
Patch Set: Ensure location bar in consistent state after initialization. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #import "base/mac/mac_util.h" 7 #import "base/mac/mac_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 8 #include "base/mac/sdk_forward_declarations.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return [[controller() downloadShelf] view]; 125 return [[controller() downloadShelf] view];
126 case VIEW_ID_TAB_CONTENT_AREA: 126 case VIEW_ID_TAB_CONTENT_AREA:
127 return [controller() tabContentArea]; 127 return [controller() tabContentArea];
128 default: 128 default:
129 NOTREACHED(); 129 NOTREACHED();
130 return nil; 130 return nil;
131 } 131 }
132 } 132 }
133 133
134 void VerifyZOrder(const std::vector<ViewID>& view_list) const { 134 void VerifyZOrder(const std::vector<ViewID>& view_list) const {
135 for (size_t i = 0; i < view_list.size() - 1; ++i) { 135 std::vector<NSView*> visible_views;
136 NSView* bottom_view = GetViewWithID(view_list[i]); 136 for (size_t i = 0; i < view_list.size(); ++i) {
137 NSView* top_view = GetViewWithID(view_list[i + 1]); 137 NSView* view = GetViewWithID(view_list[i]);
138 if ([view superview])
139 visible_views.push_back(view);
140 }
141
142 for (size_t i = 0; i < visible_views.size() - 1; ++i) {
143 NSView* bottom_view = visible_views[i];
144 NSView* top_view = visible_views[i + 1];
145
138 EXPECT_NSEQ([bottom_view superview], [top_view superview]); 146 EXPECT_NSEQ([bottom_view superview], [top_view superview]);
139 EXPECT_TRUE([bottom_view cr_isBelowView:top_view]); 147 EXPECT_TRUE([bottom_view cr_isBelowView:top_view]);
140 } 148 }
141 149
142 // Views not in |view_list| must either be nil or not parented. 150 // Views not in |view_list| must either be nil or not parented.
143 for (size_t i = 0; i < VIEW_ID_COUNT; ++i) { 151 for (size_t i = 0; i < VIEW_ID_COUNT; ++i) {
144 if (std::find(view_list.begin(), view_list.end(), i) == view_list.end()) { 152 if (std::find(view_list.begin(), view_list.end(), i) == view_list.end()) {
145 NSView* view = GetViewWithID(static_cast<ViewID>(i)); 153 NSView* view = GetViewWithID(static_cast<ViewID>(i));
146 EXPECT_TRUE(!view || ![view superview]); 154 EXPECT_TRUE(!view || ![view superview]);
147 } 155 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 LocationBarViewMac* location_bar_view = [controller() locationBarBridge]; 215 LocationBarViewMac* location_bar_view = [controller() locationBarBridge];
208 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint(); 216 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint();
209 217
210 NSPoint info_bar_top = NSMakePoint(0, 218 NSPoint info_bar_top = NSMakePoint(0,
211 NSHeight([info_bar_container_controller view].frame) - 219 NSHeight([info_bar_container_controller view].frame) -
212 overlapping_tip_height); 220 overlapping_tip_height);
213 info_bar_top = [[info_bar_container_controller view] 221 info_bar_top = [[info_bar_container_controller view]
214 convertPoint:info_bar_top toView:nil]; 222 convertPoint:info_bar_top toView:nil];
215 return icon_bottom.y - info_bar_top.y; 223 return icon_bottom.y - info_bar_top.y;
216 } 224 }
225
217 // The traffic lights should always be in front of the content view and the 226 // The traffic lights should always be in front of the content view and the
218 // tab strip view. Since the traffic lights change across OSX versions, this 227 // tab strip view. Since the traffic lights change across OSX versions, this
219 // test verifies that the contentView is in the back, and if the tab strip 228 // test verifies that the contentView is in the back, and if the tab strip
220 // view is a sibling, it is directly in front of the content view. 229 // view is a sibling, it is directly in front of the content view.
221 void VerifyTrafficLightZOrder() const { 230 void VerifyTrafficLightZOrder() const {
222 NSView* contentView = [[controller() window] contentView]; 231 NSView* contentView = [[controller() window] contentView];
223 NSView* rootView = [contentView superview]; 232 NSView* rootView = [contentView superview];
224 EXPECT_EQ(contentView, [[rootView subviews] objectAtIndex:0]); 233 EXPECT_EQ(contentView, [[rootView subviews] objectAtIndex:0]);
225 234
226 NSView* tabStripView = [controller() tabStripView]; 235 NSView* tabStripView = [controller() tabStripView];
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 EXPECT_LT(NSMinX(fullscreen_frame), NSMinX(avatar_frame)); 301 EXPECT_LT(NSMinX(fullscreen_frame), NSMinX(avatar_frame));
293 EXPECT_LT(NSMaxX(fullscreen_frame), NSMinX(avatar_frame)); 302 EXPECT_LT(NSMaxX(fullscreen_frame), NSMinX(avatar_frame));
294 } 303 }
295 304
296 // Verify that in non-Instant normal mode that the find bar and download shelf 305 // Verify that in non-Instant normal mode that the find bar and download shelf
297 // are above the content area. Everything else should be below it. 306 // are above the content area. Everything else should be below it.
298 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderNormal) { 307 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderNormal) {
299 browser()->GetFindBarController(); // add find bar 308 browser()->GetFindBarController(); // add find bar
300 309
301 std::vector<ViewID> view_list; 310 std::vector<ViewID> view_list;
311 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF);
302 view_list.push_back(VIEW_ID_BOOKMARK_BAR); 312 view_list.push_back(VIEW_ID_BOOKMARK_BAR);
303 view_list.push_back(VIEW_ID_TOOLBAR); 313 view_list.push_back(VIEW_ID_TOOLBAR);
304 view_list.push_back(VIEW_ID_INFO_BAR); 314 view_list.push_back(VIEW_ID_INFO_BAR);
305 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); 315 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA);
306 view_list.push_back(VIEW_ID_FIND_BAR); 316 view_list.push_back(VIEW_ID_FIND_BAR);
307 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); 317 VerifyZOrder(view_list);
318
319 [controller() showOverlay];
320 [controller() removeOverlay];
321 VerifyZOrder(view_list);
322
323 [controller() enterImmersiveFullscreen];
324 [controller() exitImmersiveFullscreen];
308 VerifyZOrder(view_list); 325 VerifyZOrder(view_list);
309 } 326 }
310 327
311 // Verify that in non-Instant presentation mode that the info bar is below the 328 // Verify that in non-Instant presentation mode that the info bar is below the
312 // content are and everything else is above it. 329 // content are and everything else is above it.
313 // DISABLED due to flaky failures on trybots. http://crbug.com/178778 330 // DISABLED due to flaky failures on trybots. http://crbug.com/178778
314 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, 331 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
315 DISABLED_ZOrderPresentationMode) { 332 DISABLED_ZOrderPresentationMode) {
316 chrome::ToggleFullscreenMode(browser()); 333 chrome::ToggleFullscreenMode(browser());
317 browser()->GetFindBarController(); // add find bar 334 browser()->GetFindBarController(); // add find bar
(...skipping 18 matching lines...) Expand all
336 return; 353 return;
337 354
338 chrome::ToggleFullscreenMode(browser()); 355 chrome::ToggleFullscreenMode(browser());
339 356
340 NSView* fullscreen_floating_bar = 357 NSView* fullscreen_floating_bar =
341 GetViewWithID(VIEW_ID_FULLSCREEN_FLOATING_BAR); 358 GetViewWithID(VIEW_ID_FULLSCREEN_FLOATING_BAR);
342 [fullscreen_floating_bar removeFromSuperview]; 359 [fullscreen_floating_bar removeFromSuperview];
343 [[[controller() window] contentView] addSubview:fullscreen_floating_bar 360 [[[controller() window] contentView] addSubview:fullscreen_floating_bar
344 positioned:NSWindowBelow 361 positioned:NSWindowBelow
345 relativeTo:nil]; 362 relativeTo:nil];
346 [controller() updateSubviewZOrder:[controller() inPresentationMode]]; 363 [controller() updateSubviewZOrder];
347 364
348 std::vector<ViewID> view_list; 365 std::vector<ViewID> view_list;
349 view_list.push_back(VIEW_ID_INFO_BAR); 366 view_list.push_back(VIEW_ID_INFO_BAR);
350 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); 367 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA);
351 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); 368 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR);
352 view_list.push_back(VIEW_ID_BOOKMARK_BAR); 369 view_list.push_back(VIEW_ID_BOOKMARK_BAR);
353 view_list.push_back(VIEW_ID_TOOLBAR); 370 view_list.push_back(VIEW_ID_TOOLBAR);
354 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); 371 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF);
355 VerifyZOrder(view_list); 372 VerifyZOrder(view_list);
356 } 373 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 gfx::Rect(10, 10, 100, 100)); 461 gfx::Rect(10, 10, 100, 100));
445 462
446 NSPoint originWithDevTools = [controller() statusBubbleBaseFrame].origin; 463 NSPoint originWithDevTools = [controller() statusBubbleBaseFrame].origin;
447 EXPECT_FALSE(NSEqualPoints(origin, originWithDevTools)); 464 EXPECT_FALSE(NSEqualPoints(origin, originWithDevTools));
448 465
449 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); 466 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window);
450 } 467 }
451 468
452 // Tests that top infobar tip is streched when bookmark bar becomes SHOWN/HIDDEN 469 // Tests that top infobar tip is streched when bookmark bar becomes SHOWN/HIDDEN
453 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, 470 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
454 InfoBarTipStrechedWhenBookmarkBarStatusChanged) { 471 InfoBarTipStretchedWhenBookmarkBarStatusChanged) {
455 EXPECT_FALSE([controller() isBookmarkBarVisible]); 472 EXPECT_FALSE([controller() isBookmarkBarVisible]);
456 ShowInfoBar(browser()); 473 ShowInfoBar(browser());
457 // The infobar tip is animated during the infobar is being added, wait until 474 // The infobar tip is animated during the infobar is being added, wait until
458 // it completes. 475 // it completes.
459 WaitForTopInfoBarAnimationToFinish(); 476 WaitForTopInfoBarAnimationToFinish();
460 477
461 EXPECT_FALSE([[controller() infoBarContainerController] 478 EXPECT_FALSE([[controller() infoBarContainerController]
462 shouldSuppressTopInfoBarTip]); 479 shouldSuppressTopInfoBarTip]);
463 480
464 NSInteger max_tip_height = infobars::InfoBar::kMaximumArrowTargetHeight + 481 NSInteger max_tip_height = infobars::InfoBar::kMaximumArrowTargetHeight +
(...skipping 19 matching lines...) Expand all
484 // Toggle overlay, then verify z order. 501 // Toggle overlay, then verify z order.
485 [controller() showOverlay]; 502 [controller() showOverlay];
486 [controller() removeOverlay]; 503 [controller() removeOverlay];
487 VerifyTrafficLightZOrder(); 504 VerifyTrafficLightZOrder();
488 505
489 // Toggle immersive fullscreen, then verify z order. 506 // Toggle immersive fullscreen, then verify z order.
490 [controller() enterImmersiveFullscreen]; 507 [controller() enterImmersiveFullscreen];
491 [controller() exitImmersiveFullscreen]; 508 [controller() exitImmersiveFullscreen];
492 VerifyTrafficLightZOrder(); 509 VerifyTrafficLightZOrder();
493 } 510 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698