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