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

Side by Side Diff: content/test/gpu/gpu_tests/gpu_test_base_unittest.py

Issue 1263063003: Revert of Create classes_util API, change discover to return a list instead of a dict. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/test/gpu/page_sets/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import benchmark 7 from telemetry import benchmark
8 from telemetry.core import discover
8 from telemetry.core import util 9 from telemetry.core import util
9 from telemetry.story import story_set as story_set_module 10 from telemetry.story import story_set as story_set_module
10 from telemetry.testing import fakes 11 from telemetry.testing import fakes
11 from telemetry.util import classes_util
12 12
13 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') 13 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock')
14 import mock # pylint: disable=import-error 14 import mock # pylint: disable=import-error
15 15
16 import gpu_test_base 16 import gpu_test_base
17 17
18 def _GetGpuDir(*subdirs): 18 def _GetGpuDir(*subdirs):
19 gpu_dir = os.path.dirname(os.path.dirname(__file__)) 19 gpu_dir = os.path.dirname(os.path.dirname(__file__))
20 return os.path.join(gpu_dir, *subdirs) 20 return os.path.join(gpu_dir, *subdirs)
21 21
22 # Unit tests verifying invariants of classes in GpuTestBase. 22 # Unit tests verifying invariants of classes in GpuTestBase.
23 23
24 class NoOverridesTest(unittest.TestCase): 24 class NoOverridesTest(unittest.TestCase):
25 def testValidatorBase(self): 25 def testValidatorBase(self):
26 all_validators = classes_util.DiscoverClasses( 26 all_validators = discover.DiscoverClasses(
27 _GetGpuDir('gpu_tests'), _GetGpuDir(), gpu_test_base.ValidatorBase) 27 _GetGpuDir('gpu_tests'), _GetGpuDir(),
28 gpu_test_base.ValidatorBase,
29 index_by_class_name=True).values()
28 self.assertGreater(len(all_validators), 0) 30 self.assertGreater(len(all_validators), 0)
29 for validator in all_validators: 31 for validator in all_validators:
30 self.assertEquals(gpu_test_base.ValidatorBase.ValidateAndMeasurePage, 32 self.assertEquals(gpu_test_base.ValidatorBase.ValidateAndMeasurePage,
31 validator.ValidateAndMeasurePage, 33 validator.ValidateAndMeasurePage,
32 'Class %s should not override ValidateAndMeasurePage' 34 'Class %s should not override ValidateAndMeasurePage'
33 % validator.__name__) 35 % validator.__name__)
34 36
35 def testPageBase(self): 37 def testPageBase(self):
36 all_pages = classes_util.DiscoverClasses( 38 all_pages = discover.DiscoverClasses(
37 _GetGpuDir(), _GetGpuDir(), gpu_test_base.PageBase) 39 _GetGpuDir(), _GetGpuDir(),
40 gpu_test_base.PageBase,
41 index_by_class_name=True).values()
38 self.assertGreater(len(all_pages), 0) 42 self.assertGreater(len(all_pages), 0)
39 for page in all_pages: 43 for page in all_pages:
40 self.assertEquals(gpu_test_base.PageBase.RunNavigateSteps, 44 self.assertEquals(gpu_test_base.PageBase.RunNavigateSteps,
41 page.RunNavigateSteps, 45 page.RunNavigateSteps,
42 'Class %s should not override ValidateAndMeasurePage' 46 'Class %s should not override ValidateAndMeasurePage'
43 % page.__name__) 47 % page.__name__)
44 self.assertEquals(gpu_test_base.PageBase.RunPageInteractions, 48 self.assertEquals(gpu_test_base.PageBase.RunPageInteractions,
45 page.RunPageInteractions, 49 page.RunPageInteractions,
46 'Class %s should not override RunPageInteractions' 50 'Class %s should not override RunPageInteractions'
47 % page.__name__) 51 % page.__name__)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 test.validator.ValidateAndMeasurePageInner = ( 175 test.validator.ValidateAndMeasurePageInner = (
172 manager.validator.ValidateAndMeasurePageInner) 176 manager.validator.ValidateAndMeasurePageInner)
173 test.AddFakePage(page) 177 test.AddFakePage(page)
174 self.assertEqual(test.Run(finder_options), 0, 178 self.assertEqual(test.Run(finder_options), 0,
175 'Test should run with no errors') 179 'Test should run with no errors')
176 expected = [mock.call.page.RunNavigateStepsInner(mock.ANY), 180 expected = [mock.call.page.RunNavigateStepsInner(mock.ANY),
177 mock.call.page.RunPageInteractionsInner(mock.ANY), 181 mock.call.page.RunPageInteractionsInner(mock.ANY),
178 mock.call.validator.ValidateAndMeasurePageInner( 182 mock.call.validator.ValidateAndMeasurePageInner(
179 page, mock.ANY, mock.ANY)] 183 page, mock.ANY, mock.ANY)]
180 self.assertTrue(manager.mock_calls == expected) 184 self.assertTrue(manager.mock_calls == expected)
OLDNEW
« no previous file with comments | « no previous file | content/test/gpu/page_sets/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698