0

Added test to check that GPU features are listed as hardware accelerated.

BUG=312395

Review URL: https://codereview.chromium.org/48713005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231497 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
bajones@chromium.org
2013-10-29 03:01:32 +00:00
parent 8f2ef5d63e
commit a48d40b534
2 changed files with 94 additions and 0 deletions

@ -0,0 +1,69 @@
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import hardware_accelerated_feature_expectations as expectations
from telemetry import test
from telemetry.page import page_set
from telemetry.page import page_test
test_harness_script = r"""
function VerifyHardwareAccelerated(feature) {
feature += ': '
var list = document.querySelector('.feature-status-list');
for (var i=0; i < list.childElementCount; i++) {
var span_list = list.children[i].getElementsByTagName('span');
var feature_str = span_list[0].textContent;
var value_str = span_list[1].textContent;
if ((feature_str == feature) &&
(value_str == 'Hardware accelerated')) {
return true;
}
}
return false;
};
""";
class HardwareAcceleratedFeatureValidator(page_test.PageTest):
def __init__(self):
super(HardwareAcceleratedFeatureValidator, self).__init__('ValidatePage')
def ValidatePage(self, page, tab, results):
feature = page.feature
if not tab.EvaluateJavaScript('VerifyHardwareAccelerated("%s")' % feature):
raise page_test.Failure('%s not hardware accelerated' % feature)
def safe_feature_name(feature):
return feature.lower().replace(' ', '_')
class HardwareAcceleratedFeature(test.Test):
"""Tests GPU acceleration is reported as active for various features"""
test = HardwareAcceleratedFeatureValidator
def CreateExpectations(self, page_set):
return expectations.HardwareAcceleratedFeatureExpectations()
def CreatePageSet(self, options):
features = ['WebGL', 'Canvas', '3D CSS']
page_set_dict = {
'description': 'Tests GPU acceleration is reported as active',
'user_agent_type': 'desktop',
'pages': []
}
pages = page_set_dict['pages']
for feature in features:
pages.append({
'name': 'HardwareAcceleratedFeature.%s_accelerated' %
safe_feature_name(feature),
'url': 'chrome://gpu',
'navigate_steps': [
{ "action": 'navigate' }
],
'script_to_evaluate_on_commit': test_harness_script,
'feature': feature
})
return page_set.PageSet.FromDict(page_set_dict, '')

@ -0,0 +1,25 @@
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import test_expectations as expectations
# Valid expectation conditions are:
#
# Operating systems:
# win, xp, vista, win7, mac, leopard, snowleopard, lion, mountainlion,
# linux, chromeos, android
#
# GPU vendors:
# amd, arm, broadcom, hisilicon, intel, imagination, nvidia, qualcomm,
# vivante
#
# Specific GPUs can be listed as a tuple with vendor name and device ID.
# Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604')
# Device IDs must be paired with a GPU vendor.
class HardwareAcceleratedFeatureExpectations(expectations.TestExpectations):
def SetExpectations(self):
# Accelerated 2D canvas is not available on Linux due to driver instability
self.Fail('HardwareAcceleratedFeature.canvas_accelerated',
['linux'], bug=254724)