Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 10 matching lines...) Expand all Loading... | |
| 166 | 174 |
| 167 Args: | 175 Args: |
| 168 button_action: The button id to click to initiate an action. Default is to | 176 button_action: The button id to click to initiate an action. Default is to |
| 169 click lockMouse1. | 177 click lockMouse1. |
| 170 """ | 178 """ |
| 171 self._driver.find_element_by_id(button_action).click() | 179 self._driver.find_element_by_id(button_action).click() |
| 172 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) | 180 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) |
| 173 self.AcceptCurrentFullscreenOrMouseLockRequest() | 181 self.AcceptCurrentFullscreenOrMouseLockRequest() |
| 174 self.assertTrue(self.IsMouseLocked()) | 182 self.assertTrue(self.IsMouseLocked()) |
| 175 | 183 |
| 184 def _EnableAndReturnLockMouseResult(self): | |
| 185 """Helper function to enable and return mouse lock result.""" | |
| 186 self.NavigateToURL(self.GetHttpURLForDataPath( | |
| 187 'fullscreen_mouselock', 'fullscreen_mouselock.html')) | |
| 188 lock_result = self._driver.find_element_by_id('lockMouse2').click() | |
|
scheib
2012/06/18 16:26:24
Why is lock_result assigned here?
dyu1
2012/06/18 22:04:41
Done.
| |
| 189 self.assertTrue( | |
| 190 self.WaitUntil(lambda: self.IsMouseLockPermissionRequested())) | |
|
Nirnimesh
2012/06/18 18:31:59
lambda: self.IsMouseLockPermissionRequested()
is
dyu1
2012/06/18 22:04:41
Done.
| |
| 191 self.AcceptCurrentFullscreenOrMouseLockRequest() | |
| 192 # Waits until lock_result gets 'success' or 'failure'. | |
| 193 lock_result = self._driver.execute_script('return lock_result') | |
| 194 return lock_result | |
|
Nirnimesh
2012/06/18 18:31:59
merge with previous line
dyu1
2012/06/18 22:04:41
Done.
| |
| 195 | |
| 176 def testPrefsForFullscreenAllowed(self): | 196 def testPrefsForFullscreenAllowed(self): |
| 177 """Verify prefs when fullscreen is allowed.""" | 197 """Verify prefs when fullscreen is allowed.""" |
| 178 self._LaunchFSAndExpectPrompt() | 198 self._LaunchFSAndExpectPrompt() |
| 179 self._AcceptFullscreenOrMouseLockRequest() | 199 self._AcceptFullscreenOrMouseLockRequest() |
| 180 content_settings = ( | 200 content_settings = ( |
| 181 self.GetPrefsInfo().Prefs()['profile']['content_settings']) | 201 self.GetPrefsInfo().Prefs()['profile']['content_settings']) |
| 182 self.assertEqual( | 202 self.assertEqual( |
| 183 {self._hostname_pattern + ',*': {'fullscreen': 1}}, # Allow hostname. | 203 {self._hostname_pattern + ',*': {'fullscreen': 1}}, # Allow hostname. |
| 184 content_settings['pattern_pairs'], | 204 content_settings['pattern_pairs'], |
| 185 msg='Saved hostname pattern does not match expected pattern.') | 205 msg='Saved hostname pattern does not match expected pattern.') |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 """Verify mouse lock bubble goes away when tab loses focus.""" | 388 """Verify mouse lock bubble goes away when tab loses focus.""" |
| 369 self.NavigateToURL(self.GetHttpURLForDataPath( | 389 self.NavigateToURL(self.GetHttpURLForDataPath( |
| 370 'fullscreen_mouselock', 'fullscreen_mouselock.html')) | 390 'fullscreen_mouselock', 'fullscreen_mouselock.html')) |
| 371 self._driver.find_element_by_id('lockMouse1').click() | 391 self._driver.find_element_by_id('lockMouse1').click() |
| 372 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) | 392 self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) |
| 373 self.AppendTab(pyauto.GURL('chrome://newtab')) | 393 self.AppendTab(pyauto.GURL('chrome://newtab')) |
| 374 self.assertTrue(self.WaitUntil( | 394 self.assertTrue(self.WaitUntil( |
| 375 lambda: not self.IsFullscreenBubbleDisplayingButtons()), | 395 lambda: not self.IsFullscreenBubbleDisplayingButtons()), |
| 376 msg='Mouse lock bubble did not clear when tab lost focus.') | 396 msg='Mouse lock bubble did not clear when tab lost focus.') |
| 377 | 397 |
| 398 def testTabFSExitWhenNavBackToPrevPage(self): | |
| 399 """Verify tab fullscreen exit when navigating back to previous page. | |
| 400 | |
| 401 This test navigates to a new page while in tab fullscreen mode by using | |
| 402 IDC_BACK to navigate to the previous google.html page. | |
| 403 """ | |
| 404 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) | |
| 405 self._InitiateTabFullscreen() | |
| 406 self.RunCommand(pyauto.IDC_BACK) | |
| 407 self.assertTrue( | |
| 408 not self.IsFullscreenForTab(), | |
| 409 msg='Tab fullscreen did not exit when navigating to a new page.') | |
| 410 | |
| 411 def testTabFSExitWhenNavToNewPage(self): | |
| 412 """Verify tab fullscreen exit when navigating to a new website. | |
| 413 | |
| 414 This test navigates to a new website while in tab fullscreen. | |
| 415 """ | |
| 416 self._InitiateTabFullscreen() | |
| 417 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) | |
| 418 self.assertTrue( | |
| 419 not self.IsFullscreenForTab(), | |
| 420 msg='Tab fullscreen did not exit when navigating to a new website.') | |
| 421 | |
| 422 def testTabFSDoesNotExitForAnchorLinks(self): | |
| 423 """Verify tab fullscreen does not exit for anchor links. | |
| 424 | |
| 425 Tab fullscreen should not exit when following a link to the same page such | |
| 426 as example.html#anchor. | |
| 427 """ | |
| 428 self._InitiateTabFullscreen() | |
| 429 self._driver.find_element_by_id('anchor').click() | |
| 430 self.assertTrue( | |
| 431 self.WaitUntil(self.IsFullscreenForTab), | |
| 432 msg='Tab fullscreen should not exit when clicking on an anchor link.') | |
| 433 | |
| 434 def testMLExitWhenNavBackToPrevPage(self): | |
| 435 """Verify mouse lock exit when navigating back to previous page. | |
| 436 | |
| 437 This test navigates to a new page while mouse lock is activated by using | |
| 438 IDC_BACK to navigate to the previous google.html page. | |
| 439 """ | |
| 440 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) | |
| 441 lock_result = self._EnableAndReturnLockMouseResult() | |
| 442 self.assertEqual( | |
| 443 lock_result, 'success', msg='Mouse is not locked.') | |
| 444 self.RunCommand(pyauto.IDC_BACK) | |
| 445 self.assertTrue( | |
| 446 not self.IsMouseLocked(), | |
| 447 msg='Mouse lock did not exit when navigating to the prev page.') | |
| 448 | |
| 449 def testMLExitWhenNavToNewPage(self): | |
| 450 """Verify mouse lock exit when navigating to a new website.""" | |
| 451 lock_result = self._EnableAndReturnLockMouseResult() | |
| 452 self.assertEqual( | |
| 453 lock_result, 'success', msg='Mouse is not locked.') | |
| 454 self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) | |
| 455 self.assertTrue( | |
| 456 not self.IsMouseLocked(), | |
| 457 msg='Mouse lock did not exit when navigating to a new website.') | |
| 458 | |
| 459 def testMLDoesNotExitForAnchorLinks(self): | |
| 460 """Verify mouse lock does not exit for anchor links. | |
| 461 | |
| 462 Mouse lock should not exist when following a link to the same page such as | |
| 463 example.html#anchor. | |
| 464 """ | |
| 465 lock_result = self._EnableAndReturnLockMouseResult() | |
| 466 self.assertEqual( | |
| 467 lock_result, 'success', msg='Mouse is not locked.') | |
| 468 self._driver.execute_script('document.getElementById("anchor").click()') | |
| 469 self.assertTrue(self.WaitUntil(self.IsMouseLocked), | |
| 470 msg='Mouse lock broke when clicking on an anchor link.') | |
| 471 | |
| 378 def ExitTabFSToBrowserFS(self): | 472 def ExitTabFSToBrowserFS(self): |
| 379 """Verify exiting tab fullscreen leaves browser in browser fullscreen. | 473 """Verify exiting tab fullscreen leaves browser in browser fullscreen. |
| 380 | 474 |
| 381 This test is semi-automated. | 475 This test is semi-automated. |
| 382 | 476 |
| 383 The browser initiates browser fullscreen, then initiates tab fullscreen. The | 477 The browser initiates browser fullscreen, then initiates tab fullscreen. The |
| 384 test verifies that existing tab fullscreen by simulating ESC key press or | 478 test verifies that existing tab fullscreen by simulating ESC key press or |
| 385 clicking the js function to exitFullscreen() will exit the tab fullscreen | 479 clicking the js function to exitFullscreen() will exit the tab fullscreen |
| 386 leaving browser fullscreen intact. | 480 leaving browser fullscreen intact. |
| 387 """ | 481 """ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 self.NavigateToURL(url2, 0, 1) | 570 self.NavigateToURL(url2, 0, 1) |
| 477 self._driver.switch_to_window(tab2) | 571 self._driver.switch_to_window(tab2) |
| 478 self._EnableMouseLockMode() # Lock mouse in tab 2. | 572 self._EnableMouseLockMode() # Lock mouse in tab 2. |
| 479 raw_input('Manually move the mouse cursor on the page in tab 2. Shift+Tab \ | 573 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 \ | 574 into tab 1, click on lockMouse1() button, and move the mouse \ |
| 481 cursor on the page in tab 1. Verify mouse movement is smooth.') | 575 cursor on the page in tab 1. Verify mouse movement is smooth.') |
| 482 | 576 |
| 483 | 577 |
| 484 if __name__ == '__main__': | 578 if __name__ == '__main__': |
| 485 pyauto_functional.Main() | 579 pyauto_functional.Main() |
| OLD | NEW |