Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: chrome/test/functional/fullscreen_mouselock.py

Issue 10443098: Add additional tests for mouse lock. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import re 8 import re
9 import shutil 9 import shutil
10 import time 10 import time
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 # The wait is needed due to crbug.com/123396. Should be able to click the 157 # The wait is needed due to crbug.com/123396. Should be able to click the
158 # fullscreen and mouselock button and be both accepted in a single action. 158 # fullscreen and mouselock button and be both accepted in a single action.
159 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 159 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested))
160 # Allow mouse lock. 160 # Allow mouse lock.
161 self.AcceptCurrentFullscreenOrMouseLockRequest() 161 self.AcceptCurrentFullscreenOrMouseLockRequest()
162 self.assertTrue(self.WaitUntil(self.IsMouseLocked)) 162 self.assertTrue(self.WaitUntil(self.IsMouseLocked))
163 163
164 def _EnableMouseLockMode(self, button_action='lockMouse1'): 164 def _EnableMouseLockMode(self, button_action='lockMouse1'):
165 """Helper function to enable mouse lock mode. 165 """Helper function to enable mouse lock mode.
166 166
167 For now, to lock the mouse, the browser needs to be in fullscreen mode.
168
169 Args: 167 Args:
170 button_action: The button id to click to initiate an action. Default is to 168 button_action: The button id to click to initiate an action. Default is to
171 click lockMouse1. 169 click lockMouse1.
172 """ 170 """
173 self._driver.find_element_by_id(button_action).click() 171 self._driver.find_element_by_id(button_action).click()
174 self.assertTrue(self.IsMouseLockPermissionRequested()) 172 self.assertTrue(self.WaitUntil(
173 lambda: self.IsMouseLockPermissionRequested()))
Nirnimesh 2012/05/31 00:19:26 lambda: self.IsMouseLockPermissionRequested() -> s
dyu1 2012/05/31 01:09:16 Done.
175 self.AcceptCurrentFullscreenOrMouseLockRequest() 174 self.AcceptCurrentFullscreenOrMouseLockRequest()
176 self.assertTrue(self.IsMouseLocked()) 175 self.assertTrue(self.IsMouseLocked())
177 176
178 def testPrefsForFullscreenAllowed(self): 177 def testPrefsForFullscreenAllowed(self):
179 """Verify prefs when fullscreen is allowed.""" 178 """Verify prefs when fullscreen is allowed."""
180 self._LaunchFSAndExpectPrompt() 179 self._LaunchFSAndExpectPrompt()
181 self._AcceptFullscreenOrMouseLockRequest() 180 self._AcceptFullscreenOrMouseLockRequest()
182 content_settings = ( 181 content_settings = (
183 self.GetPrefsInfo().Prefs()['profile']['content_settings']) 182 self.GetPrefsInfo().Prefs()['profile']['content_settings'])
184 self.assertEqual( 183 self.assertEqual(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 280 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()))
282 281
283 def testMouseLockInBrowserFS(self): 282 def testMouseLockInBrowserFS(self):
284 """Verify mouse lock in browser fullscreen requires allow prompt.""" 283 """Verify mouse lock in browser fullscreen requires allow prompt."""
285 self._InitiateBrowserFullscreen() 284 self._InitiateBrowserFullscreen()
286 self._driver.set_script_timeout(2) 285 self._driver.set_script_timeout(2)
287 self._driver.execute_script('lockMouse1AndSetLockResult()') 286 self._driver.execute_script('lockMouse1AndSetLockResult()')
288 # Bubble should display prompting to allow mouselock. 287 # Bubble should display prompting to allow mouselock.
289 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 288 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested))
290 self.AcceptCurrentFullscreenOrMouseLockRequest() 289 self.AcceptCurrentFullscreenOrMouseLockRequest()
291
292 # Waits until lock_result gets 'success' or 'failure'. 290 # Waits until lock_result gets 'success' or 'failure'.
293 lock_result = self._driver.execute_script('return lock_result') 291 lock_result = self._driver.execute_script('return lock_result')
294 self.assertEqual(lock_result, 'success', 292 self.assertEqual(lock_result, 'success',
295 msg='Mouse was not locked in browser fullscreen.') 293 msg='Mouse was not locked in browser fullscreen.')
296 294
297 def testNoMouseLockWhenCancelFS(self): 295 def testNoMouseLockWhenCancelFS(self):
298 """Verify mouse lock breaks when canceling tab fullscreen. 296 """Verify mouse lock breaks when canceling tab fullscreen.
299 297
300 This test uses javascript to initiate exit of tab fullscreen after mouse 298 This test uses javascript to initiate exit of tab fullscreen after mouse
301 lock success callback. 299 lock success callback.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 self.WaitUntil(lambda: self.FindInPage( 423 self.WaitUntil(lambda: self.FindInPage(
426 'This text is outside of the container')['match_count'], 424 'This text is outside of the container')['match_count'],
427 expect_retval=1)) 425 expect_retval=1))
428 # Go into fullscreen mode. 426 # Go into fullscreen mode.
429 self._driver.find_element_by_id('enterFullscreen').click() 427 self._driver.find_element_by_id('enterFullscreen').click()
430 self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 428 self.assertTrue(self.WaitUntil(self.IsFullscreenForTab))
431 time.sleep(5) 429 time.sleep(5)
432 # TODO(dyu): find a way to verify on screen text instead of using 430 # TODO(dyu): find a way to verify on screen text instead of using
433 # FindInPage() which searches for text in the HTML. 431 # FindInPage() which searches for text in the HTML.
434 432
433 def SameMouseLockMovement(self):
434 """Verify the correct feel of mouse movement data when mouse is locked.
435
436 This test loads the same web page in two different tabs while in mouse lock
437 mode. Each tab loads the web page from a different URL (e.g. by loading it
438 from a localhost server and a file url). The test verifies
439 that the mouse lock movements work the same in both
440 tabs.
441 """
442 url1 = self.GetHttpURLForDataPath(
443 'fullscreen_mouselock', 'fullscreen_mouselock.html')
444 url2 = self.GetFileURLForDataPath(
445 'fullscreen_mouselock', 'fullscreen_mouselock.html')
446 tab2 = 'f1-4'
447 self.NavigateToURL(url1)
448 self.RunCommand(pyauto.IDC_NEW_TAB) # Open new tab.
449 self.NavigateToURL(url2, 0, 1)
450 self._driver.switch_to_window(tab2)
451 self._EnableMouseLockMode() # Lock mouse in tab 2.
452 """
Nirnimesh 2012/05/31 00:19:26 Comments should be comments, not strings
dyu1 2012/05/31 01:09:16 Done.
453 Manually move the mouse cursor on the page in tab 2. Shift+Tab into
Nirnimesh 2012/05/31 00:19:26 The entire string can be moved inside the raw_inpu
dyu1 2012/05/31 01:09:16 Done.
454 tab 1, click on lockMouse1() button, and move the mouse cursor on
455 the page in tab 1. Verify mouse movement is smooth.
456 """
457 raw_input()
Nirnimesh 2012/05/31 00:19:26 Put some instructions in the raw_input() here raw
dyu1 2012/05/31 01:09:16 Done.
458
459 def MouseLockLostOnReload(self):
460 """Verify mouse lock is lost on page reload by pressing F5 key."""
461 self.NavigateToURL(self.GetHttpURLForDataPath(
462 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
463 self._EnableMouseLockMode()
464 # Require manual intervention to send F5 key.
465 print "Press F5 key to reload page and exit mouse lock."
scheib 2012/05/30 23:27:33 Is it possible to use NavigateToURL to reproduce t
Nirnimesh 2012/05/31 00:19:26 print -> logging.info or better still use raw_inp
dyu1 2012/05/31 01:09:16 I used NavigateToURL on line 461. Is that what you
dyu1 2012/05/31 01:09:16 I can't use raw_input() here since when the mouse
466 time.sleep(5)
467 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()),
468 msg='Mouse lock did not break when page is reloaded.')
469
435 470
436 if __name__ == '__main__': 471 if __name__ == '__main__':
437 pyauto_functional.Main() 472 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698