Index: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm |
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm |
index 8686570a5a34b85b56026b0f9b074b61dfbae1b8..c5a16157de483794035a4dec222d560b5af60e49 100644 |
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm |
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm |
@@ -33,7 +33,7 @@ |
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
#import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
-#import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h" |
+#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h" |
#import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
@@ -185,53 +185,26 @@ class ViewExposedChecker { |
} // namespace |
-// Mock FullscreenToolbarController used to test if the toolbar reveal animation |
-// is called correctly. |
-@interface MockFullscreenToolbarController : FullscreenToolbarController |
- |
-// True if revealToolbarForTabStripChanges was called. |
-@property(nonatomic, assign) BOOL isRevealingToolbarForTabstrip; |
- |
-// Initializer. |
-- (id)initWithBrowserController:(BrowserWindowController*)controller; |
- |
-// Sets isRevealingToolbarForTabstrip back to false. |
-- (void)resetToolbarFlag; |
- |
-// Overridden to set isRevealingToolbarForTabstrip to true when it's called. |
-- (void)revealToolbarForTabStripChanges; |
- |
-// Overridden so that we don't have to deal with the DCHECKs when the |
-// BWC exits fullscreen. |
-- (void)exitFullscreenMode; |
- |
-@end |
- |
-@implementation MockFullscreenToolbarController |
- |
-@synthesize isRevealingToolbarForTabstrip = isRevealingToolbarForTabstrip_; |
+// Mock FullscreenToolbarLayoutManager used to test if the toolbar reveal |
+// animation is called correctly. |
+class MockFullscreenToolbarLayoutManager |
+ : public FullscreenToolbarLayoutManager { |
+ public: |
+ MockFullscreenToolbarLayoutManager(BrowserWindowController* controller) |
+ : FullscreenToolbarLayoutManager(controller), |
+ is_revealing_toolbar_(false) {} |
-- (id)initWithBrowserController:(BrowserWindowController*)controller { |
- if ((self = [super initWithBrowserController:controller |
- style:FullscreenSlidingStyle:: |
- OMNIBOX_TABS_HIDDEN])) { |
+ void RevealToolbarForTabStripChanges() override { |
+ is_revealing_toolbar_ = true; |
} |
- return self; |
-} |
+ void ResetRevealFlag() { is_revealing_toolbar_ = false; } |
-- (void)resetToolbarFlag { |
- isRevealingToolbarForTabstrip_ = NO; |
-} |
+ bool is_revealing_toolbar() const { return is_revealing_toolbar_; } |
-- (void)revealToolbarForTabStripChanges { |
- isRevealingToolbarForTabstrip_ = YES; |
-} |
- |
-- (void)exitFullscreenMode { |
-} |
- |
-@end |
+ private: |
+ bool is_revealing_toolbar_; |
+}; |
@interface InfoBarContainerController(TestingAPI) |
- (BOOL)isTopInfoBarAnimationRunning; |
@@ -371,17 +344,6 @@ class BrowserWindowControllerTest : public InProcessBrowserTest { |
runner->Run(); |
} |
- void VerifyFullscreenToolbarVisibility(FullscreenSlidingStyle style) { |
- EXPECT_EQ([[controller() fullscreenToolbarController] slidingStyle], style); |
- |
- NSRect toolbarFrame = [[[controller() toolbarController] view] frame]; |
- NSRect screenFrame = [[[controller() window] screen] frame]; |
- if (style == FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT) |
- EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame)); |
- else |
- EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame)); |
- } |
- |
NSInteger GetExpectedTopInfoBarTipHeight() { |
InfoBarContainerController* info_bar_container_controller = |
[controller() infoBarContainerController]; |
@@ -748,33 +710,33 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, FullscreenResizeFlags) { |
// Tests that the omnibox and tabs are hidden/visible in fullscreen mode. |
// Ensure that when the user toggles this setting, the omnibox, tabs and |
// preferences are updated correctly. |
-// Flakily times out. http://crbug.com/599119 |
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
- DISABLED_FullscreenToolbarIsVisibleAccordingToPrefs) { |
+ FullscreenToolbarIsVisibleAccordingToPrefs) { |
// Tests that the preference is set to true by default. |
PrefService* prefs = browser()->profile()->GetPrefs(); |
EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
+ FullscreenToolbarLayoutManager* manager = |
+ [controller() fullscreenToolbarLayoutManager]; |
+ |
// Toggle fullscreen and check if the toolbar is shown. |
ToggleFullscreenAndWaitForNotification(); |
- VerifyFullscreenToolbarVisibility( |
- FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT); |
+ EXPECT_EQ(FullscreenToolbarStyle::TOOLBAR_PRESENT, |
+ manager->ComputeToolbarLayout().toolbarStyle); |
// Toggle the visibility of the fullscreen toolbar. Verify that the toolbar |
// is hidden and the preference is correctly updated. |
- [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; |
chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
EXPECT_FALSE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
- VerifyFullscreenToolbarVisibility( |
- FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN); |
+ EXPECT_EQ(FullscreenToolbarStyle::TOOLBAR_HIDDEN, |
+ manager->ComputeToolbarLayout().toolbarStyle); |
// Toggle out and back into fullscreen and verify that the toolbar is still |
// hidden. |
ToggleFullscreenAndWaitForNotification(); |
ToggleFullscreenAndWaitForNotification(); |
- [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; |
- VerifyFullscreenToolbarVisibility( |
- FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN); |
+ EXPECT_EQ(FullscreenToolbarStyle::TOOLBAR_HIDDEN, |
+ manager->ComputeToolbarLayout().toolbarStyle); |
chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
@@ -785,42 +747,43 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
// if the current tab is a NTP, since the location bar would be focused. |
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
FullscreenToolbarExposedForTabstripChanges) { |
- base::scoped_nsobject<MockFullscreenToolbarController> |
- fullscreenToolbarController([[MockFullscreenToolbarController alloc] |
- initWithBrowserController:controller()]); |
- [controller() |
- setFullscreenToolbarController:fullscreenToolbarController.get()]; |
+ MockFullscreenToolbarLayoutManager* layout_manager = |
+ new MockFullscreenToolbarLayoutManager(controller()); |
+ [controller() setFullscreenToolbarLayoutManager:layout_manager]; |
ToggleFullscreenAndWaitForNotification(); |
// Insert a non-NTP new tab in the foreground. |
AddTabAtIndex(0, GURL("http://google.com"), ui::PAGE_TRANSITION_LINK); |
ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); |
- EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
- [fullscreenToolbarController resetToolbarFlag]; |
+ EXPECT_TRUE(layout_manager->is_revealing_toolbar()); |
+ layout_manager->ResetRevealFlag(); |
// Insert a new tab in the background. |
AddTabAtBackground(0, GURL("about:blank")); |
- EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
- [fullscreenToolbarController resetToolbarFlag]; |
+ EXPECT_TRUE(layout_manager->is_revealing_toolbar()); |
+ layout_manager->ResetRevealFlag(); |
// Insert a NTP new tab in the foreground. |
AddTabAtIndex(0, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); |
ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); |
- EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
- [fullscreenToolbarController resetToolbarFlag]; |
+ EXPECT_FALSE(layout_manager->is_revealing_toolbar()); |
+ layout_manager->ResetRevealFlag(); |
// Insert a new tab in the background. The animation should not be triggered |
// since the location bar should still be focused. |
AddTabAtBackground(1, GURL("http://google.com")); |
ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); |
- EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
- [fullscreenToolbarController resetToolbarFlag]; |
+ EXPECT_FALSE(layout_manager->is_revealing_toolbar()); |
+ layout_manager->ResetRevealFlag(); |
// Switch to a non-NTP tab. |
TabStripModel* model = browser()->tab_strip_model(); |
model->ActivateTabAt(1, true); |
ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); |
- EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
- [fullscreenToolbarController resetToolbarFlag]; |
+ EXPECT_TRUE(layout_manager->is_revealing_toolbar()); |
+ layout_manager->ResetRevealFlag(); |
+ |
+ // Exit fullscreen. |
+ ToggleFullscreenAndWaitForNotification(); |
} |