Merge "Update MediaDrm exception handling" into jb-mr2-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index ed155c0..112c8ad 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -31,7 +31,6 @@
cts_support_packages := \
$(PTS_SUPPORT_PACKAGES) \
CtsAccelerationTestStubs \
- CtsDelegatingAccessibilityService \
CtsDeviceAdmin \
CtsMonkeyApp \
CtsMonkeyApp2 \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 9b8d5b1..9ff7edc 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="1"
- android:versionName="1337">
+ android:versionName="4.3_r1">
<!-- Using 10 for more complete NFC support... -->
<uses-sdk android:minSdkVersion="10"></uses-sdk>
diff --git a/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java b/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java
index 5e2e8e0..8257602 100644
--- a/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java
+++ b/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java
@@ -358,23 +358,30 @@
for (int i = 0; i < 100; i++) {
getDevice().executeShellCommand(String.format("log testGetLogcat_size log dump %d", i));
}
- // sleep a small amount of time to ensure last log message makes it into capture
- RunUtil.getDefault().sleep(10);
- InputStreamSource source = getDevice().getLogcat(100 * 1024);
- assertNotNull(source);
- File tmpTxtFile = FileUtil.createTempFile("logcat", ".txt");
- try {
- FileUtil.writeToFile(source.createInputStream(), tmpTxtFile);
- CLog.i("Created file at %s", tmpTxtFile.getAbsolutePath());
- assertEquals("Saved text file is not equal to buffer size", 100 * 1024,
- tmpTxtFile.length());
- // ensure last log message is present in log
- String s = FileUtil.readStringFromFile(tmpTxtFile);
- assertTrue("last log message is not in captured logcat",
- s.contains("testGetLogcat_size log dump 99"));
- } finally {
- FileUtil.deleteFile(tmpTxtFile);
- source.cancel();
+ boolean passed = false;
+ int retry = 0;
+ while (!passed) {
+ // sleep a small amount of time to ensure last log message makes it into capture
+ RunUtil.getDefault().sleep(10);
+ InputStreamSource source = getDevice().getLogcat(100 * 1024);
+ assertNotNull(source);
+ File tmpTxtFile = FileUtil.createTempFile("logcat", ".txt");
+ try {
+ FileUtil.writeToFile(source.createInputStream(), tmpTxtFile);
+ CLog.i("Created file at %s", tmpTxtFile.getAbsolutePath());
+ // ensure last log message is present in log
+ String s = FileUtil.readStringFromFile(tmpTxtFile);
+ if (s.contains("testGetLogcat_size log dump 99")) {
+ passed = true;
+ }
+ } finally {
+ FileUtil.deleteFile(tmpTxtFile);
+ source.cancel();
+ }
+ retry++;
+ if ((retry > 100) && !passed) {
+ fail("last log message is not in captured logcat");
+ }
}
}
}
diff --git a/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java b/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
index 8f6860f..62b0163 100644
--- a/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
+++ b/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
@@ -35,11 +35,14 @@
*/
public class BandwidthTest extends PtsAndroidTestCase {
private static final String TAG = "BandwidthTest";
- private static final int REPETITION = 10;
+ private static final int MEMCPY_REPETITION = 10;
+ private static final int MEMSET_REPETITION = 30;
private static final int REPEAT_IN_EACH_CALL = 100;
private static final int KB = 1024;
private static final int MB = 1024 * 1024;
private static final int MEMSET_CHAR = 0xa5;
+ // reject data outside +/- this value * median
+ private static final double OUTLIER_THRESHOLD = 0.1;
@Override
protected void setUp() throws Exception {
@@ -153,13 +156,13 @@
}
private void doRunMemcpy(int bufferSize) {
- double[] result = new double[REPETITION];
+ double[] result = new double[MEMCPY_REPETITION];
int repeatInEachCall = REPEAT_IN_EACH_CALL;
if (bufferSize < (1 * MB)) {
// too small buffer size finishes too early to give accurate result.
repeatInEachCall *= (1 * MB / bufferSize);
}
- for (int i = 0; i < REPETITION; i++) {
+ for (int i = 0; i < MEMCPY_REPETITION; i++) {
result[i] = MemoryNative.runMemcpy(bufferSize, repeatInEachCall);
}
getReportLog().printArray("memcpy time", result, ResultType.LOWER_BETTER,
@@ -168,7 +171,10 @@
(double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
getReportLog().printArray("memcpy throughput", mbps, ResultType.HIGHER_BETTER,
ResultUnit.MBPS);
- Stat.StatResult stat = Stat.getStat(mbps);
+ Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
+ if (stat.mDataCount != result.length) {
+ Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
+ }
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Point size = new Point();
wm.getDefaultDisplay().getSize(size);
@@ -183,13 +189,13 @@
}
private void doRunMemset(int bufferSize) {
- double[] result = new double[REPETITION];
+ double[] result = new double[MEMSET_REPETITION];
int repeatInEachCall = REPEAT_IN_EACH_CALL;
if (bufferSize < (1 * MB)) {
// too small buffer size finishes too early to give accurate result.
repeatInEachCall *= (1 * MB / bufferSize);
}
- for (int i = 0; i < REPETITION; i++) {
+ for (int i = 0; i < MEMSET_REPETITION; i++) {
result[i] = MemoryNative.runMemset(bufferSize, repeatInEachCall, MEMSET_CHAR);
}
getReportLog().printArray("memset time", result, ResultType.LOWER_BETTER,
@@ -198,7 +204,10 @@
(double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
getReportLog().printArray("memset throughput", mbps, ResultType.HIGHER_BETTER,
ResultUnit.MBPS);
- Stat.StatResult stat = Stat.getStat(mbps);
+ Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
+ if (stat.mDataCount != result.length) {
+ Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
+ }
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Point size = new Point();
wm.getDefaultDisplay().getSize(size);
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
index d698b4b..25dd014 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
@@ -287,6 +287,7 @@
@Override
public void run(int i) throws IOException {
+ Log.i(TAG, "starting " + i + " -th round");
int start = i * readsInOneMeasure;
int end = (i + 1) * readsInOneMeasure;
for (int j = start; j < end; j++) {
@@ -339,6 +340,7 @@
@Override
public void run(int i) throws IOException {
+ Log.i(TAG, "starting " + i + " -th round");
int start = i * writesInOneMeasure;
int end = (i + 1) * writesInOneMeasure;
for (int j = start; j < end; j++) {
@@ -378,6 +380,7 @@
int numberRepeatInOneRun = (int)(fileSize / bufferSize);
double[] mbpsAll = new double[numberRepetition * numberRepeatInOneRun];
for (int i = 0; i < numberRepetition; i++) {
+ Log.i(TAG, "starting " + i + " -th round");
final RandomAccessFile randomFile = new RandomAccessFile(file, "rwd"); // force O_SYNC
randomFile.seek(0L);
double[] times = MeasureTime.measure(numberRepeatInOneRun, new MeasureRun() {
diff --git a/suite/pts/deviceTests/opengl/AndroidManifest.xml b/suite/pts/deviceTests/opengl/AndroidManifest.xml
index dc906c8..7cfebaa 100644
--- a/suite/pts/deviceTests/opengl/AndroidManifest.xml
+++ b/suite/pts/deviceTests/opengl/AndroidManifest.xml
@@ -5,14 +5,14 @@
android:versionName="1.0" >
<uses-sdk
- android:targetSdkVersion="17"
- android:minSdkVersion="16" />
+ android:minSdkVersion="16"
+ android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />\
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application android:allowBackup="false" >
@@ -20,6 +20,7 @@
<activity
android:name="com.android.pts.opengl.primitive.GLPrimitiveActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -27,18 +28,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
- android:name="com.android.pts.opengl.reference.GLReferenceActivity" >
+ android:name="com.android.pts.opengl.reference.GLReferenceActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
<activity
android:name="com.android.pts.opengl.reference.GLGameActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
</application>
diff --git a/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java b/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
index 8b17171..8278618 100644
--- a/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
+++ b/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
@@ -17,6 +17,7 @@
package com.android.pts.simplecpu;
import android.cts.util.TimeoutReq;
+import android.util.Log;
import com.android.pts.util.ResultType;
import com.android.pts.util.ResultUnit;
@@ -35,6 +36,8 @@
private static final int KB = 1024;
private static final int MB = 1024 * 1024;
private static final int NUMBER_REPEAT = 20;
+ // reject data outside +/- this value * median
+ private static final double OUTLIER_THRESHOLD = 0.1;
@Override
protected void setUp() throws Exception {
@@ -99,7 +102,10 @@
}
getReportLog().printArray("sorting time", result, ResultType.LOWER_BETTER,
ResultUnit.MS);
- Stat.StatResult stat = Stat.getStat(result);
+ Stat.StatResult stat = Stat.getStatWithOutlierRejection(result, OUTLIER_THRESHOLD);
+ if (stat.mDataCount != result.length) {
+ Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
+ }
getReportLog().printSummary("sorting time", stat.mAverage, ResultType.LOWER_BETTER,
ResultUnit.MS);
}
@@ -118,7 +124,10 @@
}
getReportLog().printArray("matrix mutiplication time", result, ResultType.LOWER_BETTER,
ResultUnit.MS);
- Stat.StatResult stat = Stat.getStat(result);
+ Stat.StatResult stat = Stat.getStatWithOutlierRejection(result, OUTLIER_THRESHOLD);
+ if (stat.mDataCount != result.length) {
+ Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
+ }
getReportLog().printSummary("matrix mutiplication time", stat.mAverage,
ResultType.LOWER_BETTER, ResultUnit.MS);
}
diff --git a/suite/pts/deviceTests/ui/AndroidManifest.xml b/suite/pts/deviceTests/ui/AndroidManifest.xml
index 6925b5d..639e3d6 100644
--- a/suite/pts/deviceTests/ui/AndroidManifest.xml
+++ b/suite/pts/deviceTests/ui/AndroidManifest.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!--
+ Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,25 +16,32 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.pts.ui">
+ package="com.android.pts.ui" >
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application>
<uses-library android:name="android.test.runner" />
+
<activity
- android:name=".ScrollingActivity"
- android:screenOrientation="portrait"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
+ android:name=".ScrollingActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
+ android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER"/>
+
+ <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name="android.openglperf.cts.GlPlanetsActivity" />
+ <activity
+ android:name="android.openglperf.cts.GlPlanetsActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
</application>
- <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
- android:targetPackage="com.android.pts.ui"
- android:label="UI Latency measurement" />
-</manifest>
+
+ <instrumentation
+ android:name="android.test.InstrumentationCtsTestRunner"
+ android:label="UI Latency measurement"
+ android:targetPackage="com.android.pts.ui" />
+
+</manifest>
\ No newline at end of file
diff --git a/suite/pts/hostTests/uihost/appA/AndroidManifest.xml b/suite/pts/hostTests/uihost/appA/AndroidManifest.xml
index 1115ee6..4491210 100644
--- a/suite/pts/hostTests/uihost/appA/AndroidManifest.xml
+++ b/suite/pts/hostTests/uihost/appA/AndroidManifest.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!--
+ Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,19 +16,21 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.pts.taskswitching.appa">
+ package="com.android.pts.taskswitching.appa" >
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<activity
- android:name=".AppAActivity"
- android:screenOrientation="portrait"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
+ android:name=".AppAActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
+ android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER"/>
+
+ <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
-</manifest>
+
+</manifest>
\ No newline at end of file
diff --git a/suite/pts/hostTests/uihost/appB/AndroidManifest.xml b/suite/pts/hostTests/uihost/appB/AndroidManifest.xml
index d0ec4d7..29bf661 100644
--- a/suite/pts/hostTests/uihost/appB/AndroidManifest.xml
+++ b/suite/pts/hostTests/uihost/appB/AndroidManifest.xml
@@ -21,9 +21,10 @@
<application>
<activity
- android:name=".AppBActivity"
- android:screenOrientation="portrait"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
+ android:name=".AppBActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
+ android:screenOrientation="portrait" >
+
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
diff --git a/suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java b/suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java
index d56f59e..5560292 100644
--- a/suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java
@@ -16,6 +16,8 @@
package com.android.pts.util;
+import java.util.Arrays;
+
/**
* Utilities for doing statistics
*
@@ -30,11 +32,13 @@
public double mMin;
public double mMax;
public double mStddev;
- public StatResult(double average, double min, double max, double stddev) {
+ public int mDataCount;
+ public StatResult(double average, double min, double max, double stddev, int dataCount) {
mAverage = average;
mMin = min;
mMax = max;
mStddev = stddev;
+ mDataCount = dataCount;
}
}
@@ -60,7 +64,58 @@
eX2 /= data.length;
// stddev = sqrt(E[X^2] - (E[X])^2)
double stddev = Math.sqrt(eX2 - average * average);
- return new StatResult(average, min, max, stddev);
+ return new StatResult(average, min, max, stddev, data.length);
+ }
+
+ /**
+ * Calculate statistics properties likes average, min, max, and stddev for the given array
+ * while rejecting outlier +/- median * rejectionThreshold.
+ * rejectionThreshold should be bigger than 0.0 and be lowerthan 1.0
+ */
+ public static StatResult getStatWithOutlierRejection(double[] data, double rejectionThreshold) {
+ double[] dataCopied = Arrays.copyOf(data, data.length);
+ Arrays.sort(dataCopied);
+ int medianIndex = dataCopied.length / 2;
+ double median;
+ if (dataCopied.length % 2 == 1) {
+ median = dataCopied[medianIndex];
+ } else {
+ median = (dataCopied[medianIndex - 1] + dataCopied[medianIndex]) / 2.0;
+ }
+ double thresholdMin = median * (1.0 - rejectionThreshold);
+ double thresholdMax = median * (1.0 + rejectionThreshold);
+
+ double average = 0.0;
+ double min = median;
+ double max = median;
+ double eX2 = 0.0; // will become E[X^2]
+ int validDataCounter = 0;
+ for (int i = 0; i < data.length; i++) {
+ if ((data[i] > thresholdMin) && (data[i] < thresholdMax)) {
+ validDataCounter++;
+ average += data[i];
+ eX2 += data[i] * data[i];
+ if (data[i] > max) {
+ max = data[i];
+ }
+ if (data[i] < min) {
+ min = data[i];
+ }
+ }
+ //TODO report rejected data
+ }
+ double stddev;
+ if (validDataCounter > 0) {
+ average /= validDataCounter;
+ eX2 /= validDataCounter;
+ // stddev = sqrt(E[X^2] - (E[X])^2)
+ stddev = Math.sqrt(eX2 - average * average);
+ } else { // both median is showing too much diff
+ average = median;
+ stddev = 0; // don't care
+ }
+
+ return new StatResult(average, min, max, stddev, validDataCounter);
}
/**
diff --git a/tests/accessibility/res/xml/speaking_accessibilityservice.xml b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
index d43d3e7..d8eaf55 100644
--- a/tests/accessibility/res/xml/speaking_accessibilityservice.xml
+++ b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
@@ -17,4 +17,5 @@
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagDefault|flagRequestTouchExplorationMode"
- android:canRetrieveWindowContent="true" />
+ android:canRetrieveWindowContent="true"
+ android:canRequestTouchExplorationMode="true" />
diff --git a/tests/accessibility/res/xml/vibrating_accessibilityservice.xml b/tests/accessibility/res/xml/vibrating_accessibilityservice.xml
index c2f8799..2219ee7 100644
--- a/tests/accessibility/res/xml/vibrating_accessibilityservice.xml
+++ b/tests/accessibility/res/xml/vibrating_accessibilityservice.xml
@@ -17,4 +17,5 @@
android:accessibilityEventTypes="typeAllMask|"
android:accessibilityFeedbackType="feedbackHaptic"
android:accessibilityFlags="flagDefault|flagRequestTouchExplorationMode"
- android:canRetrieveWindowContent="true" />
+ android:canRetrieveWindowContent="true"
+ android:canRequestTouchExplorationMode="true" />
diff --git a/tests/accessibilityservice/Android.mk b/tests/accessibilityservice/Android.mk
deleted file mode 100644
index f9fec93..0000000
--- a/tests/accessibilityservice/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_SRC_FILES += \
- src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl \
- src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
-
-LOCAL_PACKAGE_NAME := CtsDelegatingAccessibilityService
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/accessibilityservice/AndroidManifest.xml b/tests/accessibilityservice/AndroidManifest.xml
deleted file mode 100644
index 117578e..0000000
--- a/tests/accessibilityservice/AndroidManifest.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.accessibilityservice.delegate">
-
- <uses-permission android:name="android.permission.CAN_REQUEST_TOUCH_EXPLORATION_MODE"/>
-
- <application>
-
- <uses-library android:name="android.test.runner"/>
-
- <service android:name=".DelegatingAccessibilityService"
- android:label="@string/title_delegating_accessibility_service"
- android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
- <intent-filter>
- <action android:name="android.accessibilityservice.AccessibilityService"/>
- </intent-filter>
- <meta-data android:name="android.accessibilityservice"
- android:resource="@xml/accessibilityservice" />
- </service>
-
- <service android:name=".DelegatingAccessibilityService$DelegatingConnectionService"
- android:exported="true"/>
-
- </application>
-
-</manifest>
diff --git a/tests/accessibilityservice/res/xml/accessibilityservice.xml b/tests/accessibilityservice/res/xml/accessibilityservice.xml
deleted file mode 100644
index 6d48f9b..0000000
--- a/tests/accessibilityservice/res/xml/accessibilityservice.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
- android:accessibilityEventTypes="typeAllMask"
- android:accessibilityFeedbackType="feedbackGeneric"
- android:accessibilityFlags="flagDefault|flagRequestTouchExplorationMode"
- android:canRetrieveWindowContent="true"
- android:notificationTimeout="0"
- android:settingsActivity="android.accessibilityservice.delegate.SomeActivity"
- android:description="@string/title_delegating_accessibility_service" />
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
deleted file mode 100644
index 868bd72..0000000
--- a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.accessibilityservice;
-
-import android.view.accessibility.AccessibilityEvent;
-
-/**
- * Interface for interacting with the accessibility service mock.
- */
-oneway interface IAccessibilityServiceDelegate {
-
- /**
- * Delegate an {@link android.view.accessibility.AccessibilityEvent}.
- */
- void onAccessibilityEvent(in AccessibilityEvent event);
-
- /**
- * Delegate an interrupt request.
- */
- void onInterrupt();
-}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
deleted file mode 100644
index 253a082..0000000
--- a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.accessibilityservice;
-
-import android.os.Bundle;
-import android.os.IBinder;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-
-import java.util.List;
-
-/**
- * Interface for registering an accessibility service delegate
- * and asking it to perform some querying of the window for us.
- */
-interface IAccessibilityServiceDelegateConnection {
-
- void setAccessibilityServiceDelegate(in IBinder binder);
-
- List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(in AccessibilityNodeInfo root,
- String text);
-
- AccessibilityNodeInfo getParent(in AccessibilityNodeInfo child);
-
- AccessibilityNodeInfo getChild(in AccessibilityNodeInfo parent, int index);
-
- AccessibilityNodeInfo findFocus(in AccessibilityNodeInfo root, int focusType);
-
- AccessibilityNodeInfo focusSearch(in AccessibilityNodeInfo current, int direction);
-
- boolean performAccessibilityAction(in AccessibilityNodeInfo target, int action,
- in Bundle arguments);
-
- AccessibilityNodeInfo getSource(in AccessibilityEvent event);
-
- void setFetchViewsNotExposedForAccessibility(boolean fetch);
-
- boolean performGlobalAction(int action);
-
- AccessibilityNodeInfo getRootInActiveWindow();
-}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java b/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java
deleted file mode 100644
index 4e9aed1..0000000
--- a/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.accessibilityservice.delegate;
-
-import android.accessibilityservice.AccessibilityService;
-import android.accessibilityservice.AccessibilityServiceInfo;
-import android.accessibilityservice.IAccessibilityServiceDelegate;
-import android.accessibilityservice.IAccessibilityServiceDelegateConnection;
-import android.app.Service;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-
-import java.util.List;
-
-/**
- * This class is an accessibility service mock to which the system is bound and
- * exposes a mock interface to the CTS accessibility tests.
- * </p>
- * Note: The end-to-end test is composed of two APKs, one with a mock accessibility
- * service, another with the instrumented activity and test cases. The
- * motivation for two APKs design is that CTS tests cannot access the secure
- * settings which is required for enabling accessibility and accessibility
- * services. Therefore, manual installation of this package is required. Once
- * the package has been installed accessibility must be enabled (Settings ->
- * Accessibility), the mock service must be enabled (Settings -> Accessibility
- * -> Mock Accessibility Service), and then the CTS tests in this package
- * <strong>CtsAccessibilityServiceTestCases.apk</strong> located in
- * <strong>cts/tests/tests/accessibility</strong> can be successfully run.
- * Further, the mock and tests run in separate processes since the
- * instrumentation restarts the process in which it is running and this breaks
- * the binding between the mock accessibility service and the system.
- */
-public class DelegatingAccessibilityService extends AccessibilityService {
-
- /**
- * Tag used for logging.
- */
- private static final String LOG_TAG = "AccessibilityServiceDelegate";
-
- /**
- * Handle to the instance used by the accessibility service connection.
- */
- static DelegatingAccessibilityService sServiceDelegate;
-
- /**
- * Interface for delegating events and interrupt requests.
- */
- private IAccessibilityServiceDelegate mDelegateInterface;
-
- @Override
- protected void onServiceConnected() {
- // the service is ready to be used only
- // after the system has bound to it
- sServiceDelegate = this;
- }
-
- @Override
- public void onAccessibilityEvent(AccessibilityEvent event) {
- if (mDelegateInterface == null) {
- return;
- }
-
- try {
- mDelegateInterface.onAccessibilityEvent(event);
- } catch (RemoteException re) {
- Log.i(LOG_TAG, "Dead: " + mDelegateInterface.toString() + " cleaning up.");
- mDelegateInterface = null;
- }
- }
-
- @Override
- public void onInterrupt() {
- if (mDelegateInterface == null) {
- return;
- }
-
- try {
- mDelegateInterface.onInterrupt();
- } catch (RemoteException re) {
- Log.i(LOG_TAG, "Dead: " + mDelegateInterface.toString() + " cleaning up.");
- mDelegateInterface = null;
- }
- }
-
- /**
- * Sets the interface to which to delegate.
- *
- * @param delegateInterface The delegate interface.
- */
- private void setDelegateInterface(IAccessibilityServiceDelegate delegateInterface) {
- mDelegateInterface = delegateInterface;
- }
-
- /**
- * This is a service to which the end-to-end CTS test connects to pass a
- * delegate interface to which the {@link DelegatingAccessibilityService}
- * to delegate.
- */
- public static class DelegatingConnectionService extends Service {
-
- @Override
- public IBinder onBind(Intent intent) {
- if (sServiceDelegate == null) {
- return null;
- }
- return new AccessibilityServiceDelegateConnection();
- }
-
- /**
- * This class is the connection wrapper passed to the end-to-end CTS
- * test, so the latter can pass a delegating interface.
- */
- private class AccessibilityServiceDelegateConnection extends
- IAccessibilityServiceDelegateConnection.Stub {
-
- @Override
- public void setAccessibilityServiceDelegate(IBinder binder) {
- sServiceDelegate.setDelegateInterface(IAccessibilityServiceDelegate.Stub
- .asInterface(binder));
- }
-
- @Override
- public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(
- AccessibilityNodeInfo root, String text) {
- return root.findAccessibilityNodeInfosByText(text);
- }
-
- @Override
- public AccessibilityNodeInfo getChild(AccessibilityNodeInfo parent, int index) {
- return parent.getChild(index);
- }
-
- @Override
- public AccessibilityNodeInfo getParent(AccessibilityNodeInfo child) {
- return child.getParent();
- }
-
- @Override
- public AccessibilityNodeInfo findFocus(AccessibilityNodeInfo root, int focusType) {
- return root.findFocus(focusType);
- }
-
- @Override
- public AccessibilityNodeInfo focusSearch(AccessibilityNodeInfo current, int direction) {
- return current.focusSearch(direction);
- }
-
- @Override
- public AccessibilityNodeInfo getSource(AccessibilityEvent event) {
- return event.getSource();
- }
-
- @Override
- public boolean performAccessibilityAction(AccessibilityNodeInfo target, int action,
- Bundle arguments) {
- return target.performAction(action, arguments);
- }
-
- @Override
- public void setFetchViewsNotExposedForAccessibility(boolean fetch) {
- AccessibilityServiceInfo info = sServiceDelegate.getServiceInfo();
- if (fetch) {
- info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
- } else {
- info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
- }
- sServiceDelegate.setServiceInfo(info);
- }
-
- @Override
- public boolean performGlobalAction(int action) {
- return sServiceDelegate.performGlobalAction(action);
- }
-
- @Override
- public AccessibilityNodeInfo getRootInActiveWindow() {
- return sServiceDelegate.getRootInActiveWindow();
- }
- }
- }
-}
diff --git a/tests/res/values-v18/strings.xml b/tests/res/values-v18/strings.xml
index 0b84d5e..d03c5cb 100644
--- a/tests/res/values-v18/strings.xml
+++ b/tests/res/values-v18/strings.xml
@@ -16,5 +16,4 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="version_cur">v18cur</string>
- <string name="version_old">v18old</string>
</resources>
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/res/values-v19/strings.xml
similarity index 72%
copy from tests/accessibilityservice/res/values/strings.xml
copy to tests/res/values-v19/strings.xml
index 3730f85..833ca08 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/res/values-v19/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,9 +14,6 @@
limitations under the License.
-->
-<resources>
-
- <!-- String title of the mock accessibility service -->
- <string name="title_delegating_accessibility_service">Delegating Accessibility Service</string>
-
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v19cur</string>
</resources>
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/res/values-v20/strings.xml
similarity index 72%
copy from tests/accessibilityservice/res/values/strings.xml
copy to tests/res/values-v20/strings.xml
index 3730f85..f47207a 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/res/values-v20/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,9 +14,6 @@
limitations under the License.
-->
-<resources>
-
- <!-- String title of the mock accessibility service -->
- <string name="title_delegating_accessibility_service">Delegating Accessibility Service</string>
-
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v20cur</string>
</resources>
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/res/values-v21/strings.xml
similarity index 72%
copy from tests/accessibilityservice/res/values/strings.xml
copy to tests/res/values-v21/strings.xml
index 3730f85..ac8f8a7 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/res/values-v21/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,9 +14,6 @@
limitations under the License.
-->
-<resources>
-
- <!-- String title of the mock accessibility service -->
- <string name="title_delegating_accessibility_service">Delegating Accessibility Service</string>
-
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v21cur</string>
</resources>
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/res/values-v22/strings.xml
similarity index 72%
rename from tests/accessibilityservice/res/values/strings.xml
rename to tests/res/values-v22/strings.xml
index 3730f85..6b51a01 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/res/values-v22/strings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,9 +14,6 @@
limitations under the License.
-->
-<resources>
-
- <!-- String title of the mock accessibility service -->
- <string name="title_delegating_accessibility_service">Delegating Accessibility Service</string>
-
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v22cur</string>
</resources>
diff --git a/tests/src/android/renderscript/cts/global_sync.rs b/tests/src/android/renderscript/cts/global_sync.rs
index c947fa2..e384143 100644
--- a/tests/src/android/renderscript/cts/global_sync.rs
+++ b/tests/src/android/renderscript/cts/global_sync.rs
@@ -6,18 +6,26 @@
rs_allocation aFailed;
-void test_global(int expected) {
+void test_read_global(int expected) {
if (gInt != expected) {
rsSetElementAt_uchar(aFailed, 1, 0);
}
}
-void test_static_global(int expected) {
+void test_read_static_global(int expected) {
if (sInt != expected) {
rsSetElementAt_uchar(aFailed, 1, 0);
}
}
+void test_write_global(int i) {
+ gInt = i;
+}
+
+void test_write_static_global(int i) {
+ sInt = i;
+}
+
void __attribute__((kernel)) write_global(int ain, uint32_t x) {
if (x == 0) {
gInt = ain;
@@ -30,3 +38,16 @@
}
}
+int __attribute__((kernel)) read_global(int ain, uint32_t x) {
+ if (gInt != ain) {
+ return 1;
+ }
+ return 0;
+}
+
+int __attribute__((kernel)) read_static_global(int ain, uint32_t x) {
+ if (sInt != ain) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/tests/src/android/renderscript/cts/sample.rs b/tests/src/android/renderscript/cts/sample.rs
index 3fecf3c..7a8d5bb 100644
--- a/tests/src/android/renderscript/cts/sample.rs
+++ b/tests/src/android/renderscript/cts/sample.rs
@@ -73,7 +73,7 @@
result = rsSample(alloc1D, gMipLinear, location, lod);
_RS_ASSERT(compare(expected3, result));
- return failed;
+ return !failed;
}
static bool sub_test_RGBA_2D(rs_allocation alloc2D, float2 location, float lod,
@@ -90,17 +90,17 @@
result = rsSample(alloc2D, gMipLinear, location, lod);
_RS_ASSERT(compare(expected3, result));
- return failed;
+ return !failed;
}
void test_RGBA(rs_allocation alloc1D, rs_allocation alloc2D) {
bool failed = false;
float4 result;
- float4 fLOD0 = convert_float4(lod0Color);
- float4 fLOD1 = convert_float4(lod1Color);
- float4 fLOD2 = convert_float4(lod2Color);
- float4 fLOD3 = convert_float4(lod3Color);
+ float4 fLOD0 = rsUnpackColor8888(lod0Color);
+ float4 fLOD1 = rsUnpackColor8888(lod1Color);
+ float4 fLOD2 = rsUnpackColor8888(lod2Color);
+ float4 fLOD3 = rsUnpackColor8888(lod3Color);
float4 fLOD04 = fLOD0*0.6f + fLOD1*0.4f;
float4 fLOD06 = fLOD0*0.4f + fLOD1*0.6f;
diff --git a/tests/src/android/webkit/cts/WebViewOnUiThread.java b/tests/src/android/webkit/cts/WebViewOnUiThread.java
index aef4374..5133653 100644
--- a/tests/src/android/webkit/cts/WebViewOnUiThread.java
+++ b/tests/src/android/webkit/cts/WebViewOnUiThread.java
@@ -618,6 +618,15 @@
});
}
+ public Picture capturePicture() {
+ return getValue(new ValueGetter<Picture>() {
+ @Override
+ public Picture capture() {
+ return mWebView.capturePicture();
+ }
+ });
+ }
+
/**
* Helper for running code on the UI thread where an exception is
* a test failure. If this is already the UI thread then it runs
diff --git a/tests/tests/accessibilityservice/Android.mk b/tests/tests/accessibilityservice/Android.mk
index 029602a..73cd288 100644
--- a/tests/tests/accessibilityservice/Android.mk
+++ b/tests/tests/accessibilityservice/Android.mk
@@ -22,13 +22,8 @@
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl \
- src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAccessibilityServiceTestCases
-# This test runner sets up/cleans up the device before/after running the tests.
-LOCAL_CTS_TEST_RUNNER := com.android.cts.tradefed.testtype.AccessibilityServiceTestRunner
-
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
deleted file mode 100644
index 868bd72..0000000
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.accessibilityservice;
-
-import android.view.accessibility.AccessibilityEvent;
-
-/**
- * Interface for interacting with the accessibility service mock.
- */
-oneway interface IAccessibilityServiceDelegate {
-
- /**
- * Delegate an {@link android.view.accessibility.AccessibilityEvent}.
- */
- void onAccessibilityEvent(in AccessibilityEvent event);
-
- /**
- * Delegate an interrupt request.
- */
- void onInterrupt();
-}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
deleted file mode 100644
index 253a082..0000000
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.accessibilityservice;
-
-import android.os.Bundle;
-import android.os.IBinder;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-
-import java.util.List;
-
-/**
- * Interface for registering an accessibility service delegate
- * and asking it to perform some querying of the window for us.
- */
-interface IAccessibilityServiceDelegateConnection {
-
- void setAccessibilityServiceDelegate(in IBinder binder);
-
- List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(in AccessibilityNodeInfo root,
- String text);
-
- AccessibilityNodeInfo getParent(in AccessibilityNodeInfo child);
-
- AccessibilityNodeInfo getChild(in AccessibilityNodeInfo parent, int index);
-
- AccessibilityNodeInfo findFocus(in AccessibilityNodeInfo root, int focusType);
-
- AccessibilityNodeInfo focusSearch(in AccessibilityNodeInfo current, int direction);
-
- boolean performAccessibilityAction(in AccessibilityNodeInfo target, int action,
- in Bundle arguments);
-
- AccessibilityNodeInfo getSource(in AccessibilityEvent event);
-
- void setFetchViewsNotExposedForAccessibility(boolean fetch);
-
- boolean performGlobalAction(int action);
-
- AccessibilityNodeInfo getRootInActiveWindow();
-}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
index affc9ec..c7e4f4c 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
@@ -17,31 +17,10 @@
package android.accessibilityservice.cts;
import android.accessibilityservice.AccessibilityServiceInfo;
-import android.accessibilityservice.IAccessibilityServiceDelegate;
-import android.accessibilityservice.IAccessibilityServiceDelegateConnection;
import android.app.Activity;
-import android.app.Service;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ServiceInfo;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.os.SystemClock;
+import android.app.UiAutomation;
import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-import android.view.accessibility.AccessibilityNodeInfo;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeoutException;
/**
* Base text case for testing accessibility APIs by instrumenting an Activity.
@@ -49,14 +28,6 @@
public abstract class AccessibilityActivityTestCase<T extends Activity>
extends ActivityInstrumentationTestCase2<T> {
- public interface AccessibilityEventFilter {
- public boolean accept(AccessibilityEvent event);
- }
-
- private static final boolean DEBUG = false;
-
- private static final String LOG_TAG = AccessibilityActivityTestCase.class.getSimpleName();
-
/**
* Timeout required for pending Binder calls or event processing to
* complete.
@@ -64,19 +35,11 @@
public static final long TIMEOUT_ASYNC_PROCESSING = 5000;
/**
- * The timeout after the last accessibility event to consider the device idle.
+ * The timeout since the last accessibility event to consider the device idle.
*/
public static final long TIMEOUT_ACCESSIBILITY_STATE_IDLE = 200;
/**
- * Instance for detecting the next accessibility event.
- */
- private static final NextAccessibilityEventWatcher sNextEventWatcher =
- new NextAccessibilityEventWatcher();
-
- private static AccessibilityInteractionBridge sInteractionBridge;
-
- /**
* @param activityClass
*/
public AccessibilityActivityTestCase(Class<T> activityClass) {
@@ -86,22 +49,17 @@
@Override
public void setUp() throws Exception {
super.setUp();
- waitForAccessibilityStateIdle();
- startActivityAndWaitForFirstEvent();
- }
- /**
- * Gets the bridge for interacting with the view hierarchy via
- * the accessibility APIs.
- *
- * @return The bridge.
- */
- public AccessibilityInteractionBridge getInteractionBridge() {
- if (sInteractionBridge == null) {
- sInteractionBridge = new AccessibilityInteractionBridge(
- getInstrumentation().getContext());
- }
- return sInteractionBridge;
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
+ info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
+
+ getInstrumentation().getUiAutomation().waitForIdle(
+ TIMEOUT_ACCESSIBILITY_STATE_IDLE,
+ TIMEOUT_ASYNC_PROCESSING);
+
+ startActivityAndWaitForFirstEvent();
}
/**
@@ -117,7 +75,7 @@
*/
private void startActivityAndWaitForFirstEvent() throws Exception {
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -125,11 +83,10 @@
getInstrumentation().waitForIdleSync();
}
},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
final int eventType = event.getEventType();
- CharSequence packageName = event.getPackageName();
// Do not check the package name since an event of this type may
// come concurrently from the app and from the IME (since input
// focus goes to the first focusable) but we dispatch one event
@@ -141,430 +98,4 @@
TIMEOUT_ASYNC_PROCESSING);
assertNotNull(awaitedEvent);
}
-
- /**
- * Waits for idle accessibility state.
- */
- private void waitForAccessibilityStateIdle() throws Exception {
- AccessibilityEvent awaitedEvent = null;
- try {
- do {
- awaitedEvent = getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
- sNextEventWatcher, sNextEventWatcher, TIMEOUT_ACCESSIBILITY_STATE_IDLE);
- } while (awaitedEvent != null);
- } catch (TimeoutException te) {
- /* success - no event within the timeout - do nothing */
- }
- }
-
- /**
- * Dummy implementation that matches every event and does nothing.
- */
- private static class NextAccessibilityEventWatcher implements Runnable,
- AccessibilityEventFilter {
- @Override
- public boolean accept(AccessibilityEvent event) {
- if (DEBUG) {
- Log.i(LOG_TAG, "Watcher event: " + event);
- }
- return true;
- }
- @Override
- public void run() {
- /* do nothing */
- }
- }
-
- /**
- * This class serves as a bridge for querying the screen content.
- * The bride is connected of a delegating accessibility service.
- */
- static class AccessibilityInteractionBridge implements ServiceConnection {
-
- /**
- * The package of the accessibility service mock interface.
- */
- private static final String DELEGATING_SERVICE_PACKAGE =
- "android.accessibilityservice.delegate";
-
- /**
- * The package of the delegating accessibility service interface.
- */
- private static final String DELEGATING_SERVICE_CLASS_NAME =
- "android.accessibilityservice.delegate.DelegatingAccessibilityService";
-
- /**
- * The package of the delegating accessibility service connection interface.
- */
- private static final String DELEGATING_SERVICE_CONNECTION_CLASS_NAME =
- "android.accessibilityservice.delegate."
- + "DelegatingAccessibilityService$DelegatingConnectionService";
-
- /**
- * Lock for synchronization.
- */
- private final Object mLock = new Object();
-
- /**
- * Whether this delegate is initialized.
- */
- private boolean mInitialized;
-
- /**
- * Query connection to the delegating accessibility service.
- */
- private IAccessibilityServiceDelegateConnection mQueryConnection;
-
- /**
- * Flag whether we are waiting for a specific event.
- */
- private boolean mWaitingForEventDelivery;
-
- /**
- * Queue with received events.
- */
- private final ArrayList<AccessibilityEvent> mEventQueue =
- new ArrayList<AccessibilityEvent>(10);
-
- public AccessibilityInteractionBridge(Context context) {
- bindToDelegatingAccessibilityService(context);
- }
-
- public void onAccessibilityEvent(AccessibilityEvent event) {
- synchronized (mLock) {
- mLock.notifyAll();
- if (mWaitingForEventDelivery) {
- mEventQueue.add(AccessibilityEvent.obtain(event));
- }
- }
- }
-
- /**
- * Ensures the required setup for the test performed and that it is bound to the
- * DelegatingAccessibilityService which runs in another process. The setup is
- * enabling accessibility and installing and enabling the delegating accessibility
- * service this test binds to.
- * </p>
- * Note: Please look at the class description for information why such an
- * approach is taken.
- */
- public void bindToDelegatingAccessibilityService(Context context) {
- // check if accessibility is enabled
- AccessibilityManager accessibilityManager = (AccessibilityManager) context
- .getSystemService(Service.ACCESSIBILITY_SERVICE);
-
- if (!accessibilityManager.isEnabled()) {
- throw new IllegalStateException("Delegating service not enabled.");
- }
-
- // check if the delegating service is running
- List<AccessibilityServiceInfo> enabledServices =
- accessibilityManager.getEnabledAccessibilityServiceList(
- AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
- boolean delegatingServiceRunning = false;
- for (AccessibilityServiceInfo enabledService : enabledServices) {
- ServiceInfo serviceInfo = enabledService.getResolveInfo().serviceInfo;
- if (DELEGATING_SERVICE_PACKAGE.equals(serviceInfo.packageName)
- && DELEGATING_SERVICE_CLASS_NAME.equals(serviceInfo.name)) {
- delegatingServiceRunning = true;
- break;
- }
- }
-
- if (!delegatingServiceRunning) {
- // delegating service not running, so check if it is installed at all
- try {
- PackageManager packageManager = context.getPackageManager();
- packageManager.getServiceInfo(new ComponentName(DELEGATING_SERVICE_PACKAGE,
- DELEGATING_SERVICE_CLASS_NAME), 0);
- } catch (NameNotFoundException nnfe) {
- throw new IllegalStateException("CtsDelegatingAccessibilityService.apk" +
- " not installed.");
- }
-
- throw new IllegalStateException("Delegating Accessibility Service not running.");
- }
-
- Intent intent = new Intent().setClassName(DELEGATING_SERVICE_PACKAGE,
- DELEGATING_SERVICE_CONNECTION_CLASS_NAME);
- context.bindService(intent, this, Context.BIND_AUTO_CREATE);
-
- final long beginTime = SystemClock.uptimeMillis();
- synchronized (mLock) {
- while (true) {
- if (mInitialized) {
- return;
- }
- final long elapsedTime = (SystemClock.uptimeMillis() - beginTime);
- final long remainingTime = TIMEOUT_ASYNC_PROCESSING - elapsedTime;
- if (remainingTime <= 0) {
- if (!mInitialized) {
- throw new IllegalStateException("Cound not connect to the delegating"
- + " accessibility service");
- }
- return;
- }
- try {
- mLock.wait(remainingTime);
- } catch (InterruptedException ie) {
- /* ignore */
- }
- }
- }
- }
-
- /**
- * {@inheritDoc ServiceConnection#onServiceConnected(ComponentName,IBinder)}
- */
- public void onServiceConnected(ComponentName name, IBinder service) {
- mQueryConnection = IAccessibilityServiceDelegateConnection.Stub.asInterface(service);
- try {
- mQueryConnection.setAccessibilityServiceDelegate(
- new IAccessibilityServiceDelegate.Stub() {
- @Override
- public void onAccessibilityEvent(AccessibilityEvent event) {
- AccessibilityInteractionBridge.this.onAccessibilityEvent(event);
- }
- @Override
- public void onInterrupt() {
- /* do nothing */
- }
- });
- synchronized (mLock) {
- mInitialized = true;
- mLock.notifyAll();
- }
- } catch (RemoteException re) {
- fail("Could not set delegate to the delegating service.");
- }
- }
-
- /**
- * {@inheritDoc ServiceConnection#onServiceDisconnected(ComponentName)}
- */
- public void onServiceDisconnected(ComponentName name) {
- synchronized (mLock) {
- mInitialized = false;
- }
- }
-
- /**
- * Gets the query connection to the delegating accessibility service.
- *
- * @return The connection.
- */
- public IAccessibilityServiceDelegateConnection getQueryConnection() {
- return mQueryConnection;
- }
-
- /**
- * Finds the first accessibility info that contains text. The search starts
- * from the given <code>root</code>
- *
- * @param text The searched text.
- * @return The node with this text or null.
- */
- public AccessibilityNodeInfo findAccessibilityNodeInfoByTextFromRoot(String text) {
- List<AccessibilityNodeInfo> nodes = findAccessibilityNodeInfosByText(text);
- if (nodes != null && !nodes.isEmpty()) {
- return nodes.get(0);
- }
- return null;
- }
-
- public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String text) {
- AccessibilityNodeInfo root = getRootInActiveWindow();
- if (root != null) {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo rootClone = AccessibilityNodeInfo.obtain(root);
- try {
- return getQueryConnection().findAccessibilityNodeInfosByText(rootClone, text);
- } catch (RemoteException re) {
- /* ignore */
- }
- }
- return Collections.emptyList();
- }
-
- public AccessibilityNodeInfo getParent(AccessibilityNodeInfo child) {
- try {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo childClone = AccessibilityNodeInfo.obtain(child);
- return getQueryConnection().getParent(childClone);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public AccessibilityNodeInfo getChild(AccessibilityNodeInfo parent, int index) {
- try {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo parentClone = AccessibilityNodeInfo.obtain(parent);
- return getQueryConnection().getChild(parentClone, index);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public boolean performAction(AccessibilityNodeInfo target, int action) {
- return performAction(target, action, null);
- }
-
- public boolean performAction(AccessibilityNodeInfo target, int action, Bundle arguments) {
- try {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo targetClone = AccessibilityNodeInfo.obtain(target);
- return getQueryConnection().performAccessibilityAction(targetClone, action,
- arguments);
- } catch (RemoteException re) {
- /* ignore */
- }
- return false;
- }
-
- public boolean performGlobalAction(int action) {
- try {
- return getQueryConnection().performGlobalAction(action);
- } catch (RemoteException re) {
- /* ignore */
- }
- return false;
- }
-
- public AccessibilityNodeInfo getSource(AccessibilityEvent event) {
- try {
- return getQueryConnection().getSource(event);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public AccessibilityNodeInfo findAccessibilityFocus(AccessibilityNodeInfo root) {
- try {
- return getQueryConnection().findFocus(root,
- AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public AccessibilityNodeInfo findInputFocus(AccessibilityNodeInfo root) {
- try {
- return getQueryConnection().findFocus(root, AccessibilityNodeInfo.FOCUS_INPUT);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public AccessibilityNodeInfo accessibilityFocusSearch(AccessibilityNodeInfo current,
- int direction) {
- try {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo currentClone = AccessibilityNodeInfo.obtain(current);
- return getQueryConnection().focusSearch(currentClone, direction);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public AccessibilityNodeInfo inputFocusSearch(AccessibilityNodeInfo current,
- int direction) {
- try {
- // Sending a node info across processes recycles
- // it so use a clone to avoid losing state
- AccessibilityNodeInfo currentClone = AccessibilityNodeInfo.obtain(current);
- return getQueryConnection().focusSearch(currentClone, direction);
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- public void setRegardViewsNotImportantForAccessibility(boolean fetch) {
- try {
- getQueryConnection().setFetchViewsNotExposedForAccessibility(fetch);
- } catch (RemoteException re) {
- /* ignore */
- }
- }
-
- public AccessibilityNodeInfo getRootInActiveWindow() {
- try {
- return getQueryConnection().getRootInActiveWindow();
- } catch (RemoteException re) {
- /* ignore */
- }
- return null;
- }
-
- /**
- * Executes a command and waits for a specific accessibility event type up
- * to a given timeout.
- *
- * @param command The command to execute before starting to wait for the event.
- * @param filter Filter that recognizes the expected event.
- * @param timeoutMillis The max wait time in milliseconds.
- */
- public AccessibilityEvent executeCommandAndWaitForAccessibilityEvent(Runnable command,
- AccessibilityEventFilter filter, long timeoutMillis)
- throws TimeoutException, Exception {
- synchronized (mLock) {
- mEventQueue.clear();
- // Prepare to wait for an event.
- mWaitingForEventDelivery = true;
- // We will ignore events from previous interactions.
- final long executionStartTimeMillis = SystemClock.uptimeMillis();
- // Execute the command.
- command.run();
- try {
- // Wait for the event.
- final long startTimeMillis = SystemClock.uptimeMillis();
- while (true) {
- // Drain the event queue
- while (!mEventQueue.isEmpty()) {
- AccessibilityEvent event = mEventQueue.remove(0);
-
- // Ignore events from previous interactions.
- if (event.getEventTime() < executionStartTimeMillis) {
- continue;
- }
- if (filter.accept(event)) {
- return event;
- }
-
- event.recycle();
- }
- // Check if timed out and if not wait.
- final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
- final long remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
- if (remainingTimeMillis <= 0) {
- throw new TimeoutException("Expected event not received within: "
- + timeoutMillis + " ms.");
- }
- mLock.notifyAll();
- try {
- mLock.wait(remainingTimeMillis);
- } catch (InterruptedException ie) {
- /* ignore */
- }
- }
- } finally {
- mWaitingForEventDelivery = false;
- mEventQueue.clear();
- mLock.notifyAll();
- }
- }
- }
- }
}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
index eedc25f..7e05e32 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
@@ -22,6 +22,7 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
+import android.app.UiAutomation;
import android.content.Intent;
import android.test.suitebuilder.annotation.MediumTest;
import android.text.TextUtils;
@@ -39,17 +40,6 @@
* This class performs end-to-end testing of the accessibility feature by
* creating an {@link Activity} and poking around so {@link AccessibilityEvent}s
* are generated and their correct dispatch verified.
- * <p>
- * Note: The accessibility CTS tests are composed of two APKs, one with delegating
- * accessibility service and another with the instrumented activity and test cases.
- * The delegating service is installed and enabled during test execution. It serves
- * as a proxy to the system used by the tests. This indirection is needed since the
- * test runner stops the package before running the tests. Hence, if the accessibility
- * service is in the test package running the tests would break the binding between
- * the service and the system. The delegating service is in
- * <strong>CtsDelegatingAccessibilityService.apk</strong> whose source is located at
- * <strong>cts/tests/accessibilityservice</strong>.
- * </p>
*/
public class AccessibilityEndToEndTest extends
AccessibilityActivityTestCase<AccessibilityEndToEndActivity> {
@@ -81,7 +71,7 @@
final ListView listView = (ListView) getActivity().findViewById(R.id.listview);
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -93,7 +83,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -117,7 +107,7 @@
final Button button = (Button) getActivity().findViewById(R.id.button);
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -129,7 +119,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -153,7 +143,7 @@
final Button button = (Button) getActivity().findViewById(R.id.button);
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -165,7 +155,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -191,7 +181,7 @@
final Button button = (Button) getActivity().findViewById(R.id.button);
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -203,7 +193,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -220,7 +210,7 @@
final EditText editText = (EditText) getActivity().findViewById(R.id.edittext);
AccessibilityEvent awaitedFocusEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -232,7 +222,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -259,7 +249,7 @@
expected.setEnabled(true);
AccessibilityEvent awaitedTextChangeEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -271,7 +261,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -293,10 +283,8 @@
expected.getText().add(getActivity().getString(R.string.alert_message));
expected.setEnabled(true);
- final EditText editText = (EditText) getActivity().findViewById(R.id.edittext);
-
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -309,7 +297,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -343,7 +331,7 @@
expected.setParcelableData(notification);
AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
@@ -359,7 +347,7 @@
}
});
}},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
// check the received event
@Override
public boolean accept(AccessibilityEvent event) {
@@ -403,7 +391,6 @@
*/
private boolean equalsNotificationAsParcelableData(AccessibilityEvent first,
AccessibilityEvent second) {
- String message = "parcelableData has incorrect value";
Notification firstNotification = (Notification) first.getParcelableData();
Notification secondNotification = (Notification) second.getParcelableData();
if (firstNotification == null) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncTest.java
index 7ae62b3..93b026c 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityFocusAndInputFocusSyncTest.java
@@ -17,8 +17,9 @@
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS;
-import android.os.SystemClock;
+import android.app.UiAutomation;
import android.test.suitebuilder.annotation.MediumTest;
+import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.android.cts.accessibilityservice.R;
@@ -31,17 +32,6 @@
* services. These APIs allow moving accessibility focus in the view tree from
* an AccessiiblityService. Specifically, this activity is for verifying the the
* sync between accessibility and input focus.
- * <p>
- * Note: The accessibility CTS tests are composed of two APKs, one with delegating
- * accessibility service and another with the instrumented activity and test cases.
- * The delegating service is installed and enabled during test execution. It serves
- * as a proxy to the system used by the tests. This indirection is needed since the
- * test runner stops the package before running the tests. Hence, if the accessibility
- * service is in the test package running the tests would break the binding between
- * the service and the system. The delegating service is in
- * <strong>CtsDelegatingAccessibilityService.apk</strong> whose source is located at
- * <strong>cts/tests/accessibilityservice</strong>.
- * </p>
*/
public class AccessibilityFocusAndInputFocusSyncTest
extends AccessibilityActivityTestCase<AccessibilityFocusAndInputFocusSyncActivity>{
@@ -53,18 +43,29 @@
@MediumTest
public void testFindAccessibilityFocus() throws Exception {
// Get the view that has input and accessibility focus.
- AccessibilityNodeInfo expected = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstEditText));
+ final AccessibilityNodeInfo expected = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.firstEditText)).get(0);
assertNotNull(expected);
assertFalse(expected.isAccessibilityFocused());
assertTrue(expected.isFocused());
- // Perform a focus action and check for success.
- assertTrue(getInteractionBridge().performAction(expected, ACTION_ACCESSIBILITY_FOCUS));
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a focus action and check for success.
+ assertTrue(expected.performAction(ACTION_ACCESSIBILITY_FOCUS));
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
// Get the second expected node info.
- AccessibilityNodeInfo received = getInteractionBridge().findAccessibilityFocus(
- getInteractionBridge().getRootInActiveWindow());
+ AccessibilityNodeInfo received = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
assertNotNull(received);
assertTrue(received.isAccessibilityFocused());
@@ -75,27 +76,35 @@
@MediumTest
public void testInitialStateNoAccessibilityFocus() throws Exception {
// Get the root which is only accessibility focused.
- AccessibilityNodeInfo focused = getInteractionBridge().findAccessibilityFocus(
- getInteractionBridge().getRootInActiveWindow());
+ AccessibilityNodeInfo focused = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
assertNull(focused);
}
@MediumTest
public void testActionAccessibilityFocus() throws Exception {
// Get the root linear layout info.
- AccessibilityNodeInfo rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
+ final AccessibilityNodeInfo rootLinearLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.rootLinearLayout)).get(0);
assertNotNull(rootLinearLayout);
assertFalse(rootLinearLayout.isAccessibilityFocused());
- // Perform a focus action and check for success.
- assertTrue(getInteractionBridge().performAction(rootLinearLayout,
- ACTION_ACCESSIBILITY_FOCUS));
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a focus action and check for success.
+ assertTrue(rootLinearLayout.performAction(ACTION_ACCESSIBILITY_FOCUS));
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
// Get the node info again.
- rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
- assertNotNull(rootLinearLayout);
+ rootLinearLayout.refresh();
// Check if the node info is focused.
assertTrue(rootLinearLayout.isAccessibilityFocused());
@@ -104,29 +113,46 @@
@MediumTest
public void testActionClearAccessibilityFocus() throws Exception {
// Get the root linear layout info.
- AccessibilityNodeInfo rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
+ final AccessibilityNodeInfo rootLinearLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.rootLinearLayout)).get(0);
assertNotNull(rootLinearLayout);
- // Perform a focus action and check for success.
- assertTrue(getInteractionBridge().performAction(rootLinearLayout,
- ACTION_ACCESSIBILITY_FOCUS));
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a focus action and check for success.
+ assertTrue(rootLinearLayout.performAction(ACTION_ACCESSIBILITY_FOCUS));
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
- // Get the node info again.
- rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
- assertNotNull(rootLinearLayout);
+ // Refresh the node info.
+ rootLinearLayout.refresh();
// Check if the node info is focused.
assertTrue(rootLinearLayout.isAccessibilityFocused());
- // Perform a clear focus action and check for success.
- assertTrue(getInteractionBridge().performAction(rootLinearLayout,
- ACTION_CLEAR_ACCESSIBILITY_FOCUS));
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a clear focus action and check for success.
+ assertTrue(rootLinearLayout.performAction(ACTION_CLEAR_ACCESSIBILITY_FOCUS));
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType()
+ == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
- // Get the node info again.
- rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
+ // Refresh the node info.
+ rootLinearLayout.refresh();
// Check if the node info is not focused.
assertFalse(rootLinearLayout.isAccessibilityFocused());
@@ -135,41 +161,55 @@
@MediumTest
public void testOnlyOneNodeHasAccessibilityFocus() throws Exception {
// Get the first not focused edit text.
- AccessibilityNodeInfo firstEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstEditText));
+ final AccessibilityNodeInfo firstEditText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.firstEditText)).get(0);
assertNotNull(firstEditText);
assertTrue(firstEditText.isFocusable());
assertTrue(firstEditText.isFocused());
assertFalse(firstEditText.isAccessibilityFocused());
- // Perform a set focus action and check for success.
- assertTrue(getInteractionBridge().performAction(firstEditText,
- ACTION_ACCESSIBILITY_FOCUS));
-
- // Wait for generated events to propagate and clear the cache.
- SystemClock.sleep(TIMEOUT_ASYNC_PROCESSING);
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a set focus action and check for success.
+ assertTrue(firstEditText.performAction(ACTION_ACCESSIBILITY_FOCUS));
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
// Get the second not focused edit text.
- AccessibilityNodeInfo secondEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondEditText));
+ final AccessibilityNodeInfo secondEditText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondEditText)).get(0);
assertNotNull(secondEditText);
assertTrue(secondEditText.isFocusable());
assertFalse(secondEditText.isFocused());
assertFalse(secondEditText.isAccessibilityFocused());
- // Perform a set focus action and check for success.
- assertTrue(getInteractionBridge().performAction(secondEditText,
- ACTION_ACCESSIBILITY_FOCUS));
-
- // Wait for generated events to propagate and clear the cache.
- SystemClock.sleep(TIMEOUT_ASYNC_PROCESSING);
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
+ @Override
+ public void run() {
+ // Perform a set focus action and check for success.
+ assertTrue(secondEditText.performAction(ACTION_ACCESSIBILITY_FOCUS));
+
+ }
+ }, new UiAutomation.AccessibilityEventFilter() {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ return event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
+ }
+ }, TIMEOUT_ASYNC_PROCESSING);
// Get the node info again.
- secondEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondEditText));
+ secondEditText.refresh();
// Make sure no other node has accessibility focus.
- AccessibilityNodeInfo root = getInteractionBridge().getRootInActiveWindow();
+ AccessibilityNodeInfo root = getInstrumentation().getUiAutomation().getRootInActiveWindow();
Queue<AccessibilityNodeInfo> workQueue = new LinkedList<AccessibilityNodeInfo>();
workQueue.add(root);
while (!workQueue.isEmpty()) {
@@ -179,8 +219,10 @@
}
final int childCount = current.getChildCount();
for (int i = 0; i < childCount; i++) {
- AccessibilityNodeInfo child = getInteractionBridge().getChild(current, i);
- workQueue.offer(child);
+ AccessibilityNodeInfo child = current.getChild(i);
+ if (child != null) {
+ workQueue.offer(child);
+ }
}
}
}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
index ad2dca4..4047f0e 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
@@ -92,6 +92,17 @@
public void testFlagToString() {
assertEquals("DEFAULT", AccessibilityServiceInfo.flagToString(
AccessibilityServiceInfo.DEFAULT));
+ assertEquals("FLAG_INCLUDE_NOT_IMPORTANT_VIEWS", AccessibilityServiceInfo.flagToString(
+ AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS));
+ assertEquals("FLAG_REPORT_VIEW_IDS", AccessibilityServiceInfo.flagToString(
+ AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS));
+ assertEquals("FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY", AccessibilityServiceInfo
+ .flagToString(AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY));
+ assertEquals("FLAG_REQUEST_FILTER_KEY_EVENTS", AccessibilityServiceInfo.flagToString(
+ AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS));
+ assertEquals("FLAG_REQUEST_TOUCH_EXPLORATION_MODE", AccessibilityServiceInfo.flagToString(
+ AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE));
+
}
/**
@@ -110,22 +121,21 @@
AccessibilityServiceInfo speakingService = enabledServices.get(0);
assertSame(AccessibilityEvent.TYPES_ALL_MASK, speakingService.eventTypes);
assertSame(AccessibilityServiceInfo.FEEDBACK_GENERIC, speakingService.feedbackType);
- assertSame(AccessibilityServiceInfo.DEFAULT
- | AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE,
+ assertSame(AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
+ | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS,
speakingService.flags);
assertSame(0l, speakingService.notificationTimeout);
- assertEquals("Delegating Accessibility Service", speakingService.getDescription());
+ assertNull(speakingService.getDescription());
assertNull(speakingService.packageNames /*all packages*/);
assertNotNull(speakingService.getId());
- assertTrue(speakingService.getCanRetrieveWindowContent());
- assertEquals("android.accessibilityservice.delegate.SomeActivity",
- speakingService.getSettingsActivityName());
- assertEquals("Delegating Accessibility Service",
- speakingService.loadDescription(getContext().getPackageManager()));
- assertEquals("android.accessibilityservice.delegate",
- speakingService.getResolveInfo().serviceInfo.packageName);
- assertEquals("android.accessibilityservice.delegate.DelegatingAccessibilityService",
- speakingService.getResolveInfo().serviceInfo.name);
+ assertSame(speakingService.getCapabilities(),
+ AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
+ | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
+ | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
+ | AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT);
+ assertNull(speakingService.getSettingsActivityName());
+ assertNull(speakingService.loadDescription(getContext().getPackageManager()));
+ assertNull(speakingService.getResolveInfo());
}
/**
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
index c8f8a48..4af69fd 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
@@ -14,6 +14,7 @@
package android.accessibilityservice.cts;
+import android.app.UiAutomation;
import android.os.Bundle;
import android.test.suitebuilder.annotation.MediumTest;
import android.text.Selection;
@@ -29,17 +30,6 @@
/**
* Test cases for testing the accessibility APIs for traversing the text content of
* a View at several granularities.
- * <p>
- * Note: The accessibility CTS tests are composed of two APKs, one with delegating
- * accessibility service and another with the instrumented activity and test cases.
- * The delegating service is installed and enabled during test execution. It serves
- * as a proxy to the system used by the tests. This indirection is needed since the
- * test runner stops the package before running the tests. Hence, if the accessibility
- * service is in the test package running the tests would break the binding between
- * the service and the system. The delegating service is in
- * <strong>CtsDelegatingAccessibilityService.apk</strong> whose source is located at
- * <strong>cts/tests/accessibilityservice</strong>.
- * </p>
*/
public class AccessibilityTextTraversalTest
extends AccessibilityActivityTestCase<AccessibilityTextTraversalActivity>{
@@ -60,8 +50,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.a_b));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.a_b)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -73,14 +64,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
// Move to the next character and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -103,14 +94,14 @@
assertNotNull(firstExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -133,14 +124,14 @@
assertNotNull(secondExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -163,18 +154,18 @@
assertNotNull(thirdExpected);
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
+ assertFalse(text.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY,
+ arguments));
// Move to the previous character and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -197,14 +188,14 @@
assertNotNull(fourthExpected);
// Move to the previous character and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -227,14 +218,14 @@
assertNotNull(fifthExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
- AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
+ text.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
+ arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -257,7 +248,7 @@
assertNotNull(sixthExpected);
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
}
@@ -273,8 +264,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -286,14 +278,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
// Move to the next character and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -316,14 +308,14 @@
assertNotNull(firstExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -346,14 +338,14 @@
assertNotNull(secondExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -376,18 +368,18 @@
assertNotNull(thirdExpected);
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Move to the next character and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -410,14 +402,14 @@
assertNotNull(fourthExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -440,14 +432,14 @@
assertNotNull(fifthExpected);
// Move to the next character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -470,7 +462,7 @@
assertNotNull(sixthExpected);
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
}
@@ -486,8 +478,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.a_b));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.a_b)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -501,14 +494,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
// Move to the next character and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -535,14 +528,14 @@
assertEquals(1, Selection.getSelectionEnd(textView.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -569,14 +562,14 @@
assertEquals(2, Selection.getSelectionEnd(textView.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -603,7 +596,7 @@
assertEquals(3, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -611,14 +604,14 @@
assertEquals(3, Selection.getSelectionEnd(textView.getText()));
// Move to the previous character and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -645,14 +638,14 @@
assertEquals(2, Selection.getSelectionEnd(textView.getText()));
// Move to the previous character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -679,14 +672,14 @@
assertEquals(1, Selection.getSelectionEnd(textView.getText()));
// Move to the previous character and wait for an event.
- AccessibilityEvent seventhExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent seventhExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -713,7 +706,7 @@
assertEquals(0, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -734,8 +727,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.a_b));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.a_b)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -750,14 +744,14 @@
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
// Move to the next character and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -784,14 +778,14 @@
assertEquals(1, Selection.getSelectionEnd(editText.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -818,14 +812,14 @@
assertEquals(2, Selection.getSelectionEnd(editText.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -852,7 +846,7 @@
assertEquals(3, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -872,7 +866,7 @@
Bundle setSelectionArgs = new Bundle();
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 3);
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 3);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
@@ -889,14 +883,14 @@
});
// Move to the previous character and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -923,14 +917,14 @@
assertEquals(3, Selection.getSelectionEnd(editText.getText()));
// Move to the previous character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -957,14 +951,14 @@
assertEquals(3, Selection.getSelectionEnd(editText.getText()));
// Move to the previous character and wait for an event.
- AccessibilityEvent seventhExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent seventhExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -991,7 +985,7 @@
assertEquals(3, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1010,8 +1004,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.foo_bar_baz)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -1025,14 +1020,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
// Move to the next word and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1059,14 +1054,14 @@
assertEquals(3, Selection.getSelectionEnd(textView.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1093,14 +1088,14 @@
assertEquals(7, Selection.getSelectionEnd(textView.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1127,7 +1122,7 @@
assertEquals(11, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1135,14 +1130,14 @@
assertEquals(11, Selection.getSelectionEnd(textView.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1169,14 +1164,14 @@
assertEquals(8, Selection.getSelectionEnd(textView.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1203,14 +1198,14 @@
assertEquals(4, Selection.getSelectionEnd(textView.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1237,7 +1232,7 @@
assertEquals(0, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1259,8 +1254,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.foo_bar_baz)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -1274,14 +1270,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
// Move to the next word and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1309,14 +1305,14 @@
assertEquals(3, editText.getSelectionEnd());
// Move to the next word and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1344,14 +1340,14 @@
assertEquals(7, editText.getSelectionEnd());
// Move to the next word and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1379,7 +1375,7 @@
assertEquals(11, editText.getSelectionEnd());
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1387,14 +1383,14 @@
assertEquals(11, editText.getSelectionEnd());
// Move to the next word and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1422,14 +1418,14 @@
assertEquals(8, editText.getSelectionEnd());
// Move to the next word and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1457,14 +1453,14 @@
assertEquals(4, editText.getSelectionEnd());
// Move to the next character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1492,7 +1488,7 @@
assertEquals(0, editText.getSelectionEnd());
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1512,8 +1508,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.foo_bar_baz)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -1528,14 +1525,14 @@
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
// Move to the next word and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1562,14 +1559,14 @@
assertEquals(3, Selection.getSelectionEnd(editText.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1596,14 +1593,14 @@
assertEquals(7, Selection.getSelectionEnd(editText.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1630,7 +1627,7 @@
assertEquals(11, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Focus the view so we can change selection.
@@ -1646,7 +1643,7 @@
Bundle setSelectionArgs = new Bundle();
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 11);
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 11);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
@@ -1663,14 +1660,14 @@
});
// Move to the next word and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1697,14 +1694,14 @@
assertEquals(11, Selection.getSelectionEnd(editText.getText()));
// Move to the next word and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1731,14 +1728,14 @@
assertEquals(11, Selection.getSelectionEnd(editText.getText()));
// Move to the next character and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1765,7 +1762,7 @@
assertEquals(11, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1784,8 +1781,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki_short));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki_short)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -1799,14 +1797,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
// Move to the next line and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1834,14 +1832,14 @@
assertEquals(25, Selection.getSelectionEnd(textView.getText()));
// Move to the next line and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1869,14 +1867,14 @@
assertEquals(53, Selection.getSelectionEnd(textView.getText()));
// Move to the next line and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1904,7 +1902,7 @@
assertEquals(60, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -1912,14 +1910,14 @@
assertEquals(60, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1947,14 +1945,14 @@
assertEquals(53, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -1982,14 +1980,14 @@
assertEquals(25, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2017,7 +2015,7 @@
assertEquals(0, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2037,8 +2035,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki_short));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki_short)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -2053,14 +2052,14 @@
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
// Move to the next line and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2088,14 +2087,14 @@
assertEquals(19, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2123,14 +2122,14 @@
assertEquals(35, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2170,7 +2169,7 @@
Bundle setSelectionArgs = new Bundle();
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 53);
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 53);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
@@ -2187,14 +2186,14 @@
});
// Move to the previous line and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2222,14 +2221,14 @@
assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2257,14 +2256,14 @@
assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2292,7 +2291,7 @@
assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2312,8 +2311,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -2327,14 +2327,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
// Move to the next page and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2362,14 +2362,14 @@
assertEquals(139, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2397,14 +2397,14 @@
assertEquals(285, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2432,7 +2432,7 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2440,14 +2440,14 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2475,14 +2475,14 @@
assertEquals(285, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2510,14 +2510,14 @@
assertEquals(139, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2545,7 +2545,7 @@
assertEquals(0, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2565,8 +2565,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -2581,14 +2582,14 @@
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
// Move to the next page and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2616,14 +2617,14 @@
assertEquals(139, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2651,14 +2652,14 @@
assertEquals(285, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2686,7 +2687,7 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Focus the view so we can change selection.
@@ -2702,7 +2703,7 @@
Bundle setSelectionArgs = new Bundle();
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 436);
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 436);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
@@ -2719,14 +2720,14 @@
});
// Move to the previous page and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2754,14 +2755,14 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2789,14 +2790,14 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2824,7 +2825,7 @@
assertEquals(436, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2843,8 +2844,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki_short));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki_short)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -2858,14 +2860,14 @@
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
// Move to the next paragraph and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2893,14 +2895,14 @@
assertEquals(104, Selection.getSelectionEnd(textView.getText()));
// Move to the next paragraph and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2928,14 +2930,14 @@
assertEquals(267, Selection.getSelectionEnd(textView.getText()));
// Move to the next paragraph and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -2963,7 +2965,7 @@
assertEquals(582, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -2971,14 +2973,14 @@
assertEquals(582, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3006,14 +3008,14 @@
assertEquals(268, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3041,14 +3043,14 @@
assertEquals(106, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3076,7 +3078,7 @@
assertEquals(2, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -3096,8 +3098,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.android_wiki_short));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.android_wiki_short)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -3112,14 +3115,14 @@
arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
// Move to the next paragraph and wait for an event.
- AccessibilityEvent firstExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent firstExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3147,14 +3150,14 @@
assertEquals(104, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
- AccessibilityEvent secondExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3182,14 +3185,14 @@
assertEquals(267, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
- AccessibilityEvent thirdExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3217,7 +3220,7 @@
assertEquals(582, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -3237,7 +3240,7 @@
Bundle setSelectionArgs = new Bundle();
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 582);
setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 582);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
@@ -3254,14 +3257,14 @@
});
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent fourthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3289,14 +3292,14 @@
assertEquals(582, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent fifthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3324,14 +3327,14 @@
assertEquals(582, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
- AccessibilityEvent sixthExpected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(text,
+ text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return
@@ -3359,7 +3362,7 @@
assertEquals(582, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
@@ -3382,19 +3385,20 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
// Select all text.
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 0);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT,
editText.getText().length());
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
// Copy the selected text.
- getInteractionBridge().performAction(text, AccessibilityNodeInfo.ACTION_COPY);
+ text.performAction( AccessibilityNodeInfo.ACTION_COPY);
// Set selection at the end.
final int textLength = editText.getText().length();
@@ -3403,7 +3407,7 @@
assertEquals(textLength, Selection.getSelectionEnd(editText.getText()));
// Paste the selected text.
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_PASTE));
// Verify the content.
@@ -3413,11 +3417,11 @@
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 0);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT,
editText.getText().length());
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
// Cut the selected text.
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_CUT));
// Verify the content.
@@ -3434,20 +3438,21 @@
}
});
- AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
// Set the cursor position.
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 4);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 4);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
// Try and fail to set the selection longer than zero.
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 4);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 5);
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
}
@@ -3461,8 +3466,9 @@
}
});
- final AccessibilityNodeInfo text = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
// Check the initial node properties.
assertFalse(text.isEditable());
@@ -3470,16 +3476,16 @@
assertSame(text.getTextSelectionEnd(), -1);
// Set the cursor position.
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 4);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 4);
- assertTrue(getInteractionBridge().performAction(text,
+ assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return (event.getEventType()
@@ -3488,8 +3494,9 @@
}, TIMEOUT_ASYNC_PROCESSING);
// Refresh the node.
- AccessibilityNodeInfo refreshedText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ AccessibilityNodeInfo refreshedText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
// Check the related node properties.
assertFalse(refreshedText.isEditable());
@@ -3500,12 +3507,13 @@
Bundle arguments = new Bundle();
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 4);
arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 5);
- assertFalse(getInteractionBridge().performAction(text,
+ assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments));
// Refresh the node.
- refreshedText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.foo_bar_baz));
+ refreshedText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.foo_bar_baz)).get(0);
// Check the related node properties.
assertFalse(refreshedText.isEditable());
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingTest.java
index 7f3a03c..9785ab4 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityViewTreeReportingTest.java
@@ -23,17 +23,6 @@
* Test cases for testing the accessibility focus APIs exposed to accessibility
* services. This test checks how the view hierarchy is reported to accessibility
* services.
- * <p>
- * Note: The accessibility CTS tests are composed of two APKs, one with delegating
- * accessibility service and another with the instrumented activity and test cases.
- * The delegating service is installed and enabled during test execution. It serves
- * as a proxy to the system used by the tests. This indirection is needed since the
- * test runner stops the package before running the tests. Hence, if the accessibility
- * service is in the test package running the tests would break the binding between
- * the service and the system. The delegating service is in
- * <strong>CtsDelegatingAccessibilityService.apk</strong> whose source is located at
- * <strong>cts/tests/accessibilityservice</strong>.
- * </p>
*/
public class AccessibilityViewTreeReportingTest
extends AccessibilityActivityTestCase<AccessibilityViewTreeReportingActivity>{
@@ -44,75 +33,88 @@
@MediumTest
public void testDescendantsOfNotImportantViewReportedInOrder1() throws Exception {
- AccessibilityNodeInfo firstFrameLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstFrameLayout));
+ AccessibilityNodeInfo firstFrameLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.firstFrameLayout)).get(0);
assertNotNull(firstFrameLayout);
assertSame(3, firstFrameLayout.getChildCount());
// Check if the first child is the right one.
- AccessibilityNodeInfo firstTextView = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstTextView));
- assertEquals(firstTextView, getInteractionBridge().getChild(firstFrameLayout, 0));
+ AccessibilityNodeInfo firstTextView = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.firstTextView)).get(0);
+ assertEquals(firstTextView, firstFrameLayout.getChild(0));
// Check if the second child is the right one.
- AccessibilityNodeInfo firstEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstEditText));
- assertEquals(firstEditText, getInteractionBridge().getChild(firstFrameLayout, 1));
+ AccessibilityNodeInfo firstEditText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
+ R.string.firstEditText)).get(0);
+ assertEquals(firstEditText, firstFrameLayout.getChild(1));
// Check if the third child is the right one.
- AccessibilityNodeInfo firstButton = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstButton));
- assertEquals(firstButton, getInteractionBridge().getChild(firstFrameLayout, 2));
+ AccessibilityNodeInfo firstButton = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.firstButton)).get(0);
+ assertEquals(firstButton, firstFrameLayout.getChild(2));
}
@MediumTest
public void testDescendantsOfNotImportantViewReportedInOrder2() throws Exception {
- AccessibilityNodeInfo secondFrameLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondFrameLayout));
+ AccessibilityNodeInfo secondFrameLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondFrameLayout)).get(0);
assertNotNull(secondFrameLayout);
assertSame(3, secondFrameLayout.getChildCount());
// Check if the first child is the right one.
- AccessibilityNodeInfo secondTextView = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondTextView));
- assertEquals(secondTextView, getInteractionBridge().getChild(secondFrameLayout, 0));
+ AccessibilityNodeInfo secondTextView = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondTextView)).get(0);
+ assertEquals(secondTextView, secondFrameLayout.getChild(0));
// Check if the second child is the right one.
- AccessibilityNodeInfo secondEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondEditText));
- assertEquals(secondEditText, getInteractionBridge().getChild(secondFrameLayout, 1));
+ AccessibilityNodeInfo secondEditText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondEditText)).get(0);
+ assertEquals(secondEditText, secondFrameLayout.getChild(1));
// Check if the third child is the right one.
- AccessibilityNodeInfo secondButton = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondButton));
- assertEquals(secondButton, getInteractionBridge().getChild(secondFrameLayout, 2));
+ AccessibilityNodeInfo secondButton = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondButton)).get(0);
+ assertEquals(secondButton, secondFrameLayout.getChild(2));
}
@MediumTest
public void testDescendantsOfNotImportantViewReportedInOrder3() throws Exception {
- AccessibilityNodeInfo rootLinearLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.rootLinearLayout));
+ AccessibilityNodeInfo rootLinearLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.rootLinearLayout)).get(0);
assertNotNull(rootLinearLayout);
assertSame(4, rootLinearLayout.getChildCount());
// Check if the first child is the right one.
- AccessibilityNodeInfo firstFrameLayout = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.firstFrameLayout));
- assertEquals(firstFrameLayout, getInteractionBridge().getChild(rootLinearLayout, 0));
+ AccessibilityNodeInfo firstFrameLayout = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.firstFrameLayout)).get(0);
+ assertEquals(firstFrameLayout, rootLinearLayout.getChild(0));
// Check if the second child is the right one.
- AccessibilityNodeInfo secondTextView = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondTextView));
- assertEquals(secondTextView, getInteractionBridge().getChild(rootLinearLayout, 1));
+ AccessibilityNodeInfo secondTextView = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondTextView)).get(0);
+ assertEquals(secondTextView, rootLinearLayout.getChild(1));
// Check if the third child is the right one.
- AccessibilityNodeInfo secondEditText = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondEditText));
- assertEquals(secondEditText, getInteractionBridge().getChild(rootLinearLayout, 2));
+ AccessibilityNodeInfo secondEditText = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondEditText)).get(0);
+ assertEquals(secondEditText, rootLinearLayout.getChild(2));
// Check if the fourth child is the right one.
- AccessibilityNodeInfo secondButton = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.secondButton));
- assertEquals(secondButton, getInteractionBridge().getChild(rootLinearLayout, 3));
+ AccessibilityNodeInfo secondButton = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.secondButton)).get(0);
+ assertEquals(secondButton, rootLinearLayout.getChild(3));
}
}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index f83c35c..0ea9a7f 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -24,6 +24,8 @@
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_SELECT;
import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.UiAutomation;
import android.graphics.Rect;
import android.os.SystemClock;
import android.test.suitebuilder.annotation.MediumTest;
@@ -41,17 +43,6 @@
* Test cases for testing the accessibility APIs for querying of the screen content.
* These APIs allow exploring the screen and requesting an action to be performed
* on a given view from an AccessiiblityService.
- * <p>
- * Note: The accessibility CTS tests are composed of two APKs, one with delegating
- * accessibility service and another with the instrumented activity and test cases.
- * The delegating service is installed and enabled during test execution. It serves
- * as a proxy to the system used by the tests. This indirection is needed since the
- * test runner stops the package before running the tests. Hence, if the accessibility
- * service is in the test package running the tests would break the binding between
- * the service and the system. The delegating service is in
- * <strong>CtsDelegatingAccessibilityService.apk</strong> whose source is located at
- * <strong>cts/tests/accessibilityservice</strong>.
- * </p>
*/
public class AccessibilityWindowQueryTest
extends AccessibilityActivityTestCase<AccessibilityWindowQueryActivity> {
@@ -63,23 +54,26 @@
@MediumTest
public void testFindByText() throws Exception {
// find a view by text
- List<AccessibilityNodeInfo> buttons =
- getInteractionBridge().findAccessibilityNodeInfosByText("butto");
+ List<AccessibilityNodeInfo> buttons = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText("butto");
assertEquals(9, buttons.size());
}
@MediumTest
public void testFindByContentDescription() throws Exception {
// find a view by text
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.contentDescription));
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.contentDescription)).get(0);
assertNotNull(button);
}
@MediumTest
public void testTraverseWindow() throws Exception {
try {
- getInteractionBridge().setRegardViewsNotImportantForAccessibility(true);
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
// make list of expected nodes
List<String> classNameAndTextList = new ArrayList<String>();
@@ -101,7 +95,7 @@
classNameAndTextList.add("android.widget.ButtonButton9");
Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
- fringe.add(getInteractionBridge().getRootInActiveWindow());
+ fringe.add(getInstrumentation().getUiAutomation().getRootInActiveWindow());
// do a BFS traversal and check nodes
while (!fringe.isEmpty()) {
@@ -117,111 +111,118 @@
final int childCount = current.getChildCount();
for (int i = 0; i < childCount; i++) {
- AccessibilityNodeInfo child = getInteractionBridge().getChild(current, i);
+ AccessibilityNodeInfo child = current.getChild(i);
fringe.add(child);
}
}
} finally {
- getInteractionBridge().setRegardViewsNotImportantForAccessibility(false);
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
}
}
@MediumTest
public void testPerformActionFocus() throws Exception {
// find a view and make sure it is not focused
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isFocused());
// focus the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_FOCUS));
+ assertTrue(button.performAction(ACTION_FOCUS));
// find the view again and make sure it is focused
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertTrue(button.isFocused());
}
@MediumTest
public void testPerformActionClearFocus() throws Exception {
// find a view and make sure it is not focused
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isFocused());
// focus the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_FOCUS));
+ assertTrue(button.performAction(ACTION_FOCUS));
// find the view again and make sure it is focused
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertTrue(button.isFocused());
// unfocus the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_CLEAR_FOCUS));
+ assertTrue(button.performAction(ACTION_CLEAR_FOCUS));
// find the view again and make sure it is not focused
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(getString(
- R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertFalse(button.isFocused());
}
@MediumTest
public void testPerformActionSelect() throws Exception {
// find a view and make sure it is not selected
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
// select the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_SELECT));
+ assertTrue(button.performAction(ACTION_SELECT));
// find the view again and make sure it is selected
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertTrue(button.isSelected());
}
@MediumTest
public void testPerformActionClearSelection() throws Exception {
// find a view and make sure it is not selected
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
// select the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_SELECT));
+ assertTrue(button.performAction(ACTION_SELECT));
// find the view again and make sure it is selected
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertTrue(button.isSelected());
// unselect the view
- assertTrue(getInteractionBridge().performAction(button, ACTION_CLEAR_SELECTION));
+ assertTrue(button.performAction(ACTION_CLEAR_SELECTION));
// find the view again and make sure it is not selected
- button = getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ button = getInstrumentation().getUiAutomation().getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
}
@MediumTest
public void testPerformActionClick() throws Exception {
// find a view and make sure it is not selected
- final AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ final AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
// Make an action and wait for an event.
- AccessibilityEvent expected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent expected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(button, ACTION_CLICK);
+ button.performAction(ACTION_CLICK);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED);
@@ -236,18 +237,19 @@
@MediumTest
public void testPerformActionLongClick() throws Exception {
// find a view and make sure it is not selected
- final AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
+ final AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
// Make an action and wait for an event.
- AccessibilityEvent expected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
+ AccessibilityEvent expected = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(new Runnable() {
@Override
public void run() {
- getInteractionBridge().performAction(button, ACTION_LONG_CLICK);
+ button.performAction(ACTION_LONG_CLICK);
}
- }, new AccessibilityEventFilter() {
+ }, new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return (event.getEventType() == AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
@@ -262,21 +264,21 @@
@MediumTest
public void testGetEventSource() throws Exception {
// find a view and make sure it is not focused
- final AccessibilityNodeInfo button =
- getInteractionBridge().findAccessibilityNodeInfoByTextFromRoot(
- getString(R.string.button5));
+ final AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
assertFalse(button.isSelected());
// focus and wait for the event
- AccessibilityEvent awaitedEvent =
- getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ AccessibilityEvent awaitedEvent = getInstrumentation().getUiAutomation()
+ .executeAndWaitForEvent(
new Runnable() {
@Override
public void run() {
- assertTrue(getInteractionBridge().performAction(button, ACTION_FOCUS));
+ assertTrue(button.performAction(ACTION_FOCUS));
}
},
- new AccessibilityEventFilter() {
+ new UiAutomation.AccessibilityEventFilter() {
@Override
public boolean accept(AccessibilityEvent event) {
return (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED);
@@ -287,7 +289,7 @@
assertNotNull(awaitedEvent);
// check that last event source
- AccessibilityNodeInfo source = getInteractionBridge().getSource(awaitedEvent);
+ AccessibilityNodeInfo source = awaitedEvent.getSource();
assertNotNull(source);
// bounds
@@ -321,7 +323,7 @@
@MediumTest
public void testPerformGlobalActionBack() throws Exception {
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK));
// Sleep a bit so the UI is settles.
@@ -330,7 +332,7 @@
@MediumTest
public void testPerformGlobalActionHome() throws Exception {
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_HOME));
// Sleep a bit so the UI is settles.
@@ -340,14 +342,14 @@
@MediumTest
public void testPerformGlobalActionRecents() throws Exception {
// Check whether the action succeeded.
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_RECENTS));
// Sleep a bit so the UI is settles.
SystemClock.sleep(3000);
// Clean up.
- getInteractionBridge().performGlobalAction(
+ getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK);
// Sleep a bit so the UI is settles.
@@ -357,14 +359,14 @@
@MediumTest
public void testPerformGlobalActionNotifications() throws Exception {
// Perform the action under test
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS));
// Sleep a bit so the UI is settles.
SystemClock.sleep(3000);
// Clean up.
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK));
// Sleep a bit so the UI is settles.
@@ -374,14 +376,14 @@
@MediumTest
public void testPerformGlobalActionQuickSettings() throws Exception {
// Check whether the action succeeded.
- assertTrue(getInteractionBridge().performGlobalAction(
+ assertTrue(getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_QUICK_SETTINGS));
// Sleep a bit so the UI is settles.
SystemClock.sleep(3000);
// Clean up.
- getInteractionBridge().performGlobalAction(
+ getInstrumentation().getUiAutomation().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_BACK);
// Sleep a bit so the UI is settles.
@@ -391,14 +393,18 @@
@MediumTest
public void testObjectContract() throws Exception {
try {
- getInteractionBridge().setRegardViewsNotImportantForAccessibility(true);
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
+
// find a view and make sure it is not focused
- AccessibilityNodeInfo button = getInteractionBridge()
- .findAccessibilityNodeInfoByTextFromRoot(getString(R.string.button5));
- AccessibilityNodeInfo parent = getInteractionBridge().getParent(button);
+ AccessibilityNodeInfo button = getInstrumentation().getUiAutomation()
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText(
+ getString(R.string.button5)).get(0);
+ AccessibilityNodeInfo parent = button.getParent();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
- AccessibilityNodeInfo child = getInteractionBridge().getChild(parent, i);
+ AccessibilityNodeInfo child = parent.getChild(i);
assertNotNull(child);
if (child.equals(button)) {
assertEquals("Equal objects must have same hasCode.", button.hashCode(),
@@ -408,7 +414,9 @@
}
fail("Parent's children do not have the info whose parent is the parent.");
} finally {
- getInteractionBridge().setRegardViewsNotImportantForAccessibility(false);
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
}
}
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index ab7410b..231bd83 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -30,6 +30,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.CRC32;
@@ -88,13 +89,12 @@
/**
* @param testinput the file to decode
- * @param master the "golden master" to compared against
* @param maxerror the maximum allowed root mean squared error
* @throws IOException
*/
private void decode(int testinput, float maxerror) throws IOException {
- short [] decoded = decodeToMemory(testinput);
+ short [] decoded = decodeToMemory(testinput, false);
assertEquals("wrong data size", mMasterBuffer.length, decoded.length);
@@ -110,11 +110,17 @@
long avgErrorSquared = (totalErrorSquared / decoded.length);
double rmse = Math.sqrt(avgErrorSquared);
assertTrue("decoding error too big: " + rmse, rmse <= maxerror);
- }
- private short[] decodeToMemory(int testinput) throws IOException {
+ short [] decoded2 = decodeToMemory(testinput, true);
+ assertEquals("count different with reconfigure", decoded.length, decoded2.length);
+ for (int i = 0; i < decoded.length; i++) {
+ assertEquals("samples don't match", decoded[i], decoded2[i]);
+ }
+ }
- short [] decoded = new short[1024];
+ private short[] decodeToMemory(int testinput, boolean reconfigure) throws IOException {
+
+ short [] decoded = new short[0];
int decodedIdx = 0;
AssetFileDescriptor testFd = mResources.openRawResourceFd(testinput);
@@ -140,6 +146,14 @@
codecInputBuffers = codec.getInputBuffers();
codecOutputBuffers = codec.getOutputBuffers();
+ if (reconfigure) {
+ codec.stop();
+ codec.configure(format, null /* surface */, null /* crypto */, 0 /* flags */);
+ codec.start();
+ codecInputBuffers = codec.getInputBuffers();
+ codecOutputBuffers = codec.getOutputBuffers();
+ }
+
extractor.selectTrack(0);
// start decoding
@@ -183,6 +197,21 @@
int res = codec.dequeueOutputBuffer(info, kTimeOutUs);
if (res >= 0) {
+ //Log.d(TAG, "got frame, size " + info.size + "/" + info.presentationTimeUs);
+
+ if (info.size > 0 && reconfigure) {
+ // once we've gotten some data out of the decoder, reconfigure it again
+ reconfigure = false;
+ extractor.seekTo(0, MediaExtractor.SEEK_TO_NEXT_SYNC);
+ sawInputEOS = false;
+ codec.stop();
+ codec.configure(format, null /* surface */, null /* crypto */, 0 /* flags */);
+ codec.start();
+ codecInputBuffers = codec.getInputBuffers();
+ codecOutputBuffers = codec.getOutputBuffers();
+ continue;
+ }
+
int outputBufIndex = res;
ByteBuffer buf = codecOutputBuffers[outputBufIndex];
@@ -208,6 +237,8 @@
MediaFormat oformat = codec.getOutputFormat();
Log.d(TAG, "output format has changed to " + oformat);
+ } else {
+ Log.d(TAG, "dequeueOutputBuffer returned " + res);
}
}
@@ -220,12 +251,12 @@
Surface s = getActivity().getSurfaceHolder().getSurface();
int frames1 = countFrames(
R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz,
- false, s);
+ false, -1, s);
assertEquals("wrong number of frames decoded", 240, frames1);
int frames2 = countFrames(
R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz,
- false, null);
+ false, -1, null);
assertEquals("different number of frames when using Surface", frames1, frames2);
}
@@ -233,15 +264,31 @@
Surface s = getActivity().getSurfaceHolder().getSurface();
int frames1 = countFrames(
R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz,
- false, s);
+ false /* reconfigure */, -1 /* eosframe */, s);
assertEquals("wrong number of frames decoded", 122, frames1);
int frames2 = countFrames(
R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz,
- false, null);
+ false /* reconfigure */, -1 /* eosframe */, null);
assertEquals("different number of frames when using Surface", frames1, frames2);
}
+ public void testCodecEarlyEOSH263() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz,
+ false, 64, s);
+ assertEquals("wrong number of frames decoded", 64, frames1);
+ }
+
+ public void testCodecEarlyEOSH264() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, 120, s);
+ assertEquals("wrong number of frames decoded", 120, frames1);
+ }
+
public void testCodecReconfigH264WithoutSurface() throws Exception {
testCodecReconfig(
R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz, null);
@@ -277,12 +324,12 @@
}
private void testCodecReconfig(int video, Surface s) throws Exception {
- int frames1 = countFrames(video, false, s);
- int frames2 = countFrames(video, true, s);
+ int frames1 = countFrames(video, false /* reconfigure */, -1 /* eosframe */, s);
+ int frames2 = countFrames(video, true /* reconfigure */, -1 /* eosframe */, s);
assertEquals("different number of frames when reusing codec", frames1, frames2);
}
- private int countFrames(int video, boolean reconfigure, Surface s) throws Exception {
+ private int countFrames(int video, boolean reconfigure, int eosframe, Surface s) throws Exception {
int numframes = 0;
AssetFileDescriptor testFd = mResources.openRawResourceFd(video);
@@ -330,6 +377,8 @@
boolean sawInputEOS = false;
boolean sawOutputEOS = false;
int deadDecoderCounter = 0;
+ int samplecounter = 0;
+ ArrayList<Long> timestamps = new ArrayList<Long>();
while (!sawOutputEOS && deadDecoderCounter < 100) {
if (!sawInputEOS) {
int inputBufIndex = codec.dequeueInputBuffer(kTimeOutUs);
@@ -348,8 +397,14 @@
sampleSize = 0;
} else {
presentationTimeUs = extractor.getSampleTime();
+ samplecounter++;
+ if (samplecounter == eosframe) {
+ sawInputEOS = true;
+ }
}
+ timestamps.add(presentationTimeUs);
+
int flags = extractor.getSampleFlags();
codec.queueInputBuffer(
@@ -380,6 +435,7 @@
numframes = 0;
extractor.seekTo(0, MediaExtractor.SEEK_TO_NEXT_SYNC);
sawInputEOS = false;
+ timestamps.clear();
codec.stop();
codec.configure(format, s /* surface */, null /* crypto */, 0 /* flags */);
codec.start();
@@ -393,8 +449,9 @@
// of access units
numframes += info.size;
} else {
- // for video, count the number of video frames
+ // for video, count the number of video frames and check the timestamp
numframes++;
+ assertTrue("invalid timestamp", timestamps.remove(info.presentationTimeUs));
}
}
int outputBufIndex = res;
@@ -750,8 +807,8 @@
codec.flush();
short maxvalue2 = getAmplitude(extractor, codec);
- assertTrue(maxvalue1 > 20000);
- assertTrue(maxvalue2 < 5000);
+ assertTrue("first section amplitude too low", maxvalue1 > 20000);
+ assertTrue("second section amplitude too high", maxvalue2 < 5000);
codec.stop();
codec.release();
diff --git a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
index c244159..d4bff12 100644
--- a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -113,25 +113,30 @@
public void testSetNetworkPreference() {
// verify swtiching between two default networks - need to connectable networks though
// could use test and whatever the current active network is
- NetworkInfo active = mCm.getActiveNetworkInfo();
int originalPref = mCm.getNetworkPreference();
int currentPref = originalPref;
for (int type = -1; type <= ConnectivityManager.MAX_NETWORK_TYPE+1; type++) {
mCm.setNetworkPreference(type);
NetworkConfig c = mNetworks.get(type);
boolean expectWorked = (c != null && c.isDefault());
- try {
- Thread.currentThread().sleep(100);
- } catch (InterruptedException e) {}
- int foundType = mCm.getNetworkPreference();
+ int totalSleep = 0;
+ int foundType = ConnectivityManager.TYPE_NONE;
+ while (totalSleep < 1000) {
+ try {
+ Thread.currentThread().sleep(100);
+ } catch (InterruptedException e) {}
+ totalSleep += 100;
+ foundType = mCm.getNetworkPreference();
+ if (currentPref != foundType) break;
+ }
if (expectWorked) {
assertTrue("We should have been able to switch prefered type " + type,
foundType == type);
- currentPref = foundType;
} else {
assertTrue("We should not have been able to switch type " + type,
- foundType == currentPref);
+ foundType != type);
}
+ currentPref = foundType;
}
mCm.setNetworkPreference(originalPref);
}
@@ -171,6 +176,10 @@
for (NetworkInfo i : ni) {
if (i.getType() == type) foundCount++;
}
+ if (foundCount != desiredFoundCount) {
+ Log.e(TAG, "failure in testGetAllNetworkInfo. Dump of returned NetworkInfos:");
+ for (NetworkInfo networkInfo : ni) Log.e(TAG, " " + networkInfo);
+ }
assertTrue("Unexpected foundCount of " + foundCount + " for type " + type,
foundCount == desiredFoundCount);
}
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index dfa8301..888a768 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -29,7 +29,7 @@
private static final String LOG_TAG = "BuildVersionTest";
private static final Set<String> EXPECTED_RELEASES =
- new HashSet<String>(Arrays.asList("4.2", "4.2.1", "4.2.2"));
+ new HashSet<String>(Arrays.asList("4.3"));
private static final int EXPECTED_SDK = 17;
@SuppressWarnings("deprecation")
diff --git a/tests/tests/provider/AndroidManifest.xml b/tests/tests/provider/AndroidManifest.xml
index 75a6392..94dc408 100644
--- a/tests/tests/provider/AndroidManifest.xml
+++ b/tests/tests/provider/AndroidManifest.xml
@@ -16,11 +16,28 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.cts.provider">
+ package="com.android.cts.provider">
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
+ <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+
<application>
- <uses-library android:name="android.test.runner" />
+ <uses-library android:name="android.test.runner"/>
+
+ <service android:name="android.provider.cts.contacts.account.MockAccountService"
+ process="com.android.cts.provider"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.accounts.AccountAuthenticator"/>
+ </intent-filter>
+
+ <meta-data android:name="android.accounts.AccountAuthenticator"
+ android:resource="@xml/contactprovider_authenticator"/>
+ </service>
+
</application>
<instrumentation android:name="android.test.InstrumentationCtsTestRunner"
diff --git a/tests/tests/provider/res/drawable/ic_cts_minitab_selected.png b/tests/tests/provider/res/drawable/ic_cts_minitab_selected.png
new file mode 100644
index 0000000..c730050
--- /dev/null
+++ b/tests/tests/provider/res/drawable/ic_cts_minitab_selected.png
Binary files differ
diff --git a/tests/tests/provider/res/drawable/ic_cts_selected.png b/tests/tests/provider/res/drawable/ic_cts_selected.png
new file mode 100644
index 0000000..72a065c
--- /dev/null
+++ b/tests/tests/provider/res/drawable/ic_cts_selected.png
Binary files differ
diff --git a/tests/tests/provider/res/values/strings.xml b/tests/tests/provider/res/values/strings.xml
new file mode 100644
index 0000000..b599c31
--- /dev/null
+++ b/tests/tests/provider/res/values/strings.xml
@@ -0,0 +1,20 @@
+<!--
+ ~ Copyright (C) 2013 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Label for this package -->
+ <string name="label">Contacts provider</string>
+</resources>
diff --git a/tests/tests/provider/res/xml/contactprovider_authenticator.xml b/tests/tests/provider/res/xml/contactprovider_authenticator.xml
new file mode 100644
index 0000000..2a53438
--- /dev/null
+++ b/tests/tests/provider/res/xml/contactprovider_authenticator.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2013 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:accountType="com.android.cts.contactsprovider"
+ android:icon="@drawable/ic_cts_selected"
+ android:smallIcon="@drawable/ic_cts_minitab_selected"
+ android:label="@string/label"
+/>
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_ContactsTest.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_ContactsTest.java
index 271588f..006f4df 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_ContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_ContactsTest.java
@@ -33,6 +33,7 @@
import android.provider.cts.contacts.ContactUtil;
import android.provider.cts.contacts.DatabaseAsserts;
import android.provider.cts.contacts.RawContactUtil;
+import android.provider.cts.contacts.account.StaticAccountAuthenticator;
import android.test.AndroidTestCase;
import java.util.List;
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
index 51d62a3..7cfb183 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
@@ -215,9 +215,7 @@
public void testDataUpdate_updatesContactLastUpdatedTimestamp() {
DatabaseAsserts.ContactIdPair ids = DatabaseAsserts.assertAndCreateContact(mResolver);
-
long dataId = createData(ids.mRawContactId);
-
long baseTime = ContactUtil.queryContactLastUpdatedTimestamp(mResolver, ids.mContactId);
SystemClock.sleep(1);
@@ -226,7 +224,8 @@
DataUtil.update(mResolver, dataId, values);
long newTime = ContactUtil.queryContactLastUpdatedTimestamp(mResolver, ids.mContactId);
- assertTrue(newTime > baseTime);
+ assertTrue("Expected contact " + ids.mContactId + " last updated to be greater than " +
+ baseTime + ". But was " + newTime, newTime > baseTime);
// Clean up
RawContactUtil.delete(mResolver, ids.mRawContactId, true);
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataUsageTest.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataUsageTest.java
index a684e41..d585ec2 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataUsageTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataUsageTest.java
@@ -16,7 +16,6 @@
package android.provider.cts;
-import static android.provider.ContactsContract.CommonDataKinds;
import static android.provider.ContactsContract.DataUsageFeedback;
import android.content.ContentResolver;
@@ -85,27 +84,10 @@
private long[] setupRawContactDataItems(long rawContactId) {
// Create 4 data items.
long[] dataIds = new long[4];
-
- ContentValues values = new ContentValues();
- values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
- values.put(CommonDataKinds.Phone.NUMBER, "555-5555");
- dataIds[0] = DataUtil.insertData(mResolver, rawContactId, values);
-
- values.clear();
- values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
- values.put(CommonDataKinds.Phone.NUMBER, "555-5554");
- dataIds[1] = DataUtil.insertData(mResolver, rawContactId, values);
-
- values.clear();
- values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Email.CONTENT_ITEM_TYPE);
- values.put(CommonDataKinds.Email.ADDRESS, "test@thisisfake.com");
- dataIds[2] = DataUtil.insertData(mResolver, rawContactId, values);
-
- values.clear();
- values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Email.CONTENT_ITEM_TYPE);
- values.put(CommonDataKinds.Phone.NUMBER, "555-5556");
- dataIds[3] = DataUtil.insertData(mResolver, rawContactId, values);
-
+ dataIds[0] = DataUtil.insertPhoneNumber(mResolver, rawContactId, "555-5555");
+ dataIds[1] = DataUtil.insertPhoneNumber(mResolver, rawContactId, "555-5554");
+ dataIds[2] = DataUtil.insertEmail(mResolver, rawContactId, "test@thisisfake.com");
+ dataIds[3] = DataUtil.insertPhoneNumber(mResolver, rawContactId, "555-5556");
return dataIds;
}
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_RawContactsTest.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_RawContactsTest.java
index d9751f4..e1cea4a 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_RawContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_RawContactsTest.java
@@ -30,6 +30,7 @@
import android.provider.cts.contacts.ContactUtil;
import android.provider.cts.contacts.DatabaseAsserts;
import android.provider.cts.contacts.RawContactUtil;
+import android.provider.cts.contacts.account.StaticAccountAuthenticator;
import android.test.AndroidTestCase;
import android.test.MoreAsserts;
@@ -91,7 +92,8 @@
}
public void testRawContactDelete_setsDeleteFlag() {
- long rawContactid = RawContactUtil.insertRawContact(mResolver);
+ long rawContactid = RawContactUtil.insertRawContact(mResolver,
+ StaticAccountAuthenticator.ACCOUNT_1);
assertTrue(RawContactUtil.rawContactExistsById(mResolver, rawContactid));
@@ -111,7 +113,8 @@
}
public void testRawContactDelete_removesRecord() {
- long rawContactid = RawContactUtil.insertRawContact(mResolver);
+ long rawContactid = RawContactUtil.insertRawContact(mResolver,
+ StaticAccountAuthenticator.ACCOUNT_1);
assertTrue(RawContactUtil.rawContactExistsById(mResolver, rawContactid));
RawContactUtil.delete(mResolver, rawContactid, true);
@@ -126,13 +129,14 @@
public void testRawContactCreate_updatesContactUpdatedTimestamp() {
long startTime = System.currentTimeMillis();
- long rawContactId = RawContactUtil.createRawContactWithName(mResolver);
- long lastUpdated = getContactLastUpdatedTimestampByRawContactId(mResolver, rawContactId);
+ DatabaseAsserts.ContactIdPair ids = DatabaseAsserts.assertAndCreateContact(mResolver);
+ long lastUpdated = getContactLastUpdatedTimestampByRawContactId(mResolver,
+ ids.mRawContactId);
assertTrue(lastUpdated > startTime);
// Clean up
- RawContactUtil.delete(mResolver, rawContactId, true);
+ RawContactUtil.delete(mResolver, ids.mRawContactId, true);
}
public void testRawContactUpdate_updatesContactUpdatedTimestamp() {
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsProvider2_AccountRemovalTest.java b/tests/tests/provider/src/android/provider/cts/ContactsProvider2_AccountRemovalTest.java
new file mode 100644
index 0000000..f700220
--- /dev/null
+++ b/tests/tests/provider/src/android/provider/cts/ContactsProvider2_AccountRemovalTest.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.provider.cts;
+
+import static android.provider.cts.contacts.DatabaseAsserts.ContactIdPair;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.ContentResolver;
+import android.os.SystemClock;
+import android.provider.cts.contacts.CommonDatabaseUtils;
+import android.provider.cts.contacts.ContactUtil;
+import android.provider.cts.contacts.DataUtil;
+import android.provider.cts.contacts.DatabaseAsserts;
+import android.provider.cts.contacts.DeletedContactUtil;
+import android.provider.cts.contacts.RawContactUtil;
+import android.provider.cts.contacts.account.StaticAccountAuthenticator;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.MediumTest;
+
+import com.google.android.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@MediumTest
+public class ContactsProvider2_AccountRemovalTest extends AndroidTestCase {
+
+ private static long ASYNC_TIMEOUT_LIMIT_MS = 1000 * 60 * 1; // 3 minutes
+ private static long SLEEP_BETWEEN_POLL_MS = 1000 * 10; // 10 seconds
+
+ private static int NOT_MERGED = -1;
+
+ // Not re-using StaticAcountAuthenticator.ACCOUNT_1 because this test may break
+ // other tests running when the account is removed. No other tests should use the following
+ // accounts.
+ private static final Account ACCT_1 = new Account("cp removal acct 1",
+ StaticAccountAuthenticator.TYPE);
+ private static final Account ACCT_2 = new Account("cp removal acct 2",
+ StaticAccountAuthenticator.TYPE);
+
+ private ContentResolver mResolver;
+ private AccountManager mAccountManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mResolver = getContext().getContentResolver();
+ mAccountManager = AccountManager.get(getContext());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testAccountRemoval_deletesContacts() {
+ mAccountManager.addAccountExplicitly(ACCT_1, null, null);
+ mAccountManager.addAccountExplicitly(ACCT_2, null, null);
+ ArrayList<ContactIdPair> acc1Ids = createContacts(ACCT_1, 5);
+ ArrayList<ContactIdPair> acc2Ids = createContacts(ACCT_2, 15);
+
+ mAccountManager.removeAccount(ACCT_2, null, null);
+ assertContactsDeletedEventually(System.currentTimeMillis(), acc2Ids);
+
+ mAccountManager.removeAccount(ACCT_1, null, null);
+ assertContactsDeletedEventually(System.currentTimeMillis(), acc1Ids);
+ }
+
+ public void testAccountRemoval_hasDeleteLogsForContacts() {
+ mAccountManager.addAccountExplicitly(ACCT_1, null, null);
+ mAccountManager.addAccountExplicitly(ACCT_2, null, null);
+ ArrayList<ContactIdPair> acc1Ids = createContacts(ACCT_1, 5);
+ ArrayList<ContactIdPair> acc2Ids = createContacts(ACCT_2, 15);
+
+ long start = System.currentTimeMillis();
+ mAccountManager.removeAccount(ACCT_2, null, null);
+ assertContactsInDeleteLogEventually(start, acc2Ids);
+
+ start = System.currentTimeMillis();
+ mAccountManager.removeAccount(ACCT_1, null, null);
+ assertContactsInDeleteLogEventually(start, acc1Ids);
+ }
+
+ /**
+ * Contact has merged raw contacts from a single account. Contact should be deleted upon
+ * account removal.
+ */
+ public void testAccountRemovalWithMergedContact_deletesContacts() {
+ mAccountManager.addAccountExplicitly(ACCT_1, null, null);
+ ArrayList<ContactIdPair> idList = createAndAssertMergedContact(ACCT_1, ACCT_1);
+ mAccountManager.removeAccount(ACCT_1, null, null);
+ assertContactsDeletedEventually(System.currentTimeMillis(), idList);
+ }
+
+ /**
+ * Contact has merged raw contacts from different accounts. Contact should not be deleted when
+ * one account is removed. But contact should have last updated timestamp updated.
+ */
+ public void testAccountRemovalWithMergedContact_doesNotDeleteContactAndTimestampUpdated() {
+ mAccountManager.addAccountExplicitly(ACCT_1, null, null);
+ ArrayList<ContactIdPair> idList = createAndAssertMergedContact(ACCT_1, ACCT_2);
+ long contactId = idList.get(0).mContactId;
+
+ long baseTime = ContactUtil.queryContactLastUpdatedTimestamp(mResolver, contactId);
+ long start = System.currentTimeMillis();
+ mAccountManager.removeAccount(ACCT_1, null, null);
+
+ while (ContactUtil.queryContactLastUpdatedTimestamp(mResolver, contactId) == baseTime) {
+ assertWithinTimeoutLimit(start,
+ "Contact " + contactId + " last updated timestamp has not been updated.");
+ SystemClock.sleep(SLEEP_BETWEEN_POLL_MS);
+ }
+ }
+
+ public void testAccountRemovalWithMergedContact_hasDeleteLogsForContacts() {
+ mAccountManager.addAccountExplicitly(ACCT_1, null, null);
+ ArrayList<ContactIdPair> idList = createAndAssertMergedContact(ACCT_1, ACCT_1);
+ long start = System.currentTimeMillis();
+ mAccountManager.removeAccount(ACCT_1, null, null);
+ assertContactsInDeleteLogEventually(start, idList);
+ }
+
+ private ArrayList<ContactIdPair> createAndAssertMergedContact(Account acct, Account acct2) {
+ ContactIdPair ids1 = DatabaseAsserts.assertAndCreateContactWithName(mResolver, acct,
+ "merge me");
+ DataUtil.insertPhoneNumber(mResolver, ids1.mRawContactId, "555-5555");
+
+ ContactIdPair ids2 = DatabaseAsserts.assertAndCreateContactWithName(mResolver, acct2,
+ "merge me");
+ DataUtil.insertPhoneNumber(mResolver, ids2.mRawContactId, "555-5555");
+
+ // Check merge before continuing. Merge process is async.
+ long mergedContactId = assertMerged(System.currentTimeMillis(), ids1.mRawContactId,
+ ids2.mRawContactId);
+
+ // Update the contact id to the newly merged contact id.
+ ids1.mContactId = mergedContactId;
+ ids2.mContactId = mergedContactId;
+
+ return Lists.newArrayList(ids1, ids2);
+ }
+
+ private long assertMerged(long start, long rawContactId, long rawContactId2) {
+ long contactId = NOT_MERGED;
+ while (contactId == NOT_MERGED) {
+ assertWithinTimeoutLimit(start,
+ "Raw contact " + rawContactId + " and " + rawContactId2 + " are not merged.");
+
+ SystemClock.sleep(SLEEP_BETWEEN_POLL_MS);
+ contactId = checkMerged(rawContactId, rawContactId2);
+ }
+ return contactId;
+ }
+
+ private long checkMerged(long rawContactId, long rawContactId2) {
+ long contactId = RawContactUtil.queryContactIdByRawContactId(mResolver, rawContactId);
+ long contactId2 = RawContactUtil.queryContactIdByRawContactId(mResolver, rawContactId2);
+ if (contactId == contactId2) {
+ return contactId;
+ }
+ return NOT_MERGED;
+ }
+
+ private void assertContactsInDeleteLogEventually(long start, ArrayList<ContactIdPair> idList) {
+ // Can not use newArrayList() because the version that accepts size is missing.
+ ArrayList<ContactIdPair> remaining = new ArrayList<ContactIdPair>(idList.size());
+ remaining.addAll(idList);
+ while (!remaining.isEmpty()) {
+ // Account cleanup is asynchronous, wait a bit before checking.
+ SystemClock.sleep(SLEEP_BETWEEN_POLL_MS);
+ assertWithinTimeoutLimit(start, "Contacts " + Arrays.toString(remaining.toArray()) +
+ " are not in delete log after account removal.");
+
+ // Need a second list to remove since we can't remove from the list while iterating.
+ ArrayList<ContactIdPair> toBeRemoved = Lists.newArrayList();
+ for (ContactIdPair ids : remaining) {
+ long deletedTime = DeletedContactUtil.queryDeletedTimestampForContactId(mResolver,
+ ids.mContactId);
+ if (deletedTime != CommonDatabaseUtils.NOT_FOUND) {
+ toBeRemoved.add(ids);
+ assertTrue("Deleted contact was found in delete log but insert time is before"
+ + " start time", deletedTime > start);
+ }
+ }
+ remaining.removeAll(toBeRemoved);
+ }
+
+ // All contacts in delete log. Pass.
+ }
+
+ /**
+ * Polls every so often to see if all contacts have been deleted. If not deleted in the
+ * pre-defined threshold, fails.
+ */
+ private void assertContactsDeletedEventually(long start, ArrayList<ContactIdPair> idList) {
+ // Can not use newArrayList() because the version that accepts size is missing.
+ ArrayList<ContactIdPair> remaining = new ArrayList<ContactIdPair>(idList.size());
+ remaining.addAll(idList);
+ while (!remaining.isEmpty()) {
+ // Account cleanup is asynchronous, wait a bit before checking.
+ SystemClock.sleep(SLEEP_BETWEEN_POLL_MS);
+ assertWithinTimeoutLimit(start, "Contacts have not been deleted after account"
+ + " removal.");
+
+ ArrayList<ContactIdPair> toBeRemoved = Lists.newArrayList();
+ for (ContactIdPair ids : remaining) {
+ if (!RawContactUtil.rawContactExistsById(mResolver, ids.mRawContactId)) {
+ toBeRemoved.add(ids);
+ }
+ }
+ remaining.removeAll(toBeRemoved);
+ }
+
+ // All contacts deleted. Pass.
+ }
+
+ private void assertWithinTimeoutLimit(long start, String message) {
+ long now = System.currentTimeMillis();
+ long elapsed = now - start;
+ if (elapsed > ASYNC_TIMEOUT_LIMIT_MS) {
+ fail(elapsed + "ms has elapsed. The limit is " + ASYNC_TIMEOUT_LIMIT_MS + "ms. " +
+ message);
+ }
+ }
+
+ /**
+ * Creates a given number of contacts for an account.
+ */
+ private ArrayList<ContactIdPair> createContacts(Account account, int numContacts) {
+ ArrayList<ContactIdPair> accountIds = Lists.newArrayList();
+ for (int i = 0; i < numContacts; i++) {
+ accountIds.add(DatabaseAsserts.assertAndCreateContact(mResolver, account));
+ }
+ return accountIds;
+ }
+}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java b/tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java
index ae2812e..1e07450 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java
@@ -16,6 +16,8 @@
package android.provider.cts.contacts;
+import static android.provider.ContactsContract.CommonDataKinds;
+
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -36,15 +38,33 @@
return CommonDatabaseUtils.singleRecordToArray(cursor);
}
- public static void insertName(ContentResolver resolver, long rawContactId) {
+ public static void insertName(ContentResolver resolver, long rawContactId, String name) {
ContentValues values = new ContentValues();
values.put(ContactsContract.Data.MIMETYPE,
- ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
- values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
- "test raw contact " + rawContactId);
+ CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
+ values.put(CommonDataKinds.StructuredName.DISPLAY_NAME, name);
insertData(resolver, rawContactId, values);
}
+ public static long insertPhoneNumber(ContentResolver resolver, long rawContactId,
+ String number) {
+ ContentValues values = new ContentValues();
+ values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
+ values.put(CommonDataKinds.Phone.NUMBER, number);
+ return DataUtil.insertData(resolver, rawContactId, values);
+ }
+
+ public static long insertEmail(ContentResolver resolver, long rawContactId, String email) {
+ ContentValues values = new ContentValues();
+ values.put(ContactsContract.Data.MIMETYPE, CommonDataKinds.Email.CONTENT_ITEM_TYPE);
+ values.put(CommonDataKinds.Email.ADDRESS, email);
+ return DataUtil.insertData(resolver, rawContactId, values);
+ }
+
+ public static void insertAutoGeneratedName(ContentResolver resolver, long rawContactId) {
+ insertName(resolver, rawContactId, "test raw contact " + rawContactId);
+ }
+
public static long insertData(ContentResolver resolver, long rawContactId,
ContentValues values) {
// copy
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java b/tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java
index 80a0a65..19b5b13 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java
@@ -16,10 +16,12 @@
package android.provider.cts.contacts;
+import android.accounts.Account;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
+import android.provider.cts.contacts.account.StaticAccountAuthenticator;
import android.test.MoreAsserts;
import junit.framework.Assert;
@@ -53,12 +55,36 @@
}
/**
- * Create a contact and assert that the record exists.
+ * Create a contact in account 1 and assert that the record exists.
*
* @return The created contact id pair.
*/
public static ContactIdPair assertAndCreateContact(ContentResolver resolver) {
- long rawContactId = RawContactUtil.createRawContactWithName(resolver);
+ return assertAndCreateContact(resolver, StaticAccountAuthenticator.ACCOUNT_1);
+ }
+
+ /**
+ * Create a contact in a specified account and assert that the record exists.
+ *
+ * @return The created contact id pair.
+ */
+ public static ContactIdPair assertAndCreateContactWithName(ContentResolver resolver,
+ Account account, String name) {
+ long rawContactId = RawContactUtil.createRawContactWithName(resolver, account, name);
+
+ long contactId = RawContactUtil.queryContactIdByRawContactId(resolver, rawContactId);
+ MoreAsserts.assertNotEqual(CommonDatabaseUtils.NOT_FOUND, contactId);
+
+ return new ContactIdPair(contactId, rawContactId);
+ }
+
+ /**
+ * Create a contact in a specified account and assert that the record exists.
+ *
+ * @return The created contact id pair.
+ */
+ public static ContactIdPair assertAndCreateContact(ContentResolver resolver, Account account) {
+ long rawContactId = RawContactUtil.createRawContactWithAutoGeneratedName(resolver, account);
long contactId = RawContactUtil.queryContactIdByRawContactId(resolver, rawContactId);
MoreAsserts.assertNotEqual(CommonDatabaseUtils.NOT_FOUND, contactId);
@@ -94,6 +120,14 @@
this.mContactId = contactId;
this.mRawContactId = rawContactId;
}
+
+ @Override
+ public String toString() {
+ return "ContactIdPair{" +
+ "mContactId=" + mContactId +
+ ", mRawContactId=" + mRawContactId +
+ '}';
+ }
}
/**
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java b/tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java
index c87dc01..38ff33d 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java
@@ -16,13 +16,13 @@
package android.provider.cts.contacts;
+import android.accounts.Account;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
-import android.provider.cts.StaticAccountAuthenticator;
import java.util.List;
@@ -39,16 +39,24 @@
resolver.update(uri, values, null, null);
}
- public static long createRawContactWithName(ContentResolver resolver) {
- Long rawContactId = insertRawContact(resolver);
- DataUtil.insertName(resolver, rawContactId);
+ public static long createRawContactWithName(ContentResolver resolver, Account account,
+ String name) {
+ Long rawContactId = insertRawContact(resolver, account);
+ DataUtil.insertName(resolver, rawContactId, name);
return rawContactId;
}
- public static long insertRawContact(ContentResolver resolver) {
+ public static long createRawContactWithAutoGeneratedName(ContentResolver resolver,
+ Account account) {
+ Long rawContactId = insertRawContact(resolver, account);
+ DataUtil.insertAutoGeneratedName(resolver, rawContactId);
+ return rawContactId;
+ }
+
+ public static long insertRawContact(ContentResolver resolver, Account account) {
ContentValues values = new ContentValues();
- values.put(ContactsContract.RawContacts.ACCOUNT_NAME, StaticAccountAuthenticator.NAME);
- values.put(ContactsContract.RawContacts.ACCOUNT_TYPE, StaticAccountAuthenticator.TYPE);
+ values.put(ContactsContract.RawContacts.ACCOUNT_NAME, account.name);
+ values.put(ContactsContract.RawContacts.ACCOUNT_TYPE, account.type);
Uri uri = resolver.insert(URI, values);
return ContentUris.parseId(uri);
}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/account/MockAccountService.java b/tests/tests/provider/src/android/provider/cts/contacts/account/MockAccountService.java
new file mode 100644
index 0000000..33a34b3
--- /dev/null
+++ b/tests/tests/provider/src/android/provider/cts/contacts/account/MockAccountService.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.provider.cts.contacts.account;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+/**
+ * Account service for the authenticator
+ */
+public class MockAccountService extends Service {
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return (new StaticAccountAuthenticator(this)).getIBinder();
+ }
+}
diff --git a/tests/tests/provider/src/android/provider/cts/StaticAccountAuthenticator.java b/tests/tests/provider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
similarity index 91%
rename from tests/tests/provider/src/android/provider/cts/StaticAccountAuthenticator.java
rename to tests/tests/provider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
index d3c9e1d..01db2a1 100644
--- a/tests/tests/provider/src/android/provider/cts/StaticAccountAuthenticator.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package android.provider.cts;
+package android.provider.cts.contacts.account;
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
@@ -32,7 +32,9 @@
public class StaticAccountAuthenticator extends AbstractAccountAuthenticator {
public static final String NAME = "test_account_name";
- public static final String TYPE = "test_account_type";
+ public static final String TYPE = "com.android.cts.contactsprovider";
+ public static final Account ACCOUNT_1 = new Account("cp account 1", TYPE);
+
private static final String LABEL = "test_auth_token_label";
private static final String TOKEN = "asdlkjfslkjfdklj";
@@ -44,20 +46,12 @@
sAccountBundle.putString(AccountManager.KEY_AUTHTOKEN, TOKEN);
}
- private Context mContext;
-
private static Bundle createResultBundle() {
return sAccountBundle;
}
- public void addAccount() {
- AccountManager.get(mContext).addAccount(TYPE, null, null, null, null, null, null);
- }
-
public StaticAccountAuthenticator(Context context) {
super(context);
- this.mContext = context;
- addAccount();
}
@Override
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
index f895661..c446ba1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
@@ -40,20 +40,19 @@
int [] In = new int [1];
In[0] = v;
AIn.copyFrom(In);
-
}
/**
* Test whether we are properly synchronizing extern global data
- * when dealing with mixed kernels/invokables.
+ * when going from kernel to invokable.
*/
- public void testGlobalSync() {
+ public void testKIGlobalSync() {
ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
int v = 7;
setupGlobalSync(mRS, gs, v);
gs.forEach_write_global(AIn);
- gs.invoke_test_global(v);
+ gs.invoke_test_read_global(v);
AFailed.copyTo(Failed);
if (Failed[0] != 0) {
@@ -66,15 +65,57 @@
/**
* Test whether we are properly synchronizing static global data
- * when dealing with mixed kernels/invokables.
+ * when going from invokable to kernel.
*/
- public void testStaticGlobalSync() {
+ public void testKIStaticGlobalSync() {
ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
int v = 9;
setupGlobalSync(mRS, gs, v);
gs.forEach_write_static_global(AIn);
- gs.invoke_test_static_global(v);
+ gs.invoke_test_read_static_global(v);
+
+ AFailed.copyTo(Failed);
+ if (Failed[0] != 0) {
+ FoundError = true;
+ }
+
+ gs.destroy();
+ checkForErrors();
+ }
+
+ /**
+ * Test whether we are properly synchronizing extern global data
+ * when going from invokable to kernel.
+ */
+ public void testIKGlobalSync() {
+ ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+ int v = 7;
+ setupGlobalSync(mRS, gs, v);
+ gs.invoke_test_write_global(v);
+ gs.forEach_read_global(AIn, AFailed);
+
+ AFailed.copyTo(Failed);
+ if (Failed[0] != 0) {
+ FoundError = true;
+ }
+
+ gs.destroy();
+ checkForErrors();
+ }
+
+ /**
+ * Test whether we are properly synchronizing static global data
+ * when going from kernel to invokable.
+ */
+ public void testIKStaticGlobalSync() {
+ ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+ int v = 9;
+ setupGlobalSync(mRS, gs, v);
+ gs.invoke_test_write_static_global(v);
+ gs.forEach_read_static_global(AIn, AFailed);
AFailed.copyTo(Failed);
if (Failed[0] != 0) {
@@ -85,4 +126,3 @@
checkForErrors();
}
}
-
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
index 75fc599..3c8650d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
@@ -71,6 +71,9 @@
public void testNearest() {
mScript.invoke_test_RGBA(mAlloc_RGBA_1D, mAlloc_RGBA_2D);
+ mRS.finish();
+ checkForErrors();
+ waitForMessage();
}
}
diff --git a/tests/tests/text/src/android/text/cts/EmojiTest.java b/tests/tests/text/src/android/text/cts/EmojiTest.java
index 867cb8d..a8d8d2d 100755
--- a/tests/tests/text/src/android/text/cts/EmojiTest.java
+++ b/tests/tests/text/src/android/text/cts/EmojiTest.java
@@ -25,7 +25,7 @@
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
-import android.webkit.WebView;
+import android.webkit.cts.WebViewOnUiThread;
import android.widget.TextView;
import android.widget.EditText;
@@ -212,24 +212,18 @@
private class CaptureWebView {
- WebView view;
+ WebViewOnUiThread webViewOnUiThread;
Bitmap bitmap;
CaptureWebView(Context context) {
- view = getActivity().getWebView();
+ webViewOnUiThread = new WebViewOnUiThread(EmojiTest.this, getActivity().getWebView());
}
Bitmap capture(char c[]) {
- view.loadData("<html><body>" + String.valueOf(c) + "</body></html>",
+ webViewOnUiThread.loadDataAndWaitForCompletion("<html><body>" + String.valueOf(c) + "</body></html>",
"text/html; charset=utf-8", "utf-8");
- try {
- Thread.sleep(200);
- } catch (InterruptedException ie) {
- return null;
- }
-
- Picture picture = view.capturePicture();
+ Picture picture = webViewOnUiThread.capturePicture();
if (picture == null || picture.getHeight() <= 0 || picture.getWidth() <= 0) {
return null;
} else {
diff --git a/tests/tests/text/src/android/text/format/cts/TimeTest.java b/tests/tests/text/src/android/text/format/cts/TimeTest.java
index 98ba55f..e287270 100644
--- a/tests/tests/text/src/android/text/format/cts/TimeTest.java
+++ b/tests/tests/text/src/android/text/format/cts/TimeTest.java
@@ -661,10 +661,13 @@
public void testGetJulianDay() throws Exception {
Time time = new Time();
- // For each day of the year, and for each timezone, get the Julian
- // day for 12am and then check that if we change the time we get the
- // same Julian day.
- for (int monthDay = 1; monthDay <= 366; monthDay += 20) {
+ // For every 15th day of 2008, and for each of the timezones listed above,
+ // get the Julian day for 12am and then check that if we change the time we get the
+ // same Julian day. Note that one of the many problems with the Time class
+ // is its lack of error handling. If we accidentally hit a time that doesn't
+ // exist (because it was skipped by a daylight savings transition), rather than
+ // an error, you'll silently get 1970-01-01. We should @deprecate Time.
+ for (int monthDay = 1; monthDay <= 366; monthDay += 15) {
for (int zoneIndex = 0; zoneIndex < mTimeZones.length; zoneIndex++) {
// We leave the "month" as zero because we are changing the
// "monthDay" from 1 to 366. The call to normalize() will
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index e91595b..08fca45 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
@Option(name="cts-install-path", description="the path to the cts installation to use")
private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
- public static final String CTS_BUILD_VERSION = "4.2_r4";
+ public static final String CTS_BUILD_VERSION = "4.3_r1";
/**
* {@inheritDoc}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/AccessibilityServiceTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/AccessibilityServiceTestRunner.java
deleted file mode 100644
index d333943..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/AccessibilityServiceTestRunner.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-
-/**
- * Running the accessibility tests requires modification of secure
- * settings. Secure settings cannot be changed from device CTS tests
- * since system signature permission is required. Such settings can
- * be modified by the shell user, so a host side test is used for
- * installing a package with a delegating accessibility service, enabling
- * this service, running these tests, disabling the service, and removing
- * the delegating accessibility service package.
- */
-public class AccessibilityServiceTestRunner extends InstrumentationApkTest {
-
- private static final String DELEGATING_ACCESSIBLITY_SERVICE_PACKAGE_NAME =
- "android.accessibilityservice.delegate";
-
- private static final String DELEGATING_ACCESSIBLITY_SERVICE_NAME =
- "android.accessibilityservice.delegate.DelegatingAccessibilityService";
-
- private static final String DELEGATING_ACCESSIBLITY_SERVICE_APK =
- "CtsDelegatingAccessibilityService.apk";
-
- private CtsBuildHelper mCtsBuild;
-
- @Override
- public void setBuild(IBuildInfo build) {
- super.setBuild(build);
- mCtsBuild = CtsBuildHelper.createBuildHelper(build);
- }
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- beforeTest();
- super.run(listener);
- afterTest();
- }
-
- private void beforeTest() throws DeviceNotAvailableException {
- installApkAndAssert(DELEGATING_ACCESSIBLITY_SERVICE_APK);
- enableAccessibilityAndDelegatingService();
- }
-
- private void afterTest() throws DeviceNotAvailableException {
- AccessibilityTestRunner.disableAccessibilityAndServices(getDevice());
- uninstallAndAssert(DELEGATING_ACCESSIBLITY_SERVICE_PACKAGE_NAME);
- }
-
- private void installApkAndAssert(String apkName) throws DeviceNotAvailableException {
- File file = FileUtil.getFileForPath(mCtsBuild.getTestCasesDir(), apkName);
- String errorMessage = getDevice().installPackage(file, true);
- TestCase.assertNull("Error installing: " + apkName, errorMessage);
- }
-
- private void uninstallAndAssert(String packageName) throws DeviceNotAvailableException {
- String errorMessage = getDevice().uninstallPackage(packageName);
- TestCase.assertNull("Error uninstalling: " + packageName, errorMessage);
- }
-
- private void enableAccessibilityAndDelegatingService() throws DeviceNotAvailableException {
- String componentName = DELEGATING_ACCESSIBLITY_SERVICE_PACKAGE_NAME + "/"
- + DELEGATING_ACCESSIBLITY_SERVICE_NAME;
- AccessibilityTestRunner.enableAccessibilityAndServices(getDevice(),
- componentName);
- }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
index 2d11657..59babec 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
@@ -48,8 +48,6 @@
public static final String VM_HOST_TEST = "vmHostTest";
public static final String ACCESSIBILITY_TEST =
"com.android.cts.tradefed.testtype.AccessibilityTestRunner";
- public static final String ACCESSIBILITYSERVICE_TEST =
- "com.android.cts.tradefed.testtype.AccessibilityServiceTestRunner";
public static final String DISPLAY_TEST =
"com.android.cts.tradefed.testtype.DisplayTestRunner";
public static final String UIAUTOMATOR_TEST = "uiAutomator";
@@ -230,9 +228,6 @@
} else if (ACCESSIBILITY_TEST.equals(mTestType)) {
AccessibilityTestRunner test = new AccessibilityTestRunner();
return setInstrumentationTest(test, testCaseDir);
- } else if (ACCESSIBILITYSERVICE_TEST.equals(mTestType)) {
- AccessibilityServiceTestRunner test = new AccessibilityServiceTestRunner();
- return setInstrumentationTest(test, testCaseDir);
} else if (DISPLAY_TEST.equals(mTestType)) {
DisplayTestRunner test = new DisplayTestRunner();
return setInstrumentationTest(test, testCaseDir);