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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 7976016: New pyauto automation hook to get browser process information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor style edit. Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/functional/process_count.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index c8b5270fa57f3c564e30e54e80d42d2bf5872c2b..5c83b894ce2d384e3ab032a5dbde54fc8047c73d 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -33,6 +33,7 @@ import logging
import optparse
import os
import pickle
+import pprint
import shutil
import signal
import socket
@@ -135,6 +136,12 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
self.Initialize(pyautolib.FilePath(self.BrowserPath()))
unittest.TestCase.__init__(self, methodName)
+ # Give all pyauto tests access to a PrettyPrinter object, and convenience
+ # calls to its |pprint| and |pformat| methods.
+ self.pretty_printer = pprint.PrettyPrinter(indent=2)
Nirnimesh 2011/09/22 19:35:26 I meant you should define this in pyauto.py I real
Nirnimesh 2011/09/22 19:36:48 ok. I'm obviously high. Ignore my previous comment
dennis_jeffrey 2011/09/22 19:54:03 Done.
dennis_jeffrey 2011/09/22 19:54:03 If you've realized you're high, you're not high en
+ self.pprint = self.pretty_printer.pprint
Nirnimesh 2011/09/22 19:36:48 Why not just self.pprint = pprint.pprint?
dennis_jeffrey 2011/09/22 19:54:03 Cool! I didn't realize I could do this directly w
+ self.pformat = self.pretty_printer.pformat
Nirnimesh 2011/09/22 19:35:26 This is unused
dennis_jeffrey 2011/09/22 19:54:03 I use it in process_count.py in the current CL.
+
# Set up remote proxies, if they were requested.
self.remotes = []
self.remote = None
@@ -1381,6 +1388,65 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ def GetProcessInfo(self):
+ """Returns information about browser-related processes that currently exist.
+
+ This will also return information about other currently-running browsers
+ besides just Chrome.
+
+ Returns:
+ A dictionary containing browser-related process information as identified
+ by class MemoryDetails in src/chrome/browser/memory_details.h. The
+ dictionary contains a single key 'browsers', mapped to a list of
+ dictionaries containing information about each browser process name.
+ Each of those dictionaries contains a key 'processes', mapped to a list
+ of dictionaries containing the specific information for each process
+ with the given process name.
+
+ The memory values given in |committed_mem| and |working_set_mem| are in
+ KBytes.
+
+ Sample:
+ { 'browsers': [ { 'name': 'Chromium',
+ 'process_name': 'chrome',
+ 'processes': [ { 'child_process_type': 'Browser',
+ 'committed_mem': { 'image': 0,
+ 'mapped': 0,
+ 'priv': 0},
+ 'is_diagnostics': False,
+ 'num_processes': 1,
+ 'pid': 7770,
+ 'product_name': '',
+ 'renderer_type': 'Unknown',
+ 'titles': [],
+ 'version': '',
+ 'working_set_mem': { 'priv': 43672,
+ 'shareable': 0,
+ 'shared': 59251}},
+ { 'child_process_type': 'Tab',
+ 'committed_mem': { 'image': 0,
+ 'mapped': 0,
+ 'priv': 0},
+ 'is_diagnostics': False,
+ 'num_processes': 1,
+ 'pid': 7791,
+ 'product_name': '',
+ 'renderer_type': 'Tab',
+ 'titles': ['about:blank'],
+ 'version': '',
+ 'working_set_mem': { 'priv': 16768,
+ 'shareable': 0,
+ 'shared': 26256}},
+ ...<more processes>...]}]}
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = { # Prepare command for the json interface.
+ 'command': 'GetProcessInfo',
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+
def GetNavigationInfo(self, tab_index=0, windex=0):
"""Get info about the navigation state of a given tab.
« no previous file with comments | « chrome/test/functional/process_count.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698