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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 #include "chrome/browser/ui/fullscreen_controller_test.h" | 6 #include "chrome/browser/ui/fullscreen_controller_test.h" |
7 #include "content/public/browser/render_view_host.h" | 7 #include "content/public/browser/render_view_host.h" |
8 #include "content/public/browser/render_widget_host_view.h" | 8 #include "content/public/browser/render_widget_host_view.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 | 10 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 ASSERT_FALSE(IsMouseLocked()); | 242 ASSERT_FALSE(IsMouseLocked()); |
243 ASSERT_TRUE(IsFullscreenForTabOrPending()); | 243 ASSERT_TRUE(IsFullscreenForTabOrPending()); |
244 | 244 |
245 // Accept both, confirm they are enabled and there is no prompt. | 245 // Accept both, confirm they are enabled and there is no prompt. |
246 AcceptCurrentFullscreenOrMouseLockRequest(); | 246 AcceptCurrentFullscreenOrMouseLockRequest(); |
247 ASSERT_TRUE(IsMouseLocked()); | 247 ASSERT_TRUE(IsMouseLocked()); |
248 ASSERT_TRUE(IsFullscreenForTabOrPending()); | 248 ASSERT_TRUE(IsFullscreenForTabOrPending()); |
249 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 249 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
250 } | 250 } |
251 | 251 |
| 252 // Tests mouse lock can be exited and re-entered by an application silently |
| 253 // with no UI distraction for users. |
252 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | 254 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, |
253 MouseLockSilentAfterTargetUnlock) { | 255 MouseLockSilentAfterTargetUnlock) { |
254 ASSERT_TRUE(test_server()->Start()); | 256 ASSERT_TRUE(test_server()->Start()); |
255 ui_test_utils::NavigateToURL(browser(), | 257 ui_test_utils::NavigateToURL(browser(), |
256 test_server()->GetURL(kFullscreenMouseLockHTML)); | 258 test_server()->GetURL(kFullscreenMouseLockHTML)); |
257 | 259 |
258 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 260 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
259 | 261 |
260 // Lock the mouse with a user gesture. | 262 // Lock the mouse with a user gesture. |
261 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 263 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
262 browser(), ui::VKEY_1, false, false, false, false, | 264 browser(), ui::VKEY_1, false, false, false, false, |
263 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 265 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
264 content::NotificationService::AllSources())); | 266 content::NotificationService::AllSources())); |
265 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | 267 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
266 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 268 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
267 ASSERT_FALSE(IsMouseLocked()); | 269 ASSERT_FALSE(IsMouseLocked()); |
268 | 270 |
269 // Accept mouse lock. | 271 // Accept mouse lock. |
270 AcceptCurrentFullscreenOrMouseLockRequest(); | 272 AcceptCurrentFullscreenOrMouseLockRequest(); |
271 ASSERT_TRUE(IsMouseLocked()); | 273 ASSERT_TRUE(IsMouseLocked()); |
272 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | 274 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
273 | 275 |
274 // Unlock the mouse from target, make sure it's unloacked | 276 // Unlock the mouse from target, make sure it's unlocked. |
275 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 277 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
276 browser(), ui::VKEY_U, false, false, false, false, | 278 browser(), ui::VKEY_U, false, false, false, false, |
277 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 279 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
278 content::NotificationService::AllSources())); | 280 content::NotificationService::AllSources())); |
279 ASSERT_FALSE(IsMouseLocked()); | 281 ASSERT_FALSE(IsMouseLocked()); |
280 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 282 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
281 | 283 |
282 // Lock mouse again, make sure it works with no bubble | 284 // Lock mouse again, make sure it works with no bubble. |
283 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 285 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
284 browser(), ui::VKEY_1, false, false, false, false, | 286 browser(), ui::VKEY_1, false, false, false, false, |
285 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 287 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
286 content::NotificationService::AllSources())); | 288 content::NotificationService::AllSources())); |
287 ASSERT_TRUE(IsMouseLocked()); | 289 ASSERT_TRUE(IsMouseLocked()); |
288 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 290 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
289 | 291 |
290 // Unlock the mouse again by target | 292 // Unlock the mouse again by target. |
291 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 293 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
292 browser(), ui::VKEY_U, false, false, false, false, | 294 browser(), ui::VKEY_U, false, false, false, false, |
293 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 295 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
294 content::NotificationService::AllSources())); | 296 content::NotificationService::AllSources())); |
295 ASSERT_FALSE(IsMouseLocked()); | 297 ASSERT_FALSE(IsMouseLocked()); |
296 | 298 |
297 // Lock from target, not user gesture, make sure it works | 299 // Lock from target, not user gesture, make sure it works. |
298 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 300 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
299 browser(), ui::VKEY_D, false, false, false, false, | 301 browser(), ui::VKEY_D, false, false, false, false, |
300 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 302 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
301 content::NotificationService::AllSources())); | 303 content::NotificationService::AllSources())); |
302 ASSERT_TRUE(IsMouseLocked()); | 304 ASSERT_TRUE(IsMouseLocked()); |
303 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 305 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
304 | 306 |
305 // Unlock by escape | 307 // Unlock by escape. |
306 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 308 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
307 browser(), ui::VKEY_ESCAPE, false, false, false, false, | 309 browser(), ui::VKEY_ESCAPE, false, false, false, false, |
308 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 310 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
309 content::NotificationService::AllSources())); | 311 content::NotificationService::AllSources())); |
310 ASSERT_FALSE(IsMouseLocked()); | 312 ASSERT_FALSE(IsMouseLocked()); |
311 | 313 |
312 // Lock the mouse with a user gesture, make sure we see bubble again | 314 // Lock the mouse with a user gesture, make sure we see bubble again. |
313 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 315 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
314 browser(), ui::VKEY_1, false, false, false, false, | 316 browser(), ui::VKEY_1, false, false, false, false, |
315 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 317 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
316 content::NotificationService::AllSources())); | 318 content::NotificationService::AllSources())); |
317 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | 319 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
318 ASSERT_TRUE(IsMouseLocked()); | 320 ASSERT_TRUE(IsMouseLocked()); |
319 } | 321 } |
320 | 322 |
| 323 // Tests Mouse Lock and Fullscreen are exited upon reload. |
| 324 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, |
| 325 ReloadExitsMouseLockAndFullscreen) { |
| 326 ASSERT_TRUE(test_server()->Start()); |
| 327 ui_test_utils::NavigateToURL(browser(), |
| 328 test_server()->GetURL(kFullscreenMouseLockHTML)); |
| 329 |
| 330 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 331 |
| 332 // Request mouse lock. |
| 333 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 334 browser(), ui::VKEY_1, false, false, false, false, |
| 335 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 336 content::NotificationService::AllSources())); |
| 337 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 338 |
| 339 // Reload. Mouse lock request should be cleared. |
| 340 { |
| 341 MouseLockNotificationObserver mouselock_observer; |
| 342 Reload(); |
| 343 mouselock_observer.Wait(); |
| 344 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 345 } |
| 346 |
| 347 // Request mouse lock. |
| 348 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 349 browser(), ui::VKEY_1, false, false, false, false, |
| 350 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 351 content::NotificationService::AllSources())); |
| 352 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 353 |
| 354 // Accept mouse lock. |
| 355 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 356 ASSERT_TRUE(IsMouseLocked()); |
| 357 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
| 358 |
| 359 // Reload. Mouse should be unlocked. |
| 360 { |
| 361 MouseLockNotificationObserver mouselock_observer; |
| 362 Reload(); |
| 363 mouselock_observer.Wait(); |
| 364 ASSERT_FALSE(IsMouseLocked()); |
| 365 } |
| 366 |
| 367 // Request to lock the mouse and enter fullscreen. |
| 368 { |
| 369 FullscreenNotificationObserver fullscreen_observer; |
| 370 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 371 browser(), ui::VKEY_B, false, true, false, false, |
| 372 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
| 373 content::NotificationService::AllSources())); |
| 374 fullscreen_observer.Wait(); |
| 375 } |
| 376 |
| 377 // We are fullscreen. |
| 378 ASSERT_TRUE(IsFullscreenForTabOrPending()); |
| 379 |
| 380 // Reload. Mouse should be unlocked and fullscreen exited. |
| 381 { |
| 382 FullscreenNotificationObserver fullscreen_observer; |
| 383 Reload(); |
| 384 fullscreen_observer.Wait(); |
| 385 ASSERT_FALSE(IsMouseLocked()); |
| 386 ASSERT_FALSE(IsFullscreenForTabOrPending()); |
| 387 } |
| 388 } |
| 389 |
OLD | NEW |