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

Unified Diff: experimental/telemetry_mini/telemetry_mini.py

Issue 3000083002: [telemetry_mini] Add UserStory class (Closed)
Patch Set: Created 3 years, 4 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 | « experimental/telemetry_mini/android_go_stories.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/telemetry_mini/telemetry_mini.py
diff --git a/experimental/telemetry_mini/telemetry_mini.py b/experimental/telemetry_mini/telemetry_mini.py
index 42271ed44613e098ce6e857c13b40c904337181b..7685a76e0e7e881a8ae29c055e09cf2ccccf358a 100644
--- a/experimental/telemetry_mini/telemetry_mini.py
+++ b/experimental/telemetry_mini/telemetry_mini.py
@@ -390,6 +390,45 @@ class SystemChromeApp(ChromiumApp):
self.device.RunShellCommand('pm', 'disable', self.PACKAGE_NAME)
+class UserStory(object):
+ def __init__(self, browser):
+ self.device = browser.device
+ self.browser = browser
+
+ def GetExtraStoryApps(self):
+ """Sequence of AndroidApp's, other than the browser, used in the story."""
+ return ()
+
+ def EnsureExtraStoryAppsClosed(self):
+ running_processes = self.device.ProcessStatus()
+ for app in self.GetExtraStoryApps():
+ if app.PACKAGE_NAME in running_processes:
+ app.ForceStop()
+
+ def Run(self, browser_flags, trace_config, trace_file):
+ with self.browser.Session(browser_flags, trace_config):
+ self.EnsureExtraStoryAppsClosed()
+ try:
+ self.RunStorySteps()
+ self.browser.CollectTrace(trace_file)
+ except Exception as exc:
+ # Helps to pin point in the logs the moment where the story failed,
+ # before any of the finally blocks get to be executed.
+ logging.error('Aborting story due to %s.', type(exc).__name__)
+ raise
+ finally:
+ self.EnsureExtraStoryAppsClosed()
+
+ def RunStorySteps(self):
+ """Subclasses should override this method to implement the story.
+
+ The steps must:
+ - at some point cause the browser to be launched, and
+ - make sure the browser remains alive when done (even if backgrounded).
+ """
+ raise NotImplementedError
+
+
def ReadProcessMetrics(trace_file):
"""Return a list of {"name": process_name, metric: value} dicts."""
with open(trace_file) as f:
« no previous file with comments | « experimental/telemetry_mini/android_go_stories.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698