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

Side by Side Diff: chrome/test/functional/process_count.py

Issue 9553010: Pyauto process count tests now get browser executable name via an automation hook. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « no previous file | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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
11 11
12 class ProcessCountTest(pyauto.PyUITest): 12 class ProcessCountTest(pyauto.PyUITest):
13 """Tests to ensure the number of Chrome-related processes is as expected.""" 13 """Tests to ensure the number of Chrome-related processes is as expected."""
14 14
15 FRESH_PROFILE_PROC_COUNT = { 15 FRESH_PROFILE_PROC_COUNT = {
16 'win': 2, # Processes: browser, tab. 16 'win': 2, # Processes: browser, tab.
17 'mac': 2, # Processes: browser, tab. 17 'mac': 2, # Processes: browser, tab.
18 'linux': 4, # Processes: browser, tab, sandbox helper, zygote. 18 'linux': 4, # Processes: browser, tab, sandbox helper, zygote.
19 'chromeos': 4, # Processes: browser, tab, sandbox helper, zygote. 19 'chromeos': 4, # Processes: browser, tab, sandbox helper, zygote.
20 } 20 }
21 21
22 CHROME_PROCESS_NAME = {
23 'win': 'chrome.exe',
24 'mac': 'Chromium',
25 'linux': 'chrome',
26 'chromeos': 'chrome',
27 }
28
29 def Debug(self): 22 def Debug(self):
30 """Test method for experimentation. 23 """Test method for experimentation.
31 24
32 This method will not run automatically. 25 This method will not run automatically.
33 """ 26 """
34 while True: 27 while True:
35 raw_input('Hit <enter> to dump process info...') 28 raw_input('Hit <enter> to dump process info...')
36 self.pprint(self.GetProcessInfo()) 29 self.pprint(self.GetProcessInfo())
37 30
38 def setUp(self): 31 def setUp(self):
39 self.proc_count_fresh_profile = 0 32 self.proc_count_fresh_profile = 0
40 self.chrome_proc_name = ''
41 if self.IsChromeOS(): 33 if self.IsChromeOS():
42 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['chromeos'] 34 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['chromeos']
43 self.chrome_proc_name = self.CHROME_PROCESS_NAME['chromeos']
44 elif self.IsWin(): 35 elif self.IsWin():
45 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['win'] 36 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['win']
46 self.chrome_proc_name = self.CHROME_PROCESS_NAME['win']
47 elif self.IsMac(): 37 elif self.IsMac():
48 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['mac'] 38 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['mac']
49 self.chrome_proc_name = self.CHROME_PROCESS_NAME['mac']
50 elif self.IsLinux(): 39 elif self.IsLinux():
51 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['linux'] 40 self.proc_count_fresh_profile = self.FRESH_PROFILE_PROC_COUNT['linux']
52 self.chrome_proc_name = self.CHROME_PROCESS_NAME['linux']
53 41
54 pyauto.PyUITest.setUp(self) 42 pyauto.PyUITest.setUp(self)
55 43
56 self.NavigateToURL('about:blank') 44 self.NavigateToURL('about:blank')
57 45
58 def _VerifyProcessCount(self, num_expected): 46 def _VerifyProcessCount(self, num_expected):
59 """Verifies the number of Chrome-related processes is as expected. 47 """Verifies the number of Chrome-related processes is as expected.
60 48
61 Args: 49 Args:
62 num_expected: An integer representing the expected number of Chrome- 50 num_expected: An integer representing the expected number of Chrome-
63 related processes that should currently exist. 51 related processes that should currently exist.
64 """ 52 """
53 browser_process_name = (
54 self.GetBrowserInfo()['properties']['BrowserProcessExecutableName'])
65 proc_info = self.GetProcessInfo() 55 proc_info = self.GetProcessInfo()
66 browser_info = [x for x in proc_info['browsers'] 56 browser_info = [x for x in proc_info['browsers']
67 if x['process_name'] == self.chrome_proc_name] 57 if x['process_name'] == browser_process_name]
68 assert len(browser_info) == 1 58 assert len(browser_info) == 1
69 # Utility & GPU processes may show up any time. Ignore them. 59 # Utility & GPU processes may show up any time. Ignore them.
70 processes = [x for x in browser_info[0]['processes'] 60 processes = [x for x in browser_info[0]['processes']
71 if x['child_process_type'] not in ('Utility', 'GPU')] 61 if x['child_process_type'] not in ('Utility', 'GPU')]
72 num_actual = len(processes) 62 num_actual = len(processes)
73 63
74 self.assertEqual(num_actual, num_expected, 64 self.assertEqual(num_actual, num_expected,
75 msg='Number of processes (ignoring Utility/GPU processes) ' 65 msg='Number of processes (ignoring Utility/GPU processes) '
76 'should be %d, but was %d.\n' 66 'should be %d, but was %d.\n'
77 'Actual processes:\n%s' % ( 67 'Actual processes:\n%s' % (
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 self.OpenNewBrowserWindow(True) 121 self.OpenNewBrowserWindow(True)
132 122
133 for _ in xrange(3): 123 for _ in xrange(3):
134 self.AppendTab(pyauto.GURL('about:blank'), 1) 124 self.AppendTab(pyauto.GURL('about:blank'), 1)
135 125
136 self._VerifyProcessCount(self.proc_count_fresh_profile + 8) 126 self._VerifyProcessCount(self.proc_count_fresh_profile + 8)
137 127
138 128
139 if __name__ == '__main__': 129 if __name__ == '__main__':
140 pyauto_functional.Main() 130 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698