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

Unified Diff: chrome/test/functional/process_count.py

Issue 7976016: New pyauto automation hook to get browser process information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed second round of review comments. 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/PYAUTO_TESTS ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/process_count.py
diff --git a/chrome/test/functional/process_count.py b/chrome/test/functional/process_count.py
index aee73a096ff21335f8bb905cb777f192f0659137..99caed1aba1830d633655c684c31ca671f2e2316 100644
--- a/chrome/test/functional/process_count.py
+++ b/chrome/test/functional/process_count.py
@@ -12,46 +12,75 @@ import pyauto
class ProcessCountTest(pyauto.PyUITest):
"""Tests to ensure the number of Chrome-related processes is as expected."""
- def _VerifyProcessCount(self, expected_count):
+ FRESH_PROFILE_PROC_COUNT = {
+ 'win': 2, # Processes: browser, tab.
+ 'mac': 2, # Processes: browser, tab.
+ 'linux': 4, # Processes: browser, tab, sandbox helper, zygote.
+ 'chromeos': 5, # Processes: browser, tab, sandbox helper, zygote, GPU.
+ }
+
+ CHROME_PROCESS_NAME = {
+ 'win': 'chrome.exe',
+ 'mac': 'Chromium',
+ 'linux': 'chrome',
+ 'chromeos': 'chrome',
+ }
+
+ def setUp(self):
+ self.proc_count_fresh_profile = 0
+ self.chrome_proc_name = ''
+ if self.IsChromeOS():
+ self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['chromeos']
+ self.chrome_proc_name = self.CHROME_PROCESS_NAME['chromeos']
+ elif self.IsWin():
+ self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['win']
+ self.chrome_proc_name = self.CHROME_PROCESS_NAME['win']
+ elif self.IsMac():
+ self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['mac']
+ self.chrome_proc_name = self.CHROME_PROCESS_NAME['mac']
+ elif self.IsLinux():
+ self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['linux']
+ self.chrome_proc_name = self.CHROME_PROCESS_NAME['linux']
+
+ pyauto.PyUITest.setUp(self)
+
+ def _VerifyProcessCount(self, num_expected):
"""Verifies the number of Chrome-related processes is as expected.
Args:
- expected_count: An integer representing the expected number of Chrome-
- related processes that should currently exist.
+ num_expected: An integer representing the expected number of Chrome-
+ related processes that should currently exist.
"""
- # Compute the actual number of Chrome-related processes that exist.
- # Processes include: a single browser process; a single renderer process
- # for each tab in each window; 0 or more child processes (associated with
- # plugins or other workers); and 0 or more extension processes.
- info = self.GetBrowserInfo()
- actual_count = (
- 1 + # Browser process.
- sum([len(tab_info['tabs']) for tab_info in info['windows']]) +
- len(info['child_processes']) + len(info['extension_views']))
-
- self.assertEqual(actual_count, expected_count,
- msg='Number of processes should be %d, but was %d.' %
- (expected_count, actual_count))
+ proc_info = self.GetProcessInfo()
+ browser_info = [x for x in proc_info['browsers']
+ if x['process_name'] == self.chrome_proc_name]
+ assert len(browser_info) == 1
+ num_actual = len(browser_info[0]['processes'])
+
+ self.assertEqual(num_actual, num_expected,
+ msg='Number of processes should be %d, but was %d.\n'
+ 'Actual process info:\n%s' % (
+ num_expected, num_actual, self.pformat(proc_info)))
def testProcessCountFreshProfile(self):
"""Verifies the process count in a fresh profile."""
- self._VerifyProcessCount(2)
+ self._VerifyProcessCount(self.proc_count_fresh_profile)
def testProcessCountAppendSingleTab(self):
"""Verifies the process count after appending a single tab."""
self.AppendTab(pyauto.GURL('about:blank'), 0)
- self._VerifyProcessCount(3)
+ self._VerifyProcessCount(self.proc_count_fresh_profile + 1)
def testProcessCountNewWindow(self):
"""Verifies the process count after opening a new window."""
self.OpenNewBrowserWindow(True)
- self._VerifyProcessCount(3)
+ self._VerifyProcessCount(self.proc_count_fresh_profile + 1)
def testProcessCountFlashProcess(self):
"""Verifies the process count when the flash process is running."""
flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf')
self.NavigateToURL(flash_url)
- self._VerifyProcessCount(3)
+ self._VerifyProcessCount(self.proc_count_fresh_profile + 1)
def testProcessCountExtensionProcess(self):
"""Verifies the process count when an extension is installed."""
@@ -59,10 +88,15 @@ class ProcessCountTest(pyauto.PyUITest):
os.path.join(self.DataDir(), 'extensions', 'page_action.crx'))
self.assertTrue(self.InstallExtension(crx_file_path, False),
msg='Extension install failed.')
- self._VerifyProcessCount(3)
+ self._VerifyProcessCount(self.proc_count_fresh_profile + 1)
def testProcessCountCombination(self):
- """Verifies process count with a combination of tabs/windows/extensions."""
+ """Verifies process count with a combination of tabs/windows/extensions.
+
+ This test installs 1 extension, appends 2 tabs to the window, navigates 1
+ tab to a flash page, opens 1 new window, and appends 3 tabs to the new
+ window (8 new processes expected).
+ """
if self.IsMac():
# On Mac 10.5, flash files loaded too quickly after firing browser ends
# up getting downloaded, which seems to indicate that the plugin hasn't
@@ -85,7 +119,7 @@ class ProcessCountTest(pyauto.PyUITest):
for _ in xrange(3):
self.AppendTab(pyauto.GURL('about:blank'), 1)
- self._VerifyProcessCount(10)
+ self._VerifyProcessCount(self.proc_count_fresh_profile + 8)
if __name__ == '__main__':
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698