Index: tools/telemetry/telemetry/benchmark.py |
diff --git a/tools/telemetry/telemetry/benchmark.py b/tools/telemetry/telemetry/benchmark.py |
index 3c20e1cd99de65c8d71c90e14c5da87107819bc6..7763ede0d2d0df0626f51bbc68da55d7e3c0dd07 100644 |
--- a/tools/telemetry/telemetry/benchmark.py |
+++ b/tools/telemetry/telemetry/benchmark.py |
@@ -55,16 +55,13 @@ class Benchmark(command_line.Command): |
@classmethod |
def AddCommandLineArgs(cls, parser): |
- cls.PageTestClass().AddCommandLineArgs(parser) |
- |
- if hasattr(cls, 'AddTestCommandLineArgs'): |
+ if hasattr(cls, 'AddBenchmarkCommandLineArgs'): |
group = optparse.OptionGroup(parser, '%s test options' % cls.Name()) |
- cls.AddTestCommandLineArgs(group) |
+ cls.AddBenchmarkCommandLineArgs(group) |
parser.add_option_group(group) |
@classmethod |
def SetArgumentDefaults(cls, parser): |
- cls.PageTestClass().SetArgumentDefaults(parser) |
default_values = parser.get_default_values() |
invalid_options = [ |
o for o in cls.options if not hasattr(default_values, o)] |
@@ -75,7 +72,7 @@ class Benchmark(command_line.Command): |
@classmethod |
def ProcessCommandLineArgs(cls, parser, args): |
- cls.PageTestClass().ProcessCommandLineArgs(parser, args) |
+ pass |
def CustomizeBrowserOptions(self, options): |
"""Add browser options that are required by this benchmark.""" |
@@ -87,7 +84,7 @@ class Benchmark(command_line.Command): |
"""Run this test with the given options.""" |
self.CustomizeBrowserOptions(finder_options.browser_options) |
- pt = self.PageTestClass()() |
+ pt = self.CreatePageTest(finder_options) |
pt.__name__ = self.__class__.__name__ |
if hasattr(self, '_disabled_strings'): |
@@ -178,17 +175,17 @@ class Benchmark(command_line.Command): |
extracted_profile_dir_path) |
options.browser_options.profile_dir = extracted_profile_dir_path |
- @classmethod |
- def PageTestClass(cls): |
+ def CreatePageTest(self, options): # pylint: disable=W0613 |
"""Get the PageTest for this Benchmark. |
- If the Benchmark has no PageTest, raises NotImplementedError. |
+ By default, it will create a page test from the test's test attribute. |
+ Override to generate a custom page test. |
""" |
- if not hasattr(cls, 'test'): |
+ if not hasattr(self, 'test'): |
raise NotImplementedError('This test has no "test" attribute.') |
- if not issubclass(cls.test, page_test.PageTest): |
- raise TypeError('"%s" is not a PageTest.' % cls.test.__name__) |
- return cls.test |
+ if not issubclass(self.test, page_test.PageTest): |
+ raise TypeError('"%s" is not a PageTest.' % self.test.__name__) |
+ return self.test() |
def CreatePageSet(self, options): # pylint: disable=W0613 |
"""Get the page set this test will run on. |