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

Side by Side Diff: tools/telemetry/telemetry/page/multi_page_benchmark_unittest.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 json 4 import json
5 import os 5 import os
6 6
7 from telemetry import multi_page_benchmark 7 from telemetry.core import wpr_modes
8 from telemetry import multi_page_benchmark_unittest_base 8 from telemetry.page import multi_page_benchmark
9 from telemetry import options_for_unittests 9 from telemetry.page import multi_page_benchmark_unittest_base
10 from telemetry import page as page_module 10 from telemetry.page import page as page_module
11 from telemetry import page_action 11 from telemetry.page import page_action
12 from telemetry import page_set 12 from telemetry.page import page_set
13 from telemetry import page_set_archive_info 13 from telemetry.page import page_set_archive_info
14 from telemetry import wpr_modes 14 from telemetry.test import options_for_unittests
15 15
16 class BenchThatFails(multi_page_benchmark.MultiPageBenchmark): 16 class BenchThatFails(multi_page_benchmark.MultiPageBenchmark):
17 def MeasurePage(self, page, tab, results): 17 def MeasurePage(self, page, tab, results):
18 raise multi_page_benchmark.MeasurementFailure('Intentional failure.') 18 raise multi_page_benchmark.MeasurementFailure('Intentional failure.')
19 19
20 class BenchThatHasDefaults(multi_page_benchmark.MultiPageBenchmark): 20 class BenchThatHasDefaults(multi_page_benchmark.MultiPageBenchmark):
21 def AddCommandLineOptions(self, parser): 21 def AddCommandLineOptions(self, parser):
22 parser.add_option('-x', dest='x', default=3) 22 parser.add_option('-x', dest='x', default=3)
23 23
24 def MeasurePage(self, page, tab, results): 24 def MeasurePage(self, page, tab, results):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 self._options = options_for_unittests.GetCopy() 56 self._options = options_for_unittests.GetCopy()
57 self._options.wpr_mode = wpr_modes.WPR_OFF 57 self._options.wpr_mode = wpr_modes.WPR_OFF
58 58
59 def testGotToBlank(self): 59 def testGotToBlank(self):
60 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html') 60 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
61 benchmark = BenchForBlank() 61 benchmark = BenchForBlank()
62 all_results = self.RunBenchmark(benchmark, ps, options=self._options) 62 all_results = self.RunBenchmark(benchmark, ps, options=self._options)
63 self.assertEquals(0, len(all_results.page_failures)) 63 self.assertEquals(0, len(all_results.page_failures))
64 64
65 def testGotQueryParams(self): 65 def testGotQueryParams(self):
66 ps = self.CreatePageSet('file:///../unittest_data/blank.html?foo=1') 66 ps = self.CreatePageSet('file:///../../unittest_data/blank.html?foo=1')
67 benchmark = BenchQueryParams() 67 benchmark = BenchQueryParams()
68 ps.pages[-1].query_params = '?foo=1' 68 ps.pages[-1].query_params = '?foo=1'
69 all_results = self.RunBenchmark(benchmark, ps, options=self._options) 69 all_results = self.RunBenchmark(benchmark, ps, options=self._options)
70 self.assertEquals(0, len(all_results.page_failures)) 70 self.assertEquals(0, len(all_results.page_failures))
71 71
72 def testFailure(self): 72 def testFailure(self):
73 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html') 73 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
74 benchmark = BenchThatFails() 74 benchmark = BenchThatFails()
75 all_results = self.RunBenchmark(benchmark, ps, options=self._options) 75 all_results = self.RunBenchmark(benchmark, ps, options=self._options)
76 self.assertEquals(1, len(all_results.page_failures)) 76 self.assertEquals(1, len(all_results.page_failures))
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 finally: 129 finally:
130 if os.path.isfile(test_archive): 130 if os.path.isfile(test_archive):
131 os.remove(test_archive) 131 os.remove(test_archive)
132 132
133 def testActions(self): 133 def testActions(self):
134 action_called = [False] 134 action_called = [False]
135 class MockAction(page_action.PageAction): 135 class MockAction(page_action.PageAction):
136 def RunAction(self, page, tab, previous_action): 136 def RunAction(self, page, tab, previous_action):
137 action_called[0] = True 137 action_called[0] = True
138 from telemetry import all_page_actions 138 from telemetry.page import all_page_actions
139 all_page_actions.RegisterClassForTest('mock', MockAction) 139 all_page_actions.RegisterClassForTest('mock', MockAction)
140 140
141 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html') 141 ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
142 setattr(ps.pages[0], 'test_action', {'action': 'mock'}) 142 setattr(ps.pages[0], 'test_action', {'action': 'mock'})
143 benchmark = BenchWithAction() 143 benchmark = BenchWithAction()
144 self.RunBenchmark(benchmark, ps, options=self._options) 144 self.RunBenchmark(benchmark, ps, options=self._options)
145 self.assertTrue(action_called[0]) 145 self.assertTrue(action_called[0])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698