OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Finds desktop browsers that can be controlled by telemetry.""" | 4 """Finds desktop browsers that can be controlled by telemetry.""" |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 | 10 |
11 from telemetry.core import browser | 11 from telemetry.core import browser |
12 from telemetry.core import possible_browser | 12 from telemetry.core import possible_browser |
13 from telemetry.core.chrome import desktop_browser_backend | 13 from telemetry.core.chrome import desktop_browser_backend |
14 from telemetry.core.chrome import linux_platform_backend | 14 from telemetry.core.chrome import linux_platform_backend |
15 from telemetry.core.chrome import mac_platform_backend | 15 from telemetry.core.chrome import mac_platform_backend |
16 from telemetry.core.chrome import win_platform_backend | 16 from telemetry.core.chrome import win_platform_backend |
17 | 17 |
18 ALL_BROWSER_TYPES = ','.join([ | 18 ALL_BROWSER_TYPES = ','.join([ |
19 'exact', | 19 'exact', |
20 'release', | 20 'release', |
21 'debug', | 21 'debug', |
22 'canary', | 22 'canary', |
23 'content-shell-debug', | 23 'content-shell-debug', |
24 'content-shell-release', | 24 'content-shell-release', |
| 25 'debug-cros', |
| 26 'release-cros', |
25 'system']) | 27 'system']) |
26 | 28 |
27 class PossibleDesktopBrowser(possible_browser.PossibleBrowser): | 29 class PossibleDesktopBrowser(possible_browser.PossibleBrowser): |
28 """A desktop browser that can be controlled.""" | 30 """A desktop browser that can be controlled.""" |
29 | 31 |
30 def __init__(self, browser_type, options, executable, is_content_shell): | 32 def __init__(self, browser_type, options, executable, is_content_shell, |
| 33 use_login=False): |
31 super(PossibleDesktopBrowser, self).__init__(browser_type, options) | 34 super(PossibleDesktopBrowser, self).__init__(browser_type, options) |
32 self._local_executable = executable | 35 self._local_executable = executable |
33 self._is_content_shell = is_content_shell | 36 self._is_content_shell = is_content_shell |
| 37 self._use_login = use_login |
34 | 38 |
35 def __repr__(self): | 39 def __repr__(self): |
36 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type | 40 return 'PossibleDesktopBrowser(browser_type=%s)' % self.browser_type |
37 | 41 |
38 def Create(self): | 42 def Create(self): |
39 backend = desktop_browser_backend.DesktopBrowserBackend( | 43 backend = desktop_browser_backend.DesktopBrowserBackend( |
40 self._options, self._local_executable, self._is_content_shell) | 44 self._options, self._local_executable, |
| 45 self._is_content_shell, self._use_login) |
41 if sys.platform.startswith('linux'): | 46 if sys.platform.startswith('linux'): |
42 p = linux_platform_backend.LinuxPlatformBackend() | 47 p = linux_platform_backend.LinuxPlatformBackend() |
43 elif sys.platform == 'darwin': | 48 elif sys.platform == 'darwin': |
44 p = mac_platform_backend.MacPlatformBackend() | 49 p = mac_platform_backend.MacPlatformBackend() |
45 elif sys.platform == 'win32': | 50 elif sys.platform == 'win32': |
46 p = win_platform_backend.WinPlatformBackend() | 51 p = win_platform_backend.WinPlatformBackend() |
47 else: | 52 else: |
48 raise NotImplementedError() | 53 raise NotImplementedError() |
49 b = browser.Browser(backend, p) | 54 b = browser.Browser(backend, p) |
50 backend.SetBrowser(b) | 55 backend.SetBrowser(b) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 app, content_shell)) | 111 app, content_shell)) |
107 return True | 112 return True |
108 return False | 113 return False |
109 | 114 |
110 # Add local builds | 115 # Add local builds |
111 AddIfFound('debug', 'Debug', chromium_app_name, False) | 116 AddIfFound('debug', 'Debug', chromium_app_name, False) |
112 AddIfFound('content-shell-debug', 'Debug', content_shell_app_name, True) | 117 AddIfFound('content-shell-debug', 'Debug', content_shell_app_name, True) |
113 AddIfFound('release', 'Release', chromium_app_name, False) | 118 AddIfFound('release', 'Release', chromium_app_name, False) |
114 AddIfFound('content-shell-release', 'Release', content_shell_app_name, True) | 119 AddIfFound('content-shell-release', 'Release', content_shell_app_name, True) |
115 | 120 |
| 121 # Add local chrome for CrOS builds. |
| 122 def AddCrOSIfFound(browser_type, type_dir): |
| 123 """Adds local chrome for ChromeOS builds on linux""" |
| 124 app = os.path.join(chrome_root, 'out', type_dir, chromium_app_name) |
| 125 ldd_path = '/usr/bin/ldd' |
| 126 if not os.path.exists(app) or not os.path.exists(ldd_path): |
| 127 return |
| 128 # Look for libchromeos.so in ldd output. |
| 129 ldd_out = subprocess.check_output([ldd_path, app]) |
| 130 if ldd_out.count('libchromeos.so'): |
| 131 browsers.append(PossibleDesktopBrowser(browser_type, options, app, |
| 132 is_content_shell=False, |
| 133 use_login=True)) |
| 134 |
| 135 if sys.platform.startswith('linux'): |
| 136 AddCrOSIfFound('debug-cros', 'Debug') |
| 137 AddCrOSIfFound('release-cros', 'Release') |
| 138 |
116 # Mac-specific options. | 139 # Mac-specific options. |
117 if sys.platform == 'darwin': | 140 if sys.platform == 'darwin': |
118 mac_canary = ('/Applications/Google Chrome Canary.app/' | 141 mac_canary = ('/Applications/Google Chrome Canary.app/' |
119 'Contents/MacOS/Google Chrome Canary') | 142 'Contents/MacOS/Google Chrome Canary') |
120 mac_system = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' | 143 mac_system = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' |
121 if os.path.exists(mac_canary): | 144 if os.path.exists(mac_canary): |
122 browsers.append(PossibleDesktopBrowser('canary', options, | 145 browsers.append(PossibleDesktopBrowser('canary', options, |
123 mac_canary, False)) | 146 mac_canary, False)) |
124 | 147 |
125 if os.path.exists(mac_system): | 148 if os.path.exists(mac_system): |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 chromium_app_name, False): | 186 chromium_app_name, False): |
164 break | 187 break |
165 | 188 |
166 if len(browsers) and not has_display: | 189 if len(browsers) and not has_display: |
167 logging.warning( | 190 logging.warning( |
168 'Found (%s), but you do not have a DISPLAY environment set.' % | 191 'Found (%s), but you do not have a DISPLAY environment set.' % |
169 ','.join([b.browser_type for b in browsers])) | 192 ','.join([b.browser_type for b in browsers])) |
170 return [] | 193 return [] |
171 | 194 |
172 return browsers | 195 return browsers |
OLD | NEW |