am d2d1f922: Merge "This module doesn\'t build, don\'t try to."
* commit 'd2d1f92256ee270e57dba04d24cfdaf84bb46636':
This module doesn't build, don't try to.
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 6373173..0898369 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="1"
- android:versionName="4.1_r1">
+ android:versionName="4.1_r2">
<!-- Using 10 for more complete NFC support... -->
<uses-sdk android:minSdkVersion="10"></uses-sdk>
@@ -183,7 +183,6 @@
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/bt_device_communication" />
<meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
@@ -194,7 +193,6 @@
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/bt_device_communication" />
<meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
@@ -308,7 +306,6 @@
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_camera" />
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/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/ReceiveUriActivity.java b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/ReceiveUriActivity.java
index 0ddc4a5..851d8da 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/ReceiveUriActivity.java
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/ReceiveUriActivity.java
@@ -16,13 +16,15 @@
package com.android.cts.usespermissiondiffcertapp;
+import static android.text.format.DateUtils.SECOND_IN_MILLIS;
+
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
-import android.os.SystemClock;
import android.os.MessageQueue.IdleHandler;
+import android.os.SystemClock;
import android.util.Log;
public class ReceiveUriActivity extends Activity {
@@ -33,6 +35,8 @@
private static boolean sDestroyed;
private static ReceiveUriActivity sCurInstance;
+ private static final long TIMEOUT_MILLIS = 30 * SECOND_IN_MILLIS;
+
Handler mHandler = new Handler();
@Override
@@ -94,10 +98,10 @@
final long startTime = SystemClock.uptimeMillis();
while (!sDestroyed) {
try {
- sLock.wait(5000);
+ sLock.wait(TIMEOUT_MILLIS);
} catch (InterruptedException e) {
}
- if (SystemClock.uptimeMillis() >= (startTime+5000)) {
+ if (SystemClock.uptimeMillis() >= (startTime + TIMEOUT_MILLIS)) {
throw new RuntimeException("Timeout");
}
}
@@ -121,10 +125,10 @@
final long startTime = SystemClock.uptimeMillis();
while (!sStarted) {
try {
- sLock.wait(5000);
+ sLock.wait(TIMEOUT_MILLIS);
} catch (InterruptedException e) {
}
- if (SystemClock.uptimeMillis() >= (startTime+5000)) {
+ if (SystemClock.uptimeMillis() >= (startTime + TIMEOUT_MILLIS)) {
throw new RuntimeException("Timeout");
}
}
@@ -136,10 +140,10 @@
final long startTime = SystemClock.uptimeMillis();
while (!sNewIntent) {
try {
- sLock.wait(5000);
+ sLock.wait(TIMEOUT_MILLIS);
} catch (InterruptedException e) {
}
- if (SystemClock.uptimeMillis() >= (startTime+5000)) {
+ if (SystemClock.uptimeMillis() >= (startTime + TIMEOUT_MILLIS)) {
throw new RuntimeException("Timeout");
}
}
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/suite/audio_quality/Android.mk b/suite/audio_quality/Android.mk
index c12e390..2078606 100644
--- a/suite/audio_quality/Android.mk
+++ b/suite/audio_quality/Android.mk
@@ -19,16 +19,26 @@
CTS_AUDIO_TOP:= $(call my-dir)
-CTS_AUDIO_INSTALL_DIR := $(HOST_OUT)/cts_audio_quality
+CTS_AUDIO_INSTALL_DIR := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality
+CTS_AUDIO_QUALITY_ZIP := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality.zip
-cts_audio: cts_audio_quality_test cts_audio_quality CtsAudioClient $(CTS_AUDIO_TOP)/test_description
+$(CTS_AUDIO_QUALITY_ZIP): cts_audio_quality_test cts_audio_quality \
+ CtsAudioClient $(CTS_AUDIO_TOP)/test_description
$(hide) mkdir -p $(CTS_AUDIO_INSTALL_DIR)
$(hide) mkdir -p $(CTS_AUDIO_INSTALL_DIR)/client
- $(hide) $(ACP) -fp $(ANDROID_PRODUCT_OUT)/data/app/CtsAudioClient.apk \
+ $(hide) $(ACP) -fp $(PRODUCT_OUT)/data/app/CtsAudioClient.apk \
$(CTS_AUDIO_INSTALL_DIR)/client
$(hide) $(ACP) -fp $(HOST_OUT)/bin/cts_audio_quality_test $(CTS_AUDIO_INSTALL_DIR)
$(hide) $(ACP) -fp $(HOST_OUT)/bin/cts_audio_quality $(CTS_AUDIO_INSTALL_DIR)
$(hide) $(ACP) -fr $(CTS_AUDIO_TOP)/test_description $(CTS_AUDIO_INSTALL_DIR)
+ $(hide) echo "Package cts_audio: $@"
+ $(hide) cd $(HOST_OUT)/cts-audio-quality && \
+ zip -rq android-cts-audio-quality.zip android-cts-audio-quality -x android-cts-audio-quality/reports/\*
+
+cts: $(CTS_AUDIO_QUALITY_ZIP)
+ifneq ($(filter cts, $(MAKECMDGOALS)),)
+$(call dist-for-goals, cts, $(CTS_AUDIO_QUALITY_ZIP))
+endif # cts
include $(call all-subdir-makefiles)
diff --git a/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java b/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java
index c5bc671..d3ace8b 100644
--- a/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java
+++ b/suite/audio_quality/client/src/com/android/cts/audiotest/AudioProtocol.java
@@ -22,6 +22,7 @@
import android.media.AudioRecord;
import android.media.MediaRecorder.AudioSource;
import android.media.AudioTrack;
+import android.os.Build;
import android.os.Looper;
import android.util.Log;
@@ -52,10 +53,11 @@
private static final int PROTOCOL_ERROR_GENERIC = 2;
private static final int CMD_DOWNLOAD = 0x12340001;
- private static final int CMD_START_PLAYBACK = 0x12340002;
- private static final int CMD_STOP_PLAYBACK = 0x12340003;
+ private static final int CMD_START_PLAYBACK = 0x12340002;
+ private static final int CMD_STOP_PLAYBACK = 0x12340003;
private static final int CMD_START_RECORDING = 0x12340004;
private static final int CMD_STOP_RECORDING = 0x12340005;
+ private static final int CMD_GET_DEVICE_INFO = 0x12340006;
private ByteBuffer mHeaderBuffer = ByteBuffer.allocate(PROTOCOL_HEADER_SIZE);
private ByteBuffer mDataBuffer = ByteBuffer.allocate(MAX_NON_DATA_PAYLOAD_SIZE);
@@ -263,6 +265,9 @@
if (bufferSize < 256 * 1024) {
bufferSize = 256 * 1024;
}
+ if (bufferSize > data.capacity()) {
+ bufferSize = data.capacity();
+ }
mPlayback = new AudioTrack(type, samplingRate,
stereo ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, bufferSize,
@@ -288,6 +293,9 @@
while (dataWritten < data.capacity()) {
int dataLeft = data.capacity() - dataWritten;
dataToWrite = (bufferSize < dataLeft)? bufferSize : dataLeft;
+ if (mPlayback == null) { // stopped
+ return;
+ }
mPlayback.write(data.array(), dataWritten, dataToWrite);
dataWritten += dataToWrite;
}
@@ -366,19 +374,11 @@
totalRead += lenRead;
}
Log.d(TAG, "reading recording completed");
- mClientLock.lock();
-
- mReplyBuffer.clear();
- mReplyBuffer.putInt((CMD_START_RECORDING & 0xffff) | 0x43210000);
- mReplyBuffer.putInt(recordingOk ? PROTOCOL_OK : PROTOCOL_ERROR_GENERIC);
- mReplyBuffer.putInt(recordingOk ? mRecordingLength : 0);
-
- if (mOutput != null) {
- mOutput.write(mReplyBuffer.array(), 0, PROTOCOL_SIMPLE_REPLY_SIZE);
- if (recordingOk) {
- mOutput.write(data, 0, mRecordingLength);
- }
- }
+ sendReplyWithData(
+ CMD_START_RECORDING,
+ recordingOk ? PROTOCOL_OK : PROTOCOL_ERROR_GENERIC,
+ recordingOk ? mRecordingLength : 0,
+ recordingOk ? data : null);
} catch (IOException e) {
// maybe socket already closed. don't do anything
Log.e(TAG, "ignore exception", e);
@@ -386,7 +386,6 @@
mRecord.stop();
mRecord.release();
mRecord = null;
- mClientLock.unlock();
}
}
});
@@ -412,6 +411,32 @@
sendSimpleReplyHeader(CMD_STOP_RECORDING, PROTOCOL_OK);
}
+ private static final String BUILD_INFO_TAG = "build-info";
+
+ private void appendAttrib(StringBuilder builder, String name, String value) {
+ builder.append(" " + name + "=\"" + value + "\"");
+ }
+
+ private void handleGetDeviceInfo(int len) throws ProtocolError, IOException{
+ Log.d(TAG, "getDeviceInfo");
+ assertProtocol(len == 0, "wrong payload len");
+ StringBuilder builder = new StringBuilder();
+ builder.append("<build-info");
+ appendAttrib(builder, "board", Build.BOARD);
+ appendAttrib(builder, "brand", Build.BRAND);
+ appendAttrib(builder, "device", Build.DEVICE);
+ appendAttrib(builder, "display", Build.DISPLAY);
+ appendAttrib(builder, "fingerprint", Build.FINGERPRINT);
+ appendAttrib(builder, "id", Build.ID);
+ appendAttrib(builder, "model", Build.MODEL);
+ appendAttrib(builder, "product", Build.PRODUCT);
+ appendAttrib(builder, "release", Build.VERSION.RELEASE);
+ appendAttrib(builder, "sdk", Integer.toString(Build.VERSION.SDK_INT));
+ builder.append(" />");
+ byte[] data = builder.toString().getBytes();
+
+ sendReplyWithData(CMD_GET_DEVICE_INFO, PROTOCOL_OK, data.length, data);
+ }
/**
* send reply without payload.
* This function is thread-safe.
@@ -422,20 +447,29 @@
*/
private void sendSimpleReplyHeader(int command, int errorCode) throws IOException {
Log.d(TAG, "sending reply cmd " + command + " err " + errorCode);
+ sendReplyWithData(command, errorCode, 0, null);
+ }
+
+ private void sendReplyWithData(int cmd, int errorCode, int len, byte[] data) throws IOException {
try {
mClientLock.lock();
mReplyBuffer.clear();
- mReplyBuffer.putInt((command & 0xffff) | 0x43210000);
+ mReplyBuffer.putInt((cmd & 0xffff) | 0x43210000);
mReplyBuffer.putInt(errorCode);
- mReplyBuffer.putInt(0); // payload length
+ mReplyBuffer.putInt(len);
+
if (mOutput != null) {
mOutput.write(mReplyBuffer.array(), 0, PROTOCOL_SIMPLE_REPLY_SIZE);
+ if (data != null) {
+ mOutput.write(data, 0, len);
+ }
}
+ } catch (IOException e) {
+ throw e;
} finally {
mClientLock.unlock();
}
}
-
private class LoopThread extends Thread {
private Looper mLooper;
LoopThread(Runnable runnable) {
@@ -513,6 +547,8 @@
case CMD_STOP_RECORDING:
handleStopRecording(len);
break;
+ case CMD_GET_DEVICE_INFO:
+ handleGetDeviceInfo(len);
}
}
} catch (IOException e) {
diff --git a/suite/audio_quality/executable/src/main.cpp b/suite/audio_quality/executable/src/main.cpp
index 3d72d0d..cf33a0f 100644
--- a/suite/audio_quality/executable/src/main.cpp
+++ b/suite/audio_quality/executable/src/main.cpp
@@ -13,15 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-
+#include <getopt.h>
#include <stdio.h>
#include <utils/String8.h>
#include <UniquePtr.h>
+#include "GenericFactory.h"
#include "Log.h"
#include "Report.h"
+#include "Settings.h"
#include "task/TaskGeneric.h"
#include "task/ModelBuilder.h"
@@ -29,30 +31,58 @@
class CleanupStatics {
public:
- CleanupStatics() {};
+ CleanupStatics() {
+
+ }
~CleanupStatics() {
Log::Finalize();
Report::Finalize();
+ // create zip file after log and report files are closed.
+ android::String8 reportDirPath =
+ Settings::Instance()->getSetting(Settings::EREPORT_FILE).getPathDir();
+ android::String8 zipFilename = reportDirPath.getPathLeaf();
+ android::String8 command = android::String8::format("cd %s;zip -r ../%s.zip *",
+ reportDirPath.string(), zipFilename.string());
+ fprintf(stderr, "\n\nexecuting %s\n", command.string());
+ if (system(command.string()) == -1) {
+ fprintf(stderr, "cannot create zip file with command %s\n", command.string());
+ }
+ Settings::Finalize();
}
};
+void usage(char* bin)
+{
+ fprintf(stderr, "%s [-l log_level][-s serial] test_xml\n", bin);
+}
int main(int argc, char *argv[])
{
if (argc < 2) {
- fprintf(stderr, "%s [-llog_level] test_xml\n", argv[0]);
+ fprintf(stderr, "%s [-l log_level][-s serial] test_xml\n", argv[0]);
return 1;
}
- int logLevel = 3;
- int argCurrent = 1;
- if (strncmp(argv[argCurrent], "-l", 2) == 0) {
- logLevel = atoi(argv[argCurrent] + 2);
- argCurrent++;
+ int logLevel = Log::ELogE;
+ char* serial = NULL;
+ int opt;
+ while ((opt = getopt(argc, argv, "l:s:")) != -1) {
+ switch (opt) {
+ case 'l':
+ logLevel = atoi(optarg);
+ break;
+ case 's':
+ serial = optarg;
+ break;
+ default:
+ usage(argv[0]);
+ return 1;
+ }
}
- if (argCurrent == argc) {
- fprintf(stderr, "wrong arguments");
+ if (optind >= argc) {
+ usage(argv[0]);
return 1;
}
- android::String8 xmlFile(argv[argCurrent]);
+
+ android::String8 xmlFile(argv[optind]);
android::String8 dirName;
if (!FileUtil::prepare(dirName)) {
@@ -61,6 +91,14 @@
}
UniquePtr<CleanupStatics> staticStuffs(new CleanupStatics());
+ if (Settings::Instance() == NULL) {
+ fprintf(stderr, "caanot create Settings");
+ return 1;
+ }
+ if (serial != NULL) {
+ android::String8 strSerial(serial);
+ Settings::Instance()->addSetting(Settings::EADB, strSerial);
+ }
if (Log::Instance(dirName.string()) == NULL) {
fprintf(stderr, "cannot create Log");
return 1;
@@ -73,13 +111,33 @@
return 1;
}
+ GenericFactory factory;
+ ClientInterface* client = factory.createClientInterface();
+ if (client == NULL) {
+ fprintf(stderr, "cannot create ClientInterface");
+ return 1;
+ }
+ if (!client->init(Settings::Instance()->getSetting(Settings::EADB))) {
+ fprintf(stderr, "cannot init ClientInterface");
+ return 1;
+ }
+ android::String8 deviceInfo;
+ if (!client->getAudio()->getDeviceInfo(deviceInfo)) {
+ fprintf(stderr, "cannot get device info");
+ return 1;
+ }
+ delete client; // release so that it can be used in tests
+ Settings::Instance()->addSetting(Settings::EDEVICE_INFO, deviceInfo);
+
ModelBuilder modelBuilder;
UniquePtr<TaskGeneric> topTask(modelBuilder.parseTestDescriptionXml(xmlFile));
if (topTask.get() == NULL) {
LOGE("Parsing of %x failed", xmlFile.string());
return 1;
}
+ Settings::Instance()->addSetting(Settings::ETEST_XML, xmlFile);
topTask->run();
+
return 0;
}
diff --git a/suite/audio_quality/lib/include/GenericFactory.h b/suite/audio_quality/lib/include/GenericFactory.h
index 243a744..9f74b7f 100644
--- a/suite/audio_quality/lib/include/GenericFactory.h
+++ b/suite/audio_quality/lib/include/GenericFactory.h
@@ -18,8 +18,8 @@
#define CTSAUDIO_GENERIC_FACTORY_H
#include "task/TaskGeneric.h"
+#include "ClientInterface.h"
-class ClientInterface;
/**
* Factory methods for all abstract classes
diff --git a/suite/audio_quality/lib/include/Log.h b/suite/audio_quality/lib/include/Log.h
index 2b75bc2..e3e803c 100644
--- a/suite/audio_quality/lib/include/Log.h
+++ b/suite/audio_quality/lib/include/Log.h
@@ -59,6 +59,8 @@
#define LOGD(x...) do { Log::Instance()->printf(Log::ELogD, x); } while(0)
#define LOGV(x...) do { Log::Instance()->printf(Log::ELogV, x); } while(0)
+#define MSG(x...) do { Log::Instance()->printf(Log::ELogW, x); } while(0)
+
#define ASSERT(cond) if(!(cond)) { Log::Instance()->printf(Log::ELogE, \
"assertion failed %s %d", __FILE__, __LINE__); \
Log::Finalize(); \
diff --git a/suite/audio_quality/lib/include/Report.h b/suite/audio_quality/lib/include/Report.h
index 67a0572..248f4b9 100644
--- a/suite/audio_quality/lib/include/Report.h
+++ b/suite/audio_quality/lib/include/Report.h
@@ -37,13 +37,14 @@
void addCasePassed(const android::String8& name);
void addCaseFailed(const android::String8& name);
- void printf(const char* fmt, ...);
+
private:
Report();
~Report();
bool init(const char* dirName);
- void writeSummary();
+ void writeReport();
+ void printf(const char* fmt, ...);
private:
static Report* mInstance;
diff --git a/suite/audio_quality/lib/include/Settings.h b/suite/audio_quality/lib/include/Settings.h
index 5cdcd7a..a8cfea5 100644
--- a/suite/audio_quality/lib/include/Settings.h
+++ b/suite/audio_quality/lib/include/Settings.h
@@ -25,13 +25,18 @@
static Settings* Instance();
static void Finalize();
enum SettingType {
- EADB
+ EADB = 0, // adb device serial number
+ EREPORT_TIME = 1,
+ EREPORT_FILE = 2,
+ EDEVICE_INFO = 3,
+ ETEST_XML = 4, // name of test description xml
+ EMAX_SETTINGS = 4 // not real setting
};
void addSetting(SettingType type, const android::String8 setting);
const android::String8& getSetting(SettingType type);
private:
static Settings* mInstance;
- android::String8 mAdbSetting;
+ android::String8 mSettings[EMAX_SETTINGS + 1];
};
diff --git a/suite/audio_quality/lib/include/audio/AudioProtocol.h b/suite/audio_quality/lib/include/audio/AudioProtocol.h
index 83ba922..01e8507 100644
--- a/suite/audio_quality/lib/include/audio/AudioProtocol.h
+++ b/suite/audio_quality/lib/include/audio/AudioProtocol.h
@@ -37,6 +37,7 @@
uint32_t mVolume;
uint32_t mId;
android::sp<Buffer> mBuffer;
+ void* mExtra; // extra data for whatever purpose
};
class AudioProtocol {
@@ -48,7 +49,8 @@
ECmdStopPlayback = 0x12340003,
ECmdStartRecording = 0x12340004,
ECmdStopRecording = 0x12340005,
- ECmdLast = 0x12340006, // not actual command
+ ECmdGetDeviceInfo = 0x12340006,
+ ECmdLast = 0x12340007, // not actual command
};
static const uint32_t REPLY_HEADER_SIZE = 12;
@@ -140,7 +142,13 @@
virtual ~CmdStopRecording() {};
};
+class CmdGetDeviceInfo: public AudioProtocol {
+public:
+ CmdGetDeviceInfo(ClientSocket& socket)
+ : AudioProtocol(socket, ECmdGetDeviceInfo) {};
+ virtual ~CmdGetDeviceInfo() {};
-
+ virtual bool handleReply(const uint32_t* data, AudioParam* param);
+};
#endif // CTSAUDIO_AUDIOPROTOCOL_H
diff --git a/suite/audio_quality/lib/include/audio/RemoteAudio.h b/suite/audio_quality/lib/include/audio/RemoteAudio.h
index 4c587e6..26647c4 100644
--- a/suite/audio_quality/lib/include/audio/RemoteAudio.h
+++ b/suite/audio_quality/lib/include/audio/RemoteAudio.h
@@ -21,6 +21,7 @@
#include <map>
#include <utils/Looper.h>
+#include <utils/String8.h>
#include <utils/StrongPointer.h>
#include <utils/threads.h>
@@ -56,6 +57,8 @@
android::sp<Buffer>& buffer);
bool waitForRecordingCompletion();
void stopRecording();
+
+ bool getDeviceInfo(android::String8& data);
/** should be called before RemoteAudio is destroyed */
void release();
@@ -139,6 +142,7 @@
android::sp<android::MessageHandler> mDownloadHandler;
android::sp<android::MessageHandler> mPlaybackHandler;
android::sp<android::MessageHandler> mRecordingHandler;
+ android::sp<android::MessageHandler> mDeviceInfoHandler;
AudioProtocol* mCmds[AudioProtocol::ECmdLast - AudioProtocol::ECmdStart];
int mDownloadId;
diff --git a/suite/audio_quality/lib/src/FileUtil.cpp b/suite/audio_quality/lib/src/FileUtil.cpp
index e40b7e3..8c8ea7e 100644
--- a/suite/audio_quality/lib/src/FileUtil.cpp
+++ b/suite/audio_quality/lib/src/FileUtil.cpp
@@ -19,6 +19,7 @@
#include <errno.h>
#include "Log.h"
+#include "Settings.h"
#include "StringUtil.h"
#include "FileUtil.h"
@@ -54,9 +55,14 @@
_LOGD_("mkdir of topdir failed, error %d", errno);
return false;
}
+ android::String8 reportTime;
+ if (reportTime.appendFormat("%04d_%02d_%02d_%02d_%02d_%02d", tm->tm_year + 1900,
+ tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec) != 0) {
+ return false;
+ }
+ Settings::Instance()->addSetting(Settings::EREPORT_TIME, reportTime);
android::String8 path;
- if (path.appendFormat("%s/%04d_%02d_%02d_%02d_%02d_%02d", reportTopDir,tm->tm_year + 1900,
- tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec) != 0) {
+ if (path.appendFormat("%s/%s", reportTopDir, reportTime.string()) != 0) {
return false;
}
result = mkdir(path.string(), S_IRWXU);
diff --git a/suite/audio_quality/lib/src/Report.cpp b/suite/audio_quality/lib/src/Report.cpp
index b487836..e6a248c 100644
--- a/suite/audio_quality/lib/src/Report.cpp
+++ b/suite/audio_quality/lib/src/Report.cpp
@@ -15,6 +15,7 @@
*/
#include "Log.h"
+#include "Settings.h"
#include "StringUtil.h"
#include "Report.h"
@@ -43,7 +44,7 @@
Report::~Report()
{
- writeSummary();
+ writeReport();
}
bool Report::init(const char* dirName)
@@ -52,9 +53,10 @@
return true;
}
android::String8 report;
- if (report.appendFormat("%s/report.txt", dirName) != 0) {
+ if (report.appendFormat("%s/report.xml", dirName) != 0) {
return false;
}
+ Settings::Instance()->addSetting(Settings::EREPORT_FILE, report);
return FileUtil::init(report.string());
}
@@ -76,17 +78,24 @@
mFailedCases.push_back(name);
}
-void Report::writeSummary()
+void Report::writeReport()
{
- printf("= Test cases executed: %d, passed: %d, failed: %d =",
- mPassedCases.size() + mFailedCases.size(), mPassedCases.size(), mFailedCases.size());
- printf("= Failed cases =");
+ printf("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>");
+ printf("<audio-test-results-report report-version=\"1\" creation-time=\"%s\">",
+ Settings::Instance()->getSetting(Settings::EREPORT_TIME).string());
+ printf(" <verifier-info version-name=\"1\" version-code=\"1\" />");
+ printf(" <device-info>");
+ printf(" %s", Settings::Instance()->getSetting(Settings::EDEVICE_INFO).string());
+ printf(" </device-info>");
+ printf(" <audio-test-results xml=\"%s\">",
+ Settings::Instance()->getSetting(Settings::ETEST_XML).string());
std::list<android::String8>::iterator it;
for (it = mFailedCases.begin(); it != mFailedCases.end(); it++) {
- printf("* %s", it->string());
+ printf(" <test title=\"%s\" result=\"fail\" />", it->string());
}
- printf("= Passed cases =");
for (it = mPassedCases.begin(); it != mPassedCases.end(); it++) {
- printf("* %s", it->string());
+ printf(" <test title=\"%s\" result=\"pass\" />", it->string());
}
+ printf(" </audio-test-results>");
+ printf("</audio-test-results-report>");
}
diff --git a/suite/audio_quality/lib/src/Settings.cpp b/suite/audio_quality/lib/src/Settings.cpp
index 4f78fe4..42dd30e 100644
--- a/suite/audio_quality/lib/src/Settings.cpp
+++ b/suite/audio_quality/lib/src/Settings.cpp
@@ -36,23 +36,11 @@
void Settings::addSetting(SettingType type, const android::String8 setting)
{
- // TODO key, string can be better if there are large number of settings
- switch(type) {
- case EADB:
- mAdbSetting = setting;
- default:
- ASSERT(false);
- }
+ mSettings[type] = setting;
}
const android::String8& Settings::getSetting(SettingType type)
{
- switch(type) {
- case EADB:
- return mAdbSetting;
- default:
- ASSERT(false);
- }
- return mAdbSetting; // just for removing compiler warning, will not reach here
+ return mSettings[type];
}
diff --git a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
index bf1ca22..c3457f5 100644
--- a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
+++ b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
@@ -19,6 +19,7 @@
#include <sys/socket.h>
#include <utils/StrongPointer.h>
+#include <utils/UniquePtr.h>
#include "audio/Buffer.h"
#include "Log.h"
@@ -171,6 +172,26 @@
return true;
}
+bool CmdGetDeviceInfo::handleReply(const uint32_t* data, AudioParam* param)
+{
+ if (!checkHeaderId(data, ECmdGetDeviceInfo)) {
+ return false;
+ }
+ if (data[1] != 0) { // no endian change for 0
+ LOGE("error in reply %d", ntohl(data[1]));
+ return false;
+ }
+ int len = ntohl(data[2]);
+ UniquePtr<char, DefaultDelete<char[]> > infoString(new char[len + 1]);
+ if (!readData(infoString.get(), len)) {
+ return false;
+ }
+ (infoString.get())[len] = 0;
+ LOGI("received data %s from device", infoString.get());
+ android::String8* string = reinterpret_cast<android::String8*>(param->mExtra);
+ string->setTo(infoString.get(), len);
+ return true;
+}
diff --git a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp b/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
index bb9474b..1156173 100644
--- a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
+++ b/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
@@ -32,6 +32,7 @@
mDownloadHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdDownload)),
mPlaybackHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdStartPlayback)),
mRecordingHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdStartRecording)),
+ mDeviceInfoHandler(new CommandHandler(*this, (int)AudioProtocol::ECmdGetDeviceInfo)),
mDownloadId(0)
{
mCmds[AudioProtocol::ECmdDownload - AudioProtocol::ECmdStart] = new CmdDownload(socket);
@@ -43,6 +44,8 @@
new CmdStartRecording(socket);
mCmds[AudioProtocol::ECmdStopRecording - AudioProtocol::ECmdStart] =
new CmdStopRecording(socket);
+ mCmds[AudioProtocol::ECmdGetDeviceInfo - AudioProtocol::ECmdStart] =
+ new CmdGetDeviceInfo(socket);
}
RemoteAudio::~RemoteAudio()
@@ -104,7 +107,6 @@
if (!AudioProtocol::handleReplyHeader(mSocket, data, id)) {
return false;
}
- AudioParam* param = NULL;
CommandHandler* handler = NULL;
if (id == AudioProtocol::ECmdDownload) {
handler = reinterpret_cast<CommandHandler*>(mDownloadHandler.get());
@@ -112,6 +114,11 @@
handler = reinterpret_cast<CommandHandler*>(mPlaybackHandler.get());
} else if (id == AudioProtocol::ECmdStartRecording) {
handler = reinterpret_cast<CommandHandler*>(mRecordingHandler.get());
+ } else if (id == AudioProtocol::ECmdGetDeviceInfo) {
+ handler = reinterpret_cast<CommandHandler*>(mDeviceInfoHandler.get());
+ }
+ AudioParam* param = NULL;
+ if (handler != NULL) {
param = &(handler->getParam());
}
bool result = mCmds[id - AudioProtocol::ECmdStart]->handleReply(data, param);
@@ -148,6 +155,7 @@
bool RemoteAudio::waitForCompletion(android::sp<android::MessageHandler>& command, int timeInMSec)
{
+ LOGV("waitForCompletion %d", timeInMSec);
return toCommandHandler(command)->timedWait(timeInMSec);
}
@@ -190,12 +198,13 @@
CommandHandler* handler = reinterpret_cast<CommandHandler*>(mDownloadHandler.get());
id = mDownloadId;
mDownloadId++;
+ handler->mStateLock.lock();
handler->getParam().mId = id;
handler->getParam().mBuffer = buffer;
- sendCommand(mDownloadHandler);
- handler->mStateLock.lock();
handler->mNotifyOnReply = true;
handler->mStateLock.unlock();
+ sendCommand(mDownloadHandler);
+
// assume 1Mbps ==> 1000 bits per msec ==> 125 bytes per msec
int maxWaitTime = CLIENT_WAIT_TIMEOUT_MSEC + buffer->getSize() / 125;
// client blocked until reply comes from DUT
@@ -299,6 +308,23 @@
doStop(mRecordingHandler, AudioProtocol::ECmdStopRecording);
}
+bool RemoteAudio::getDeviceInfo(android::String8& data)
+{
+ CommandHandler* handler = reinterpret_cast<CommandHandler*>(mDeviceInfoHandler.get());
+ handler->mStateLock.lock();
+ handler->mNotifyOnReply = true;
+ handler->getParam().mExtra = &data;
+ handler->mStateLock.unlock();
+ sendCommand(mDeviceInfoHandler);
+
+ // client blocked until reply comes from DUT
+ if (!waitForCompletion(mDeviceInfoHandler, CLIENT_WAIT_TIMEOUT_MSEC)) {
+ LOGE("timeout");
+ return false;
+ }
+ return handler->mResult;
+}
+
/** should be called before RemoteAudio is destroyed */
void RemoteAudio::release()
{
@@ -322,11 +348,13 @@
case AudioProtocol::ECmdStopPlayback:
case AudioProtocol::ECmdStartRecording:
case AudioProtocol::ECmdStopRecording:
+ case AudioProtocol::ECmdGetDeviceInfo:
{
mResult = (mThread.mCmds[message.what - AudioProtocol::ECmdStart]) \
->sendCommand(mParam);
- // no post for download. Client blocked until reply comes with time-out
- if (message.what != AudioProtocol::ECmdDownload) {
+ // no post for download and getdeviceinfo. Client blocked until reply comes with time-out
+ if ((message.what != AudioProtocol::ECmdDownload) &&
+ (message.what != AudioProtocol::ECmdGetDeviceInfo) ) {
mClientWait.post();
}
diff --git a/suite/audio_quality/lib/src/task/TaskBatch.cpp b/suite/audio_quality/lib/src/task/TaskBatch.cpp
index f8c77fe..70499fc 100644
--- a/suite/audio_quality/lib/src/task/TaskBatch.cpp
+++ b/suite/audio_quality/lib/src/task/TaskBatch.cpp
@@ -58,10 +58,10 @@
if (!findStringAttribute(STR_NAME, name) || !findStringAttribute(STR_VERSION, version)) {
LOGW("TaskBatch::run no name or version information");
}
- Report::Instance()->printf("= Test batch %s version %s started. =", name.string(),
+ MSG("= Test batch %s version %s started. =", name.string(),
version.string());
bool result = TaskGeneric::forEachChild(runAlways, NULL);
- Report::Instance()->printf("= Finished Test batch =");
+ MSG("= Finished Test batch =");
return TaskGeneric::EResultOK;
}
diff --git a/suite/audio_quality/lib/src/task/TaskCase.cpp b/suite/audio_quality/lib/src/task/TaskCase.cpp
index 9cbc6c8..c92e71b 100644
--- a/suite/audio_quality/lib/src/task/TaskCase.cpp
+++ b/suite/audio_quality/lib/src/task/TaskCase.cpp
@@ -300,8 +300,7 @@
if (!findStringAttribute(STR_NAME, name) || !findStringAttribute(STR_VERSION, version)) {
LOGW("TaskCase::run no name or version information");
}
- Report::Instance()->printf("== Test case %s version %s started ==", name.string(),
- version.string());
+ MSG("== Test case %s version %s started ==", name.string(), version.string());
std::list<TaskGeneric*>::iterator i = getChildren().begin();
std::list<TaskGeneric*>::iterator end = getChildren().end();
TaskGeneric* setup = *i;
@@ -316,12 +315,12 @@
TaskGeneric::ExecutionResult result = setup->run();
TaskGeneric::ExecutionResult resultAction(TaskGeneric::EResultOK);
if (result != TaskGeneric::EResultOK) {
- Report::Instance()->printf("== setup stage failed %d ==", result);
+ MSG("== setup stage failed %d ==", result);
testPassed = false;
} else {
resultAction = action->run();
if (resultAction != TaskGeneric::EResultPass) {
- Report::Instance()->printf("== action stage failed %d ==", resultAction);
+ MSG("== action stage failed %d ==", resultAction);
testPassed = false;
}
// save done even for failure if possible
@@ -329,19 +328,19 @@
result = save->run();
}
if (result != TaskGeneric::EResultOK) {
- Report::Instance()->printf("== save stage failed %d ==", result);
+ MSG("== save stage failed %d ==", result);
testPassed = false;
}
}
if (testPassed) {
result = TaskGeneric::EResultPass;
- Report::Instance()->printf("== Case %s Passed ==", name.string());
+ MSG("== Case %s Passed ==", name.string());
Report::Instance()->addCasePassed(name);
} else {
if (resultAction != TaskGeneric::EResultOK) {
result = resultAction;
}
- Report::Instance()->printf("== Case %s Failed ==", name.string());
+ MSG("== Case %s Failed ==", name.string());
Report::Instance()->addCaseFailed(name);
}
// release remote audio for other cases to use
diff --git a/suite/audio_quality/lib/src/task/TaskSave.cpp b/suite/audio_quality/lib/src/task/TaskSave.cpp
index d62b846..8938c1e 100644
--- a/suite/audio_quality/lib/src/task/TaskSave.cpp
+++ b/suite/audio_quality/lib/src/task/TaskSave.cpp
@@ -110,7 +110,7 @@
LOGE("alloc failed");
return false;
}
- Report::Instance()->printf("=== Values stored ===");
+ MSG("=== Values stored ===");
for (size_t i = 0; i < listp->size(); i++) {
UniquePtr<std::list<TaskCase::ValuePair> > values(
getTestCase()->findAllValues((*listp)[i]));
@@ -123,11 +123,9 @@
std::list<TaskCase::ValuePair>::iterator end = values->end();
for (; it != end; it++) {
if (it->second.getType() == TaskCase::Value::ETypeDouble) {
- Report::Instance()->printf(" %s: %f", it->first.string(),
- it->second.getDouble());
+ MSG(" %s: %f", it->first.string(), it->second.getDouble());
} else { //64bit int
- Report::Instance()->printf(" %s: %lld", it->first.string(),
- it->second.getInt64());
+ MSG(" %s: %lld", it->first.string(), it->second.getInt64());
}
}
}
diff --git a/suite/audio_quality/test/ClientInterfaceTest.cpp b/suite/audio_quality/test/ClientInterfaceTest.cpp
index b72be9b..88e502b 100644
--- a/suite/audio_quality/test/ClientInterfaceTest.cpp
+++ b/suite/audio_quality/test/ClientInterfaceTest.cpp
@@ -49,6 +49,15 @@
// all done in SetUp
}
+TEST_F(ClientInterfaceTest, getDeviceInfoTest) {
+ ClientImpl* client = reinterpret_cast<ClientImpl*>(mClient);
+ android::sp<RemoteAudio>& audio(client->getAudio());
+ android::String8 info;
+
+ ASSERT_TRUE(audio->getDeviceInfo(info));
+ LOGD("device info %s", info.string());
+}
+
TEST_F(ClientInterfaceTest, PlayTest) {
ClientImpl* client = reinterpret_cast<ClientImpl*>(mClient);
android::sp<RemoteAudio>& audio(client->getAudio());
diff --git a/suite/audio_quality/test/ModelBuilderTest.cpp b/suite/audio_quality/test/ModelBuilderTest.cpp
index 49a0c57..c9ba154 100644
--- a/suite/audio_quality/test/ModelBuilderTest.cpp
+++ b/suite/audio_quality/test/ModelBuilderTest.cpp
@@ -41,7 +41,7 @@
}
TEST_F(ModelBuilderTest, ParsingBatchTest) {
- android::String8 xmlFile("test_description/all.xml");
+ android::String8 xmlFile("test_description/all_playback.xml");
TaskGeneric* testBatch = mModelBuilder.parseTestDescriptionXml(xmlFile);
ASSERT_TRUE(testBatch != NULL);
//TODO verify TestCase
@@ -49,7 +49,7 @@
}
TEST_F(ModelBuilderTest, CaseOnlyTest) {
- android::String8 xmlFile("test_description/all.xml");
+ android::String8 xmlFile("test_description/all_playback.xml");
TaskGeneric* task = mModelBuilder.parseTestDescriptionXml(xmlFile, true);
ASSERT_TRUE(task == NULL);
diff --git a/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp b/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp
index 7d77a9b..d428c17 100644
--- a/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp
+++ b/suite/audio_quality/test/RemoteAudioFakeTcpTest.cpp
@@ -307,3 +307,24 @@
mTestSocket.setReadExpectation((char*)stopReply, sizeof(stopReply));
mRemoteAudio->stopRecording();
}
+
+TEST_F(RemoteAudioFakeTcpTest, getDeviceInfoTest) {
+ uint32_t prepareSend[] = {
+ U32_ENDIAN_SWAP(AudioProtocol::ECmdGetDeviceInfo),
+ U32_ENDIAN_SWAP(0)
+ };
+ uint32_t prepareReply[] = {
+ U32_ENDIAN_SWAP((AudioProtocol::ECmdGetDeviceInfo & 0xffff) | 0x43210000),
+ 0,
+ U32_ENDIAN_SWAP(4),
+ U32_ENDIAN_SWAP(0x30313233)
+ };
+
+ mTestSocket.setSendExpectation((char*)prepareSend, sizeof(prepareSend));
+ // this is reply, but set expectation for reply first as it is sent after send
+ mTestSocket.setReadExpectation((char*)prepareReply, sizeof(prepareReply));
+
+ android::String8 info;
+ ASSERT_TRUE(mRemoteAudio->getDeviceInfo(info));
+ ASSERT_TRUE(info == "0123");
+}
diff --git a/suite/audio_quality/test_description/dut_speaker_calibration.xml b/suite/audio_quality/test_description/dut_speaker_calibration.xml
index f0ddf17..e0a613d 100644
--- a/suite/audio_quality/test_description/dut_speaker_calibration.xml
+++ b/suite/audio_quality/test_description/dut_speaker_calibration.xml
@@ -31,7 +31,7 @@
<sequential repeat="8" index="j">
<input device="host" id="host_in" gain="100" time="500" sync="complete" />
<!-- ------------moving average RMS min for pass, max for pass result calculated -->
- <process method="builtin:rms_mva" input="id:host_in,consti:3000,consti:8000" output="val:rms_$i_$j" />
+ <process method="builtin:rms_mva" input="id:host_in,consti:1000,consti:8000" output="val:rms_$i_$j" />
<!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
</sequential>
</sequential>
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..a5d92ee 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;
@@ -52,12 +53,27 @@
public boolean accept(AccessibilityEvent event);
}
+ private static final boolean DEBUG = false;
+
+ private static final String LOG_TAG = AccessibilityActivityTestCase.class.getSimpleName();
+
/**
* Timeout required for pending Binder calls or event processing to
* complete.
*/
public static final long TIMEOUT_ASYNC_PROCESSING = 5000;
+ /**
+ * The timeout after the last accessibility event to consider the device idle.
+ */
+ public static final long TIMEOUT_ACCESSIBILITY_STATE_IDLE = 100;
+
+ /**
+ * Instance for detecting the next accessibility event.
+ */
+ private static final NextAccessibilityEventWatcher sNextEventWatcher =
+ new NextAccessibilityEventWatcher();
+
private static AccessibilityInteractionBridge sInteractionBridge;
/**
@@ -70,6 +86,7 @@
@Override
public void setUp() throws Exception {
super.setUp();
+ waitForAccessibilityStateIdle();
startActivityAndWaitForFirstEvent();
}
@@ -123,6 +140,39 @@
}
/**
+ * Waits for idle accessibility state.
+ */
+ private void waitForAccessibilityStateIdle() throws Exception {
+ AccessibilityEvent awaitedEvent = null;
+ try {
+ do {
+ awaitedEvent = getInteractionBridge().executeCommandAndWaitForAccessibilityEvent(
+ sNextEventWatcher, sNextEventWatcher, TIMEOUT_ACCESSIBILITY_STATE_IDLE);
+ } while (awaitedEvent != null);
+ } catch (TimeoutException te) {
+ /* success - no event within the timeout - do nothing */
+ }
+ }
+
+ /**
+ * Dummy implementation that matches every event and does nothing.
+ */
+ private static class NextAccessibilityEventWatcher implements Runnable,
+ AccessibilityEventFilter {
+ @Override
+ public boolean accept(AccessibilityEvent event) {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Watcher event: " + event);
+ }
+ return true;
+ }
+ @Override
+ public void run() {
+ /* do nothing */
+ }
+ }
+
+ /**
* This class serves as a bridge for querying the screen content.
* The bride is connected of a delegating accessibility service.
*/
@@ -165,7 +215,7 @@
/**
* Flag whether we are waiting for a specific event.
*/
- private volatile boolean mWaitingForEventDelivery;
+ private boolean mWaitingForEventDelivery;
/**
* Queue with received events.
@@ -178,9 +228,6 @@
}
public void onAccessibilityEvent(AccessibilityEvent event) {
- if (!mWaitingForEventDelivery) {
- return;
- }
synchronized (mLock) {
mLock.notifyAll();
if (mWaitingForEventDelivery) {
@@ -232,8 +279,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 +327,8 @@
/* do nothing */
}
});
- mInitialized = true;
synchronized (mLock) {
+ mInitialized = true;
mLock.notifyAll();
}
} catch (RemoteException re) {
@@ -294,8 +340,9 @@
* {@inheritDoc ServiceConnection#onServiceDisconnected(ComponentName)}
*/
public void onServiceDisconnected(ComponentName name) {
- mInitialized = false;
- /* do nothing */
+ synchronized (mLock) {
+ mInitialized = false;
+ }
}
/**
@@ -463,22 +510,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 +542,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/app/src/android/app/cts/DownloadManagerTest.java b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
index 1da6af9..d3029ea 100644
--- a/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
@@ -27,10 +27,16 @@
import android.net.Uri;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
+import android.os.SystemClock;
import android.test.AndroidTestCase;
+import android.text.format.DateUtils;
import android.webkit.cts.CtsTestServer;
+import com.google.android.collect.Sets;
+
import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -42,6 +48,9 @@
*/
private static final int MINIMUM_DOWNLOAD_BYTES = 55 * 1024 * 1024;
+ private static final long SHORT_TIMEOUT = 5 * DateUtils.SECOND_IN_MILLIS;
+ private static final long LONG_TIMEOUT = 2 * DateUtils.MINUTE_IN_MILLIS;
+
private DownloadManager mDownloadManager;
private CtsTestServer mWebServer;
@@ -61,8 +70,7 @@
}
public void testDownloadManager() throws Exception {
- DownloadCompleteReceiver receiver =
- new DownloadCompleteReceiver(2, TimeUnit.SECONDS.toMillis(3));
+ final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
try {
IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
mContext.registerReceiver(receiver, intentFilter);
@@ -76,7 +84,7 @@
assertDownloadQueryableById(goodId);
assertDownloadQueryableById(badId);
- receiver.waitForDownloadComplete();
+ receiver.waitForDownloadComplete(SHORT_TIMEOUT, goodId, badId);
assertDownloadQueryableByStatus(DownloadManager.STATUS_SUCCESSFUL);
assertDownloadQueryableByStatus(DownloadManager.STATUS_FAILED);
@@ -89,14 +97,13 @@
}
public void testMinimumDownload() throws Exception {
- DownloadCompleteReceiver receiver =
- new DownloadCompleteReceiver(1, TimeUnit.MINUTES.toMillis(2));
+ final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
try {
IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
mContext.registerReceiver(receiver, intentFilter);
long id = mDownloadManager.enqueue(new Request(getMinimumDownloadUrl()));
- receiver.waitForDownloadComplete();
+ receiver.waitForDownloadComplete(LONG_TIMEOUT, id);
ParcelFileDescriptor fileDescriptor = mDownloadManager.openDownloadedFile(id);
assertEquals(MINIMUM_DOWNLOAD_BYTES, fileDescriptor.getStatSize());
@@ -146,8 +153,7 @@
assertTrue(publicLocation.delete());
}
- DownloadCompleteReceiver receiver =
- new DownloadCompleteReceiver(3, TimeUnit.SECONDS.toMillis(5));
+ final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
try {
IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
mContext.registerReceiver(receiver, intentFilter);
@@ -168,7 +174,7 @@
int allDownloads = getTotalNumberDownloads();
assertEquals(3, allDownloads);
- receiver.waitForDownloadComplete();
+ receiver.waitForDownloadComplete(SHORT_TIMEOUT, uriId, extFileId, publicId);
assertSuccessfulDownload(uriId, uriLocation);
assertSuccessfulDownload(extFileId, extFileLocation);
@@ -198,8 +204,7 @@
assertTrue(wrongExtLocation.delete());
}
- DownloadCompleteReceiver receiver =
- new DownloadCompleteReceiver(2, TimeUnit.SECONDS.toMillis(5));
+ final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
try {
IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
mContext.registerReceiver(receiver, intentFilter);
@@ -215,7 +220,7 @@
int allDownloads = getTotalNumberDownloads();
assertEquals(2, allDownloads);
- receiver.waitForDownloadComplete();
+ receiver.waitForDownloadComplete(SHORT_TIMEOUT, noExtId, wrongExtId);
assertSuccessfulDownload(noExtId, noExtLocation);
assertSuccessfulDownload(wrongExtId, wrongExtLocation);
@@ -228,24 +233,45 @@
}
private class DownloadCompleteReceiver extends BroadcastReceiver {
+ private HashSet<Long> mCompleteIds = Sets.newHashSet();
- private final CountDownLatch mReceiveLatch;
-
- private final long waitTimeMs;
-
- public DownloadCompleteReceiver(int numDownload, long waitTimeMs) {
- this.mReceiveLatch = new CountDownLatch(numDownload);
- this.waitTimeMs = waitTimeMs;
+ public DownloadCompleteReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
- mReceiveLatch.countDown();
+ synchronized (mCompleteIds) {
+ mCompleteIds.add(intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1));
+ mCompleteIds.notifyAll();
+ }
}
- public void waitForDownloadComplete() throws InterruptedException {
- assertTrue("Make sure you have WiFi or some other connectivity for this test.",
- mReceiveLatch.await(waitTimeMs, TimeUnit.MILLISECONDS));
+ private boolean isCompleteLocked(long... ids) {
+ for (long id : ids) {
+ if (!mCompleteIds.contains(id)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void waitForDownloadComplete(long timeoutMillis, long... waitForIds)
+ throws InterruptedException {
+ if (waitForIds.length == 0) {
+ throw new IllegalArgumentException("Missing IDs to wait for");
+ }
+
+ final long startTime = SystemClock.elapsedRealtime();
+ do {
+ synchronized (mCompleteIds) {
+ mCompleteIds.wait(timeoutMillis);
+ if (isCompleteLocked(waitForIds)) return;
+ }
+ } while ((SystemClock.elapsedRealtime() - startTime) < timeoutMillis);
+
+ throw new InterruptedException("Timeout waiting for IDs " + Arrays.toString(waitForIds)
+ + "; received " + mCompleteIds.toString()
+ + ". Make sure you have WiFi or some other connectivity for this test.");
}
}
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 b316e55..46e777f 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;
import java.lang.Thread;
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/cts/NetworkInfoTest.java b/tests/tests/net/src/android/net/cts/NetworkInfoTest.java
index e53614b..4a7b4e7 100644
--- a/tests/tests/net/src/android/net/cts/NetworkInfoTest.java
+++ b/tests/tests/net/src/android/net/cts/NetworkInfoTest.java
@@ -53,7 +53,7 @@
}
private void assertNetworkInfo(NetworkInfo netInfo, String expectedTypeName) {
- assertEquals(expectedTypeName, netInfo.getTypeName());
+ assertEquals(expectedTypeName.compareToIgnoreCase(netInfo.getTypeName()), 0);
if(netInfo.isConnectedOrConnecting()) {
assertTrue(netInfo.isAvailable());
if (State.CONNECTED == netInfo.getState()) {
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..8b33359 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", "4.1.2"));
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 3a8d87f..3055e44 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 " +
@@ -84,8 +86,31 @@
"310000", // Tracfone
"46003", // China Telecom
"311230", // C SPire Wireless + Celluar South
- "310600", // Cellcom
- "31000" // Republic Wireless US
+ "310600", // Cellcom
+ "31000", // Republic Wireless US
+ // 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
@@ -99,7 +124,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
@@ -326,12 +374,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/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 277f104..e02998e 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -164,6 +164,7 @@
}
public void testOnUnhandledKeyEvent() throws Throwable {
+ requireLoadedPage();
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
@@ -191,6 +192,10 @@
assertTrue(webViewClient.hasOnScaleChangedCalled());
}
+ private void requireLoadedPage() throws Throwable {
+ mOnUiThread.loadUrlAndWaitForCompletion("about:blank");
+ }
+
private class MockWebViewClient extends WaitForLoadedClient {
private boolean mOnPageStartedCalled;
private boolean mOnPageFinishedCalled;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 0dd3934..3f7ea78 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,
@@ -1155,6 +1167,20 @@
}
public void testRequestImageRef() throws Exception, Throwable {
+ final class ImageLoaded {
+ public boolean mImageLoaded;
+
+ public void loaded() {
+ mImageLoaded = true;
+ }
+ }
+ final ImageLoaded imageLoaded = new ImageLoaded();
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ mOnUiThread.getSettings().setJavaScriptEnabled(true);
+ }
+ });
+ mOnUiThread.addJavascriptInterface(imageLoaded, "imageLoaded");
AssetManager assets = getActivity().getAssets();
Bitmap bitmap = BitmapFactory.decodeStream(assets.open(TestHtmlConstants.LARGE_IMG_URL));
int imgWidth = bitmap.getWidth();
@@ -1163,8 +1189,24 @@
startWebServer(false);
final String imgUrl = mWebServer.getAssetUrl(TestHtmlConstants.LARGE_IMG_URL);
mOnUiThread.loadDataAndWaitForCompletion(
- "<html><title>Title</title><body><img src=\"" + imgUrl
- + "\"/></body></html>", "text/html", null);
+ "<html><head><title>Title</title><style type=\"text/css\">"
+ + "#imgElement { -webkit-transform: translate3d(0,0,1); }"
+ + "#imgElement.finish { -webkit-transform: translate3d(0,0,0);"
+ + " -webkit-transition-duration: 1ms; }</style>"
+ + "<script type=\"text/javascript\">function imgLoad() {"
+ + "imgElement = document.getElementById('imgElement');"
+ + "imgElement.addEventListener('webkitTransitionEnd',"
+ + "function(e) { imageLoaded.loaded(); });"
+ + "imgElement.className = 'finish';}</script>"
+ + "</head><body><img id=\"imgElement\" src=\"" + imgUrl
+ + "\" width=\"" + imgWidth + "\" height=\"" + imgHeight
+ + "\" onLoad=\"imgLoad()\"/></body></html>", "text/html", null);
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return imageLoaded.mImageLoaded;
+ }
+ }.run();
getInstrumentation().waitForIdleSync();
final HrefCheckHandler handler = new HrefCheckHandler(mWebView.getHandler().getLooper());
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 25d13f1..7fa2d2f 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -536,6 +536,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
*/