| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 logging | 5 import logging |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import shutil | 8 import shutil |
| 9 import sys | 9 import sys |
| 10 import zipfile | 10 import zipfile |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 A test packages a PageTest/PageMeasurement and a PageSet together. | 31 A test packages a PageTest/PageMeasurement and a PageSet together. |
| 32 """ | 32 """ |
| 33 options = {} | 33 options = {} |
| 34 | 34 |
| 35 @classmethod | 35 @classmethod |
| 36 def Name(cls): | 36 def Name(cls): |
| 37 name = cls.__module__.split('.')[-1] | 37 name = cls.__module__.split('.')[-1] |
| 38 if hasattr(cls, 'tag'): | 38 if hasattr(cls, 'tag'): |
| 39 name += '.' + cls.tag | 39 name += '.' + cls.tag |
| 40 if hasattr(cls, 'page_set'): | 40 if hasattr(cls, 'page_set'): |
| 41 if isinstance(cls.page_set, basestring): | 41 name += '.' + cls.page_set.Name() |
| 42 # TODO(dtu): Remove this code path after crbug.com/362293. | |
| 43 name += '.' + os.path.basename(os.path.splitext(cls.page_set)[0]) | |
| 44 else: | |
| 45 name += '.' + cls.page_set.Name() | |
| 46 return name | 42 return name |
| 47 | 43 |
| 48 @classmethod | 44 @classmethod |
| 49 def AddCommandLineArgs(cls, parser): | 45 def AddCommandLineArgs(cls, parser): |
| 50 cls.PageTestClass().AddCommandLineArgs(parser) | 46 cls.PageTestClass().AddCommandLineArgs(parser) |
| 51 | 47 |
| 52 if hasattr(cls, 'AddTestCommandLineArgs'): | 48 if hasattr(cls, 'AddTestCommandLineArgs'): |
| 53 group = optparse.OptionGroup(parser, '%s test options' % cls.Name()) | 49 group = optparse.OptionGroup(parser, '%s test options' % cls.Name()) |
| 54 cls.AddTestCommandLineArgs(group) | 50 cls.AddTestCommandLineArgs(group) |
| 55 parser.add_option_group(group) | 51 parser.add_option_group(group) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 raise TypeError('"%s" is not a PageSet.' % cls.page_set.__name__) | 175 raise TypeError('"%s" is not a PageSet.' % cls.page_set.__name__) |
| 180 return cls.page_set | 176 return cls.page_set |
| 181 | 177 |
| 182 @classmethod | 178 @classmethod |
| 183 def CreatePageSet(cls, options): # pylint: disable=W0613 | 179 def CreatePageSet(cls, options): # pylint: disable=W0613 |
| 184 """Get the page set this test will run on. | 180 """Get the page set this test will run on. |
| 185 | 181 |
| 186 By default, it will create a page set from the file at this test's | 182 By default, it will create a page set from the file at this test's |
| 187 page_set attribute. Override to generate a custom page set. | 183 page_set attribute. Override to generate a custom page set. |
| 188 """ | 184 """ |
| 189 if not hasattr(cls, 'page_set'): | 185 return cls.PageSetClass()() |
| 190 raise NotImplementedError('This test has no "page_set" attribute.') | |
| 191 if isinstance(cls.page_set, basestring): | |
| 192 # TODO(dtu): Remove this code path after crbug.com/362293. | |
| 193 return page_set.PageSet.FromFile( | |
| 194 file_path=os.path.join(util.GetBaseDir(), cls.page_set)) | |
| 195 else: | |
| 196 return cls.PageSetClass()() | |
| 197 | 186 |
| 198 @classmethod | 187 @classmethod |
| 199 def CreateExpectations(cls, ps): # pylint: disable=W0613 | 188 def CreateExpectations(cls, ps): # pylint: disable=W0613 |
| 200 """Get the expectations this test will run with. | 189 """Get the expectations this test will run with. |
| 201 | 190 |
| 202 By default, it will create an empty expectations set. Override to generate | 191 By default, it will create an empty expectations set. Override to generate |
| 203 custom expectations. | 192 custom expectations. |
| 204 """ | 193 """ |
| 205 if hasattr(cls, 'expectations'): | 194 if hasattr(cls, 'expectations'): |
| 206 return cls.expectations | 195 return cls.expectations |
| 207 else: | 196 else: |
| 208 return test_expectations.TestExpectations() | 197 return test_expectations.TestExpectations() |
| 209 | 198 |
| 210 | 199 |
| 211 def AddCommandLineArgs(parser): | 200 def AddCommandLineArgs(parser): |
| 212 page_runner.AddCommandLineArgs(parser) | 201 page_runner.AddCommandLineArgs(parser) |
| 213 | 202 |
| 214 | 203 |
| 215 def ProcessCommandLineArgs(parser, args): | 204 def ProcessCommandLineArgs(parser, args): |
| 216 page_runner.ProcessCommandLineArgs(parser, args) | 205 page_runner.ProcessCommandLineArgs(parser, args) |
| OLD | NEW |