Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / test / gpu / gpu_tests / gpu_test_expectations.py
blob28fba8ebe5da4f90943456febda68cd9e24b30bc
1 # Copyright 2014 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.
5 import test_expectations
7 # Valid expectation conditions are:
9 # Operating systems:
10 # win, xp, vista, win7, mac, leopard, snowleopard, lion, mountainlion,
11 # mavericks, yosemite, linux, chromeos, android
13 # GPU vendors:
14 # amd, arm, broadcom, hisilicon, intel, imagination, nvidia, qualcomm,
15 # vivante
17 # Browser types:
18 # android-webview-shell, android-content-shell, debug
20 # ANGLE renderer:
21 # d3d9, d3d11, opengl
23 # Specific GPUs can be listed as a tuple with vendor name and device ID.
24 # Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604')
25 # Device IDs must be paired with a GPU vendor.
27 # Sample usage in SetExpectations in subclasses:
28 # self.Fail('gl-enable-vertex-attrib.html',
29 # ['mac', 'amd', ('nvidia', 0x1234)], bug=123)
31 ANGLE_MODIFIERS = ['d3d9', 'd3d11', 'opengl']
33 BROWSER_TYPE_MODIFIERS = [
34 'android-webview-shell', 'android-content-shell', 'debug' ]
36 class _FlakyExpectation(object):
37 def __init__(self, expectation, max_num_retries):
38 self.expectation = expectation
39 self.max_num_retries = max_num_retries
41 class GpuTestExpectations(test_expectations.TestExpectations):
42 def __init__(self):
43 self._flaky_expectations = []
44 super(GpuTestExpectations, self).__init__()
46 def Flaky(self, url_pattern, conditions=None, bug=None, max_num_retries=2):
47 expectation = _FlakyExpectation(self.CreateExpectation(
48 'pass', url_pattern, conditions, bug), max_num_retries)
49 self._flaky_expectations.append(expectation)
51 def GetFlakyRetriesForPage(self, page, browser):
52 for fe in self._flaky_expectations:
53 e = fe.expectation
54 if self.ExpectationAppliesToPage(e, browser, page):
55 return fe.max_num_retries
56 return 0
58 def IsValidUserDefinedCondition(self, condition):
59 # Add support for d3d9, d3d11 and opengl-specific expectations.
60 if condition in ANGLE_MODIFIERS:
61 return True
62 # Add support for browser-type-specific expectations.
63 if condition in BROWSER_TYPE_MODIFIERS:
64 return True
65 return super(GpuTestExpectations,
66 self).IsValidUserDefinedCondition(condition)
68 def ModifiersApply(self, browser, expectation):
69 if not super(GpuTestExpectations, self).ModifiersApply(
70 browser, expectation):
71 return False
73 # We'll only get here if the OS and GPU matched the expectation.
75 # TODO(kbr): refactor _Expectation to be a public class so that
76 # the GPU-specific properties can be moved into a subclass, and
77 # run the unit tests from this directory on the CQ and the bots.
78 # crbug.com/495868 crbug.com/495870
80 # Check for presence of Android WebView.
81 browser_expectations = [x for x in expectation.user_defined_conditions
82 if x in BROWSER_TYPE_MODIFIERS]
83 browser_matches = ((not browser_expectations) or
84 browser.browser_type in browser_expectations)
85 if not browser_matches:
86 return False
87 angle_renderer = ''
88 gpu_info = None
89 if browser.supports_system_info:
90 gpu_info = browser.GetSystemInfo().gpu
91 if gpu_info and gpu_info.aux_attributes:
92 gl_renderer = gpu_info.aux_attributes.get('gl_renderer')
93 if gl_renderer:
94 if 'Direct3D11' in gl_renderer:
95 angle_renderer = 'd3d11'
96 elif 'Direct3D9' in gl_renderer:
97 angle_renderer = 'd3d9'
98 elif 'OpenGL' in gl_renderer:
99 angle_renderer = 'opengl'
100 angle_expectations = [x for x in expectation.user_defined_conditions
101 if x in ANGLE_MODIFIERS]
102 angle_matches = ((not angle_expectations) or
103 angle_renderer in angle_expectations)
104 return angle_matches