Chromium Code Reviews| 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 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/utf_string_conversions.h" | |
| 6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/fullscreen_controller_test.h" | 11 #include "chrome/browser/ui/fullscreen_controller_test.h" |
| 12 #include "content/public/browser/render_view_host.h" | |
| 13 #include "content/public/browser/web_contents.h" | |
| 11 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 12 #if defined(OS_MACOSX) | 15 #if defined(OS_MACOSX) |
| 13 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
| 14 #endif | 17 #endif |
| 15 | 18 |
| 16 using content::WebContents; | 19 using content::WebContents; |
| 17 | 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); | 23 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 31 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen | 34 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen |
| 32 #else | 35 #else |
| 33 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen | 36 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen |
| 34 #endif | 37 #endif |
| 35 | 38 |
| 36 // Tests that while in fullscreen creating a new tab will exit fullscreen. | 39 // Tests that while in fullscreen creating a new tab will exit fullscreen. |
| 37 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 40 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 38 MAYBE_TestNewTabExitsFullscreen) { | 41 MAYBE_TestNewTabExitsFullscreen) { |
| 39 ASSERT_TRUE(test_server()->Start()); | 42 ASSERT_TRUE(test_server()->Start()); |
| 40 | 43 |
| 41 AddTabAtIndex( | 44 AddTabAtIndexAndWait( |
| 42 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 45 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 43 | 46 |
| 44 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 47 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 45 | 48 |
| 46 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 49 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 47 | 50 |
| 48 { | 51 { |
| 49 FullscreenNotificationObserver fullscreen_observer; | 52 FullscreenNotificationObserver fullscreen_observer; |
| 50 AddTabAtIndex( | 53 AddTabAtIndexAndWait( |
| 51 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 54 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 52 fullscreen_observer.Wait(); | 55 fullscreen_observer.Wait(); |
| 53 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 56 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 54 } | 57 } |
| 55 } | 58 } |
| 56 | 59 |
| 57 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 58 // http://crbug.com/100467 | 61 // http://crbug.com/100467 |
| 59 #define MAYBE_TestTabExitsItselfFromFullscreen \ | 62 #define MAYBE_TestTabExitsItselfFromFullscreen \ |
| 60 FAILS_TestTabExitsItselfFromFullscreen | 63 FAILS_TestTabExitsItselfFromFullscreen |
| 61 #else | 64 #else |
| 62 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen | 65 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen |
| 63 #endif | 66 #endif |
| 64 | 67 |
| 65 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. | 68 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. |
| 66 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 69 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 67 MAYBE_TestTabExitsItselfFromFullscreen) { | 70 MAYBE_TestTabExitsItselfFromFullscreen) { |
| 68 ASSERT_TRUE(test_server()->Start()); | 71 ASSERT_TRUE(test_server()->Start()); |
| 69 | 72 |
| 70 AddTabAtIndex( | 73 AddTabAtIndexAndWait( |
| 71 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 74 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 72 | 75 |
| 73 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 76 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 74 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 77 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 75 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 78 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
| 76 } | 79 } |
| 77 | 80 |
| 78 // Tests entering fullscreen and then requesting mouse lock results in | 81 // Tests entering fullscreen and then requesting mouse lock results in |
| 79 // buttons for the user, and that after confirming the buttons are dismissed. | 82 // buttons for the user, and that after confirming the buttons are dismissed. |
| 80 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 83 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 81 TestFullscreenBubbleMouseLockState) { | 84 TestFullscreenBubbleMouseLockState) { |
| 82 ASSERT_TRUE(test_server()->Start()); | 85 ASSERT_TRUE(test_server()->Start()); |
| 83 | 86 |
| 84 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 87 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
| 85 content::PAGE_TRANSITION_TYPED); | 88 content::PAGE_TRANSITION_TYPED); |
| 86 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 89 AddTabAtIndexAndWait(1, GURL(chrome::kAboutBlankURL), |
| 87 content::PAGE_TRANSITION_TYPED); | 90 content::PAGE_TRANSITION_TYPED); |
| 88 | 91 |
| 89 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 92 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 90 | 93 |
| 91 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 94 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 92 | 95 |
| 93 // Request mouse lock and verify the bubble is waiting for user confirmation. | 96 // Request mouse lock and verify the bubble is waiting for user confirmation. |
| 94 RequestToLockMouse(fullscreen_tab, true, false); | 97 RequestToLockMouse(fullscreen_tab, true, false); |
| 95 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 98 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 96 | 99 |
| 97 // Accept mouse lock and verify bubble no longer shows confirmation buttons. | 100 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
| 98 AcceptCurrentFullscreenOrMouseLockRequest(); | 101 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 99 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | 102 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
| 100 } | 103 } |
| 101 | 104 |
| 102 // Helper method to be called by multiple tests. | 105 // Helper method to be called by multiple tests. |
| 103 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 106 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 104 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { | 107 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { |
| 105 GURL url = test_server()->GetURL("simple.html"); | 108 GURL url = test_server()->GetURL("simple.html"); |
| 106 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 109 AddTabAtIndexAndWait(0, url, content::PAGE_TRANSITION_TYPED); |
| 107 WebContents* tab = browser()->GetActiveWebContents(); | 110 WebContents* tab = browser()->GetActiveWebContents(); |
| 108 | 111 |
| 109 // Validate that going fullscreen for a URL defaults to asking permision. | 112 // Validate that going fullscreen for a URL defaults to asking permision. |
| 110 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 113 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 111 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 114 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 112 ASSERT_TRUE(IsFullscreenPermissionRequested()); | 115 ASSERT_TRUE(IsFullscreenPermissionRequested()); |
| 113 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 116 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
| 114 | 117 |
| 115 // Add content setting to ALLOW fullscreen. | 118 // Add content setting to ALLOW fullscreen. |
| 116 HostContentSettingsMap* settings_map = | 119 HostContentSettingsMap* settings_map = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 TestFullscreenMouseLockContentSettings(); | 179 TestFullscreenMouseLockContentSettings(); |
| 177 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); | 180 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); |
| 178 } | 181 } |
| 179 | 182 |
| 180 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. | 183 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. |
| 181 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { | 184 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { |
| 182 // Enter browser fullscreen. | 185 // Enter browser fullscreen. |
| 183 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 186 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
| 184 | 187 |
| 185 // Enter tab fullscreen. | 188 // Enter tab fullscreen. |
| 186 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 189 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
| 187 content::PAGE_TRANSITION_TYPED); | 190 content::PAGE_TRANSITION_TYPED); |
| 188 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 191 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 189 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 192 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 190 | 193 |
| 191 // Exit browser fullscreen. | 194 // Exit browser fullscreen. |
| 192 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); | 195 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); |
| 193 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 196 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 194 } | 197 } |
| 195 | 198 |
| 196 // Tests Browser Fullscreen remains active after Tab mode entered and exited. | 199 // Tests Browser Fullscreen remains active after Tab mode entered and exited. |
| 197 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 200 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 198 BrowserFullscreenAfterTabFSExit) { | 201 BrowserFullscreenAfterTabFSExit) { |
| 199 // Enter browser fullscreen. | 202 // Enter browser fullscreen. |
| 200 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 203 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
| 201 | 204 |
| 202 // Enter and then exit tab fullscreen. | 205 // Enter and then exit tab fullscreen. |
| 203 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 206 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
| 204 content::PAGE_TRANSITION_TYPED); | 207 content::PAGE_TRANSITION_TYPED); |
| 205 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 208 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 206 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 209 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 207 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 210 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
| 208 | 211 |
| 209 // Verify browser fullscreen still active. | 212 // Verify browser fullscreen still active. |
| 210 ASSERT_TRUE(IsFullscreenForBrowser()); | 213 ASSERT_TRUE(IsFullscreenForBrowser()); |
| 211 } | 214 } |
| 212 | 215 |
| 213 // Tests fullscreen entered without permision prompt for file:// urls. | 216 // Tests fullscreen entered without permision prompt for file:// urls. |
| 214 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { | 217 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { |
| 215 ui_test_utils::NavigateToURL(browser(), | 218 ui_test_utils::NavigateToURL(browser(), |
| 216 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 219 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 217 FilePath(kSimpleFile))); | 220 FilePath(kSimpleFile))); |
| 218 WebContents* tab = browser()->GetActiveWebContents(); | 221 WebContents* tab = browser()->GetActiveWebContents(); |
| 219 | 222 |
| 220 // Validate that going fullscreen for a file does not ask permision. | 223 // Validate that going fullscreen for a file does not ask permision. |
| 221 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 224 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 222 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 225 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 223 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 226 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 224 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 227 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
| 225 } | 228 } |
| 226 | 229 |
| 230 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | |
| 231 TestTabExitsFullscreenOnNavigation) { | |
| 232 ASSERT_TRUE(test_server()->Start()); | |
| 233 | |
| 234 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | |
| 235 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | |
| 236 | |
| 237 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | |
| 238 | |
| 239 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( | |
| 240 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 241 content::NotificationService::AllSources()); | |
| 242 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | |
| 243 tree_updated_observer1.Wait(); | |
|
scheib
2012/06/15 16:12:31
This block (and similar one in next test) can be r
koz (OOO until 15th September)
2012/06/18 02:28:10
Done.
| |
| 244 | |
| 245 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 246 | |
| 247 ui_test_utils::WindowedNotificationObserver tree_updated_observer2( | |
| 248 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 249 content::NotificationService::AllSources()); | |
| 250 browser()->GoBack(CURRENT_TAB); | |
| 251 tree_updated_observer2.Wait(); | |
|
scheib
2012/06/15 16:12:31
Please refactor this block into a method on Fullsc
koz (OOO until 15th September)
2012/06/18 02:28:10
Done.
| |
| 252 | |
| 253 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
| 254 } | |
| 255 | |
| 256 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | |
| 257 TestTabDoesntExitFullscreenOnSubFrameNavigation) { | |
| 258 ASSERT_TRUE(test_server()->Start()); | |
| 259 | |
| 260 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | |
| 261 FilePath(kSimpleFile))); | |
| 262 ui_test_utils::NavigateToURL(browser(), url); | |
| 263 | |
| 264 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | |
| 265 | |
| 266 ui_test_utils::WindowedNotificationObserver tree_updated_observer1( | |
| 267 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 268 content::NotificationService::AllSources()); | |
| 269 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | |
| 270 tree_updated_observer1.Wait(); | |
| 271 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 272 | |
| 273 GURL url_with_fragment(url.spec() + "#fragment"); | |
| 274 ui_test_utils::NavigateToURL(browser(), url_with_fragment); | |
| 275 | |
| 276 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
|
scheib
2012/06/15 16:12:31
If fullscreen were to change, it likely wouldn't h
koz (OOO until 15th September)
2012/06/18 02:28:10
NavigateToURL() blocks until the navigation is com
| |
| 277 } | |
| 278 | |
| 227 #if defined(OS_MACOSX) | 279 #if defined(OS_MACOSX) |
| 228 // http://crbug.com/100467 | 280 // http://crbug.com/100467 |
| 229 IN_PROC_BROWSER_TEST_F( | 281 IN_PROC_BROWSER_TEST_F( |
| 230 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { | 282 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { |
| 231 ASSERT_TRUE(test_server()->Start()); | 283 ASSERT_TRUE(test_server()->Start()); |
| 232 | 284 |
| 233 AddTabAtIndex( | 285 AddTabAtIndexAndWait( |
| 234 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 286 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 235 | 287 |
| 236 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 288 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 237 | 289 |
| 238 { | 290 { |
| 239 FullscreenNotificationObserver fullscreen_observer; | 291 FullscreenNotificationObserver fullscreen_observer; |
| 240 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 292 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
| 241 EXPECT_FALSE(browser()->window()->InPresentationMode()); | 293 EXPECT_FALSE(browser()->window()->InPresentationMode()); |
| 242 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | 294 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); |
| 243 fullscreen_observer.Wait(); | 295 fullscreen_observer.Wait(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 258 // on Lion. | 310 // on Lion. |
| 259 FullscreenNotificationObserver fullscreen_observer; | 311 FullscreenNotificationObserver fullscreen_observer; |
| 260 browser()->ToggleFullscreenMode(); | 312 browser()->ToggleFullscreenMode(); |
| 261 fullscreen_observer.Wait(); | 313 fullscreen_observer.Wait(); |
| 262 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 314 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 263 ASSERT_FALSE(browser()->window()->InPresentationMode()); | 315 ASSERT_FALSE(browser()->window()->InPresentationMode()); |
| 264 } | 316 } |
| 265 } | 317 } |
| 266 #endif | 318 #endif |
| 267 | 319 |
| OLD | NEW |