Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3549)

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 2086273003: [Mac] Reveal Fullscreen Toolbar for Tab Strip Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped_nsobject Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3ae2294dcd677195242d054f60a13e1ba9426958..0c61d7989e15acf42fa265615ef20993cfaae173 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -22,6 +22,8 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
#import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
@@ -35,6 +37,7 @@
#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"
+#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
#include "chrome/browser/ui/extensions/application_launch.h"
@@ -48,6 +51,7 @@
#include "components/infobars/core/infobar_delegate.h"
#include "components/infobars/core/simple_alert_infobar_delegate.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#import "testing/gtest_mac.h"
#import "third_party/ocmock/OCMock/OCMock.h"
@@ -181,6 +185,54 @@ class ViewExposedChecker {
} // namespace
+// Mock PresentationModeController used to test if the toolbar reveal animation
+// is called correctly.
+@interface MockPresentationModeController : PresentationModeController
+
+// 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)exitPresentationMode;
+
+@end
+
+@implementation MockPresentationModeController
+
+@synthesize isRevealingToolbarForTabstrip = isRevealingToolbarForTabstrip_;
+
+- (id)initWithBrowserController:(BrowserWindowController*)controller {
+ if ((self = [super
+ initWithBrowserController:controller
+ style:fullscreen_mac::OMNIBOX_TABS_HIDDEN])) {
+ }
+
+ return self;
+}
+
+- (void)resetToolbarFlag {
+ isRevealingToolbarForTabstrip_ = NO;
+}
+
+- (void)revealToolbarForTabStripChanges {
+ isRevealingToolbarForTabstrip_ = YES;
+}
+
+- (void)exitPresentationMode {
+}
+
+@end
+
@interface InfoBarContainerController(TestingAPI)
- (BOOL)isTopInfoBarAnimationRunning;
@end
@@ -390,6 +442,15 @@ class BrowserWindowControllerTest : public InProcessBrowserTest {
ASSERT_FALSE([controller() isActiveTabContentsControllerResizeBlocked]);
}
+ // Inserts a new tab into the tabstrip at the background.
+ void AddTabAtBackground(int index, GURL url) {
+ chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
+ params.tabstrip_index = index;
+ params.disposition = NEW_BACKGROUND_TAB;
+ chrome::Navigate(&params);
+ content::WaitForLoadStopWithoutSuccessCheck(params.target_contents);
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(BrowserWindowControllerTest);
};
@@ -716,3 +777,47 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR);
EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar));
}
+
+// Tests that the toolbar (tabstrip and omnibox) reveal animation is correctly
+// triggered by the changes in the tabstrip. The animation should not trigger
+// if the current tab is a NTP, since the location bar would be focused.
+IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
+ FullscreenToolbarExposedForTabstripChanges) {
+ base::scoped_nsobject<MockPresentationModeController>
+ presentationModeController([[MockPresentationModeController alloc]
+ initWithBrowserController:controller()]);
+ [controller() setPresentationModeController:presentationModeController.get()];
+
+ 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([presentationModeController isRevealingToolbarForTabstrip]);
+ [presentationModeController resetToolbarFlag];
+
+ // Insert a new tab in the background.
+ AddTabAtBackground(0, GURL("about:blank"));
+ EXPECT_TRUE([presentationModeController isRevealingToolbarForTabstrip]);
+ [presentationModeController resetToolbarFlag];
+
+ // Insert a NTP new tab in the foreground.
+ AddTabAtIndex(0, GURL("about:blank"), ui::PAGE_TRANSITION_LINK);
+ ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]);
+ EXPECT_FALSE([presentationModeController isRevealingToolbarForTabstrip]);
+ [presentationModeController resetToolbarFlag];
+
+ // 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([presentationModeController isRevealingToolbarForTabstrip]);
+ [presentationModeController resetToolbarFlag];
+
+ // Switch to a non-NTP tab.
+ TabStripModel* model = browser()->tab_strip_model();
+ model->ActivateTabAt(1, true);
+ ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]);
+ EXPECT_TRUE([presentationModeController isRevealingToolbarForTabstrip]);
+ [presentationModeController resetToolbarFlag];
+}
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/cocoa/presentation_mode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698