OLD | NEW |
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.core import util | 9 from telemetry.core import util |
10 from telemetry.core import wpr_modes | 10 from telemetry.core import wpr_modes |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 def WillRunActions(self, page, tab): | 61 def WillRunActions(self, page, tab): |
62 self.func_calls.append('WillRunActions') | 62 self.func_calls.append('WillRunActions') |
63 | 63 |
64 def DidRunActions(self, page, tab): | 64 def DidRunActions(self, page, tab): |
65 self.func_calls.append('DidRunActions') | 65 self.func_calls.append('DidRunActions') |
66 | 66 |
67 def ValidatePage(self, page, tab, results): | 67 def ValidatePage(self, page, tab, results): |
68 self.func_calls.append('ValidatePage') | 68 self.func_calls.append('ValidatePage') |
69 | 69 |
| 70 def WillStartBrowser(self, browser): |
| 71 self.func_calls.append('WillStartBrowser') |
| 72 |
| 73 def DidStartBrowser(self, browser): |
| 74 self.func_calls.append('DidStartBrowser') |
70 | 75 |
71 class MockBenchmark(benchmark.Benchmark): | 76 class MockBenchmark(benchmark.Benchmark): |
72 test = MockPageTest | 77 test = MockPageTest |
73 mock_page_set = None | 78 mock_page_set = None |
74 | 79 |
75 @classmethod | 80 @classmethod |
76 def AddTestCommandLineArgs(cls, group): | 81 def AddTestCommandLineArgs(cls, group): |
77 group.add_option('', '--mock-benchmark-url', action='store', type='string') | 82 group.add_option('', '--mock-benchmark-url', action='store', type='string') |
78 | 83 |
79 def CreatePageSet(self, options): | 84 def CreatePageSet(self, options): |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 wpr_recorder.options.browser_options.wpr_mode) | 186 wpr_recorder.options.browser_options.wpr_mode) |
182 | 187 |
183 def testFindAllActionNames(self): | 188 def testFindAllActionNames(self): |
184 # The src/tools/telemetry/unittest_data/page_measurements/ has been | 189 # The src/tools/telemetry/unittest_data/page_measurements/ has been |
185 # populated with three simple Page Measurement classes, the first two of | 190 # populated with three simple Page Measurement classes, the first two of |
186 # which have action_name_to_run defined. | 191 # which have action_name_to_run defined. |
187 action_names_to_run = record_wpr.FindAllActionNames(self._test_data_dir) | 192 action_names_to_run = record_wpr.FindAllActionNames(self._test_data_dir) |
188 self.assertTrue('RunFoo' in action_names_to_run) | 193 self.assertTrue('RunFoo' in action_names_to_run) |
189 self.assertTrue('RunBar' in action_names_to_run) | 194 self.assertTrue('RunBar' in action_names_to_run) |
190 self.assertFalse('RunBaz' in action_names_to_run) | 195 self.assertFalse('RunBaz' in action_names_to_run) |
| 196 |
| 197 # When the RecorderPageTest WillStartBrowser/DidStartBrowser function is |
| 198 # called, it forwards the call to the PageTest |
| 199 def testRecorderPageTest_BrowserMethods(self): |
| 200 record_page_test = record_wpr.RecorderPageTest([]) |
| 201 record_page_test.page_test = MockBenchmark().test() |
| 202 record_page_test.WillStartBrowser(self._tab.browser) |
| 203 record_page_test.DidStartBrowser(self._tab.browser) |
| 204 self.assertTrue('WillStartBrowser' in record_page_test.page_test.func_calls) |
| 205 self.assertTrue('DidStartBrowser' in record_page_test.page_test.func_calls) |
OLD | NEW |