| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 gpu_process_expectations as expectations | 4 import gpu_process_expectations as expectations |
| 5 | 5 |
| 6 from telemetry import test | 6 from telemetry import test |
| 7 from telemetry.page import page_set | 7 from telemetry.page import page_set |
| 8 from telemetry.page import page_test | 8 from telemetry.page import page_test |
| 9 | 9 |
| 10 test_harness_script = r""" | 10 test_harness_script = r""" |
| 11 var domAutomationController = {}; | 11 var domAutomationController = {}; |
| 12 domAutomationController._finished = false; | 12 domAutomationController._finished = false; |
| 13 domAutomationController.setAutomationId = function(id) {} | 13 domAutomationController.setAutomationId = function(id) {} |
| 14 domAutomationController.send = function(msg) { | 14 domAutomationController.send = function(msg) { |
| 15 domAutomationController._finished = true; | 15 domAutomationController._finished = true; |
| 16 } | 16 } |
| 17 | 17 |
| 18 window.domAutomationController = domAutomationController; | 18 window.domAutomationController = domAutomationController; |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 class GpuProcessValidator(page_test.PageTest): | 21 class GpuProcessValidator(page_test.PageTest): |
| 22 def __init__(self): | 22 def __init__(self): |
| 23 super(GpuProcessValidator, self).__init__('ValidatePage', | 23 super(GpuProcessValidator, self).__init__('ValidatePage', |
| 24 needs_browser_restart_after_each_run=True) | 24 needs_browser_restart_after_each_page=True) |
| 25 | 25 |
| 26 def CustomizeBrowserOptions(self, options): | 26 def CustomizeBrowserOptions(self, options): |
| 27 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 27 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 28 | 28 |
| 29 def ValidatePage(self, page, tab, results): | 29 def ValidatePage(self, page, tab, results): |
| 30 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' | 30 has_gpu_process_js = 'chrome.gpuBenchmarking.hasGpuProcess()' |
| 31 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) | 31 has_gpu_process = tab.EvaluateJavaScript(has_gpu_process_js) |
| 32 if not has_gpu_process: | 32 if not has_gpu_process: |
| 33 raise page_test.Failure('No GPU process detected') | 33 raise page_test.Failure('No GPU process detected') |
| 34 | 34 |
| 35 class GpuProcess(test.Test): | 35 class GpuProcess(test.Test): |
| 36 """Tests that accelerated content triggers the creation of a GPU process""" | 36 """Tests that accelerated content triggers the creation of a GPU process""" |
| 37 test = GpuProcessValidator | 37 test = GpuProcessValidator |
| 38 page_set = 'page_sets/gpu_process_tests.json' | 38 page_set = 'page_sets/gpu_process_tests.json' |
| 39 | 39 |
| 40 def CreateExpectations(self, page_set): | 40 def CreateExpectations(self, page_set): |
| 41 return expectations.GpuProcessExpectations() | 41 return expectations.GpuProcessExpectations() |
| 42 | 42 |
| 43 def CreatePageSet(self, options): | 43 def CreatePageSet(self, options): |
| 44 page_set = super(GpuProcess, self).CreatePageSet(options) | 44 page_set = super(GpuProcess, self).CreatePageSet(options) |
| 45 for page in page_set.pages: | 45 for page in page_set.pages: |
| 46 page.script_to_evaluate_on_commit = test_harness_script | 46 page.script_to_evaluate_on_commit = test_harness_script |
| 47 return page_set | 47 return page_set |
| OLD | NEW |