Merge "revise Linkify.PHONE_NUMBER CTS" into jb-mr2-dev
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
index 9747ca5..43e93d3 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
@@ -16,10 +16,16 @@
package com.android.pts.util;
+import android.app.Instrumentation;
+import android.os.Bundle;
import android.util.Log;
+import java.lang.Exception;
+
public class DeviceReportLog extends ReportLog {
- private static final String TAG = "PtsReport";
+ private static final String TAG = "DevicePtsReport";
+ private static final String PTS_RESULT = "PTS_RESULT";
+ private static final int INST_STATUS_IN_PROGRESS = 2;
DeviceReportLog() {
mDepth = 4;
@@ -29,4 +35,11 @@
protected void printLog(String msg) {
Log.i(TAG, msg);
}
+
+ public void deliverReportToHost(Instrumentation instrumentation) {
+ Log.i(TAG, "deliverReportToHost");
+ Bundle output = new Bundle();
+ output.putString(PTS_RESULT, generateReport());
+ instrumentation.sendStatus(INST_STATUS_IN_PROGRESS, output);
+ }
}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DummyActivity.java
similarity index 66%
rename from tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp
rename to suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DummyActivity.java
index ed527a6..c3ceb9f 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DummyActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,16 +14,11 @@
* limitations under the License.
*/
-#include "GLTestHelper.h"
-using namespace android;
+package com.android.pts.util;
-ANativeWindow* GLTestHelper::mWindow;
+import android.app.Activity;
-ANativeWindow* GLTestHelper::getWindow() {
- return mWindow;
-}
+public class DummyActivity extends Activity {
-void GLTestHelper::setWindow(ANativeWindow* value) {
- mWindow = value;
}
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
index 0c9cdfa..a14be01 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
@@ -24,7 +24,7 @@
public class PtsActivityInstrumentationTestCase2<T extends Activity> extends
ActivityInstrumentationTestCase2<T> {
- private ReportLog mReportLog = new DeviceReportLog();
+ private DeviceReportLog mReportLog = new DeviceReportLog();
public PtsActivityInstrumentationTestCase2(Class<T> activityClass) {
super(activityClass);
@@ -36,7 +36,8 @@
@Override
protected void tearDown() throws Exception {
- mReportLog.throwReportToHost();
+ mReportLog.deliverReportToHost(getInstrumentation());
+ super.tearDown();
}
}
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
index b847df7..6da7bdc 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
@@ -17,18 +17,20 @@
package com.android.pts.util;
+import android.content.Context;
import android.test.AndroidTestCase;
-public class PtsAndroidTestCase extends AndroidTestCase {
-
- private ReportLog mReportLog = new DeviceReportLog();
-
- public ReportLog getReportLog() {
- return mReportLog;
+/**
+ * This class emulates AndroidTestCase, but internally it is ActivityInstrumentationTestCase2
+ * to access Instrumentation.
+ * DummyActivity is not supposed to be accessed.
+ */
+public class PtsAndroidTestCase extends PtsActivityInstrumentationTestCase2<DummyActivity> {
+ public PtsAndroidTestCase() {
+ super(DummyActivity.class);
}
- @Override
- protected void tearDown() throws Exception {
- mReportLog.throwReportToHost();
+ public Context getContext() {
+ return getInstrumentation().getContext();
}
}
diff --git a/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
index dd7b834..d02b260 100644
--- a/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
+++ b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
@@ -17,6 +17,7 @@
package com.android.pts.bootup;
import android.cts.util.TimeoutReq;
+import com.android.pts.util.HostReportLog;
import com.android.pts.util.MeasureRun;
import com.android.pts.util.MeasureTime;
import com.android.pts.util.ResultType;
@@ -32,27 +33,18 @@
* Measure reboot-time using adb shell reboot
*/
public class BootupTimeTest extends DeviceTestCase {
-
- private ReportLog mReport = null;
// add some delay before each reboot
final static long SLEEP_BEFORE_REBOOT_TIME = 2 * 60 * 1000L;
final static int REBOOT_TIMEOUT_MS = 10 * 60 * 1000;
- @Override
- protected void setUp() throws Exception {
- mReport = new ReportLog();
- super.setUp();
- }
-
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- mReport.throwReportToHost();
- }
-
@TimeoutReq(minutes = 30)
public void testBootupTime() throws Exception {
+ // cannot run in emulator
+ if (getDevice().getSerialNumber().startsWith("emulator-")) {
+ return;
+ }
+ HostReportLog report =
+ new HostReportLog(getDevice().getSerialNumber(), ReportLog.getClassMethodNames());
final int NUMBER_REPEAT = 5;
double[] result = MeasureTime.measure(NUMBER_REPEAT, new MeasureRun() {
@Override
@@ -67,11 +59,12 @@
rebootDevice();
}
});
- mReport.printArray("bootup time", result, ResultType.LOWER_BETTER,
+ report.printArray("bootup time", result, ResultType.LOWER_BETTER,
ResultUnit.MS);
StatResult stat = Stat.getStat(result);
- mReport.printSummary("bootup time", stat.mAverage, ResultType.LOWER_BETTER,
+ report.printSummary("bootup time", stat.mAverage, ResultType.LOWER_BETTER,
ResultUnit.MS);
+ report.deliverReportToHost();
}
private void rebootDevice() throws DeviceNotAvailableException {
diff --git a/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatLineReceiver.java b/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatLineReceiver.java
deleted file mode 100644
index cb4980c..0000000
--- a/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatLineReceiver.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.pts.ptsutil;
-
-import com.android.tradefed.device.ITestDevice;
-
-/**
- * class to handle logcat log per each line.
- * processALine is supposed to be overridden.
- */
-public class LogcatLineReceiver extends LogcatMonitor {
- public LogcatLineReceiver(ITestDevice device, String logcatFilter, long timeoutInSec) {
- super(device, logcatFilter, timeoutInSec);
- }
-
- /**
- * empty default implementation. Will be called whenever a line of log is received
- * @param line
- * @throws Exception
- */
- public void processALine(String line) throws Exception {
-
- }
-
- @Override
- public void addOutput(byte[] data, int offset, int length) {
- String lines = new String(data, offset, length);
- try {
- for (String line : lines.split("\n")) {
- processALine(line);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatMonitor.java b/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatMonitor.java
deleted file mode 100644
index adc1340..0000000
--- a/suite/pts/hostTests/ptshostutil/src/com/android/pts/ptsutil/LogcatMonitor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.pts.ptsutil;
-
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.tradefed.device.BackgroundDeviceAction;
-import com.android.tradefed.device.ITestDevice;
-
-import java.io.IOException;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * class to monitor adb logcat asynchronously.
- * Unlike tradefed's LogcatReceiver, log is accumulated to a buffer, and the log is removed after
- * reading once.
- */
-public class LogcatMonitor implements IShellOutputReceiver {
- private static final String TAG = "LogcatMonitor";
- private LinkedBlockingQueue<String> mQ = new LinkedBlockingQueue<String>();
- private boolean mRunning = false;
- private long mTimeoutInSec;
- private BackgroundDeviceAction mDeviceAction;
- // sentinel to detect EOS
- private static final String EOS = "LOGCAT_MONITOR_EOS";
- private static final String LOGCAT_CMD = "logcat -v threadtime ";
-
- public LogcatMonitor(ITestDevice device, String logcatFilter, long timeoutInSec) {
- mTimeoutInSec = timeoutInSec;
- int logStartDelay = 0;
- mDeviceAction = new BackgroundDeviceAction(LOGCAT_CMD + logcatFilter, TAG, device,
- this, logStartDelay);
- }
-
- /** start monitoring log */
- public void start() {
- if (mRunning) {
- return;
- }
- clear();
- mDeviceAction.start();
- mRunning = true;
- }
-
- /** stop monitoring */
- public void stop() {
- mDeviceAction.cancel();
- mRunning = false;
- }
-
- /** clear all stored logs */
- public void clear() {
- mQ.clear();
- }
-
- /**
- * read a line of log. If there is no data stored, it can wait until
- * the timeout specified in the constructor.
- * @return null for time-out. Otherwise, a line of log is returned.
- * @throws IOException for EOS (logcat terminated for whatever reason)
- * @throws InterruptedException
- */
- public String getALine() throws IOException, InterruptedException {
- String line = mQ.poll(mTimeoutInSec, TimeUnit.SECONDS);
- if (line == EOS) {
- throw new IOException();
- }
- return line;
- }
-
- public boolean dataAvailable() {
- return !mQ.isEmpty();
- }
-
- @Override
- public void addOutput(byte[] data, int offset, int length) {
- String lines = new String(data, offset, length);
- for (String line : lines.split("\n")) {
- mQ.add(line);
- }
- }
-
- @Override
- public void flush() {
- mQ.add(EOS);
- mRunning = false;
- }
-
- @Override
- public boolean isCancelled() {
- return !mRunning;
- }
-}
diff --git a/suite/pts/hostTests/ptshostutil/src/com/android/pts/util/HostReportLog.java b/suite/pts/hostTests/ptshostutil/src/com/android/pts/util/HostReportLog.java
new file mode 100644
index 0000000..49f24fe
--- /dev/null
+++ b/suite/pts/hostTests/ptshostutil/src/com/android/pts/util/HostReportLog.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.pts.util;
+
+import com.android.cts.tradefed.result.PtsHostStore;
+
+
+/**
+ * ReportLog for host tests
+ * Note that setTestInfo should be set before throwing report
+ */
+public class HostReportLog extends ReportLog {
+ private String mDeviceSerial;
+ private String mClassMethodName;
+
+ /**
+ * @param deviceSerial serial number of the device
+ * @param classMethodName class name and method name of the test in class#method format.
+ * Note that ReportLog.getClassMethodNames() provide this.
+ */
+ public HostReportLog(String deviceSerial, String classMethodName) {
+ mDeviceSerial = deviceSerial;
+ mClassMethodName = classMethodName;
+ }
+
+ public void deliverReportToHost() {
+ PtsHostStore.storePtsResult(mDeviceSerial, mClassMethodName, generateReport());
+ }
+}
diff --git a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
index 056e0f4..55e9b40 100644
--- a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
+++ b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
@@ -17,6 +17,7 @@
package com.android.pts.uihost;
import com.android.cts.tradefed.build.CtsBuildHelper;
+import com.android.pts.util.HostReportLog;
import com.android.pts.util.MeasureRun;
import com.android.pts.util.MeasureTime;
import com.android.pts.util.ResultType;
@@ -38,7 +39,6 @@
public class InstallTimeTest extends DeviceTestCase implements IBuildReceiver {
private CtsBuildHelper mBuild;
private ITestDevice mDevice;
- private ReportLog mReport = null;
static final String PACKAGE = "com.replica.replicaisland";
static final String APK = "com.replica.replicaisland.apk";
@@ -51,19 +51,19 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mReport = new ReportLog();
mDevice = getDevice();
}
@Override
protected void tearDown() throws Exception {
- super.tearDown();
mDevice.uninstallPackage(PACKAGE);
- mReport.throwReportToHost();
+ super.tearDown();
}
public void testInstallTime() throws Exception {
+ HostReportLog report =
+ new HostReportLog(mDevice.getSerialNumber(), ReportLog.getClassMethodNames());
final int NUMBER_REPEAT = 10;
final CtsBuildHelper build = mBuild;
final ITestDevice device = mDevice;
@@ -78,11 +78,12 @@
device.installPackage(app, false);
}
});
- mReport.printArray("install time", result, ResultType.LOWER_BETTER,
+ report.printArray("install time", result, ResultType.LOWER_BETTER,
ResultUnit.MS);
StatResult stat = Stat.getStat(result);
- mReport.printSummary("install time", stat.mAverage, ResultType.LOWER_BETTER,
+ report.printSummary("install time", stat.mAverage, ResultType.LOWER_BETTER,
ResultUnit.MS);
+ report.deliverReportToHost();
}
}
diff --git a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/TaskSwitchingTest.java b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/TaskSwitchingTest.java
index 49d14a3..f1eb80a 100644
--- a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/TaskSwitchingTest.java
+++ b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/TaskSwitchingTest.java
@@ -19,14 +19,14 @@
import android.cts.util.TimeoutReq;
import com.android.cts.tradefed.build.CtsBuildHelper;
+import com.android.cts.tradefed.result.PtsReportUtil;
+import com.android.cts.tradefed.result.PtsHostStore;
import com.android.ddmlib.Log;
+import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.pts.util.MeasureRun;
-import com.android.pts.util.MeasureTime;
-import com.android.pts.util.PtsException;
-import com.android.pts.util.Stat;
-import com.android.pts.util.Stat.StatResult;
+import com.android.pts.util.HostReportLog;
+import com.android.pts.util.ReportLog;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
@@ -40,6 +40,7 @@
import java.io.File;
import java.util.Map;
+
/**
* Measure time to taskswitching between two Apps: A & B
* Actual test is done in device, but this host side code installs all necessary APKs
@@ -50,6 +51,7 @@
private final static String CTS_RUNNER = "android.test.InstrumentationCtsTestRunner";
private CtsBuildHelper mBuild;
private ITestDevice mDevice;
+ private String mPtsReport = null;
static final String[] PACKAGES = {
"com.android.pts.taskswitching.control",
@@ -81,36 +83,36 @@
@Override
protected void tearDown() throws Exception {
- super.tearDown();
for (int i = 0; i < PACKAGES.length; i++) {
mDevice.uninstallPackage(PACKAGES[i]);
}
+ super.tearDown();
}
@TimeoutReq(minutes = 30)
public void testTaskswitching() throws Exception {
+ HostReportLog report =
+ new HostReportLog(mDevice.getSerialNumber(), ReportLog.getClassMethodNames());
RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(PACKAGES[0], CTS_RUNNER,
mDevice.getIDevice());
- CollectingTestListener listener = new CollectingTestListener();
+ LocalListener listener = new LocalListener();
mDevice.runInstrumentationTests(testRunner, listener);
TestRunResult result = listener.getCurrentRunResults();
if (result.isRunFailure()) {
fail(result.getRunFailureMessage());
}
- Map<TestIdentifier, TestResult> details = result.getTestResults();
- final String expectedException = "com.android.pts.util.PtsException";
- for (Map.Entry<TestIdentifier, TestResult> entry : details.entrySet()) {
- TestResult res = entry.getValue();
- String stackTrace = res.getStackTrace();
- if (stackTrace != null) {
- if (stackTrace.startsWith(expectedException)) {
- String[] lines = stackTrace.split("[\r\n]+");
- String msg = lines[0].substring(expectedException.length() + 1).trim();
- throw new PtsException(msg);
- }
- }
- }
- fail("no performance data");
+ assertNotNull("no performance data", mPtsReport);
+ PtsHostStore.storePtsResult(mDevice.getSerialNumber(),
+ ReportLog.getClassMethodNames(), mPtsReport);
+
}
+ public class LocalListener extends CollectingTestListener {
+ @Override
+ public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
+ // necessary as testMetrics passed from CollectingTestListerner is empty
+ mPtsReport = PtsReportUtil.getPtsResultFromMetrics(testMetrics);
+ super.testEnded(test, testMetrics);
+ }
+ }
}
diff --git a/suite/pts/lib/commonutil/Android.mk b/suite/pts/lib/commonutil/Android.mk
index 152f862..73df09b 100644
--- a/suite/pts/lib/commonutil/Android.mk
+++ b/suite/pts/lib/commonutil/Android.mk
@@ -28,7 +28,7 @@
include $(CLEAR_VARS)
-# only TmeoutReq annotation used from the libs/util, so add it here
+# only TimeoutReq annotation used from the libs/util, so add it here
LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
../../../../libs/util/src/android/cts/util/TimeoutReq.java
diff --git a/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
index 8a5e624..63f5589 100644
--- a/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
@@ -115,9 +115,10 @@
LOG_ELEM_SEPARATOR + unit.getXmlString() + LOG_ELEM_SEPARATOR + value;
}
- public void throwReportToHost() throws PtsException {
+ protected String generateReport() {
if ((mSummary == null) && mMessages.isEmpty()) {
- return;
+ // just return empty string
+ return "";
}
StringBuilder builder = new StringBuilder();
builder.append(mSummary);
@@ -132,7 +133,7 @@
}
mSummary = null;
mMessages.clear();
- throw new PtsException(builder.toString());
+ return builder.toString();
}
/**
@@ -177,7 +178,7 @@
}
/**
- * get classname.methodname from call stack of the current thread
+ * get classname#methodname from call stack of the current thread
*/
public static String getClassMethodNames() {
return getClassMethodNames(mDepth, false);
diff --git a/suite/pts/utils/grapher.py b/suite/pts/utils/grapher.py
index e6dfe05..e326612 100755
--- a/suite/pts/utils/grapher.py
+++ b/suite/pts/utils/grapher.py
@@ -66,7 +66,6 @@
name = r['device']
lbl = name + ' (%s)'%score
clr = colors.get(name, "#%06X" % (hash(name) % 0xFFFFFF))
- print clr
# Plot the workload vs the values
ax.plot(x, y, 'o-', label=lbl, color=clr)
# Add a legend
diff --git a/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
index ff6d15d..7449895 100644
--- a/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
@@ -18,7 +18,8 @@
import android.media.MediaDrm;
import android.media.MediaDrm.ProvisionRequest;
-import android.media.MediaDrm.LicenseRequest;
+import android.media.MediaDrm.KeyRequest;
+import android.media.MediaDrm.CryptoSession;
import android.media.MediaDrmException;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -73,7 +74,7 @@
MediaDrm md = new MediaDrm(mockScheme);
md.setPropertyString("test-string", "test-value");
- assertTrue(md.getPropertyString("test-string").equals("test-value"));
+ assertTrue(md.getPropertyString("test-string").equals("test-value"));
}
public void testByteArrayProperties() throws Exception {
@@ -194,7 +195,7 @@
assertTrue(gotException);
}
- public void testGetLicenseRequest() throws Exception {
+ public void testGetKeyRequest() throws Exception {
if (!isMockPluginInstalled()) {
return;
}
@@ -214,21 +215,21 @@
optionalParameters.put("param2", "value2");
String mimeType = "video/iso.segment";
- LicenseRequest request = md.getLicenseRequest(sessionId, initData, mimeType,
- MediaDrm.MEDIA_DRM_LICENSE_TYPE_STREAMING,
+ KeyRequest request = md.getKeyRequest(sessionId, initData, mimeType,
+ MediaDrm.MEDIA_DRM_KEY_TYPE_STREAMING,
optionalParameters);
assertTrue(Arrays.equals(request.data, testRequest));
assertTrue(request.defaultUrl.equals(testDefaultUrl));
assertTrue(Arrays.equals(initData, md.getPropertyByteArray("mock-initdata")));
assertTrue(mimeType.equals(md.getPropertyString("mock-mimetype")));
- assertTrue(md.getPropertyString("mock-licensetype").equals("1"));
+ assertTrue(md.getPropertyString("mock-keytype").equals("1"));
assertTrue(md.getPropertyString("mock-optparams").equals("{param1,value1},{param2,value2}"));
md.closeSession(sessionId);
}
- public void testGetLicenseRequestNoOptionalParameters() throws Exception {
+ public void testGetKeyRequestNoOptionalParameters() throws Exception {
if (!isMockPluginInstalled()) {
return;
}
@@ -245,20 +246,20 @@
byte[] initData = {0x0a, 0x0b, 0x0c, 0x0d};
String mimeType = "video/iso.segment";
- LicenseRequest request = md.getLicenseRequest(sessionId, initData, mimeType,
- MediaDrm.MEDIA_DRM_LICENSE_TYPE_STREAMING,
+ KeyRequest request = md.getKeyRequest(sessionId, initData, mimeType,
+ MediaDrm.MEDIA_DRM_KEY_TYPE_STREAMING,
null);
assertTrue(Arrays.equals(request.data, testRequest));
assertTrue(request.defaultUrl.equals(testDefaultUrl));
assertTrue(Arrays.equals(initData, md.getPropertyByteArray("mock-initdata")));
assertTrue(mimeType.equals(md.getPropertyString("mock-mimetype")));
- assertTrue(md.getPropertyString("mock-licensetype").equals("1"));
+ assertTrue(md.getPropertyString("mock-keytype").equals("1"));
md.closeSession(sessionId);
}
- public void testProvideLicenseResponse() throws Exception {
+ public void testProvideKeyResponse() throws Exception {
if (!isMockPluginInstalled()) {
return;
}
@@ -269,31 +270,52 @@
// Set up mock expected responses using properties
byte testResponse[] = {0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20};
- md.provideLicenseResponse(sessionId, testResponse);
+ md.provideKeyResponse(sessionId, testResponse);
assertTrue(Arrays.equals(testResponse, md.getPropertyByteArray("mock-response")));
md.closeSession(sessionId);
}
- public void testRemoveLicense() throws Exception {
+ public void testRemoveKeys() throws Exception {
if (!isMockPluginInstalled()) {
return;
}
MediaDrm md = new MediaDrm(mockScheme);
byte[] sessionId = md.openSession();
- md.removeLicense(sessionId);
+
+ byte testResponse[] = {0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20};
+ byte[] keySetId = md.provideKeyResponse(sessionId, testResponse);
+ md.closeSession(sessionId);
+
+ md.removeKeys(keySetId);
+ }
+
+ public void testRestoreKeys() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+ byte[] sessionId = md.openSession();
+
+ byte testResponse[] = {0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20};
+ byte[] keySetId = md.provideKeyResponse(sessionId, testResponse);
+ md.closeSession(sessionId);
+
+ sessionId = md.openSession();
+ md.restoreKeys(sessionId, keySetId);
md.closeSession(sessionId);
}
- public void testQueryLicenseStatus() throws Exception {
+ public void testQueryKeyStatus() throws Exception {
if (!isMockPluginInstalled()) {
return;
}
MediaDrm md = new MediaDrm(mockScheme);
byte[] sessionId = md.openSession();
- HashMap<String, String> infoMap = md.queryLicenseStatus(sessionId);
+ HashMap<String, String> infoMap = md.queryKeyStatus(sessionId);
// these are canned strings returned by the mock
assertTrue(infoMap.containsKey("purchaseDuration"));
@@ -355,4 +377,134 @@
md.closeSession(session3);
}
+ public void testCryptoSession() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "AES/CBC/NoPadding", "HmacSHA256");
+ assertFalse(cs == null);
+ }
+
+ public void testBadCryptoSession() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ boolean gotException = false;
+ try {
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "bad", "bad");
+ } catch (IllegalArgumentException e) {
+ gotException = true;
+ }
+ assertTrue(gotException);
+ }
+
+ public void testCryptoSessionEncrypt() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "AES/CBC/NoPadding", "HmacSHA256");
+ assertFalse(cs == null);
+
+ byte[] keyId = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ byte[] input = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
+ byte[] iv = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
+ byte[] expected_output = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
+
+ md.setPropertyByteArray("mock-output", expected_output);
+
+ byte[] output = cs.encrypt(keyId, input, iv);
+
+ assertTrue(Arrays.equals(keyId, md.getPropertyByteArray("mock-keyid")));
+ assertTrue(Arrays.equals(input, md.getPropertyByteArray("mock-input")));
+ assertTrue(Arrays.equals(iv, md.getPropertyByteArray("mock-iv")));
+ assertTrue(Arrays.equals(output, expected_output));
+ }
+
+ public void testCryptoSessionDecrypt() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "AES/CBC/NoPadding", "HmacSHA256");
+ assertFalse(cs == null);
+
+ byte[] keyId = {0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49};
+ byte[] input = {0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59};
+ byte[] iv = {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69};
+ byte[] expected_output = {0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79};
+
+ md.setPropertyByteArray("mock-output", expected_output);
+
+ byte[] output = cs.decrypt(keyId, input, iv);
+
+ assertTrue(Arrays.equals(keyId, md.getPropertyByteArray("mock-keyid")));
+ assertTrue(Arrays.equals(input, md.getPropertyByteArray("mock-input")));
+ assertTrue(Arrays.equals(iv, md.getPropertyByteArray("mock-iv")));
+ assertTrue(Arrays.equals(output, expected_output));
+ }
+
+ public void testCryptoSessionSign() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "AES/CBC/NoPadding", "HmacSHA256");
+ assertFalse(cs == null);
+
+ byte[] keyId = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ byte[] message = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
+ byte[] expected_signature = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
+
+ md.setPropertyByteArray("mock-signature", expected_signature);
+
+ byte[] signature = cs.sign(keyId, message);
+
+ assertTrue(Arrays.equals(keyId, md.getPropertyByteArray("mock-keyid")));
+ assertTrue(Arrays.equals(message, md.getPropertyByteArray("mock-message")));
+ assertTrue(Arrays.equals(signature, expected_signature));
+ }
+
+ public void testCryptoSessionVerify() throws Exception {
+ if (!isMockPluginInstalled()) {
+ return;
+ }
+
+ MediaDrm md = new MediaDrm(mockScheme);
+
+ byte[] sessionId = md.openSession();
+ CryptoSession cs = md.getCryptoSession(sessionId, "AES/CBC/NoPadding", "HmacSHA256");
+ assertFalse(cs == null);
+
+ byte[] keyId = {0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49};
+ byte[] message = {0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59};
+ byte[] signature = {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69};
+
+ md.setPropertyString("mock-match", "1");
+ assertTrue(cs.verify(keyId, message, signature));
+
+ assertTrue(Arrays.equals(keyId, md.getPropertyByteArray("mock-keyid")));
+ assertTrue(Arrays.equals(message, md.getPropertyByteArray("mock-message")));
+ assertTrue(Arrays.equals(signature, md.getPropertyByteArray("mock-signature")));
+
+ md.setPropertyString("mock-match", "0");
+ assertFalse(cs.verify(keyId, message, signature));
+ }
}
diff --git a/tests/tests/nativeopengl/AndroidManifest.xml b/tests/tests/nativeopengl/AndroidManifest.xml
index 52157b4..72d87ac 100644
--- a/tests/tests/nativeopengl/AndroidManifest.xml
+++ b/tests/tests/nativeopengl/AndroidManifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/tests/tests/nativeopengl/libnativeopengltests/Android.mk b/tests/tests/nativeopengl/libnativeopengltests/Android.mk
index b6ca1cb..c9e10c4 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/Android.mk
+++ b/tests/tests/nativeopengl/libnativeopengltests/Android.mk
@@ -16,7 +16,7 @@
# This is the shared library included by the JNI test app.
#
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH:= $(call my-dir)/../standalone/jni/
include $(CLEAR_VARS)
@@ -34,14 +34,13 @@
LOCAL_SRC_FILES := \
register.cpp \
GLTestHelper.cpp \
- android_test_wrappedgtest_WrappedGTestActivity.cpp \
- com_android_opengl_cts_GLTestActivity.cpp \
tests/GLTest_test.cpp
LOCAL_SHARED_LIBRARIES := libEGL \
libGLESv2 \
libstlport \
- libandroid
+ libandroid \
+ liblog
LOCAL_STATIC_LIBRARIES := libgtest
diff --git a/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp b/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp
deleted file mode 100644
index 5e1c30e..0000000
--- a/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 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.
- */
-#include <android/log.h>
-#include <gtest/gtest.h>
-#include <jni.h>
-
-using namespace testing;
-
-class GTestListener : public EmptyTestEventListener {
-public:
- GTestListener(JNIEnv *env, jobject activity)
- : mActivity(activity), mEnv(env) {
-
- jclass clazz = env->FindClass(
- "android/test/wrappedgtest/WrappedGTestActivity");
- mSendStatusID = env->GetMethodID(clazz, "sendStatus",
- "(Ljava/lang/String;)V");
- mMessageBuffer = new char[2048];
- }
-
- ~GTestListener() {
- delete[] mMessageBuffer;
- }
-
-private:
- jobject mActivity;
- JNIEnv * mEnv;
- jmethodID mSendStatusID;
- char * mMessageBuffer;
-
- virtual void OnTestIterationStart(const UnitTest& unit_test,
- int iteration) {
- snprintf(mMessageBuffer, sizeof(char) * 2048,
- "[==========] Running %i tests from %i test cases.",
- unit_test.test_to_run_count(),
- unit_test.test_case_to_run_count());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestStart(const TestInfo& test_info) {
- snprintf(mMessageBuffer, sizeof(char) * 2048, "[ RUN ] %s.%s",
- test_info.test_case_name(), test_info.name());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestPartResult(const TestPartResult& result) {
- if (result.type() == TestPartResult::kSuccess) {
- return;
- }
-
- snprintf(mMessageBuffer, sizeof(char) * 2048, "%s:%i: Failure\n%s",
- result.file_name(), result.line_number(), result.message());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestEnd(const TestInfo& test_info) {
- const char * result = test_info.result()->Passed() ?
- "[ OK ] " : "[ FAILED ] ";
-
- snprintf(mMessageBuffer, sizeof(char) * 2048, "%s%s.%s (%lli ms)",
- result, test_info.test_case_name(), test_info.name(),
- test_info.result()->elapsed_time());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
- snprintf(mMessageBuffer, sizeof(char) * 2048,
- "[==========] %i tests from %i test cases ran. (%lli ms total)",
- unit_test.test_to_run_count(),
- unit_test.test_case_to_run_count(), unit_test.elapsed_time());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-};
-
-static jboolean WrappedGTestActivity_runTests(JNIEnv *env, jobject obj,
- jobject activity) {
- // init gtest with no args
- int argc = 0;
- InitGoogleTest(&argc, (char**)NULL);
-
- // delete the default listener
- TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
- delete listeners.Release(listeners.default_result_printer());
-
- // add custom listener
- GTestListener * listener = new GTestListener(env, activity);
- listeners.Append(listener);
-
- // run tests
- int result = RUN_ALL_TESTS();
-
- delete listener;
- return result;
-};
-
-static JNINativeMethod methods[] = {
- // name, signature, function
- { "runTests", "(Landroid/test/wrappedgtest/WrappedGTestActivity;)I", (void*)WrappedGTestActivity_runTests },
-};
-
-int register_WrappedGTestActivity(JNIEnv *env) {
- return env->RegisterNatives(
- env->FindClass("android/test/wrappedgtest/WrappedGTestActivity"),
- methods, sizeof(methods) / sizeof(JNINativeMethod));
-};
diff --git a/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp b/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp
deleted file mode 100644
index 8544f2a..0000000
--- a/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include <gtest/gtest.h>
-#include <jni.h>
-
-#include "GLTestHelper.h"
-#include <android/native_window_jni.h>
-
-using namespace android;
-
-static void GLTestActivity_setSurface(JNIEnv *env, jobject obj,
- jobject surface) {
- ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
- GLTestHelper::setWindow(window);
-};
-
-static JNINativeMethod methods[] = {
- // name, signature, function
- { "setSurface", "(Landroid/view/Surface;)V", (void*)GLTestActivity_setSurface },
-};
-
-int register_GLTestActivity(JNIEnv *env) {
- return env->RegisterNatives(
- env->FindClass("com/android/opengl/cts/GLTestActivity"),
- methods, sizeof(methods) / sizeof(JNINativeMethod));
-};
diff --git a/tests/tests/nativeopengl/standalone/AndroidManifest.xml b/tests/tests/nativeopengl/standalone/AndroidManifest.xml
new file mode 100644
index 0000000..a82e42a
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.gltest"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="15" />
+
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+
+ <application>
+ <activity android:name=".GLTestActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/tests/tests/nativeopengl/standalone/jni/Android.mk b/tests/tests/nativeopengl/standalone/jni/Android.mk
new file mode 100644
index 0000000..c23a1df
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/Android.mk
@@ -0,0 +1,48 @@
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+MY_LOCAL_PATH := $(call my-dir)
+MY_GTEST_PATH := $(MY_LOCAL_PATH)/../../../../../../external/gtest
+
+# gtest
+
+LOCAL_PATH := $(MY_GTEST_PATH)
+
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_MODULE := libgtest
+LOCAL_C_INCLUDES := $(MY_GTEST_PATH)/include
+LOCAL_SRC_FILES := src/gtest-all.cc
+
+include $(BUILD_SHARED_LIBRARY)
+
+# nativetests
+
+LOCAL_PATH := $(MY_LOCAL_PATH)
+
+include $(CLEAR_VARS)
+
+LIB_PATH := $(LOCAL_PATH)/../libs/$(TARGET_ARCH_ABI)/
+LOCAL_C_INCLUDES := $(MY_GTEST_PATH)/include
+LOCAL_LDLIBS := -L$(LIB_PATH) -landroid -lEGL -lGLESv2 -llog -lgtest
+LOCAL_MODULE := nativeopengltests
+LOCAL_SRC_FILES := GLTestHelper.cpp \
+ register.cpp \
+ tests/GLTest_test.cpp
+
+LOCAL_SHARE_LIBRARIES := libgtest
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/nativeopengl/standalone/jni/Application.mk b/tests/tests/nativeopengl/standalone/jni/Application.mk
new file mode 100644
index 0000000..76d05a7
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/Application.mk
@@ -0,0 +1,16 @@
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+APP_STL := stlport_shared
diff --git a/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp
new file mode 100644
index 0000000..d1f29d5
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "GLTest"
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+#include <android/log.h>
+#include <android/native_window.h>
+#include <GLTestHelper.h>
+
+// this listener is used to forward the subset of
+// gtest output needed to generate CTS results
+class CTSGTestListener : public EmptyTestEventListener {
+public:
+ CTSGTestListener(JNIEnv *env, jobject activity)
+ : mActivity(activity), mEnv(env) {
+
+ jclass clazz = env->FindClass(
+ "android/test/wrappedgtest/WrappedGTestActivity");
+ mSendStatusID = env->GetMethodID(clazz, "sendStatus",
+ "(Ljava/lang/String;)V");
+ mMessageBuffer = new char[2048];
+ }
+
+ ~CTSGTestListener() {
+ delete[] mMessageBuffer;
+ }
+
+private:
+ jobject mActivity;
+ JNIEnv * mEnv;
+ jmethodID mSendStatusID;
+ char * mMessageBuffer;
+
+ virtual void OnTestIterationStart(const UnitTest& unit_test,
+ int iteration) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048,
+ "[==========] Running %i tests from %i test cases.",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestStart(const TestInfo& test_info) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "[ RUN ] %s.%s",
+ test_info.test_case_name(), test_info.name());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestPartResult(const TestPartResult& result) {
+ if (result.type() == TestPartResult::kSuccess) {
+ return;
+ }
+
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "%s:%i: Failure\n%s",
+ result.file_name(), result.line_number(), result.message());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestEnd(const TestInfo& test_info) {
+ const char * result = test_info.result()->Passed() ?
+ "[ OK ] " : "[ FAILED ] ";
+
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "%s%s.%s (%lli ms)",
+ result, test_info.test_case_name(), test_info.name(),
+ test_info.result()->elapsed_time());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048,
+ "[==========] %i tests from %i test cases ran. (%lli ms total)",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count(), unit_test.elapsed_time());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+};
+
+// this listener is similar to the default gtest listener
+// but it outputs the results to the log instead of stdout
+class LogGTestListener : public EmptyTestEventListener {
+
+private:
+ virtual void OnTestIterationStart(const UnitTest& unit_test,
+ int iteration) {
+ LOGI("[==========] Running %i tests from %i test cases.\n",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count());
+ }
+
+ virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) {
+ LOGI("[==========] Global test environment set-up.\n");
+ }
+
+ virtual void OnTestCaseStart(const TestCase& test_case) {
+ LOGI("[----------] %i tests from %s\n",
+ test_case.test_to_run_count(),
+ test_case.name());
+
+ }
+
+ virtual void OnTestStart(const TestInfo& test_info) {
+ LOGI("[ RUN ] %s.%s\n", test_info.test_case_name(),
+ test_info.name());
+
+ }
+
+ virtual void OnTestPartResult(const TestPartResult& result) {
+ if (result.type() == TestPartResult::kSuccess) {
+ return;
+ }
+
+ LOGI("%s:%i: Failure\n%s\n", result.file_name(), result.line_number(),
+ result.message());
+ }
+
+ virtual void OnTestEnd(const TestInfo& test_info) {
+ const char * result = test_info.result()->Passed() ?
+ "[ OK ] " : "[ FAILED ] ";
+
+ LOGI("%s%s.%s (%lli ms)\n", result, test_info.test_case_name(),
+ test_info.name(), test_info.result()->elapsed_time());
+ }
+
+
+ virtual void OnTestCaseEnd(const TestCase& test_case) {
+ LOGI("[----------] %i tests from %s (%lli ms total)\n",
+ test_case.test_to_run_count(), test_case.name(),
+ test_case.elapsed_time());
+
+ }
+
+ virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) {
+ LOGI("[==========] Global test environment tear-down.\n");
+ }
+
+ void PrintFailedTests(const UnitTest& unit_test) {
+ const int failed_test_count = unit_test.failed_test_count();
+ if (failed_test_count == 0) {
+ return;
+ }
+
+ for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+ const TestCase& test_case = *unit_test.GetTestCase(i);
+
+ if (!test_case.should_run() || test_case.failed_test_count() == 0) {
+ continue;
+ }
+
+ for (int j = 0; j < test_case.total_test_count(); ++j) {
+ const TestInfo& test_info = *test_case.GetTestInfo(j);
+ if (!test_info.should_run() || test_info.result()->Passed()) {
+ continue;
+ }
+ LOGI("[ FAILED ] %s.%s\n", test_case.name(),
+ test_info.name());
+ }
+ }
+ }
+ virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
+ LOGI("[==========] %i tests from %i test cases ran. (%lli ms total)\n",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count(), unit_test.elapsed_time());
+
+ LOGI("[ PASSED ] %i tests\n", unit_test.successful_test_count());
+
+ if(unit_test.Passed()) {
+ return;
+ }
+
+ LOGI("[ FAILED ] %i tests, listed below:\n",
+ unit_test.failed_test_count());
+
+ PrintFailedTests(unit_test);
+
+ LOGI("\n%2d FAILED TESTS\n", unit_test.failed_test_count());
+ }
+};
+
+ANativeWindow* GLTestHelper::mWindow;
+
+ANativeWindow* GLTestHelper::getWindow() {
+ return mWindow;
+}
+
+void GLTestHelper::setWindow(JNIEnv *env, jobject obj, jobject surface) {
+ mWindow = ANativeWindow_fromSurface(env, surface);
+}
+
+int GLTestHelper::runGTests(TestEventListener * listener, char * filter) {
+
+ if (filter) {
+ ::testing::GTEST_FLAG(filter) = filter;
+ }
+
+ int argc = 0;
+ InitGoogleTest(&argc, (char**)NULL);
+
+ TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
+ delete listeners.Release(listeners.default_result_printer());
+
+ listeners.Append(listener);
+ int result = RUN_ALL_TESTS();
+ return result;
+}
+
+int GLTestHelper::runTests(JNIEnv *env, jobject obj, jstring filter) {
+ LogGTestListener * listener = new LogGTestListener();
+
+ char * filter_cstr = NULL;
+
+ // set filter if there is one
+ if (filter) {
+ filter_cstr = new char[512];
+ const char * ptr = env->GetStringUTFChars(filter, NULL);
+ snprintf(filter_cstr, sizeof(char) * 512, "%s", ptr);
+ env->ReleaseStringUTFChars(filter, ptr);
+ }
+
+ int result = runGTests(listener, filter_cstr);
+
+ if (filter_cstr) {
+ delete[] filter_cstr;
+ }
+
+ delete listener;
+ return result;
+}
+
+int GLTestHelper::runTestsCTS(JNIEnv *env, jobject obj, jobject activity) {
+ CTSGTestListener * listener = new CTSGTestListener(env, activity);
+ int result = runGTests(listener, NULL);
+ delete listener;
+ return result;
+}
+
+int GLTestHelper::registerNative(JNIEnv * env) {
+
+ jclass clazz = env->FindClass("com/android/opengl/cts/GLTestActivity");
+
+ jthrowable exception = env->ExceptionOccurred();
+ // CTS class not found, assume stand-alone application
+ if (exception) {
+ env->ExceptionClear();
+
+ if (!env->IsInstanceOf(env->ExceptionOccurred(),
+ env->FindClass("java/lang/NoClassDefFoundError"))) {
+ env->Throw(exception);
+ }
+
+ //
+ JNINativeMethod standaloneMethods[] = {
+ // name, signature, function
+ { "setSurface", "(Landroid/view/Surface;)V", (void*)(GLTestHelper::setWindow) },
+ { "runTests", "(Ljava/lang/String;)V", (void*)(GLTestHelper::runTests) },
+ };
+
+ return env->RegisterNatives(
+ env->FindClass("com/android/gltest/GLTestActivity"),
+ standaloneMethods,
+ sizeof(standaloneMethods) / sizeof(JNINativeMethod));
+ }
+
+ // GLTestActivity methods
+ JNINativeMethod glTestActMethods[] = {
+ // name, signature, function
+ { "setSurface", "(Landroid/view/Surface;)V", (void*)(GLTestHelper::setWindow) },
+ };
+
+ int result = env->RegisterNatives(clazz, glTestActMethods,
+ sizeof(glTestActMethods) / sizeof(JNINativeMethod));
+
+ if (result) {
+ return result;
+ }
+
+ // WrappedGTestActivity methods
+ JNINativeMethod wrappedGTestActMethods[] = {
+ // name, signature, function
+ { "runTests", "(Landroid/test/wrappedgtest/WrappedGTestActivity;)I",
+ (void*)(GLTestHelper::runTestsCTS) },
+ };
+
+ return env->RegisterNatives(
+ env->FindClass("android/test/wrappedgtest/WrappedGTestActivity"),
+ wrappedGTestActMethods,
+ sizeof(wrappedGTestActMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
similarity index 63%
rename from tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h
rename to tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
index c0775f0..d09d2f1 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h
+++ b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,20 +17,22 @@
#ifndef ANDROID_GL_TEST_HELPER_H
#define ANDROID_GL_TEST_HELPER_H
-#include <stdint.h>
-#include <sys/types.h>
-#include <android/native_window.h>
-#include <utils/RefBase.h>
+#include <android/native_window_jni.h>
+#include <gtest/gtest.h>
-using namespace android;
+using namespace testing;
class GLTestHelper
{
private:
static ANativeWindow* mWindow;
+ static int runGTests(TestEventListener* listener, char * filter);
+ static int runTests(JNIEnv* env, jobject obj, jstring filter);
+ static int runTestsCTS(JNIEnv* env, jobject obj, jobject activity);
public:
static ANativeWindow* getWindow();
- static void setWindow(ANativeWindow* value);
+ static void setWindow(JNIEnv* env, jobject obj, jobject surface);
+ static int registerNative(JNIEnv* env);
};
diff --git a/tests/tests/nativeopengl/libnativeopengltests/register.cpp b/tests/tests/nativeopengl/standalone/jni/register.cpp
similarity index 77%
rename from tests/tests/nativeopengl/libnativeopengltests/register.cpp
rename to tests/tests/nativeopengl/standalone/jni/register.cpp
index 97a8bd4..8dd14ed 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/register.cpp
+++ b/tests/tests/nativeopengl/standalone/jni/register.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 The Android Open Source Project
+ * Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
#include <jni.h>
-#include <stdlib.h>
+#include <GLTestHelper.h>
/*
* This function is called automatically by the system when this
@@ -29,13 +29,7 @@
return JNI_ERR;
}
- extern int register_WrappedGTestActivity(JNIEnv *);
- if (register_WrappedGTestActivity(env)) {
- return JNI_ERR;
- }
-
- extern int register_GLTestActivity(JNIEnv *);
- if (register_GLTestActivity(env)) {
+ if (GLTestHelper::registerNative(env)) {
return JNI_ERR;
}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp b/tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
similarity index 98%
rename from tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp
rename to tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
index 37bfcb5..5df090d 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp
+++ b/tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 The Android Open Source Project
+ * Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,15 +17,15 @@
#include <android/native_window.h>
-#include <gtest/gtest.h>
-
#include <EGL/egl.h>
#include <EGL/eglext.h>
+
+#include <gtest/gtest.h>
+
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-
-#include "GLTestHelper.h"
+#include <GLTestHelper.h>
namespace android {
diff --git a/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java b/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java
new file mode 100644
index 0000000..3c1e2af
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.gltest;
+
+import android.app.Activity;
+import android.app.KeyguardManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.Surface;
+
+public class GLTestActivity extends Activity {
+
+ private class TestThread extends Thread {
+
+ public void run() {
+ // it is possible to set the GTest filter flag from here
+ // for example "GLTest.ClearColorTest" to run that specific test only
+ runTests(null);
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+
+ finish();
+ System.exit(0);
+ }
+ }
+
+ private SurfaceView mSurfaceView;
+
+ private SurfaceHolder.Callback mHolderCallback = new SurfaceHolder.Callback() {
+
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ setSurface(holder.getSurface());
+ }
+
+ public void surfaceCreated(SurfaceHolder holder) {
+ setSurface(holder.getSurface());
+ Thread t = new TestThread();
+ t.start();
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
+ };
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ if (checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+ == PackageManager.PERMISSION_GRANTED) {
+ KeyguardManager keyguardManager =
+ (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
+ keyguardManager.newKeyguardLock("gltest").disableKeyguard();
+ }
+
+ super.onCreate(savedInstanceState);
+
+ mSurfaceView = new SurfaceView(this);
+ mSurfaceView.getHolder().addCallback(mHolderCallback);
+ setContentView(mSurfaceView);
+ System.loadLibrary("stlport_shared");
+ System.loadLibrary("gtest");
+ System.loadLibrary("nativeopengltests");
+ }
+
+ private static native void setSurface(Surface surface);
+ private static native void runTests(String filter);
+}
diff --git a/tests/tests/security/src/android/security/cts/CertificateData.java b/tests/tests/security/src/android/security/cts/CertificateData.java
index 1b039a5..f2e2f8c 100644
--- a/tests/tests/security/src/android/security/cts/CertificateData.java
+++ b/tests/tests/security/src/android/security/cts/CertificateData.java
@@ -63,6 +63,7 @@
"59:AF:82:79:91:86:C7:B4:75:07:CB:CF:03:57:46:EB:04:DD:B7:16",
"50:30:06:09:1D:97:D4:F5:AE:39:F7:CB:E7:92:7D:7D:65:2D:34:31",
"1B:4B:39:61:26:27:6B:64:91:A2:68:6D:D7:02:43:21:2D:1F:1D:96",
+ "77:47:4F:C6:30:E4:0F:4C:47:64:3F:84:BA:B8:C6:95:4A:8A:41:EC",
"8C:F4:27:FD:79:0C:3A:D1:66:06:8D:E8:1E:57:EF:BB:93:22:72:D4",
"56:E0:FA:C0:3B:8F:18:23:55:18:E5:D3:11:CA:E8:C2:43:31:AB:66",
"02:72:68:29:3E:5F:5D:17:AA:A4:B3:C3:E6:36:1E:1F:92:57:5E:AA",
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 888bb73..0af3f21 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -247,10 +247,11 @@
Rect rect = new Rect();
final Button button = new Button(mActivity);
final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
+ final int btnHeight = view.getHeight()/3;
runTestOnUiThread(new Runnable() {
public void run() {
mActivity.addContentView(button,
- new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+ new LinearLayout.LayoutParams(WRAP_CONTENT, btnHeight));
}
});
getInstrumentation().waitForIdleSync();
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
index e8965ab..4a9e2fc 100644
--- a/tools/tradefed-host/Android.mk
+++ b/tools/tradefed-host/Android.mk
@@ -16,7 +16,8 @@
include $(CLEAR_VARS)
-# Only compile source java files in this lib.
+# suite/pts/hostTests/ptshostutil is treated specially
+# as it cannot be put into ptscommonutilhost due to dependency on cts-tradefed
LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
$(call all-java-files-under, ../../suite/pts/hostTests/ptshostutil/src)
diff --git a/tools/tradefed-host/res/report/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
index b924d2f..0c38be1 100644
--- a/tools/tradefed-host/res/report/cts_result.xsl
+++ b/tools/tradefed-host/res/report/cts_result.xsl
@@ -526,11 +526,6 @@
<xsl:value-of select="@result"/>
</div>
</TD>
- <TD class="failuredetails">
- <div class="details">
- <xsl:value-of select="FailedScene/@message"/>
- </div>
- </TD>
<TD class="failuredetails"></TD>
</xsl:if>
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 942f1b1..e91595b 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
@Option(name="cts-install-path", description="the path to the cts installation to use")
private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
- public static final String CTS_BUILD_VERSION = "4.2_r3";
+ public static final String CTS_BUILD_VERSION = "4.2_r4";
/**
* {@inheritDoc}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index 2f62d71..9517d8e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -99,9 +99,8 @@
private File mLogDir;
private String mSuiteName;
- private static final String PTS_PERFORMANCE_EXCEPTION = "com.android.pts.util.PtsException";
- private static final Pattern mPtsLogPattern = Pattern.compile(
- "com\\.android\\.pts\\.util\\.PtsException:\\s(.*)\\+\\+\\+\\+(.*)");
+ private static final Pattern mPtsLogPattern = Pattern.compile("(.*)\\+\\+\\+\\+(.*)");
+
public void setReportDir(File reportDir) {
mReportDir = reportDir;
}
@@ -226,21 +225,7 @@
*/
@Override
public void testFailed(TestFailure status, TestIdentifier test, String trace) {
- if (trace.startsWith(PTS_PERFORMANCE_EXCEPTION)) { //PTS result
- Test tst = mCurrentPkgResult.findTest(test);
- // this exception is always thrown as exception is thrown from tearDown.
- // Just ignore it.
- if (tst.getName().endsWith("testAndroidTestCaseSetupProperly")) {
- return;
- }
- Matcher m = mPtsLogPattern.matcher(trace);
- if (m.find()) {
- mCurrentPkgResult.reportPerformanceResult(test, CtsTestStatus.PASS, m.group(1),
- m.group(2));
- }
- } else {
- mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
- }
+ mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
}
/**
@@ -248,6 +233,7 @@
*/
@Override
public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
+ collectPtsResults(test, testMetrics);
mCurrentPkgResult.reportTestEnded(test);
Test result = mCurrentPkgResult.findTest(test);
String stack = result.getStackTrace() == null ? "" : "\n" + result.getStackTrace();
@@ -256,6 +242,31 @@
}
/**
+ * Collect Pts results for both device and host tests to the package result.
+ * @param test test ran
+ * @param testMetrics test metrics which can contain performance result for device tests
+ */
+ private void collectPtsResults(TestIdentifier test, Map<String, String> testMetrics) {
+ // device test can have performance results in testMetrics
+ String perfResult = PtsReportUtil.getPtsResultFromMetrics(testMetrics);
+ // host test should be checked in PtsHostStore.
+ if (perfResult == null) {
+ perfResult = PtsHostStore.removePtsResult(mDeviceSerial, test);
+ }
+ if (perfResult != null) {
+ // PTS result is passed in Summary++++Details format.
+ // Extract Summary and Details, and pass them.
+ Matcher m = mPtsLogPattern.matcher(perfResult);
+ if (m.find()) {
+ mCurrentPkgResult.reportPerformanceResult(test, CtsTestStatus.PASS, m.group(1),
+ m.group(2));
+ } else {
+ logResult("PTS Result unrecognizable:" + perfResult);
+ }
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsHostStore.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsHostStore.java
new file mode 100644
index 0000000..5944c66
--- /dev/null
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsHostStore.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.tradefed.result;
+
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.device.ITestDevice;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Utility class for storing Pts Results.
+ * This is necessary for host tests where test metrics cannot be passed.
+ */
+public class PtsHostStore {
+
+ // needs concurrent verion as there can be multiple client accessing this.
+ // But there is no additional protection for the same key as that should not happen.
+ private static final ConcurrentHashMap<String, String> mMap =
+ new ConcurrentHashMap<String, String>();
+
+ /**
+ * Stores PTS result. Existing result with the same key will be replaced.
+ * Note that key is generated in the form of device_serial#class#method name.
+ * So there should be no concurrent test for the same (serial, class, method).
+ * @param device
+ * @param test
+ * @param result PTS result string
+ */
+ public static void storePtsResult(String deviceSerial, String classMethodName, String result) {
+ mMap.put(generateTestKey(deviceSerial, classMethodName), result);
+ }
+
+ /**
+ * retrieves a PTS result for the given condition and remove it from the internal
+ * storage. If there is no result for the given condition, it will return null.
+ */
+ public static String removePtsResult(String deviceSerial, TestIdentifier test) {
+ return mMap.remove(generateTestKey(deviceSerial, test));
+ }
+
+ /**
+ * return test key in the form of device_serial#class_name#method_name
+ */
+ private static String generateTestKey(String deviceSerial, TestIdentifier test) {
+ return String.format("%s#%s", deviceSerial, test.toString());
+
+ }
+
+ /**
+ * return test key in the form of device_serial#class_name#method_name
+ */
+ private static String generateTestKey(String deviceSerial, String classMethodName) {
+ return String.format("%s#%s", deviceSerial, classMethodName);
+
+ }
+}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsReportUtil.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsReportUtil.java
new file mode 100644
index 0000000..2e3dab1
--- /dev/null
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/PtsReportUtil.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.tradefed.result;
+
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.device.ITestDevice;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Static utility class for handling Pts Results.
+ */
+public class PtsReportUtil {
+ private static final String PTS_RESULT_KEY = "PTS_RESULT";
+
+ /**
+ * Utility method to extract PTS result from test metrics
+ * @param testMetrics
+ * @return result or null if not found
+ */
+ public static String getPtsResultFromMetrics(Map<String, String> testMetrics) {
+ for (Map.Entry<String, String> entry: testMetrics.entrySet()) {
+ if (PTS_RESULT_KEY.equals(entry.getKey())) {
+ return entry.getValue();
+ }
+ }
+ return null;
+ }
+}
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 9188dca..27f7c21 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
@@ -493,6 +493,9 @@
"CtsViewTestCases",
"CtsWidgetTestCases" );
long intervalInMSec = mRebootIntervalMin * 60 * 1000;
+ if (mDevice.getSerialNumber().startsWith("emulator-")) {
+ return;
+ }
if (!mDisableReboot) {
long currentTime = System.currentTimeMillis();
if (((currentTime - mPrevRebootTime) > intervalInMSec) ||