| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import sys | 4 import sys |
| 5 from telemetry.story import story_set as story_set_module | 5 from telemetry.story import story_set as story_set_module |
| 6 from telemetry.page import page_test | 6 from telemetry.page import legacy_page_test |
| 7 | 7 |
| 8 from gpu_tests import gpu_test_base | 8 from gpu_tests import gpu_test_base |
| 9 | 9 |
| 10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): | 10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): |
| 11 | 11 |
| 12 gpu_switches = ['--gpu-no-complete-info-collection', | 12 gpu_switches = ['--gpu-no-complete-info-collection', |
| 13 '--gpu-testing-os-version', | 13 '--gpu-testing-os-version', |
| 14 '--gpu-testing-vendor-id', | 14 '--gpu-testing-vendor-id', |
| 15 '--gpu-testing-device-id', | 15 '--gpu-testing-device-id', |
| 16 '--gpu-testing-secondary-vendor-ids', | 16 '--gpu-testing-secondary-vendor-ids', |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 description = info['description'] | 56 description = info['description'] |
| 57 value = info['value'] | 57 value = info['value'] |
| 58 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): | 58 if description.startswith('GPU%d' % index) and value.startswith('VENDOR'): |
| 59 if value.endswith('*ACTIVE*'): | 59 if value.endswith('*ACTIVE*'): |
| 60 active_gpu.append(value) | 60 active_gpu.append(value) |
| 61 else: | 61 else: |
| 62 inactive_gpus.append(value) | 62 inactive_gpus.append(value) |
| 63 index += 1 | 63 index += 1 |
| 64 | 64 |
| 65 if active_gpu != self.active_gpu: | 65 if active_gpu != self.active_gpu: |
| 66 raise page_test.Failure('Active GPU field is wrong %s' % active_gpu) | 66 raise legacy_page_test.Failure( |
| 67 'Active GPU field is wrong %s' % active_gpu) |
| 67 | 68 |
| 68 if inactive_gpus != self.inactive_gpus: | 69 if inactive_gpus != self.inactive_gpus: |
| 69 raise page_test.Failure('Inactive GPU field is wrong %s' % inactive_gpus) | 70 raise legacy_page_test.Failure( |
| 71 'Inactive GPU field is wrong %s' % inactive_gpus) |
| 70 | 72 |
| 71 | 73 |
| 72 class DriverBugWorkaroundsTestsPage(gpu_test_base.PageBase): | 74 class DriverBugWorkaroundsTestsPage(gpu_test_base.PageBase): |
| 73 def __init__(self, page_set=None, name='', | 75 def __init__(self, page_set=None, name='', |
| 74 shared_page_state_class=None, | 76 shared_page_state_class=None, |
| 75 expectations=None, | 77 expectations=None, |
| 76 expected_workaround=None, | 78 expected_workaround=None, |
| 77 unexpected_workaround=None): | 79 unexpected_workaround=None): |
| 78 super(DriverBugWorkaroundsTestsPage, self).__init__( | 80 super(DriverBugWorkaroundsTestsPage, self).__init__( |
| 79 url='chrome:gpu', | 81 url='chrome:gpu', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 if is_expected and not is_present: | 100 if is_expected and not is_present: |
| 99 failure = True | 101 failure = True |
| 100 error_message = "is missing" | 102 error_message = "is missing" |
| 101 elif not is_expected and is_present: | 103 elif not is_expected and is_present: |
| 102 failure = True | 104 failure = True |
| 103 error_message = "is not expected" | 105 error_message = "is not expected" |
| 104 | 106 |
| 105 if failure: | 107 if failure: |
| 106 print 'Test failed. Printing page contents:' | 108 print 'Test failed. Printing page contents:' |
| 107 print tab.EvaluateJavaScript('document.body.innerHTML') | 109 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 108 raise page_test.Failure('%s %s in Browser process workarounds: %s' \ | 110 raise legacy_page_test.Failure('%s %s in Browser process workarounds: %s' |
| 109 % (workaround_name, error_message, gpu_driver_bug_workarounds)) | 111 % (workaround_name, error_message, gpu_driver_bug_workarounds)) |
| 110 | 112 |
| 111 def Validate(self, tab, results): | 113 def Validate(self, tab, results): |
| 112 if not self.expected_workaround and not self.unexpected_workaround: | 114 if not self.expected_workaround and not self.unexpected_workaround: |
| 113 return | 115 return |
| 114 | 116 |
| 115 if self.expected_workaround: | 117 if self.expected_workaround: |
| 116 self._Validate(tab, "browser_process", True, self.expected_workaround) | 118 self._Validate(tab, "browser_process", True, self.expected_workaround) |
| 117 self._Validate(tab, "gpu_process", True, self.expected_workaround) | 119 self._Validate(tab, "gpu_process", True, self.expected_workaround) |
| 118 | 120 |
| 119 if self.unexpected_workaround: | 121 if self.unexpected_workaround: |
| 120 self._Validate(tab, "browser_process", False, self.unexpected_workaround) | 122 self._Validate(tab, "browser_process", False, self.unexpected_workaround) |
| 121 self._Validate(tab, "gpu_process", False, self.unexpected_workaround) | 123 self._Validate(tab, "gpu_process", False, self.unexpected_workaround) |
| 122 | 124 |
| 123 | 125 |
| 124 class EqualBugWorkaroundsBasePage(gpu_test_base.PageBase): | 126 class EqualBugWorkaroundsBasePage(gpu_test_base.PageBase): |
| 125 def __init__(self, name=None, page_set=None, shared_page_state_class=None, | 127 def __init__(self, name=None, page_set=None, shared_page_state_class=None, |
| 126 expectations=None): | 128 expectations=None): |
| 127 super(EqualBugWorkaroundsBasePage, self).__init__( | 129 super(EqualBugWorkaroundsBasePage, self).__init__( |
| 128 url='chrome:gpu', | 130 url='chrome:gpu', |
| 129 name=name, | 131 name=name, |
| 130 page_set=page_set, | 132 page_set=page_set, |
| 131 shared_page_state_class=shared_page_state_class, | 133 shared_page_state_class=shared_page_state_class, |
| 132 expectations=expectations) | 134 expectations=expectations) |
| 133 | 135 |
| 134 def Validate(self, tab, results): | 136 def Validate(self, tab, results): |
| 135 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | 137 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' |
| 136 if not tab.EvaluateJavaScript(has_gpu_process_js): | 138 if not tab.EvaluateJavaScript(has_gpu_process_js): |
| 137 raise page_test.Failure('No GPU process detected') | 139 raise legacy_page_test.Failure('No GPU process detected') |
| 138 | 140 |
| 139 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' | 141 has_gpu_channel_js = 'chrome.gpuBenchmarking.hasGpuChannel()' |
| 140 if not tab.EvaluateJavaScript(has_gpu_channel_js): | 142 if not tab.EvaluateJavaScript(has_gpu_channel_js): |
| 141 raise page_test.Failure('No GPU channel detected') | 143 raise legacy_page_test.Failure('No GPU channel detected') |
| 142 | 144 |
| 143 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') | 145 browser_list = tab.EvaluateJavaScript('GetDriverBugWorkarounds()') |
| 144 gpu_list = tab.EvaluateJavaScript( \ | 146 gpu_list = tab.EvaluateJavaScript( \ |
| 145 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') | 147 'chrome.gpuBenchmarking.getGpuDriverBugWorkarounds()') |
| 146 | 148 |
| 147 diff = set(browser_list).symmetric_difference(set(gpu_list)) | 149 diff = set(browser_list).symmetric_difference(set(gpu_list)) |
| 148 if len(diff) > 0: | 150 if len(diff) > 0: |
| 149 print 'Test failed. Printing page contents:' | 151 print 'Test failed. Printing page contents:' |
| 150 print tab.EvaluateJavaScript('document.body.innerHTML') | 152 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 151 raise page_test.Failure('Browser and GPU process list of driver bug' \ | 153 raise legacy_page_test.Failure( |
| 152 'workarounds are not equal: %s != %s, diff: %s' % \ | 154 'Browser and GPU process list of driver bug' |
| 155 'workarounds are not equal: %s != %s, diff: %s' % |
| 153 (browser_list, gpu_list, list(diff))) | 156 (browser_list, gpu_list, list(diff))) |
| 154 | 157 |
| 155 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') | 158 basic_infos = tab.EvaluateJavaScript('browserBridge.gpuInfo.basic_info') |
| 156 disabled_gl_extensions = None | 159 disabled_gl_extensions = None |
| 157 for info in basic_infos: | 160 for info in basic_infos: |
| 158 if info['description'].startswith('Disabled Extensions'): | 161 if info['description'].startswith('Disabled Extensions'): |
| 159 disabled_gl_extensions = info['value'] | 162 disabled_gl_extensions = info['value'] |
| 160 break | 163 break |
| 161 | 164 |
| 162 return gpu_list, disabled_gl_extensions | 165 return gpu_list, disabled_gl_extensions |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 def __init__(self, story_set, expectations): | 194 def __init__(self, story_set, expectations): |
| 192 super(GpuInfoCompletePage, self).__init__( | 195 super(GpuInfoCompletePage, self).__init__( |
| 193 url='file://../../data/gpu/functional_3d_css.html', | 196 url='file://../../data/gpu/functional_3d_css.html', |
| 194 name='GpuProcess.gpu_info_complete', | 197 name='GpuProcess.gpu_info_complete', |
| 195 story_set=story_set, | 198 story_set=story_set, |
| 196 expectations=expectations) | 199 expectations=expectations) |
| 197 | 200 |
| 198 def Validate(self, tab, results): | 201 def Validate(self, tab, results): |
| 199 # Regression test for crbug.com/454906 | 202 # Regression test for crbug.com/454906 |
| 200 if not tab.browser.supports_system_info: | 203 if not tab.browser.supports_system_info: |
| 201 raise page_test.Failure('Browser must support system info') | 204 raise legacy_page_test.Failure('Browser must support system info') |
| 202 system_info = tab.browser.GetSystemInfo() | 205 system_info = tab.browser.GetSystemInfo() |
| 203 if not system_info.gpu: | 206 if not system_info.gpu: |
| 204 raise page_test.Failure('Target machine must have a GPU') | 207 raise legacy_page_test.Failure('Target machine must have a GPU') |
| 205 if not system_info.gpu.aux_attributes: | 208 if not system_info.gpu.aux_attributes: |
| 206 raise page_test.Failure('Browser must support GPU aux attributes') | 209 raise legacy_page_test.Failure('Browser must support GPU aux attributes') |
| 207 if not 'gl_renderer' in system_info.gpu.aux_attributes: | 210 if not 'gl_renderer' in system_info.gpu.aux_attributes: |
| 208 raise page_test.Failure('Browser must have gl_renderer in aux attribs') | 211 raise legacy_page_test.Failure( |
| 212 'Browser must have gl_renderer in aux attribs') |
| 209 if len(system_info.gpu.aux_attributes['gl_renderer']) <= 0: | 213 if len(system_info.gpu.aux_attributes['gl_renderer']) <= 0: |
| 210 raise page_test.Failure('Must have a non-empty gl_renderer string') | 214 raise legacy_page_test.Failure( |
| 215 'Must have a non-empty gl_renderer string') |
| 211 | 216 |
| 212 | 217 |
| 213 class NoGpuProcessSharedPageState(GpuProcessSharedPageState): | 218 class NoGpuProcessSharedPageState(GpuProcessSharedPageState): |
| 214 def __init__(self, test, finder_options, story_set): | 219 def __init__(self, test, finder_options, story_set): |
| 215 super(NoGpuProcessSharedPageState, self).__init__( | 220 super(NoGpuProcessSharedPageState, self).__init__( |
| 216 test, finder_options, story_set) | 221 test, finder_options, story_set) |
| 217 options = finder_options.browser_options | 222 options = finder_options.browser_options |
| 218 | 223 |
| 219 if options.browser_type.startswith('android'): | 224 if options.browser_type.startswith('android'): |
| 220 # Android doesn't support starting up the browser without any | 225 # Android doesn't support starting up the browser without any |
| (...skipping 29 matching lines...) Expand all Loading... |
| 250 url='about:blank', | 255 url='about:blank', |
| 251 name='GpuProcess.no_gpu_process', | 256 name='GpuProcess.no_gpu_process', |
| 252 page_set=story_set, | 257 page_set=story_set, |
| 253 shared_page_state_class=NoGpuProcessSharedPageState, | 258 shared_page_state_class=NoGpuProcessSharedPageState, |
| 254 expectations=expectations) | 259 expectations=expectations) |
| 255 | 260 |
| 256 def Validate(self, tab, results): | 261 def Validate(self, tab, results): |
| 257 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | 262 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' |
| 258 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) | 263 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) |
| 259 if has_gpu_process: | 264 if has_gpu_process: |
| 260 raise page_test.Failure('GPU process detected') | 265 raise legacy_page_test.Failure('GPU process detected') |
| 261 | 266 |
| 262 | 267 |
| 263 class SoftwareGpuProcessSharedPageState(GpuProcessSharedPageState): | 268 class SoftwareGpuProcessSharedPageState(GpuProcessSharedPageState): |
| 264 def __init__(self, test, finder_options, story_set): | 269 def __init__(self, test, finder_options, story_set): |
| 265 super(SoftwareGpuProcessSharedPageState, self).__init__( | 270 super(SoftwareGpuProcessSharedPageState, self).__init__( |
| 266 test, finder_options, story_set) | 271 test, finder_options, story_set) |
| 267 options = finder_options.browser_options | 272 options = finder_options.browser_options |
| 268 | 273 |
| 269 # Hit exception from id 50 from kSoftwareRenderingListJson. | 274 # Hit exception from id 50 from kSoftwareRenderingListJson. |
| 270 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') | 275 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 url='chrome:gpu', | 307 url='chrome:gpu', |
| 303 name='GpuProcess.skip_gpu_process', | 308 name='GpuProcess.skip_gpu_process', |
| 304 page_set=story_set, | 309 page_set=story_set, |
| 305 shared_page_state_class=SkipGpuProcessSharedPageState, | 310 shared_page_state_class=SkipGpuProcessSharedPageState, |
| 306 expectations=expectations) | 311 expectations=expectations) |
| 307 | 312 |
| 308 def Validate(self, tab, results): | 313 def Validate(self, tab, results): |
| 309 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | 314 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' |
| 310 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) | 315 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) |
| 311 if has_gpu_process: | 316 if has_gpu_process: |
| 312 raise page_test.Failure('GPU process detected') | 317 raise legacy_page_test.Failure('GPU process detected') |
| 313 | 318 |
| 314 | 319 |
| 315 class DriverBugWorkaroundsShared(GpuProcessSharedPageState): | 320 class DriverBugWorkaroundsShared(GpuProcessSharedPageState): |
| 316 def __init__(self, test, finder_options, story_set): | 321 def __init__(self, test, finder_options, story_set): |
| 317 super(DriverBugWorkaroundsShared, self).__init__( | 322 super(DriverBugWorkaroundsShared, self).__init__( |
| 318 test, finder_options, story_set) | 323 test, finder_options, story_set) |
| 319 options = finder_options.browser_options | 324 options = finder_options.browser_options |
| 320 options.AppendExtraBrowserArgs('--use_gpu_driver_workaround_for_testing') | 325 options.AppendExtraBrowserArgs('--use_gpu_driver_workaround_for_testing') |
| 321 | 326 |
| 322 | 327 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 result = result and status == 'enabled_on' | 558 result = result and status == 'enabled_on' |
| 554 elif name == 'native_gpu_memory_buffers': | 559 elif name == 'native_gpu_memory_buffers': |
| 555 result = result and status == 'disabled_software' | 560 result = result and status == 'disabled_software' |
| 556 elif name == 'webgl': | 561 elif name == 'webgl': |
| 557 result = result and status == 'enabled_readback' | 562 result = result and status == 'enabled_readback' |
| 558 elif name == 'webgl2': | 563 elif name == 'webgl2': |
| 559 result = result and status == 'unavailable_off' | 564 result = result and status == 'unavailable_off' |
| 560 else: | 565 else: |
| 561 result = result and status == 'unavailable_software' | 566 result = result and status == 'unavailable_software' |
| 562 if not result: | 567 if not result: |
| 563 raise page_test.Failure('WebGL readback setup failed: %s' \ | 568 raise legacy_page_test.Failure('WebGL readback setup failed: %s' \ |
| 564 % feature_status_list) | 569 % feature_status_list) |
| 565 | 570 |
| 566 | 571 |
| 567 class HasTransparentVisualsShared(GpuProcessSharedPageState): | 572 class HasTransparentVisualsShared(GpuProcessSharedPageState): |
| 568 def __init__(self, test, finder_options, story_set): | 573 def __init__(self, test, finder_options, story_set): |
| 569 super(HasTransparentVisualsShared, self).__init__( | 574 super(HasTransparentVisualsShared, self).__init__( |
| 570 test, finder_options, story_set) | 575 test, finder_options, story_set) |
| 571 options = finder_options.browser_options | 576 options = finder_options.browser_options |
| 572 if sys.platform.startswith('linux'): | 577 if sys.platform.startswith('linux'): |
| 573 # Hit id 173 from kGpuDriverBugListJson. | 578 # Hit id 173 from kGpuDriverBugListJson. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 if self.expected_workarounds is None: | 703 if self.expected_workarounds is None: |
| 699 return | 704 return |
| 700 | 705 |
| 701 recorded_info = super(OnlyOneWorkaroundPage, self).Validate(tab, results) | 706 recorded_info = super(OnlyOneWorkaroundPage, self).Validate(tab, results) |
| 702 gpu_list, disabled_gl_extensions = recorded_info | 707 gpu_list, disabled_gl_extensions = recorded_info |
| 703 | 708 |
| 704 diff = set(self.expected_workarounds).symmetric_difference(set(gpu_list)) | 709 diff = set(self.expected_workarounds).symmetric_difference(set(gpu_list)) |
| 705 if len(diff) > 0: | 710 if len(diff) > 0: |
| 706 print 'Test failed. Printing page contents:' | 711 print 'Test failed. Printing page contents:' |
| 707 print tab.EvaluateJavaScript('document.body.innerHTML') | 712 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 708 raise page_test.Failure('GPU process and expected list of driver bug' \ | 713 raise legacy_page_test.Failure( |
| 709 'workarounds are not equal: %s != %s, diff: %s' % \ | 714 'GPU process and expected list of driver bug' |
| 715 'workarounds are not equal: %s != %s, diff: %s' % |
| 710 (self.expected_workarounds, gpu_list, list(diff))) | 716 (self.expected_workarounds, gpu_list, list(diff))) |
| 711 | 717 |
| 712 if self.expected_disabled_exts != disabled_gl_extensions: | 718 if self.expected_disabled_exts != disabled_gl_extensions: |
| 713 print 'Test failed. Printing page contents:' | 719 print 'Test failed. Printing page contents:' |
| 714 print tab.EvaluateJavaScript('document.body.innerHTML') | 720 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 715 raise page_test.Failure('The expected disabled gl extensions are ' \ | 721 raise legacy_page_test.Failure( |
| 716 'incorrect: %s != %s:' % \ | 722 'The expected disabled gl extensions are ' |
| 723 'incorrect: %s != %s:' % |
| 717 (self.expected_disabled_exts, disabled_gl_extensions)) | 724 (self.expected_disabled_exts, disabled_gl_extensions)) |
| 718 | 725 |
| 719 | 726 |
| 720 class GpuProcessTestsStorySet(story_set_module.StorySet): | 727 class GpuProcessTestsStorySet(story_set_module.StorySet): |
| 721 | 728 |
| 722 """ Tests that accelerated content triggers the creation of a GPU process """ | 729 """ Tests that accelerated content triggers the creation of a GPU process """ |
| 723 | 730 |
| 724 def __init__(self, expectations, is_platform_android): | 731 def __init__(self, expectations, is_platform_android): |
| 725 super(GpuProcessTestsStorySet, self).__init__( | 732 super(GpuProcessTestsStorySet, self).__init__( |
| 726 serving_dirs=set(['../../../../content/test/data'])) | 733 serving_dirs=set(['../../../../content/test/data'])) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 769 |
| 763 # There is currently no entry in kSoftwareRenderingListJson that enables | 770 # There is currently no entry in kSoftwareRenderingListJson that enables |
| 764 # a software GL driver on Android. | 771 # a software GL driver on Android. |
| 765 self.AddStory(SoftwareGpuProcessPage(self, expectations)) | 772 self.AddStory(SoftwareGpuProcessPage(self, expectations)) |
| 766 | 773 |
| 767 @property | 774 @property |
| 768 def allow_mixed_story_states(self): | 775 def allow_mixed_story_states(self): |
| 769 # Return True here in order to be able to run pages with different browser | 776 # Return True here in order to be able to run pages with different browser |
| 770 # command line arguments. | 777 # command line arguments. |
| 771 return True | 778 return True |
| OLD | NEW |