| Index: content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
|
| diff --git a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
|
| index 7d87ff89862b51ac2cf229a2f11c03504f232d7d..c62317566251953e49294f5170a01336e3ee6ac6 100644
|
| --- a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
|
| +++ b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
|
| @@ -17,6 +17,7 @@ from gpu_tests import gpu_integration_test
|
| from gpu_tests import gpu_test_expectations
|
|
|
| _GLOBAL_TEST_COUNT = 0
|
| +_GLOBAL_RESTART_CRASH = False
|
|
|
| class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
|
| # Must be class-scoped since instances aren't reused across runs.
|
| @@ -24,6 +25,8 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
|
|
|
| _num_browser_starts = 0
|
|
|
| + _num_restart_failures = 0
|
| +
|
| @classmethod
|
| def Name(cls):
|
| return 'simple_integration_unittest'
|
| @@ -61,6 +64,9 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
|
| yield ('expected_skip', 'failure.html', ())
|
| yield ('unexpected_failure', 'failure.html', ())
|
| yield ('unexpected_error', 'error.html', ())
|
| + # This test causes the browser to restart 2 times (max allowed 3) and then
|
| + # succeeds on the third attempt
|
| + yield ('restart', 'restart.html', ())
|
|
|
| @classmethod
|
| def _CreateExpectations(cls):
|
| @@ -75,9 +81,26 @@ class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
|
| super(SimpleIntegrationUnittest, cls).StartBrowser()
|
| cls._num_browser_starts += 1
|
|
|
| + @classmethod
|
| + def StopBrowser(cls):
|
| + global _GLOBAL_RESTART_CRASH
|
| + if _GLOBAL_RESTART_CRASH:
|
| + if cls._num_restart_failures < 2:
|
| + cls._num_restart_failures += 1
|
| + raise Exception
|
| + else:
|
| + _GLOBAL_RESTART_CRASH = False
|
| +
|
| + super(SimpleIntegrationUnittest, cls).StopBrowser()
|
| +
|
| +
|
| def RunActualGpuTest(self, file_path, *args):
|
| if file_path == 'failure.html':
|
| self.fail('Expected failure')
|
| + elif file_path == 'restart.html':
|
| + global _GLOBAL_RESTART_CRASH
|
| + _GLOBAL_RESTART_CRASH = True
|
| + self._RestartBrowser("testing restart on failure")
|
| elif file_path == 'flaky.html':
|
| if self.__class__._num_flaky_runs_to_fail > 0:
|
| self.__class__._num_flaky_runs_to_fail -= 1
|
| @@ -109,10 +132,12 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
|
| 'unexpected_error',
|
| 'unexpected_failure'])
|
| self.assertEquals(test_result['successes'], [
|
| - 'expected_flaky'])
|
| + 'expected_flaky', 'restart'])
|
| self.assertEquals(test_result['valid'], True)
|
| # It might be nice to be more precise about the order of operations
|
| # with these browser restarts, but this is at least a start.
|
| - self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 6)
|
| + self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 7)
|
| + # Assert that we restarted the browser 2 times due to failure in restart
|
| + self.assertEquals(SimpleIntegrationUnittest._num_restart_failures, 2)
|
| finally:
|
| os.remove(temp_file_name)
|
|
|