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

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 | « chrome/test/functional/PYAUTO_TESTS ('k') | 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(self.IsMouseLockPermissionRequested))
175 self.AcceptCurrentFullscreenOrMouseLockRequest() 173 self.AcceptCurrentFullscreenOrMouseLockRequest()
176 self.assertTrue(self.IsMouseLocked()) 174 self.assertTrue(self.IsMouseLocked())
177 175
178 def testPrefsForFullscreenAllowed(self): 176 def testPrefsForFullscreenAllowed(self):
179 """Verify prefs when fullscreen is allowed.""" 177 """Verify prefs when fullscreen is allowed."""
180 self._LaunchFSAndExpectPrompt() 178 self._LaunchFSAndExpectPrompt()
181 self._AcceptFullscreenOrMouseLockRequest() 179 self._AcceptFullscreenOrMouseLockRequest()
182 content_settings = ( 180 content_settings = (
183 self.GetPrefsInfo().Prefs()['profile']['content_settings']) 181 self.GetPrefsInfo().Prefs()['profile']['content_settings'])
184 self.assertEqual( 182 self.assertEqual(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 279 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()))
282 280
283 def testMouseLockInBrowserFS(self): 281 def testMouseLockInBrowserFS(self):
284 """Verify mouse lock in browser fullscreen requires allow prompt.""" 282 """Verify mouse lock in browser fullscreen requires allow prompt."""
285 self._InitiateBrowserFullscreen() 283 self._InitiateBrowserFullscreen()
286 self._driver.set_script_timeout(2) 284 self._driver.set_script_timeout(2)
287 self._driver.execute_script('lockMouse1AndSetLockResult()') 285 self._driver.execute_script('lockMouse1AndSetLockResult()')
288 # Bubble should display prompting to allow mouselock. 286 # Bubble should display prompting to allow mouselock.
289 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 287 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested))
290 self.AcceptCurrentFullscreenOrMouseLockRequest() 288 self.AcceptCurrentFullscreenOrMouseLockRequest()
291
292 # Waits until lock_result gets 'success' or 'failure'. 289 # Waits until lock_result gets 'success' or 'failure'.
293 lock_result = self._driver.execute_script('return lock_result') 290 lock_result = self._driver.execute_script('return lock_result')
294 self.assertEqual(lock_result, 'success', 291 self.assertEqual(lock_result, 'success',
295 msg='Mouse was not locked in browser fullscreen.') 292 msg='Mouse was not locked in browser fullscreen.')
296 293
297 def testNoMouseLockWhenCancelFS(self): 294 def testNoMouseLockWhenCancelFS(self):
298 """Verify mouse lock breaks when canceling tab fullscreen. 295 """Verify mouse lock breaks when canceling tab fullscreen.
299 296
300 This test uses javascript to initiate exit of tab fullscreen after mouse 297 This test uses javascript to initiate exit of tab fullscreen after mouse
301 lock success callback. 298 lock success callback.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 Mouse lock breaks when the focus is placed on another new window. 348 Mouse lock breaks when the focus is placed on another new window.
352 """ 349 """
353 self._LaunchFSAndExpectPrompt() 350 self._LaunchFSAndExpectPrompt()
354 self.AcceptCurrentFullscreenOrMouseLockRequest() 351 self.AcceptCurrentFullscreenOrMouseLockRequest()
355 # Open a new window to shift focus away. 352 # Open a new window to shift focus away.
356 self.OpenNewBrowserWindow(True) 353 self.OpenNewBrowserWindow(True)
357 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 354 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()))
358 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()), 355 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()),
359 msg='Mouse lock did not break when browser lost focus.') 356 msg='Mouse lock did not break when browser lost focus.')
360 357
358 def testMouseLockLostOnReload(self):
359 """Verify mouse lock is lost on page reload."""
360 self.NavigateToURL(self.GetHttpURLForDataPath(
361 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
362 self._EnableMouseLockMode()
363 self.ReloadActiveTab()
364 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()),
365 msg='Mouse lock did not break when page is reloaded.')
366
361 def ExitTabFSToBrowserFS(self): 367 def ExitTabFSToBrowserFS(self):
362 """Verify exiting tab fullscreen leaves browser in browser fullscreen. 368 """Verify exiting tab fullscreen leaves browser in browser fullscreen.
363 369
370 This test is semi-automated.
371
364 The browser initiates browser fullscreen, then initiates tab fullscreen. The 372 The browser initiates browser fullscreen, then initiates tab fullscreen. The
365 test verifies that existing tab fullscreen by simulating ESC key press or 373 test verifies that existing tab fullscreen by simulating ESC key press or
366 clicking the js function to exitFullscreen() will exit the tab fullscreen 374 clicking the js function to exitFullscreen() will exit the tab fullscreen
367 leaving browser fullscreen intact. 375 leaving browser fullscreen intact.
368 """ 376 """
369 self._InitiateBrowserFullscreen() 377 self._InitiateBrowserFullscreen()
370 # Initiate tab fullscreen. 378 # Initiate tab fullscreen.
371 self._driver.find_element_by_id('enterFullscreen').click() 379 self._driver.find_element_by_id('enterFullscreen').click()
372 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 380 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()))
373 # Require manual intervention to send ESC key due to crbug.com/123930. 381 # Require manual intervention to send ESC key due to crbug.com/123930.
374 # TODO(dyu): Update to a full test once associated bug is fixed. 382 # TODO(dyu): Update to a full test once associated bug is fixed.
375 print "Press ESC key to exit tab fullscreen." 383 logging.info('Press ESC key to exit tab fullscreen.')
376 time.sleep(5) 384 time.sleep(5)
377 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 385 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab()))
378 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()), 386 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()),
379 msg='Not in browser fullscreen mode.') 387 msg='Not in browser fullscreen mode.')
380 388
381 self._driver.find_element_by_id('enterFullscreen').click() 389 self._driver.find_element_by_id('enterFullscreen').click()
382 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 390 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()))
383 # Exit tab fullscreen by clicking button exitFullscreen(). 391 # Exit tab fullscreen by clicking button exitFullscreen().
384 self._driver.find_element_by_id('exitFullscreen').click() 392 self._driver.find_element_by_id('exitFullscreen').click()
385 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 393 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab()))
386 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()), 394 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()),
387 msg='Not in browser fullscreen mode.') 395 msg='Not in browser fullscreen mode.')
388 396
389 def F11KeyExitsTabAndBrowserFS(self): 397 def F11KeyExitsTabAndBrowserFS(self):
390 """Verify existing tab fullscreen exits all fullscreen modes. 398 """Verify existing tab fullscreen exits all fullscreen modes.
391 399
400 This test is semi-automated.
401
392 The browser initiates browser fullscreen, then initiates tab fullscreen. The 402 The browser initiates browser fullscreen, then initiates tab fullscreen. The
393 test verifies that existing tab fullscreen by simulating F11 key press or 403 test verifies that existing tab fullscreen by simulating F11 key press or
394 CMD + SHIFT + F keys on the Mac will exit the tab fullscreen and the 404 CMD + SHIFT + F keys on the Mac will exit the tab fullscreen and the
395 browser fullscreen. 405 browser fullscreen.
396 """ 406 """
397 self._InitiateBrowserFullscreen() 407 self._InitiateBrowserFullscreen()
398 # Initiate tab fullscreen. 408 # Initiate tab fullscreen.
399 self._driver.find_element_by_id('enterFullscreen').click() 409 self._driver.find_element_by_id('enterFullscreen').click()
400 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 410 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()))
401 # Require manual intervention to send F11 key due to crbug.com/123930. 411 # Require manual intervention to send F11 key due to crbug.com/123930.
402 # TODO(dyu): Update to a full test once associated bug is fixed. 412 # TODO(dyu): Update to a full test once associated bug is fixed.
403 print "Press F11 key to exit tab fullscreen." 413 logging.info('Press F11 key to exit tab fullscreen.')
404 time.sleep(5) 414 time.sleep(5)
405 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 415 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab()))
406 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForBrowser()), 416 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForBrowser()),
407 msg='Browser is in fullscreen mode.') 417 msg='Browser is in fullscreen mode.')
408 418
409 def SearchForTextOutsideOfContainer(self): 419 def SearchForTextOutsideOfContainer(self):
410 """Verify text outside of container is not visible when fullscreen. 420 """Verify text outside of container is not visible when fullscreen.
411 421
422 This test is semi-automated.
423
412 Verify this test manually until there is a way to find text on screen 424 Verify this test manually until there is a way to find text on screen
413 without using FindInPage(). 425 without using FindInPage().
414 426
415 The text that is outside of the fullscreen container should only be visible 427 The text that is outside of the fullscreen container should only be visible
416 when fullscreen is off. The text should not be visible while in fullscreen 428 when fullscreen is off. The text should not be visible while in fullscreen
417 mode. 429 mode.
418 """ 430 """
419 self.NavigateToURL(self.GetHttpURLForDataPath( 431 self.NavigateToURL(self.GetHttpURLForDataPath(
420 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 432 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
421 # Should not be in fullscreen mode during initial launch. 433 # Should not be in fullscreen mode during initial launch.
422 self.assertFalse(self.IsFullscreenForBrowser()) 434 self.assertFalse(self.IsFullscreenForBrowser())
423 self.assertFalse(self.IsFullscreenForTab()) 435 self.assertFalse(self.IsFullscreenForTab())
424 self.assertTrue( 436 self.assertTrue(
425 self.WaitUntil(lambda: self.FindInPage( 437 self.WaitUntil(lambda: self.FindInPage(
426 'This text is outside of the container')['match_count'], 438 'This text is outside of the container')['match_count'],
427 expect_retval=1)) 439 expect_retval=1))
428 # Go into fullscreen mode. 440 # Go into fullscreen mode.
429 self._driver.find_element_by_id('enterFullscreen').click() 441 self._driver.find_element_by_id('enterFullscreen').click()
430 self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 442 self.assertTrue(self.WaitUntil(self.IsFullscreenForTab))
431 time.sleep(5) 443 time.sleep(5)
432 # TODO(dyu): find a way to verify on screen text instead of using 444 # TODO(dyu): find a way to verify on screen text instead of using
433 # FindInPage() which searches for text in the HTML. 445 # FindInPage() which searches for text in the HTML.
434 446
447 def SameMouseLockMovement(self):
448 """Verify the correct feel of mouse movement data when mouse is locked.
449
450 This test is semi-automated.
451
452 This test loads the same web page in two different tabs while in mouse lock
453 mode. Each tab loads the web page from a different URL (e.g. by loading it
454 from a localhost server and a file url). The test verifies
455 that the mouse lock movements work the same in both
456 tabs.
457 """
458 url1 = self.GetHttpURLForDataPath(
459 'fullscreen_mouselock', 'fullscreen_mouselock.html')
460 url2 = self.GetFileURLForDataPath(
461 'fullscreen_mouselock', 'fullscreen_mouselock.html')
462 tab2 = 'f1-4'
463 self.NavigateToURL(url1)
464 self.RunCommand(pyauto.IDC_NEW_TAB) # Open new tab.
465 self.NavigateToURL(url2, 0, 1)
466 self._driver.switch_to_window(tab2)
467 self._EnableMouseLockMode() # Lock mouse in tab 2.
468 raw_input('Manually move the mouse cursor on the page in tab 2. Shift+Tab \
469 into tab 1, click on lockMouse1() button, and move the mouse \
470 cursor on the page in tab 1. Verify mouse movement is smooth.')
471
435 472
436 if __name__ == '__main__': 473 if __name__ == '__main__':
437 pyauto_functional.Main() 474 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698