aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2013-06-19 14:14:25 -0700
committerTony Wickham <twickham@google.com>2013-06-25 08:48:36 -0700
commit7dde4b200c490587409e0301e58261210e7a5896 (patch)
treea45180363733fd840566dcb76644dc74508ee32b /src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
parent022f444db92ed15a90b025626d88b3f351695b9f (diff)
downloaddroiddriver-7dde4b200c490587409e0301e58261210e7a5896.tar.gz
Fixed issue with clicking on partially visible elements.
Because UiElement.click() was performed on the center of elements, it didn't work when the element's center was off screen. To fix this, I added a getVisibleBounds() method to UiElement, which is implemented by ViewElement and UiAutomationElement. This method is used in ClickAction to make sure that the click is performed on the visible portion of the element. DeviceUtils was added with getDisplayBounds(). Lastly, UiAutomationContext now holds Instrumentation instead of UiAutomation, which also forced other files to change accordingly. Change-Id: Ic2fd163a9759a0d95bd413b557976ee8a3d044f9
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
index 3facbb2..03c8969 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationDriver.java
@@ -17,6 +17,7 @@
package com.google.android.droiddriver.uiautomation;
import android.app.UiAutomation;
+import android.app.Instrumentation;
import android.graphics.Bitmap;
import android.os.SystemClock;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -38,11 +39,11 @@ public class UiAutomationDriver extends AbstractDroidDriver {
private static final long QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE = 500;// ms
private final UiAutomationContext context;
- private final UiAutomation uiAutomation;
+ private final Instrumentation instrumentation;
- public UiAutomationDriver(UiAutomation uiAutomation) {
- this.uiAutomation = uiAutomation;
- this.context = new UiAutomationContext(uiAutomation);
+ public UiAutomationDriver(Instrumentation instrumentation) {
+ this.instrumentation = instrumentation;
+ this.context = new UiAutomationContext(instrumentation);
}
@Override
@@ -53,13 +54,14 @@ public class UiAutomationDriver extends AbstractDroidDriver {
private AccessibilityNodeInfo getRootNode() {
long timeoutMillis = getPoller().getTimeoutMillis();
try {
- uiAutomation.waitForIdle(QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE, timeoutMillis);
+ getUiAutomation().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 = uiAutomation.getRootInActiveWindow();
+ AccessibilityNodeInfo root = getUiAutomation().getRootInActiveWindow();
if (root != null) {
return root;
}
@@ -75,6 +77,10 @@ public class UiAutomationDriver extends AbstractDroidDriver {
@Override
protected Bitmap takeScreenshot() {
- return uiAutomation.takeScreenshot();
+ return getUiAutomation().takeScreenshot();
+ }
+
+ private UiAutomation getUiAutomation() {
+ return instrumentation.getUiAutomation();
}
}