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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/process_count.py ('k') | no next file » | 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 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 15 matching lines...) Expand all
26 """ 26 """
27 27
28 import cStringIO 28 import cStringIO
29 import functools 29 import functools
30 import hashlib 30 import hashlib
31 import inspect 31 import inspect
32 import logging 32 import logging
33 import optparse 33 import optparse
34 import os 34 import os
35 import pickle 35 import pickle
36 import pprint
36 import shutil 37 import shutil
37 import signal 38 import signal
38 import socket 39 import socket
39 import stat 40 import stat
40 import string 41 import string
41 import subprocess 42 import subprocess
42 import sys 43 import sys
43 import tempfile 44 import tempfile
44 import time 45 import time
45 import types 46 import types
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 homepage: the home page. Defaults to "about:blank" 129 homepage: the home page. Defaults to "about:blank"
129 """ 130 """
130 # Fetch provided keyword args, or fill in defaults. 131 # Fetch provided keyword args, or fill in defaults.
131 clear_profile = kwargs.get('clear_profile', True) 132 clear_profile = kwargs.get('clear_profile', True)
132 homepage = kwargs.get('homepage', 'about:blank') 133 homepage = kwargs.get('homepage', 'about:blank')
133 134
134 pyautolib.PyUITestBase.__init__(self, clear_profile, homepage) 135 pyautolib.PyUITestBase.__init__(self, clear_profile, homepage)
135 self.Initialize(pyautolib.FilePath(self.BrowserPath())) 136 self.Initialize(pyautolib.FilePath(self.BrowserPath()))
136 unittest.TestCase.__init__(self, methodName) 137 unittest.TestCase.__init__(self, methodName)
137 138
139 # Give all pyauto tests access to a PrettyPrinter object, and convenience
140 # calls to its |pprint| and |pformat| methods.
141 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
142 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
143 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.
144
138 # Set up remote proxies, if they were requested. 145 # Set up remote proxies, if they were requested.
139 self.remotes = [] 146 self.remotes = []
140 self.remote = None 147 self.remote = None
141 global _REMOTE_PROXY 148 global _REMOTE_PROXY
142 if _REMOTE_PROXY: 149 if _REMOTE_PROXY:
143 self.remotes = _REMOTE_PROXY 150 self.remotes = _REMOTE_PROXY
144 self.remote = _REMOTE_PROXY[0] 151 self.remote = _REMOTE_PROXY[0]
145 152
146 def __del__(self): 153 def __del__(self):
147 pyautolib.PyUITestBase.__del__(self) 154 pyautolib.PyUITestBase.__del__(self)
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 u'y': 44}]} 1381 u'y': 44}]}
1375 1382
1376 Raises: 1383 Raises:
1377 pyauto_errors.JSONInterfaceError if the automation call returns an error. 1384 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1378 """ 1385 """
1379 cmd_dict = { # Prepare command for the json interface 1386 cmd_dict = { # Prepare command for the json interface
1380 'command': 'GetBrowserInfo', 1387 'command': 'GetBrowserInfo',
1381 } 1388 }
1382 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) 1389 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
1383 1390
1391 def GetProcessInfo(self):
1392 """Returns information about browser-related processes that currently exist.
1393
1394 This will also return information about other currently-running browsers
1395 besides just Chrome.
1396
1397 Returns:
1398 A dictionary containing browser-related process information as identified
1399 by class MemoryDetails in src/chrome/browser/memory_details.h. The
1400 dictionary contains a single key 'browsers', mapped to a list of
1401 dictionaries containing information about each browser process name.
1402 Each of those dictionaries contains a key 'processes', mapped to a list
1403 of dictionaries containing the specific information for each process
1404 with the given process name.
1405
1406 The memory values given in |committed_mem| and |working_set_mem| are in
1407 KBytes.
1408
1409 Sample:
1410 { 'browsers': [ { 'name': 'Chromium',
1411 'process_name': 'chrome',
1412 'processes': [ { 'child_process_type': 'Browser',
1413 'committed_mem': { 'image': 0,
1414 'mapped': 0,
1415 'priv': 0},
1416 'is_diagnostics': False,
1417 'num_processes': 1,
1418 'pid': 7770,
1419 'product_name': '',
1420 'renderer_type': 'Unknown',
1421 'titles': [],
1422 'version': '',
1423 'working_set_mem': { 'priv': 43672,
1424 'shareable': 0,
1425 'shared': 59251}},
1426 { 'child_process_type': 'Tab',
1427 'committed_mem': { 'image': 0,
1428 'mapped': 0,
1429 'priv': 0},
1430 'is_diagnostics': False,
1431 'num_processes': 1,
1432 'pid': 7791,
1433 'product_name': '',
1434 'renderer_type': 'Tab',
1435 'titles': ['about:blank'],
1436 'version': '',
1437 'working_set_mem': { 'priv': 16768,
1438 'shareable': 0,
1439 'shared': 26256}},
1440 ...<more processes>...]}]}
1441
1442 Raises:
1443 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1444 """
1445 cmd_dict = { # Prepare command for the json interface.
1446 'command': 'GetProcessInfo',
1447 }
1448 return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
1449
1384 def GetNavigationInfo(self, tab_index=0, windex=0): 1450 def GetNavigationInfo(self, tab_index=0, windex=0):
1385 """Get info about the navigation state of a given tab. 1451 """Get info about the navigation state of a given tab.
1386 1452
1387 Args: 1453 Args:
1388 tab_index: The tab index, default is 0. 1454 tab_index: The tab index, default is 0.
1389 window_index: The window index, default is 0. 1455 window_index: The window index, default is 0.
1390 1456
1391 Returns: 1457 Returns:
1392 a dictionary. 1458 a dictionary.
1393 Sample: 1459 Sample:
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 successful = result.wasSuccessful() 4541 successful = result.wasSuccessful()
4476 if not successful: 4542 if not successful:
4477 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 4543 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
4478 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 4544 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
4479 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 4545 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
4480 sys.exit(not successful) 4546 sys.exit(not successful)
4481 4547
4482 4548
4483 if __name__ == '__main__': 4549 if __name__ == '__main__':
4484 Main() 4550 Main()
OLDNEW
« 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