Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / test / gpu / gpu_tests / gpu_process.py
blobde5579af2f0f9b28be3e00c0cc0988d93424ed8b
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
5 import gpu_test_base
6 import page_sets
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;
19 """
21 class GpuProcessValidator(gpu_test_base.ValidatorBase):
22 def __init__(self):
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)
32 else:
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
42 @classmethod
43 def Name(cls):
44 return 'gpu_process'
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
53 return story_set