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

Unified Diff: build/android/pylib/android_commands.py

Issue 12094029: Make startup timing independent of host performance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make startup timing independent of host performance - code layout fix Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 08ffa6e2ba282b120acdc3fc47a37bb66515c622..d2a1f5823088841283ea2a602c6a72e1c6a0c3ab 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -530,12 +530,9 @@ class AndroidCommands(object):
return 0
return processes_killed
- def StartActivity(self, package, activity, wait_for_completion=False,
- action='android.intent.action.VIEW',
- category=None, data=None,
- extras=None, trace_file_name=None,
- force_stop=False):
- """Starts |package|'s activity on the device.
+ def _ActivityCmd(self, package, activity, wait_for_completion, action,
Sami 2013/01/29 15:07:59 Bikeshed: _GetActivityCommand?
aberent 2013/01/29 17:02:18 Done.
+ category, data, extras, trace_file_name, force_stop):
+ """Creates command to start |package|'s activity on the device.
Args:
package: Name of package to start (e.g. 'com.google.android.apps.chrome').
@@ -576,8 +573,62 @@ class AndroidCommands(object):
cmd += ' %s %s' % (key, value)
if trace_file_name:
cmd += ' --start-profiler ' + trace_file_name
+ return cmd
+
+ def StartActivity(self, package, activity, wait_for_completion=False,
+ action='android.intent.action.VIEW',
+ category=None, data=None,
+ extras=None, trace_file_name=None,
+ force_stop=False):
+ """Starts |package|'s activity on the device.
Sami 2013/01/29 15:07:59 Rather than having three copies of more or less th
aberent 2013/01/29 17:02:18 Done.
+
+ Args:
+ package: Name of package to start (e.g. 'com.google.android.apps.chrome').
+ activity: Name of activity (e.g. '.Main' or
+ 'com.google.android.apps.chrome.Main').
+ wait_for_completion: wait for the activity to finish launching (-W flag).
+ action: string (e.g. "android.intent.action.MAIN"). Default is VIEW.
+ category: string (e.g. "android.intent.category.HOME")
+ data: Data string to pass to activity (e.g. 'http://www.example.com/').
+ extras: Dict of extras to pass to activity. Values are significant.
+ trace_file_name: If used, turns on and saves the trace to this file name.
+ force_stop: force stop the target app before starting the activity (-S
+ flag).
+ """
+ cmd = self._ActivityCmd(package, activity, wait_for_completion, action,
+ category, data, extras, trace_file_name, force_stop)
self.RunShellCommand(cmd)
+ def StartActivityTimed(self, package, activity, wait_for_completion=False,
+ action='android.intent.action.VIEW',
+ category=None, data=None,
+ extras=None, trace_file_name=None,
+ force_stop=False):
+ """Starts |package|'s activity on the device, returning the start time
+
+ Args:
+ package: Name of package to start (e.g. 'com.google.android.apps.chrome').
+ activity: Name of activity (e.g. '.Main' or
+ 'com.google.android.apps.chrome.Main').
+ wait_for_completion: wait for the activity to finish launching (-W flag).
+ action: string (e.g. "android.intent.action.MAIN"). Default is VIEW.
+ category: string (e.g. "android.intent.category.HOME")
+ data: Data string to pass to activity (e.g. 'http://www.example.com/').
+ extras: Dict of extras to pass to activity. Values are significant.
+ trace_file_name: If used, turns on and saves the trace to this file name.
+ force_stop: force stop the target app before starting the activity (-S
+ flag).
+ """
Sami 2013/01/29 15:07:59 Return value description missing here too.
aberent 2013/01/29 17:02:18 Done.
+ cmd = self._ActivityCmd(package, activity, wait_for_completion, action,
+ category, data, extras, trace_file_name, force_stop)
+ self.StartMonitoringLogcat()
+ self.RunShellCommand('log starting activity; ' + cmd)
Sami 2013/01/29 15:07:59 This works nicely, but I was wondering if you cons
aberent 2013/01/29 17:02:18 That is what it used to do, but we don't seem to g
+ activity_started_re = re.compile('.*starting activity.*')
+ m = self.WaitForLogMatch(activity_started_re, None)
+ assert m
+ start_line = m.group(0)
+ return GetLogTimestamp(start_line, self.GetDeviceYear())
+
def GoHome(self):
"""Tell the device to return to the home screen. Blocks until completion."""
self.RunShellCommand('am start -W '
@@ -858,7 +909,7 @@ class AndroidCommands(object):
raise pexpect.TIMEOUT(
'Timeout (%ds) exceeded waiting for pattern "%s" (tip: use -vv '
'to debug)' %
- (self._logcat.timeout, success_re.pattern))
+ (timeout, success_re.pattern))
except pexpect.EOF:
# It seems that sometimes logcat can end unexpectedly. This seems
# to happen during Chrome startup after a reboot followed by a cache
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698