aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2013-05-22 13:26:01 -0700
committerKevin Jin <kjin@google.com>2013-05-22 13:26:01 -0700
commitc1a957dbec671deb711d2f69cf326dc97f339f66 (patch)
treeb66f74cfe47087d6622b3918b569a8c0f2eee9db /src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
parent7b1b7d4561b60f8b3bcd7c2d592454dd7bfef619 (diff)
downloaddroiddriver-c1a957dbec671deb711d2f69cf326dc97f339f66.tar.gz
sync with UiAutomation.executeAndWaitForEvent
This solves the clicking DrawerLayout problem, but we need to find the exact cause to solve the general problem. Also add logging for Events Change-Id: I0cba140021b676cb1d13c3fe3d319c2cca535ccd
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
index cf31d4c..d027f09 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
@@ -27,9 +27,19 @@ import com.google.android.droiddriver.exceptions.TimeoutException;
* Implementation of a DroidDriver that is driven via the accessibility layer.
*/
public class UiAutomationDriver extends AbstractDroidDriver {
+ // TODO: magic const from UiAutomator, but may not be useful
+ /**
+ * This value has the greatest bearing on the appearance of test execution
+ * speeds. This value is used as the minimum time to wait before considering
+ * the UI idle after each action.
+ */
+ private static final long QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE = 500;// ms
+
private final UiAutomationContext context;
+ private final UiAutomation uiAutomation;
public UiAutomationDriver(UiAutomation uiAutomation) {
+ this.uiAutomation = uiAutomation;
this.context = new UiAutomationContext(uiAutomation);
}
@@ -40,9 +50,14 @@ public class UiAutomationDriver extends AbstractDroidDriver {
private AccessibilityNodeInfo getRootNode() {
int timeoutMillis = getPoller().getTimeoutMillis();
+ try {
+ uiAutomation.waitForIdle(QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE, timeoutMillis);
+ } catch (java.util.concurrent.TimeoutException e) {
+ throw new TimeoutException(e);
+ }
long end = SystemClock.uptimeMillis() + timeoutMillis;
while (true) {
- AccessibilityNodeInfo root = context.getUiAutomation().getRootInActiveWindow();
+ AccessibilityNodeInfo root = uiAutomation.getRootInActiveWindow();
if (root != null) {
return root;
}