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

Unified Diff: client/bin/site_utils.py

Issue 1565001: test: Clean up site_login.py a bit. (Closed)
Patch Set: update one more call to attempt_logout() Created 10 years, 9 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: client/bin/site_utils.py
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..50a0bdff94cd94ad048e6f0cdfeebf0771f0292e
--- /dev/null
+++ b/client/bin/site_utils.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import time
+from autotest_lib.client.common_lib import error
+
+
+def poll_for_condition(
+ condition, exception=None, timeout=10, sleep_interval=0.1):
+ """Poll until a condition becomes true.
+
+ condition: function taking no args and returning bool
+ exception: exception to throw if condition doesn't become true
+ timeout: maximum number of seconds to wait
+ sleep_interval: time to sleep between polls
+
+ Raises:
+ 'exception' arg if supplied; error.TestError otherwise
+ """
+ start_time = time.time()
+ while True:
+ if condition():
+ return
+ if time.time() + sleep_interval - start_time > timeout:
+ raise exception if exception else error.TestError(
+ 'Timed out waiting for condition')
+ time.sleep(sleep_interval)
« no previous file with comments | « client/bin/site_ui_test.py ('k') | client/site_tests/desktopui_ChromeFirstRender/desktopui_ChromeFirstRender.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698