| OLD | NEW |
| 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 import unittest | 4 import unittest |
| 5 | 5 |
| 6 from telemetry.internal.backends.chrome import desktop_browser_finder | 6 from telemetry.internal.backends.chrome import desktop_browser_finder |
| 7 from telemetry.internal.browser import browser_options | 7 from telemetry.internal.browser import browser_options |
| 8 from telemetry.internal.platform import desktop_device | 8 from telemetry.internal.platform import desktop_device |
| 9 from telemetry.testing import system_stub | 9 from telemetry.testing import system_stub |
| 10 | 10 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 self._finder_stubs.sys.platform = 'linux2' | 147 self._finder_stubs.sys.platform = 'linux2' |
| 148 self._path_stubs.sys.platform = 'linux2' | 148 self._path_stubs.sys.platform = 'linux2' |
| 149 self._files.append('/foo/chrome') | 149 self._files.append('/foo/chrome') |
| 150 self._files.append('../../../out/Release/chrome') | 150 self._files.append('../../../out/Release/chrome') |
| 151 self._files.append('../../../out/Debug/chrome') | 151 self._files.append('../../../out/Debug/chrome') |
| 152 self._files.append('../../../out/Release/content_shell') | 152 self._files.append('../../../out/Release/content_shell') |
| 153 self._files.append('../../../out/Debug/content_shell') | 153 self._files.append('../../../out/Debug/content_shell') |
| 154 | 154 |
| 155 self.has_google_chrome_on_path = False | 155 self.has_google_chrome_on_path = False |
| 156 self.chrome_beta_is_google_chrome = False |
| 156 this = self | 157 this = self |
| 157 def call_hook(*args, **kwargs): # pylint: disable=W0613 | 158 def call_hook(*args, **kwargs): # pylint: disable=W0613 |
| 158 if this.has_google_chrome_on_path: | 159 if this.has_google_chrome_on_path: |
| 159 return 0 | 160 return 0 |
| 160 raise OSError('Not found') | 161 raise OSError('Not found') |
| 161 self._finder_stubs.subprocess.call = call_hook | 162 self._finder_stubs.subprocess.call = call_hook |
| 162 | 163 |
| 164 def realpath_hook(*unused_args, **unused_kwargs): |
| 165 if this.chrome_beta_is_google_chrome: |
| 166 return '/opt/google/chrome-beta/google-chrome-beta' |
| 167 return '/opt/google/chrome/google-chrome' |
| 168 self._finder_stubs.os.path.realpath = realpath_hook |
| 169 |
| 163 def testFindAllWithExact(self): | 170 def testFindAllWithExact(self): |
| 164 if not self.CanFindAvailableBrowsers(): | 171 if not self.CanFindAvailableBrowsers(): |
| 165 return | 172 return |
| 166 | 173 |
| 167 types = self.DoFindAllTypes() | 174 types = self.DoFindAllTypes() |
| 168 self.assertEquals( | 175 self.assertEquals( |
| 169 set(types), | 176 set(types), |
| 170 set(['debug', 'release', | 177 set(['debug', 'release', |
| 171 'content-shell-debug', 'content-shell-release'])) | 178 'content-shell-debug', 'content-shell-release'])) |
| 172 | 179 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 187 def testFindUsingDefaults(self): | 194 def testFindUsingDefaults(self): |
| 188 if not self.CanFindAvailableBrowsers(): | 195 if not self.CanFindAvailableBrowsers(): |
| 189 return | 196 return |
| 190 | 197 |
| 191 self.has_google_chrome_on_path = True | 198 self.has_google_chrome_on_path = True |
| 192 self.assertIn('release', self.DoFindAllTypes()) | 199 self.assertIn('release', self.DoFindAllTypes()) |
| 193 | 200 |
| 194 del self._files[1] | 201 del self._files[1] |
| 195 self.has_google_chrome_on_path = True | 202 self.has_google_chrome_on_path = True |
| 196 self.assertIn('system', self.DoFindAllTypes()) | 203 self.assertIn('system', self.DoFindAllTypes()) |
| 204 self.assertIn('stable', self.DoFindAllTypes()) |
| 205 self.assertIn('beta', self.DoFindAllTypes()) |
| 206 self.assertIn('dev', self.DoFindAllTypes()) |
| 197 | 207 |
| 198 self.has_google_chrome_on_path = False | 208 self.has_google_chrome_on_path = False |
| 199 del self._files[1] | 209 del self._files[1] |
| 200 self.assertEquals(['content-shell-debug', 'content-shell-release'], | 210 self.assertEquals(['content-shell-debug', 'content-shell-release'], |
| 201 self.DoFindAllTypes()) | 211 self.DoFindAllTypes()) |
| 202 | 212 |
| 213 self.has_google_chrome_on_path = True |
| 214 self.chrome_beta_is_google_chrome = True |
| 215 |
| 216 google_chrome = [browser for browser in self.DoFindAll() |
| 217 if browser._local_executable == 'google-chrome'][0] |
| 218 self.assertEquals('/opt/google/chrome-beta', |
| 219 google_chrome._browser_directory) |
| 220 |
| 203 def testFindUsingRelease(self): | 221 def testFindUsingRelease(self): |
| 204 if not self.CanFindAvailableBrowsers(): | 222 if not self.CanFindAvailableBrowsers(): |
| 205 return | 223 return |
| 206 | 224 |
| 207 self.assertIn('release', self.DoFindAllTypes()) | 225 self.assertIn('release', self.DoFindAllTypes()) |
| 208 | 226 |
| 209 | 227 |
| 210 class WinFindTest(FindTestBase): | 228 class WinFindTest(FindTestBase): |
| 211 def setUp(self): | 229 def setUp(self): |
| 212 super(WinFindTest, self).setUp() | 230 super(WinFindTest, self).setUp() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if not self.CanFindAvailableBrowsers(): | 269 if not self.CanFindAvailableBrowsers(): |
| 252 return | 270 return |
| 253 | 271 |
| 254 self._finder_options.browser_executable = 'c:\\tmp\\chrome_shell.apk' | 272 self._finder_options.browser_executable = 'c:\\tmp\\chrome_shell.apk' |
| 255 types = self.DoFindAllTypes() | 273 types = self.DoFindAllTypes() |
| 256 self.assertEquals( | 274 self.assertEquals( |
| 257 set(types), | 275 set(types), |
| 258 set(['debug', 'release', | 276 set(['debug', 'release', |
| 259 'content-shell-debug', 'content-shell-release', | 277 'content-shell-debug', 'content-shell-release', |
| 260 'system', 'canary'])) | 278 'system', 'canary'])) |
| OLD | NEW |