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

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

Issue 14977013: Delete Automation[Tab/Renderer]Helper and users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update now that 202087 is committed Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/perf_endure.py ('k') | chrome/test/webdriver/webdriver_automation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 3610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3621 3621
3622 Returns: 3622 Returns:
3623 a string that was sent back via the domAutomationController.send method 3623 a string that was sent back via the domAutomationController.send method
3624 """ 3624 """
3625 converted_args = map(lambda arg: json.dumps(arg), args) 3625 converted_args = map(lambda arg: json.dumps(arg), args)
3626 js = '%s(%s)' % (function, ', '.join(converted_args)) 3626 js = '%s(%s)' % (function, ', '.join(converted_args))
3627 logging.debug('Executing javascript: %s', js) 3627 logging.debug('Executing javascript: %s', js)
3628 return self.ExecuteJavascript(js, tab_index, windex) 3628 return self.ExecuteJavascript(js, tab_index, windex)
3629 3629
3630 def HeapProfilerDump(self, process_type, reason, tab_index=0, windex=0): 3630 def HeapProfilerDump(self, process_type, reason, tab_index=0, windex=0):
3631 """Dumps a heap profile. It works only on Linux and ChromeOS. 3631 """Dumps a heap profile. It works only on Linux and ChromeOS.
3632 3632
3633 We need an environment variable "HEAPPROFILE" set to a directory and a 3633 We need an environment variable "HEAPPROFILE" set to a directory and a
3634 filename prefix, for example, "/tmp/prof". In a case of this example, 3634 filename prefix, for example, "/tmp/prof". In a case of this example,
3635 heap profiles will be dumped into "/tmp/prof.(pid).0002.heap", 3635 heap profiles will be dumped into "/tmp/prof.(pid).0002.heap",
3636 "/tmp/prof.(pid).0003.heap", and so on. Nothing happens when this 3636 "/tmp/prof.(pid).0003.heap", and so on. Nothing happens when this
3637 function is called without the env. 3637 function is called without the env.
3638 3638
3639 Also, this requires the --enable-memory-benchmarking command line flag.
3640
3639 Args: 3641 Args:
3640 process_type: A string which is one of 'browser' or 'renderer'. 3642 process_type: A string which is one of 'browser' or 'renderer'.
3641 reason: A string which describes the reason for dumping a heap profile. 3643 reason: A string which describes the reason for dumping a heap profile.
3642 The reason will be included in the logged message. 3644 The reason will be included in the logged message.
3643 Examples: 3645 Examples:
3644 'To check memory leaking' 3646 'To check memory leaking'
3645 'For PyAuto tests' 3647 'For PyAuto tests'
3646 tab_index: tab index to work on if 'process_type' == 'renderer'. 3648 tab_index: tab index to work on if 'process_type' == 'renderer'.
3647 Defaults to 0 (first tab). 3649 Defaults to 0 (first tab).
3648 windex: window index to work on if 'process_type' == 'renderer'. 3650 windex: window index to work on if 'process_type' == 'renderer'.
3649 Defaults to 0 (first window). 3651 Defaults to 0 (first window).
3650 3652
3651 Raises: 3653 Raises:
3652 pyauto_errors.JSONInterfaceError if the automation call returns an error. 3654 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3653 """ 3655 """
3654 assert process_type in ('browser', 'renderer') 3656 assert process_type in ('browser', 'renderer')
3655 if self.IsLinux(): # IsLinux() also implies IsChromeOS(). 3657 if self.IsLinux(): # IsLinux() also implies IsChromeOS().
3656 cmd_dict = { 3658 js = """
3657 'command': 'HeapProfilerDump', 3659 if (!chrome.memoryBenchmarking ||
3658 'process_type': process_type, 3660 !chrome.memoryBenchmarking.isHeapProfilerRunning()) {
3659 'reason': reason, 3661 domAutomationController.send('memory benchmarking disabled');
3660 'windex': windex, 3662 } else {
3661 'tab_index': tab_index, 3663 chrome.memoryBenchmarking.heapProfilerDump("%s", "%s");
3662 } 3664 domAutomationController.send('success');
3663 self._GetResultFromJSONRequest(cmd_dict) 3665 }
3666 """ % (process_type, reason.replace('"', '\\"'))
3667 result = self.ExecuteJavascript(js, tab_index, windex)
3668 if result != 'success':
3669 raise JSONInterfaceError('Heap profiler dump failed: ' + result)
3664 else: 3670 else:
3665 logging.warn('Heap-profiling is not supported in this OS.') 3671 logging.warn('Heap-profiling is not supported in this OS.')
3666 3672
3667 def GetNTPThumbnails(self): 3673 def GetNTPThumbnails(self):
3668 """Return a list of info about the sites in the NTP most visited section. 3674 """Return a list of info about the sites in the NTP most visited section.
3669 SAMPLE: 3675 SAMPLE:
3670 [{ u'title': u'Google', 3676 [{ u'title': u'Google',
3671 u'url': u'http://www.google.com'}, 3677 u'url': u'http://www.google.com'},
3672 { 3678 {
3673 u'title': u'Yahoo', 3679 u'title': u'Yahoo',
(...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after
6204 successful = result.wasSuccessful() 6210 successful = result.wasSuccessful()
6205 if not successful: 6211 if not successful:
6206 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6212 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6207 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6213 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6208 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6214 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6209 sys.exit(not successful) 6215 sys.exit(not successful)
6210 6216
6211 6217
6212 if __name__ == '__main__': 6218 if __name__ == '__main__':
6213 Main() 6219 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/perf_endure.py ('k') | chrome/test/webdriver/webdriver_automation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698