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

Side by Side Diff: telemetry/telemetry/benchmark_run_unittest.py

Issue 2978643002: Removing bad-continuation param and fixing resulting errors. Fixed indentation errors, in telemetry… (Closed)
Patch Set: Created 3 years, 5 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 | « telemetry/telemetry/benchmark.py ('k') | telemetry/telemetry/benchmark_runner.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 unittest 5 import unittest
6 6
7 from telemetry import benchmark as benchmark_module 7 from telemetry import benchmark as benchmark_module
8 from telemetry import page as page_module 8 from telemetry import page as page_module
9 from telemetry.page import legacy_page_test 9 from telemetry.page import legacy_page_test
10 from telemetry import story as story_module 10 from telemetry import story as story_module
(...skipping 10 matching lines...) Expand all
21 # that its definition is overridden here. 21 # that its definition is overridden here.
22 self.ValidateAndMeasurePage = mock.Mock() 22 self.ValidateAndMeasurePage = mock.Mock()
23 23
24 24
25 # More end-to-end tests of Benchmark, shared_page_state and associated 25 # More end-to-end tests of Benchmark, shared_page_state and associated
26 # classes using telemetry.testing.fakes, to avoid needing to construct 26 # classes using telemetry.testing.fakes, to avoid needing to construct
27 # a real browser instance. 27 # a real browser instance.
28 28
29 class FakePage(page_module.Page): 29 class FakePage(page_module.Page):
30 def __init__(self, page_set): 30 def __init__(self, page_set):
31 super(FakePage, self).__init__( 31 super(FakePage, self).__init__(\
32 url='http://nonexistentserver.com/nonexistentpage.html', 32 url='http://nonexistentserver.com/nonexistentpage.html',
33 name='fake page', 33 name='fake page',
34 page_set=page_set, 34 page_set=page_set,
35 shared_page_state_class=fakes.FakeSharedPageState) 35 shared_page_state_class=fakes.FakeSharedPageState)
36 self.RunNavigateSteps = mock.Mock() 36 self.RunNavigateSteps = mock.Mock()
37 self.RunPageInteractions = mock.Mock() 37 self.RunPageInteractions = mock.Mock()
38 38
39 class FakeBenchmark(benchmark_module.Benchmark): 39 class FakeBenchmark(benchmark_module.Benchmark):
40 def __init__(self, max_failures=None): 40 def __init__(self, max_failures=None):
41 super(FakeBenchmark, self).__init__(max_failures) 41 super(FakeBenchmark, self).__init__(max_failures)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 benchmarkclass.ProcessCommandLineArgs(parser, options) 88 benchmarkclass.ProcessCommandLineArgs(parser, options)
89 benchmark = benchmarkclass() 89 benchmark = benchmarkclass()
90 return benchmark, finder_options 90 return benchmark, finder_options
91 91
92 def testPassingPage(self): 92 def testPassingPage(self):
93 benchmark, finder_options = self.setupBenchmark() 93 benchmark, finder_options = self.setupBenchmark()
94 manager = mock.Mock() 94 manager = mock.Mock()
95 page = FakePage(benchmark.GetFakeStorySet()) 95 page = FakePage(benchmark.GetFakeStorySet())
96 page.RunNavigateSteps = manager.page.RunNavigateSteps 96 page.RunNavigateSteps = manager.page.RunNavigateSteps
97 page.RunPageInteractions = manager.page.RunPageInteractions 97 page.RunPageInteractions = manager.page.RunPageInteractions
98 benchmark.validator.ValidateAndMeasurePage = ( 98 benchmark.validator.ValidateAndMeasurePage = (\
99 manager.validator.ValidateAndMeasurePage) 99 manager.validator.ValidateAndMeasurePage)
100 benchmark.AddFakePage(page) 100 benchmark.AddFakePage(page)
101 self.assertEqual(benchmark.Run(finder_options), 0, 101 self.assertEqual(benchmark.Run(finder_options), 0,
102 'Test should run with no errors') 102 'Test should run with no errors')
103 expected = [mock.call.page.RunNavigateSteps(mock.ANY), 103 expected = [mock.call.page.RunNavigateSteps(mock.ANY),
104 mock.call.page.RunPageInteractions(mock.ANY), 104 mock.call.page.RunPageInteractions(mock.ANY),
105 mock.call.validator.ValidateAndMeasurePage( 105 mock.call.validator.ValidateAndMeasurePage(\
106 page, mock.ANY, mock.ANY)] 106 page, mock.ANY, mock.ANY)]
107 self.assertTrue(manager.mock_calls == expected) 107 self.assertTrue(manager.mock_calls == expected)
108 108
109 109
110 def testFailingPage(self): 110 def testFailingPage(self):
111 benchmark, finder_options = self.setupBenchmark() 111 benchmark, finder_options = self.setupBenchmark()
112 page = FailingPage(benchmark.GetFakeStorySet()) 112 page = FailingPage(benchmark.GetFakeStorySet())
113 benchmark.AddFakePage(page) 113 benchmark.AddFakePage(page)
114 self.assertNotEqual(benchmark.Run(finder_options), 0, 'Test should fail') 114 self.assertNotEqual(benchmark.Run(finder_options), 0, 'Test should fail')
115 self.assertFalse(page.RunPageInteractions.called) 115 self.assertFalse(page.RunPageInteractions.called)
OLDNEW
« no previous file with comments | « telemetry/telemetry/benchmark.py ('k') | telemetry/telemetry/benchmark_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698