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

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 10784009: screenshot disabling policy tests (Closed) Base URL: http://git.chromium.org/chromium/src.git@disable_screenshots
Patch Set: Updated accelerator_action.h Created 8 years, 4 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
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 """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 5770 matching lines...) Expand 10 before | Expand all | Expand 10 after
5781 for measurement_type in stats: 5781 for measurement_type in stats:
5782 values = stats[measurement_type] 5782 values = stats[measurement_type]
5783 result[measurement_type] = { 5783 result[measurement_type] = {
5784 'min': min(values), 5784 'min': min(values),
5785 'max': max(values), 5785 'max': max(values),
5786 'end': values[-1], 5786 'end': values[-1],
5787 } 5787 }
5788 5788
5789 return result 5789 return result
5790 5790
5791 def RunAshCommand(self, action):
5792 """Applies accelerator to ASH.
5793
5794 Apply the accelerator with given id to ASH (ChromeOS only). Action list can
5795 be found in ash/accelerators/accelerator_table.h, AcceleratorAction enum.
5796
5797 Args:
5798 action: accelerator code (eg. pyauto.TAKE_SCREENSHOT).
5799
5800 Returns:
5801 A boolean indicating whether the accelerator was handled.
5802 """
5803 cmd_dict = {
5804 'command': 'RunAshCommand',
5805 'action': action
5806 }
5807 return self._GetResultFromJSONRequest(cmd_dict, windex=None)
5808
5791 ## ChromeOS section -- end 5809 ## ChromeOS section -- end
5792 5810
5793 5811
5794 class ExtraBrowser(PyUITest): 5812 class ExtraBrowser(PyUITest):
5795 """Launches a new browser with some extra flags. 5813 """Launches a new browser with some extra flags.
5796 5814
5797 The new browser is launched with its own fresh profile. 5815 The new browser is launched with its own fresh profile.
5798 This class does not apply to ChromeOS. 5816 This class does not apply to ChromeOS.
5799 """ 5817 """
5800 def __init__(self, chrome_flags=[], methodName='runTest', **kwargs): 5818 def __init__(self, chrome_flags=[], methodName='runTest', **kwargs):
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
6236 """Returns a list of tests loaded from the given args. 6254 """Returns a list of tests loaded from the given args.
6237 6255
6238 The given args can be either a module (ex: module1) or a testcase 6256 The given args can be either a module (ex: module1) or a testcase
6239 (ex: module2.MyTestCase) or a test (ex: module1.MyTestCase.testX) 6257 (ex: module2.MyTestCase) or a test (ex: module1.MyTestCase.testX)
6240 If empty, the tests in the already imported modules are loaded. 6258 If empty, the tests in the already imported modules are loaded.
6241 6259
6242 Args: 6260 Args:
6243 args: [module1, module2, module3.testcase, module4.testcase.testX] 6261 args: [module1, module2, module3.testcase, module4.testcase.testX]
6244 These modules or test cases or tests should be importable 6262 These modules or test cases or tests should be importable
6245 6263
6246 Returns: 6264 Returns:
6247 a list of expanded test names. Example: 6265 a list of expanded test names. Example:
6248 [ 6266 [
6249 'module1.TestCase1.testA', 6267 'module1.TestCase1.testA',
6250 'module1.TestCase1.testB', 6268 'module1.TestCase1.testB',
6251 'module2.TestCase2.testX', 6269 'module2.TestCase2.testX',
6252 'module3.testcase.testY', 6270 'module3.testcase.testY',
6253 'module4.testcase.testX' 6271 'module4.testcase.testX'
6254 ] 6272 ]
6255 """ 6273 """
6256 if not args: # Load tests ourselves 6274 if not args: # Load tests ourselves
6257 if self._HasTestCases('__main__'): # we are running a test script 6275 if self._HasTestCases('__main__'): # we are running a test script
6258 module_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] 6276 module_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
6259 args.append(module_name) # run the test cases found in it 6277 args.append(module_name) # run the test cases found in it
6260 else: # run tests from the test description file 6278 else: # run tests from the test description file
6261 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6279 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6262 logging.debug("Reading %s", pyauto_tests_file) 6280 logging.debug("Reading %s", pyauto_tests_file)
6263 if not os.path.exists(pyauto_tests_file): 6281 if not os.path.exists(pyauto_tests_file):
6264 logging.warn("%s missing. Cannot load tests.", pyauto_tests_file) 6282 logging.warn("%s missing. Cannot load tests.", pyauto_tests_file)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 successful = result.wasSuccessful() 6377 successful = result.wasSuccessful()
6360 if not successful: 6378 if not successful:
6361 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6379 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6362 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6380 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6363 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6381 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6364 sys.exit(not successful) 6382 sys.exit(not successful)
6365 6383
6366 6384
6367 if __name__ == '__main__': 6385 if __name__ == '__main__':
6368 Main() 6386 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698