aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2013-05-29 12:07:36 -0700
committerKevin Jin <kjin@google.com>2013-05-29 14:44:05 -0700
commitdc5bb6b7cd5111a5c082ef7bc6e46a95d17de8e5 (patch)
tree959b8716af0f285fcd6ed19c3c257c9b89947c4c /src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
parent0858f7292b7e7f32c25662d853c9d8ed8db1403f (diff)
downloaddroiddriver-dc5bb6b7cd5111a5c082ef7bc6e46a95d17de8e5.tar.gz
change type of millis int->long
Change-Id: Ibcd6be9ea429f665a653f3aa1b3c6a27d3d84766
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
index d027f09..9a42a02 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
@@ -22,6 +22,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.google.android.droiddriver.base.AbstractDroidDriver;
import com.google.android.droiddriver.exceptions.TimeoutException;
+import com.google.common.primitives.Longs;
/**
* Implementation of a DroidDriver that is driven via the accessibility layer.
@@ -49,7 +50,7 @@ public class UiAutomationDriver extends AbstractDroidDriver {
}
private AccessibilityNodeInfo getRootNode() {
- int timeoutMillis = getPoller().getTimeoutMillis();
+ long timeoutMillis = getPoller().getTimeoutMillis();
try {
uiAutomation.waitForIdle(QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE, timeoutMillis);
} catch (java.util.concurrent.TimeoutException e) {
@@ -61,12 +62,13 @@ public class UiAutomationDriver extends AbstractDroidDriver {
if (root != null) {
return root;
}
- if (SystemClock.uptimeMillis() > end) {
+ long remainingMillis = end - SystemClock.uptimeMillis();
+ if (remainingMillis < 0) {
throw new TimeoutException(
String.format("Timed out after %d milliseconds waiting for root AccessibilityNodeInfo",
timeoutMillis));
}
- SystemClock.sleep(250);
+ SystemClock.sleep(Longs.min(250, remainingMillis));
}
}
}