Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: tools/chrome_proxy/webdriver/decorators.py

Issue 2823253002: Refactor decorators into thier own python class (Closed)
Patch Set: Forgot to add new decorators class Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/chrome_proxy/webdriver/decorators.py
diff --git a/tools/chrome_proxy/webdriver/decorators.py b/tools/chrome_proxy/webdriver/decorators.py
new file mode 100644
index 0000000000000000000000000000000000000000..5da3650523d7dc0cbfe7a41c8f4e27ee38b0440b
--- /dev/null
+++ b/tools/chrome_proxy/webdriver/decorators.py
@@ -0,0 +1,74 @@
+# Copyright 2017 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 common import ParseFlags
+
+
+# Platform-specific decorators.
+# These decorators can be used to only run a test function for certain platforms
+# by annotating the function with them.
+
+def AndroidOnly(func):
+ def wrapper(*args, **kwargs):
+ if ParseFlags().android:
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test runs on Android only.')
+ return wrapper
+
+def NotAndroid(func):
+ def wrapper(*args, **kwargs):
+ if not ParseFlags().android:
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test does not run on Android.')
+ return wrapper
+
+def WindowsOnly(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform == 'win32':
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test runs on Windows only.')
+ return wrapper
+
+def NotWindows(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform != 'win32':
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test does not run on Windows.')
+ return wrapper
+
+def LinuxOnly(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform.startswith('linux'):
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test runs on Linux only.')
+ return wrapper
+
+def NotLinux(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform.startswith('linux'):
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test does not run on Linux.')
+ return wrapper
+
+def MacOnly(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform == 'darwin':
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test runs on Mac OS only.')
+ return wrapper
+
+def NotMac(func):
+ def wrapper(*args, **kwargs):
+ if sys.platform == 'darwin':
+ func(*args, **kwargs)
+ else:
+ args[0].skipTest('This test does not run on Mac OS.')
+ return wrapper

Powered by Google App Engine
This is Rietveld 408576698