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