aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2013-05-20 16:59:02 -0700
committerKevin Jin <kjin@google.com>2013-05-21 11:34:11 -0700
commit7b1b7d4561b60f8b3bcd7c2d592454dd7bfef619 (patch)
treec291d94660f05d3e885781555c42aab2e80d4d4a /src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
parentc96f83c2e617f9f9c4a270258c10c5b46bd9f04e (diff)
downloaddroiddriver-7b1b7d4561b60f8b3bcd7c2d592454dd7bfef619.tar.gz
clean up ConditionCheckers
clearer logging for findElement Change-Id: I53f4d13f6a013b97368d3f7351cffa45c7d0efe6
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
index 2bdf8ef..cf31d4c 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
@@ -21,13 +21,12 @@ import android.os.SystemClock;
import android.view.accessibility.AccessibilityNodeInfo;
import com.google.android.droiddriver.base.AbstractDroidDriver;
-import com.google.android.droiddriver.exceptions.ElementNotFoundException;
+import com.google.android.droiddriver.exceptions.TimeoutException;
/**
* Implementation of a DroidDriver that is driven via the accessibility layer.
*/
public class UiAutomationDriver extends AbstractDroidDriver {
-
private final UiAutomationContext context;
public UiAutomationDriver(UiAutomation uiAutomation) {
@@ -40,14 +39,19 @@ public class UiAutomationDriver extends AbstractDroidDriver {
}
private AccessibilityNodeInfo getRootNode() {
- long end = SystemClock.uptimeMillis() + getPoller().getTimeoutMillis();
- do {
+ int timeoutMillis = getPoller().getTimeoutMillis();
+ long end = SystemClock.uptimeMillis() + timeoutMillis;
+ while (true) {
AccessibilityNodeInfo root = context.getUiAutomation().getRootInActiveWindow();
if (root != null) {
return root;
}
+ if (SystemClock.uptimeMillis() > end) {
+ throw new TimeoutException(
+ String.format("Timed out after %d milliseconds waiting for root AccessibilityNodeInfo",
+ timeoutMillis));
+ }
SystemClock.sleep(250);
- } while (SystemClock.uptimeMillis() < end);
- throw new ElementNotFoundException("Could not find root node!");
+ }
}
}