OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 os | 4 import os |
5 | 5 |
6 from telemetry import test as test_module | 6 from telemetry import test as test_module |
7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
8 from telemetry.core import util | 8 from telemetry.core import util |
| 9 from telemetry.page import page |
9 from telemetry.page import page_set | 10 from telemetry.page import page_set |
| 11 # pylint: disable=W0401,W0614 |
10 from telemetry.page import page_test | 12 from telemetry.page import page_test |
| 13 from telemetry.page.actions.all_page_actions import * |
11 | 14 |
12 data_path = os.path.join( | 15 data_path = os.path.join( |
13 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') | 16 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
14 | 17 |
15 wait_timeout = 20 # seconds | 18 wait_timeout = 20 # seconds |
16 | 19 |
17 harness_script = r""" | 20 harness_script = r""" |
18 var domAutomationController = {}; | 21 var domAutomationController = {}; |
19 | 22 |
20 domAutomationController._loaded = false; | 23 domAutomationController._loaded = false; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 except (exceptions.TabCrashException, Exception): | 96 except (exceptions.TabCrashException, Exception): |
94 print 'Tab crashed while closing chrome://gpucrash' | 97 print 'Tab crashed while closing chrome://gpucrash' |
95 if not completed: | 98 if not completed: |
96 raise page_test.Failure( | 99 raise page_test.Failure( |
97 'Test didn\'t complete (no context lost event?)') | 100 'Test didn\'t complete (no context lost event?)') |
98 if not tab.EvaluateJavaScript( | 101 if not tab.EvaluateJavaScript( |
99 'window.domAutomationController._succeeded'): | 102 'window.domAutomationController._succeeded'): |
100 raise page_test.Failure( | 103 raise page_test.Failure( |
101 'Test failed (context not restored properly?)') | 104 'Test failed (context not restored properly?)') |
102 | 105 |
| 106 class WebGLContextLostFromGPUProcessExitPage(page.Page): |
| 107 def __init__(self, page_set, base_dir): |
| 108 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( |
| 109 url='file://webgl.html?query=kill_after_notification', |
| 110 page_set=page_set, |
| 111 base_dir=base_dir) |
| 112 self.name = 'ContextLost.WebGLContextLostFromGPUProcessExit' |
| 113 self.script_to_evaluate_on_commit = harness_script |
| 114 self.kill_gpu_process = True |
| 115 self.number_of_gpu_process_kills = 1 |
| 116 |
| 117 def RunNavigateSteps(self, action_runner): |
| 118 action_runner.RunAction(NavigateAction()) |
| 119 action_runner.RunAction(WaitAction( |
| 120 {'javascript': 'window.domAutomationController._loaded'})) |
| 121 |
| 122 |
| 123 class WebGLContextLostFromLoseContextExtensionPage(page.Page): |
| 124 def __init__(self, page_set, base_dir): |
| 125 super(WebGLContextLostFromLoseContextExtensionPage, self).__init__( |
| 126 url='file://webgl.html?query=WEBGL_lose_context', |
| 127 page_set=page_set, |
| 128 base_dir=base_dir) |
| 129 self.name = 'ContextLost.WebGLContextLostFromLoseContextExtension', |
| 130 self.script_to_evaluate_on_commit = harness_script |
| 131 self.kill_gpu_process = False |
| 132 |
| 133 def RunNavigateSteps(self, action_runner): |
| 134 action_runner.RunAction(NavigateAction()) |
| 135 action_runner.RunAction(WaitAction( |
| 136 {'javascript': 'window.domAutomationController._finished'})) |
| 137 |
| 138 |
103 class ContextLost(test_module.Test): | 139 class ContextLost(test_module.Test): |
104 enabled = True | 140 enabled = True |
105 test = _ContextLostValidator | 141 test = _ContextLostValidator |
106 # For the record, this would have been another way to get the pages | 142 # For the record, this would have been another way to get the pages |
107 # to repeat. pageset_repeat would be another option. | 143 # to repeat. pageset_repeat would be another option. |
108 # options = {'page_repeat': 5} | 144 # options = {'page_repeat': 5} |
109 def CreatePageSet(self, options): | 145 def CreatePageSet(self, options): |
110 page_set_dict = { | 146 ps = page_set.PageSet( |
111 'description': 'Test cases for real and synthetic context lost events', | 147 file_path=data_path, |
112 'user_agent_type': 'desktop', | 148 description='Test cases for real and synthetic context lost events', |
113 'serving_dirs': [''], | 149 user_agent_type='desktop', |
114 'pages': [ | 150 serving_dirs=set([''])) |
115 { | 151 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) |
116 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', | 152 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) |
117 'url': 'file://webgl.html?query=kill_after_notification', | 153 return ps |
118 'script_to_evaluate_on_commit': harness_script, | |
119 'navigate_steps': [ | |
120 { 'action': 'navigate' }, | |
121 { 'action': 'wait', | |
122 'javascript': 'window.domAutomationController._loaded' } | |
123 ], | |
124 'kill_gpu_process': True, | |
125 'number_of_gpu_process_kills': 1, | |
126 }, | |
127 { | |
128 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', | |
129 'url': 'file://webgl.html?query=WEBGL_lose_context', | |
130 'script_to_evaluate_on_commit': harness_script, | |
131 'navigate_steps': [ | |
132 { 'action': 'navigate' }, | |
133 { 'action': 'wait', | |
134 'javascript': 'window.domAutomationController._finished' } | |
135 ], | |
136 'kill_gpu_process': False | |
137 }, | |
138 ] | |
139 } | |
140 return page_set.PageSet.FromDict(page_set_dict, data_path) | |
OLD | NEW |