diff options
author | dennisjeffrey@chromium.org <dennisjeffrey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 20:34:07 +0000 |
---|---|---|
committer | dennisjeffrey@chromium.org <dennisjeffrey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 20:34:07 +0000 |
commit | 1e5e1dd8d286ca0a786f91802b70273ff2209131 (patch) | |
tree | 81d4a4a460c0ed8507eab41d7674f9ac58e31299 | |
parent | d72de5bee9af23c9db0ff4a805117987f5755569 (diff) | |
download | chromium_src-1e5e1dd8d286ca0a786f91802b70273ff2209131.zip chromium_src-1e5e1dd8d286ca0a786f91802b70273ff2209131.tar.gz chromium_src-1e5e1dd8d286ca0a786f91802b70273ff2209131.tar.bz2 |
Adding pyauto tests to verify Chrome-related process counts.
These tests can help prevent against the existence of duplicate
Chrome-related processes.
BUG=chromium-os:19041,chromium-os:18953
TEST=None
Review URL: http://codereview.chromium.org/7633075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97503 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 1 | ||||
-rw-r--r-- | chrome/test/functional/process_count.py | 87 |
2 files changed, 88 insertions, 0 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index c574a39..7e2fa36 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -63,6 +63,7 @@ 'plugins_check', 'popups', 'prefs', + 'process_count', 'pyauto_webdriver', 'search_engines', 'shortcuts', diff --git a/chrome/test/functional/process_count.py b/chrome/test/functional/process_count.py new file mode 100644 index 0000000..f870e10 --- /dev/null +++ b/chrome/test/functional/process_count.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os + +import pyauto_functional +import pyauto + + +class ProcessCountTest(pyauto.PyUITest): + """Tests to ensure the number of Chrome-related processes is as expected.""" + + def _VerifyProcessCount(self, expected_count): + """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. + """ + # 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_processes'])) + + self.assertEqual(actual_count, expected_count, + msg='Number of processes should be %d, but was %d.' % + (expected_count, actual_count)) + + def testProcessCountFreshProfile(self): + """Verifies the process count in a fresh profile.""" + self._VerifyProcessCount(2) + + def testProcessCountAppendSingleTab(self): + """Verifies the process count after appending a single tab.""" + self.AppendTab(pyauto.GURL('about:blank'), 0) + self._VerifyProcessCount(3) + + def testProcessCountNewWindow(self): + """Verifies the process count after opening a new window.""" + self.OpenNewBrowserWindow(True) + self._VerifyProcessCount(3) + + 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) + + def testProcessCountExtensionProcess(self): + """Verifies the process count when an extension is installed.""" + crx_file_path = os.path.abspath( + os.path.join(self.DataDir(), 'extensions', 'page_action.crx')) + self.assertTrue(self.InstallExtension(crx_file_path, False), + msg='Extension install failed.') + self._VerifyProcessCount(3) + + def testProcessCountCombination(self): + """Verifies process count with a combination of tabs/windows/extensions.""" + crx_file_path = os.path.abspath( + os.path.join(self.DataDir(), 'extensions', 'page_action.crx')) + self.assertTrue(self.InstallExtension(crx_file_path, False), + msg='Extension install failed.') + + for _ in xrange(2): + self.AppendTab(pyauto.GURL('about:blank'), 0) + + flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') + self.NavigateToURL(flash_url) + + self.OpenNewBrowserWindow(True) + + for _ in xrange(3): + self.AppendTab(pyauto.GURL('about:blank'), 1) + + self._VerifyProcessCount(10) + + +if __name__ == '__main__': + pyauto_functional.Main() |