| 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 """PyAuto: Python Interface to Chromium's Automation Proxy. | 6 """PyAuto: Python Interface to Chromium's Automation Proxy. |
| 7 | 7 |
| 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
| 9 For complete documentation on the functionality available, | 9 For complete documentation on the functionality available, |
| 10 run pydoc on this file. | 10 run pydoc on this file. |
| (...skipping 5413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5424 for measurement_type in stats: | 5424 for measurement_type in stats: |
| 5425 values = stats[measurement_type] | 5425 values = stats[measurement_type] |
| 5426 result[measurement_type] = { | 5426 result[measurement_type] = { |
| 5427 'min': min(values), | 5427 'min': min(values), |
| 5428 'max': max(values), | 5428 'max': max(values), |
| 5429 'end': values[-1], | 5429 'end': values[-1], |
| 5430 } | 5430 } |
| 5431 | 5431 |
| 5432 return result | 5432 return result |
| 5433 | 5433 |
| 5434 def RunAshCommand(self, action): |
| 5435 """Applies accelerator to ASH. |
| 5436 |
| 5437 Apply the accelerator with given id to ASH (ChromeOS only). Action list can |
| 5438 be found in ash/accelerators/accelerator_table.h, AcceleratorAction enum. |
| 5439 |
| 5440 Args: |
| 5441 action: accelerator code (eg. pyauto.TAKE_SCREENSHOT). |
| 5442 |
| 5443 Returns: |
| 5444 A boolean indicating whether the accelerator was handled. |
| 5445 """ |
| 5446 cmd_dict = { |
| 5447 'command': 'RunAshCommand', |
| 5448 'action': action |
| 5449 } |
| 5450 return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
| 5451 |
| 5434 ## ChromeOS section -- end | 5452 ## ChromeOS section -- end |
| 5435 | 5453 |
| 5436 | 5454 |
| 5437 class ExtraBrowser(PyUITest): | 5455 class ExtraBrowser(PyUITest): |
| 5438 """Launches a new browser with some extra flags. | 5456 """Launches a new browser with some extra flags. |
| 5439 | 5457 |
| 5440 The new browser is launched with its own fresh profile. | 5458 The new browser is launched with its own fresh profile. |
| 5441 This class does not apply to ChromeOS. | 5459 This class does not apply to ChromeOS. |
| 5442 """ | 5460 """ |
| 5443 def __init__(self, chrome_flags=[], methodName='runTest', **kwargs): | 5461 def __init__(self, chrome_flags=[], methodName='runTest', **kwargs): |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5879 """Returns a list of tests loaded from the given args. | 5897 """Returns a list of tests loaded from the given args. |
| 5880 | 5898 |
| 5881 The given args can be either a module (ex: module1) or a testcase | 5899 The given args can be either a module (ex: module1) or a testcase |
| 5882 (ex: module2.MyTestCase) or a test (ex: module1.MyTestCase.testX) | 5900 (ex: module2.MyTestCase) or a test (ex: module1.MyTestCase.testX) |
| 5883 If empty, the tests in the already imported modules are loaded. | 5901 If empty, the tests in the already imported modules are loaded. |
| 5884 | 5902 |
| 5885 Args: | 5903 Args: |
| 5886 args: [module1, module2, module3.testcase, module4.testcase.testX] | 5904 args: [module1, module2, module3.testcase, module4.testcase.testX] |
| 5887 These modules or test cases or tests should be importable | 5905 These modules or test cases or tests should be importable |
| 5888 | 5906 |
| 5889 Returns: | 5907 Returns: |
| 5890 a list of expanded test names. Example: | 5908 a list of expanded test names. Example: |
| 5891 [ | 5909 [ |
| 5892 'module1.TestCase1.testA', | 5910 'module1.TestCase1.testA', |
| 5893 'module1.TestCase1.testB', | 5911 'module1.TestCase1.testB', |
| 5894 'module2.TestCase2.testX', | 5912 'module2.TestCase2.testX', |
| 5895 'module3.testcase.testY', | 5913 'module3.testcase.testY', |
| 5896 'module4.testcase.testX' | 5914 'module4.testcase.testX' |
| 5897 ] | 5915 ] |
| 5898 """ | 5916 """ |
| 5899 if not args: # Load tests ourselves | 5917 if not args: # Load tests ourselves |
| 5900 if self._HasTestCases('__main__'): # we are running a test script | 5918 if self._HasTestCases('__main__'): # we are running a test script |
| 5901 module_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] | 5919 module_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] |
| 5902 args.append(module_name) # run the test cases found in it | 5920 args.append(module_name) # run the test cases found in it |
| 5903 else: # run tests from the test description file | 5921 else: # run tests from the test description file |
| 5904 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 5922 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 5905 logging.debug("Reading %s", pyauto_tests_file) | 5923 logging.debug("Reading %s", pyauto_tests_file) |
| 5906 if not os.path.exists(pyauto_tests_file): | 5924 if not os.path.exists(pyauto_tests_file): |
| 5907 logging.warn("%s missing. Cannot load tests.", pyauto_tests_file) | 5925 logging.warn("%s missing. Cannot load tests.", pyauto_tests_file) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6002 successful = result.wasSuccessful() | 6020 successful = result.wasSuccessful() |
| 6003 if not successful: | 6021 if not successful: |
| 6004 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 6022 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 6005 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 6023 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 6006 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 6024 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 6007 sys.exit(not successful) | 6025 sys.exit(not successful) |
| 6008 | 6026 |
| 6009 | 6027 |
| 6010 if __name__ == '__main__': | 6028 if __name__ == '__main__': |
| 6011 Main() | 6029 Main() |
| OLD | NEW |