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