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 | |
9 import urllib | 8 import urllib |
10 | 9 |
11 from telemetry import decorators | |
12 from telemetry import story as story_module | 10 from telemetry import story as story_module |
13 # TODO(perezju): Remove references to telementry.internal when | 11 # TODO(perezju): Remove references to telementry.internal when |
14 # https://github.com/catapult-project/catapult/issues/2102 is resolved. | 12 # https://github.com/catapult-project/catapult/issues/2102 is resolved. |
15 from telemetry.internal.browser import browser_finder | 13 from telemetry.internal.browser import browser_finder |
16 from telemetry.internal.browser import browser_finder_exceptions | 14 from telemetry.internal.browser import browser_finder_exceptions |
17 from telemetry.util import wpr_modes | 15 from telemetry.util import wpr_modes |
18 | 16 |
19 from page_sets.top_10_mobile import URL_LIST | 17 from page_sets.top_10_mobile import URL_LIST |
20 | 18 |
21 | 19 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 (s.browser_type, None) for s in story_set) | 69 (s.browser_type, None) for s in story_set) |
72 self._current_story = None | 70 self._current_story = None |
73 self._current_browser = None | 71 self._current_browser = None |
74 self._current_tab = None | 72 self._current_tab = None |
75 | 73 |
76 possible_browser = self._PrepareBrowser('default', finder_options) | 74 possible_browser = self._PrepareBrowser('default', finder_options) |
77 if not possible_browser: | 75 if not possible_browser: |
78 raise browser_finder_exceptions.BrowserFinderException( | 76 raise browser_finder_exceptions.BrowserFinderException( |
79 'No browser found.\n\nAvailable browsers:\n%s\n' % | 77 'No browser found.\n\nAvailable browsers:\n%s\n' % |
80 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) | 78 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) |
81 if not finder_options.run_disabled_tests: | |
82 self._CheckTestEnabled(test, possible_browser) | |
83 | 79 |
84 extra_browser_types = set(story.browser_type for story in story_set) | 80 extra_browser_types = set(story.browser_type for story in story_set) |
85 extra_browser_types.remove('default') # Must include 'default' browser. | 81 extra_browser_types.remove('default') # Must include 'default' browser. |
86 for browser_type in extra_browser_types: | 82 for browser_type in extra_browser_types: |
87 options = _OptionsForBrowser(browser_type, finder_options) | 83 options = _OptionsForBrowser(browser_type, finder_options) |
88 if not self._PrepareBrowser(browser_type, options): | 84 if not self._PrepareBrowser(browser_type, options): |
89 logging.warning('Skipping %s (%s) because %s browser is not available', | 85 logging.warning('Skipping %s (%s) because %s browser is not available', |
perezju
2016/09/30 13:28:01
nit: Skipping -> Can't run
eyaich1
2016/09/30 13:32:22
Done.
| |
90 test.__name__, str(test), browser_type) | 86 test.__name__, str(test), browser_type) |
91 logging.warning('Install %s to be able to run the test.', browser_type) | 87 logging.warning('Install %s to be able to run the test.', browser_type) |
92 sys.exit(0) | 88 raise Exception("Browser not available, unable to run benchmark.") |
93 | 89 |
94 # TODO(crbug/404771): Move network controller options out of | 90 # TODO(crbug/404771): Move network controller options out of |
95 # browser_options and into finder_options. | 91 # browser_options and into finder_options. |
96 browser_options = finder_options.browser_options | 92 browser_options = finder_options.browser_options |
97 if finder_options.use_live_sites: | 93 if finder_options.use_live_sites: |
98 wpr_mode = wpr_modes.WPR_OFF | 94 wpr_mode = wpr_modes.WPR_OFF |
99 elif browser_options.wpr_mode == wpr_modes.WPR_RECORD: | 95 elif browser_options.wpr_mode == wpr_modes.WPR_RECORD: |
100 wpr_mode = wpr_modes.WPR_RECORD | 96 wpr_mode = wpr_modes.WPR_RECORD |
101 else: | 97 else: |
102 wpr_mode = wpr_modes.WPR_REPLAY | 98 wpr_mode = wpr_modes.WPR_REPLAY |
103 | 99 |
104 self.platform.network_controller.Open(wpr_mode, | 100 self.platform.network_controller.Open(wpr_mode, |
105 browser_options.extra_wpr_args) | 101 browser_options.extra_wpr_args) |
106 | 102 |
107 @property | 103 @property |
108 def current_tab(self): | 104 def current_tab(self): |
109 return self._current_tab | 105 return self._current_tab |
110 | 106 |
111 @property | 107 @property |
112 def platform(self): | 108 def platform(self): |
113 return self._platform | 109 return self._platform |
114 | 110 |
115 def _CheckTestEnabled(self, test, possible_browser): | |
116 should_skip, msg = decorators.ShouldSkip(test, possible_browser) | |
117 if should_skip: | |
118 logging.warning(msg) | |
119 logging.warning('You are trying to run a disabled test.') | |
120 logging.warning( | |
121 'Pass --also-run-disabled-tests to squelch this message.') | |
122 sys.exit(0) | |
123 | |
124 def _PrepareBrowser(self, browser_type, options): | 111 def _PrepareBrowser(self, browser_type, options): |
125 """Add a browser to the dict of possible browsers. | 112 """Add a browser to the dict of possible browsers. |
126 | 113 |
127 TODO(perezju): When available, use the GetBrowserForPlatform API instead. | 114 TODO(perezju): When available, use the GetBrowserForPlatform API instead. |
128 See: crbug.com/570348 | 115 See: crbug.com/570348 |
129 | 116 |
130 Returns: | 117 Returns: |
131 The possible browser if found, or None otherwise. | 118 The possible browser if found, or None otherwise. |
132 """ | 119 """ |
133 possible_browser = browser_finder.FindBrowser(options) | 120 possible_browser = browser_finder.FindBrowser(options) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), | 249 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), |
263 browser_type='android-webview', | 250 browser_type='android-webview', |
264 phase='on_webview')) | 251 phase='on_webview')) |
265 | 252 |
266 # Stories that run on the browser selected by command line options. | 253 # Stories that run on the browser selected by command line options. |
267 self.AddStory(SinglePage( | 254 self.AddStory(SinglePage( |
268 name=re.sub(r'\W+', '_', url), | 255 name=re.sub(r'\W+', '_', url), |
269 url=url, | 256 url=url, |
270 browser_type='default', | 257 browser_type='default', |
271 phase='on_chrome')) | 258 phase='on_chrome')) |
OLD | NEW |