Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: tools/telemetry/telemetry/core/backends/android_browser_backend_settings.py

Issue 811703007: Create AndroidCommandLineBackend to handle setting up cmdline args (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/backends/android_browser_backend_settings.py
diff --git a/tools/telemetry/telemetry/core/backends/android_browser_backend_settings.py b/tools/telemetry/telemetry/core/backends/android_browser_backend_settings.py
new file mode 100644
index 0000000000000000000000000000000000000000..e08a84a170ff4e5f6df892633a21d44fb8d97bc8
--- /dev/null
+++ b/tools/telemetry/telemetry/core/backends/android_browser_backend_settings.py
@@ -0,0 +1,121 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import time
+
+from telemetry.core import exceptions
+
+
+class AndroidBrowserBackendSettings(object):
+
+ def __init__(self, activity, cmdline_file, package, pseudo_exec_name,
+ supports_tab_control):
+ self.activity = activity
+ 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,
+ self.package = package
+ self.pseudo_exec_name = pseudo_exec_name
+ self.supports_tab_control = supports_tab_control
+
+ def GetCommandLineFile(self, is_user_debug_build): # pylint: disable=W0613
+ return self._cmdline_file
+
+ def GetDevtoolsRemotePort(self, adb):
+ raise NotImplementedError()
+
+ @property
+ def profile_ignore_list(self):
+ # Don't delete lib, since it is created by the installer.
+ return ['lib']
+
+
+class ChromeBackendSettings(AndroidBrowserBackendSettings):
+ # Stores a default Preferences file, re-used to speed up "--page-repeat".
+ _default_preferences_file = None
+
+ def GetCommandLineFile(self, is_user_debug_build):
+ if is_user_debug_build:
+ return '/data/local/tmp/chrome-command-line'
+ else:
+ return '/data/local/chrome-command-line'
+
+ def __init__(self, package):
+ super(ChromeBackendSettings, self).__init__(
+ activity='com.google.android.apps.chrome.Main',
+ cmdline_file=None,
+ package=package,
+ pseudo_exec_name='chrome',
+ supports_tab_control=True)
+
+ def GetDevtoolsRemotePort(self, adb):
+ return 'localabstract:chrome_devtools_remote'
+
+
+class ContentShellBackendSettings(AndroidBrowserBackendSettings):
+ def __init__(self, package):
+ super(ContentShellBackendSettings, self).__init__(
+ activity='org.chromium.content_shell_apk.ContentShellActivity',
+ cmdline_file='/data/local/tmp/content-shell-command-line',
+ package=package,
+ pseudo_exec_name='content_shell',
+ supports_tab_control=False)
+
+ def GetDevtoolsRemotePort(self, adb):
+ return 'localabstract:content_shell_devtools_remote'
+
+
+class ChromeShellBackendSettings(AndroidBrowserBackendSettings):
+ def __init__(self, package):
+ super(ChromeShellBackendSettings, self).__init__(
+ activity='org.chromium.chrome.shell.ChromeShellActivity',
+ cmdline_file='/data/local/tmp/chrome-shell-command-line',
+ package=package,
+ pseudo_exec_name='chrome_shell',
+ supports_tab_control=False)
+
+ def GetDevtoolsRemotePort(self, adb):
+ return 'localabstract:chrome_shell_devtools_remote'
+
+
+class WebviewBackendSettings(AndroidBrowserBackendSettings):
+ def __init__(self,
+ package,
+ activity='org.chromium.telemetry_shell.TelemetryActivity',
+ cmdline_file='/data/local/tmp/webview-command-line'):
+ super(WebviewBackendSettings, self).__init__(
+ activity=activity,
+ cmdline_file=cmdline_file,
+ package=package,
+ pseudo_exec_name='webview',
+ supports_tab_control=False)
+
+ def GetDevtoolsRemotePort(self, adb):
+ # The DevTools socket name for WebView depends on the activity PID's.
+ retries = 0
+ timeout = 1
+ pid = None
+ while True:
+ pids = adb.ExtractPid(self.package)
+ if len(pids) > 0:
+ pid = pids[-1]
+ break
+ time.sleep(timeout)
+ retries += 1
+ timeout *= 2
+ if retries == 4:
+ logging.critical('android_browser_backend: Timeout while waiting for '
+ 'activity %s:%s to come up',
+ self.package,
+ self.activity)
+ raise exceptions.BrowserGoneException(self.browser,
+ 'Timeout waiting for PID.')
+ return 'localabstract:webview_devtools_remote_%s' % str(pid)
+
+
+class WebviewShellBackendSettings(WebviewBackendSettings):
+ def __init__(self, package):
+ super(WebviewShellBackendSettings, self).__init__(
+ activity='org.chromium.android_webview.shell.AwShellActivity',
+ cmdline_file='/data/local/tmp/android-webview-command-line',
+ package=package)

Powered by Google App Engine
This is Rietveld 408576698