| 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 | 4 |
| 5 import logging | 5 import logging |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from telemetry.core import exceptions | 8 from telemetry.core import exceptions |
| 9 | 9 |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 def pseudo_exec_name(self): | 30 def pseudo_exec_name(self): |
| 31 return self._pseudo_exec_name | 31 return self._pseudo_exec_name |
| 32 | 32 |
| 33 @property | 33 @property |
| 34 def supports_tab_control(self): | 34 def supports_tab_control(self): |
| 35 return self._supports_tab_control | 35 return self._supports_tab_control |
| 36 | 36 |
| 37 def GetCommandLineFile(self, is_user_debug_build): # pylint: disable=W0613 | 37 def GetCommandLineFile(self, is_user_debug_build): # pylint: disable=W0613 |
| 38 return self._cmdline_file | 38 return self._cmdline_file |
| 39 | 39 |
| 40 def GetDevtoolsRemotePort(self, adb): | 40 def GetDevtoolsRemotePort(self, device): |
| 41 raise NotImplementedError() | 41 raise NotImplementedError() |
| 42 | 42 |
| 43 @property | 43 @property |
| 44 def profile_ignore_list(self): | 44 def profile_ignore_list(self): |
| 45 # Don't delete lib, since it is created by the installer. | 45 # Don't delete lib, since it is created by the installer. |
| 46 return ['lib'] | 46 return ['lib'] |
| 47 | 47 |
| 48 | 48 |
| 49 class ChromeBackendSettings(AndroidBrowserBackendSettings): | 49 class ChromeBackendSettings(AndroidBrowserBackendSettings): |
| 50 # Stores a default Preferences file, re-used to speed up "--page-repeat". | 50 # Stores a default Preferences file, re-used to speed up "--page-repeat". |
| 51 _default_preferences_file = None | 51 _default_preferences_file = None |
| 52 | 52 |
| 53 def GetCommandLineFile(self, is_user_debug_build): | 53 def GetCommandLineFile(self, is_user_debug_build): |
| 54 if is_user_debug_build: | 54 if is_user_debug_build: |
| 55 return '/data/local/tmp/chrome-command-line' | 55 return '/data/local/tmp/chrome-command-line' |
| 56 else: | 56 else: |
| 57 return '/data/local/chrome-command-line' | 57 return '/data/local/chrome-command-line' |
| 58 | 58 |
| 59 def __init__(self, package): | 59 def __init__(self, package): |
| 60 super(ChromeBackendSettings, self).__init__( | 60 super(ChromeBackendSettings, self).__init__( |
| 61 activity='com.google.android.apps.chrome.Main', | 61 activity='com.google.android.apps.chrome.Main', |
| 62 cmdline_file=None, | 62 cmdline_file=None, |
| 63 package=package, | 63 package=package, |
| 64 pseudo_exec_name='chrome', | 64 pseudo_exec_name='chrome', |
| 65 supports_tab_control=True) | 65 supports_tab_control=True) |
| 66 | 66 |
| 67 def GetDevtoolsRemotePort(self, adb): | 67 def GetDevtoolsRemotePort(self, device): |
| 68 return 'localabstract:chrome_devtools_remote' | 68 return 'localabstract:chrome_devtools_remote' |
| 69 | 69 |
| 70 | 70 |
| 71 class ContentShellBackendSettings(AndroidBrowserBackendSettings): | 71 class ContentShellBackendSettings(AndroidBrowserBackendSettings): |
| 72 def __init__(self, package): | 72 def __init__(self, package): |
| 73 super(ContentShellBackendSettings, self).__init__( | 73 super(ContentShellBackendSettings, self).__init__( |
| 74 activity='org.chromium.content_shell_apk.ContentShellActivity', | 74 activity='org.chromium.content_shell_apk.ContentShellActivity', |
| 75 cmdline_file='/data/local/tmp/content-shell-command-line', | 75 cmdline_file='/data/local/tmp/content-shell-command-line', |
| 76 package=package, | 76 package=package, |
| 77 pseudo_exec_name='content_shell', | 77 pseudo_exec_name='content_shell', |
| 78 supports_tab_control=False) | 78 supports_tab_control=False) |
| 79 | 79 |
| 80 def GetDevtoolsRemotePort(self, adb): | 80 def GetDevtoolsRemotePort(self, device): |
| 81 return 'localabstract:content_shell_devtools_remote' | 81 return 'localabstract:content_shell_devtools_remote' |
| 82 | 82 |
| 83 | 83 |
| 84 class ChromeShellBackendSettings(AndroidBrowserBackendSettings): | 84 class ChromeShellBackendSettings(AndroidBrowserBackendSettings): |
| 85 def __init__(self, package): | 85 def __init__(self, package): |
| 86 super(ChromeShellBackendSettings, self).__init__( | 86 super(ChromeShellBackendSettings, self).__init__( |
| 87 activity='org.chromium.chrome.shell.ChromeShellActivity', | 87 activity='org.chromium.chrome.shell.ChromeShellActivity', |
| 88 cmdline_file='/data/local/tmp/chrome-shell-command-line', | 88 cmdline_file='/data/local/tmp/chrome-shell-command-line', |
| 89 package=package, | 89 package=package, |
| 90 pseudo_exec_name='chrome_shell', | 90 pseudo_exec_name='chrome_shell', |
| 91 supports_tab_control=False) | 91 supports_tab_control=False) |
| 92 | 92 |
| 93 def GetDevtoolsRemotePort(self, adb): | 93 def GetDevtoolsRemotePort(self, device): |
| 94 return 'localabstract:chrome_shell_devtools_remote' | 94 return 'localabstract:chrome_shell_devtools_remote' |
| 95 | 95 |
| 96 | 96 |
| 97 class WebviewBackendSettings(AndroidBrowserBackendSettings): | 97 class WebviewBackendSettings(AndroidBrowserBackendSettings): |
| 98 def __init__(self, | 98 def __init__(self, |
| 99 package, | 99 package, |
| 100 activity='org.chromium.webview_shell.TelemetryActivity', | 100 activity='org.chromium.webview_shell.TelemetryActivity', |
| 101 cmdline_file='/data/local/tmp/webview-command-line'): | 101 cmdline_file='/data/local/tmp/webview-command-line'): |
| 102 super(WebviewBackendSettings, self).__init__( | 102 super(WebviewBackendSettings, self).__init__( |
| 103 activity=activity, | 103 activity=activity, |
| 104 cmdline_file=cmdline_file, | 104 cmdline_file=cmdline_file, |
| 105 package=package, | 105 package=package, |
| 106 pseudo_exec_name='webview', | 106 pseudo_exec_name='webview', |
| 107 supports_tab_control=False) | 107 supports_tab_control=False) |
| 108 | 108 |
| 109 def GetDevtoolsRemotePort(self, adb): | 109 def GetDevtoolsRemotePort(self, device): |
| 110 # The DevTools socket name for WebView depends on the activity PID's. | 110 # The DevTools socket name for WebView depends on the activity PID's. |
| 111 retries = 0 | 111 retries = 0 |
| 112 timeout = 1 | 112 timeout = 1 |
| 113 pid = None | 113 pid = None |
| 114 while True: | 114 while True: |
| 115 pids = adb.ExtractPid(self.package) | 115 pids = device.GetPids(self.package) |
| 116 if len(pids) > 0: | 116 if not pids or self.package not in pids: |
| 117 pid = pids[-1] | 117 time.sleep(timeout) |
| 118 break | 118 retries += 1 |
| 119 time.sleep(timeout) | 119 timeout *= 2 |
| 120 retries += 1 | 120 if retries == 4: |
| 121 timeout *= 2 | 121 logging.critical('android_browser_backend: Timeout while waiting for ' |
| 122 if retries == 4: | 122 'activity %s:%s to come up', |
| 123 logging.critical('android_browser_backend: Timeout while waiting for ' | 123 self.package, |
| 124 'activity %s:%s to come up', | 124 self.activity) |
| 125 self.package, | 125 raise exceptions.BrowserGoneException(self.browser, |
| 126 self.activity) | 126 'Timeout waiting for PID.') |
| 127 raise exceptions.BrowserGoneException(self.browser, | 127 pid = pids[self.package] |
| 128 'Timeout waiting for PID.') | 128 break |
| 129 return 'localabstract:webview_devtools_remote_%s' % str(pid) | 129 return 'localabstract:webview_devtools_remote_%s' % str(pid) |
| 130 | 130 |
| 131 | 131 |
| 132 class WebviewShellBackendSettings(WebviewBackendSettings): | 132 class WebviewShellBackendSettings(WebviewBackendSettings): |
| 133 def __init__(self, package): | 133 def __init__(self, package): |
| 134 super(WebviewShellBackendSettings, self).__init__( | 134 super(WebviewShellBackendSettings, self).__init__( |
| 135 activity='org.chromium.android_webview.shell.AwShellActivity', | 135 activity='org.chromium.android_webview.shell.AwShellActivity', |
| 136 cmdline_file='/data/local/tmp/android-webview-command-line', | 136 cmdline_file='/data/local/tmp/android-webview-command-line', |
| 137 package=package) | 137 package=package) |
| OLD | NEW |