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

Unified Diff: tools/telemetry/telemetry/page/page_test.py

Issue 16373012: [telemetry] Simplify the way PageRunner is called. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DidStartHTTPServer() and re-add WillRunPageSet() Created 7 years, 6 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/page/page_test.py
diff --git a/tools/telemetry/telemetry/page/page_test.py b/tools/telemetry/telemetry/page/page_test.py
index 7e3e08b179b5fe1d4989d2940f730eed29491da9..5ca6addce1b410f3e3d600d4984e5b474ebb2153 100644
--- a/tools/telemetry/telemetry/page/page_test.py
+++ b/tools/telemetry/telemetry/page/page_test.py
@@ -4,6 +4,8 @@
import logging
from telemetry.core import util
+from telemetry.page import gtest_test_results
+from telemetry.page import page_test_results
from telemetry.page.actions import all_page_actions
from telemetry.page.actions import page_action
@@ -97,7 +99,7 @@ class PageTest(object):
"""Override to customize if the test can be ran for the given page."""
return True
- def WillRunPageSet(self, tab, results):
+ def WillRunPageSet(self, tab):
"""Override to do operations before the page set is navigated."""
pass
@@ -106,6 +108,10 @@ class PageTest(object):
is torn down."""
pass
+ def DidStartHTTPServer(self, tab):
+ """Override to do operations after the HTTP server is started."""
+ pass
+
def WillNavigateToPage(self, page, tab):
"""Override to do operations before the page is navigated."""
pass
@@ -128,6 +134,29 @@ class PageTest(object):
allowing arbitrary page sets entered from the command-line."""
return None
+ def AddOutputOptions(self, parser):
+ parser.add_option('--output-format',
+ default=self.output_format_choices[0],
+ choices=self.output_format_choices,
+ help='Output format. Defaults to "%%default". '
+ 'Can be %s.' % ', '.join(self.output_format_choices))
+
+ @property
+ def output_format_choices(self):
+ """Allowed output formats. The default is the first item in the list."""
+ return ['gtest', 'none']
+
+ def PrepareResults(self, options):
+ if options.output_format == 'gtest':
+ return gtest_test_results.GTestTestResults()
+ elif options.output_format == 'none':
+ return page_test_results.PageTestResults()
+ else:
+ # Should never be reached. The parser enforces the choices.
+ raise Exception('Invalid --output-format "%s". Valid choices are: %s'
+ % (options.output_format,
+ ', '.join(self.output_format_choices)))
+
def Run(self, options, page, tab, results):
self.options = options
compound_action = GetCompoundActionFromPage(page, self._action_name_to_run)
« no previous file with comments | « tools/telemetry/telemetry/page/page_runner_unittest.py ('k') | tools/telemetry/telemetry/page/page_test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698