Index: chrome/test/functional/fullscreen_mouselock.py |
=================================================================== |
--- chrome/test/functional/fullscreen_mouselock.py (revision 132298) |
+++ chrome/test/functional/fullscreen_mouselock.py (working copy) |
@@ -16,6 +16,20 @@ |
class FullscreenMouselockTest(pyauto.PyUITest): |
"""TestCase for Fullscreen and Mouse Lock.""" |
+ def setUp(self): |
+ pyauto.PyUITest.setUp(self) |
+ self._driver = self.NewWebDriver() |
+ |
+ def Debug(self): |
+ """Test method for experimentation. |
+ |
+ This method will not run automatically. |
+ """ |
+ driver = self.NewWebDriver() |
Nirnimesh
2012/04/16 19:42:12
why not use self._driver?
dyu1
2012/04/16 23:21:27
Done.
|
+ page = settings.ContentSettingsPage.FromNavigation(driver) |
+ import pdb |
+ pdb.set_trace() |
+ |
def ExtraChromeFlags(self): |
"""Ensures Chrome is launched with custom flags. |
@@ -28,10 +42,6 @@ |
def testFullScreenMouseLockHooks(self): |
"""Verify fullscreen and mouse lock automation hooks work.""" |
- |
- from webdriver_pages import settings |
- from webdriver_pages.settings import Behaviors, ContentTypes |
- driver = self.NewWebDriver() |
self.NavigateToURL(self.GetHttpURLForDataPath( |
'fullscreen_mouselock', 'fullscreen_mouselock.html')) |
@@ -40,7 +50,7 @@ |
self.assertFalse(self.IsFullscreenForTab()) |
# Go fullscreen |
- driver.find_element_by_id('enterFullscreen').click() |
+ self._driver.find_element_by_id('enterFullscreen').click() |
self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) |
# Bubble should be up prompting to allow fullscreen |
@@ -55,7 +65,7 @@ |
# Try to lock mouse, it won't lock yet but permision will be requested. |
self.assertFalse(self.IsMouseLocked()) |
- driver.find_element_by_id('lockMouse1').click() |
+ self._driver.find_element_by_id('lockMouse1').click() |
self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) |
self.assertFalse(self.IsMouseLocked()) |
@@ -66,7 +76,7 @@ |
self.assertFalse(self.IsMouseLocked()) |
# Try mouse lock again, and accept it. |
- driver.find_element_by_id('lockMouse1').click() |
+ self._driver.find_element_by_id('lockMouse1').click() |
self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) |
self.AcceptCurrentFullscreenOrMouseLockRequest() |
self.assertTrue(self.WaitUntil(self.IsMouseLocked)) |
@@ -91,6 +101,159 @@ |
# keys_target.send_keys(Keys.F11) |
# self.assertTrue(self.WaitUntil(self.IsFullscreenForBrowser)) |
+ def LaunchFullscreenMode(self): |
scheib
2012/04/16 21:37:48
Consider naming this so it's clear that it doesn't
dyu1
2012/04/16 23:21:27
Done.
|
+ """Helper function to launch into Fullscreen mode.""" |
+ self.NavigateToURL(self.GetHttpURLForDataPath( |
+ 'fullscreen_mouselock', 'fullscreen_mouselock.html')) |
+ # Should not be in fullscreen mode during initial launch. |
+ self.assertFalse(self.IsFullscreenForBrowser()) |
+ self.assertFalse(self.IsFullscreenForTab()) |
+ # Go into fullscreen mode. |
+ self._driver.find_element_by_id('enterFullscreen').click() |
+ self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) |
+ # Bubble should display prompting to allow fullscreen. |
+ self.assertTrue(self.IsFullscreenBubbleDisplayed()) |
scheib
2012/04/16 21:37:48
FYI: Above these lines are duplicated when testing
dyu1
2012/04/16 23:21:27
There could be a chance for additional duplicates
|
+ self.assertTrue(self.IsFullscreenBubbleDisplayingButtons()) |
+ self.assertTrue(self.IsFullscreenPermissionRequested()) |
+ def _AcceptFullscreenOrMouseLockRequest(self): |
+ """Helper function to accept Fullscreen or Mouse Lock request.""" |
+ self.AcceptCurrentFullscreenOrMouseLockRequest() |
+ self.assertTrue(self.WaitUntil( |
+ lambda: not self.IsFullscreenBubbleDisplayingButtons())) |
+ |
+ def EnableFullscreenAndMouseLockMode(self): |
+ """Helper function to enable fullscreen and mouse lock mode.""" |
+ self.NavigateToURL(self.GetHttpURLForDataPath( |
+ 'fullscreen_mouselock', 'fullscreen_mouselock.html')) |
+ self._driver.find_element_by_id('enterFullscreenAndLockMouse1').click() |
+ self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) |
Nirnimesh
2012/04/16 19:42:12
why not call LaunchFullscreenMode() instead of 127
dyu1
2012/04/16 23:21:27
Done.
|
+ # Allow fullscreen. |
+ self.AcceptCurrentFullscreenOrMouseLockRequest() |
+ self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) |
scheib
2012/04/16 21:37:48
Please add a comment noting that this wait shouldn
dyu1
2012/04/16 23:21:27
Done.
|
+ # Allow mouse lock. |
+ self.AcceptCurrentFullscreenOrMouseLockRequest() |
+ self.assertTrue(self.WaitUntil(self.IsMouseLocked)) |
+ |
+ def EnableMouseLockMode(self): |
Nirnimesh
2012/04/16 19:42:12
_ prefix?
dyu1
2012/04/16 23:21:27
I didn't make this private since later on you'll b
|
+ """Helper function to enable mouse lock mode.""" |
Nirnimesh
2012/04/16 19:42:12
Declare the expectations. That the fullscreen_mous
dyu1
2012/04/16 23:21:27
Done.
|
+ self._driver.find_element_by_id('lockMouse1').click() |
+ self.assertTrue(self.IsMouseLockPermissionRequested()) |
+ self.AcceptCurrentFullscreenOrMouseLockRequest() |
+ self.assertTrue(self.IsMouseLocked()) |
+ |
+ def testPrefsLineEntryForFullscreenAllowed(self): |
+ """Verify line entry when fullscreen is allowed.""" |
+ self.LaunchFullscreenMode() |
+ self._AcceptFullscreenOrMouseLockRequest() |
+ # Get the hostname pattern (e.g. http://127.0.0.1:57622). |
+ hostname_pattern = ( |
+ '/'.join(self.GetHttpURLForDataPath('').split('/')[0:3]) + ',*') |
Nirnimesh
2012/04/16 19:42:12
this is incomprehensible. Don't split. Just remove
dyu1
2012/04/16 23:21:27
Done and moved to setUp()
On 2012/04/16 19:42:12,
|
+ content_settings = ( |
+ self.GetPrefsInfo().Prefs()['profile']['content_settings']) |
+ self.assertEqual( |
+ {hostname_pattern: {'fullscreen': 1}}, # Allow the hostname. |
+ content_settings['pattern_pairs']) |
+ |
+ def testPrefsLineEntryForFullscreenExit(self): |
+ """Verify line entry is empty when exit fullscreen mode before allowing.""" |
+ self.LaunchFullscreenMode() |
+ self._driver.find_element_by_id('exitFullscreen').click() |
+ # Verify exit from fullscreen mode. |
+ self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) |
+ content_settings = ( |
+ self.GetPrefsInfo().Prefs()['profile']['content_settings']) |
+ self.assertEqual({}, content_settings['pattern_pairs']) |
+ |
+ def testPatternsForAllowFullscreenAndPointerLock(self): |
Nirnimesh
2012/04/16 19:42:12
the test names are getting too big. Makes it diffi
dyu1
2012/04/16 23:21:27
Done.
|
+ """Verify hostname pattern and behavior for allowed pointer lock. |
+ |
+ To lock the mouse, the browser needs to be in fullscreen mode. |
+ """ |
+ self.EnableFullscreenAndMouseLockMode() |
+ self.EnableMouseLockMode() |
+ hostname_pattern = ( |
+ '/'.join(self.GetHttpURLForDataPath('').split('/')[0:3]) + ',*') |
+ expected_pattern = ( |
+ {hostname_pattern: {'fullscreen': 1, 'mouselock': 1}}) |
+ content_settings = ( |
+ self.GetPrefsInfo().Prefs()['profile']['content_settings']) |
+ self.assertEqual(expected_pattern, content_settings['pattern_pairs']) |
+ |
+ def testPatternsForAllowMouseLock(self): |
+ """Verify hostname pattern and behavior for allowed mouse lock. |
+ |
+ Enable fullscreen mode and enable mouse lock separately. |
+ """ |
+ self.LaunchFullscreenMode() |
+ self.AcceptCurrentFullscreenOrMouseLockRequest() |
+ self.EnableMouseLockMode() |
+ hostname_pattern = ( |
+ '/'.join(self.GetHttpURLForDataPath('').split('/')[0:3]) + ',*') |
+ expected_pattern = ( |
+ {hostname_pattern: {'fullscreen': 1, 'mouselock': 1}}) |
+ content_settings = ( |
+ self.GetPrefsInfo().Prefs()['profile']['content_settings']) |
+ self.assertEqual(expected_pattern, content_settings['pattern_pairs']) |
+ |
+ def testNoMouseLockRequest(self): |
+ """Verify mouse lock request does not appear. |
+ |
+ When allowing all sites to disable the mouse cursor, the mouse lock request |
+ bubble should not show. The mouse cursor should be automatically disabled |
+ when clicking on a disable mouse button. |
+ """ |
+ # Allow all sites to disable mouse cursor. |
+ self.SetPrefs(pyauto.kDefaultContentSettings, {u'mouselock': 1}) |
+ self.LaunchFullscreenMode() |
+ # Allow for fullscreen mode. |
+ self._AcceptFullscreenOrMouseLockRequest() |
+ self._driver.find_element_by_id('lockMouse1').click() |
+ self.assertTrue(self.WaitUntil( |
+ lambda: not self.IsMouseLockPermissionRequested())) |
+ self.assertTrue(self.IsMouseLocked()) |
+ |
+ def testUnableToLockMouse(self): |
+ """Verify mouse lock is disabled. |
+ |
+ When not allowing any site to disable the mouse cursor, the mouse lock |
+ request bubble should not show and the mouse cursor should not be disabled. |
+ """ |
+ # Do not allow any site to disable mouse cursor. |
+ self.SetPrefs(pyauto.kDefaultContentSettings, {u'mouselock': 2}) |
+ self.LaunchFullscreenMode() |
+ # Allow for fullscreen mode. |
+ self._AcceptFullscreenOrMouseLockRequest() |
+ self._driver.find_element_by_id('lockMouse1').click() |
+ self.assertTrue(self.WaitUntil( |
+ lambda: not self.IsMouseLockPermissionRequested())) |
scheib
2012/04/16 21:37:48
I'm concerned that there is a race condition here.
dyu1
2012/04/16 23:21:27
If the js callback is successful then check the tw
scheib
2012/04/16 23:55:42
If you can get your python test code to wait for s
dyu1
2012/04/23 18:50:26
Done.
|
+ self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) |
+ |
+ def SearchForTextOutsideOfContainer(self): |
+ """Verify text outside of container is not visible when fullscreen. |
+ |
+ Verify this test manually until there is a way to find text on screen |
+ without using FindInPage(). |
+ |
+ The text that is outside of the fullscreen container should only be visible |
+ when fullscreen is off. The text should not be visible while in fullscreen |
+ mode. |
+ """ |
+ self.NavigateToURL(self.GetHttpURLForDataPath( |
+ 'fullscreen_mouselock', 'fullscreen_mouselock.html')) |
+ # Should not be in fullscreen mode during initial launch. |
+ self.assertFalse(self.IsFullscreenForBrowser()) |
+ self.assertFalse(self.IsFullscreenForTab()) |
+ self.assertTrue( |
+ self.WaitUntil(lambda: self.FindInPage( |
+ 'This text is outside of the container')['match_count'], |
+ expect_retval=1)) |
+ # Go into fullscreen mode. |
+ self._driver.find_element_by_id('enterFullscreen').click() |
+ self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) |
+ # TODO(dyu): find a way to verify on screen text instead of using |
+ # FindInPage() which searches for text in the HTML. |
+ |
+ |
if __name__ == '__main__': |
pyauto_functional.Main() |