aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2013-08-05 19:56:58 -0700
committerKevin Jin <kjin@google.com>2013-08-06 17:13:32 -0700
commit21a0001e2426644dd68e6140b5873ebaeafcc3dc (patch)
tree6b1783f3a77ba699520187f39afc226b1a37c1ce /src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
parentf9c6c5063b38b623679e47d7095cccddb0481319 (diff)
downloaddroiddriver-21a0001e2426644dd68e6140b5873ebaeafcc3dc.tar.gz
wait for AccessibilityEvent after injecting events via UiAutomation Change-Id: I3d56e07cf2e7912a21de12d1a7bacd4f33e1bc5a
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
index cfd1488..7efa48e 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
@@ -16,13 +16,12 @@
package com.google.android.droiddriver.uiautomation;
-import android.app.Instrumentation;
import android.app.UiAutomation;
import android.view.InputEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.google.android.droiddriver.InputInjector;
-import com.google.common.base.Preconditions;
+import com.google.android.droiddriver.base.AbstractContext;
import com.google.common.collect.MapMaker;
import java.util.Map;
@@ -30,33 +29,20 @@ import java.util.Map;
/**
* Internal helper for managing all instances.
*/
-public class UiAutomationContext {
- private final Instrumentation instrumentation;
- private final InputInjector injector;
+public class UiAutomationContext extends AbstractContext {
// Maybe we should use Cache instead of Map on memory-constrained devices
private final Map<AccessibilityNodeInfo, UiAutomationElement> map = new MapMaker().weakKeys()
.weakValues().makeMap();
+ private final UiAutomation uiAutomation;
- UiAutomationContext(Instrumentation instrumentation) {
- this.instrumentation = Preconditions.checkNotNull(instrumentation);
- injector = new InputInjector() {
+ UiAutomationContext(final UiAutomation uiAutomation) {
+ super(new InputInjector() {
@Override
public boolean injectInputEvent(InputEvent event) {
- return getUiAutomation().injectInputEvent(event, true /* sync */);
+ return uiAutomation.injectInputEvent(event, true /* sync */);
}
- };
- }
-
- public Instrumentation getInstrumentation() {
- return instrumentation;
- }
-
- public UiAutomation getUiAutomation() {
- return instrumentation.getUiAutomation();
- }
-
- public InputInjector getInjector() {
- return injector;
+ });
+ this.uiAutomation = uiAutomation;
}
public UiAutomationElement getUiElement(AccessibilityNodeInfo node) {
@@ -67,4 +53,13 @@ public class UiAutomationContext {
}
return element;
}
+
+ @Override
+ public void clearData() {
+ map.clear();
+ }
+
+ public UiAutomation getUiAutomation() {
+ return uiAutomation;
+ }
}