| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import os | 4 import os |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from telemetry.core import discover | 7 from telemetry.util import classes_util |
| 8 | 8 |
| 9 import gpu_test_base | 9 import gpu_test_base |
| 10 | 10 |
| 11 def _GetGpuDir(*subdirs): | 11 def _GetGpuDir(*subdirs): |
| 12 gpu_dir = os.path.dirname(os.path.dirname(__file__)) | 12 gpu_dir = os.path.dirname(os.path.dirname(__file__)) |
| 13 return os.path.join(gpu_dir, *subdirs) | 13 return os.path.join(gpu_dir, *subdirs) |
| 14 | 14 |
| 15 # | 15 # |
| 16 # Unit tests verifying invariants of classes in GpuTestBase. | 16 # Unit tests verifying invariants of classes in GpuTestBase. |
| 17 # | 17 # |
| 18 | 18 |
| 19 class NoOverridesTest(unittest.TestCase): | 19 class NoOverridesTest(unittest.TestCase): |
| 20 def testValidatorBase(self): | 20 def testValidatorBase(self): |
| 21 all_validators = discover.DiscoverClasses( | 21 all_validators = classes_util.DiscoverClasses( |
| 22 _GetGpuDir('gpu_tests'), _GetGpuDir(), | 22 _GetGpuDir('gpu_tests'), _GetGpuDir(), gpu_test_base.ValidatorBase) |
| 23 gpu_test_base.ValidatorBase, | |
| 24 index_by_class_name=True).values() | |
| 25 self.assertGreater(len(all_validators), 0) | 23 self.assertGreater(len(all_validators), 0) |
| 26 for validator in all_validators: | 24 for validator in all_validators: |
| 27 self.assertEquals(gpu_test_base.ValidatorBase.ValidateAndMeasurePage, | 25 self.assertEquals(gpu_test_base.ValidatorBase.ValidateAndMeasurePage, |
| 28 validator.ValidateAndMeasurePage, | 26 validator.ValidateAndMeasurePage, |
| 29 'Class %s should not override ValidateAndMeasurePage' | 27 'Class %s should not override ValidateAndMeasurePage' |
| 30 % validator.__name__) | 28 % validator.__name__) |
| 31 | 29 |
| 32 def testPageBase(self): | 30 def testPageBase(self): |
| 33 all_pages = discover.DiscoverClasses( | 31 all_pages = classes_util.DiscoverClasses( |
| 34 _GetGpuDir(), _GetGpuDir(), | 32 _GetGpuDir(), _GetGpuDir(), gpu_test_base.PageBase) |
| 35 gpu_test_base.PageBase, | |
| 36 index_by_class_name=True).values() | |
| 37 self.assertGreater(len(all_pages), 0) | 33 self.assertGreater(len(all_pages), 0) |
| 38 for page in all_pages: | 34 for page in all_pages: |
| 39 self.assertEquals(gpu_test_base.PageBase.RunNavigateSteps, | 35 self.assertEquals(gpu_test_base.PageBase.RunNavigateSteps, |
| 40 page.RunNavigateSteps, | 36 page.RunNavigateSteps, |
| 41 'Class %s should not override ValidateAndMeasurePage' | 37 'Class %s should not override ValidateAndMeasurePage' |
| 42 % page.__name__) | 38 % page.__name__) |
| 43 self.assertEquals(gpu_test_base.PageBase.RunPageInteractions, | 39 self.assertEquals(gpu_test_base.PageBase.RunPageInteractions, |
| 44 page.RunPageInteractions, | 40 page.RunPageInteractions, |
| 45 'Class %s should not override RunPageInteractions' | 41 'Class %s should not override RunPageInteractions' |
| 46 % page.__name__) | 42 % page.__name__) |
| OLD | NEW |