OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2012 The Chromium Authors. All rights reserved. | 2 # Copyright 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 import logging | 5 import logging |
6 import sys | 6 import sys |
7 import time | 7 import time |
8 | 8 |
9 from telemetry import benchmark | 9 from telemetry import benchmark |
10 from telemetry.core import browser_options | 10 from telemetry.core import browser_options |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class RecorderPageTest(page_test.PageTest): # pylint: disable=W0223 | 22 class RecorderPageTest(page_test.PageTest): # pylint: disable=W0223 |
23 def __init__(self, action_names): | 23 def __init__(self, action_names): |
24 super(RecorderPageTest, self).__init__() | 24 super(RecorderPageTest, self).__init__() |
25 self._action_names = action_names | 25 self._action_names = action_names |
26 self.page_test = None | 26 self.page_test = None |
27 | 27 |
28 def CanRunForPage(self, page): | 28 def CanRunForPage(self, page): |
29 return page.url.startswith('http') | 29 return page.url.startswith('http') |
30 | 30 |
| 31 def WillStartBrowser(self, browser): |
| 32 if self.page_test: |
| 33 self.page_test.WillStartBrowser(browser) |
| 34 |
| 35 def DidStartBrowser(self, browser): |
| 36 if self.page_test: |
| 37 self.page_test.DidStartBrowser(browser) |
| 38 |
31 def WillNavigateToPage(self, page, tab): | 39 def WillNavigateToPage(self, page, tab): |
32 """Override to ensure all resources are fetched from network.""" | 40 """Override to ensure all resources are fetched from network.""" |
33 tab.ClearCache(force=False) | 41 tab.ClearCache(force=False) |
34 if self.page_test: | 42 if self.page_test: |
35 self.page_test.options = self.options | 43 self.page_test.options = self.options |
36 self.page_test.WillNavigateToPage(page, tab) | 44 self.page_test.WillNavigateToPage(page, tab) |
37 | 45 |
38 def DidNavigateToPage(self, page, tab): | 46 def DidNavigateToPage(self, page, tab): |
39 if self.page_test: | 47 if self.page_test: |
40 self.page_test.DidNavigateToPage(page, tab) | 48 self.page_test.DidNavigateToPage(page, tab) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 def Main(base_dir): | 189 def Main(base_dir): |
182 quick_args = [a for a in sys.argv[1:] if not a.startswith('-')] | 190 quick_args = [a for a in sys.argv[1:] if not a.startswith('-')] |
183 if len(quick_args) != 1: | 191 if len(quick_args) != 1: |
184 print >> sys.stderr, 'Usage: record_wpr <PageSet|Benchmark>\n' | 192 print >> sys.stderr, 'Usage: record_wpr <PageSet|Benchmark>\n' |
185 sys.exit(1) | 193 sys.exit(1) |
186 target = quick_args.pop() | 194 target = quick_args.pop() |
187 wpr_recorder = WprRecorder(base_dir, target) | 195 wpr_recorder = WprRecorder(base_dir, target) |
188 results = wpr_recorder.Record() | 196 results = wpr_recorder.Record() |
189 wpr_recorder.HandleResults(results) | 197 wpr_recorder.HandleResults(results) |
190 return min(255, len(results.failures)) | 198 return min(255, len(results.failures)) |
OLD | NEW |