OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 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 |
| 5 from gpu_tests import gpu_integration_test |
| 6 import gpu_tests.hardware_accelerated_feature_expectations as hw_expectations |
| 7 |
| 8 test_harness_script = r""" |
| 9 function VerifyHardwareAccelerated(feature) { |
| 10 feature += ': ' |
| 11 var list = document.querySelector('.feature-status-list'); |
| 12 for (var i=0; i < list.childElementCount; i++) { |
| 13 var span_list = list.children[i].getElementsByTagName('span'); |
| 14 var feature_str = span_list[0].textContent; |
| 15 var value_str = span_list[1].textContent; |
| 16 if ((feature_str == feature) && |
| 17 (value_str == 'Hardware accelerated')) { |
| 18 return true; |
| 19 } |
| 20 } |
| 21 return false; |
| 22 }; |
| 23 """ |
| 24 |
| 25 def safe_feature_name(feature): |
| 26 return feature.lower().replace(' ', '_') |
| 27 |
| 28 class HardwareAcceleratedFeatureIntegrationTest( |
| 29 gpu_integration_test.GpuIntegrationTest): |
| 30 """Tests GPU acceleration is reported as active for various features.""" |
| 31 |
| 32 @classmethod |
| 33 def Name(cls): |
| 34 """The name by which this test is invoked on the command line.""" |
| 35 return 'hardware_accelerated_feature' |
| 36 |
| 37 @classmethod |
| 38 def setUpClass(cls): |
| 39 super(cls, HardwareAcceleratedFeatureIntegrationTest).setUpClass() |
| 40 cls.SetBrowserOptions(cls._finder_options) |
| 41 cls.StartBrowser() |
| 42 cls.SetStaticServerDirs([]) |
| 43 |
| 44 @classmethod |
| 45 def _CreateExpectations(cls): |
| 46 return hw_expectations.HardwareAcceleratedFeatureExpectations() |
| 47 |
| 48 def _Navigate(self, url): |
| 49 # It's crucial to use the action_runner, rather than the tab's |
| 50 # Navigate method directly. It waits for the document ready state |
| 51 # to become interactive or better, avoiding critical race |
| 52 # conditions. |
| 53 self.tab.action_runner.Navigate( |
| 54 url, script_to_evaluate_on_commit=test_harness_script) |
| 55 |
| 56 @classmethod |
| 57 def GenerateGpuTests(cls, options): |
| 58 tests = ('WebGL', 'Canvas') |
| 59 for feature in tests: |
| 60 yield('HardwareAcceleratedFeature_%s_accelerated' % |
| 61 safe_feature_name(feature), |
| 62 'chrome://gpu', |
| 63 (feature)) |
| 64 |
| 65 def RunActualGpuTest(self, test_path, *args): |
| 66 feature = args[0] |
| 67 self._Navigate(test_path) |
| 68 tab = self.tab |
| 69 if not tab.EvaluateJavaScript('VerifyHardwareAccelerated("%s")' % feature): |
| 70 print 'Test failed. Printing page contents:' |
| 71 print tab.EvaluateJavaScript('document.body.innerHTML') |
| 72 self.fail('%s not hardware accelerated' % feature) |
OLD | NEW |