| 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 21 matching lines...) Expand all Loading... |
| 32 """Override to ensure all resources are fetched from network.""" | 32 """Override to ensure all resources are fetched from network.""" |
| 33 tab.ClearCache(force=False) | 33 tab.ClearCache(force=False) |
| 34 if self.page_test: | 34 if self.page_test: |
| 35 self.page_test.options = self.options | 35 self.page_test.options = self.options |
| 36 self.page_test.WillNavigateToPage(page, tab) | 36 self.page_test.WillNavigateToPage(page, tab) |
| 37 | 37 |
| 38 def DidNavigateToPage(self, page, tab): | 38 def DidNavigateToPage(self, page, tab): |
| 39 if self.page_test: | 39 if self.page_test: |
| 40 self.page_test.DidNavigateToPage(page, tab) | 40 self.page_test.DidNavigateToPage(page, tab) |
| 41 | 41 |
| 42 def WillStartBrowser(self, browser): |
| 43 if self.page_test: |
| 44 self.page_test.WillStartBrowser(browser) |
| 45 |
| 46 def DidStartBrowser(self, browser): |
| 47 if self.page_test: |
| 48 self.page_test.DidStartBrowser(browser) |
| 49 |
| 42 def WillRunActions(self, page, tab): | 50 def WillRunActions(self, page, tab): |
| 43 if self.page_test: | 51 if self.page_test: |
| 44 self.page_test.WillRunActions(page, tab) | 52 self.page_test.WillRunActions(page, tab) |
| 45 | 53 |
| 46 def DidRunActions(self, page, tab): | 54 def DidRunActions(self, page, tab): |
| 47 if self.page_test: | 55 if self.page_test: |
| 48 self.page_test.DidRunActions(page, tab) | 56 self.page_test.DidRunActions(page, tab) |
| 49 | 57 |
| 50 def ValidatePage(self, page, tab, results): | 58 def ValidatePage(self, page, tab, results): |
| 51 if self.page_test: | 59 if self.page_test: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 self._parser = self._options.CreateParser(usage='%prog <PageSet|Benchmark>') | 134 self._parser = self._options.CreateParser(usage='%prog <PageSet|Benchmark>') |
| 127 self._AddCommandLineArgs() | 135 self._AddCommandLineArgs() |
| 128 self._ParseArgs(args) | 136 self._ParseArgs(args) |
| 129 self._ProcessCommandLineArgs() | 137 self._ProcessCommandLineArgs() |
| 130 self._page_set = self._GetPageSet(base_dir, target) | 138 self._page_set = self._GetPageSet(base_dir, target) |
| 131 | 139 |
| 132 @property | 140 @property |
| 133 def options(self): | 141 def options(self): |
| 134 return self._options | 142 return self._options |
| 135 | 143 |
| 144 @property |
| 145 def page_test(self): |
| 146 return self._record_page_test.page_test if self._benchmark else None |
| 147 |
| 136 def _CreateOptions(self): | 148 def _CreateOptions(self): |
| 137 options = browser_options.BrowserFinderOptions() | 149 options = browser_options.BrowserFinderOptions() |
| 138 options.browser_options.wpr_mode = wpr_modes.WPR_RECORD | 150 options.browser_options.wpr_mode = wpr_modes.WPR_RECORD |
| 139 options.browser_options.no_proxy_server = True | 151 options.browser_options.no_proxy_server = True |
| 140 return options | 152 return options |
| 141 | 153 |
| 142 def _AddCommandLineArgs(self): | 154 def _AddCommandLineArgs(self): |
| 143 page_runner.AddCommandLineArgs(self._parser) | 155 page_runner.AddCommandLineArgs(self._parser) |
| 144 if self._benchmark is not None: | 156 if self._benchmark is not None: |
| 145 self._benchmark.AddCommandLineArgs(self._parser) | 157 self._benchmark.AddCommandLineArgs(self._parser) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 def Main(base_dir): | 192 def Main(base_dir): |
| 181 quick_args = [a for a in sys.argv[1:] if not a.startswith('-')] | 193 quick_args = [a for a in sys.argv[1:] if not a.startswith('-')] |
| 182 if len(quick_args) != 1: | 194 if len(quick_args) != 1: |
| 183 print >> sys.stderr, 'Usage: record_wpr <PageSet|Benchmark>\n' | 195 print >> sys.stderr, 'Usage: record_wpr <PageSet|Benchmark>\n' |
| 184 sys.exit(1) | 196 sys.exit(1) |
| 185 target = quick_args.pop() | 197 target = quick_args.pop() |
| 186 wpr_recorder = WprRecorder(base_dir, target) | 198 wpr_recorder = WprRecorder(base_dir, target) |
| 187 results = wpr_recorder.Record() | 199 results = wpr_recorder.Record() |
| 188 wpr_recorder.HandleResults(results) | 200 wpr_recorder.HandleResults(results) |
| 189 return min(255, len(results.failures)) | 201 return min(255, len(results.failures)) |
| OLD | NEW |