| 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 tab_index: The index of the tab, default is 0. | 713 tab_index: The index of the tab, default is 0. |
| 714 window_index: The index of the window, default is 0. | 714 window_index: The index of the window, default is 0. |
| 715 """ | 715 """ |
| 716 cmd_dict = { # Prepare command for the json interface | 716 cmd_dict = { # Prepare command for the json interface |
| 717 'command': 'SelectTranslateOption', | 717 'command': 'SelectTranslateOption', |
| 718 'tab_index': tab_index, | 718 'tab_index': tab_index, |
| 719 'option': 'revert_translation' | 719 'option': 'revert_translation' |
| 720 } | 720 } |
| 721 self._GetResultFromJSONRequest(cmd_dict, windex=window_index) | 721 self._GetResultFromJSONRequest(cmd_dict, windex=window_index) |
| 722 | 722 |
| 723 def ChangeTranslateToLanguage(self, new_language, tab_index=0, |
| 724 window_index=0): |
| 725 """Set the target language to be a new language. |
| 726 |
| 727 This is equivalent to selecting a different language from the 'to' |
| 728 drop-down menu on the translate bar. If the page was already translated |
| 729 before calling this function, this will trigger a re-translate to the |
| 730 new language. |
| 731 |
| 732 Args: |
| 733 new_language: The new target language. The string should be equivalent |
| 734 to the text seen in the translate bar options. |
| 735 Example: 'English'. |
| 736 tab_index: The tab index - default is 0. |
| 737 window_index: The window index - default is 0. |
| 738 |
| 739 Returns: |
| 740 False, if a new translation was triggered and the translation failed. |
| 741 True on success. |
| 742 """ |
| 743 cmd_dict = { # Prepare command for the json interface |
| 744 'command': 'SelectTranslateOption', |
| 745 'tab_index': tab_index, |
| 746 'option': 'set_target_language', |
| 747 'target_language': new_language |
| 748 } |
| 749 return self._GetResultFromJSONRequest( |
| 750 cmd_dict, windex=window_index)['translation_success'] |
| 751 |
| 723 def GetExtensionsInfo(self): | 752 def GetExtensionsInfo(self): |
| 724 """Returns information about all installed extensions. | 753 """Returns information about all installed extensions. |
| 725 | 754 |
| 726 Returns: | 755 Returns: |
| 727 A list of dictionaries representing each of the installed extensions. | 756 A list of dictionaries representing each of the installed extensions. |
| 728 Example: | 757 Example: |
| 729 [ { u'background_url': u'', | 758 [ { u'background_url': u'', |
| 730 u'description': u'Bookmark Manager', | 759 u'description': u'Bookmark Manager', |
| 731 u'id': u'eemcgdkfndhakfknompkggombfjjjeno', | 760 u'id': u'eemcgdkfndhakfknompkggombfjjjeno', |
| 732 u'name': u'Bookmark Manager', | 761 u'name': u'Bookmark Manager', |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 if self._options.verbose: | 1456 if self._options.verbose: |
| 1428 verbosity = 2 | 1457 verbosity = 2 |
| 1429 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) | 1458 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) |
| 1430 del loaded_tests # Need to destroy test cases before the suite | 1459 del loaded_tests # Need to destroy test cases before the suite |
| 1431 del pyauto_suite | 1460 del pyauto_suite |
| 1432 sys.exit(not result.wasSuccessful()) | 1461 sys.exit(not result.wasSuccessful()) |
| 1433 | 1462 |
| 1434 | 1463 |
| 1435 if __name__ == '__main__': | 1464 if __name__ == '__main__': |
| 1436 Main() | 1465 Main() |
| OLD | NEW |