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 json | 5 import json |
6 import mock | 6 import mock |
7 import os | 7 import os |
8 import tempfile | 8 import tempfile |
9 import unittest | 9 import unittest |
10 | 10 |
11 from telemetry.testing import fakes | 11 from telemetry.testing import fakes |
12 from telemetry.testing import browser_test_runner | 12 from telemetry.testing import browser_test_runner |
13 | 13 |
14 import gpu_project_config | 14 import gpu_project_config |
15 | 15 |
16 from gpu_tests import gpu_integration_test | 16 from gpu_tests import gpu_integration_test |
17 from gpu_tests import gpu_test_expectations | 17 from gpu_tests import gpu_test_expectations |
18 | 18 |
19 _GLOBAL_TEST_COUNT = 0 | |
19 | 20 |
20 class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): | 21 class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): |
21 # Must be class-scoped since instances aren't reused across runs. | 22 # Must be class-scoped since instances aren't reused across runs. |
22 _num_flaky_runs_to_fail = 2 | 23 _num_flaky_runs_to_fail = 2 |
23 | 24 |
24 _num_browser_starts = 0 | 25 _num_browser_starts = 0 |
25 | 26 |
26 @classmethod | 27 @classmethod |
27 def Name(cls): | 28 def Name(cls): |
28 return 'simple_integration_unittest' | 29 return 'simple_integration_unittest' |
29 | 30 |
31 def setUp(self): | |
32 super(SimpleIntegrationUnittest, self).setUp() | |
33 global _GLOBAL_TEST_COUNT | |
34 _GLOBAL_TEST_COUNT += 1 | |
35 # If this is the first test, fail on setup to ensure that the | |
36 # gpu_integration_test handles failures in setup and remaining tests | |
37 # can be executed | |
38 if _GLOBAL_TEST_COUNT == 1: | |
39 self.tab.Navigate('chrome://crash') | |
Ken Russell (switch to Gerrit)
2016/07/14 21:38:22
Per comments in https://codereview.chromium.org/21
eyaich
2016/07/15 13:30:27
Done.
| |
40 | |
30 @classmethod | 41 @classmethod |
31 def setUpClass(cls): | 42 def setUpClass(cls): |
32 finder_options = fakes.CreateBrowserFinderOptions() | 43 finder_options = fakes.CreateBrowserFinderOptions() |
33 finder_options.browser_options.platform = fakes.FakeLinuxPlatform() | 44 finder_options.browser_options.platform = fakes.FakeLinuxPlatform() |
34 finder_options.output_formats = ['none'] | 45 finder_options.output_formats = ['none'] |
35 finder_options.suppress_gtest_report = True | 46 finder_options.suppress_gtest_report = True |
36 finder_options.output_dir = None | 47 finder_options.output_dir = None |
37 finder_options.upload_bucket = 'public' | 48 finder_options.upload_bucket = 'public' |
38 finder_options.upload_results = False | 49 finder_options.upload_results = False |
39 cls._finder_options = finder_options | 50 cls._finder_options = finder_options |
40 cls.platform = None | 51 cls.platform = None |
41 cls.browser = None | 52 cls.browser = None |
42 cls.SetBrowserOptions(cls._finder_options) | 53 cls.SetBrowserOptions(cls._finder_options) |
43 cls.StartBrowser() | 54 cls.StartBrowser() |
44 | 55 |
45 @classmethod | 56 @classmethod |
46 def GenerateGpuTests(cls, options): | 57 def GenerateGpuTests(cls, options): |
58 yield ('setup', 'pass.html', ()) | |
47 yield ('expected_failure', 'failure.html', ()) | 59 yield ('expected_failure', 'failure.html', ()) |
48 yield ('expected_flaky', 'flaky.html', ()) | 60 yield ('expected_flaky', 'flaky.html', ()) |
49 yield ('expected_skip', 'failure.html', ()) | 61 yield ('expected_skip', 'failure.html', ()) |
50 yield ('unexpected_failure', 'failure.html', ()) | 62 yield ('unexpected_failure', 'failure.html', ()) |
51 yield ('unexpected_error', 'error.html', ()) | 63 yield ('unexpected_error', 'error.html', ()) |
52 | 64 |
53 @classmethod | 65 @classmethod |
54 def _CreateExpectations(cls): | 66 def _CreateExpectations(cls): |
55 expectations = gpu_test_expectations.GpuTestExpectations() | 67 expectations = gpu_test_expectations.GpuTestExpectations() |
56 expectations.Fail('expected_failure') | 68 expectations.Fail('expected_failure') |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 config, options, | 101 config, options, |
90 ['simple_integration_unittest', | 102 ['simple_integration_unittest', |
91 '--write-abbreviated-json-results-to=%s' % temp_file_name]) | 103 '--write-abbreviated-json-results-to=%s' % temp_file_name]) |
92 with open(temp_file_name) as f: | 104 with open(temp_file_name) as f: |
93 test_result = json.load(f) | 105 test_result = json.load(f) |
94 self.assertEquals(test_result['failures'], [ | 106 self.assertEquals(test_result['failures'], [ |
95 'unexpected_error', | 107 'unexpected_error', |
96 'unexpected_failure']) | 108 'unexpected_failure']) |
97 self.assertEquals(test_result['successes'], [ | 109 self.assertEquals(test_result['successes'], [ |
98 'expected_failure', | 110 'expected_failure', |
99 'expected_flaky']) | 111 'expected_flaky', |
112 'setup']) | |
100 self.assertEquals(test_result['valid'], True) | 113 self.assertEquals(test_result['valid'], True) |
101 # It might be nice to be more precise about the order of operations | 114 # It might be nice to be more precise about the order of operations |
102 # with these browser restarts, but this is at least a start. | 115 # with these browser restarts, but this is at least a start. |
103 self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 5) | 116 self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 6) |
104 finally: | 117 finally: |
105 os.remove(temp_file_name) | 118 os.remove(temp_file_name) |
OLD | NEW |