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

Unified Diff: tools/perf/page_sets/system_health/system_health_story.py

Issue 2386083003: Add background stories to MobileSystemHealth (Closed)
Patch Set: Created 4 years, 2 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/perf/page_sets/system_health/system_health_story.py
diff --git a/tools/perf/page_sets/system_health/system_health_story.py b/tools/perf/page_sets/system_health/system_health_story.py
index 78b9347b73e0787a72ea31f5d76a5c6da5243b1c..5c5e098580e9ce1e8074a04da99efb78e2cff88b 100644
--- a/tools/perf/page_sets/system_health/system_health_story.py
+++ b/tools/perf/page_sets/system_health/system_health_story.py
@@ -8,6 +8,8 @@ from telemetry import decorators
from telemetry.page import page
from telemetry.page import shared_page_state
+from devil.android.sdk import intent # pylint: disable=import-error
+from devil.android.sdk import keyevent # pylint: disable=import-error
# Extra wait time after the page has loaded required by the loading metric. We
# use it in all benchmarks to avoid divergence between benchmarks.
@@ -66,7 +68,8 @@ class SystemHealthStory(page.Page):
ABSTRACT_STORY = True
SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
- def __init__(self, story_set, take_memory_measurement):
+ def __init__(
+ self, story_set, take_memory_measurement, measure_in_background):
case, group, _ = self.NAME.split(':')
super(SystemHealthStory, self).__init__(
shared_page_state_class=_SystemHealthSharedState, page_set=story_set,
@@ -74,6 +77,7 @@ class SystemHealthStory(page.Page):
credentials_path='../data/credentials.json',
grouping_keys={'case': case, 'group': group})
self._take_memory_measurement = take_memory_measurement
+ self._measure_in_background = measure_in_background
@classmethod
def CanRun(cls, possible_browser):
@@ -103,6 +107,26 @@ class SystemHealthStory(page.Page):
def _DidLoadDocument(self, action_runner):
pass
+ def _BackgroundChromeIfNecessary(self, action_runner):
+ if self._measure_in_background:
+ self._BackgroundChrome(action_runner)
+
+ def _ForegroundChromeIfNecessary(self, action_runner):
+ if self._measure_in_background:
+ self._ForegroundChrome(action_runner)
+
+ def _BackgroundChrome(self, action_runner):
+ platform = action_runner.tab.browser.platform
+ platform.LaunchAndroidApplication(
+ intent.Intent(
+ package='com.google.android.deskclock',
+ activity='com.android.deskclock.DeskClock'),
+ app_has_webviews=False)
hjd 2016/10/03 11:23:27 The block above seems kind of ugly, it seems like
+
+ def _ForegroundChrome(self, action_runner):
+ platform = action_runner.tab.browser.platform
+ platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
+
def RunNavigateSteps(self, action_runner):
self._Login(action_runner)
super(SystemHealthStory, self).RunNavigateSteps(action_runner)
@@ -110,4 +134,7 @@ class SystemHealthStory(page.Page):
def RunPageInteractions(self, action_runner):
action_runner.tab.WaitForDocumentReadyStateToBeComplete()
self._DidLoadDocument(action_runner)
+ self._BackgroundChromeIfNecessary(action_runner)
self._Measure(action_runner)
+ self._ForegroundChromeIfNecessary(action_runner)
+

Powered by Google App Engine
This is Rietveld 408576698