| 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 |
| 11 from gpu_tests import gpu_test_expectations | 11 from gpu_tests import gpu_test_expectations |
| 12 | 12 |
| 13 | 13 |
| 14 class GpuIntegrationTest( | 14 class GpuIntegrationTest( |
| 15 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): | 15 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): |
| 16 | 16 |
| 17 _cached_expectations = None | 17 _cached_expectations = None |
| 18 | 18 |
| 19 @classmethod | 19 @classmethod |
| 20 def GenerateTestCases__RunGpuTest(cls, options): | 20 def GenerateTestCases__RunGpuTest(cls, options): |
| 21 for test_name, url, args in cls.GenerateGpuTests(options): | 21 for test_name, url, args in cls.GenerateGpuTests(options): |
| 22 yield test_name, (url, test_name, args) | 22 yield test_name, (url, test_name, args) |
| 23 | 23 |
| 24 @classmethod | 24 @classmethod |
| 25 def StartBrowser(cls): | 25 def StartBrowser(cls): |
| 26 # We still need to retry the browser's launch even though |
| 27 # desktop_browser_finder does so too, because it wasn't possible |
| 28 # to push the fetch of the first tab into the lower retry loop |
| 29 # without breaking Telemetry's unit tests, and that hook is used |
| 30 # to implement the gpu_integration_test_unittests. |
| 26 for x in range(0, 3): | 31 for x in range(0, 3): |
| 27 try: | 32 try: |
| 28 restart = 'Starting browser, attempt %d of 3' % (x + 1) | |
| 29 logging.warning(restart) | |
| 30 super(GpuIntegrationTest, cls).StartBrowser() | 33 super(GpuIntegrationTest, cls).StartBrowser() |
| 31 cls.tab = cls.browser.tabs[0] | 34 cls.tab = cls.browser.tabs[0] |
| 32 logging.warning('Started browser successfully.') | |
| 33 return | 35 return |
| 34 except Exception: | 36 except Exception: |
| 37 logging.warning('Browser start failed (attempt %d of 3)', (x + 1)) |
| 35 # If we are on the last try and there is an exception take a screenshot | 38 # If we are on the last try and there is an exception take a screenshot |
| 36 # to try and capture more about the browser failure and raise | 39 # to try and capture more about the browser failure and raise |
| 37 if x == 2: | 40 if x == 2: |
| 38 url = screenshot.TryCaptureScreenShotAndUploadToCloudStorage( | 41 url = screenshot.TryCaptureScreenShotAndUploadToCloudStorage( |
| 39 cls.platform) | 42 cls.platform) |
| 40 if url is not None: | 43 if url is not None: |
| 41 logging.info("GpuIntegrationTest screenshot of browser failure " + | 44 logging.info("GpuIntegrationTest screenshot of browser failure " + |
| 42 "located at " + url) | 45 "located at " + url) |
| 43 else: | 46 else: |
| 44 logging.warning("GpuIntegrationTest unable to take screenshot") | 47 logging.warning("GpuIntegrationTest unable to take screenshot") |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 cls._RestartBrowser('failure in setup') | 195 cls._RestartBrowser('failure in setup') |
| 193 raise | 196 raise |
| 194 | 197 |
| 195 def setUp(self): | 198 def setUp(self): |
| 196 self._EnsureTabIsAvailable() | 199 self._EnsureTabIsAvailable() |
| 197 | 200 |
| 198 def LoadAllTestsInModule(module): | 201 def LoadAllTestsInModule(module): |
| 199 # Just delegates to serially_executed_browser_test_case to reduce the | 202 # Just delegates to serially_executed_browser_test_case to reduce the |
| 200 # number of imports in other files. | 203 # number of imports in other files. |
| 201 return serially_executed_browser_test_case.LoadAllTestsInModule(module) | 204 return serially_executed_browser_test_case.LoadAllTestsInModule(module) |
| OLD | NEW |