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

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

Issue 737403002: Revert of telemetry: Remove command line args from page test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « tools/telemetry/telemetry/benchmark.py ('k') | tools/telemetry/telemetry/page/page_test_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 081ea9884cee6838cc335843bf2e1c508c2a9531..478f4a2ba2d0cea964f6718e9c6dc2e22716639d 100644
--- a/tools/telemetry/telemetry/page/page_test.py
+++ b/tools/telemetry/telemetry/page/page_test.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from telemetry.core import command_line
from telemetry.page import test_expectations
from telemetry.page.actions import action_runner as action_runner_module
@@ -22,7 +23,7 @@
designed-for problem."""
-class PageTest(object):
+class PageTest(command_line.Command):
"""A class styled on unittest.TestCase for creating page-specific tests.
Test should override ValidateAndMeasurePage to perform test
@@ -34,6 +35,19 @@
'document.body.children.length')
results.AddValue(scalar.ScalarValue(
page, 'body_children', 'count', body_child_count))
+
+ The class also provide hooks to add test-specific options. Here is
+ an example:
+
+ class BodyChildElementMeasurement(PageTest):
+ def AddCommandLineArgs(parser):
+ parser.add_option('--element', action='store', default='body')
+
+ def ValidateAndMeasurePage(self, page, tab, results):
+ body_child_count = tab.EvaluateJavaScript(
+ 'document.querySelector('%s').children.length')
+ results.AddValue(scalar.ScalarValue(
+ page, 'children', 'count', child_count))
Args:
action_name_to_run: This is the method name in telemetry.page.Page
@@ -48,6 +62,8 @@
is_action_name_to_run_optional is True, otherwise the page
will fail.
"""
+
+ options = {}
def __init__(self,
action_name_to_run='',
@@ -82,6 +98,10 @@
# _exit_requested is set to true when the test requests an early exit.
self._exit_requested = False
+ @classmethod
+ def SetArgumentDefaults(cls, parser):
+ parser.set_defaults(**cls.options)
+
@property
def discard_first_result(self):
"""When set to True, the first run of the test is discarded. This is
@@ -117,6 +137,11 @@
@max_failures.setter
def max_failures(self, count):
self._max_failures = count
+
+ def Run(self, args):
+ # Define this method to avoid pylint errors.
+ # TODO(dtu): Make this actually run the test with args.page_set.
+ pass
def RestartBrowserBeforeEachPage(self):
""" Should the browser be restarted for the page?
« no previous file with comments | « tools/telemetry/telemetry/benchmark.py ('k') | tools/telemetry/telemetry/page/page_test_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698