am 4d086b69: Merge "Fix DocletRunner to use updated TF path"
* commit '4d086b69057eb0c304be2cae3edc96cc620227b4':
Fix DocletRunner to use updated TF path
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
index dc75e7d..23d353e 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
@@ -19,16 +19,20 @@
import com.android.cts.tradefed.build.CtsBuildHelper;
import com.android.ddmlib.Log;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
+import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.TestResult;
import com.android.tradefed.result.TestRunResult;
+import com.android.tradefed.result.TestResult.TestStatus;
import com.android.tradefed.testtype.DeviceTestCase;
import com.android.tradefed.testtype.IBuildReceiver;
import java.io.File;
import java.io.FileNotFoundException;
+import java.util.Map;
/**
* Set of tests that verify various security checks involving multiple apps are properly enforced.
@@ -233,46 +237,6 @@
}
/**
- * Test behavior when
- * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} is enforced.
- */
- public void testReadExternalStorageEnforced() throws Exception {
- try {
- getDevice().uninstallPackage(EXTERNAL_STORAGE_APP_PKG);
- getDevice().uninstallPackage(WRITE_EXTERNAL_STORAGE_APP_PKG);
-
- // stage test file on external storage
- getDevice().pushString("CAEK", "/sdcard/meow");
-
- // mark permission as enforced
- setPermissionEnforced(getDevice(), READ_EXTERNAL_STORAGE, true);
-
- // install apps and run test
- assertNull(getDevice()
- .installPackage(getTestAppFile(EXTERNAL_STORAGE_APP_APK), false));
- assertNull(getDevice()
- .installPackage(getTestAppFile(WRITE_EXTERNAL_STORAGE_APP_APK), false));
-
- // normal app should not be able to read
- assertTrue("Normal app able to read external storage", runDeviceTests(
- EXTERNAL_STORAGE_APP_PKG, EXTERNAL_STORAGE_APP_CLASS,
- "testFailReadExternalStorage"));
-
- // WRITE_EXTERNAL app should be able to read and write
- assertTrue("WRITE_EXTERNAL app unable to read external storage", runDeviceTests(
- WRITE_EXTERNAL_STORAGE_APP_PKG, WRITE_EXTERNAL_STORAGE_APP_CLASS,
- "testReadExternalStorage"));
- assertTrue("WRITE_EXTERNAL app unable to write external storage", runDeviceTests(
- WRITE_EXTERNAL_STORAGE_APP_PKG, WRITE_EXTERNAL_STORAGE_APP_CLASS,
- "testWriteExternalStorage"));
-
- } finally {
- getDevice().uninstallPackage(EXTERNAL_STORAGE_APP_PKG);
- getDevice().uninstallPackage(WRITE_EXTERNAL_STORAGE_APP_PKG);
- }
- }
-
- /**
* Test that uninstall of an app removes its private data.
*/
public void testUninstallRemovesData() throws Exception {
@@ -360,8 +324,8 @@
assertNull(String.format("failed to install permission app with diff cert. Reason: %s",
installResult), installResult);
// run PERMISSION_DIFF_CERT_PKG tests which try to access the permission
- assertTrue("unexpected result when running permission tests",
- runDeviceTests(PERMISSION_DIFF_CERT_PKG));
+ TestRunResult result = doRunTests(PERMISSION_DIFF_CERT_PKG, null, null);
+ assertDeviceTestsPass(result);
}
finally {
getDevice().uninstallPackage(DECLARE_PERMISSION_PKG);
@@ -370,6 +334,32 @@
}
/**
+ * Helper method that checks that all tests in given result passed, and attempts to generate
+ * a meaningful error message if they failed.
+ *
+ * @param result
+ */
+ private void assertDeviceTestsPass(TestRunResult result) {
+ // TODO: consider rerunning if this occurred
+ assertFalse(String.format("Failed to successfully run device tests for %s. Reason: %s",
+ result.getName(), result.getRunFailureMessage()), result.isRunFailure());
+
+ if (result.hasFailedTests()) {
+ // build a meaningful error message
+ StringBuilder errorBuilder = new StringBuilder("on-device tests failed:\n");
+ for (Map.Entry<TestIdentifier, TestResult> resultEntry :
+ result.getTestResults().entrySet()) {
+ if (!resultEntry.getValue().getStatus().equals(TestStatus.PASSED)) {
+ errorBuilder.append(resultEntry.getKey().toString());
+ errorBuilder.append(":\n");
+ errorBuilder.append(resultEntry.getValue().getStackTrace());
+ }
+ }
+ fail(errorBuilder.toString());
+ }
+ }
+
+ /**
* Helper method that will the specified packages tests on device.
*
* @param pkgName Android application package for tests
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
index 0bc2c10..36dae9d 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
@@ -31,6 +31,7 @@
File app = mBuild.getTestApp(APKS[i]);
mDevice.installPackage(app, false);
}
+ clearLogCat();
}
@Override
@@ -41,7 +42,7 @@
}
}
- void clearLogCat() throws DeviceNotAvailableException {
+ private void clearLogCat() throws DeviceNotAvailableException {
mDevice.executeAdbCommand("logcat", "-c");
}
}
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
index 17a5cf8..f38b332 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
@@ -19,8 +19,6 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import java.util.Scanner;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
public class MonkeyTest extends AbstractMonkeyTest {
@@ -28,13 +26,11 @@
private static final String HUMAN = "(^_^)";
public void testIsMonkey() throws Exception {
- clearLogCat();
mDevice.executeShellCommand("monkey -p " + PKGS[0] + " 500");
assertIsUserAMonkey(true);
}
public void testNotMonkey() throws Exception {
- clearLogCat();
mDevice.executeShellCommand("am start -W -a android.intent.action.MAIN "
+ "-n com.android.cts.monkey/com.android.cts.monkey.MonkeyActivity");
assertIsUserAMonkey(false);
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
index aa6106b..3859f19 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
@@ -16,22 +16,32 @@
package com.android.cts.monkey;
+import java.util.regex.Pattern;
+
public class PackageTest extends AbstractMonkeyTest {
+ private static final Pattern ALLOW_MONKEY =
+ Pattern.compile("^.*Allowing.*cmp=com\\.android\\.cts\\.monkey/\\.MonkeyActivity.*$",
+ Pattern.MULTILINE);
+
+ private static final Pattern ALLOW_CHIMP =
+ Pattern.compile("^.*Allowing.*cmp=com\\.android\\.cts\\.monkey2/\\.ChimpActivity.*$",
+ Pattern.MULTILINE);
+
public void testSinglePackage() throws Exception {
String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0] + " 5000");
- assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertFalse(out.contains("cmp=com.android.cts.monkey2/.ChimpActivity"));
+ assertTrue(out, ALLOW_MONKEY.matcher(out).find());
+ assertFalse(out, ALLOW_CHIMP.matcher(out).find());
out = mDevice.executeShellCommand("monkey -v -p " + PKGS[1] + " 5000");
- assertFalse(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertTrue(out.contains("cmp=com.android.cts.monkey2/.ChimpActivity"));
+ assertFalse(out, ALLOW_MONKEY.matcher(out).find());
+ assertTrue(out, ALLOW_CHIMP.matcher(out).find());
}
public void testMultiplePackages() throws Exception {
String out = mDevice.executeShellCommand("monkey -v -p " + PKGS[0]
+ " -p " + PKGS[1] + " 5000");
- assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertTrue(out.contains("cmp=com.android.cts.monkey2/.ChimpActivity"));
+ assertTrue(out, ALLOW_MONKEY.matcher(out).find());
+ assertTrue(out, ALLOW_CHIMP.matcher(out).find());
}
}
diff --git a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
index cc7d7b0..6dce943 100644
--- a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
+++ b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
@@ -85,7 +85,6 @@
System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath());
System.setProperty("user.dir", cacheDir.getAbsolutePath());
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
mEnvironment = new TestEnvironment();
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index d742509..9228564 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -67,6 +67,11 @@
"org.apache.harmony.luni.tests.java.net.URLConnectionTest",
"org.apache.harmony.xnet.provider.jsse.NativeCryptoTest#test_SSL_do_handshake_server_timeout"
]
+ },
+ {
+ description: "MediaPlayerFlakyNetworkTest tests",
+ name: "android.media.cts.MediaPlayerFlakyNetworkTest",
+ bug: 6782035
}
]
diff --git a/tests/src/android/app/cts/ClearTop.java b/tests/src/android/app/cts/ClearTop.java
index fe0b44b..5f60870 100644
--- a/tests/src/android/app/cts/ClearTop.java
+++ b/tests/src/android/app/cts/ClearTop.java
@@ -19,10 +19,11 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
public class ClearTop extends Activity {
public static final String WAIT_CLEAR_TASK = "waitClearTask";
-
+ private static final String TAG = "ClearTop";
public ClearTop() {
}
@@ -36,6 +37,7 @@
@Override
public void onNewIntent(Intent intent) {
+ Log.i(TAG, "onNewIntent");
if (LocalScreen.CLEAR_TASK.equals(intent.getAction())) {
setResult(RESULT_OK);
} else {
diff --git a/tests/src/android/app/cts/LaunchpadActivity.java b/tests/src/android/app/cts/LaunchpadActivity.java
index 7191e03..2a90055 100644
--- a/tests/src/android/app/cts/LaunchpadActivity.java
+++ b/tests/src/android/app/cts/LaunchpadActivity.java
@@ -272,7 +272,7 @@
if (!mStarted) {
mStarted = true;
- mHandler.postDelayed(mTimeout, 5 * 1000);
+ mHandler.postDelayed(mTimeout, 10 * 1000);
final String action = getIntent().getAction();
@@ -630,6 +630,7 @@
private final Runnable mTimeout = new Runnable() {
public void run() {
+ Log.i(TAG, "timeout");
String msg = "Timeout";
if (mExpectedReceivers != null && mNextReceiver < mExpectedReceivers.length) {
msg = msg + " waiting for " + mExpectedReceivers[mNextReceiver];
diff --git a/tests/src/android/app/cts/TestedActivity.java b/tests/src/android/app/cts/TestedActivity.java
index 39d8f88..b6565bf 100644
--- a/tests/src/android/app/cts/TestedActivity.java
+++ b/tests/src/android/app/cts/TestedActivity.java
@@ -20,8 +20,10 @@
import android.os.Bundle;
import android.os.Looper;
import android.os.MessageQueue;
+import android.util.Log;
public class TestedActivity extends Activity {
+ private static final String TAG = "TestedActivity" ;
public TestedActivity() {
}
@@ -49,6 +51,7 @@
private class Idler implements MessageQueue.IdleHandler {
public final boolean queueIdle() {
+ Log.i(TAG, "idle");
setResult(RESULT_OK);
finish();
return false;
diff --git a/tests/src/android/app/cts/TestedScreen.java b/tests/src/android/app/cts/TestedScreen.java
index a96df2c..052fb34 100644
--- a/tests/src/android/app/cts/TestedScreen.java
+++ b/tests/src/android/app/cts/TestedScreen.java
@@ -24,12 +24,13 @@
import android.os.Message;
import android.os.MessageQueue;
import android.os.SystemClock;
+import android.util.Log;
public class TestedScreen extends Activity {
public static final String WAIT_BEFORE_FINISH = "TestedScreen.WAIT_BEFORE_FINISH";
public static final String DELIVER_RESULT = "TestedScreen.DELIVER_RESULT";
public static final String CLEAR_TASK = "TestedScreen.CLEAR_TASK";
-
+ private static final String TAG = "TestedScreen" ;
public TestedScreen() {
}
@@ -101,6 +102,7 @@
private class Idler implements MessageQueue.IdleHandler {
public final boolean queueIdle() {
+ Log.i(TAG, "idle");
if (WAIT_BEFORE_FINISH.equals(getIntent().getAction())) {
final Message m = Message.obtain();
mHandler.sendMessageAtTime(m, SystemClock.uptimeMillis() + 1000);
diff --git a/tests/src/android/webkit/cts/WebViewOnUiThread.java b/tests/src/android/webkit/cts/WebViewOnUiThread.java
index 0a1547e..bb07d08 100644
--- a/tests/src/android/webkit/cts/WebViewOnUiThread.java
+++ b/tests/src/android/webkit/cts/WebViewOnUiThread.java
@@ -661,12 +661,11 @@
* @param call The call to make on the UI thread prior to waiting.
*/
private void callAndWait(Runnable call) {
- synchronized (this) {
- Assert.assertTrue("WebViewOnUiThread.load*AndWaitForCompletion calls "
- + "may not be mixed with load* calls directly on WebView "
- + "without calling waitForLoadCompletion after the load",
- !mLoaded);
- }
+ Assert.assertTrue("WebViewOnUiThread.load*AndWaitForCompletion calls "
+ + "may not be mixed with load* calls directly on WebView "
+ + "without calling waitForLoadCompletion after the load",
+ !isLoaded());
+ clearLoad(); // clear any extraneous signals from a previous load.
runOnUiThread(call);
waitForLoadCompletion();
}
diff --git a/tests/tests/acceleration/Android.mk b/tests/tests/acceleration/Android.mk
index 93c4d51..30a1f51 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/tests/tests/acceleration/Android.mk
@@ -22,6 +22,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
diff --git a/tests/tests/acceleration/AndroidManifest.xml b/tests/tests/acceleration/AndroidManifest.xml
index 8a2f955..d08827e 100644
--- a/tests/tests/acceleration/AndroidManifest.xml
+++ b/tests/tests/acceleration/AndroidManifest.xml
@@ -19,11 +19,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.acceleration">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.acceleration.stub"
android:label="Tests for the Hardware Acceleration APIs." />
diff --git a/tests/tests/accessibility/Android.mk b/tests/tests/accessibility/Android.mk
index ad8f719..ee50eef 100644
--- a/tests/tests/accessibility/Android.mk
+++ b/tests/tests/accessibility/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsAccessibilityTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := ctsutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctsutil ctstestrunner
# This test runner sets up/cleans up the device before/after running the tests.
LOCAL_CTS_TEST_RUNNER := com.android.cts.tradefed.testtype.AccessibilityTestRunner
diff --git a/tests/tests/accessibility/AndroidManifest.xml b/tests/tests/accessibility/AndroidManifest.xml
index affe0c2..53b9cc3 100644
--- a/tests/tests/accessibility/AndroidManifest.xml
+++ b/tests/tests/accessibility/AndroidManifest.xml
@@ -19,11 +19,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.view.cts.accessibility">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application android:theme="@android:style/Theme.Holo.NoActionBar" >
<uses-library android:name="android.test.runner"/>
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="android.view.cts.accessibility"
android:label="Tests for the accessibility APIs."/>
diff --git a/tests/tests/accessibilityservice/Android.mk b/tests/tests/accessibilityservice/Android.mk
index ce92944..029602a 100644
--- a/tests/tests/accessibilityservice/Android.mk
+++ b/tests/tests/accessibilityservice/Android.mk
@@ -20,6 +20,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl \
src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
diff --git a/tests/tests/accessibilityservice/AndroidManifest.xml b/tests/tests/accessibilityservice/AndroidManifest.xml
index 3f5de30..c000460 100644
--- a/tests/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/tests/accessibilityservice/AndroidManifest.xml
@@ -42,7 +42,7 @@
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.accessibilityservice"
android:label="Tests for the accessibility APIs."/>
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
index 97f4359..f1a7114 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityActivityTestCase.java
@@ -33,6 +33,7 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -165,7 +166,7 @@
/**
* Flag whether we are waiting for a specific event.
*/
- private volatile boolean mWaitingForEventDelivery;
+ private boolean mWaitingForEventDelivery;
/**
* Queue with received events.
@@ -178,10 +179,8 @@
}
public void onAccessibilityEvent(AccessibilityEvent event) {
- if (!mWaitingForEventDelivery) {
- return;
- }
synchronized (mLock) {
+ Log.e("OPALA", "Event: " + event);
mLock.notifyAll();
if (mWaitingForEventDelivery) {
mEventQueue.add(AccessibilityEvent.obtain(event));
@@ -232,8 +231,7 @@
" not installed.");
}
- throw new IllegalStateException("Delegating Accessibility Service not running."
- + "(Settings -> Accessibility -> Delegating Accessibility Service)");
+ throw new IllegalStateException("Delegating Accessibility Service not running.");
}
Intent intent = new Intent().setClassName(DELEGATING_SERVICE_PACKAGE,
@@ -281,8 +279,8 @@
/* do nothing */
}
});
- mInitialized = true;
synchronized (mLock) {
+ mInitialized = true;
mLock.notifyAll();
}
} catch (RemoteException re) {
@@ -294,8 +292,9 @@
* {@inheritDoc ServiceConnection#onServiceDisconnected(ComponentName)}
*/
public void onServiceDisconnected(ComponentName name) {
- mInitialized = false;
- /* do nothing */
+ synchronized (mLock) {
+ mInitialized = false;
+ }
}
/**
@@ -463,22 +462,22 @@
* to a given timeout.
*
* @param command The command to execute before starting to wait for the event.
- * @param filter Filter that recognizes the epected 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 {
- // Prepare to wait for an event.
- mWaitingForEventDelivery = true;
- // Execute the command.
- command.run();
synchronized (mLock) {
+ mEventQueue.clear();
+ // Prepare to wait for an event.
+ mWaitingForEventDelivery = true;
+ // Execute the command.
+ command.run();
try {
// Wait for the event.
final long startTimeMillis = SystemClock.uptimeMillis();
while (true) {
- mLock.notifyAll();
// Drain the event queue
while (!mEventQueue.isEmpty()) {
AccessibilityEvent event = mEventQueue.remove(0);
@@ -495,6 +494,7 @@
throw new TimeoutException("Expected event not received within: "
+ timeoutMillis + " ms.");
}
+ mLock.notifyAll();
try {
mLock.wait(remainingTimeMillis);
} catch (InterruptedException ie) {
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index e0ec789..f65627c 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -321,80 +321,54 @@
@MediumTest
public void testPerformGlobalActionBack() throws Exception {
- // Get the root node info.
- final AccessibilityNodeInfo root = getInteractionBridge().getRootInActiveWindow();
+ assertTrue(getInteractionBridge().performGlobalAction(
+ AccessibilityService.GLOBAL_ACTION_BACK));
- AccessibilityEvent expected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
- @Override
- public void run() {
- getInteractionBridge().performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
- }
- }, new AccessibilityEventFilter() {
- @Override
- public boolean accept(AccessibilityEvent event) {
- return (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
- && "com.android.launcher".equals(event.getPackageName());
- }
- },
- TIMEOUT_ASYNC_PROCESSING);
-
- // Check if the expected event was received.
- assertNotNull(expected);
+ // Sleep a bit so the UI is settles.
+ SystemClock.sleep(3000);
}
@MediumTest
public void testPerformGlobalActionHome() throws Exception {
- // Get the root node info.
- final AccessibilityNodeInfo root = getInteractionBridge().getRootInActiveWindow();
+ assertTrue(getInteractionBridge().performGlobalAction(
+ AccessibilityService.GLOBAL_ACTION_HOME));
- AccessibilityEvent expected = getInteractionBridge()
- .executeCommandAndWaitForAccessibilityEvent(new Runnable() {
- @Override
- public void run() {
- getInteractionBridge().performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
- }
- }, new AccessibilityEventFilter() {
- @Override
- public boolean accept(AccessibilityEvent event) {
- return (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
- && "com.android.launcher".equals(event.getPackageName());
- }
- },
- TIMEOUT_ASYNC_PROCESSING);
-
- // Check if the expected event was received.
- assertNotNull(expected);
+ // Sleep a bit so the UI is settles.
+ SystemClock.sleep(3000);
}
@MediumTest
public void testPerformGlobalActionRecents() throws Exception {
- // Get the root node info.
- final AccessibilityNodeInfo root = getInteractionBridge().getRootInActiveWindow();
-
// Check whether the action succeeded.
assertTrue(getInteractionBridge().performGlobalAction(
AccessibilityService.GLOBAL_ACTION_RECENTS));
- // Sleep a bit so the recents UI is shown.
+ // Sleep a bit so the UI is settles.
SystemClock.sleep(3000);
// Clean up.
- getInteractionBridge().performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
+ getInteractionBridge().performGlobalAction(
+ AccessibilityService.GLOBAL_ACTION_BACK);
+
+ // Sleep a bit so the UI is settles.
+ SystemClock.sleep(3000);
}
@MediumTest
public void testPerformGlobalActionNotifications() throws Exception {
- // Get the root node info.
- final AccessibilityNodeInfo root = getInteractionBridge().getRootInActiveWindow();
-
// Perform the action under test
- final boolean handled = getInteractionBridge().performGlobalAction(
- AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS);
- assertTrue(handled);
+ assertTrue(getInteractionBridge().performGlobalAction(
+ AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS));
+
+ // Sleep a bit so the UI is settles.
+ SystemClock.sleep(3000);
// Clean up.
- getInteractionBridge().performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
+ assertTrue(getInteractionBridge().performGlobalAction(
+ AccessibilityService.GLOBAL_ACTION_BACK));
+
+ // Sleep a bit so the UI is settles.
+ SystemClock.sleep(3000);
}
@MediumTest
diff --git a/tests/tests/accounts/Android.mk b/tests/tests/accounts/Android.mk
index 2806bbe..e4536d4 100644
--- a/tests/tests/accounts/Android.mk
+++ b/tests/tests/accounts/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES += android-common
+LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/accounts/AndroidManifest.xml b/tests/tests/accounts/AndroidManifest.xml
index a54d423..6020636 100644
--- a/tests/tests/accounts/AndroidManifest.xml
+++ b/tests/tests/accounts/AndroidManifest.xml
@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
@@ -38,7 +39,7 @@
</service>
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="android.accounts.cts"
android:label="CTS tests for android.accounts"/>
diff --git a/tests/tests/admin/Android.mk b/tests/tests/admin/Android.mk
index 8c71e0c..1affed6 100644
--- a/tests/tests/admin/Android.mk
+++ b/tests/tests/admin/Android.mk
@@ -22,6 +22,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAdminTestCases
diff --git a/tests/tests/admin/AndroidManifest.xml b/tests/tests/admin/AndroidManifest.xml
index 102c7ec..7ce29aa 100644
--- a/tests/tests/admin/AndroidManifest.xml
+++ b/tests/tests/admin/AndroidManifest.xml
@@ -19,13 +19,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.admin">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner"/>
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="android.deviceadmin.cts"
android:label="Tests for the admin APIs."/>
diff --git a/tests/tests/animation/Android.mk b/tests/tests/animation/Android.mk
index 95cc614..a83bb65 100644
--- a/tests/tests/animation/Android.mk
+++ b/tests/tests/animation/Android.mk
@@ -27,6 +27,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/animation/AndroidManifest.xml b/tests/tests/animation/AndroidManifest.xml
index f18d416..2212643 100644
--- a/tests/tests/animation/AndroidManifest.xml
+++ b/tests/tests/animation/AndroidManifest.xml
@@ -17,7 +17,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.animation">
<uses-sdk android:minSdkVersion="11" />
- <uses-permission android:name="android.permission.INJECT_EVENTS"></uses-permission>
+ <uses-permission android:name="android.permission.INJECT_EVENTS" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<activity android:name="android.animation.cts.AnimationActivity"
android:label="AnimationActivity"/>
@@ -26,7 +27,7 @@
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.animation"
android:label="CTS tests for android.animation package"/>
</manifest>
diff --git a/tests/tests/animation/src/android/animation/cts/AnimatorTest.java b/tests/tests/animation/src/android/animation/cts/AnimatorTest.java
index f460c14..5f07afb 100644
--- a/tests/tests/animation/src/android/animation/cts/AnimatorTest.java
+++ b/tests/tests/animation/src/android/animation/cts/AnimatorTest.java
@@ -94,7 +94,11 @@
public void testCancel() throws Throwable {
startAnimation(mAnimator);
Thread.sleep(100);
- mAnimator.cancel();
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ mAnimator.cancel();
+ }
+ });
assertFalse(mAnimator.isRunning());
}
diff --git a/tests/tests/app/Android.mk b/tests/tests/app/Android.mk
index 58d0dcd..8d5877d 100644
--- a/tests/tests/app/Android.mk
+++ b/tests/tests/app/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAppTestCases
diff --git a/tests/tests/app/AndroidManifest.xml b/tests/tests/app/AndroidManifest.xml
index 54fcf12..af7d997 100644
--- a/tests/tests/app/AndroidManifest.xml
+++ b/tests/tests/app/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.app">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
index e448a9d..0780101 100644
--- a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.cts.util.PollingCheck;
import android.os.SystemClock;
import android.test.AndroidTestCase;
@@ -38,8 +39,8 @@
private long mWakeupTime;
private MockAlarmReceiver mMockAlarmReceiver;
- private final int TIME_DELTA = 200;
- private final int TIME_DELAY = 2000;
+ private final int TIME_DELTA = 1000;
+ private final int TIME_DELAY = 5000;
class Sync {
public boolean mIsConnected;
@@ -73,32 +74,48 @@
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = System.currentTimeMillis() + SNOOZE_DELAY;
mAlarmManager.set(AlarmManager.RTC_WAKEUP, mWakeupTime, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
assertEquals(mMockAlarmReceiver.rtcTime, mWakeupTime, TIME_DELTA);
// test parameter type is RTC
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = System.currentTimeMillis() + SNOOZE_DELAY;
mAlarmManager.set(AlarmManager.RTC, mWakeupTime, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
assertEquals(mMockAlarmReceiver.rtcTime, mWakeupTime, TIME_DELTA);
// test parameter type is ELAPSED_REALTIME
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = SystemClock.elapsedRealtime() + SNOOZE_DELAY;
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, mWakeupTime, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
assertEquals(mMockAlarmReceiver.elapsedTime, mWakeupTime, TIME_DELTA);
// test parameter type is ELAPSED_REALTIME_WAKEUP
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = SystemClock.elapsedRealtime() + SNOOZE_DELAY;
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, mWakeupTime, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
assertEquals(mMockAlarmReceiver.elapsedTime, mWakeupTime, TIME_DELTA);
}
@@ -109,19 +126,31 @@
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = -1000;
mAlarmManager.set(AlarmManager.RTC, mWakeupTime, mSender);
- Thread.sleep(TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
}
public void testSetRepeating() throws Exception {
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = System.currentTimeMillis() + SNOOZE_DELAY;
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, mWakeupTime, TIME_DELAY / 2, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
mMockAlarmReceiver.setAlarmedFalse();
- Thread.sleep(TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
mAlarmManager.cancel(mSender);
}
@@ -129,11 +158,19 @@
mMockAlarmReceiver.setAlarmedFalse();
mWakeupTime = System.currentTimeMillis() + SNOOZE_DELAY;
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, mWakeupTime, 1000, mSender);
- Thread.sleep(SNOOZE_DELAY + TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(SNOOZE_DELAY + TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
mMockAlarmReceiver.setAlarmedFalse();
- Thread.sleep(TIME_DELAY);
- assertTrue(mMockAlarmReceiver.alarmed);
+ new PollingCheck(TIME_DELAY) {
+ @Override
+ protected boolean check() {
+ return mMockAlarmReceiver.alarmed;
+ }
+ }.run();
mAlarmManager.cancel(mSender);
Thread.sleep(TIME_DELAY);
mMockAlarmReceiver.setAlarmedFalse();
diff --git a/tests/tests/bluetooth/Android.mk b/tests/tests/bluetooth/Android.mk
index 94c6c19..701730d 100644
--- a/tests/tests/bluetooth/Android.mk
+++ b/tests/tests/bluetooth/Android.mk
@@ -28,6 +28,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/bluetooth/AndroidManifest.xml b/tests/tests/bluetooth/AndroidManifest.xml
index 486460d..9caa267 100644
--- a/tests/tests/bluetooth/AndroidManifest.xml
+++ b/tests/tests/bluetooth/AndroidManifest.xml
@@ -19,13 +19,14 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.bluetooth"
android:label="CTS tests of bluetooth component"/>
diff --git a/tests/tests/content/Android.mk b/tests/tests/content/Android.mk
index ae2aee8..6f883b6 100644
--- a/tests/tests/content/Android.mk
+++ b/tests/tests/content/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsContentTestCases
diff --git a/tests/tests/content/AndroidManifest.xml b/tests/tests/content/AndroidManifest.xml
index 8f1d2b7..0d702f4 100644
--- a/tests/tests/content/AndroidManifest.xml
+++ b/tests/tests/content/AndroidManifest.xml
@@ -17,12 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.content">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.stub"
android:label="CTS tests of android.content"/>
</manifest>
diff --git a/tests/tests/database/Android.mk b/tests/tests/database/Android.mk
index 6ad21b3..8557c60 100644
--- a/tests/tests/database/Android.mk
+++ b/tests/tests/database/Android.mk
@@ -21,7 +21,7 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner ctstestrunner
LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/tests/database/AndroidManifest.xml b/tests/tests/database/AndroidManifest.xml
index dd3855c..602f783 100644
--- a/tests/tests/database/AndroidManifest.xml
+++ b/tests/tests/database/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.database">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/dpi/Android.mk b/tests/tests/dpi/Android.mk
index 2f256c4..a9dbcc3 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/Android.mk
@@ -19,6 +19,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsDpiTestCases
diff --git a/tests/tests/dpi/AndroidManifest.xml b/tests/tests/dpi/AndroidManifest.xml
index 6e141ac..bacfe4a 100644
--- a/tests/tests/dpi/AndroidManifest.xml
+++ b/tests/tests/dpi/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.dpi">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
@@ -25,7 +26,7 @@
android:configChanges="orientation" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.dpi"
android:label="CTS tests for DPI"/>
</manifest>
diff --git a/tests/tests/dpi2/Android.mk b/tests/tests/dpi2/Android.mk
index cc11256..92ba992 100644
--- a/tests/tests/dpi2/Android.mk
+++ b/tests/tests/dpi2/Android.mk
@@ -19,7 +19,7 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
# We use the DefaultManifestAttributesTest from the android.cts.dpi package.
-LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi
+LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi ctstestrunner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/dpi2/AndroidManifest.xml b/tests/tests/dpi2/AndroidManifest.xml
index f63ff73..0364b10 100644
--- a/tests/tests/dpi2/AndroidManifest.xml
+++ b/tests/tests/dpi2/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.dpi2">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
@@ -26,7 +27,7 @@
properly for the screen size attributes. -->
<uses-sdk android:targetSdkVersion="3" />
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.dpi2"
android:label="CTS tests for DPI"/>
</manifest>
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
index 6e6ba56..3264c32 100644
--- a/tests/tests/drm/Android.mk
+++ b/tests/tests/drm/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsDrmTestCases
diff --git a/tests/tests/drm/AndroidManifest.xml b/tests/tests/drm/AndroidManifest.xml
index fe515f3..1fc8968 100644
--- a/tests/tests/drm/AndroidManifest.xml
+++ b/tests/tests/drm/AndroidManifest.xml
@@ -17,6 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.drm">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/effect/Android.mk b/tests/tests/effect/Android.mk
index 075dc82..9e27769 100644
--- a/tests/tests/effect/Android.mk
+++ b/tests/tests/effect/Android.mk
@@ -27,6 +27,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/effect/AndroidManifest.xml b/tests/tests/effect/AndroidManifest.xml
index e410800..1a346ae 100644
--- a/tests/tests/effect/AndroidManifest.xml
+++ b/tests/tests/effect/AndroidManifest.xml
@@ -17,12 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.effect">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.effect"
android:label="CTS tests of android.media.effect component"/>
diff --git a/tests/tests/example/Android.mk b/tests/tests/example/Android.mk
index 7e2d841..c6ef67b 100644
--- a/tests/tests/example/Android.mk
+++ b/tests/tests/example/Android.mk
@@ -28,6 +28,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/example/AndroidManifest.xml b/tests/tests/example/AndroidManifest.xml
index 37c07b3..ba41cce 100644
--- a/tests/tests/example/AndroidManifest.xml
+++ b/tests/tests/example/AndroidManifest.xml
@@ -21,12 +21,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.example">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.example"
android:label="CTS tests of example component"/>
diff --git a/tests/tests/gesture/Android.mk b/tests/tests/gesture/Android.mk
index f4fa8b3..5d44cfc 100755
--- a/tests/tests/gesture/Android.mk
+++ b/tests/tests/gesture/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsGestureTestCases
diff --git a/tests/tests/gesture/AndroidManifest.xml b/tests/tests/gesture/AndroidManifest.xml
index 4690d4d..39e2b90 100755
--- a/tests/tests/gesture/AndroidManifest.xml
+++ b/tests/tests/gesture/AndroidManifest.xml
@@ -18,12 +18,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.gesture">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.gesture"
android:label="CTS tests of android.gesture"/>
diff --git a/tests/tests/graphics/Android.mk b/tests/tests/graphics/Android.mk
index 9575dd3..811267a 100644
--- a/tests/tests/graphics/Android.mk
+++ b/tests/tests/graphics/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsGraphicsTestCases
diff --git a/tests/tests/graphics/AndroidManifest.xml b/tests/tests/graphics/AndroidManifest.xml
index 2c5bf23..c052a15 100644
--- a/tests/tests/graphics/AndroidManifest.xml
+++ b/tests/tests/graphics/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.graphics">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/graphics2/Android.mk b/tests/tests/graphics2/Android.mk
index 9c6d46d..b3e7340 100644
--- a/tests/tests/graphics2/Android.mk
+++ b/tests/tests/graphics2/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsGraphics2TestCases
diff --git a/tests/tests/graphics2/AndroidManifest.xml b/tests/tests/graphics2/AndroidManifest.xml
index e26b962..2392100 100644
--- a/tests/tests/graphics2/AndroidManifest.xml
+++ b/tests/tests/graphics2/AndroidManifest.xml
@@ -19,11 +19,12 @@
android:versionName="1.0" >
<uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-feature android:name="android.hardware.camera" />
<instrumentation
android:targetPackage="com.android.cts.graphics2"
- android:name="android.test.InstrumentationTestRunner" />
+ android:name="android.test.InstrumentationCtsTestRunner" />
<application>
<uses-library android:name="android.test.runner" />
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index dd769fa..76088a0 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -20,6 +20,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsHardwareTestCases
diff --git a/tests/tests/hardware/AndroidManifest.xml b/tests/tests/hardware/AndroidManifest.xml
index 2293f8f..971d6c7 100644
--- a/tests/tests/hardware/AndroidManifest.xml
+++ b/tests/tests/hardware/AndroidManifest.xml
@@ -18,11 +18,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.hardware">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.stub"
android:label="CTS tests of android.hardware"/>
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
index 939a6c2..d0a2bf0 100755
--- a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
@@ -78,8 +78,8 @@
private int mCameraErrorCode = NO_ERROR;
private boolean mAutoFocusSucceeded = false;
- private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 1500; // Milliseconds.
- private static final int WAIT_FOR_FOCUS_TO_COMPLETE = 3000;
+ private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 5000; // Milliseconds.
+ private static final int WAIT_FOR_FOCUS_TO_COMPLETE = 5000;
private static final int WAIT_FOR_SNAPSHOT_TO_COMPLETE = 5000;
private static final int FOCUS_AREA = 0;
diff --git a/tests/tests/holo/Android.mk b/tests/tests/holo/Android.mk
index 25e10d2..d844116 100644
--- a/tests/tests/holo/Android.mk
+++ b/tests/tests/holo/Android.mk
@@ -22,6 +22,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_AAPT_FLAGS = -c land -c xx_YY -c cs -c 320dpi -c 240dpi -c 213dpi -c 160dpi -c 120dpi
diff --git a/tests/tests/holo/AndroidManifest.xml b/tests/tests/holo/AndroidManifest.xml
index df05cbb..ea53a73 100644
--- a/tests/tests/holo/AndroidManifest.xml
+++ b/tests/tests/holo/AndroidManifest.xml
@@ -18,6 +18,7 @@
package="com.android.cts.holo">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application android:hardwareAccelerated="false">
<uses-library android:name="android.test.runner" />
@@ -53,7 +54,7 @@
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.holo"
android:label="CTS tests for the Holo theme" />
diff --git a/tests/tests/jni/Android.mk b/tests/tests/jni/Android.mk
index c8c92fd..4f44e15 100644
--- a/tests/tests/jni/Android.mk
+++ b/tests/tests/jni/Android.mk
@@ -28,6 +28,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_JNI_SHARED_LIBRARIES := libjnitest
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/jni/AndroidManifest.xml b/tests/tests/jni/AndroidManifest.xml
index 82abd42..c3407d1 100644
--- a/tests/tests/jni/AndroidManifest.xml
+++ b/tests/tests/jni/AndroidManifest.xml
@@ -17,12 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.jni">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.jni"
android:label="CTS tests of calling native code via JNI"/>
diff --git a/tests/tests/location/Android.mk b/tests/tests/location/Android.mk
index b53aaa0..b76672c 100644
--- a/tests/tests/location/Android.mk
+++ b/tests/tests/location/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsLocationTestCases
diff --git a/tests/tests/location/AndroidManifest.xml b/tests/tests/location/AndroidManifest.xml
index c402be2..147f0ba 100644
--- a/tests/tests/location/AndroidManifest.xml
+++ b/tests/tests/location/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.location">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
@@ -26,7 +27,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.location"
android:label="CTS tests of android.location"/>
</manifest>
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index 07091cc..bee0671 100755
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -36,6 +36,7 @@
import android.provider.Settings;
import android.test.InstrumentationTestCase;
+import java.lang.Thread;
import java.util.List;
/**
@@ -606,6 +607,9 @@
// now update to trigger exit proximity proximity
mIntentReceiver.clearReceivedIntents();
+
+ // delay 2 seconds since location update in less than 1s will be neglected.
+ Thread.sleep(2000);
updateLocation(20, 20);
waitForReceiveBroadcast();
assertProximityType(false);
diff --git a/tests/tests/media/Android.mk b/tests/tests/media/Android.mk
index 1e6098f..f7639a4 100644
--- a/tests/tests/media/Android.mk
+++ b/tests/tests/media/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := ctsutil ctstestserver
+LOCAL_STATIC_JAVA_LIBRARIES := ctsutil ctstestserver ctstestrunner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/media/AndroidManifest.xml b/tests/tests/media/AndroidManifest.xml
index a336e73..2eeef08 100644
--- a/tests/tests/media/AndroidManifest.xml
+++ b/tests/tests/media/AndroidManifest.xml
@@ -18,6 +18,7 @@
package="com.android.cts.media">
<uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
@@ -59,7 +60,7 @@
</activity>
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.media"
android:label="CTS tests of android.media"/>
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecListTest.java b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
new file mode 100644
index 0000000..d89d992
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
@@ -0,0 +1,190 @@
+/*
+ * 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 android.media.cts;
+
+
+import android.media.MediaCodecList;
+import android.media.MediaCodecInfo;
+import android.media.MediaCodecInfo.CodecProfileLevel;
+import android.media.MediaCodecInfo.CodecCapabilities;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import java.io.File;
+import java.util.List;
+import java.util.ArrayList;
+
+public class MediaCodecListTest extends AndroidTestCase {
+
+ private static final String TAG = "MediaCodecListTest";
+ private static final String MEDIA_CODEC_XML_FILE = "/etc/media_codecs.xml";
+
+ class CodecType {
+ CodecType(String type, boolean isEncoder) {
+ mMimeTypeName = type;
+ mIsEncoder = isEncoder;
+ }
+
+ boolean equals(CodecType codecType) {
+ return (mMimeTypeName.compareTo(codecType.mMimeTypeName) == 0) &&
+ mIsEncoder == codecType.mIsEncoder;
+ }
+
+ String mMimeTypeName;
+ boolean mIsEncoder;
+ };
+
+ public static void testMediaCodecXmlFileExist() {
+ File file = new File(MEDIA_CODEC_XML_FILE);
+ assertTrue("/etc/media_codecs.xml does not exist", file.exists());
+ }
+
+ public void testRequiredMediaCodecList() {
+ List<CodecType> requiredList = getRequiredCodecTypes();
+ List<CodecType> supportedList = getSupportedCodecTypes();
+ assertTrue(areRequiredCodecTypesSupported(requiredList, supportedList));
+ }
+
+ // H263 baseline profile must be supported
+ public void testIsH263BaselineProfileSupported() {
+ int profile = CodecProfileLevel.H263ProfileBaseline;
+ assertTrue(checkProfileSupported("video/3gpp", false, profile));
+ assertTrue(checkProfileSupported("video/3gpp", true, profile));
+ }
+
+ // AVC baseline profile must be supported
+ public void testIsAVCBaselineProfileSupported() {
+ int profile = CodecProfileLevel.AVCProfileBaseline;
+ assertTrue(checkProfileSupported("video/avc", false, profile));
+ assertTrue(checkProfileSupported("video/avc", true, profile));
+ }
+
+ // MPEG4 simple profile must be supported
+ public void testIsM4VSimpleProfileSupported() {
+ int profile = CodecProfileLevel.MPEG4ProfileSimple;
+ assertTrue(checkProfileSupported("video/mp4v-es", false, profile));
+
+ // FIXME: no support for M4v simple profile video encoder
+ // assertTrue(checkProfileSupported("video/mp4v-es", true, profile));
+ }
+
+ /*
+ * Find whether the given codec is supported
+ */
+ private boolean checkProfileSupported(
+ String codecName, boolean isEncoder, int profile) {
+
+ boolean isSupported = false;
+
+ int codecCount = MediaCodecList.getCodecCount();
+ for (int i = 0; i < codecCount; ++i) {
+ MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
+ String[] types = info.getSupportedTypes();
+
+ if (isEncoder != info.isEncoder()) {
+ continue;
+ }
+
+ for (int j = 0; j < types.length; ++j) {
+ if (types[j].compareTo(codecName) == 0) {
+ CodecCapabilities cap = info.getCapabilitiesForType(types[j]);
+ CodecProfileLevel[] profileLevels = cap.profileLevels;
+ for (int k = 0; k < profileLevels.length; ++k) {
+ if (profileLevels[k].profile == profile) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Find whether all required media codec types are supported
+ */
+ private boolean areRequiredCodecTypesSupported(
+ List<CodecType> requiredList, List<CodecType> supportedList) {
+ for (CodecType requiredCodec: requiredList) {
+ boolean isSupported = false;
+ for (CodecType supportedCodec: supportedList) {
+ if (requiredCodec.equals(supportedCodec)) {
+ isSupported = true;
+ }
+ }
+ if (!isSupported) {
+ String codec = requiredCodec.mMimeTypeName
+ + ", " + (requiredCodec.mIsEncoder? "encoder": "decoder");
+ Log.e(TAG, "Media codec (" + codec + ") is not supported");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * Find all the media codec types are supported.
+ */
+ private List<CodecType> getSupportedCodecTypes() {
+ int codecCount = MediaCodecList.getCodecCount();
+ assertTrue("Unexpected media codec count", codecCount > 0);
+ List<CodecType> supportedList = new ArrayList<CodecType>(codecCount);
+ for (int i = 0; i < codecCount; ++i) {
+ MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
+ String[] types = info.getSupportedTypes();
+ assertTrue("Unexpected number of supported types", types.length > 0);
+ boolean isEncoder = info.isEncoder();
+ for (int j = 0; j < types.length; ++j) {
+ supportedList.add(new CodecType(types[j], isEncoder));
+ }
+ }
+ return supportedList;
+ }
+
+ /*
+ * This list should be kept in sync with the CCD document
+ * See http://developer.android.com/guide/appendix/media-formats.html
+ */
+ private List<CodecType> getRequiredCodecTypes() {
+ List<CodecType> list = new ArrayList<CodecType>(16);
+
+ // Mandatory audio codecs
+ list.add(new CodecType("audio/amr-wb", false)); // amrwb decoder
+ list.add(new CodecType("audio/amr-wb", true)); // amrwb encoder
+
+ // flac decoder is not omx-based yet
+ // list.add(new CodecType("audio/flac", false)); // flac decoder
+ list.add(new CodecType("audio/flac", true)); // flac encoder
+ list.add(new CodecType("audio/mpeg", false)); // mp3 decoder
+ list.add(new CodecType("audio/mp4a-latm", false)); // aac decoder
+ list.add(new CodecType("audio/mp4a-latm", true)); // aac encoder
+ list.add(new CodecType("audio/vorbis", false)); // vorbis decoder
+ list.add(new CodecType("audio/3gpp", false)); // amrnb decoder
+ list.add(new CodecType("audio/3gpp", true)); // amrnb encoder
+
+ // Mandatory video codecs
+ list.add(new CodecType("video/avc", false)); // avc decoder
+ list.add(new CodecType("video/avc", true)); // avc encoder
+ list.add(new CodecType("video/3gpp", false)); // h263 decoder
+ list.add(new CodecType("video/3gpp", true)); // h263 encoder
+ list.add(new CodecType("video/mp4v-es", false)); // m4v decoder
+ list.add(new CodecType("video/mp4v-es", true)); // m4v encoder
+ list.add(new CodecType("video/x-vnd.on2.vp8", false)); // vp8 decoder
+
+ return list;
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index 90ed4fc..0c39531 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -43,14 +43,29 @@
*/
public class MediaPlayerTest extends MediaPlayerTestBase {
- private static final String RECORDED_FILE =
- new File(Environment.getExternalStorageDirectory(),
- "record.out").getAbsolutePath();
+ private String RECORDED_FILE;
private static final int RECORDED_VIDEO_WIDTH = 176;
private static final int RECORDED_VIDEO_HEIGHT = 144;
private static final long RECORDED_DURATION_MS = 3000;
+ private File mOutFile;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ RECORDED_FILE = new File(Environment.getExternalStorageDirectory(),
+ "mediaplayer_record.out").getAbsolutePath();
+ mOutFile = new File(RECORDED_FILE);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (mOutFile != null && mOutFile.exists()) {
+ mOutFile.delete();
+ }
+ }
public void testPlayNullSource() throws Exception {
try {
mMediaPlayer.setDataSource((String) null);
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index 42aaef1..8b9da47 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -84,15 +84,10 @@
protected Context mContext;
protected Resources mResources;
- /*
- * InstrumentationTestRunner.onStart() calls Looper.prepare(), which creates a looper
- * for the current thread. However, since we don't actually call loop() in the test,
- * any messages queued with that looper will never be consumed. We instantiate the player
- * in the constructor, before setUp(), so that its constructor does not see the
- * nonfunctional Looper.
- */
- protected MediaPlayer mMediaPlayer = new MediaPlayer();
- protected MediaPlayer mMediaPlayer2 = new MediaPlayer();
+
+ protected MediaPlayer mMediaPlayer = null;
+ protected MediaPlayer mMediaPlayer2 = null;
+ protected MediaStubActivity mActivity;
public MediaPlayerTestBase() {
super(MediaStubActivity.class);
@@ -101,6 +96,19 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ mActivity = getActivity();
+ getInstrumentation().waitForIdleSync();
+ try {
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ mMediaPlayer = new MediaPlayer();
+ mMediaPlayer2 = new MediaPlayer();
+ }
+ });
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail();
+ }
mContext = getInstrumentation().getTargetContext();
mResources = mContext.getResources();
}
@@ -109,10 +117,13 @@
protected void tearDown() throws Exception {
if (mMediaPlayer != null) {
mMediaPlayer.release();
+ mMediaPlayer = null;
}
if (mMediaPlayer2 != null) {
mMediaPlayer2.release();
+ mMediaPlayer2 = null;
}
+ mActivity = null;
super.tearDown();
}
@@ -172,7 +183,7 @@
final float leftVolume = 0.5f;
final float rightVolume = 0.5f;
- mMediaPlayer.setDisplay(getActivity().getSurfaceHolder());
+ mMediaPlayer.setDisplay(mActivity.getSurfaceHolder());
mMediaPlayer.setScreenOnWhilePlaying(true);
mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index abbdc31..55be9ac 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -32,6 +32,10 @@
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
+import java.lang.InterruptedException;
+import java.lang.Runnable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaStubActivity> {
private final String TAG = "MediaRecorderTest";
@@ -57,14 +61,7 @@
private Camera mCamera;
private MediaStubActivity mActivity = null;
- /*
- * InstrumentationTestRunner.onStart() calls Looper.prepare(), which creates a looper
- * for the current thread. However, since we don't actually call loop() in the test,
- * any messages queued with that looper will never be consumed. We instantiate the recorder
- * in the constructor, before setUp(), so that its constructor does not see the
- * nonfunctional Looper.
- */
- private MediaRecorder mMediaRecorder = new MediaRecorder();
+ private MediaRecorder mMediaRecorder;
public MediaRecorderTest() {
super("com.android.cts.media", MediaStubActivity.class);
@@ -74,21 +71,43 @@
"record2.out").getAbsolutePath();
}
+ private void completeOnUiThread(final Runnable runnable) {
+ final CountDownLatch latch = new CountDownLatch(1);
+ getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ runnable.run();
+ latch.countDown();
+ }
+ });
+ try {
+ // if UI thread does not run, things will fail anyway
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+ } catch (java.lang.InterruptedException e) {
+ fail("should not be interrupted");
+ }
+ }
+
@Override
protected void setUp() throws Exception {
mActivity = getActivity();
- mOutFile = new File(OUTPUT_PATH);
- mOutFile2 = new File(OUTPUT_PATH2);
- mMediaRecorder.reset();
- mMediaRecorder.setOutputFile(OUTPUT_PATH);
- mMediaRecorder.setOnInfoListener(new OnInfoListener() {
- public void onInfo(MediaRecorder mr, int what, int extra) {
- mOnInfoCalled = true;
- }
- });
- mMediaRecorder.setOnErrorListener(new OnErrorListener() {
- public void onError(MediaRecorder mr, int what, int extra) {
- mOnErrorCalled = true;
+ completeOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mMediaRecorder = new MediaRecorder();
+ mOutFile = new File(OUTPUT_PATH);
+ mOutFile2 = new File(OUTPUT_PATH2);
+ mMediaRecorder.setOutputFile(OUTPUT_PATH);
+ mMediaRecorder.setOnInfoListener(new OnInfoListener() {
+ public void onInfo(MediaRecorder mr, int what, int extra) {
+ mOnInfoCalled = true;
+ }
+ });
+ mMediaRecorder.setOnErrorListener(new OnErrorListener() {
+ public void onError(MediaRecorder mr, int what, int extra) {
+ mOnErrorCalled = true;
+ }
+ });
}
});
super.setUp();
@@ -138,7 +157,7 @@
recordVideoUsingCamera(true);
}
- public void recordVideoUsingCamera(boolean timelapse) throws Exception {
+ private void recordVideoUsingCamera(boolean timelapse) throws Exception {
int nCamera = Camera.getNumberOfCameras();
int durMs = timelapse? 4000: 1000;
for (int cameraId = 0; cameraId < nCamera; cameraId++) {
@@ -210,6 +229,7 @@
retriever.setDataSource(fileName);
String location = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_LOCATION);
if (location == null) {
+ retriever.release();
Log.v(TAG, "No location information found in file " + fileName);
return false;
}
@@ -230,6 +250,7 @@
float longitude = Float.parseFloat(location.substring(index));
assertTrue("Incorrect latitude: " + latitude, Math.abs(latitude - LATITUDE) <= TOLERANCE);
assertTrue("Incorrect longitude: " + longitude, Math.abs(longitude - LONGITUDE) <= TOLERANCE);
+ retriever.release();
return true;
}
@@ -256,6 +277,7 @@
long maxFileSize = MAX_FILE_SIZE * 10;
recordMedia(maxFileSize, mOutFile2);
assertFalse(checkLocationInFile(OUTPUT_PATH2));
+ fos.close();
}
public void testRecordingAudioInRawFormats() throws Exception {
diff --git a/tests/tests/mediastress/Android.mk b/tests/tests/mediastress/Android.mk
index 505d123..f497295 100644
--- a/tests/tests/mediastress/Android.mk
+++ b/tests/tests/mediastress/Android.mk
@@ -22,6 +22,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_JNI_SHARED_LIBRARIES := libctsmediastress_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/mediastress/AndroidManifest.xml b/tests/tests/mediastress/AndroidManifest.xml
index 7388fe3..931a774 100644
--- a/tests/tests/mediastress/AndroidManifest.xml
+++ b/tests/tests/mediastress/AndroidManifest.xml
@@ -18,6 +18,7 @@
package="com.android.cts.mediastress">
<uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
@@ -38,7 +39,7 @@
<activity android:name="android.mediastress.cts.NativeMediaActivity"
android:label="NativeMedia" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.mediastress"
android:label="Media stress tests InstrumentationRunner" />
diff --git a/tests/tests/ndef/Android.mk b/tests/tests/ndef/Android.mk
index 13e5624..70853d9 100644
--- a/tests/tests/ndef/Android.mk
+++ b/tests/tests/ndef/Android.mk
@@ -27,6 +27,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/ndef/AndroidManifest.xml b/tests/tests/ndef/AndroidManifest.xml
index 4a65818..a7ebb6e 100644
--- a/tests/tests/ndef/AndroidManifest.xml
+++ b/tests/tests/ndef/AndroidManifest.xml
@@ -17,12 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.ndef">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.ndef"
android:label="CTS tests of NDEF data classes"/>
diff --git a/tests/tests/net/Android.mk b/tests/tests/net/Android.mk
index 5c70ad4..b327392 100644
--- a/tests/tests/net/Android.mk
+++ b/tests/tests/net/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsNetTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctsutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctsutil ctstestrunner
# uncomment when dalvik.annotation.Test* are removed or part of SDK
#LOCAL_SDK_VERSION := current
diff --git a/tests/tests/net/AndroidManifest.xml b/tests/tests/net/AndroidManifest.xml
index b3556f5..ade6728 100644
--- a/tests/tests/net/AndroidManifest.xml
+++ b/tests/tests/net/AndroidManifest.xml
@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
@@ -31,7 +32,7 @@
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.net"
android:label="CTS tests of android.net"/>
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
index 92a55b2..4480a24 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
@@ -38,10 +38,12 @@
return;
}
List<WifiConfiguration> wifiConfigurations = mWifiManager.getConfiguredNetworks();
- for (int i = 0; i < wifiConfigurations.size(); i++) {
- WifiConfiguration wifiConfiguration = wifiConfigurations.get(i);
- assertNotNull(wifiConfiguration);
- assertNotNull(wifiConfiguration.toString());
+ if (wifiConfigurations != null) {
+ for (int i = 0; i < wifiConfigurations.size(); i++) {
+ WifiConfiguration wifiConfiguration = wifiConfigurations.get(i);
+ assertNotNull(wifiConfiguration);
+ assertNotNull(wifiConfiguration.toString());
+ }
}
}
}
diff --git a/tests/tests/opengl/Android.mk b/tests/tests/opengl/Android.mk
index 6c533a0..0610c5f 100644
--- a/tests/tests/opengl/Android.mk
+++ b/tests/tests/opengl/Android.mk
@@ -26,7 +26,11 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_JNI_SHARED_LIBRARIES := libopengltest
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/opengl/AndroidManifest.xml b/tests/tests/opengl/AndroidManifest.xml
index ef1af51..4619512 100644
--- a/tests/tests/opengl/AndroidManifest.xml
+++ b/tests/tests/opengl/AndroidManifest.xml
@@ -18,10 +18,11 @@
android:versionCode="1"
android:versionName="1.0" >
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-sdk android:minSdkVersion="14" />
<uses-feature android:glEsVersion="0x00020000"/>
<instrumentation
- android:name="android.test.InstrumentationTestRunner"
+ android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.opengl" />
<application
android:icon="@drawable/ic_launcher"
diff --git a/tests/tests/openglperf/Android.mk b/tests/tests/openglperf/Android.mk
index c07969e..2d1767e 100644
--- a/tests/tests/openglperf/Android.mk
+++ b/tests/tests/openglperf/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsOpenGlPerfTestCases
diff --git a/tests/tests/openglperf/AndroidManifest.xml b/tests/tests/openglperf/AndroidManifest.xml
index e47c0bc..540f190 100644
--- a/tests/tests/openglperf/AndroidManifest.xml
+++ b/tests/tests/openglperf/AndroidManifest.xml
@@ -19,6 +19,7 @@
android:versionName="1.0" >
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
@@ -26,10 +27,10 @@
<!-- Two activities are used -->
<instrumentation
android:targetPackage="com.replica.replicaisland"
- android:name="android.test.InstrumentationTestRunner" />
+ android:name="android.test.InstrumentationCtsTestRunner" />
<instrumentation
android:targetPackage="com.android.cts.openglperf"
- android:name="android.test.InstrumentationTestRunner" />
+ android:name="android.test.InstrumentationCtsTestRunner" />
<application
android:label="@string/app_name" >
diff --git a/tests/tests/os/Android.mk b/tests/tests/os/Android.mk
index 54ebc4a..be0ab83 100644
--- a/tests/tests/os/Android.mk
+++ b/tests/tests/os/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsOsTestCases
diff --git a/tests/tests/os/AndroidManifest.xml b/tests/tests/os/AndroidManifest.xml
index 1ae59a9..64b45be 100644
--- a/tests/tests/os/AndroidManifest.xml
+++ b/tests/tests/os/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.os">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index f001168..04d5ca9 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.1"));
+ new HashSet<String>(Arrays.asList("4.1.1"));
private static final int EXPECTED_SDK = 16;
@SuppressWarnings("deprecation")
diff --git a/tests/tests/permission/Android.mk b/tests/tests/permission/Android.mk
index 3e81c17..07f20d8 100644
--- a/tests/tests/permission/Android.mk
+++ b/tests/tests/permission/Android.mk
@@ -21,6 +21,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_JNI_SHARED_LIBRARIES := libctspermission_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/permission/AndroidManifest.xml b/tests/tests/permission/AndroidManifest.xml
index f824c7d..1e1465d 100644
--- a/tests/tests/permission/AndroidManifest.xml
+++ b/tests/tests/permission/AndroidManifest.xml
@@ -39,7 +39,7 @@
package. That runner cannot be added to this package either, since it
relies on hidden APIs.
-->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.permission"
android:label="CTS tests of com.android.cts.permission"/>
diff --git a/tests/tests/permission2/Android.mk b/tests/tests/permission2/Android.mk
index d461be4..86a8bc7 100755
--- a/tests/tests/permission2/Android.mk
+++ b/tests/tests/permission2/Android.mk
@@ -21,6 +21,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common mms-common
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsPermission2TestCases
diff --git a/tests/tests/permission2/AndroidManifest.xml b/tests/tests/permission2/AndroidManifest.xml
index 8f77fad..8cc7737 100755
--- a/tests/tests/permission2/AndroidManifest.xml
+++ b/tests/tests/permission2/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.permission2">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
@@ -41,7 +42,7 @@
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.permission2"
android:label="More CTS tests for permissions"/>
diff --git a/tests/tests/preference/Android.mk b/tests/tests/preference/Android.mk
index 7816c3b..cc2b210 100644
--- a/tests/tests/preference/Android.mk
+++ b/tests/tests/preference/Android.mk
@@ -22,6 +22,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsPreferenceTestCases
diff --git a/tests/tests/preference/AndroidManifest.xml b/tests/tests/preference/AndroidManifest.xml
index af57c86..3477192 100644
--- a/tests/tests/preference/AndroidManifest.xml
+++ b/tests/tests/preference/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.preference">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/preference2/Android.mk b/tests/tests/preference2/Android.mk
index 8fda601..47b081d 100644
--- a/tests/tests/preference2/Android.mk
+++ b/tests/tests/preference2/Android.mk
@@ -24,6 +24,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/preference2/AndroidManifest.xml b/tests/tests/preference2/AndroidManifest.xml
index 964a698..23b085d 100644
--- a/tests/tests/preference2/AndroidManifest.xml
+++ b/tests/tests/preference2/AndroidManifest.xml
@@ -17,6 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.preference2">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
<activity
@@ -34,7 +35,7 @@
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.preference2"
android:label="CTS Test Cases for android.preference"/>
diff --git a/tests/tests/provider/Android.mk b/tests/tests/provider/Android.mk
index fba7cda..edc078d 100644
--- a/tests/tests/provider/Android.mk
+++ b/tests/tests/provider/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsProviderTestCases
diff --git a/tests/tests/provider/AndroidManifest.xml b/tests/tests/provider/AndroidManifest.xml
index 6811ed2..75a6392 100644
--- a/tests/tests/provider/AndroidManifest.xml
+++ b/tests/tests/provider/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.provider">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
index 36612cf..f4d01e3 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
@@ -62,7 +62,8 @@
"/video/testvideo1.3gp";
int numBytes = 1337;
- FileUtils.createFile(new File(externalVideoPath), numBytes);
+ File videoFile = new File(externalVideoPath);
+ FileUtils.createFile(videoFile, numBytes);
ContentValues values = new ContentValues();
values.put(Media.ALBUM, "cts");
@@ -86,7 +87,7 @@
values.put(Media.TITLE, "testvideo");
long dateAdded = System.currentTimeMillis() / 1000;
values.put(Media.DATE_ADDED, dateAdded);
- long dateModified = System.currentTimeMillis() / 1000;
+ long dateModified = videoFile.lastModified() / 1000;
values.put(Media.DATE_MODIFIED, dateModified);
// insert
diff --git a/tests/tests/renderscript/Android.mk b/tests/tests/renderscript/Android.mk
index d2137e2..77bef50 100644
--- a/tests/tests/renderscript/Android.mk
+++ b/tests/tests/renderscript/Android.mk
@@ -28,6 +28,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
diff --git a/tests/tests/renderscript/AndroidManifest.xml b/tests/tests/renderscript/AndroidManifest.xml
index 7205b3c..49fca1e 100644
--- a/tests/tests/renderscript/AndroidManifest.xml
+++ b/tests/tests/renderscript/AndroidManifest.xml
@@ -21,12 +21,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.renderscript">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
<!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.stub"
android:label="CTS tests of Renderscript component"/>
diff --git a/tests/tests/sax/Android.mk b/tests/tests/sax/Android.mk
index 9dc1847..5270ae5 100644
--- a/tests/tests/sax/Android.mk
+++ b/tests/tests/sax/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSaxTestCases
diff --git a/tests/tests/sax/AndroidManifest.xml b/tests/tests/sax/AndroidManifest.xml
index e90f04d..4fbf840 100644
--- a/tests/tests/sax/AndroidManifest.xml
+++ b/tests/tests/sax/AndroidManifest.xml
@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.sax">
-
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index ef13886..40f844c 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -20,6 +20,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSecurityTestCases
diff --git a/tests/tests/security/AndroidManifest.xml b/tests/tests/security/AndroidManifest.xml
index 7dcd7a8..6c2c87a 100644
--- a/tests/tests/security/AndroidManifest.xml
+++ b/tests/tests/security/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.security">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
index f278b0f..a21589a 100644
--- a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
+++ b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
@@ -89,7 +89,16 @@
"com.android.tradefed.utils.wifi",
// Game used for CTS testing...
- "com.replica.replicaisland"
+ "com.replica.replicaisland",
+
+ // CTS test
+ "android.core.tests.libcore.package.com",
+ "android.core.tests.libcore.package.dalvik",
+ "android.core.tests.libcore.package.libcore",
+ "android.core.tests.libcore.package.org",
+ "android.core.tests.libcore.package.sun",
+ "android.core.tests.libcore.package.tests"
+
));
private boolean isWhitelistedPackage(String packageName) {
diff --git a/tests/tests/speech/Android.mk b/tests/tests/speech/Android.mk
index 225acf3..60acf90 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSpeechTestCases
diff --git a/tests/tests/speech/AndroidManifest.xml b/tests/tests/speech/AndroidManifest.xml
index 778f763..93576b1 100755
--- a/tests/tests/speech/AndroidManifest.xml
+++ b/tests/tests/speech/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.speech">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/telephony/Android.mk b/tests/tests/telephony/Android.mk
index f219f90..e7a3336 100644
--- a/tests/tests/telephony/Android.mk
+++ b/tests/tests/telephony/Android.mk
@@ -24,6 +24,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common mms-common
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsTelephonyTestCases
diff --git a/tests/tests/telephony/AndroidManifest.xml b/tests/tests/telephony/AndroidManifest.xml
index a565fad..1dfd68d 100644
--- a/tests/tests/telephony/AndroidManifest.xml
+++ b/tests/tests/telephony/AndroidManifest.xml
@@ -17,6 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.telephony">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index bbeffe0..4808bc0 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -29,6 +29,7 @@
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
+import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
@@ -41,6 +42,7 @@
*/
public class SmsManagerTest extends AndroidTestCase {
+ private static final String TAG = "SmsManagerTest";
private static final String LONG_TEXT =
"This is a very long text. This text should be broken into three " +
"separate messages.This is a very long text. This text should be broken into " +
@@ -82,7 +84,30 @@
"310000", // Tracfone
"46003", // China Telecom
"311230", // C SPire Wireless + Celluar South
- "310600" // Cellcom
+ "310600", // Cellcom
+ // Verizon
+ "310004",
+ "310012",
+ "311280",
+ "311281",
+ "311282",
+ "311283",
+ "311284",
+ "311285",
+ "311286",
+ "311287",
+ "311288",
+ "311289",
+ "311480",
+ "311481",
+ "311482",
+ "311483",
+ "311484",
+ "311485",
+ "311486",
+ "311487",
+ "311488",
+ "311489"
);
// List of network operators that doesn't support Data(binary) SMS message
@@ -96,7 +121,30 @@
"30237", // Fido
"45008", // KT
"45005", // SKT Mobility
- "45002" // SKT Mobility
+ "45002", // SKT Mobility
+ // Verizon
+ "310004",
+ "310012",
+ "311280",
+ "311281",
+ "311282",
+ "311283",
+ "311284",
+ "311285",
+ "311286",
+ "311287",
+ "311288",
+ "311289",
+ "311480",
+ "311481",
+ "311482",
+ "311483",
+ "311484",
+ "311485",
+ "311486",
+ "311487",
+ "311488",
+ "311489"
);
// List of network operators that doesn't support Maltipart SMS message
@@ -323,12 +371,11 @@
mReceivedDataSms = true;
mReceivedText=sb.toString();
}
+ Log.i(TAG, "onReceive " + intent.getAction());
if (intent.getAction().equals(mAction)) {
synchronized (mLock) {
mCalls += 1;
- if (mCalls >= mExpectedCalls) {
- mLock.notify();
- }
+ mLock.notify();
}
}
}
diff --git a/tests/tests/text/Android.mk b/tests/tests/text/Android.mk
index 1ffeee9..ae14124 100644
--- a/tests/tests/text/Android.mk
+++ b/tests/tests/text/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsTextTestCases
diff --git a/tests/tests/text/AndroidManifest.xml b/tests/tests/text/AndroidManifest.xml
index ee8e3b0..16ba2d9 100644
--- a/tests/tests/text/AndroidManifest.xml
+++ b/tests/tests/text/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.text">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index 9515281..1907ac7 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -24,6 +24,7 @@
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;
+import java.util.TimeZone;
public class DateUtilsTest extends AndroidTestCase {
@@ -38,6 +39,7 @@
protected void setUp() throws Exception {
super.setUp();
mContext = getContext();
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
mBaseTime = System.currentTimeMillis();
}
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 fdefcf8..c1587ae 100644
--- a/tests/tests/text/src/android/text/format/cts/TimeTest.java
+++ b/tests/tests/text/src/android/text/format/cts/TimeTest.java
@@ -26,7 +26,7 @@
import android.util.TimeFormatException;
public class TimeTest extends AndroidTestCase {
-
+ private static final String TAG = "TimeTest";
public void testConstructor() {
Time time = new Time();
new Time(Time.getCurrentTimezone());
@@ -483,10 +483,14 @@
public void testSetToNow0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
- long currentTime = System.currentTimeMillis();
+ // Time has resolution of 1 second. So round-off to second and compare
+ long currentTime = System.currentTimeMillis() / 1000;
t.setToNow();
- long time = t.toMillis(false);
- assertTrue(Math.abs(currentTime - time) < 999);
+ long time = t.toMillis(false) / 1000;
+ // 1 sec of delta can happen
+ if (Math.abs(currentTime - time) > 1) {
+ fail("currentTime " + currentTime + " time " + time);
+ }
}
public void testMillis0() throws Exception {
@@ -626,7 +630,7 @@
time.timezone = mTimeZones[zoneIndex];
long millis = time.normalize(true);
if (zoneIndex == 0) {
- Log.i("TimeTest", time.format("%B %d, %Y"));
+ Log.i(TAG, time.format("%B %d, %Y"));
}
// This is the Julian day for 12am for this day of the year
@@ -665,7 +669,7 @@
time.timezone = mTimeZones[zoneIndex];
long millis = time.normalize(true);
if (zoneIndex == 0) {
- Log.i("TimeTest", time.format("%B %d, %Y"));
+ Log.i(TAG, time.format("%B %d, %Y"));
}
int julianDay = Time.getJulianDay(millis, time.gmtoff);
@@ -684,7 +688,7 @@
millis = time.toMillis(false);
int day = Time.getJulianDay(millis, time.gmtoff);
if (day != julianDay) {
- Log.i("TimeTest", "Error: gmtoff " + (time.gmtoff / 3600.0) + " day "
+ Log.i(TAG, "Error: gmtoff " + (time.gmtoff / 3600.0) + " day "
+ julianDay + " millis " + millis + " " + time.format("%B %d, %Y")
+ " " + time.timezone);
}
diff --git a/tests/tests/textureview/Android.mk b/tests/tests/textureview/Android.mk
index 0dd610b..30cc4ff 100644
--- a/tests/tests/textureview/Android.mk
+++ b/tests/tests/textureview/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsTextureViewTestCases
diff --git a/tests/tests/textureview/AndroidManifest.xml b/tests/tests/textureview/AndroidManifest.xml
index 05e0ba6..63cd233 100644
--- a/tests/tests/textureview/AndroidManifest.xml
+++ b/tests/tests/textureview/AndroidManifest.xml
@@ -18,13 +18,14 @@
>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<instrumentation
android:targetPackage="com.android.cts.textureview"
- android:name="android.test.InstrumentationTestRunner" />
+ android:name="android.test.InstrumentationCtsTestRunner" />
<application
android:label="@string/app_name"
diff --git a/tests/tests/theme/Android.mk b/tests/tests/theme/Android.mk
index 95f55fb..5846426 100644
--- a/tests/tests/theme/Android.mk
+++ b/tests/tests/theme/Android.mk
@@ -27,6 +27,8 @@
# All tests should include android.test.runner.
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/theme/AndroidManifest.xml b/tests/tests/theme/AndroidManifest.xml
index f41183a..0edc836 100644
--- a/tests/tests/theme/AndroidManifest.xml
+++ b/tests/tests/theme/AndroidManifest.xml
@@ -17,12 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.theme">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
<activity android:name="android.theme.cts.DeviceDefaultActivity" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.theme"
android:label="CTS tests for themes"/>
</manifest>
diff --git a/tests/tests/util/Android.mk b/tests/tests/util/Android.mk
index b1bb103..f1c75dc 100644
--- a/tests/tests/util/Android.mk
+++ b/tests/tests/util/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsUtilTestCases
diff --git a/tests/tests/util/AndroidManifest.xml b/tests/tests/util/AndroidManifest.xml
index ee467c7..3969ac8 100644
--- a/tests/tests/util/AndroidManifest.xml
+++ b/tests/tests/util/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.util">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/view/Android.mk b/tests/tests/view/Android.mk
index 4d82d91..2c07cc3 100644
--- a/tests/tests/view/Android.mk
+++ b/tests/tests/view/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsViewTestCases
diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml
index ca82d07..233dc44 100644
--- a/tests/tests/view/AndroidManifest.xml
+++ b/tests/tests/view/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.view">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/view/src/android/view/cts/DisplayRefreshRateTest.java b/tests/tests/view/src/android/view/cts/DisplayRefreshRateTest.java
index a4c9318..cc2517d 100644
--- a/tests/tests/view/src/android/view/cts/DisplayRefreshRateTest.java
+++ b/tests/tests/view/src/android/view/cts/DisplayRefreshRateTest.java
@@ -25,6 +25,8 @@
import android.view.WindowManager;
import android.util.Log;
+import java.lang.InterruptedException;
+import java.lang.Thread;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
@@ -50,6 +52,7 @@
private class FpsResult {
private float mFps;
private boolean mValid = false;
+ private boolean mRestartRequested = false;
public final synchronized void notifyResult(float fps) {
if (!mValid) {
@@ -67,6 +70,17 @@
}
return mFps;
}
+
+ public synchronized void restart() {
+ mRestartRequested = true;
+ mValid = false;
+ }
+ public synchronized boolean restartNecessary() {
+ return mRestartRequested;
+ }
+ public synchronized void ackRestart() {
+ mRestartRequested = false;
+ }
}
private class Renderer implements GLSurfaceView.Renderer {
@@ -117,6 +131,11 @@
break;
case STATE_DONE:
+ if (mResult.restartNecessary()) {
+ mResult.ackRestart();
+ mState = STATE_START;
+ Log.d(TAG, "restarting");
+ }
break;
}
@@ -150,10 +169,9 @@
GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
- public void testRefreshRate() {
+ public void testRefreshRate() throws java.lang.InterruptedException {
+ boolean fpsOk = false;
GLSurfaceViewStubActivity activity = getActivity();
- float achievedFps = mResult.waitResult();
- activity.finish();
WindowManager wm = (WindowManager)activity
.getView()
@@ -162,10 +180,22 @@
Display dpy = wm.getDefaultDisplay();
float claimedFps = dpy.getRefreshRate();
- Log.d(TAG, "claimed " + claimedFps + " fps, " +
- "achieved " + achievedFps + " fps");
-
- assertTrue(Math.abs(claimedFps - achievedFps) <= FPS_TOLERANCE);
+ for (int i = 0; i < 3; i++) {
+ float achievedFps = mResult.waitResult();
+ Log.d(TAG, "claimed " + claimedFps + " fps, " +
+ "achieved " + achievedFps + " fps");
+ fpsOk = Math.abs(claimedFps - achievedFps) <= FPS_TOLERANCE;
+ if (fpsOk) {
+ break;
+ } else {
+ // it could be other sctivity like bug report capturing for other failures
+ // sleep for a while and re-try
+ Thread.sleep(10000);
+ mResult.restart();
+ }
+ }
+ activity.finish();
+ assertTrue(fpsOk);
}
}
diff --git a/tests/tests/view/src/android/view/cts/SurfaceViewTest.java b/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
index 4c0fafe..2d61559 100644
--- a/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
+++ b/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
@@ -18,6 +18,7 @@
import android.app.Instrumentation;
import android.content.Context;
+import android.cts.util.PollingCheck;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.Region;
@@ -30,7 +31,6 @@
import android.view.cts.SurfaceViewStubActivity.MockSurfaceView;
public class SurfaceViewTest extends ActivityInstrumentationTestCase2<SurfaceViewStubActivity> {
- private static final long WAIT_TIME = 1000;
private Context mContext;
private Instrumentation mInstrumentation;
@@ -136,13 +136,17 @@
}
public void testOnDetachedFromWindow() {
- MockSurfaceView mockSurfaceView = getActivity().getSurfaceView();
+ final MockSurfaceView mockSurfaceView = getActivity().getSurfaceView();
assertFalse(mockSurfaceView.isDetachedFromWindow());
assertTrue(mockSurfaceView.isShown());
sendKeys(KeyEvent.KEYCODE_BACK);
- sleep(WAIT_TIME);
- assertTrue(mockSurfaceView.isDetachedFromWindow());
- assertFalse(mockSurfaceView.isShown());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return mockSurfaceView.isDetachedFromWindow() &&
+ !mockSurfaceView.isShown();
+ }
+ }.run();
}
private void sleep(long time) {
diff --git a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
index adfec69..74f3c13 100644
--- a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
+++ b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
@@ -21,6 +21,7 @@
import android.app.Activity;
import android.app.Instrumentation;
+import android.cts.util.PollingCheck;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.test.ActivityInstrumentationTestCase2;
@@ -35,6 +36,7 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
+
public class View_UsingViewsTest extends ActivityInstrumentationTestCase2<UsingViewsStubActivity> {
/**
* country of Argentina
@@ -347,15 +349,21 @@
mEditText.setLongClickable(true);
assertTrue(mEditText.isLongClickable());
- MockOnLongClickListener onLongClickListener = new MockOnLongClickListener();
+ final MockOnLongClickListener onLongClickListener = new MockOnLongClickListener();
mEditText.setOnLongClickListener(onLongClickListener);
// long click the edit text
assertFalse(onLongClickListener.isOnLongClickCalled());
assertNull(onLongClickListener.getView());
+ mInstrumentation.waitForIdleSync();
TouchUtils.longClickView(this, mEditText);
- assertTrue(onLongClickListener.isOnLongClickCalled());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return onLongClickListener.isOnLongClickCalled();
+ }
+ }.run();
assertSame(mEditText, onLongClickListener.getView());
// click the Cancel button
diff --git a/tests/tests/webkit/Android.mk b/tests/tests/webkit/Android.mk
index 1426dbb..a307f99 100644
--- a/tests/tests/webkit/Android.mk
+++ b/tests/tests/webkit/Android.mk
@@ -23,6 +23,8 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsWebkitTestCases
diff --git a/tests/tests/webkit/AndroidManifest.xml b/tests/tests/webkit/AndroidManifest.xml
index d23a976..9475451 100644
--- a/tests/tests/webkit/AndroidManifest.xml
+++ b/tests/tests/webkit/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.webkit">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 0dd3934..0a8cc30 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -48,6 +48,7 @@
import android.webkit.SslErrorHandler;
import android.webkit.WebBackForwardList;
import android.webkit.WebChromeClient;
+import android.webkit.WebIconDatabase;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebView.HitTestResult;
@@ -86,6 +87,7 @@
private WebView mWebView;
private CtsTestServer mWebServer;
private WebViewOnUiThread mOnUiThread;
+ private WebIconDatabase mIconDb;
public WebViewTest() {
super("com.android.cts.stub", WebViewStubActivity.class);
@@ -108,6 +110,11 @@
if (mWebServer != null) {
mWebServer.shutdown();
}
+ if (mIconDb != null) {
+ mIconDb.removeAllIcons();
+ mIconDb.close();
+ mIconDb = null;
+ }
super.tearDown();
}
@@ -773,7 +780,7 @@
}
@UiThreadTest
- public void testLoadDataWithBaseUrl() throws Exception {
+ public void testLoadDataWithBaseUrl() throws Throwable {
assertNull(mWebView.getTitle());
assertNull(mWebView.getUrl());
String imgUrl = TestHtmlConstants.SMALL_IMG_URL; // relative
@@ -782,6 +789,9 @@
startWebServer(false);
String baseUrl = mWebServer.getAssetUrl("foo.html");
String historyUrl = "random";
+ String dbPath = getActivity().getFilesDir().toString() + "/icons";
+ mIconDb = WebIconDatabase.getInstance();
+ mIconDb.open(dbPath);
mWebServer.resetRequestState();
// force the favicon to be loaded first
mOnUiThread.loadDataWithBaseURLAndWaitForCompletion(baseUrl,
@@ -790,7 +800,9 @@
new PollingCheck() {
@Override
protected boolean check() {
- return mWebServer.getLastRequestUrl().endsWith("favicon.ico");
+ String lastRequestedUrl = mWebServer.getLastRequestUrl();
+ return lastRequestedUrl != null
+ && lastRequestedUrl.endsWith("favicon.ico");
}
}.run();
mOnUiThread.loadDataWithBaseURLAndWaitForCompletion(baseUrl,
@@ -1164,6 +1176,7 @@
final String imgUrl = mWebServer.getAssetUrl(TestHtmlConstants.LARGE_IMG_URL);
mOnUiThread.loadDataAndWaitForCompletion(
"<html><title>Title</title><body><img src=\"" + imgUrl
+ + "\" width=\"" + imgWidth + "\" height=\"" + imgHeight
+ "\"/></body></html>", "text/html", null);
getInstrumentation().waitForIdleSync();
diff --git a/tests/tests/webkitsecurity/Android.mk b/tests/tests/webkitsecurity/Android.mk
index 7223766..424cbf3 100644
--- a/tests/tests/webkitsecurity/Android.mk
+++ b/tests/tests/webkitsecurity/Android.mk
@@ -24,7 +24,7 @@
LOCAL_PACKAGE_NAME := CtsWebkitSecurityTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := ctsutil ctstestserver
+LOCAL_STATIC_JAVA_LIBRARIES := ctsutil ctstestserver ctstestrunner
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/webkitsecurity/AndroidManifest.xml b/tests/tests/webkitsecurity/AndroidManifest.xml
index 468a704..706c51c 100644
--- a/tests/tests/webkitsecurity/AndroidManifest.xml
+++ b/tests/tests/webkitsecurity/AndroidManifest.xml
@@ -18,12 +18,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.webkitsecurity">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
<activity android:name="android.webkitsecurity.cts.WebViewStubActivity" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.webkitsecurity"
android:label="CTS tests of android.webkitsecurity"/>
diff --git a/tests/tests/widget/Android.mk b/tests/tests/widget/Android.mk
index 628935c..f6be07d 100644
--- a/tests/tests/widget/Android.mk
+++ b/tests/tests/widget/Android.mk
@@ -21,7 +21,7 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES += android-common
+LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner
LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/tests/widget/AndroidManifest.xml b/tests/tests/widget/AndroidManifest.xml
index e510fcb..e69a7d5 100644
--- a/tests/tests/widget/AndroidManifest.xml
+++ b/tests/tests/widget/AndroidManifest.xml
@@ -18,6 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.widget">
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
index 6846d38..72150f2 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -534,6 +534,7 @@
assertEquals(0, listener.getPosition());
assertEquals(0, listener.getID());
+ mInstrumentation.waitForIdleSync();
TouchUtils.longClickView(this, v);
new PollingCheck() {
diff --git a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
index 7e46b82..760a160 100755
--- a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
@@ -25,6 +25,7 @@
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Context;
+import android.cts.util.PollingCheck;
import android.graphics.Rect;
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
@@ -373,7 +374,12 @@
mInstrumentation.sendStringSync(testString);
// onFilterComplete will close the popup.
- assertFalse(mAutoCompleteTextView.isPopupShowing());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return !mAutoCompleteTextView.isPopupShowing();
+ }
+ }.run();
if (mNumeric) {
// "that" in case of 12-key(NUMERIC) keyboard
@@ -382,7 +388,12 @@
testString = "that";
}
mInstrumentation.sendStringSync(testString);
- assertFalse(mAutoCompleteTextView.isPopupShowing());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return !mAutoCompleteTextView.isPopupShowing();
+ }
+ }.run();
// Test the expected filter matching scene
runTestOnUiThread(new Runnable() {
@@ -400,9 +411,12 @@
}
assertTrue(mAutoCompleteTextView.hasFocus());
assertTrue(mAutoCompleteTextView.hasWindowFocus());
- // give some time for UI to settle
- Thread.sleep(200);
- assertTrue(mAutoCompleteTextView.isPopupShowing());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return mAutoCompleteTextView.isPopupShowing();
+ }
+ }.run();
}
public void testPerformFiltering() throws Throwable {
@@ -450,7 +464,7 @@
});
mInstrumentation.waitForIdleSync();
// Create and get the filter.
- MockFilter filter = (MockFilter) adapter.getFilter();
+ final MockFilter filter = (MockFilter) adapter.getFilter();
// performFiltering will be indirectly invoked by onKeyDown
assertNull(filter.getResult());
@@ -458,13 +472,20 @@
if (mNumeric) {
// "numeric" in case of 12-key(NUMERIC) keyboard
mInstrumentation.sendStringSync("6688633777444222");
- Thread.sleep(100);
- assertEquals("numeric", filter.getResult());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return "numeric".equals(filter.getResult());
+ }
+ }.run();
} else {
mInstrumentation.sendStringSync(STRING_TEST);
- // give some time for UI to settle
- Thread.sleep(100);
- assertEquals(STRING_TEST, filter.getResult());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return STRING_TEST.equals(filter.getResult());
+ }
+ }.run();
}
}
diff --git a/tests/tests/widget/src/android/widget/cts/FilterTest.java b/tests/tests/widget/src/android/widget/cts/FilterTest.java
index d7d165e..394f861 100644
--- a/tests/tests/widget/src/android/widget/cts/FilterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/FilterTest.java
@@ -118,41 +118,57 @@
}
public boolean hadPublishedResults() {
- return mHadPublishedResults;
+ synchronized (this) {
+ return mHadPublishedResults;
+ }
}
public boolean hadPerformedFiltering() {
- return mHadPerformedFiltering;
+ synchronized (this) {
+ return mHadPerformedFiltering;
+ }
}
public CharSequence getPerformFilteringConstraint() {
- return mPerformFilteringConstraint;
+ synchronized (this) {
+ return mPerformFilteringConstraint;
+ }
}
public CharSequence getPublishResultsConstraint() {
- return mPublishResultsConstraint;
+ synchronized (this) {
+ return mPublishResultsConstraint;
+ }
}
public FilterResults getResults() {
- return mResults;
+ synchronized (this) {
+ return mResults;
+ }
}
public FilterResults getExpectResults() {
- return mExpectResults;
+ synchronized (this) {
+ return mExpectResults;
+ }
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
- mHadPerformedFiltering = true;
- mPerformFilteringConstraint = constraint;
- return mExpectResults;
+ synchronized (this) {
+ mHadPerformedFiltering = true;
+ mPerformFilteringConstraint = constraint;
+ return mExpectResults;
+ }
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
- mPublishResultsConstraint = constraint;
- mResults = results;
- mHadPublishedResults = true;
+ synchronized (this) {
+ mPublishResultsConstraint = constraint;
+ mResults = results;
+ mHadPublishedResults = true;
+ }
}
}
diff --git a/tools/tradefed-host/res/config/cts.xml b/tools/tradefed-host/res/config/cts.xml
index 0c7fe58..158f49d 100644
--- a/tools/tradefed-host/res/config/cts.xml
+++ b/tools/tradefed-host/res/config/cts.xml
@@ -17,7 +17,6 @@
description="Runs a CTS plan from a pre-existing CTS installation">
<option name="enable-root" value="false" />
- <option name="disable-keyguard" value="false" />
<build_provider class="com.android.cts.tradefed.build.CtsBuildProvider" />
<device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" />
<test class="com.android.cts.tradefed.testtype.CtsTest" />
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
index 2f0e872..a815a48 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
@@ -173,6 +173,8 @@
helpBuilder.append("session\n");
helpBuilder.append("Dump:\n");
helpBuilder.append(" d/dump l/logs: dump the tradefed logs for all running invocations\n");
+ helpBuilder.append("Options:\n");
+ helpBuilder.append(" --reboot-per-package : reboot device after running each package.\n");
return helpBuilder.toString();
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 8142036..78f7412 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -29,6 +29,7 @@
import com.android.tradefed.config.Option.Importance;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.device.TestDeviceOptions;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
@@ -46,6 +47,9 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.lang.InterruptedException;
+import java.lang.System;
+import java.lang.Thread;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -132,6 +136,18 @@
"run tests including known failures")
private boolean mIncludeKnownFailures;
+ @Option(name = "reboot-per-package", description =
+ "Reboot after each package run")
+ private boolean mRebootPerPackage = false;
+
+ @Option(name = "reboot-wait-time", description =
+ "Additional wait time in ms after boot complete. Meaningful only with reboot-per-package option")
+ private int mRebootWaitTimeMSec = 2 * 60 * 1000;
+
+ @Option(name = "reboot-interval", description =
+ "Interval between each reboot in min. Meaningful only with reboot-per-package option")
+ private int mRebootIntervalMin = 30;
+
/** data structure for a {@link IRemoteTest} and its known tests */
class TestPackage {
private final IRemoteTest mTestForPackage;
@@ -330,7 +346,12 @@
// always collect the device info, even for resumed runs, since test will likely be
// running on a different device
collectDeviceInfo(getDevice(), mCtsBuild, listener);
-
+ if (mRemainingTestPkgs.size() > 1) {
+ Log.i(LOG_TAG, "Initial reboot for multiple packages");
+ rebootDevice();
+ }
+ long prevTime = System.currentTimeMillis();
+ long intervalInMSec = mRebootIntervalMin * 60 * 1000;
while (!mRemainingTestPkgs.isEmpty()) {
TestPackage knownTests = mRemainingTestPkgs.get(0);
@@ -345,6 +366,20 @@
forwardPackageDetails(knownTests.getPackageDef(), listener);
test.run(filter);
mRemainingTestPkgs.remove(0);
+ if (mRemainingTestPkgs.size() > 0) {
+ if (mRebootPerPackage) {
+ long currentTime = System.currentTimeMillis();
+ if ((currentTime - prevTime) > intervalInMSec) {
+ Log.i(LOG_TAG, String.format("Rebooting after running package %s",
+ knownTests.getPackageDef().getName()));
+ rebootDevice();
+ prevTime = System.currentTimeMillis();
+ }
+ }
+ // remove artifacts like status bar from the previous test.
+ // But this cannot dismiss dialog popped-up.
+ changeToHomeScreen();
+ }
}
if (mScreenshot) {
@@ -363,6 +398,40 @@
}
}
+ private void rebootDevice() throws DeviceNotAvailableException {
+ final int TIMEOUT_MS = 4 * 60 * 1000;
+ TestDeviceOptions options = mDevice.getOptions();
+ // store default value and increase time-out for reboot
+ int rebootTimeout = options.getRebootTimeout();
+ long onlineTimeout = options.getOnlineTimeout();
+ options.setRebootTimeout(TIMEOUT_MS);
+ options.setOnlineTimeout(TIMEOUT_MS);
+ mDevice.setOptions(options);
+
+ mDevice.reboot();
+
+ // restore default values
+ options.setRebootTimeout(rebootTimeout);
+ options.setOnlineTimeout(onlineTimeout);
+ mDevice.setOptions(options);
+ Log.i(LOG_TAG, "Rebooting done");
+ try {
+ Thread.sleep(mRebootWaitTimeMSec);
+ } catch (InterruptedException e) {
+ Log.i(LOG_TAG, "Boot wait interrupted");
+ }
+ }
+
+ private void changeToHomeScreen() throws DeviceNotAvailableException {
+ final String homeCmd = "input keyevent 3";
+
+ mDevice.executeShellCommand(homeCmd);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ //ignore
+ }
+ }
/**
* Build the list of test packages to run
*/