| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/search/search.h" | |
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.cc" | 18 #include "chrome/browser/ui/browser_tabstrip.cc" |
| 20 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 21 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 20 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| 22 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 21 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 23 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 22 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 24 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 23 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 25 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 24 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 26 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 25 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 27 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 26 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 28 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 27 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 29 #include "chrome/browser/ui/extensions/application_launch.h" | 28 #include "chrome/browser/ui/extensions/application_launch.h" |
| 30 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 29 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 31 #include "chrome/browser/ui/find_bar/find_bar.h" | 30 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 32 #include "chrome/browser/ui/search/search_model.h" | |
| 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 34 #include "chrome/test/base/in_process_browser_test.h" | 32 #include "chrome/test/base/in_process_browser_test.h" |
| 35 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
| 36 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/browser/web_contents_view.h" | 35 #include "content/public/browser/web_contents_view.h" |
| 38 #import "testing/gtest_mac.h" | 36 #import "testing/gtest_mac.h" |
| 39 | 37 |
| 40 namespace { | 38 namespace { |
| 41 | 39 |
| 42 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 40 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual void SetUpOnMainThread() OVERRIDE { | 97 virtual void SetUpOnMainThread() OVERRIDE { |
| 100 [[controller() bookmarkBarController] setStateAnimationsEnabled:NO]; | 98 [[controller() bookmarkBarController] setStateAnimationsEnabled:NO]; |
| 101 [[controller() bookmarkBarController] setInnerContentAnimationsEnabled:NO]; | 99 [[controller() bookmarkBarController] setInnerContentAnimationsEnabled:NO]; |
| 102 } | 100 } |
| 103 | 101 |
| 104 BrowserWindowController* controller() const { | 102 BrowserWindowController* controller() const { |
| 105 return [BrowserWindowController browserWindowControllerForWindow: | 103 return [BrowserWindowController browserWindowControllerForWindow: |
| 106 browser()->window()->GetNativeWindow()]; | 104 browser()->window()->GetNativeWindow()]; |
| 107 } | 105 } |
| 108 | 106 |
| 109 void ShowInstantResults() { | |
| 110 chrome::EnableInstantExtendedAPIForTesting(); | |
| 111 SearchMode mode(SearchMode::MODE_SEARCH_SUGGESTIONS, | |
| 112 SearchMode::ORIGIN_SEARCH); | |
| 113 browser()->search_model()->SetMode(mode); | |
| 114 browser()->search_model()->SetTopBarsVisible(false); | |
| 115 EXPECT_TRUE(browser()->search_model()->mode().is_search_suggestions()); | |
| 116 EXPECT_EQ(browser_window_controller::kInstantUIFullPageResults, | |
| 117 [controller() currentInstantUIState]); | |
| 118 } | |
| 119 | |
| 120 void ShowInstantNTP() { | |
| 121 chrome::EnableInstantExtendedAPIForTesting(); | |
| 122 SearchMode mode(SearchMode::MODE_NTP, SearchMode::ORIGIN_NTP); | |
| 123 browser()->search_model()->SetMode(mode); | |
| 124 browser()->search_model()->SetTopBarsVisible(true); | |
| 125 EXPECT_TRUE(browser()->search_model()->mode().is_ntp()); | |
| 126 EXPECT_EQ(browser_window_controller::kInstantUINone, | |
| 127 [controller() currentInstantUIState]); | |
| 128 } | |
| 129 | |
| 130 void ShowInfoBar() { | 107 void ShowInfoBar() { |
| 131 content::WebContents* web_contents = | 108 content::WebContents* web_contents = |
| 132 browser()->tab_strip_model()->GetActiveWebContents(); | 109 browser()->tab_strip_model()->GetActiveWebContents(); |
| 133 InfoBarService* service = | 110 InfoBarService* service = |
| 134 InfoBarService::FromWebContents(web_contents); | 111 InfoBarService::FromWebContents(web_contents); |
| 135 info_bar_delegate_.reset(new DummyInfoBar(service)); | 112 info_bar_delegate_.reset(new DummyInfoBar(service)); |
| 136 [[controller() infoBarContainerController] | 113 [[controller() infoBarContainerController] |
| 137 addInfoBar:info_bar_delegate_->CreateInfoBar(service) | 114 addInfoBar:info_bar_delegate_->CreateInfoBar(service) |
| 138 animate:NO]; | 115 animate:NO]; |
| 139 } | 116 } |
| 140 | 117 |
| 141 void HideInstant() { | |
| 142 SearchMode mode; | |
| 143 browser()->search_model()->SetMode(mode); | |
| 144 browser()->search_model()->SetTopBarsVisible(true); | |
| 145 EXPECT_TRUE(browser()->search_model()->mode().is_default()); | |
| 146 EXPECT_EQ(browser_window_controller::kInstantUINone, | |
| 147 [controller() currentInstantUIState]); | |
| 148 } | |
| 149 | |
| 150 NSView* GetViewWithID(ViewID view_id) const { | 118 NSView* GetViewWithID(ViewID view_id) const { |
| 151 switch (view_id) { | 119 switch (view_id) { |
| 152 case VIEW_ID_FULLSCREEN_FLOATING_BAR: | 120 case VIEW_ID_FULLSCREEN_FLOATING_BAR: |
| 153 return [controller() floatingBarBackingView]; | 121 return [controller() floatingBarBackingView]; |
| 154 case VIEW_ID_TOOLBAR: | 122 case VIEW_ID_TOOLBAR: |
| 155 return [[controller() toolbarController] view]; | 123 return [[controller() toolbarController] view]; |
| 156 case VIEW_ID_BOOKMARK_BAR: | 124 case VIEW_ID_BOOKMARK_BAR: |
| 157 return [[controller() bookmarkBarController] view]; | 125 return [[controller() bookmarkBarController] view]; |
| 158 case VIEW_ID_INFO_BAR: | 126 case VIEW_ID_INFO_BAR: |
| 159 return [[controller() infoBarContainerController] view]; | 127 return [[controller() infoBarContainerController] view]; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 view_list.push_back(VIEW_ID_INFO_BAR); | 257 view_list.push_back(VIEW_ID_INFO_BAR); |
| 290 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); | 258 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); |
| 291 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); | 259 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); |
| 292 view_list.push_back(VIEW_ID_BOOKMARK_BAR); | 260 view_list.push_back(VIEW_ID_BOOKMARK_BAR); |
| 293 view_list.push_back(VIEW_ID_TOOLBAR); | 261 view_list.push_back(VIEW_ID_TOOLBAR); |
| 294 view_list.push_back(VIEW_ID_FIND_BAR); | 262 view_list.push_back(VIEW_ID_FIND_BAR); |
| 295 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); | 263 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); |
| 296 VerifyZOrder(view_list); | 264 VerifyZOrder(view_list); |
| 297 } | 265 } |
| 298 | 266 |
| 299 // Normal mode with Instant results showing. Should be same z-order as normal | |
| 300 // mode except find bar is below content area. | |
| 301 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderNormalInstant) { | |
| 302 ShowInstantResults(); | |
| 303 browser()->GetFindBarController(); // add find bar | |
| 304 | |
| 305 std::vector<ViewID> view_list; | |
| 306 view_list.push_back(VIEW_ID_BOOKMARK_BAR); | |
| 307 view_list.push_back(VIEW_ID_TOOLBAR); | |
| 308 view_list.push_back(VIEW_ID_INFO_BAR); | |
| 309 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); | |
| 310 view_list.push_back(VIEW_ID_FIND_BAR); | |
| 311 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); | |
| 312 VerifyZOrder(view_list); | |
| 313 } | |
| 314 | |
| 315 // Presentation mode with Instant results showing. Should be exact same as | |
| 316 // non-Instant presentation mode. | |
| 317 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | |
| 318 DISABLED_ZOrderInstantPresentationMode) { | |
| 319 // TODO(kbr): re-enable: http://crbug.com/222296 | |
| 320 if (base::mac::IsOSMountainLionOrLater()) | |
| 321 return; | |
| 322 | |
| 323 chrome::ToggleFullscreenMode(browser()); | |
| 324 ShowInstantResults(); | |
| 325 browser()->GetFindBarController(); // add find bar | |
| 326 | |
| 327 std::vector<ViewID> view_list; | |
| 328 view_list.push_back(VIEW_ID_INFO_BAR); | |
| 329 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); | |
| 330 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); | |
| 331 view_list.push_back(VIEW_ID_BOOKMARK_BAR); | |
| 332 view_list.push_back(VIEW_ID_TOOLBAR); | |
| 333 view_list.push_back(VIEW_ID_FIND_BAR); | |
| 334 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); | |
| 335 VerifyZOrder(view_list); | |
| 336 } | |
| 337 | |
| 338 // Verify that in presentation mode, Instant search results are below the | |
| 339 // floating toolbar. | |
| 340 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | |
| 341 DISABLED_OverlayOffsetInstantPresentationMode) { | |
| 342 chrome::ToggleFullscreenMode(browser()); | |
| 343 ShowInstantResults(); | |
| 344 [controller() setFloatingBarShownFraction:0.0]; | |
| 345 EXPECT_EQ( | |
| 346 0, [[controller() overlayableContentsController] overlayContentsOffset]); | |
| 347 EXPECT_EQ( | |
| 348 0, [[controller() overlayableContentsController] activeContainerOffset]); | |
| 349 [controller() setFloatingBarShownFraction:1.0]; | |
| 350 | |
| 351 NSView* floating_bar = GetViewWithID(VIEW_ID_FULLSCREEN_FLOATING_BAR); | |
| 352 CGFloat floating_bar_height = NSHeight([floating_bar frame]); | |
| 353 EXPECT_EQ( | |
| 354 floating_bar_height, | |
| 355 [[controller() overlayableContentsController] overlayContentsOffset]); | |
| 356 EXPECT_EQ( | |
| 357 floating_bar_height, | |
| 358 [[controller() overlayableContentsController] activeContainerOffset]); | |
| 359 } | |
| 360 | |
| 361 // Verify that if the fullscreen floating bar view is below the tab content area | 267 // Verify that if the fullscreen floating bar view is below the tab content area |
| 362 // then calling |updateSubviewZOrder:| will correctly move back above. | 268 // then calling |updateSubviewZOrder:| will correctly move back above. |
| 363 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 269 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 364 DISABLED_FloatingBarBelowContentView) { | 270 DISABLED_FloatingBarBelowContentView) { |
| 365 // TODO(kbr): re-enable: http://crbug.com/222296 | 271 // TODO(kbr): re-enable: http://crbug.com/222296 |
| 366 if (base::mac::IsOSMountainLionOrLater()) | 272 if (base::mac::IsOSMountainLionOrLater()) |
| 367 return; | 273 return; |
| 368 | 274 |
| 369 chrome::ToggleFullscreenMode(browser()); | 275 chrome::ToggleFullscreenMode(browser()); |
| 370 | 276 |
| 371 NSView* fullscreen_floating_bar = | 277 NSView* fullscreen_floating_bar = |
| 372 GetViewWithID(VIEW_ID_FULLSCREEN_FLOATING_BAR); | 278 GetViewWithID(VIEW_ID_FULLSCREEN_FLOATING_BAR); |
| 373 [fullscreen_floating_bar removeFromSuperview]; | 279 [fullscreen_floating_bar removeFromSuperview]; |
| 374 [[[controller() window] contentView] addSubview:fullscreen_floating_bar | 280 [[[controller() window] contentView] addSubview:fullscreen_floating_bar |
| 375 positioned:NSWindowBelow | 281 positioned:NSWindowBelow |
| 376 relativeTo:nil]; | 282 relativeTo:nil]; |
| 377 [controller() updateSubviewZOrder:[controller() inPresentationMode]]; | 283 [controller() updateSubviewZOrder:[controller() inPresentationMode]]; |
| 378 | 284 |
| 379 std::vector<ViewID> view_list; | 285 std::vector<ViewID> view_list; |
| 380 view_list.push_back(VIEW_ID_INFO_BAR); | 286 view_list.push_back(VIEW_ID_INFO_BAR); |
| 381 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); | 287 view_list.push_back(VIEW_ID_TAB_CONTENT_AREA); |
| 382 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); | 288 view_list.push_back(VIEW_ID_FULLSCREEN_FLOATING_BAR); |
| 383 view_list.push_back(VIEW_ID_BOOKMARK_BAR); | 289 view_list.push_back(VIEW_ID_BOOKMARK_BAR); |
| 384 view_list.push_back(VIEW_ID_TOOLBAR); | 290 view_list.push_back(VIEW_ID_TOOLBAR); |
| 385 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); | 291 view_list.push_back(VIEW_ID_DOWNLOAD_SHELF); |
| 386 VerifyZOrder(view_list); | 292 VerifyZOrder(view_list); |
| 387 } | 293 } |
| 388 | 294 |
| 389 // Verify that in non-Instant presentation mode the content area is beneath | |
| 390 // the bookmark bar and info bar. | |
| 391 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffset) { | |
| 392 OverlayableContentsController* overlay = | |
| 393 [controller() overlayableContentsController]; | |
| 394 // Just toolbar. | |
| 395 EXPECT_EQ(1, [overlay activeContainerOffset]); | |
| 396 | |
| 397 // Plus bookmark bar. | |
| 398 browser()->window()->ToggleBookmarkBar(); | |
| 399 CGFloat bookmark_bar_offset = | |
| 400 GetViewHeight(VIEW_ID_BOOKMARK_BAR) - bookmarks::kBookmarkBarOverlap + 1; | |
| 401 EXPECT_EQ(bookmark_bar_offset, [overlay activeContainerOffset]); | |
| 402 | |
| 403 // Plus info bar. | |
| 404 ShowInfoBar(); | |
| 405 EXPECT_EQ(bookmark_bar_offset + GetViewHeight(VIEW_ID_INFO_BAR), | |
| 406 [overlay activeContainerOffset]); | |
| 407 | |
| 408 // Minus bookmark bar. | |
| 409 browser()->window()->ToggleBookmarkBar(); | |
| 410 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR) + 1, | |
| 411 [overlay activeContainerOffset]); | |
| 412 } | |
| 413 | |
| 414 // Verify that in non-Instant presentation mode the content area is beneath | |
| 415 // the info bar. | |
| 416 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | |
| 417 DISABLED_ContentOffsetPresentationMode) { | |
| 418 // TODO(kbr): re-enable: http://crbug.com/222296 | |
| 419 if (base::mac::IsOSMountainLionOrLater()) | |
| 420 return; | |
| 421 | |
| 422 chrome::ToggleFullscreenMode(browser()); | |
| 423 OverlayableContentsController* overlay = | |
| 424 [controller() overlayableContentsController]; | |
| 425 | |
| 426 // Just toolbar. | |
| 427 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 428 | |
| 429 // Plus bookmark bar. | |
| 430 browser()->window()->ToggleBookmarkBar(); | |
| 431 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 432 | |
| 433 // Plus info bar. | |
| 434 ShowInfoBar(); | |
| 435 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 436 | |
| 437 // Minus bookmark bar. | |
| 438 browser()->window()->ToggleBookmarkBar(); | |
| 439 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 440 } | |
| 441 | |
| 442 // Verify that when showing Instant results the content area overlaps the | |
| 443 // bookmark bar and info bar. | |
| 444 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstant) { | |
| 445 OverlayableContentsController* overlay = | |
| 446 [controller() overlayableContentsController]; | |
| 447 ShowInstantResults(); | |
| 448 | |
| 449 // Just toolbar. | |
| 450 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 451 | |
| 452 // Plus bookmark bar. | |
| 453 browser()->window()->ToggleBookmarkBar(); | |
| 454 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 455 | |
| 456 // Plus info bar. | |
| 457 ShowInfoBar(); | |
| 458 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 459 | |
| 460 // Minus bookmark bar. | |
| 461 browser()->window()->ToggleBookmarkBar(); | |
| 462 EXPECT_EQ(0, [overlay activeContainerOffset]); | |
| 463 } | |
| 464 | |
| 465 // The Instant NTP case is same as normal case except that the overlay is | |
| 466 // also shifted down. | |
| 467 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffsetInstantNTP) { | |
| 468 ShowInstantNTP(); | |
| 469 OverlayableContentsController* overlay = | |
| 470 [controller() overlayableContentsController]; | |
| 471 | |
| 472 // Just toolbar. | |
| 473 EXPECT_EQ(1, [overlay activeContainerOffset]); | |
| 474 | |
| 475 // Plus bookmark bar. | |
| 476 browser()->window()->ToggleBookmarkBar(); | |
| 477 CGFloat bookmark_bar_offset = | |
| 478 GetViewHeight(VIEW_ID_BOOKMARK_BAR) - bookmarks::kBookmarkBarOverlap + 1; | |
| 479 EXPECT_EQ(bookmark_bar_offset, [overlay activeContainerOffset]); | |
| 480 | |
| 481 // Plus info bar. | |
| 482 ShowInfoBar(); | |
| 483 EXPECT_EQ(bookmark_bar_offset + GetViewHeight(VIEW_ID_INFO_BAR), | |
| 484 [overlay activeContainerOffset]); | |
| 485 | |
| 486 // Minus bookmark bar. | |
| 487 browser()->window()->ToggleBookmarkBar(); | |
| 488 EXPECT_EQ(GetViewHeight(VIEW_ID_INFO_BAR) + 1, | |
| 489 [overlay activeContainerOffset]); | |
| 490 } | |
| 491 | |
| 492 // Verify that the find bar is positioned corerctly when a full page instant | |
| 493 // search result is displayed. | |
| 494 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, FindBarOffsetInstant) { | |
| 495 // Add bookmark bar and find bar. | |
| 496 browser()->window()->ToggleBookmarkBar(); | |
| 497 browser()->GetFindBarController(); | |
| 498 | |
| 499 CGFloat line_width = [GetViewWithID(VIEW_ID_FIND_BAR) cr_lineWidth]; | |
| 500 NSRect bookmark_bar_frame = [GetViewWithID(VIEW_ID_BOOKMARK_BAR) frame]; | |
| 501 NSRect find_bar_frame = [GetViewWithID(VIEW_ID_FIND_BAR) frame]; | |
| 502 EXPECT_EQ(NSMinY(bookmark_bar_frame), NSMaxY(find_bar_frame) - line_width); | |
| 503 | |
| 504 // Show instant and add a find bar to it. | |
| 505 ShowInstantResults(); | |
| 506 browser()->GetFindBarController()->find_bar()->Show(false); | |
| 507 | |
| 508 NSRect toolbar_bar_frame = [GetViewWithID(VIEW_ID_TOOLBAR) frame]; | |
| 509 find_bar_frame = [GetViewWithID(VIEW_ID_FIND_BAR) frame]; | |
| 510 EXPECT_EQ(NSMinY(toolbar_bar_frame) - bookmarks::kBookmarkBarOverlap + | |
| 511 line_width, | |
| 512 NSMaxY(find_bar_frame)); | |
| 513 } | |
| 514 | |
| 515 // Verify that if bookmark bar is underneath Instant search results then | |
| 516 // clicking on Instant search results still works. | |
| 517 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | |
| 518 InstantSearchResultsHitTest) { | |
| 519 browser()->window()->ToggleBookmarkBar(); | |
| 520 ShowInstantResults(); | |
| 521 | |
| 522 NSView* bookmarkView = [[controller() bookmarkBarController] view]; | |
| 523 NSView* contentView = [[controller() window] contentView]; | |
| 524 NSPoint point = [bookmarkView convertPoint:NSMakePoint(1, 1) | |
| 525 toView:[contentView superview]]; | |
| 526 | |
| 527 EXPECT_FALSE([[contentView hitTest:point] isDescendantOf:bookmarkView]); | |
| 528 EXPECT_TRUE([[contentView hitTest:point] | |
| 529 isDescendantOf:[controller() tabContentArea]]); | |
| 530 } | |
| 531 | |
| 532 // Verify that |currentInstantUIState| returns the correct value for search | |
| 533 // results mode. | |
| 534 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, InstantSearchResultsMode) { | |
| 535 chrome::EnableInstantExtendedAPIForTesting(); | |
| 536 SearchMode mode(SearchMode::MODE_SEARCH_RESULTS, SearchMode::ORIGIN_SEARCH); | |
| 537 browser()->search_model()->SetMode(mode); | |
| 538 browser()->search_model()->SetTopBarsVisible(false); | |
| 539 EXPECT_TRUE(browser()->search_model()->mode().is_search_results()); | |
| 540 EXPECT_EQ(browser_window_controller::kInstantUIFullPageResults, | |
| 541 [controller() currentInstantUIState]); | |
| 542 } | |
| 543 | |
| 544 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) { | 295 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) { |
| 545 ASSERT_TRUE([controller() isKindOfClass:[BrowserWindowController class]]); | 296 ASSERT_TRUE([controller() isKindOfClass:[BrowserWindowController class]]); |
| 546 EXPECT_TRUE([controller() isTabbedWindow]); | 297 EXPECT_TRUE([controller() isTabbedWindow]); |
| 547 EXPECT_TRUE([controller() hasTabStrip]); | 298 EXPECT_TRUE([controller() hasTabStrip]); |
| 548 EXPECT_FALSE([controller() hasTitleBar]); | 299 EXPECT_FALSE([controller() hasTitleBar]); |
| 549 EXPECT_TRUE([controller() hasToolbar]); | 300 EXPECT_TRUE([controller() hasToolbar]); |
| 550 EXPECT_FALSE([controller() isBookmarkBarVisible]); | 301 EXPECT_FALSE([controller() isBookmarkBarVisible]); |
| 551 | 302 |
| 552 NSRect defaultAlertFrame = NSMakeRect(0, 0, 300, 200); | 303 NSRect defaultAlertFrame = NSMakeRect(0, 0, 300, 200); |
| 553 NSWindow* window = browser()->window()->GetNativeWindow(); | 304 NSWindow* window = browser()->window()->GetNativeWindow(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 usingRect:defaultAlertFrame]; | 343 usingRect:defaultAlertFrame]; |
| 593 EXPECT_EQ(NSMinY(alertFrame), | 344 EXPECT_EQ(NSMinY(alertFrame), |
| 594 NSHeight([[popupWindow contentView] frame]) - | 345 NSHeight([[popupWindow contentView] frame]) - |
| 595 defaultAlertFrame.size.height); | 346 defaultAlertFrame.size.height); |
| 596 | 347 |
| 597 // Close the application window. | 348 // Close the application window. |
| 598 popup_browser->tab_strip_model()->CloseSelectedTabs(); | 349 popup_browser->tab_strip_model()->CloseSelectedTabs(); |
| 599 [popupController close]; | 350 [popupController close]; |
| 600 } | 351 } |
| 601 | 352 |
| 602 // Verify that the info bar tip is hidden when the instant overlay is visible. | |
| 603 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | |
| 604 InfoBarTipHiddenForInstant) { | |
| 605 ShowInfoBar(); | |
| 606 EXPECT_FALSE( | |
| 607 [[controller() infoBarContainerController] shouldSuppressTopInfoBarTip]); | |
| 608 | |
| 609 ShowInstantResults(); | |
| 610 EXPECT_TRUE( | |
| 611 [[controller() infoBarContainerController] shouldSuppressTopInfoBarTip]); | |
| 612 | |
| 613 HideInstant(); | |
| 614 EXPECT_FALSE( | |
| 615 [[controller() infoBarContainerController] shouldSuppressTopInfoBarTip]); | |
| 616 } | |
| 617 | |
| 618 // Verify that the info bar tip is hidden when the toolbar is not visible. | 353 // Verify that the info bar tip is hidden when the toolbar is not visible. |
| 619 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 354 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 620 InfoBarTipHiddenForWindowWithoutToolbar) { | 355 InfoBarTipHiddenForWindowWithoutToolbar) { |
| 621 ShowInfoBar(); | 356 ShowInfoBar(); |
| 622 EXPECT_FALSE( | 357 EXPECT_FALSE( |
| 623 [[controller() infoBarContainerController] shouldSuppressTopInfoBarTip]); | 358 [[controller() infoBarContainerController] shouldSuppressTopInfoBarTip]); |
| 624 | 359 |
| 625 gfx::Rect initial_bounds(0, 0, 400, 400); | 360 gfx::Rect initial_bounds(0, 0, 400, 400); |
| 626 chrome::OpenAppShortcutWindow( | 361 chrome::OpenAppShortcutWindow( |
| 627 browser()->profile(), GURL("about:blank"), initial_bounds); | 362 browser()->profile(), GURL("about:blank"), initial_bounds); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 655 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); | 390 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); |
| 656 | 391 |
| 657 base::scoped_nsobject<HistoryOverlayController> overlay( | 392 base::scoped_nsobject<HistoryOverlayController> overlay( |
| 658 [[HistoryOverlayController alloc] initForMode:kHistoryOverlayModeBack]); | 393 [[HistoryOverlayController alloc] initForMode:kHistoryOverlayModeBack]); |
| 659 [overlay showPanelForView:web_contents_view->GetNativeView()]; | 394 [overlay showPanelForView:web_contents_view->GetNativeView()]; |
| 660 EXPECT_TRUE(web_contents_view->GetAllowOverlappingViews()); | 395 EXPECT_TRUE(web_contents_view->GetAllowOverlappingViews()); |
| 661 | 396 |
| 662 overlay.reset(); | 397 overlay.reset(); |
| 663 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); | 398 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); |
| 664 } | 399 } |
| OLD | NEW |