OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 collections | 5 import collections |
6 import logging | 6 import logging |
7 import re | 7 import re |
8 import sys | 8 import sys |
9 import urllib | 9 import urllib |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 def TearDownState(self): | 183 def TearDownState(self): |
184 self.platform.network_controller.Close() | 184 self.platform.network_controller.Close() |
185 | 185 |
186 for browser_type, browser in self._browsers.iteritems(): | 186 for browser_type, browser in self._browsers.iteritems(): |
187 try: | 187 try: |
188 browser.Close() | 188 browser.Close() |
189 except Exception: | 189 except Exception: |
190 logging.exception('Error while closing browser: %s', browser_type) | 190 logging.exception('Error while closing browser: %s', browser_type) |
191 self._browsers = None # Not usable after tearing down. | 191 self._browsers = None # Not usable after tearing down. |
192 | 192 |
| 193 def DumpStateUponFailure(self, unused_story, unused_results): |
| 194 if self._browsers: |
| 195 for browser_type, browser in self._browsers.iteritems(): |
| 196 logging.info('vvvvv BROWSER STATE BELOW FOR \'%s\' vvvvv', browser_type) |
| 197 browser.DumpStateUponFailure() |
| 198 else: |
| 199 logging.warning('Cannot dump browser states: No browsers.') |
| 200 |
193 | 201 |
194 class SinglePage(story_module.Story): | 202 class SinglePage(story_module.Story): |
195 def __init__(self, name, url, browser_type, phase): | 203 def __init__(self, name, url, browser_type, phase): |
196 """A story that associates a particular page with a browser to view it. | 204 """A story that associates a particular page with a browser to view it. |
197 | 205 |
198 Args: | 206 Args: |
199 name: A string with the name of the page as it will appear reported, | 207 name: A string with the name of the page as it will appear reported, |
200 e.g., on results and dashboards. | 208 e.g., on results and dashboards. |
201 url: A string with the url of the page to load. | 209 url: A string with the url of the page to load. |
202 browser_type: A string identifying the browser where this page should be | 210 browser_type: A string identifying the browser where this page should be |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), | 246 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), |
239 browser_type='android-webview', | 247 browser_type='android-webview', |
240 phase='on_webview')) | 248 phase='on_webview')) |
241 | 249 |
242 # Stories that run on the browser selected by command line options. | 250 # Stories that run on the browser selected by command line options. |
243 self.AddStory(SinglePage( | 251 self.AddStory(SinglePage( |
244 name=re.sub('\W+', '_', url), | 252 name=re.sub('\W+', '_', url), |
245 url=url, | 253 url=url, |
246 browser_type='default', | 254 browser_type='default', |
247 phase='on_chrome')) | 255 phase='on_chrome')) |
OLD | NEW |