| 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 "chrome/browser/content_settings/host_content_settings_map.h" | 6 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/fullscreen_controller_test.h" | 10 #include "chrome/browser/ui/fullscreen_controller_test.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 // Tests that while in fullscreen creating a new tab will exit fullscreen. | 36 // Tests that while in fullscreen creating a new tab will exit fullscreen. |
| 37 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 37 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 38 MAYBE_TestNewTabExitsFullscreen) { | 38 MAYBE_TestNewTabExitsFullscreen) { |
| 39 ASSERT_TRUE(test_server()->Start()); | 39 ASSERT_TRUE(test_server()->Start()); |
| 40 | 40 |
| 41 AddTabAtIndex( | 41 AddTabAtIndex( |
| 42 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 42 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 43 | 43 |
| 44 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 44 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 45 | 45 |
| 46 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 46 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 47 | 47 |
| 48 { | 48 { |
| 49 FullscreenNotificationObserver fullscreen_observer; | 49 FullscreenNotificationObserver fullscreen_observer; |
| 50 AddTabAtIndex( | 50 AddTabAtIndex( |
| 51 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 51 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 52 fullscreen_observer.Wait(); | 52 fullscreen_observer.Wait(); |
| 53 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 53 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
| 58 // http://crbug.com/100467 | 58 // http://crbug.com/100467 |
| 59 #define MAYBE_TestTabExitsItselfFromFullscreen \ | 59 #define MAYBE_TestTabExitsItselfFromFullscreen \ |
| 60 FAILS_TestTabExitsItselfFromFullscreen | 60 FAILS_TestTabExitsItselfFromFullscreen |
| 61 #else | 61 #else |
| 62 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen | 62 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. | 65 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. |
| 66 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 66 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 67 MAYBE_TestTabExitsItselfFromFullscreen) { | 67 MAYBE_TestTabExitsItselfFromFullscreen) { |
| 68 ASSERT_TRUE(test_server()->Start()); | 68 ASSERT_TRUE(test_server()->Start()); |
| 69 | 69 |
| 70 AddTabAtIndex( | 70 AddTabAtIndex( |
| 71 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 71 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 72 | 72 |
| 73 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 73 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 74 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 74 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 75 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 75 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Tests entering fullscreen and then requesting mouse lock results in | 78 // Tests entering fullscreen and then requesting mouse lock results in |
| 79 // buttons for the user, and that after confirming the buttons are dismissed. | 79 // buttons for the user, and that after confirming the buttons are dismissed. |
| 80 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 80 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 81 TestFullscreenBubbleMouseLockState) { | 81 TestFullscreenBubbleMouseLockState) { |
| 82 ASSERT_TRUE(test_server()->Start()); | 82 ASSERT_TRUE(test_server()->Start()); |
| 83 | 83 |
| 84 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 84 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 85 content::PAGE_TRANSITION_TYPED); | 85 content::PAGE_TRANSITION_TYPED); |
| 86 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 86 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), |
| 87 content::PAGE_TRANSITION_TYPED); | 87 content::PAGE_TRANSITION_TYPED); |
| 88 | 88 |
| 89 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 89 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 90 | 90 |
| 91 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 91 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 92 | 92 |
| 93 // Request mouse lock and verify the bubble is waiting for user confirmation. | 93 // Request mouse lock and verify the bubble is waiting for user confirmation. |
| 94 RequestToLockMouse(fullscreen_tab, true, false); | 94 RequestToLockMouse(fullscreen_tab, true, false); |
| 95 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 95 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 96 | 96 |
| 97 // Accept mouse lock and verify bubble no longer shows confirmation buttons. | 97 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
| 98 AcceptCurrentFullscreenOrMouseLockRequest(); | 98 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 99 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | 99 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Helper method to be called by multiple tests. | 102 // Helper method to be called by multiple tests. |
| 103 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 103 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 104 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { | 104 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { |
| 105 GURL url = test_server()->GetURL("simple.html"); | 105 GURL url = test_server()->GetURL("simple.html"); |
| 106 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 106 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 107 WebContents* tab = browser()->GetSelectedWebContents(); | 107 WebContents* tab = browser()->GetActiveWebContents(); |
| 108 | 108 |
| 109 // Validate that going fullscreen for a URL defaults to asking permision. | 109 // Validate that going fullscreen for a URL defaults to asking permision. |
| 110 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 110 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 111 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 111 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 112 ASSERT_TRUE(IsFullscreenPermissionRequested()); | 112 ASSERT_TRUE(IsFullscreenPermissionRequested()); |
| 113 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 113 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
| 114 | 114 |
| 115 // Add content setting to ALLOW fullscreen. | 115 // Add content setting to ALLOW fullscreen. |
| 116 HostContentSettingsMap* settings_map = | 116 HostContentSettingsMap* settings_map = |
| 117 browser()->profile()->GetHostContentSettingsMap(); | 117 browser()->profile()->GetHostContentSettingsMap(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. | 180 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. |
| 181 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { | 181 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { |
| 182 // Enter browser fullscreen. | 182 // Enter browser fullscreen. |
| 183 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 183 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
| 184 | 184 |
| 185 // Enter tab fullscreen. | 185 // Enter tab fullscreen. |
| 186 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 186 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 187 content::PAGE_TRANSITION_TYPED); | 187 content::PAGE_TRANSITION_TYPED); |
| 188 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 188 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 189 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 189 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 190 | 190 |
| 191 // Exit browser fullscreen. | 191 // Exit browser fullscreen. |
| 192 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); | 192 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); |
| 193 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 193 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Tests Browser Fullscreen remains active after Tab mode entered and exited. | 196 // Tests Browser Fullscreen remains active after Tab mode entered and exited. |
| 197 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 197 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 198 BrowserFullscreenAfterTabFSExit) { | 198 BrowserFullscreenAfterTabFSExit) { |
| 199 // Enter browser fullscreen. | 199 // Enter browser fullscreen. |
| 200 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 200 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
| 201 | 201 |
| 202 // Enter and then exit tab fullscreen. | 202 // Enter and then exit tab fullscreen. |
| 203 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 203 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 204 content::PAGE_TRANSITION_TYPED); | 204 content::PAGE_TRANSITION_TYPED); |
| 205 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 205 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 206 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 206 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 207 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 207 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
| 208 | 208 |
| 209 // Verify browser fullscreen still active. | 209 // Verify browser fullscreen still active. |
| 210 ASSERT_TRUE(IsFullscreenForBrowser()); | 210 ASSERT_TRUE(IsFullscreenForBrowser()); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Tests fullscreen entered without permision prompt for file:// urls. | 213 // Tests fullscreen entered without permision prompt for file:// urls. |
| 214 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { | 214 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { |
| 215 ui_test_utils::NavigateToURL(browser(), | 215 ui_test_utils::NavigateToURL(browser(), |
| 216 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 216 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 217 FilePath(kSimpleFile))); | 217 FilePath(kSimpleFile))); |
| 218 WebContents* tab = browser()->GetSelectedWebContents(); | 218 WebContents* tab = browser()->GetActiveWebContents(); |
| 219 | 219 |
| 220 // Validate that going fullscreen for a file does not ask permision. | 220 // Validate that going fullscreen for a file does not ask permision. |
| 221 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 221 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 222 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 222 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 223 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 223 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 224 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 224 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
| 225 } | 225 } |
| 226 | 226 |
| 227 #if defined(OS_MACOSX) | 227 #if defined(OS_MACOSX) |
| 228 // http://crbug.com/100467 | 228 // http://crbug.com/100467 |
| 229 IN_PROC_BROWSER_TEST_F( | 229 IN_PROC_BROWSER_TEST_F( |
| 230 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { | 230 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { |
| 231 ASSERT_TRUE(test_server()->Start()); | 231 ASSERT_TRUE(test_server()->Start()); |
| 232 | 232 |
| 233 AddTabAtIndex( | 233 AddTabAtIndex( |
| 234 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 234 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 235 | 235 |
| 236 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 236 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 237 | 237 |
| 238 { | 238 { |
| 239 FullscreenNotificationObserver fullscreen_observer; | 239 FullscreenNotificationObserver fullscreen_observer; |
| 240 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 240 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
| 241 EXPECT_FALSE(browser()->window()->InPresentationMode()); | 241 EXPECT_FALSE(browser()->window()->InPresentationMode()); |
| 242 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | 242 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); |
| 243 fullscreen_observer.Wait(); | 243 fullscreen_observer.Wait(); |
| 244 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 244 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 245 ASSERT_TRUE(browser()->window()->InPresentationMode()); | 245 ASSERT_TRUE(browser()->window()->InPresentationMode()); |
| 246 } | 246 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 258 // on Lion. | 258 // on Lion. |
| 259 FullscreenNotificationObserver fullscreen_observer; | 259 FullscreenNotificationObserver fullscreen_observer; |
| 260 browser()->ToggleFullscreenMode(); | 260 browser()->ToggleFullscreenMode(); |
| 261 fullscreen_observer.Wait(); | 261 fullscreen_observer.Wait(); |
| 262 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 262 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 263 ASSERT_FALSE(browser()->window()->InPresentationMode()); | 263 ASSERT_FALSE(browser()->window()->InPresentationMode()); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 #endif | 266 #endif |
| 267 | 267 |
| OLD | NEW |