| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); | 257 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); |
| 258 FullscreenNotificationObserver fullscreen_observer; | 258 FullscreenNotificationObserver fullscreen_observer; |
| 259 | 259 |
| 260 browser()->ToggleFullscreenMode(); | 260 browser()->ToggleFullscreenMode(); |
| 261 | 261 |
| 262 fullscreen_observer.Wait(); | 262 fullscreen_observer.Wait(); |
| 263 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 263 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
| 264 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); | 264 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { | 267 void RequestToLockMouse(content::WebContents* tab, |
| 268 browser()->RequestToLockMouse(tab, user_gesture); | 268 bool user_gesture, |
| 269 bool last_unlocked_by_target) { |
| 270 browser()->RequestToLockMouse(tab, user_gesture, |
| 271 last_unlocked_by_target); |
| 269 } | 272 } |
| 270 | 273 |
| 271 void LostMouseLock() { | 274 void LostMouseLock() { |
| 272 browser()->LostMouseLock(); | 275 browser()->LostMouseLock(); |
| 273 } | 276 } |
| 274 | 277 |
| 275 bool SendEscapeToFullscreenController() { | 278 bool SendEscapeToFullscreenController() { |
| 276 return browser()->fullscreen_controller_->HandleUserPressedEscape(); | 279 return browser()->fullscreen_controller_->HandleUserPressedEscape(); |
| 277 } | 280 } |
| 278 | 281 |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 1056 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 1054 content::PAGE_TRANSITION_TYPED); | 1057 content::PAGE_TRANSITION_TYPED); |
| 1055 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 1058 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), |
| 1056 content::PAGE_TRANSITION_TYPED); | 1059 content::PAGE_TRANSITION_TYPED); |
| 1057 | 1060 |
| 1058 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 1061 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 1059 | 1062 |
| 1060 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 1063 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 1061 | 1064 |
| 1062 // Request mouse lock and verify the bubble is waiting for user confirmation. | 1065 // Request mouse lock and verify the bubble is waiting for user confirmation. |
| 1063 RequestToLockMouse(fullscreen_tab, true); | 1066 RequestToLockMouse(fullscreen_tab, true, false); |
| 1064 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 1067 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 1065 | 1068 |
| 1066 // Accept mouse lock and verify bubble no longer shows confirmation buttons. | 1069 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
| 1067 AcceptCurrentFullscreenOrMouseLockRequest(); | 1070 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 1068 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | 1071 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
| 1069 } | 1072 } |
| 1070 | 1073 |
| 1071 // Tests mouse lock then fullscreen. | 1074 // Tests mouse lock then fullscreen. |
| 1072 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { | 1075 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { |
| 1073 ASSERT_TRUE(test_server()->Start()); | 1076 ASSERT_TRUE(test_server()->Start()); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 FullscreenNotificationObserver fullscreen_observer; | 1282 FullscreenNotificationObserver fullscreen_observer; |
| 1280 SendEscapeToFullscreenController(); | 1283 SendEscapeToFullscreenController(); |
| 1281 fullscreen_observer.Wait(); | 1284 fullscreen_observer.Wait(); |
| 1282 } | 1285 } |
| 1283 ASSERT_FALSE(IsMouseLocked()); | 1286 ASSERT_FALSE(IsMouseLocked()); |
| 1284 ASSERT_FALSE(IsFullscreenForTabOrPending()); | 1287 ASSERT_FALSE(IsFullscreenForTabOrPending()); |
| 1285 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1288 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1286 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1289 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1287 } | 1290 } |
| 1288 | 1291 |
| 1292 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockSilentAfterTargetUnlock) { |
| 1293 ASSERT_TRUE(test_server()->Start()); |
| 1294 ui_test_utils::NavigateToURL(browser(), |
| 1295 test_server()->GetURL(kFullscreenMouseLockHTML)); |
| 1296 |
| 1297 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1298 |
| 1299 // Lock the mouse with a user gesture. |
| 1300 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1301 browser(), ui::VKEY_1, false, false, false, false, |
| 1302 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1303 content::NotificationService::AllSources())); |
| 1304 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
| 1305 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 1306 ASSERT_FALSE(IsMouseLocked()); |
| 1307 |
| 1308 // Accept mouse lock. |
| 1309 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 1310 ASSERT_TRUE(IsMouseLocked()); |
| 1311 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
| 1312 |
| 1313 // Unlock the mouse from target, make sure it's unloacked |
| 1314 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1315 browser(), ui::VKEY_U, false, false, false, false, |
| 1316 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1317 content::NotificationService::AllSources())); |
| 1318 ASSERT_FALSE(IsMouseLocked()); |
| 1319 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1320 |
| 1321 // Lock mouse again, make sure it works with no bubble |
| 1322 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1323 browser(), ui::VKEY_1, false, false, false, false, |
| 1324 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1325 content::NotificationService::AllSources())); |
| 1326 ASSERT_TRUE(IsMouseLocked()); |
| 1327 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1328 |
| 1329 // Unlock the mouse again by target |
| 1330 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1331 browser(), ui::VKEY_U, false, false, false, false, |
| 1332 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1333 content::NotificationService::AllSources())); |
| 1334 ASSERT_FALSE(IsMouseLocked()); |
| 1335 |
| 1336 // Lock from target, not user gesture, make sure it works |
| 1337 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1338 browser(), ui::VKEY_D, false, false, false, false, |
| 1339 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1340 content::NotificationService::AllSources())); |
| 1341 ASSERT_TRUE(IsMouseLocked()); |
| 1342 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1343 |
| 1344 // Unlock by escape |
| 1345 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1346 browser(), ui::VKEY_ESCAPE, false, false, false, false, |
| 1347 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1348 content::NotificationService::AllSources())); |
| 1349 ASSERT_FALSE(IsMouseLocked()); |
| 1350 |
| 1351 // Lock the mouse with a user gesture, make sure we see bubble again |
| 1352 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 1353 browser(), ui::VKEY_1, false, false, false, false, |
| 1354 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 1355 content::NotificationService::AllSources())); |
| 1356 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
| 1357 ASSERT_TRUE(IsMouseLocked()); |
| 1358 } |
| 1359 |
| 1289 // Helper method to be called by multiple tests. | 1360 // Helper method to be called by multiple tests. |
| 1290 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 1361 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 1291 void BrowserTest::TestFullscreenMouseLockContentSettings() { | 1362 void BrowserTest::TestFullscreenMouseLockContentSettings() { |
| 1292 GURL url = test_server()->GetURL("simple.html"); | 1363 GURL url = test_server()->GetURL("simple.html"); |
| 1293 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 1364 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 1294 WebContents* tab = browser()->GetSelectedWebContents(); | 1365 WebContents* tab = browser()->GetSelectedWebContents(); |
| 1295 | 1366 |
| 1296 // Validate that going fullscreen for a URL defaults to asking permision. | 1367 // Validate that going fullscreen for a URL defaults to asking permision. |
| 1297 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1368 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1298 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 1369 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1312 // Now, fullscreen should not prompt for permission. | 1383 // Now, fullscreen should not prompt for permission. |
| 1313 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1384 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1314 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 1385 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 1315 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1386 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1316 | 1387 |
| 1317 // Leaving tab in fullscreen, now test mouse lock ALLOW: | 1388 // Leaving tab in fullscreen, now test mouse lock ALLOW: |
| 1318 | 1389 |
| 1319 // Validate that mouse lock defaults to asking permision. | 1390 // Validate that mouse lock defaults to asking permision. |
| 1320 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1391 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1321 ASSERT_FALSE(IsMouseLocked()); | 1392 ASSERT_FALSE(IsMouseLocked()); |
| 1322 RequestToLockMouse(tab, true); | 1393 RequestToLockMouse(tab, true, false); |
| 1323 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 1394 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 1324 LostMouseLock(); | 1395 LostMouseLock(); |
| 1325 | 1396 |
| 1326 // Add content setting to ALLOW mouse lock. | 1397 // Add content setting to ALLOW mouse lock. |
| 1327 settings_map->SetContentSetting( | 1398 settings_map->SetContentSetting( |
| 1328 pattern, ContentSettingsPattern::Wildcard(), | 1399 pattern, ContentSettingsPattern::Wildcard(), |
| 1329 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 1400 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
| 1330 CONTENT_SETTING_ALLOW); | 1401 CONTENT_SETTING_ALLOW); |
| 1331 | 1402 |
| 1332 // Now, mouse lock should not prompt for permission. | 1403 // Now, mouse lock should not prompt for permission. |
| 1333 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1404 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1334 RequestToLockMouse(tab, true); | 1405 RequestToLockMouse(tab, true, false); |
| 1335 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1406 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1336 LostMouseLock(); | 1407 LostMouseLock(); |
| 1337 | 1408 |
| 1338 // Leaving tab in fullscreen, now test mouse lock BLOCK: | 1409 // Leaving tab in fullscreen, now test mouse lock BLOCK: |
| 1339 | 1410 |
| 1340 // Add content setting to BLOCK mouse lock. | 1411 // Add content setting to BLOCK mouse lock. |
| 1341 settings_map->SetContentSetting( | 1412 settings_map->SetContentSetting( |
| 1342 pattern, ContentSettingsPattern::Wildcard(), | 1413 pattern, ContentSettingsPattern::Wildcard(), |
| 1343 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 1414 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
| 1344 CONTENT_SETTING_BLOCK); | 1415 CONTENT_SETTING_BLOCK); |
| 1345 | 1416 |
| 1346 // Now, mouse lock should not be pending. | 1417 // Now, mouse lock should not be pending. |
| 1347 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1418 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1348 RequestToLockMouse(tab, true); | 1419 RequestToLockMouse(tab, true, false); |
| 1349 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1420 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1350 } | 1421 } |
| 1351 | 1422 |
| 1352 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 1423 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 1353 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { | 1424 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { |
| 1354 TestFullscreenMouseLockContentSettings(); | 1425 TestFullscreenMouseLockContentSettings(); |
| 1355 } | 1426 } |
| 1356 | 1427 |
| 1357 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, | 1428 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, |
| 1358 // but with the browser initiated in fullscreen mode first. | 1429 // but with the browser initiated in fullscreen mode first. |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 command_line->AppendSwitchASCII(switches::kApp, url.spec()); | 2210 command_line->AppendSwitchASCII(switches::kApp, url.spec()); |
| 2140 } | 2211 } |
| 2141 }; | 2212 }; |
| 2142 | 2213 |
| 2143 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { | 2214 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { |
| 2144 // Test that an application browser window loads correctly. | 2215 // Test that an application browser window loads correctly. |
| 2145 | 2216 |
| 2146 // Verify the browser is in application mode. | 2217 // Verify the browser is in application mode. |
| 2147 EXPECT_TRUE(browser()->IsApplication()); | 2218 EXPECT_TRUE(browser()->IsApplication()); |
| 2148 } | 2219 } |
| OLD | NEW |