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
3 # found in the LICENSE file.
4 import gpu_process_expectations
as expectations
8 from telemetry
.page
import page_test
10 test_harness_script
= r
"""
11 var domAutomationController = {};
12 domAutomationController._finished = false;
13 domAutomationController.setAutomationId = function(id) {}
14 domAutomationController.send = function(msg) {
15 domAutomationController._finished = true;
18 window.domAutomationController = domAutomationController;
21 class GpuProcessValidator(gpu_test_base
.ValidatorBase
):
23 super(GpuProcessValidator
, self
).__init
__(
24 needs_browser_restart_after_each_page
=True)
26 def CustomizeBrowserOptions(self
, options
):
27 options
.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
29 def ValidateAndMeasurePage(self
, page
, tab
, results
):
30 if hasattr(page
, 'Validate'):
31 page
.Validate(tab
, results
)
33 has_gpu_process_js
= 'chrome.gpuBenchmarking.hasGpuProcess()'
34 has_gpu_process
= tab
.EvaluateJavaScript(has_gpu_process_js
)
35 if not has_gpu_process
:
36 raise page_test
.Failure('No GPU process detected')
38 class GpuProcess(gpu_test_base
.TestBase
):
39 """Tests that accelerated content triggers the creation of a GPU process"""
40 test
= GpuProcessValidator
46 def _CreateExpectations(self
):
47 return expectations
.GpuProcessExpectations()
49 def CreateStorySet(self
, options
):
50 story_set
= page_sets
.GpuProcessTestsStorySet(self
.GetExpectations())
51 for page
in story_set
:
52 page
.script_to_evaluate_on_commit
= test_harness_script