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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 self._current_story = None | 72 self._current_story = None |
73 self._current_browser = None | 73 self._current_browser = None |
74 self._current_tab = None | 74 self._current_tab = None |
75 | 75 |
76 possible_browser = self._PrepareBrowser('default', finder_options) | 76 possible_browser = self._PrepareBrowser('default', finder_options) |
77 if not possible_browser: | 77 if not possible_browser: |
78 raise browser_finder_exceptions.BrowserFinderException( | 78 raise browser_finder_exceptions.BrowserFinderException( |
79 'No browser found.\n\nAvailable browsers:\n%s\n' % | 79 'No browser found.\n\nAvailable browsers:\n%s\n' % |
80 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) | 80 '\n'.join(browser_finder.GetAllAvailableBrowserTypes(finder_options))) |
81 if not finder_options.run_disabled_tests: | 81 if not finder_options.run_disabled_tests: |
82 self._CheckTestEnabled(test, possible_browser) | 82 self._CheckTestEnabled(test, possible_browser) |
perezju
2016/09/30 13:13:29
I think now you can remove this check together wit
eyaich1
2016/09/30 13:22:35
Why did we ever need it? Would the execution ever
perezju
2016/09/30 13:28:01
I think I added it here _because_ of the other bug
| |
83 | 83 |
84 extra_browser_types = set(story.browser_type for story in story_set) | 84 extra_browser_types = set(story.browser_type for story in story_set) |
85 extra_browser_types.remove('default') # Must include 'default' browser. | 85 extra_browser_types.remove('default') # Must include 'default' browser. |
86 for browser_type in extra_browser_types: | 86 for browser_type in extra_browser_types: |
87 options = _OptionsForBrowser(browser_type, finder_options) | 87 options = _OptionsForBrowser(browser_type, finder_options) |
88 if not self._PrepareBrowser(browser_type, options): | 88 if not self._PrepareBrowser(browser_type, options): |
89 logging.warning('Skipping %s (%s) because %s browser is not available', | 89 logging.warning('Skipping %s (%s) because %s browser is not available', |
90 test.__name__, str(test), browser_type) | 90 test.__name__, str(test), browser_type) |
91 logging.warning('Install %s to be able to run the test.', browser_type) | 91 logging.warning('Install %s to be able to run the test.', browser_type) |
92 sys.exit(0) | 92 sys.exit(0) |
perezju
2016/09/30 13:13:29
Could you make this one die hard instead by raisin
eyaich1
2016/09/30 13:22:35
Done.
| |
93 | 93 |
94 # TODO(crbug/404771): Move network controller options out of | 94 # TODO(crbug/404771): Move network controller options out of |
95 # browser_options and into finder_options. | 95 # browser_options and into finder_options. |
96 browser_options = finder_options.browser_options | 96 browser_options = finder_options.browser_options |
97 if finder_options.use_live_sites: | 97 if finder_options.use_live_sites: |
98 wpr_mode = wpr_modes.WPR_OFF | 98 wpr_mode = wpr_modes.WPR_OFF |
99 elif browser_options.wpr_mode == wpr_modes.WPR_RECORD: | 99 elif browser_options.wpr_mode == wpr_modes.WPR_RECORD: |
100 wpr_mode = wpr_modes.WPR_RECORD | 100 wpr_mode = wpr_modes.WPR_RECORD |
101 else: | 101 else: |
102 wpr_mode = wpr_modes.WPR_REPLAY | 102 wpr_mode = wpr_modes.WPR_REPLAY |
103 | 103 |
104 self.platform.network_controller.Open(wpr_mode, | 104 self.platform.network_controller.Open(wpr_mode, |
105 browser_options.extra_wpr_args) | 105 browser_options.extra_wpr_args) |
106 | 106 |
107 @property | 107 @property |
108 def current_tab(self): | 108 def current_tab(self): |
109 return self._current_tab | 109 return self._current_tab |
110 | 110 |
111 @property | 111 @property |
112 def platform(self): | 112 def platform(self): |
113 return self._platform | 113 return self._platform |
114 | 114 |
115 def _CheckTestEnabled(self, test, possible_browser): | 115 def _CheckTestEnabled(self, test, possible_browser): |
116 should_skip, msg = decorators.ShouldSkip(test, possible_browser) | 116 should_skip, msg = decorators.ShouldSkip(test, possible_browser) |
117 if should_skip: | 117 if should_skip: |
118 logging.warning(msg) | 118 logging.warning(msg) |
119 logging.warning('You are trying to run a disabled test.') | 119 logging.warning('You are trying to run a disabled test.') |
120 logging.warning( | 120 logging.warning('Valid chartjson ouput will not be generated.') |
perezju
2016/09/29 13:01:45
This will effectively cause the benchmark to run e
eyaich1
2016/09/29 13:05:30
Well it won't fail, it will still technically succ
nednguyen
2016/09/29 13:08:40
Hmhh, why not define ShouldDisable(..) for the ben
| |
121 'Pass --also-run-disabled-tests to squelch this message.') | |
122 sys.exit(0) | |
123 | 121 |
124 def _PrepareBrowser(self, browser_type, options): | 122 def _PrepareBrowser(self, browser_type, options): |
125 """Add a browser to the dict of possible browsers. | 123 """Add a browser to the dict of possible browsers. |
126 | 124 |
127 TODO(perezju): When available, use the GetBrowserForPlatform API instead. | 125 TODO(perezju): When available, use the GetBrowserForPlatform API instead. |
128 See: crbug.com/570348 | 126 See: crbug.com/570348 |
129 | 127 |
130 Returns: | 128 Returns: |
131 The possible browser if found, or None otherwise. | 129 The possible browser if found, or None otherwise. |
132 """ | 130 """ |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), | 260 url=GOOGLE_SEARCH + urllib.urlencode({'q': query}), |
263 browser_type='android-webview', | 261 browser_type='android-webview', |
264 phase='on_webview')) | 262 phase='on_webview')) |
265 | 263 |
266 # Stories that run on the browser selected by command line options. | 264 # Stories that run on the browser selected by command line options. |
267 self.AddStory(SinglePage( | 265 self.AddStory(SinglePage( |
268 name=re.sub(r'\W+', '_', url), | 266 name=re.sub(r'\W+', '_', url), |
269 url=url, | 267 url=url, |
270 browser_type='default', | 268 browser_type='default', |
271 phase='on_chrome')) | 269 phase='on_chrome')) |
OLD | NEW |