| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 5 |
| 6 def HostOnlyTest(func): | 6 def HostOnlyTest(func): |
| 7 """Decorator for running unit tests only on the host device. | 7 """Decorator for running unit tests only on the host device. |
| 8 | 8 |
| 9 This will disable unit tests from running on Android devices. | 9 This will disable unit tests from running on Android devices. |
| 10 """ | 10 """ |
| 11 return _SkipTestDecoratorHelper(func, ['android']) | 11 return _SkipTestDecoratorHelper(func, ['android']) |
| 12 | 12 |
| 13 | 13 |
| 14 def ClientOnlyTest(func): | 14 def ClientOnlyTest(func): |
| 15 """Decorator for running unit tests only on client devices (Android). | 15 """Decorator for running unit tests only on client devices (Android). |
| 16 """ | 16 """ |
| 17 return _SkipTestDecoratorHelper(func, ['windows', 'linux', 'mac']) | 17 return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac']) |
| 18 |
| 19 |
| 20 def Disabled(func): |
| 21 """Decorator for not running a unit test on any Trybot platform. |
| 22 """ |
| 23 return _SkipTestDecoratorHelper(func, ['win', 'linux', 'mac', 'android']) |
| 18 | 24 |
| 19 | 25 |
| 20 def _SkipTestDecoratorHelper(func, disabled_strings): | 26 def _SkipTestDecoratorHelper(func, disabled_strings): |
| 21 if not hasattr(func, '_disabled_strings'): | 27 if not hasattr(func, '_disabled_strings'): |
| 22 setattr(func, '_disabled_strings', set(disabled_strings)) | 28 setattr(func, '_disabled_strings', set(disabled_strings)) |
| 23 return func | 29 return func |
| 24 | 30 |
| 25 | 31 |
| 26 def ShouldSkip(test, device): | 32 def ShouldSkip(test, device): |
| 27 """Returns whether the test should be skipped and the reason for it.""" | 33 """Returns whether the test should be skipped and the reason for it.""" |
| 28 if hasattr(test, '_disabled_strings'): | 34 if hasattr(test, '_disabled_strings'): |
| 29 disabled_devices = getattr(test, '_disabled_strings') | 35 disabled_devices = getattr(test, '_disabled_strings') |
| 30 return device in disabled_devices | 36 return device in disabled_devices |
| 31 return False | 37 return False |
| OLD | NEW |