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 from telemetry.story import story_set as story_set_module | 5 from telemetry.story import story_set as story_set_module |
5 from telemetry.page import page_test | 6 from telemetry.page import page_test |
6 | 7 |
7 from gpu_tests import gpu_test_base | 8 from gpu_tests import gpu_test_base |
8 | 9 |
| 10 class GpuProcessSharedPageState(gpu_test_base.GpuSharedPageState): |
| 11 |
| 12 gpu_switches = ['--gpu-no-complete-info-collection', |
| 13 '--gpu-testing-os-version', |
| 14 '--gpu-testing-vendor-id', |
| 15 '--gpu-testing-device-id', |
| 16 '--gpu-testing-gl-vendor', |
| 17 '--gpu-testing-gl-renderer', |
| 18 '--gpu-testing-gl-version'] |
| 19 |
| 20 def __init__(self, test, finder_options, story_set): |
| 21 super(GpuProcessSharedPageState, self).__init__( |
| 22 test, finder_options, story_set) |
| 23 options = finder_options.browser_options.extra_browser_args |
| 24 |
| 25 # Clear all existing gpu testing switches. |
| 26 old_gpu_switches = [] |
| 27 for opt in options: |
| 28 for gpu_switch in self.gpu_switches: |
| 29 if opt.startswith(gpu_switch): |
| 30 old_gpu_switches.append(opt) |
| 31 options.difference_update(old_gpu_switches) |
| 32 |
9 class GpuProcessTestsPage(gpu_test_base.PageBase): | 33 class GpuProcessTestsPage(gpu_test_base.PageBase): |
10 | |
11 def __init__(self, url, name, story_set, expectations): | 34 def __init__(self, url, name, story_set, expectations): |
12 super(GpuProcessTestsPage, self).__init__(url=url, page_set=story_set, | 35 super(GpuProcessTestsPage, self).__init__(url=url, |
13 name=name, | 36 shared_page_state_class=gpu_test_base.GpuSharedPageState, |
14 expectations=expectations) | 37 page_set=story_set, |
| 38 name=name, |
| 39 expectations=expectations) |
15 | 40 |
16 | 41 |
17 class FunctionalVideoPage(GpuProcessTestsPage): | 42 class FunctionalVideoPage(GpuProcessTestsPage): |
18 | 43 |
19 def __init__(self, story_set, expectations): | 44 def __init__(self, story_set, expectations): |
20 super(FunctionalVideoPage, self).__init__( | 45 super(FunctionalVideoPage, self).__init__( |
21 url='file://../../data/gpu/functional_video.html', | 46 url='file://../../data/gpu/functional_video.html', |
22 name='GpuProcess.video', | 47 name='GpuProcess.video', |
23 story_set=story_set, | 48 story_set=story_set, |
24 expectations=expectations) | 49 expectations=expectations) |
(...skipping 21 matching lines...) Expand all Loading... |
46 if not system_info.gpu: | 71 if not system_info.gpu: |
47 raise page_test.Failure('Target machine must have a GPU') | 72 raise page_test.Failure('Target machine must have a GPU') |
48 if not system_info.gpu.aux_attributes: | 73 if not system_info.gpu.aux_attributes: |
49 raise page_test.Failure('Browser must support GPU aux attributes') | 74 raise page_test.Failure('Browser must support GPU aux attributes') |
50 if not 'gl_renderer' in system_info.gpu.aux_attributes: | 75 if not 'gl_renderer' in system_info.gpu.aux_attributes: |
51 raise page_test.Failure('Browser must have gl_renderer in aux attribs') | 76 raise page_test.Failure('Browser must have gl_renderer in aux attribs') |
52 if len(system_info.gpu.aux_attributes['gl_renderer']) <= 0: | 77 if len(system_info.gpu.aux_attributes['gl_renderer']) <= 0: |
53 raise page_test.Failure('Must have a non-empty gl_renderer string') | 78 raise page_test.Failure('Must have a non-empty gl_renderer string') |
54 | 79 |
55 | 80 |
| 81 class NoGpuProcessSharedPageState(GpuProcessSharedPageState): |
| 82 def __init__(self, test, finder_options, story_set): |
| 83 super(NoGpuProcessSharedPageState, self).__init__( |
| 84 test, finder_options, story_set) |
| 85 options = finder_options.browser_options |
| 86 |
| 87 if sys.platform in ('cygwin', 'win32'): |
| 88 # Hit id 34 from kSoftwareRenderingListJson. |
| 89 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x5333') |
| 90 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x8811') |
| 91 elif sys.platform.startswith('linux'): |
| 92 # Hit id 50 from kSoftwareRenderingListJson. |
| 93 options.AppendExtraBrowserArgs('--gpu-no-complete-info-collection') |
| 94 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') |
| 95 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') |
| 96 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=VMware') |
| 97 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=softpipe') |
| 98 options.AppendExtraBrowserArgs('--gpu-testing-gl-version="2.1 Mesa 10.1"') |
| 99 elif sys.platform == 'darwin': |
| 100 # Hit id 81 from kSoftwareRenderingListJson. |
| 101 options.AppendExtraBrowserArgs('--gpu-testing-os-version=10.7') |
| 102 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x15ad') |
| 103 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0393') |
| 104 |
| 105 |
| 106 class NoGpuProcessPage(gpu_test_base.PageBase): |
| 107 |
| 108 def __init__(self, story_set, expectations): |
| 109 super(NoGpuProcessPage, self).__init__( |
| 110 url='about:blank', |
| 111 name='GpuProcess.no_gpu_process', |
| 112 page_set=story_set, |
| 113 shared_page_state_class=NoGpuProcessSharedPageState, |
| 114 expectations=expectations) |
| 115 |
| 116 def Validate(self, tab, results): |
| 117 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' |
| 118 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) |
| 119 if has_gpu_process: |
| 120 raise page_test.Failure('GPU process detected') |
| 121 |
| 122 |
| 123 class SoftwareGpuProcessSharedPageState(GpuProcessSharedPageState): |
| 124 def __init__(self, test, finder_options, story_set): |
| 125 super(SoftwareGpuProcessSharedPageState, self).__init__( |
| 126 test, finder_options, story_set) |
| 127 options = finder_options.browser_options |
| 128 options.AppendExtraBrowserArgs('--gpu-testing-vendor-id=0x10de') |
| 129 options.AppendExtraBrowserArgs('--gpu-testing-device-id=0x0de1') |
| 130 options.AppendExtraBrowserArgs('--gpu-testing-gl-vendor=VMware') |
| 131 options.AppendExtraBrowserArgs('--gpu-testing-gl-renderer=SVGA3D') |
| 132 options.AppendExtraBrowserArgs('--gpu-testing-gl-version="2.1 Mesa 10.1"') |
| 133 |
| 134 |
| 135 class SoftwareGpuProcessPage(gpu_test_base.PageBase): |
| 136 |
| 137 def __init__(self, story_set, expectations): |
| 138 super(SoftwareGpuProcessPage, self).__init__( |
| 139 url='about:blank', |
| 140 name='GpuProcess.software_gpu_process', |
| 141 page_set=story_set, |
| 142 shared_page_state_class=SoftwareGpuProcessSharedPageState, |
| 143 expectations=expectations) |
| 144 |
| 145 |
56 class GpuProcessTestsStorySet(story_set_module.StorySet): | 146 class GpuProcessTestsStorySet(story_set_module.StorySet): |
57 | 147 |
58 """ Tests that accelerated content triggers the creation of a GPU process """ | 148 """ Tests that accelerated content triggers the creation of a GPU process """ |
59 | 149 |
60 def __init__(self, expectations): | 150 def __init__(self, expectations): |
61 super(GpuProcessTestsStorySet, self).__init__( | 151 super(GpuProcessTestsStorySet, self).__init__( |
62 serving_dirs=set(['../../../../content/test/data'])) | 152 serving_dirs=set(['../../../../content/test/data'])) |
63 | 153 |
64 urls_and_names_list = [ | 154 urls_and_names_list = [ |
65 ('file://../../data/gpu/functional_canvas_demo.html', | 155 ('file://../../data/gpu/functional_canvas_demo.html', |
66 'GpuProcess.canvas2d'), | 156 'GpuProcess.canvas2d'), |
67 ('file://../../data/gpu/functional_3d_css.html', | 157 ('file://../../data/gpu/functional_3d_css.html', |
68 'GpuProcess.css3d'), | 158 'GpuProcess.css3d'), |
69 ('file://../../data/gpu/functional_webgl.html', | 159 ('file://../../data/gpu/functional_webgl.html', |
70 'GpuProcess.webgl') | 160 'GpuProcess.webgl') |
71 ] | 161 ] |
72 | 162 |
73 for url, name in urls_and_names_list: | 163 for url, name in urls_and_names_list: |
74 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) | 164 self.AddStory(GpuProcessTestsPage(url, name, self, expectations)) |
75 | 165 |
76 self.AddStory(FunctionalVideoPage(self, expectations)) | 166 self.AddStory(FunctionalVideoPage(self, expectations)) |
77 self.AddStory(GpuInfoCompletePage(self, expectations)) | 167 self.AddStory(GpuInfoCompletePage(self, expectations)) |
| 168 self.AddStory(NoGpuProcessPage(self, expectations)) |
| 169 self.AddStory(SoftwareGpuProcessPage(self, expectations)) |
| 170 |
| 171 @property |
| 172 def allow_mixed_story_states(self): |
| 173 # Return True here in order to be able to run pages with different browser |
| 174 # command line arguments. |
| 175 return True |
OLD | NEW |