| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import os | 6 import os |
| 7 | 7 |
| 8 import pyauto_functional | 8 import pyauto_functional |
| 9 import pyauto | 9 import pyauto |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 """Verifies the number of Chrome-related processes is as expected. | 57 """Verifies the number of Chrome-related processes is as expected. |
| 58 | 58 |
| 59 Args: | 59 Args: |
| 60 num_expected: An integer representing the expected number of Chrome- | 60 num_expected: An integer representing the expected number of Chrome- |
| 61 related processes that should currently exist. | 61 related processes that should currently exist. |
| 62 """ | 62 """ |
| 63 proc_info = self.GetProcessInfo() | 63 proc_info = self.GetProcessInfo() |
| 64 browser_info = [x for x in proc_info['browsers'] | 64 browser_info = [x for x in proc_info['browsers'] |
| 65 if x['process_name'] == self.chrome_proc_name] | 65 if x['process_name'] == self.chrome_proc_name] |
| 66 assert len(browser_info) == 1 | 66 assert len(browser_info) == 1 |
| 67 # Utility processes may show up any time. Ignore them. | 67 # Utility & GPU processes may show up any time. Ignore them. |
| 68 processes = [x for x in browser_info[0]['processes'] | 68 processes = [x for x in browser_info[0]['processes'] |
| 69 if x['child_process_type'] != 'Utility'] | 69 if x['child_process_type'] not in ('Utility', 'GPU')] |
| 70 num_actual = len(processes) | 70 num_actual = len(processes) |
| 71 | 71 |
| 72 self.assertEqual(num_actual, num_expected, | 72 self.assertEqual(num_actual, num_expected, |
| 73 msg='Number of processes (ignoring Utility processes) ' | 73 msg='Number of processes (ignoring Utility/GPU processes) ' |
| 74 'should be %d, but was %d.\n' | 74 'should be %d, but was %d.\n' |
| 75 'Actual process info:\n%s' % ( | 75 'Actual processes:\n%s' % ( |
| 76 num_expected, num_actual, self.pformat(proc_info))) | 76 num_expected, num_actual, |
| 77 [x['child_process_type'] for x in processes])) |
| 77 | 78 |
| 78 def testProcessCountFreshProfile(self): | 79 def testProcessCountFreshProfile(self): |
| 79 """Verifies the process count in a fresh profile.""" | 80 """Verifies the process count in a fresh profile.""" |
| 80 self._VerifyProcessCount(self.proc_count_fresh_profile) | 81 self._VerifyProcessCount(self.proc_count_fresh_profile) |
| 81 | 82 |
| 82 def testProcessCountAppendSingleTab(self): | 83 def testProcessCountAppendSingleTab(self): |
| 83 """Verifies the process count after appending a single tab.""" | 84 """Verifies the process count after appending a single tab.""" |
| 84 self.AppendTab(pyauto.GURL('about:blank'), 0) | 85 self.AppendTab(pyauto.GURL('about:blank'), 0) |
| 85 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) | 86 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) |
| 86 | 87 |
| 87 def testProcessCountNewWindow(self): | 88 def testProcessCountNewWindow(self): |
| 88 """Verifies the process count after opening a new window.""" | 89 """Verifies the process count after opening a new window.""" |
| 89 self.OpenNewBrowserWindow(True) | 90 self.OpenNewBrowserWindow(True) |
| 90 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) | 91 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) |
| 91 | 92 |
| 92 def testProcessCountFlashProcess(self): | 93 def testProcessCountFlashProcess(self): |
| 93 """Verifies the process count when the flash process is running.""" | 94 """Verifies the process count when the flash process is running.""" |
| 94 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 95 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') |
| 95 self.NavigateToURL(flash_url) | 96 self.NavigateToURL(flash_url) |
| 96 if self.IsChromeOS(): | 97 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) |
| 97 # Flash triggers an extra GPU process on ChromeOS. | |
| 98 self._VerifyProcessCount(self.proc_count_fresh_profile + 2) | |
| 99 else: | |
| 100 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) | |
| 101 | 98 |
| 102 def testProcessCountExtensionProcess(self): | 99 def testProcessCountExtensionProcess(self): |
| 103 """Verifies the process count when an extension is installed.""" | 100 """Verifies the process count when an extension is installed.""" |
| 104 crx_file_path = os.path.abspath( | 101 crx_file_path = os.path.abspath( |
| 105 os.path.join(self.DataDir(), 'extensions', 'page_action.crx')) | 102 os.path.join(self.DataDir(), 'extensions', 'page_action.crx')) |
| 106 self.InstallExtension(crx_file_path) | 103 self.InstallExtension(crx_file_path) |
| 107 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) | 104 self._VerifyProcessCount(self.proc_count_fresh_profile + 1) |
| 108 | 105 |
| 109 def testProcessCountCombination(self): | 106 def testProcessCountCombination(self): |
| 110 """Verifies process count with a combination of tabs/windows/extensions. | 107 """Verifies process count with a combination of tabs/windows/extensions. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 127 self.AppendTab(pyauto.GURL('about:blank'), 0) | 124 self.AppendTab(pyauto.GURL('about:blank'), 0) |
| 128 | 125 |
| 129 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 126 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') |
| 130 self.NavigateToURL(flash_url) | 127 self.NavigateToURL(flash_url) |
| 131 | 128 |
| 132 self.OpenNewBrowserWindow(True) | 129 self.OpenNewBrowserWindow(True) |
| 133 | 130 |
| 134 for _ in xrange(3): | 131 for _ in xrange(3): |
| 135 self.AppendTab(pyauto.GURL('about:blank'), 1) | 132 self.AppendTab(pyauto.GURL('about:blank'), 1) |
| 136 | 133 |
| 137 if self.IsChromeOS(): | 134 self._VerifyProcessCount(self.proc_count_fresh_profile + 8) |
| 138 # Flash triggers an extra GPU process on ChromeOS. | |
| 139 self._VerifyProcessCount(self.proc_count_fresh_profile + 9) | |
| 140 else: | |
| 141 self._VerifyProcessCount(self.proc_count_fresh_profile + 8) | |
| 142 | 135 |
| 143 | 136 |
| 144 if __name__ == '__main__': | 137 if __name__ == '__main__': |
| 145 pyauto_functional.Main() | 138 pyauto_functional.Main() |
| OLD | NEW |