diff options
author | Kevin Jin <kjin@google.com> | 2013-08-05 19:56:58 -0700 |
---|---|---|
committer | Kevin Jin <kjin@google.com> | 2013-08-06 17:13:32 -0700 |
commit | 21a0001e2426644dd68e6140b5873ebaeafcc3dc (patch) | |
tree | 6b1783f3a77ba699520187f39afc226b1a37c1ce /src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java | |
parent | f9c6c5063b38b623679e47d7095cccddb0481319 (diff) | |
download | droiddriver-21a0001e2426644dd68e6140b5873ebaeafcc3dc.tar.gz |
clear internal data while refreshing rootandroid-sdk-4.4.2_r1.0.1android-sdk-4.4.2_r1android-cts-4.4_r4android-cts-4.4_r1android-4.4w_r1android-4.4_r1.2.0.1android-4.4_r1.2android-4.4_r1.1.0.1android-4.4_r1.1android-4.4_r1.0.1android-4.4_r1android-4.4_r0.9android-4.4_r0.8android-4.4_r0.7android-4.4.4_r2.0.1android-4.4.4_r2android-4.4.4_r1.0.1android-4.4.4_r1android-4.4.3_r1.1.0.1android-4.4.3_r1.1android-4.4.3_r1.0.1android-4.4.3_r1android-4.4.2_r2.0.1android-4.4.2_r2android-4.4.2_r1.0.1android-4.4.2_r1android-4.4.1_r1.0.1android-4.4.1_r1kitkat-wearkitkat-releasekitkat-mr2.2-releasekitkat-mr2.1-releasekitkat-mr2-releasekitkat-mr1.1-releasekitkat-mr1-releasekitkat-devkitkat-cts-releasekitkat-cts-dev
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.java | 39 |
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; + } } |