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

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

Issue 10535173: Add three fullscreen tests and three mouse lock tests. (Closed) Base URL: svn://svn.chromium.org/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
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 136 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
137 # Should not be in fullscreen mode during initial launch. 137 # Should not be in fullscreen mode during initial launch.
138 self.assertFalse(self.IsFullscreenForBrowser()) 138 self.assertFalse(self.IsFullscreenForBrowser())
139 self.assertFalse(self.IsFullscreenForTab()) 139 self.assertFalse(self.IsFullscreenForTab())
140 # Initiate browser fullscreen. 140 # Initiate browser fullscreen.
141 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN) 141 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN)
142 self.assertTrue(self.WaitUntil(self.IsFullscreenForBrowser)) 142 self.assertTrue(self.WaitUntil(self.IsFullscreenForBrowser))
143 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 143 self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab()))
144 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 144 self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()))
145 145
146 def _InitiateTabFullscreen(self):
147 """Helper function that initiates tab fullscreen."""
148 self.NavigateToURL(self.GetHttpURLForDataPath(
149 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
150 # Initiate tab fullscreen.
151 self._driver.find_element_by_id('enterFullscreen').click()
152 self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()))
153
146 def _AcceptFullscreenOrMouseLockRequest(self): 154 def _AcceptFullscreenOrMouseLockRequest(self):
147 """Helper function to accept fullscreen or mouse lock request.""" 155 """Helper function to accept fullscreen or mouse lock request."""
148 self.AcceptCurrentFullscreenOrMouseLockRequest() 156 self.AcceptCurrentFullscreenOrMouseLockRequest()
149 self.assertTrue(self.WaitUntil( 157 self.assertTrue(self.WaitUntil(
150 lambda: not self.IsFullscreenBubbleDisplayingButtons())) 158 lambda: not self.IsFullscreenBubbleDisplayingButtons()))
151 159
152 def _EnableFullscreenAndMouseLockMode(self): 160 def _EnableFullscreenAndMouseLockMode(self):
153 """Helper function to enable fullscreen and mouse lock mode.""" 161 """Helper function to enable fullscreen and mouse lock mode."""
154 self._LaunchFSAndExpectPrompt(button_action='enterFullscreenAndLockMouse1') 162 self._LaunchFSAndExpectPrompt(button_action='enterFullscreenAndLockMouse1')
155 # Allow fullscreen. 163 # Allow fullscreen.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 """Verify mouse lock bubble goes away when tab loses focus.""" 376 """Verify mouse lock bubble goes away when tab loses focus."""
369 self.NavigateToURL(self.GetHttpURLForDataPath( 377 self.NavigateToURL(self.GetHttpURLForDataPath(
370 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 378 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
371 self._driver.find_element_by_id('lockMouse1').click() 379 self._driver.find_element_by_id('lockMouse1').click()
372 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 380 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested))
373 self.AppendTab(pyauto.GURL('chrome://newtab')) 381 self.AppendTab(pyauto.GURL('chrome://newtab'))
374 self.assertTrue(self.WaitUntil( 382 self.assertTrue(self.WaitUntil(
375 lambda: not self.IsFullscreenBubbleDisplayingButtons()), 383 lambda: not self.IsFullscreenBubbleDisplayingButtons()),
376 msg='Mouse lock bubble did not clear when tab lost focus.') 384 msg='Mouse lock bubble did not clear when tab lost focus.')
377 385
386 def testTabFSExitUponNavigation(self):
387 """Verify tab fullscreen exit when navigating to a new page.
388
389 This test navigates to a new page while in tab fullscreen mode by clicking
390 on the js Navigate Back button to navigate backwards to the previous
391 google.html page.
392 """
393 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html'))
394 self._InitiateTabFullscreen()
395 self._driver.find_element_by_id('goBack').click()
Nirnimesh 2012/06/15 05:40:15 use pyauto calls instead of going back from js.
dyu1 2012/06/16 23:24:21 Done.
396 self.assertTrue(
397 self.WaitUntil(lambda: not self.IsFullscreenForTab),
Nirnimesh 2012/06/15 05:40:15 Is IsFullscreenForTab missing ()?
Nirnimesh 2012/06/15 05:40:15 Is WaitUntil really required?
dyu1 2012/06/16 23:24:21 Done.
dyu1 2012/06/16 23:24:21 Done.
398 msg='Tab fullscreen did not exit when navigating to a new page.')
399
400 def testTabFSExitWhenNavToNewPage(self):
401 """Verify tab fullscreen exit when navigating to a new website.
402
403 This test navigates to a new website while in tab fullscreen.
404 """
405 self._InitiateTabFullscreen()
406 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html'))
407 self.assertTrue(
408 self.WaitUntil(lambda: not self.IsFullscreenForTab),
Nirnimesh 2012/06/15 05:40:15 is the waitUntil really required?
dyu1 2012/06/16 23:24:21 Done.
409 msg='Tab fullscreen did not exit when navigating to a new website.')
410
411 def testTabFSDoesNotExitForAnchorLinks(self):
412 """Verify tab fullscreen does not exit for anchor links.
413
414 Tab fullscreen should not exit when following a link to the same page such
415 as example.html#anchor.
416 """
417 self._InitiateTabFullscreen()
418 self._driver.find_element_by_id('anchor').click()
419 self.assertTrue(
scheib 2012/06/15 16:49:00 Some delay is needed here. Can we detect and wait
dyu1 2012/06/16 23:24:21 Researching how to go about doing this. On 2012/0
dyu1 2012/06/27 22:48:44 I ran into two issues with the anchor link. Someti
420 self.WaitUntil(self.IsFullscreenForTab),
421 msg='Tab fullscreen should not exit when clicking on an anchor link.')
422
423 def testMLDoesNotExitForAnchorLinks(self):
424 """Verify mouse lock does not exit for anchor links.
425
426 Mouse lock should not exist when following a link to the same page such as
427 example.html#anchor.
428 """
429 self.NavigateToURL(self.GetHttpURLForDataPath(
430 'fullscreen_mouselock', 'fullscreen_mouselock.html'))
431 lock_result = self._driver.find_element_by_id('lockMouse2').click()
432 self.assertTrue(
433 self.WaitUntil(lambda: self.IsMouseLockPermissionRequested()))
434 self.AcceptCurrentFullscreenOrMouseLockRequest()
435 # Waits until lock_result gets 'success' or 'failure'.
436 lock_result = self._driver.execute_script('return lock_result')
437 self.assertEqual(
438 lock_result, 'success', msg='Mouse is not locked.')
439 self._driver.execute_script('document.getElementById("anchor").click()')
440 self.assertTrue(self.WaitUntil(self.IsMouseLocked),
441 msg='Mouse lock broke when clicking on an anchor link.')
442
378 def ExitTabFSToBrowserFS(self): 443 def ExitTabFSToBrowserFS(self):
379 """Verify exiting tab fullscreen leaves browser in browser fullscreen. 444 """Verify exiting tab fullscreen leaves browser in browser fullscreen.
380 445
381 This test is semi-automated. 446 This test is semi-automated.
382 447
383 The browser initiates browser fullscreen, then initiates tab fullscreen. The 448 The browser initiates browser fullscreen, then initiates tab fullscreen. The
384 test verifies that existing tab fullscreen by simulating ESC key press or 449 test verifies that existing tab fullscreen by simulating ESC key press or
385 clicking the js function to exitFullscreen() will exit the tab fullscreen 450 clicking the js function to exitFullscreen() will exit the tab fullscreen
386 leaving browser fullscreen intact. 451 leaving browser fullscreen intact.
387 """ 452 """
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 self.NavigateToURL(url2, 0, 1) 541 self.NavigateToURL(url2, 0, 1)
477 self._driver.switch_to_window(tab2) 542 self._driver.switch_to_window(tab2)
478 self._EnableMouseLockMode() # Lock mouse in tab 2. 543 self._EnableMouseLockMode() # Lock mouse in tab 2.
479 raw_input('Manually move the mouse cursor on the page in tab 2. Shift+Tab \ 544 raw_input('Manually move the mouse cursor on the page in tab 2. Shift+Tab \
480 into tab 1, click on lockMouse1() button, and move the mouse \ 545 into tab 1, click on lockMouse1() button, and move the mouse \
481 cursor on the page in tab 1. Verify mouse movement is smooth.') 546 cursor on the page in tab 1. Verify mouse movement is smooth.')
482 547
483 548
484 if __name__ == '__main__': 549 if __name__ == '__main__':
485 pyauto_functional.Main() 550 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698