| OLD | NEW |
| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 view_list.push_back(VIEW_ID_TOOLBAR); | 344 view_list.push_back(VIEW_ID_TOOLBAR); |
| 345 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); | 345 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); |
| 346 VerifyZOrder(view_list); | 346 VerifyZOrder(view_list); |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Verify that in non-Instant presentation mode the content area is beneath | 349 // Verify that in non-Instant presentation mode the content area is beneath |
| 350 // the bookmark bar and info bar. | 350 // the bookmark bar and info bar. |
| 351 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffset) { | 351 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffset) { |
| 352 OverlayableContentsController* overlay = | 352 OverlayableContentsController* overlay = |
| 353 [controller() overlayableContentsController]; | 353 [controller() overlayableContentsController]; |
| 354 | |
| 355 // Just toolbar. | 354 // Just toolbar. |
| 356 EXPECT_EQ(0, [overlay activeContainerOffset]); | 355 EXPECT_EQ(bookmarks::kBookmarkBarOverlap - 1, |
| 356 [overlay activeContainerOffset]); |
| 357 | 357 |
| 358 // Plus bookmark bar. | 358 // Plus bookmark bar. |
| 359 browser()->window()->ToggleBookmarkBar(); | 359 browser()->window()->ToggleBookmarkBar(); |
| 360 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR), | 360 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR), |
| 361 [overlay activeContainerOffset]); | 361 [overlay activeContainerOffset]); |
| 362 | 362 |
| 363 // Plus info bar. | 363 // Plus info bar. |
| 364 ShowInfoBar(); | 364 ShowInfoBar(); |
| 365 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR) + | 365 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR) + |
| 366 GetViewHeight(VIEW_ID_INFO_BAR), | 366 GetViewHeight(VIEW_ID_INFO_BAR), |
| 367 [overlay activeContainerOffset]); | 367 [overlay activeContainerOffset]); |
| 368 | 368 |
| 369 // Minus bookmark bar. | 369 // Minus bookmark bar. |
| 370 browser()->window()->ToggleBookmarkBar(); | 370 browser()->window()->ToggleBookmarkBar(); |
| 371 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR), [overlay activeContainerOffset]); | 371 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR) + bookmarks::kBookmarkBarOverlap, |
| 372 [overlay activeContainerOffset]); |
| 372 } | 373 } |
| 373 | 374 |
| 374 // Verify that in non-Instant presentation mode the content area is beneath | 375 // Verify that in non-Instant presentation mode the content area is beneath |
| 375 // the info bar. | 376 // the info bar. |
| 376 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 377 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 377 DISABLED_ContentOffsetPresentationMode) { | 378 DISABLED_ContentOffsetPresentationMode) { |
| 378 // TODO(kbr): re-enable: http://crbug.com/222296 | 379 // TODO(kbr): re-enable: http://crbug.com/222296 |
| 379 if (base::mac::IsOSMountainLionOrLater()) | 380 if (base::mac::IsOSMountainLionOrLater()) |
| 380 return; | 381 return; |
| 381 | 382 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 395 EXPECT_EQ(0, [overlay activeContainerOffset]); | 396 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 396 | 397 |
| 397 // Minus bookmark bar. | 398 // Minus bookmark bar. |
| 398 browser()->window()->ToggleBookmarkBar(); | 399 browser()->window()->ToggleBookmarkBar(); |
| 399 EXPECT_EQ(0, [overlay activeContainerOffset]); | 400 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 400 } | 401 } |
| 401 | 402 |
| 402 // Verify that when showing Instant results the content area overlaps the | 403 // Verify that when showing Instant results the content area overlaps the |
| 403 // bookmark bar and info bar. | 404 // bookmark bar and info bar. |
| 404 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstant) { | 405 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstant) { |
| 405 ShowInstantResults(); | |
| 406 OverlayableContentsController* overlay = | 406 OverlayableContentsController* overlay = |
| 407 [controller() overlayableContentsController]; | 407 [controller() overlayableContentsController]; |
| 408 ShowInstantResults(); |
| 408 | 409 |
| 409 // Just toolbar. | 410 // Just toolbar. |
| 410 EXPECT_EQ(0, [overlay activeContainerOffset]); | 411 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 411 | 412 |
| 412 // Plus bookmark bar. | 413 // Plus bookmark bar. |
| 413 browser()->window()->ToggleBookmarkBar(); | 414 browser()->window()->ToggleBookmarkBar(); |
| 414 EXPECT_EQ(0, [overlay activeContainerOffset]); | 415 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 415 | 416 |
| 416 // Plus info bar. | 417 // Plus info bar. |
| 417 ShowInfoBar(); | 418 ShowInfoBar(); |
| 418 EXPECT_EQ(0, [overlay activeContainerOffset]); | 419 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 419 | 420 |
| 420 // Minus bookmark bar. | 421 // Minus bookmark bar. |
| 421 browser()->window()->ToggleBookmarkBar(); | 422 browser()->window()->ToggleBookmarkBar(); |
| 422 EXPECT_EQ(0, [overlay activeContainerOffset]); | 423 EXPECT_EQ(0, [overlay activeContainerOffset]); |
| 423 } | 424 } |
| 424 | 425 |
| 425 // The Instant NTP case is same as normal case except that the overlay is | 426 // The Instant NTP case is same as normal case except that the overlay is |
| 426 // also shifted down. | 427 // also shifted down. |
| 427 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstantNPT) { | 428 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstantNTP) { |
| 428 ShowInstantNTP(); | 429 ShowInstantNTP(); |
| 429 OverlayableContentsController* overlay = | 430 OverlayableContentsController* overlay = |
| 430 [controller() overlayableContentsController]; | 431 [controller() overlayableContentsController]; |
| 431 | 432 |
| 432 // Just toolbar. | 433 // Just toolbar. |
| 433 EXPECT_EQ(0, [overlay activeContainerOffset]); | 434 EXPECT_EQ(bookmarks::kBookmarkBarOverlap - 1, |
| 435 [overlay activeContainerOffset]); |
| 434 | 436 |
| 435 // Plus bookmark bar. | 437 // Plus bookmark bar. |
| 436 browser()->window()->ToggleBookmarkBar(); | 438 browser()->window()->ToggleBookmarkBar(); |
| 437 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR), | 439 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR), |
| 438 [overlay activeContainerOffset]); | 440 [overlay activeContainerOffset]); |
| 439 | 441 |
| 440 // Plus info bar. | 442 // Plus info bar. |
| 441 ShowInfoBar(); | 443 ShowInfoBar(); |
| 442 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR) + | 444 EXPECT_EQ(GetViewHeight(VIEW_ID_BOOKMARK_BAR) + |
| 443 GetViewHeight(VIEW_ID_INFO_BAR), | 445 GetViewHeight(VIEW_ID_INFO_BAR), |
| 444 [overlay activeContainerOffset]); | 446 [overlay activeContainerOffset]); |
| 445 | 447 |
| 446 // Minus bookmark bar. | 448 // Minus bookmark bar. |
| 447 browser()->window()->ToggleBookmarkBar(); | 449 browser()->window()->ToggleBookmarkBar(); |
| 448 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR), [overlay activeContainerOffset]); | 450 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR) + bookmarks::kBookmarkBarOverlap, |
| 451 [overlay activeContainerOffset]); |
| 449 } | 452 } |
| 450 | 453 |
| 451 // Verify that if bookmark bar is underneath Instant search results then | 454 // Verify that if bookmark bar is underneath Instant search results then |
| 452 // clicking on Instant search results still works. | 455 // clicking on Instant search results still works. |
| 453 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 456 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 454 InstantSearchResultsHitTest) { | 457 InstantSearchResultsHitTest) { |
| 455 browser()->window()->ToggleBookmarkBar(); | 458 browser()->window()->ToggleBookmarkBar(); |
| 456 ShowInstantResults(); | 459 ShowInstantResults(); |
| 457 | 460 |
| 458 NSView* bookmarkView = [[controller() bookmarkBarController] view]; | 461 NSView* bookmarkView = [[controller() bookmarkBarController] view]; |
| 459 NSView* contentView = [[controller() window] contentView]; | 462 NSView* contentView = [[controller() window] contentView]; |
| 460 NSPoint point = [bookmarkView convertPoint:NSMakePoint(1, 1) | 463 NSPoint point = [bookmarkView convertPoint:NSMakePoint(1, 1) |
| 461 toView:[contentView superview]]; | 464 toView:[contentView superview]]; |
| 462 | 465 |
| 463 EXPECT_FALSE([[contentView hitTest:point] isDescendantOf:bookmarkView]); | 466 EXPECT_FALSE([[contentView hitTest:point] isDescendantOf:bookmarkView]); |
| 464 EXPECT_TRUE([[contentView hitTest:point] | 467 EXPECT_TRUE([[contentView hitTest:point] |
| 465 isDescendantOf:[controller() tabContentArea]]); | 468 isDescendantOf:[controller() tabContentArea]]); |
| 466 } | 469 } |
| OLD | NEW |