| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Launches the remoting webapp unit test in chrome with the appropriate flags. | 6 """Launches the remoting webapp unit tests in chrome with the appropriate flags. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| 11 import platform | 11 import platform |
| 12 import sys | 12 import sys |
| 13 import tempfile | 13 import tempfile |
| 14 import urllib | 14 import urllib |
| 15 | 15 |
| 16 def GetChromePath(): | 16 def GetChromePath(): |
| 17 """Locates the chrome binary on the system.""" | 17 """Locates the chrome binary on the system.""" |
| 18 chrome_path = '' | 18 chrome_path = '' |
| 19 if platform.system() == 'Darwin': # Darwin == MacOSX | 19 if platform.system() == 'Darwin': # Darwin == MacOSX |
| 20 chrome_path = ( | 20 chrome_path = ( |
| 21 '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome') | 21 '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome') |
| 22 elif platform.system() == 'Linux': | 22 elif platform.system() == 'Linux': |
| 23 chrome_path = '/usr/bin/google-chrome' | 23 chrome_path = '/usr/bin/google-chrome' |
| 24 else: | 24 else: |
| 25 # TODO(kelvinp): Support chrome path location on Windows. | 25 # TODO(kelvinp): Support chrome path location on Windows. |
| 26 print 'Unsupported OS.' | 26 print 'Unsupported OS.' |
| 27 return chrome_path | 27 return chrome_path |
| 28 | 28 |
| 29 | 29 |
| 30 def BuildTestPageUri(opt_module=None, opt_coverage=False): | 30 def BuildTestPageUri(opt_module=None, opt_coverage=False): |
| 31 """Builds the Uri for the test page with params.""" | 31 """Builds the Uri for the test page with params.""" |
| 32 script_path = os.path.dirname(__file__) | 32 script_path = os.path.dirname(__file__) |
| 33 | 33 |
| 34 test_page_path = os.path.join(script_path, | 34 test_page_path = os.path.join(script_path, |
| 35 '../../out/Debug/remoting/unittests/unittest.html') | 35 '../../out/Debug/remoting/unittests/unittests.html') |
| 36 test_page_path = 'file://' + os.path.abspath(test_page_path) | 36 test_page_path = 'file://' + os.path.abspath(test_page_path) |
| 37 | 37 |
| 38 test_page_params = {} | 38 test_page_params = {} |
| 39 if opt_coverage: | 39 if opt_coverage: |
| 40 test_page_params['coverage'] = 'true' | 40 test_page_params['coverage'] = 'true' |
| 41 if opt_module: | 41 if opt_module: |
| 42 test_page_params['module'] = opt_module | 42 test_page_params['module'] = opt_module |
| 43 if test_page_params: | 43 if test_page_params: |
| 44 test_page_path = test_page_path + '?%s' % urllib.urlencode(test_page_params) | 44 test_page_path = test_page_path + '?%s' % urllib.urlencode(test_page_params) |
| 45 return '"' + test_page_path + '"' | 45 return '"' + test_page_path + '"' |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 print 'binary to run the test.' | 84 print 'binary to run the test.' |
| 85 return 1 | 85 return 1 |
| 86 | 86 |
| 87 command_line = BuildCommandLine(args.chrome_path, args.module, args.coverage) | 87 command_line = BuildCommandLine(args.chrome_path, args.module, args.coverage) |
| 88 os.system(command_line) | 88 os.system(command_line) |
| 89 return 0 | 89 return 0 |
| 90 | 90 |
| 91 | 91 |
| 92 if __name__ == '__main__': | 92 if __name__ == '__main__': |
| 93 sys.exit(main()) | 93 sys.exit(main()) |
| OLD | NEW |