| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
| 8 | 8 |
| 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
| 10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 right key. It's useful to dump the preferences first to determine | 482 right key. It's useful to dump the preferences first to determine |
| 483 what type is expected for a particular preference path. | 483 what type is expected for a particular preference path. |
| 484 """ | 484 """ |
| 485 cmd_dict = { | 485 cmd_dict = { |
| 486 'command': 'SetPrefs', | 486 'command': 'SetPrefs', |
| 487 'path': path, | 487 'path': path, |
| 488 'value': value, | 488 'value': value, |
| 489 } | 489 } |
| 490 self._GetResultFromJSONRequest(cmd_dict) | 490 self._GetResultFromJSONRequest(cmd_dict) |
| 491 | 491 |
| 492 def WaitForAllDownloadsToComplete(self): | 492 def WaitForAllDownloadsToComplete(self, timeout=-1): |
| 493 """Wait for all downloads to complete. | 493 """Wait for all downloads to complete. |
| 494 | 494 |
| 495 Args: |
| 496 timeout: The timeout to use - default is WaitUntil's default timeout. |
| 497 |
| 495 Note: This method does not work for dangerous downloads. Use | 498 Note: This method does not work for dangerous downloads. Use |
| 496 WaitForGivenDownloadsToComplete (below) instead. | 499 WaitForGivenDownloadsToComplete (below) instead. |
| 497 """ | 500 """ |
| 498 self._GetResultFromJSONRequest({'command': 'WaitForAllDownloadsToComplete'}) | 501 # Downloads implementation is largely broken. Try to get around by using |
| 502 # WaitUntil instead of using notifications. crbug.com/54131 |
| 503 # self._GetResultFromJSONRequest( |
| 504 # {'command': 'WaitForAllDownloadsToComplete'}) |
| 505 return self.WaitUntil( |
| 506 lambda: len(self.GetDownloadsInfo().DownloadsInProgress()) == 0, |
| 507 timeout=timeout) |
| 499 | 508 |
| 500 def WaitForDownloadToComplete(self, download_path, timeout=-1): | 509 def WaitForDownloadToComplete(self, download_path, timeout=-1): |
| 501 """Wait for the given downloads to complete. | 510 """Wait for the given downloads to complete. |
| 502 | 511 |
| 503 This method works for dangerous downloads as well as regular downloads. | 512 This method works for dangerous downloads as well as regular downloads. |
| 504 | 513 |
| 505 Args: | 514 Args: |
| 506 download_path: The path to the final download. This is only necessary for | 515 download_path: The path to the final download. This is only necessary for |
| 507 the workaround described in the comments below and should | 516 the workaround described in the comments below and should |
| 508 be removed when downloads are re-implemented. | 517 be removed when downloads are re-implemented. |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 if self._options.verbose: | 1683 if self._options.verbose: |
| 1675 verbosity = 2 | 1684 verbosity = 2 |
| 1676 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 1685 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
| 1677 del loaded_tests # Need to destroy test cases before the suite | 1686 del loaded_tests # Need to destroy test cases before the suite |
| 1678 del pyauto_suite | 1687 del pyauto_suite |
| 1679 sys.exit(not result.wasSuccessful()) | 1688 sys.exit(not result.wasSuccessful()) |
| 1680 | 1689 |
| 1681 | 1690 |
| 1682 if __name__ == '__main__': | 1691 if __name__ == '__main__': |
| 1683 Main() | 1692 Main() |
| OLD | NEW |