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

Side by Side Diff: chrome/test/mini_installer/launch_chrome.py

Issue 24126005: Use CreateProcess instead of subprocess.Popen to launch Chrome in the mini_installer test framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address gab's comment. Created 7 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
« 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 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Launches Chrome. 5 """Launches Chrome.
6 6
7 This script launches Chrome and waits until its window shows up. 7 This script launches Chrome and waits until its window shows up.
8 """ 8 """
9 9
10 import optparse 10 import optparse
11 import subprocess
12 import sys 11 import sys
13 import time 12 import time
13 import win32process
14 14
15 import chrome_helper 15 import chrome_helper
16 16
17 17
18 def WaitForWindow(process_id, class_pattern): 18 def WaitForWindow(process_id, class_pattern):
19 """Waits until a window specified by |process_id| and class name shows up. 19 """Waits until a window specified by |process_id| and class name shows up.
20 20
21 Args: 21 Args:
22 process_id: The ID of the process that owns the window. 22 process_id: The ID of the process that owns the window.
23 class_pattern: The regular expression pattern of the window class name. 23 class_pattern: The regular expression pattern of the window class name.
(...skipping 11 matching lines...) Expand all
35 35
36 36
37 def main(): 37 def main():
38 usage = 'usage: %prog chrome_path' 38 usage = 'usage: %prog chrome_path'
39 parser = optparse.OptionParser(usage, description='Launch Chrome.') 39 parser = optparse.OptionParser(usage, description='Launch Chrome.')
40 _, args = parser.parse_args() 40 _, args = parser.parse_args()
41 if len(args) != 1: 41 if len(args) != 1:
42 parser.error('Incorrect number of arguments.') 42 parser.error('Incorrect number of arguments.')
43 chrome_path = args[0] 43 chrome_path = args[0]
44 44
45 process = subprocess.Popen(chrome_path) 45 # Use CreateProcess rather than subprocess.Popen to avoid side effects such as
46 if not WaitForWindow(process.pid, 'Chrome_WidgetWin_'): 46 # handle interitance.
47 _, _, process_id, _ = win32process.CreateProcess(None, chrome_path, None,
48 None, 0, 0, None, None,
49 win32process.STARTUPINFO())
50 if not WaitForWindow(process_id, 'Chrome_WidgetWin_'):
47 raise Exception('Could not launch Chrome.') 51 raise Exception('Could not launch Chrome.')
48 return 0 52 return 0
49 53
50 54
51 if __name__ == '__main__': 55 if __name__ == '__main__':
52 sys.exit(main()) 56 sys.exit(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