diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 20:17:20 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 20:17:20 +0000 |
commit | d804ac00eae7ba3004ca329da43b127541330068 (patch) | |
tree | 418ef11ddd718dff70142f10a7e004a012b5a313 | |
parent | f8e033da19d0d381c32b59c7cdad4a6b6228d5f6 (diff) | |
download | chromium_src-d804ac00eae7ba3004ca329da43b127541330068.zip chromium_src-d804ac00eae7ba3004ca329da43b127541330068.tar.gz chromium_src-d804ac00eae7ba3004ca329da43b127541330068.tar.bz2 |
Reverting due to memory (Valgrind) errors.
Revert 129448 - Automated tests for full screen & mouse lock M16 features
Tests added to browsertest to improve coverage for fullscreen and mouse lock transitions.
Several helper functions added to BrowserTest. Removes need to friend many tests and simplifies tests to increases readability.
IsFullscreenForTab() removed globally leaving only IsFullscreenForTabOrPending.
IsFullscreenForBrowser() added to fullscreen controller to enable testing.
typedef BrowserWithTestWindowTest BrowserTest; removed due to name conflict.
BUG=100678
TEST=
Review URL: http://codereview.chromium.org/9702055
TBR=scheib@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9875028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129474 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/browser.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/browser_browsertest.cc | 312 | ||||
-rw-r--r-- | chrome/browser/ui/browser_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_controller.mm | 2 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_controller_private.mm | 6 | ||||
-rw-r--r-- | chrome/browser/ui/fullscreen_controller.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/fullscreen_controller.h | 15 | ||||
-rw-r--r-- | chrome/browser/ui/tests/browser_uitest.cc | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 2 | ||||
-rw-r--r-- | content/public/browser/web_contents_delegate.cc | 3 | ||||
-rw-r--r-- | content/public/browser/web_contents_delegate.h | 2 |
12 files changed, 90 insertions, 306 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 2920d28b..113dbbc 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -504,12 +504,8 @@ Browser::~Browser() { TabRestoreServiceDestroyed(tab_restore_service_); } -bool Browser::IsFullscreenForTabOrPending() const { - return fullscreen_controller_->IsFullscreenForTabOrPending(); -} - -bool Browser::IsMouseLockedOrPending() const { - return fullscreen_controller_->IsMouseLockedOrPending(); +bool Browser::IsFullscreenForTab() const { + return fullscreen_controller_->IsFullscreenForTab(); } // static @@ -4198,7 +4194,7 @@ void Browser::ToggleFullscreenModeForTab(WebContents* tab, fullscreen_controller_->ToggleFullscreenModeForTab(tab, enter_fullscreen); } -bool Browser::IsFullscreenForTabOrPending(const WebContents* tab) const { +bool Browser::IsFullscreenForTab(const WebContents* tab) const { return fullscreen_controller_->IsFullscreenForTabOrPending(tab); } diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 051d35e..81c05b2 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -909,11 +909,9 @@ class Browser : public TabHandlerDelegate, bool is_app() const; bool is_devtools() const; - // See FullscreenController::IsFullscreenForTabOrPending. - bool IsFullscreenForTabOrPending() const; - - // True when the mouse cursor is locked or pending lock. - bool IsMouseLockedOrPending() const; + // True when the current tab is in fullscreen mode, requested by + // webkitRequestFullScreen. + bool IsFullscreenForTab() const; // Called each time the browser window is shown. void OnWindowDidShow(); @@ -931,12 +929,14 @@ class Browser : public TabHandlerDelegate, virtual BrowserWindow* CreateBrowserWindow(); private: - friend class BrowserTest; FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest); FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp); FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); + FRIEND_TEST_ALL_PREFIXES(BrowserTest, TestNewTabExitsFullscreen); + FRIEND_TEST_ALL_PREFIXES(BrowserTest, TestTabExitsItselfFromFullscreen); + FRIEND_TEST_ALL_PREFIXES(BrowserTest, TestFullscreenBubbleMouseLockState); FRIEND_TEST_ALL_PREFIXES(BrowserTest, TabEntersPresentationModeFromWindowed); FRIEND_TEST_ALL_PREFIXES(FullscreenExitBubbleControllerTest, DenyExitsFullscreen); @@ -1063,7 +1063,7 @@ class Browser : public TabHandlerDelegate, const FilePath& path) OVERRIDE; virtual void ToggleFullscreenModeForTab(content::WebContents* tab, bool enter_fullscreen) OVERRIDE; - virtual bool IsFullscreenForTabOrPending( + virtual bool IsFullscreenForTab( const content::WebContents* tab) const OVERRIDE; virtual void JSOutOfMemory(content::WebContents* tab) OVERRIDE; virtual void RegisterProtocolHandler(content::WebContents* tab, diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 95c8283..9715b49 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -14,7 +14,6 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/command_updater.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" @@ -87,7 +86,6 @@ const char* kOpenNewBeforeUnloadPage = const FilePath::CharType* kBeforeUnloadFile = FILE_PATH_LITERAL("beforeunload.html"); -const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); @@ -178,15 +176,6 @@ class TestInterstitialPage : public content::InterstitialPageDelegate { InterstitialPage* interstitial_page_; // Owns us. }; -// Fullscreen transition notification observer simplifies test code. -class FullscreenNotificationObserver - : public ui_test_utils::WindowedNotificationObserver { - public: - FullscreenNotificationObserver() : WindowedNotificationObserver( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()) {} -}; - } // namespace class BrowserTest : public ExtensionBrowserTest { @@ -222,93 +211,6 @@ class BrowserTest : public ExtensionBrowserTest { NOTREACHED(); return NULL; } - - void ToggleTabFullscreen(WebContents* tab, bool enter_fullscreen) { - if (IsFullscreenForBrowser()) { - // Changing tab fullscreen state will not actually change the window - // when browser fullscreen is in effect. - browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); - } else { // Not in browser fullscreen, expect window to actually change. - FullscreenNotificationObserver fullscreen_observer; - browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); - fullscreen_observer.Wait(); - ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); - } - } - - void ToggleBrowserFullscreen(bool enter_fullscreen) { - ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); - FullscreenNotificationObserver fullscreen_observer; - - browser()->ToggleFullscreenMode(); - - fullscreen_observer.Wait(); - ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); - ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); - } - - void RequestToLockMouse(content::WebContents* tab) { - browser()->RequestToLockMouse(tab); - } - - void LostMouseLock() { - browser()->LostMouseLock(); - } - - bool IsFullscreenForBrowser() { - return browser()->fullscreen_controller_->IsFullscreenForBrowser(); - } - - bool IsFullscreenForTabOrPending() { - return browser()->IsFullscreenForTabOrPending(); - } - - bool IsMouseLockedOrPending() { - return browser()->IsMouseLockedOrPending(); - } - - bool IsMouseLockPermissionRequested() { - FullscreenExitBubbleType type = - browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - bool mouse_lock = false; - fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); - return mouse_lock; - } - - bool IsFullscreenPermissionRequested() { - FullscreenExitBubbleType type = - browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - bool fullscreen = false; - fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); - return fullscreen; - } - - FullscreenExitBubbleType GetFullscreenExitBubbleType() { - return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - } - - bool IsFullscreenBubbleDisplayed() { - FullscreenExitBubbleType type = - browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix. - return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; - } - - bool IsFullscreenBubbleDisplayingButtons() { - FullscreenExitBubbleType type = - browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - return fullscreen_bubble::ShowButtonsForType(type); - } - - void AcceptCurrentFullscreenOrMouseLockRequest() { - WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - FullscreenExitBubbleType type = - browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); - browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); - } - - // Helper method to be called by multiple tests. - void TestFullscreenMouseLockContentSettings(); }; // Launch the app on a page with no title, check that the app title was set @@ -973,7 +875,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen #endif -// Tests that while in fullscreen creating a new tab will exit fullscreen. IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { ASSERT_TRUE(test_server()->Start()); @@ -982,10 +883,19 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); + { + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); + browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); + fullscreen_observer.Wait(); + ASSERT_TRUE(browser()->window()->IsFullscreen()); + } { - FullscreenNotificationObserver fullscreen_observer; + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); AddTabAtIndex( 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); fullscreen_observer.Wait(); @@ -1001,7 +911,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen #endif -// Tests a tab exiting fullscreen will bring the browser out of fullscreen. IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { ASSERT_TRUE(test_server()->Start()); @@ -1009,12 +918,26 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); + + { + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); + browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); + fullscreen_observer.Wait(); + ASSERT_TRUE(browser()->window()->IsFullscreen()); + } + + { + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); + browser()->ToggleFullscreenModeForTab(fullscreen_tab, false); + fullscreen_observer.Wait(); + ASSERT_FALSE(browser()->window()->IsFullscreen()); + } } -// Tests entering fullscreen and then requesting mouse lock results in -// buttons for the user, and that after confirming the buttons are dismissed. IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { ASSERT_TRUE(test_server()->Start()); @@ -1025,156 +948,25 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); - - // Request mouse lock and verify the bubble is waiting for user confirmation. - RequestToLockMouse(fullscreen_tab); - ASSERT_TRUE(IsMouseLockPermissionRequested()); - - // Accept mouse lock and verify bubble no longer shows confirmation buttons. - AcceptCurrentFullscreenOrMouseLockRequest(); - ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); -} - -// Tests mouse lock fails before fullscreen is entered. -IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { - WebContents* tab = browser()->GetSelectedWebContents(); - ASSERT_FALSE(IsFullscreenBubbleDisplayed()); - - RequestToLockMouse(tab); - ASSERT_FALSE(IsFullscreenBubbleDisplayed()); - - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); - ASSERT_TRUE(IsFullscreenPermissionRequested()); - ASSERT_FALSE(IsMouseLockPermissionRequested()); -} - -// Helper method to be called by multiple tests. -// Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. -void BrowserTest::TestFullscreenMouseLockContentSettings() { - GURL url = test_server()->GetURL("simple.html"); - AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - WebContents* tab = browser()->GetSelectedWebContents(); - - // Validate that going fullscreen for a URL defaults to asking permision. - ASSERT_FALSE(IsFullscreenPermissionRequested()); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); - ASSERT_TRUE(IsFullscreenPermissionRequested()); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); - - // Add content setting to ALLOW fullscreen. - HostContentSettingsMap* settings_map = - browser()->profile()->GetHostContentSettingsMap(); - ContentSettingsPattern pattern = - ContentSettingsPattern::FromURL(url); - settings_map->SetContentSetting( - pattern, ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), - CONTENT_SETTING_ALLOW); - - // Now, fullscreen should not prompt for permission. - ASSERT_FALSE(IsFullscreenPermissionRequested()); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); - ASSERT_FALSE(IsFullscreenPermissionRequested()); - - // Leaving tab in fullscreen, now test mouse lock ALLOW: - - // Validate that mouse lock defaults to asking permision. - ASSERT_FALSE(IsMouseLockPermissionRequested()); - ASSERT_FALSE(IsMouseLockedOrPending()); - RequestToLockMouse(tab); - ASSERT_TRUE(IsMouseLockPermissionRequested()); - ASSERT_TRUE(IsMouseLockedOrPending()); - LostMouseLock(); - - // Add content setting to ALLOW mouse lock. - settings_map->SetContentSetting( - pattern, ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), - CONTENT_SETTING_ALLOW); - - // Now, mouse lock should not prompt for permission. - ASSERT_FALSE(IsMouseLockedOrPending()); - ASSERT_FALSE(IsMouseLockPermissionRequested()); - RequestToLockMouse(tab); - ASSERT_TRUE(IsMouseLockedOrPending()); - ASSERT_FALSE(IsMouseLockPermissionRequested()); - LostMouseLock(); - - // Leaving tab in fullscreen, now test mouse lock BLOCK: - - // Add content setting to BLOCK mouse lock. - settings_map->SetContentSetting( - pattern, ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), - CONTENT_SETTING_BLOCK); - - // Now, mouse lock should not be pending. - ASSERT_FALSE(IsMouseLockedOrPending()); - ASSERT_FALSE(IsMouseLockPermissionRequested()); - RequestToLockMouse(tab); - ASSERT_FALSE(IsMouseLockedOrPending()); - ASSERT_FALSE(IsMouseLockPermissionRequested()); -} - -// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. -IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { - TestFullscreenMouseLockContentSettings(); -} - -// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, -// but with the browser initiated in fullscreen mode first. -IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenMouseLockContentSettings) { - // Enter browser fullscreen first. - ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); - TestFullscreenMouseLockContentSettings(); - ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); -} - -// Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. -IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenExit) { - // Enter browser fullscreen. - ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); - - // Enter tab fullscreen. - AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), - content::PAGE_TRANSITION_TYPED); - WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); - - // Exit browser fullscreen. - ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); - ASSERT_FALSE(browser()->window()->IsFullscreen()); -} - -// Tests Browser Fullscreen remains active after Tab mode entered and exited. -IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenAfterTabFSExit) { - // Enter browser fullscreen. - ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); - - // Enter and then exit tab fullscreen. - AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), - content::PAGE_TRANSITION_TYPED); - WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); + { + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); + browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); + fullscreen_observer.Wait(); + ASSERT_TRUE(browser()->window()->IsFullscreen()); + } - // Verify browser fullscreen still active. - ASSERT_TRUE(IsFullscreenForBrowser()); -} + browser()->RequestToLockMouse(fullscreen_tab); + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + bool mouse_lock = false; + fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); + ASSERT_TRUE(mouse_lock); -// Tests fullscreen entered without permision prompt for file:// urls. -IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenFileURL) { - ui_test_utils::NavigateToURL(browser(), - ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), - FilePath(kSimpleFile))); - WebContents* tab = browser()->GetSelectedWebContents(); - - // Validate that going fullscreen for a file does not ask permision. - ASSERT_FALSE(IsFullscreenPermissionRequested()); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); - ASSERT_FALSE(IsFullscreenPermissionRequested()); - ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); + browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); + type = browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + ASSERT_FALSE(fullscreen_bubble::ShowButtonsForType(type)); } #if defined(OS_MACOSX) @@ -1189,7 +981,9 @@ IN_PROC_BROWSER_TEST_F( WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); { - FullscreenNotificationObserver fullscreen_observer; + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); EXPECT_FALSE(browser()->window()->IsFullscreen()); EXPECT_FALSE(browser()->window()->InPresentationMode()); browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); @@ -1199,7 +993,9 @@ IN_PROC_BROWSER_TEST_F( } { - FullscreenNotificationObserver fullscreen_observer; + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); browser()->TogglePresentationMode(); fullscreen_observer.Wait(); ASSERT_FALSE(browser()->window()->IsFullscreen()); @@ -1209,7 +1005,9 @@ IN_PROC_BROWSER_TEST_F( if (base::mac::IsOSLionOrLater()) { // Test that tab fullscreen mode doesn't make presentation mode the default // on Lion. - FullscreenNotificationObserver fullscreen_observer; + ui_test_utils::WindowedNotificationObserver fullscreen_observer( + chrome::NOTIFICATION_FULLSCREEN_CHANGED, + content::NotificationService::AllSources()); browser()->ToggleFullscreenMode(); fullscreen_observer.Wait(); ASSERT_TRUE(browser()->window()->IsFullscreen()); diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc index f761bdc..b2a38b9 100644 --- a/chrome/browser/ui/browser_unittest.cc +++ b/chrome/browser/ui/browser_unittest.cc @@ -8,6 +8,8 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/site_instance.h" +typedef BrowserWithTestWindowTest BrowserTest; + class TestingOffTheRecordDestructionProfile : public TestingProfile { public: TestingOffTheRecordDestructionProfile() : destroyed_profile_(false) { @@ -21,7 +23,7 @@ class TestingOffTheRecordDestructionProfile : public TestingProfile { DISALLOW_COPY_AND_ASSIGN(TestingOffTheRecordDestructionProfile); }; -class BrowserTestOffTheRecord : public BrowserWithTestWindowTest { +class BrowserTestOffTheRecord : public BrowserTest { public: BrowserTestOffTheRecord() : off_the_record_profile_(NULL) {} @@ -37,7 +39,7 @@ class BrowserTestOffTheRecord : public BrowserWithTestWindowTest { }; // Various assertions around setting show state. -TEST_F(BrowserWithTestWindowTest, GetSavedWindowShowState) { +TEST_F(BrowserTest, GetSavedWindowShowState) { // Default show state is SHOW_STATE_DEFAULT. EXPECT_EQ(ui::SHOW_STATE_DEFAULT, browser()->GetSavedWindowShowState()); diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index 89a1b9e..da965ae 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -2014,7 +2014,7 @@ willAnimateFromState:(bookmarks::VisualState)oldState if (presentationMode) { BOOL fullscreen = [self isFullscreen]; - BOOL fullscreen_for_tab = browser_->IsFullscreenForTabOrPending(); + BOOL fullscreen_for_tab = browser_->IsFullscreenForTab(); if (!fullscreen_for_tab) [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; enteredPresentationModeFromFullscreen_ = fullscreen; diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm index 75362f9..1c74e9b 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm @@ -676,7 +676,7 @@ willPositionSheet:(NSWindow*)sheet return; if (presentationMode) { - BOOL fullscreen_for_tab = browser_->IsFullscreenForTabOrPending(); + BOOL fullscreen_for_tab = browser_->IsFullscreenForTab(); BOOL showDropdown = !fullscreen_for_tab && (forceDropdown || [self floatingBarHasFocus]); NSView* contentView = [[self window] contentView]; @@ -789,7 +789,7 @@ willPositionSheet:(NSWindow*)sheet } - (void)showFullscreenExitBubbleIfNecessary { - if (!browser_->IsFullscreenForTabOrPending()) { + if (!browser_->IsFullscreenForTab()) { return; } @@ -851,7 +851,7 @@ willPositionSheet:(NSWindow*)sheet NSWindow* window = [self window]; savedRegularWindowFrame_ = [window frame]; BOOL mode = [self shouldUsePresentationModeWhenEnteringFullscreen]; - mode = mode || browser_->IsFullscreenForTabOrPending(); + mode = mode || browser_->IsFullscreenForTab(); enteringFullscreen_ = YES; [self setPresentationModeInternal:mode forceDropdown:NO]; } diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc index 24f363a..36ebb44 100644 --- a/chrome/browser/ui/fullscreen_controller.cc +++ b/chrome/browser/ui/fullscreen_controller.cc @@ -39,12 +39,16 @@ FullscreenController::FullscreenController(BrowserWindow* window, FullscreenController::~FullscreenController() {} -bool FullscreenController::IsFullscreenForBrowser() const { - return window_->IsFullscreen() && !tab_caused_fullscreen_; +bool FullscreenController::IsFullscreenForTab() const { + return fullscreened_tab_ != NULL; } -bool FullscreenController::IsFullscreenForTabOrPending() const { - return fullscreened_tab_ != NULL; +bool FullscreenController::IsFullscreenForTab(const WebContents* tab) const { + if (IsFullscreenForTabOrPending(tab)) { + DCHECK(window_->IsFullscreen()); + return true; + } + return false; } bool FullscreenController::IsFullscreenForTabOrPending( @@ -57,10 +61,6 @@ bool FullscreenController::IsFullscreenForTabOrPending( return true; } -bool FullscreenController::IsMouseLockedOrPending() const { - return mouse_lock_state_ != MOUSELOCK_NOT_REQUESTED; -} - void FullscreenController::RequestToLockMouse(WebContents* tab) { // Mouse Lock is only permitted when browser is in tab fullscreen. if (!IsFullscreenForTabOrPending(tab)) { @@ -171,7 +171,7 @@ void FullscreenController::LostMouseLock() { } void FullscreenController::OnTabClosing(WebContents* web_contents) { - if (IsFullscreenForTabOrPending(web_contents)) { + if (IsFullscreenForTab(web_contents)) { ExitTabbedFullscreenModeIfNecessary(); // The call to exit fullscreen may result in asynchronous notification of // fullscreen state change (e.g., on Linux). We don't want to rely on it @@ -265,7 +265,7 @@ void FullscreenController::WindowFullscreenStateChanged() { } bool FullscreenController::HandleUserPressedEscape() { - if (!IsFullscreenForTabOrPending()) + if (!IsFullscreenForTab()) return false; ExitTabbedFullscreenModeIfNecessary(); return true; diff --git a/chrome/browser/ui/fullscreen_controller.h b/chrome/browser/ui/fullscreen_controller.h index 9284c19..e3bc446 100644 --- a/chrome/browser/ui/fullscreen_controller.h +++ b/chrome/browser/ui/fullscreen_controller.h @@ -40,21 +40,10 @@ class FullscreenController : public base::RefCounted<FullscreenController> { virtual ~FullscreenController(); // Querying. - - // Returns true if the window is currently fullscreen and was initially - // transitioned to fullscreen by a browser (vs tab) mode transition. - bool IsFullscreenForBrowser() const; - - // Returns true if fullscreen has been caused by a tab. - // The window may still be transitioning, and window_->IsFullscreen() - // may still return false. - bool IsFullscreenForTabOrPending() const; + bool IsFullscreenForTab() const; + bool IsFullscreenForTab(const content::WebContents* tab) const; bool IsFullscreenForTabOrPending(const content::WebContents* tab) const; - // Returns true if the mouse has been locked or a lock request is pending - // user confirmation. - bool IsMouseLockedOrPending() const; - // Requests. void RequestToLockMouse(content::WebContents* tab); void ToggleFullscreenModeForTab(content::WebContents* tab, diff --git a/chrome/browser/ui/tests/browser_uitest.cc b/chrome/browser/ui/tests/browser_uitest.cc index f18be60..4c23a46 100644 --- a/chrome/browser/ui/tests/browser_uitest.cc +++ b/chrome/browser/ui/tests/browser_uitest.cc @@ -28,7 +28,7 @@ namespace { -class BrowserUITest : public UITest { +class BrowserTest : public UITest { }; class VisibleBrowserTest : public UITest { @@ -42,7 +42,7 @@ class VisibleBrowserTest : public UITest { // The browser should quit quickly if it receives a WM_ENDSESSION message // on Windows, or SIGTERM on posix. -TEST_F(BrowserUITest, SessionEnd) { +TEST_F(BrowserTest, SessionEnd) { FilePath test_file(test_data_directory_); test_file = test_file.AppendASCII("title1.html"); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 60baede..aa7d8e0 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -983,7 +983,7 @@ void TabContents::ToggleFullscreenMode(bool enter_fullscreen) { } bool TabContents::IsFullscreenForCurrentTab() const { - return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; + return delegate_ ? delegate_->IsFullscreenForTab(this) : false; } void TabContents::RequestToLockMouse() { diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc index ed5a1d9..0e24df0 100644 --- a/content/public/browser/web_contents_delegate.cc +++ b/content/public/browser/web_contents_delegate.cc @@ -130,8 +130,7 @@ JavaScriptDialogCreator* WebContentsDelegate::GetJavaScriptDialogCreator() { return NULL; } -bool WebContentsDelegate::IsFullscreenForTabOrPending( - const WebContents* tab) const { +bool WebContentsDelegate::IsFullscreenForTab(const WebContents* tab) const { return false; } diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 6c4ec68..2d1669c 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -333,7 +333,7 @@ class CONTENT_EXPORT WebContentsDelegate { // Called when the renderer puts a tab into or out of fullscreen mode. virtual void ToggleFullscreenModeForTab(WebContents* tab, bool enter_fullscreen) {} - virtual bool IsFullscreenForTabOrPending(const WebContents* tab) const; + virtual bool IsFullscreenForTab(const WebContents* tab) const; // Called when a Javascript out of memory notification is received. virtual void JSOutOfMemory(WebContents* tab) {} |