| 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 | 9 |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 base::Timer timer(false, true); | 345 base::Timer timer(false, true); |
| 346 timer.Start( | 346 timer.Start( |
| 347 FROM_HERE, | 347 FROM_HERE, |
| 348 base::TimeDelta::FromMilliseconds(15), | 348 base::TimeDelta::FromMilliseconds(15), |
| 349 base::Bind(&CheckBookmarkBarAnimation, | 349 base::Bind(&CheckBookmarkBarAnimation, |
| 350 [controller() bookmarkBarController], | 350 [controller() bookmarkBarController], |
| 351 runner->QuitClosure())); | 351 runner->QuitClosure())); |
| 352 runner->Run(); | 352 runner->Run(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void VerifyFullscreenToolbarVisibility(FullscreenToolbarStyle style) { | |
| 356 EXPECT_EQ( | |
| 357 [[controller() fullscreenToolbarController] computeLayout].toolbarStyle, | |
| 358 style); | |
| 359 | |
| 360 NSRect toolbarFrame = [[[controller() toolbarController] view] frame]; | |
| 361 NSRect screenFrame = [[[controller() window] screen] frame]; | |
| 362 if (style == FullscreenToolbarStyle::TOOLBAR_PRESENT) | |
| 363 EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame)); | |
| 364 else | |
| 365 EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame)); | |
| 366 } | |
| 367 | |
| 368 NSInteger GetExpectedTopInfoBarTipHeight() { | 355 NSInteger GetExpectedTopInfoBarTipHeight() { |
| 369 InfoBarContainerController* info_bar_container_controller = | 356 InfoBarContainerController* info_bar_container_controller = |
| 370 [controller() infoBarContainerController]; | 357 [controller() infoBarContainerController]; |
| 371 CGFloat overlapping_tip_height = | 358 CGFloat overlapping_tip_height = |
| 372 [info_bar_container_controller overlappingTipHeight]; | 359 [info_bar_container_controller overlappingTipHeight]; |
| 373 LocationBarViewMac* location_bar_view = [controller() locationBarBridge]; | 360 LocationBarViewMac* location_bar_view = [controller() locationBarBridge]; |
| 374 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint(); | 361 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint(); |
| 375 | 362 |
| 376 NSPoint info_bar_top = NSMakePoint(0, | 363 NSPoint info_bar_top = NSMakePoint(0, |
| 377 NSHeight([info_bar_container_controller view].frame) - | 364 NSHeight([info_bar_container_controller view].frame) - |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 VerifyFullscreenResizeFlagsAfterTransition(); | 711 VerifyFullscreenResizeFlagsAfterTransition(); |
| 725 | 712 |
| 726 // Exit fullscreen and verify the flags. | 713 // Exit fullscreen and verify the flags. |
| 727 ToggleFullscreenAndWaitForNotification(); | 714 ToggleFullscreenAndWaitForNotification(); |
| 728 VerifyFullscreenResizeFlagsAfterTransition(); | 715 VerifyFullscreenResizeFlagsAfterTransition(); |
| 729 } | 716 } |
| 730 | 717 |
| 731 // Tests that the omnibox and tabs are hidden/visible in fullscreen mode. | 718 // Tests that the omnibox and tabs are hidden/visible in fullscreen mode. |
| 732 // Ensure that when the user toggles this setting, the omnibox, tabs and | 719 // Ensure that when the user toggles this setting, the omnibox, tabs and |
| 733 // preferences are updated correctly. | 720 // preferences are updated correctly. |
| 734 // Flakily times out. http://crbug.com/599119 | |
| 735 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 721 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 736 DISABLED_FullscreenToolbarIsVisibleAccordingToPrefs) { | 722 FullscreenToolbarIsVisibleAccordingToPrefs) { |
| 737 // Tests that the preference is set to true by default. | 723 // Tests that the preference is set to true by default. |
| 738 PrefService* prefs = browser()->profile()->GetPrefs(); | 724 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 739 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 725 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
| 740 | 726 |
| 727 [[controller() fullscreenToolbarController] setMenubarTracker:nil]; |
| 728 |
| 741 // Toggle fullscreen and check if the toolbar is shown. | 729 // Toggle fullscreen and check if the toolbar is shown. |
| 742 ToggleFullscreenAndWaitForNotification(); | 730 ToggleFullscreenAndWaitForNotification(); |
| 743 VerifyFullscreenToolbarVisibility(FullscreenToolbarStyle::TOOLBAR_PRESENT); | 731 EXPECT_EQ( |
| 732 FullscreenToolbarStyle::TOOLBAR_PRESENT, |
| 733 [[controller() fullscreenToolbarController] computeLayout].toolbarStyle); |
| 744 | 734 |
| 745 // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar | 735 // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar |
| 746 // is hidden and the preference is correctly updated. | 736 // is hidden and the preference is correctly updated. |
| 747 [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; | |
| 748 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); | 737 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
| 749 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 738 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
| 750 VerifyFullscreenToolbarVisibility(FullscreenToolbarStyle::TOOLBAR_HIDDEN); | 739 EXPECT_EQ( |
| 740 FullscreenToolbarStyle::TOOLBAR_HIDDEN, |
| 741 [[controller() fullscreenToolbarController] computeLayout].toolbarStyle); |
| 751 | 742 |
| 752 // Toggle out and back into fullscreen and verify that the toolbar is still | 743 // Toggle out and back into fullscreen and verify that the toolbar is still |
| 753 // hidden. | 744 // hidden. |
| 754 ToggleFullscreenAndWaitForNotification(); | 745 ToggleFullscreenAndWaitForNotification(); |
| 755 ToggleFullscreenAndWaitForNotification(); | 746 ToggleFullscreenAndWaitForNotification(); |
| 756 [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; | 747 EXPECT_EQ( |
| 757 VerifyFullscreenToolbarVisibility(FullscreenToolbarStyle::TOOLBAR_HIDDEN); | 748 FullscreenToolbarStyle::TOOLBAR_HIDDEN, |
| 749 [[controller() fullscreenToolbarController] computeLayout].toolbarStyle); |
| 758 | 750 |
| 759 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); | 751 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
| 760 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 752 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
| 761 } | 753 } |
| 762 | 754 |
| 763 // Tests that the toolbar (tabstrip and omnibox) reveal animation is correctly | 755 // Tests that the toolbar (tabstrip and omnibox) reveal animation is correctly |
| 764 // triggered by the changes in the tabstrip. The animation should not trigger | 756 // triggered by the changes in the tabstrip. The animation should not trigger |
| 765 // if the current tab is a NTP, since the location bar would be focused. | 757 // if the current tab is a NTP, since the location bar would be focused. |
| 766 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 758 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 767 FullscreenToolbarExposedForTabstripChanges) { | 759 FullscreenToolbarExposedForTabstripChanges) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 797 EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); | 789 EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
| 798 [fullscreenToolbarController resetToolbarFlag]; | 790 [fullscreenToolbarController resetToolbarFlag]; |
| 799 | 791 |
| 800 // Switch to a non-NTP tab. | 792 // Switch to a non-NTP tab. |
| 801 TabStripModel* model = browser()->tab_strip_model(); | 793 TabStripModel* model = browser()->tab_strip_model(); |
| 802 model->ActivateTabAt(1, true); | 794 model->ActivateTabAt(1, true); |
| 803 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); | 795 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); |
| 804 EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); | 796 EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
| 805 [fullscreenToolbarController resetToolbarFlag]; | 797 [fullscreenToolbarController resetToolbarFlag]; |
| 806 } | 798 } |
| OLD | NEW |