OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 import logging | |
6 import time | |
7 | |
8 from telemetry.core import exceptions | |
9 | |
10 | |
11 class AndroidBrowserBackendSettings(object): | |
12 | |
13 def __init__(self, activity, cmdline_file, package, pseudo_exec_name, | |
14 supports_tab_control): | |
15 self.activity = activity | |
16 self._cmdline_file = cmdline_file | |
nednguyen
2015/01/13 16:03:04
Can you make the 3 properties below "immutable"?
ariblue
2015/01/13 20:23:37
Done (added immutable property for self.activity,
| |
17 self.package = package | |
18 self.pseudo_exec_name = pseudo_exec_name | |
19 self.supports_tab_control = supports_tab_control | |
20 | |
21 def GetCommandLineFile(self, is_user_debug_build): # pylint: disable=W0613 | |
22 return self._cmdline_file | |
23 | |
24 def GetDevtoolsRemotePort(self, adb): | |
25 raise NotImplementedError() | |
26 | |
27 @property | |
28 def profile_ignore_list(self): | |
29 # Don't delete lib, since it is created by the installer. | |
30 return ['lib'] | |
31 | |
32 | |
33 class ChromeBackendSettings(AndroidBrowserBackendSettings): | |
34 # Stores a default Preferences file, re-used to speed up "--page-repeat". | |
35 _default_preferences_file = None | |
36 | |
37 def GetCommandLineFile(self, is_user_debug_build): | |
38 if is_user_debug_build: | |
39 return '/data/local/tmp/chrome-command-line' | |
40 else: | |
41 return '/data/local/chrome-command-line' | |
42 | |
43 def __init__(self, package): | |
44 super(ChromeBackendSettings, self).__init__( | |
45 activity='com.google.android.apps.chrome.Main', | |
46 cmdline_file=None, | |
47 package=package, | |
48 pseudo_exec_name='chrome', | |
49 supports_tab_control=True) | |
50 | |
51 def GetDevtoolsRemotePort(self, adb): | |
52 return 'localabstract:chrome_devtools_remote' | |
53 | |
54 | |
55 class ContentShellBackendSettings(AndroidBrowserBackendSettings): | |
56 def __init__(self, package): | |
57 super(ContentShellBackendSettings, self).__init__( | |
58 activity='org.chromium.content_shell_apk.ContentShellActivity', | |
59 cmdline_file='/data/local/tmp/content-shell-command-line', | |
60 package=package, | |
61 pseudo_exec_name='content_shell', | |
62 supports_tab_control=False) | |
63 | |
64 def GetDevtoolsRemotePort(self, adb): | |
65 return 'localabstract:content_shell_devtools_remote' | |
66 | |
67 | |
68 class ChromeShellBackendSettings(AndroidBrowserBackendSettings): | |
69 def __init__(self, package): | |
70 super(ChromeShellBackendSettings, self).__init__( | |
71 activity='org.chromium.chrome.shell.ChromeShellActivity', | |
72 cmdline_file='/data/local/tmp/chrome-shell-command-line', | |
73 package=package, | |
74 pseudo_exec_name='chrome_shell', | |
75 supports_tab_control=False) | |
76 | |
77 def GetDevtoolsRemotePort(self, adb): | |
78 return 'localabstract:chrome_shell_devtools_remote' | |
79 | |
80 | |
81 class WebviewBackendSettings(AndroidBrowserBackendSettings): | |
82 def __init__(self, | |
83 package, | |
84 activity='org.chromium.telemetry_shell.TelemetryActivity', | |
85 cmdline_file='/data/local/tmp/webview-command-line'): | |
86 super(WebviewBackendSettings, self).__init__( | |
87 activity=activity, | |
88 cmdline_file=cmdline_file, | |
89 package=package, | |
90 pseudo_exec_name='webview', | |
91 supports_tab_control=False) | |
92 | |
93 def GetDevtoolsRemotePort(self, adb): | |
94 # The DevTools socket name for WebView depends on the activity PID's. | |
95 retries = 0 | |
96 timeout = 1 | |
97 pid = None | |
98 while True: | |
99 pids = adb.ExtractPid(self.package) | |
100 if len(pids) > 0: | |
101 pid = pids[-1] | |
102 break | |
103 time.sleep(timeout) | |
104 retries += 1 | |
105 timeout *= 2 | |
106 if retries == 4: | |
107 logging.critical('android_browser_backend: Timeout while waiting for ' | |
108 'activity %s:%s to come up', | |
109 self.package, | |
110 self.activity) | |
111 raise exceptions.BrowserGoneException(self.browser, | |
112 'Timeout waiting for PID.') | |
113 return 'localabstract:webview_devtools_remote_%s' % str(pid) | |
114 | |
115 | |
116 class WebviewShellBackendSettings(WebviewBackendSettings): | |
117 def __init__(self, package): | |
118 super(WebviewShellBackendSettings, self).__init__( | |
119 activity='org.chromium.android_webview.shell.AwShellActivity', | |
120 cmdline_file='/data/local/tmp/android-webview-command-line', | |
121 package=package) | |
OLD | NEW |