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 logging | 5 import logging |
6 | 6 |
7 from telemetry.testing import serially_executed_browser_test_case | 7 from telemetry.testing import serially_executed_browser_test_case |
8 from telemetry.util import screenshot | 8 from telemetry.util import screenshot |
9 | 9 |
10 from gpu_tests import exception_formatter | 10 from gpu_tests import exception_formatter |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 if x == 2: | 44 if x == 2: |
45 url = screenshot.TryCaptureScreenShotAndUploadToCloudStorage( | 45 url = screenshot.TryCaptureScreenShotAndUploadToCloudStorage( |
46 cls.platform) | 46 cls.platform) |
47 if url is not None: | 47 if url is not None: |
48 logging.info("GpuIntegrationTest screenshot of browser failure " + | 48 logging.info("GpuIntegrationTest screenshot of browser failure " + |
49 "located at " + url) | 49 "located at " + url) |
50 else: | 50 else: |
51 logging.warning("GpuIntegrationTest unable to take screenshot") | 51 logging.warning("GpuIntegrationTest unable to take screenshot") |
52 raise | 52 raise |
53 | 53 |
54 def _RestartBrowser(self, reason): | 54 @classmethod |
| 55 def _RestartBrowser(cls, reason): |
55 logging.warning('Restarting browser due to '+ reason) | 56 logging.warning('Restarting browser due to '+ reason) |
56 self.StopBrowser() | 57 cls.StopBrowser() |
57 self.SetBrowserOptions(self._finder_options) | 58 cls.SetBrowserOptions(cls._finder_options) |
58 self.StartBrowser() | 59 cls.StartBrowser() |
59 self.tab = self.browser.tabs[0] | 60 cls.tab = cls.browser.tabs[0] |
60 | 61 |
61 def _RunGpuTest(self, url, test_name, *args): | 62 def _RunGpuTest(self, url, test_name, *args): |
62 temp_page = _EmulatedPage(url, test_name) | 63 temp_page = _EmulatedPage(url, test_name) |
63 expectations = self.__class__.GetExpectations() | 64 expectations = self.__class__.GetExpectations() |
64 expectation = expectations.GetExpectationForPage( | 65 expectation = expectations.GetExpectationForPage( |
65 self.browser, temp_page) | 66 self.browser, temp_page) |
66 if expectation == 'skip': | 67 if expectation == 'skip': |
67 # skipTest in Python's unittest harness raises an exception, so | 68 # skipTest in Python's unittest harness raises an exception, so |
68 # aborts the control flow here. | 69 # aborts the control flow here. |
69 self.skipTest('SKIPPING TEST due to test expectations') | 70 self.skipTest('SKIPPING TEST due to test expectations') |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return cls._cached_expectations | 152 return cls._cached_expectations |
152 | 153 |
153 @classmethod | 154 @classmethod |
154 def _CreateExpectations(cls): | 155 def _CreateExpectations(cls): |
155 # Subclasses **must** override this in order to provide their test | 156 # Subclasses **must** override this in order to provide their test |
156 # expectations to the harness. | 157 # expectations to the harness. |
157 # | 158 # |
158 # Do not call this directly. Call GetExpectations where necessary. | 159 # Do not call this directly. Call GetExpectations where necessary. |
159 raise NotImplementedError | 160 raise NotImplementedError |
160 | 161 |
161 def setUp(self): | 162 @classmethod |
| 163 def _EnsureTabIsAvailable(cls): |
162 try: | 164 try: |
163 self.tab = self.browser.tabs[0] | 165 cls.tab = cls.browser.tabs[0] |
164 except Exception: | 166 except Exception: |
165 # restart the browser to make sure a failure in a test doesn't | 167 # restart the browser to make sure a failure in a test doesn't |
166 # propagate to the next test iteration. | 168 # propagate to the next test iteration. |
167 logging.exception("Failure during browser startup") | 169 logging.exception("Failure during browser startup") |
168 self._RestartBrowser('failure in setup') | 170 cls._RestartBrowser('failure in setup') |
169 raise | 171 raise |
| 172 |
| 173 def setUp(self): |
| 174 self._EnsureTabIsAvailable() |
OLD | NEW |