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

Unified Diff: build/android/pylib/device/decorators_test.py

Issue 294113003: [Android] Convert to DeviceUtils versions of WaitUntilFullyBooted and GetExternalStoragePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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: build/android/pylib/device/decorators_test.py
diff --git a/build/android/pylib/device/decorators_test.py b/build/android/pylib/device/decorators_test.py
index 53bb281401958b152967ff5799028e56e3c4244a..3ec5e4e2dc635c0d4d86a05b888d97e2725afb35 100644
--- a/build/android/pylib/device/decorators_test.py
+++ b/build/android/pylib/device/decorators_test.py
@@ -109,6 +109,22 @@ class DecoratorsTest(unittest.TestCase):
alwaysRaisesCommandFailedError(retries=5)
self.assertEquals(6, DecoratorsTest._decorated_function_called_count)
+ def testDefaultsFunctionDecoratorPassesValues(self):
+ """Tests that the defaults decorator passes timeout and retries kwargs."""
+ @decorators.WithTimeoutAndRetriesDefaults(30, 10)
+ def alwaysReturnsTimeouts(timeout=None, retries=None):
+ return timeout
+
+ self.assertEquals(30, alwaysReturnsTimeouts())
+ self.assertEquals(120, alwaysReturnsTimeouts(timeout=120))
+
+ @decorators.WithTimeoutAndRetriesDefaults(30, 10)
+ def alwaysReturnsRetries(timeout=None, retries=None):
+ return retries
+
+ self.assertEquals(10, alwaysReturnsRetries())
+ self.assertEquals(1, alwaysReturnsRetries(retries=1))
+
def testExplicitFunctionDecoratorDoesTimeouts(self):
"""Tests that the explicit decorator handles timeout logic."""
DecoratorsTest._decorated_function_called_count = 0
@@ -165,6 +181,20 @@ class DecoratorsTest(unittest.TestCase):
raise device_errors.CommandFailedError(['testCommand'],
'testCommand failed')
+ # pylint: disable=R0201
+
+ @decorators.WithTimeoutAndRetriesFromInstance(
+ 'default_timeout', 'default_retries')
+ def alwaysReturnsTimeout(self, timeout=None, retries=None):
+ return timeout
+
+ @decorators.WithTimeoutAndRetriesFromInstance(
+ 'default_timeout', 'default_retries')
+ def alwaysReturnsRetries(self, timeout=None, retries=None):
+ return retries
+
+ # pylint: enable=R0201
+
def testMethodDecoratorDoesTimeout(self):
"""Tests that the method decorator handles timeout logic."""
@@ -181,7 +211,7 @@ class DecoratorsTest(unittest.TestCase):
self.assertEquals(1, test_obj.function_call_counters['alwaysTimesOut'])
def testMethodDecoratorDoesRetries(self):
- """ Tests that the method decorator handles retries logic."""
+ """Tests that the method decorator handles retries logic."""
test_obj = self._MethodDecoratorTestObject(self)
with self.assertRaises(device_errors.CommandFailedError):
try:
@@ -192,6 +222,15 @@ class DecoratorsTest(unittest.TestCase):
self.assertEquals(
11, test_obj.function_call_counters['alwaysRaisesCommandFailedError'])
+ def testMethodDecoratorPassesValues(self):
+ """Tests that the method decorator passes timeout and retries kwargs."""
+ test_obj = self._MethodDecoratorTestObject(
+ self, default_timeout=42, default_retries=31)
+ self.assertEquals(42, test_obj.alwaysReturnsTimeout())
+ self.assertEquals(41, test_obj.alwaysReturnsTimeout(timeout=41))
+ self.assertEquals(31, test_obj.alwaysReturnsRetries())
+ self.assertEquals(32, test_obj.alwaysReturnsRetries(retries=32))
+
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698