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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 | 311 |
312 // Lock the mouse with a user gesture, make sure we see bubble again | 312 // Lock the mouse with a user gesture, make sure we see bubble again |
313 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 313 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
314 browser(), ui::VKEY_1, false, false, false, false, | 314 browser(), ui::VKEY_1, false, false, false, false, |
315 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | 315 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, |
316 content::NotificationService::AllSources())); | 316 content::NotificationService::AllSources())); |
317 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | 317 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); |
318 ASSERT_TRUE(IsMouseLocked()); | 318 ASSERT_TRUE(IsMouseLocked()); |
319 } | 319 } |
320 | 320 |
321 // Tests fullscreen is exited on page navigation. | |
322 // (Similar to fullscreen version in FullscreenControllerTest) | |
323 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
324 TestMouseLockExitsFullscreenOnNavigation) { | |
yzshen1
2012/06/20 18:07:54
'Fullscreen' is not needed in the name, right? It
scheib
2012/06/20 20:38:24
Done.
| |
325 ASSERT_TRUE(test_server()->Start()); | |
326 ui_test_utils::NavigateToURL(browser(), | |
327 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
328 | |
329 // Lock the mouse with a user gesture. | |
330 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
331 browser(), ui::VKEY_1, false, false, false, false, | |
332 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
333 content::NotificationService::AllSources())); | |
334 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
335 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
336 ASSERT_FALSE(IsMouseLocked()); | |
337 | |
338 // Accept mouse lock. | |
339 AcceptCurrentFullscreenOrMouseLockRequest(); | |
340 ASSERT_TRUE(IsMouseLocked()); | |
341 | |
342 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | |
343 | |
344 ASSERT_FALSE(IsMouseLocked()); | |
345 } | |
346 | |
347 // Tests fullscreen is exited when navigating back. | |
348 // (Similar to fullscreen version in FullscreenControllerTest) | |
349 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
350 TestMouseLockExitsFullscreenOnGoBack) { | |
351 ASSERT_TRUE(test_server()->Start()); | |
352 | |
353 // Navigate twice to provide a place to go back to. | |
354 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | |
355 ui_test_utils::NavigateToURL(browser(), | |
356 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
357 | |
358 // Lock the mouse with a user gesture. | |
359 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
360 browser(), ui::VKEY_1, false, false, false, false, | |
361 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
362 content::NotificationService::AllSources())); | |
363 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
364 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
365 ASSERT_FALSE(IsMouseLocked()); | |
366 | |
367 // Accept mouse lock. | |
368 AcceptCurrentFullscreenOrMouseLockRequest(); | |
369 ASSERT_TRUE(IsMouseLocked()); | |
370 | |
371 GoBack(); | |
372 | |
373 ASSERT_FALSE(IsMouseLocked()); | |
374 } | |
375 | |
376 // Tests fullscreen is not exited on sub frame navigation. | |
377 // (Similar to fullscreen version in FullscreenControllerTest) | |
378 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
379 TestMouseLockDoesntExitFullscreenOnSubFrameNavigation) { | |
380 ASSERT_TRUE(test_server()->Start()); | |
381 | |
382 // Create URLs for test page and test page with #fragment. | |
383 GURL url(test_server()->GetURL(kFullscreenMouseLockHTML)); | |
384 GURL url_with_fragment(url.spec() + "#fragment"); | |
385 | |
386 // Navigate to test page. | |
387 ui_test_utils::NavigateToURL(browser(), url); | |
388 | |
389 // Lock the mouse with a user gesture. | |
390 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
391 browser(), ui::VKEY_1, false, false, false, false, | |
392 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
393 content::NotificationService::AllSources())); | |
394 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
395 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
396 ASSERT_FALSE(IsMouseLocked()); | |
koz (OOO until 15th September)
2012/06/19 23:57:17
Maybe this block (in this test and others) should
scheib
2012/06/20 20:38:24
I will do so in another polish patch to keep this
| |
397 | |
398 // Accept mouse lock. | |
399 AcceptCurrentFullscreenOrMouseLockRequest(); | |
400 ASSERT_TRUE(IsMouseLocked()); | |
401 | |
402 // Navigate to url with fragment. Mouse lock should persist. | |
403 ui_test_utils::NavigateToURL(browser(), url_with_fragment); | |
404 ASSERT_TRUE(IsMouseLocked()); | |
405 } | |
406 | |
407 // Tests Mouse Lock and Fullscreen are exited upon reload. | |
408 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
409 ReloadExitsMouseLockAndFullscreen) { | |
410 ASSERT_TRUE(test_server()->Start()); | |
411 ui_test_utils::NavigateToURL(browser(), | |
412 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
413 | |
414 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
415 | |
416 // Request mouse lock. | |
417 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
418 browser(), ui::VKEY_1, false, false, false, false, | |
419 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
420 content::NotificationService::AllSources())); | |
421 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
422 | |
423 // Reload. Mouse lock request should be cleared. | |
424 { | |
425 MouseLockNotificationObserver mouselock_observer; | |
426 Reload(); | |
427 mouselock_observer.Wait(); | |
428 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
429 } | |
430 | |
431 // Request mouse lock. | |
432 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
433 browser(), ui::VKEY_1, false, false, false, false, | |
434 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
435 content::NotificationService::AllSources())); | |
436 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
437 | |
438 // Accept mouse lock. | |
439 AcceptCurrentFullscreenOrMouseLockRequest(); | |
440 ASSERT_TRUE(IsMouseLocked()); | |
441 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
442 | |
443 // Reload. Mouse should be unlocked. | |
444 { | |
445 MouseLockNotificationObserver mouselock_observer; | |
446 Reload(); | |
447 mouselock_observer.Wait(); | |
448 ASSERT_FALSE(IsMouseLocked()); | |
449 } | |
450 | |
451 // Request to lock the mouse and enter fullscreen. | |
452 { | |
453 FullscreenNotificationObserver fullscreen_observer; | |
454 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
455 browser(), ui::VKEY_B, false, true, false, false, | |
456 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
457 content::NotificationService::AllSources())); | |
458 fullscreen_observer.Wait(); | |
459 } | |
460 | |
461 // We are fullscreen. | |
462 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
463 | |
464 // Reload. Mouse should be unlocked and fullscreen exited. | |
465 { | |
466 FullscreenNotificationObserver fullscreen_observer; | |
467 Reload(); | |
468 fullscreen_observer.Wait(); | |
469 ASSERT_FALSE(IsMouseLocked()); | |
470 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
471 } | |
472 } | |
OLD | NEW |