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

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

Issue 432543003: Add usage message with available page_sets and benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 3 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
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 os 5 import os
6 import sys 6 import sys
7 7
8 from telemetry import benchmark 8 from telemetry import benchmark
9 from telemetry import decorators 9 from telemetry import decorators
10 from telemetry.core import util 10 from telemetry.core import util
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 self.assertEqual(3, len(record_page_test.page_test.func_calls)) 141 self.assertEqual(3, len(record_page_test.page_test.func_calls))
142 self.assertEqual('WillRunActions', record_page_test.page_test.func_calls[0]) 142 self.assertEqual('WillRunActions', record_page_test.page_test.func_calls[0])
143 self.assertEqual('DidRunActions', record_page_test.page_test.func_calls[1]) 143 self.assertEqual('DidRunActions', record_page_test.page_test.func_calls[1])
144 self.assertEqual('ValidatePage', record_page_test.page_test.func_calls[2]) 144 self.assertEqual('ValidatePage', record_page_test.page_test.func_calls[2])
145 145
146 @decorators.Disabled('chromeos') # crbug.com/404868. 146 @decorators.Disabled('chromeos') # crbug.com/404868.
147 def testWprRecorderWithPageSet(self): 147 def testWprRecorderWithPageSet(self):
148 flags = [] 148 flags = []
149 mock_page_set = MockPageSet(url=self._url) 149 mock_page_set = MockPageSet(url=self._url)
150 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, 150 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir,
151 mock_page_set, flags) 151 mock_page_set, 'run', flags)
152 results = wpr_recorder.CreateResults() 152 results = wpr_recorder.CreateResults()
153 wpr_recorder.Record(results) 153 wpr_recorder.Record(results)
154 self.assertEqual(set(mock_page_set.pages), results.pages_that_succeeded) 154 self.assertEqual(set(mock_page_set.pages), results.pages_that_succeeded)
155 155
156 def testWprRecorderWithBenchmark(self): 156 def testWprRecorderWithBenchmark(self):
157 flags = ['--mock-benchmark-url', self._url] 157 flags = ['--mock-benchmark-url', self._url]
158 mock_benchmark = MockBenchmark() 158 mock_benchmark = MockBenchmark()
159 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, mock_benchmark, 159 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, mock_benchmark,
160 flags) 160 'run', flags)
161 results = wpr_recorder.CreateResults() 161 results = wpr_recorder.CreateResults()
162 wpr_recorder.Record(results) 162 wpr_recorder.Record(results)
163 self.assertEqual(set(mock_benchmark.mock_page_set.pages), 163 self.assertEqual(set(mock_benchmark.mock_page_set.pages),
164 results.pages_that_succeeded) 164 results.pages_that_succeeded)
165 165
166 def testCommandLineFlags(self): 166 def testCommandLineFlags(self):
167 flags = [ 167 flags = [
168 '--page-repeat', '2', 168 '--page-repeat', '2',
169 '--mock-benchmark-url', self._url, 169 '--mock-benchmark-url', self._url,
170 '--mock-page-test-option', 170 '--mock-page-test-option',
171 ] 171 ]
172 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, MockBenchmark(), 172 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, MockBenchmark(),
173 flags) 173 'run', flags)
174 # page_runner command-line args 174 # page_runner command-line args
175 self.assertEquals(2, wpr_recorder.options.page_repeat) 175 self.assertEquals(2, wpr_recorder.options.page_repeat)
176 # benchmark command-line args 176 # benchmark command-line args
177 self.assertEquals(self._url, wpr_recorder.options.mock_benchmark_url) 177 self.assertEquals(self._url, wpr_recorder.options.mock_benchmark_url)
178 # benchmark's page_test command-line args 178 # benchmark's page_test command-line args
179 self.assertTrue(wpr_recorder.options.mock_page_test_option) 179 self.assertTrue(wpr_recorder.options.mock_page_test_option)
180 # invalid command-line args 180 # invalid command-line args
181 self.assertFalse(hasattr(wpr_recorder.options, 'not_a_real_option')) 181 self.assertFalse(hasattr(wpr_recorder.options, 'not_a_real_option'))
182 182
183 def testRecordingEnabled(self): 183 def testRecordingEnabled(self):
184 flags = ['--mock-benchmark-url', self._url] 184 flags = ['--mock-benchmark-url', self._url]
185 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, MockBenchmark(), 185 wpr_recorder = record_wpr.WprRecorder(self._test_data_dir, MockBenchmark(),
186 flags) 186 'run', flags)
187 self.assertEqual(wpr_modes.WPR_RECORD, 187 self.assertEqual(wpr_modes.WPR_RECORD,
188 wpr_recorder.options.browser_options.wpr_mode) 188 wpr_recorder.options.browser_options.wpr_mode)
189 189
190 def testFindAllActionNames(self): 190 def testFindAllActionNames(self):
191 # The src/tools/telemetry/unittest_data/page_tests/ has been 191 # The src/tools/telemetry/unittest_data/page_tests/ has been
192 # populated with three simple Page Measurement classes, the first two of 192 # populated with three simple Page Measurement classes, the first two of
193 # which have action_name_to_run defined. 193 # which have action_name_to_run defined.
194 action_names_to_run = record_wpr.FindAllActionNames(self._test_data_dir) 194 action_names_to_run = record_wpr.FindAllActionNames(self._test_data_dir)
195 self.assertTrue('RunFoo' in action_names_to_run) 195 self.assertTrue('RunFoo' in action_names_to_run)
196 self.assertTrue('RunBar' in action_names_to_run) 196 self.assertTrue('RunBar' in action_names_to_run)
197 self.assertFalse('RunBaz' in action_names_to_run) 197 self.assertFalse('RunBaz' in action_names_to_run)
198 198
199 # When the RecorderPageTest WillStartBrowser/DidStartBrowser function is 199 # When the RecorderPageTest WillStartBrowser/DidStartBrowser function is
200 # called, it forwards the call to the PageTest 200 # called, it forwards the call to the PageTest
201 def testRecorderPageTest_BrowserMethods(self): 201 def testRecorderPageTest_BrowserMethods(self):
202 record_page_test = record_wpr.RecorderPageTest([]) 202 record_page_test = record_wpr.RecorderPageTest([])
203 record_page_test.page_test = MockBenchmark().test() 203 record_page_test.page_test = MockBenchmark().test()
204 record_page_test.WillStartBrowser(self._tab.browser) 204 record_page_test.WillStartBrowser(self._tab.browser)
205 record_page_test.DidStartBrowser(self._tab.browser) 205 record_page_test.DidStartBrowser(self._tab.browser)
206 self.assertTrue('WillStartBrowser' in record_page_test.page_test.func_calls) 206 self.assertTrue('WillStartBrowser' in record_page_test.page_test.func_calls)
207 self.assertTrue('DidStartBrowser' in record_page_test.page_test.func_calls) 207 self.assertTrue('DidStartBrowser' in record_page_test.page_test.func_calls)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698