diff options
author | dmurph@chromium.org <dmurph@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 00:15:44 +0000 |
---|---|---|
committer | dmurph@chromium.org <dmurph@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 00:15:44 +0000 |
commit | a9c81f02b244f2afd0c9756e51053dca164c7fcd (patch) | |
tree | 17e4d40135df14a129da3dbe6a670f27044f6910 /chrome/browser/ui/browser_browsertest.cc | |
parent | 15a36f4314b55a421270356c1c7e62722be06b9e (diff) | |
download | chromium_src-a9c81f02b244f2afd0c9756e51053dca164c7fcd.zip chromium_src-a9c81f02b244f2afd0c9756e51053dca164c7fcd.tar.gz chromium_src-a9c81f02b244f2afd0c9756e51053dca164c7fcd.tar.bz2 |
- Added test for silent mouse lock after unlocked by target, added argument to mouse lock request in tests for after_target_unlock_request.
- mouse lock dispatcher keeps track of voluntary unlocks by the target, and adds this as a parameter for the lock request. Fullscreen controller will silently lock the mouse when the mouse was previously voluntarily unlocked by the target.
Contributed by dmurph@chromium.com
BUG=113460
Review URL: https://chromiumcodereview.appspot.com/10443045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_browsertest.cc')
-rw-r--r-- | chrome/browser/ui/browser_browsertest.cc | 83 |
1 files changed, 77 insertions, 6 deletions
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index abc3dc4..6979f48 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -264,8 +264,11 @@ class BrowserTest : public ExtensionBrowserTest { ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); } - void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { - browser()->RequestToLockMouse(tab, user_gesture); + void RequestToLockMouse(content::WebContents* tab, + bool user_gesture, + bool last_unlocked_by_target) { + browser()->RequestToLockMouse(tab, user_gesture, + last_unlocked_by_target); } void LostMouseLock() { @@ -1068,7 +1071,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); // Request mouse lock and verify the bubble is waiting for user confirmation. - RequestToLockMouse(fullscreen_tab, true); + RequestToLockMouse(fullscreen_tab, true, false); ASSERT_TRUE(IsMouseLockPermissionRequested()); // Accept mouse lock and verify bubble no longer shows confirmation buttons. @@ -1302,6 +1305,74 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLockAndFullscreen) { ASSERT_FALSE(IsMouseLockPermissionRequested()); } +IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockSilentAfterTargetUnlock) { + ASSERT_TRUE(test_server()->Start()); + ui_test_utils::NavigateToURL(browser(), + test_server()->GetURL(kFullscreenMouseLockHTML)); + + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); + + // Lock the mouse with a user gesture. + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_1, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + ASSERT_TRUE(IsMouseLockPermissionRequested()); + ASSERT_FALSE(IsMouseLocked()); + + // Accept mouse lock. + AcceptCurrentFullscreenOrMouseLockRequest(); + ASSERT_TRUE(IsMouseLocked()); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + + // Unlock the mouse from target, make sure it's unloacked + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_U, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_FALSE(IsMouseLocked()); + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); + + // Lock mouse again, make sure it works with no bubble + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_1, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_TRUE(IsMouseLocked()); + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); + + // Unlock the mouse again by target + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_U, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_FALSE(IsMouseLocked()); + + // Lock from target, not user gesture, make sure it works + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_D, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_TRUE(IsMouseLocked()); + ASSERT_FALSE(IsFullscreenBubbleDisplayed()); + + // Unlock by escape + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_ESCAPE, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_FALSE(IsMouseLocked()); + + // Lock the mouse with a user gesture, make sure we see bubble again + ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( + browser(), ui::VKEY_1, false, false, false, false, + chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, + content::NotificationService::AllSources())); + ASSERT_TRUE(IsFullscreenBubbleDisplayed()); + ASSERT_TRUE(IsMouseLocked()); +} + // Helper method to be called by multiple tests. // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. void BrowserTest::TestFullscreenMouseLockContentSettings() { @@ -1335,7 +1406,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() { // Validate that mouse lock defaults to asking permision. ASSERT_FALSE(IsMouseLockPermissionRequested()); ASSERT_FALSE(IsMouseLocked()); - RequestToLockMouse(tab, true); + RequestToLockMouse(tab, true, false); ASSERT_TRUE(IsMouseLockPermissionRequested()); LostMouseLock(); @@ -1347,7 +1418,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() { // Now, mouse lock should not prompt for permission. ASSERT_FALSE(IsMouseLockPermissionRequested()); - RequestToLockMouse(tab, true); + RequestToLockMouse(tab, true, false); ASSERT_FALSE(IsMouseLockPermissionRequested()); LostMouseLock(); @@ -1361,7 +1432,7 @@ void BrowserTest::TestFullscreenMouseLockContentSettings() { // Now, mouse lock should not be pending. ASSERT_FALSE(IsMouseLockPermissionRequested()); - RequestToLockMouse(tab, true); + RequestToLockMouse(tab, true, false); ASSERT_FALSE(IsMouseLockPermissionRequested()); } |