Index: tools/perf/page_sets/android_screen_restoration_shared_state.py |
diff --git a/tools/perf/page_sets/android_screen_restoration_shared_state.py b/tools/perf/page_sets/android_screen_restoration_shared_state.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3de3c2e294267d0124d87661a543b7ccd1799963 |
--- /dev/null |
+++ b/tools/perf/page_sets/android_screen_restoration_shared_state.py |
@@ -0,0 +1,29 @@ |
+# Copyright 2015 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 |
+ |
+from telemetry.page import shared_page_state |
+ |
+ |
+class AndroidScreenRestorationSharedState(shared_page_state.SharedPageState): |
+ """ Ensures the screen is on before and after each user story is run. """ |
+ |
+ def WillRunUserStory(self, page): |
+ super(AndroidScreenRestorationSharedState, self).WillRunUserStory(page) |
+ self._EnsureScreenOn() |
+ |
+ def DidRunUserStory(self, results): |
+ try: |
+ super(AndroidScreenRestorationSharedState, self).DidRunUserStory(results) |
+ finally: |
+ self._EnsureScreenOn() |
+ |
+ def CanRunOnBrowser(self, browser_info): |
+ if not browser_info.browser_type.startswith('android'): |
+ logging.warning('Browser is non-Android, skipping test') |
+ return False |
+ return True |
+ |
+ def _EnsureScreenOn(self): |
+ self.platform.android_action_runner.EnsureScreenOn() |