| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 from telemetry.core import repeat_options | 7 from telemetry.core import repeat_options |
| 8 from telemetry.core import util | 8 from telemetry.core import util |
| 9 from telemetry.page import page_runner | 9 from telemetry.page import page_runner |
| 10 from telemetry.page import page_set | 10 from telemetry.page import page_set |
| 11 from telemetry.page import page_test | 11 from telemetry.page import page_test |
| 12 from telemetry.page import test_expectations | 12 from telemetry.page import test_expectations |
| 13 | 13 |
| 14 | 14 |
| 15 class Test(object): | 15 class Test(object): |
| 16 """Base class for a Telemetry test or benchmark. | 16 """Base class for a Telemetry test or benchmark. |
| 17 | 17 |
| 18 A test packages a PageTest/PageMeasurement and a PageSet together. | 18 A test packages a PageTest/PageMeasurement and a PageSet together. |
| 19 """ | 19 """ |
| 20 options = {} | 20 options = {} |
| 21 enabled = True | 21 enabled = True |
| 22 | 22 |
| 23 @classmethod |
| 24 def GetName(cls): |
| 25 name = cls.__module__.split('.')[-1] |
| 26 if hasattr(cls, 'name'): |
| 27 name += '.' + cls.name |
| 28 elif hasattr(cls, 'page_set'): |
| 29 name += '.' + os.path.basename(os.path.splitext(cls.page_set)[0]) |
| 30 return name |
| 31 |
| 23 def Run(self, options): | 32 def Run(self, options): |
| 24 """Run this test with the given options.""" | 33 """Run this test with the given options.""" |
| 25 assert hasattr(self, 'test'), 'This test has no "test" attribute.' | 34 assert hasattr(self, 'test'), 'This test has no "test" attribute.' |
| 26 assert issubclass(self.test, page_test.PageTest), ( | 35 assert issubclass(self.test, page_test.PageTest), ( |
| 27 '"%s" is not a PageTest.' % self.test.__name__) | 36 '"%s" is not a PageTest.' % self.test.__name__) |
| 28 | 37 |
| 29 for key, value in self.options.iteritems(): | 38 for key, value in self.options.iteritems(): |
| 30 setattr(options, key, value) | 39 setattr(options, key, value) |
| 31 | 40 |
| 32 options.repeat_options = self._CreateRepeatOptions(options) | 41 options.repeat_options = self._CreateRepeatOptions(options) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 custom expectations. | 78 custom expectations. |
| 70 """ | 79 """ |
| 71 if hasattr(self, 'expectations'): | 80 if hasattr(self, 'expectations'): |
| 72 return self.expectations | 81 return self.expectations |
| 73 else: | 82 else: |
| 74 return test_expectations.TestExpectations() | 83 return test_expectations.TestExpectations() |
| 75 | 84 |
| 76 @staticmethod | 85 @staticmethod |
| 77 def AddCommandLineOptions(parser): | 86 def AddCommandLineOptions(parser): |
| 78 page_runner.AddCommandLineOptions(parser) | 87 page_runner.AddCommandLineOptions(parser) |
| OLD | NEW |