| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import fnmatch | 5 import fnmatch |
| 6 import urlparse | 6 import urlparse |
| 7 | 7 |
| 8 # Valid expectation conditions are: | 8 # Valid expectation conditions are: |
| 9 # | 9 # |
| 10 # Operating systems: | 10 # Operating systems: |
| 11 # win, xp, vista, win7, win8, win10, mac, leopard, snowleopard, | 11 # win, xp, vista, win7, win8, win10, mac, leopard, snowleopard, |
| 12 # lion, mountainlion, mavericks, yosemite, linux, chromeos, | 12 # lion, mountainlion, mavericks, yosemite, linux, chromeos, |
| 13 # android | 13 # android |
| 14 # | 14 # |
| 15 # Browser types: | 15 # Browser types: |
| 16 # android-webview-shell, android-content-shell, debug, release | 16 # android-webview-shell, android-content-shell, debug, release |
| 17 # | 17 # |
| 18 # Sample usage in SetExpectations in subclasses: | 18 # Sample usage in SetExpectations in subclasses: |
| 19 # self.Fail('gl-enable-vertex-attrib.html', | 19 # self.Fail('gl-enable-vertex-attrib.html', |
| 20 # ['mac', 'release'], bug=123) | 20 # ['mac', 'release'], bug=123) |
| 21 | 21 |
| 22 WIN_CONDITIONS = ['xp', 'vista', 'win7', 'win8', 'win10'] | 22 WIN_CONDITIONS = ['xp', 'vista', 'win7', 'win8', 'win10'] |
| 23 MAC_CONDITIONS = ['leopard', 'snowleopard', 'lion', 'mountainlion', | 23 MAC_CONDITIONS = ['leopard', 'snowleopard', 'lion', 'mountainlion', |
| 24 'mavericks', 'yosemite'] | 24 'mavericks', 'yosemite'] |
| 25 | 25 |
| 26 OS_CONDITIONS = ['win', 'mac', 'linux', 'chromeos', 'android'] + \ | 26 OS_CONDITIONS = ['win', 'mac', 'linux', 'chromeos', 'android'] + \ |
| 27 WIN_CONDITIONS + MAC_CONDITIONS | 27 WIN_CONDITIONS + MAC_CONDITIONS |
| 28 | 28 |
| 29 BROWSER_TYPE_CONDITIONS = [ | 29 BROWSER_TYPE_CONDITIONS = [ |
| 30 'android-webview-shell', 'android-content-shell', 'debug', 'release'] | 30 'android-webview-shell', 'android-content-shell', 'android-chromium', |
| 31 'debug', 'release'] |
| 31 | 32 |
| 32 class Expectation(object): | 33 class Expectation(object): |
| 33 """Represents a single test expectation for a page. | 34 """Represents a single test expectation for a page. |
| 34 | 35 |
| 35 Supports conditions based on operating system (e.g., win, mac) and | 36 Supports conditions based on operating system (e.g., win, mac) and |
| 36 browser type (e.g. 'debug', 'release'). | 37 browser type (e.g. 'debug', 'release'). |
| 37 | 38 |
| 38 Subclass this class and call super.__init__ last in your constructor | 39 Subclass this class and call super.__init__ last in your constructor |
| 39 in order to add new user-defined conditions. The conditions are | 40 in order to add new user-defined conditions. The conditions are |
| 40 parsed at the end of this class's constructor, so be careful not to | 41 parsed at the end of this class's constructor, so be careful not to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 62 implementation will raise an exception if the condition is | 63 implementation will raise an exception if the condition is |
| 63 unsupported. | 64 unsupported. |
| 64 | 65 |
| 65 Valid expectation conditions are: | 66 Valid expectation conditions are: |
| 66 | 67 |
| 67 Operating systems: | 68 Operating systems: |
| 68 win, xp, vista, win7, mac, leopard, snowleopard, lion, | 69 win, xp, vista, win7, mac, leopard, snowleopard, lion, |
| 69 mountainlion, mavericks, yosemite, linux, chromeos, android | 70 mountainlion, mavericks, yosemite, linux, chromeos, android |
| 70 | 71 |
| 71 Browser types: | 72 Browser types: |
| 72 android-webview-shell, android-content-shell, debug, release | 73 android-webview-shell, android-content-shell, android-chromium, |
| 74 debug, release |
| 73 | 75 |
| 74 Sample usage in SetExpectations in subclasses: | 76 Sample usage in SetExpectations in subclasses: |
| 75 self.Fail('gl-enable-vertex-attrib.html', | 77 self.Fail('gl-enable-vertex-attrib.html', |
| 76 ['mac', 'release'], bug=123) | 78 ['mac', 'release'], bug=123) |
| 77 """ | 79 """ |
| 78 cl = condition.lower() | 80 cl = condition.lower() |
| 79 if cl in OS_CONDITIONS: | 81 if cl in OS_CONDITIONS: |
| 80 self.os_conditions.append(cl) | 82 self.os_conditions.append(cl) |
| 81 elif cl in BROWSER_TYPE_CONDITIONS: | 83 elif cl in BROWSER_TYPE_CONDITIONS: |
| 82 self.browser_conditions.append(condition) | 84 self.browser_conditions.append(condition) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 platform = browser.platform | 255 platform = browser.platform |
| 254 os_matches = (not expectation.os_conditions or | 256 os_matches = (not expectation.os_conditions or |
| 255 platform.GetOSName() in expectation.os_conditions or | 257 platform.GetOSName() in expectation.os_conditions or |
| 256 platform.GetOSVersionName() in expectation.os_conditions) | 258 platform.GetOSVersionName() in expectation.os_conditions) |
| 257 | 259 |
| 258 browser_matches = ( | 260 browser_matches = ( |
| 259 (not expectation.browser_conditions) or | 261 (not expectation.browser_conditions) or |
| 260 browser.browser_type in expectation.browser_conditions) | 262 browser.browser_type in expectation.browser_conditions) |
| 261 | 263 |
| 262 return os_matches and browser_matches | 264 return os_matches and browser_matches |
| OLD | NEW |