Merge "More tests."
diff --git a/apps/CtsVerifier/res/menu/test_list_menu.xml b/apps/CtsVerifier/res/menu/test_list_menu.xml
index 67c626c..495e36f 100644
--- a/apps/CtsVerifier/res/menu/test_list_menu.xml
+++ b/apps/CtsVerifier/res/menu/test_list_menu.xml
@@ -6,7 +6,7 @@
<item android:id="@+id/copy"
android:icon="@android:drawable/ic_menu_upload"
android:title="@string/copy" />
- <item android:id="@+id/share"
+ <item android:id="@+id/export"
android:icon="@android:drawable/ic_menu_share"
- android:title="@string/share" />
+ android:title="@string/export" />
</menu>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 7291d7c..5242a55 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -40,9 +40,10 @@
<string name="test_results_cleared">Test results cleared.</string>
<string name="copy">Copy</string>
<string name="test_results_copied">Test results copied to clipboard.</string>
- <string name="share">Share</string>
- <string name="share_test_results">Share Test Results</string>
<string name="test_results_error">Couldn\'t create test results report.</string>
+ <string name="export">Export</string>
+ <string name="no_storage">Cannot save report to external storage, see log for details.</string>
+ <string name="report_saved">Report saved to: %s</string>
<!-- Strings for Device Administration tests -->
<string name="da_policy_serialization_test">Policy Serialization Test</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/ReportExporter.java b/apps/CtsVerifier/src/com/android/cts/verifier/ReportExporter.java
new file mode 100644
index 0000000..f7db56d
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/ReportExporter.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier;
+
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Environment;
+import android.widget.Toast;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Background task to generate a report and save it to external storage.
+ */
+class ReportExporter extends AsyncTask<Void, Void, String> {
+ protected static final Logger LOG = Logger.getLogger(ReportExporter.class.getName());
+
+ private final Context mContext;
+ private final TestListAdapter mAdapter;
+
+ ReportExporter(Context context, TestListAdapter adapter) {
+ this.mContext = context;
+ this.mAdapter = adapter;
+ }
+
+ @Override
+ protected String doInBackground(Void... params) {
+ if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
+ LOG.log(Level.WARNING, "External storage is not writable.");
+ return mContext.getString(R.string.no_storage);
+ }
+ byte[] contents;
+ try {
+ TestResultsReport report = new TestResultsReport(mContext, mAdapter);
+ contents = report.getContents().getBytes();
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Couldn't create test results report", e);
+ return mContext.getString(R.string.test_results_error);
+ }
+ File reportPath = new File(Environment.getExternalStorageDirectory(), "ctsVerifierReports");
+ reportPath.mkdirs();
+ File reportFile = new File(reportPath,
+ "ctsVerifierReport-" + System.currentTimeMillis() + ".zip");
+ ZipOutputStream out = null;
+ try {
+ out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(reportFile)));
+ ZipEntry entry = new ZipEntry("ctsVerifierReport.xml");
+ out.putNextEntry(entry);
+ out.write(contents);
+ } catch (IOException e) {
+ LOG.log(Level.WARNING, "I/O exception writing report to storage.", e);
+ return mContext.getString(R.string.no_storage);
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {
+ LOG.log(Level.WARNING, "I/O exception closing report.", e);
+ }
+ }
+
+ return mContext.getString(R.string.report_saved, reportFile.getPath());
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ Toast.makeText(mContext, result, Toast.LENGTH_LONG).show();
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
index fe41583..bc7a2b0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
@@ -100,8 +100,8 @@
handleCopyItemSelected();
return true;
- case R.id.share:
- handleShareItemSelected();
+ case R.id.export:
+ handleExportItemSelected();
return true;
default:
@@ -119,25 +119,15 @@
TestResultsReport report = new TestResultsReport(this, mAdapter);
ClipboardManager clipboardManager = (ClipboardManager)
getSystemService(CLIPBOARD_SERVICE);
- clipboardManager.setText(report.getBody());
+ clipboardManager.setText(report.getContents());
Toast.makeText(this, R.string.test_results_copied, Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, R.string.test_results_error, Toast.LENGTH_SHORT).show();
- Log.e(TAG, "Coudn't copy test results report", e);
+ Log.e(TAG, "Couldn't copy test results report", e);
}
}
- private void handleShareItemSelected() {
- try {
- Intent target = new Intent(Intent.ACTION_SEND);
- TestResultsReport report = new TestResultsReport(this, mAdapter);
- target.setType(report.getType());
- target.putExtra(Intent.EXTRA_SUBJECT, report.getSubject());
- target.putExtra(Intent.EXTRA_TEXT, report.getBody());
- startActivity(Intent.createChooser(target, getString(R.string.share_test_results)));
- } catch (IOException e) {
- Toast.makeText(this, R.string.test_results_error, Toast.LENGTH_SHORT).show();
- Log.e(TAG, "Coudn't share test results report", e);
- }
+ private void handleExportItemSelected() {
+ new ReportExporter(this, mAdapter).execute();
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
index c7af68a..37d4819 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
@@ -77,17 +77,7 @@
this.mAdapter = adapter;
}
- String getType() {
- return "application/xml";
- }
-
- String getSubject() {
- return mContext.getString(R.string.subject_header,
- Version.getVersionName(mContext),
- Build.FINGERPRINT);
- }
-
- String getBody() throws IllegalArgumentException, IllegalStateException, IOException {
+ String getContents() throws IllegalArgumentException, IllegalStateException, IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
XmlSerializer xml = Xml.newSerializer();
@@ -106,7 +96,16 @@
xml.startTag(null, DEVICE_INFO_TAG);
xml.startTag(null, BUILD_INFO_TAG);
+ xml.attribute(null, "board", Build.BOARD);
+ xml.attribute(null, "brand", Build.BRAND);
+ xml.attribute(null, "device", Build.DEVICE);
+ xml.attribute(null, "display", Build.DISPLAY);
xml.attribute(null, "fingerprint", Build.FINGERPRINT);
+ xml.attribute(null, "id", Build.ID);
+ xml.attribute(null, "model", Build.MODEL);
+ xml.attribute(null, "product", Build.PRODUCT);
+ xml.attribute(null, "release", Build.VERSION.RELEASE);
+ xml.attribute(null, "sdk", Build.VERSION.SDK);
xml.endTag(null, BUILD_INFO_TAG);
xml.endTag(null, DEVICE_INFO_TAG);
diff --git a/tests/res/layout/mediaplayer.xml b/tests/res/layout/mediaplayer.xml
index 31ef492..aa66e64 100644
--- a/tests/res/layout/mediaplayer.xml
+++ b/tests/res/layout/mediaplayer.xml
@@ -25,4 +25,16 @@
android:layout_gravity="center">
</SurfaceView>
+ <SurfaceView android:id="@+id/surface2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ </SurfaceView>
+
+ <SurfaceView android:id="@+id/surface3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ </SurfaceView>
+
</LinearLayout>
diff --git a/tests/src/android/media/cts/MediaStubActivity.java b/tests/src/android/media/cts/MediaStubActivity.java
index e10e6fa..f0ca755 100644
--- a/tests/src/android/media/cts/MediaStubActivity.java
+++ b/tests/src/android/media/cts/MediaStubActivity.java
@@ -26,6 +26,7 @@
public static final int WIDTH = 320;
public static final int HEIGHT = 240;
private SurfaceHolder mHolder;
+ private SurfaceHolder mHolder2;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -40,9 +41,28 @@
mHolder = surfaceV.getHolder();
mHolder.setFixedSize(WIDTH, HEIGHT);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+
+ SurfaceView surfaceV2 = (SurfaceView)findViewById(R.id.surface2);
+ ViewGroup.LayoutParams lp2 = surfaceV2.getLayoutParams();
+ lp2.width = WIDTH;
+ lp2.height = HEIGHT;
+ surfaceV2.setLayoutParams(lp2);
+ mHolder2 = surfaceV2.getHolder();
+ mHolder2.setFixedSize(WIDTH, HEIGHT);
+ mHolder2.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+
}
public SurfaceHolder getSurfaceHolder() {
return mHolder;
}
+
+ public SurfaceHolder getSurfaceHolder2() {
+ return mHolder2;
+ }
+
+ public SurfaceHolder generateSurfaceHolder() {
+ SurfaceView surface = (SurfaceView)findViewById(R.id.surface3);
+ return surface.getHolder();
+ }
}
diff --git a/tests/tests/content/src/android/content/pm/cts/SignatureTest.java b/tests/tests/content/src/android/content/pm/cts/SignatureTest.java
index 16e1027..6bd77dd 100644
--- a/tests/tests/content/src/android/content/pm/cts/SignatureTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/SignatureTest.java
@@ -30,110 +30,138 @@
@TestTargetClass(Signature.class)
public class SignatureTest extends AndroidTestCase {
- private static final String mSignatureString = "1234567890abcdef";
- // mSignatureByteArray is the byte code of mSignatureString.
- private static final byte[] mSignatureByteArray = { (byte) 0x12, (byte) 0x34, (byte) 0x56,
+ private static final String SIGNATURE_STRING = "1234567890abcdef";
+ // SIGNATURE_BYTE_ARRAY is the byte code of SIGNATURE_STRING.
+ private static final byte[] SIGNATURE_BYTE_ARRAY = { (byte) 0x12, (byte) 0x34, (byte) 0x56,
(byte) 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef };
- // mDiffByteArray has different content to mSignatureString.
- private static final byte[] mDiffByteArray = { (byte) 0xfe, (byte) 0xdc, (byte) 0xba,
+ // DIFF_BYTE_ARRAY has different content to SIGNATURE_STRING.
+ private static final byte[] DIFF_BYTE_ARRAY = { (byte) 0xfe, (byte) 0xdc, (byte) 0xba,
(byte) 0x09, (byte) 0x87, (byte) 0x65, (byte) 0x43, (byte) 0x21 };
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test constructor",
- method = "Signature",
- args = {byte[].class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test constructor",
- method = "Signature",
- args = {java.lang.String.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test toByteArray",
- method = "toByteArray",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test toCharsString",
- method = "toCharsString",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test toChars",
- method = "toChars",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test toChars",
- method = "toChars",
- args = {char[].class, int[].class}
- )
- })
- public void testSignature() {
- Signature signature = new Signature(mSignatureString);
+ public void testSignatureStringConstructorValid() {
+ Signature signature = new Signature(SIGNATURE_STRING);
byte[] actualByteArray = signature.toByteArray();
- assertTrue(Arrays.equals(mSignatureByteArray, actualByteArray));
-
- signature = new Signature(mSignatureByteArray);
- String actualString = signature.toCharsString();
- assertEquals(mSignatureString, actualString);
-
- char[] charArray = signature.toChars();
- actualString = new String(charArray);
- assertEquals(mSignatureString, actualString);
-
- char[] existingCharArray = new char[mSignatureString.length()];
- int[] intArray = new int[1];
- charArray = signature.toChars(existingCharArray, intArray);
- actualString = new String(charArray);
- assertEquals(mSignatureString, actualString);
- // intArray[0] represents the length of array.
- assertEquals(intArray[0], mSignatureByteArray.length);
+ assertTrue("Output byte array should match constructor byte array.",
+ Arrays.equals(SIGNATURE_BYTE_ARRAY, actualByteArray));
}
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test equals",
- method = "equals",
- args = {java.lang.Object.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test hashCode",
- method = "hashCode",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test describeContents",
- method = "describeContents",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "Test writeToParcel",
- method = "writeToParcel",
- args = {android.os.Parcel.class, int.class}
- )
- })
+ public void testSignatureStringConstructorNull() {
+ String sig = null;
+
+ try {
+ Signature signature = new Signature(sig);
+ fail("Should throw NullPointerException on null input");
+ } catch (NullPointerException e) {
+ // pass
+ }
+ }
+
+ public void testSignatureStringConstructorInvalidLength() {
+ try {
+ Signature signature = new Signature("123");
+ fail("Should throw IllegalArgumentException on odd-sized input");
+ } catch (IllegalArgumentException e) {
+ // pass
+ }
+ }
+
+ public void testSignatureByteArrayToCharsString() {
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+ String actualString = signature.toCharsString();
+ assertEquals(SIGNATURE_STRING, actualString);
+ }
+
+ public void testSignatureByteArrayConstructorNull() {
+ byte[] sig = null;
+
+ try {
+ Signature signature = new Signature(sig);
+ fail("Should throw NullPointerException on null input");
+ } catch (NullPointerException e) {
+ // pass
+ }
+ }
+
+ public void testSignatureToChars() {
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+ char[] charArray = signature.toChars();
+ String actualString = new String(charArray);
+ assertEquals(SIGNATURE_STRING, actualString);
+ }
+
+ public void testSignatureToCharsExistingArrayCorrectlySized() {
+ char[] existingCharArray = new char[SIGNATURE_STRING.length()];
+ int[] intArray = new int[1];
+
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+
+ char[] charArray = signature.toChars(existingCharArray, intArray);
+
+ assertTrue("Should return the same object since it's correctly sized.",
+ existingCharArray == charArray);
+
+ String actualString = new String(charArray);
+ assertEquals("The re-encoded Signature should match the constructor input",
+ SIGNATURE_STRING, actualString);
+
+ // intArray[0] represents the length of array.
+ assertEquals(intArray[0], SIGNATURE_BYTE_ARRAY.length);
+ }
+
+ public void testSignatureToCharsExistingArrayTooSmall() {
+ char[] existingCharArray = new char[0];
+ int[] intArray = new int[1];
+
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+ char[] charArray = signature.toChars(existingCharArray, intArray);
+
+ assertFalse("Should return a new array since the existing one is too small",
+ existingCharArray == charArray);
+
+ String actualString = new String(charArray);
+ assertEquals("The re-encoded Signature should match the constructor input",
+ SIGNATURE_STRING, actualString);
+
+ // intArray[0] represents the length of array.
+ assertEquals(intArray[0], SIGNATURE_BYTE_ARRAY.length);
+ }
+
+ public void testSignatureToCharsNullArrays() {
+ char[] existingCharArray = null;
+ int[] intArray = null;
+
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+ char[] charArray = signature.toChars(existingCharArray, intArray);
+
+ assertFalse("Should return a new array since the existing one is too small",
+ existingCharArray == charArray);
+
+ String actualString = new String(charArray);
+ assertEquals("The re-encoded Signature should match the constructor input",
+ SIGNATURE_STRING, actualString);
+ }
+
+ public void testSignatureStringToByteArray() {
+ Signature signature = new Signature(SIGNATURE_BYTE_ARRAY);
+ byte[] actualByteArray = signature.toByteArray();
+
+ assertFalse("Should return a different array to avoid modification",
+ SIGNATURE_BYTE_ARRAY == actualByteArray);
+
+ assertTrue("Output byte array should match constructor byte array.",
+ Arrays.equals(SIGNATURE_BYTE_ARRAY, actualByteArray));
+ }
+
public void testTools() {
- Signature byteSignature = new Signature(mSignatureByteArray);
- Signature stringSignature = new Signature(mSignatureString);
+ Signature byteSignature = new Signature(SIGNATURE_BYTE_ARRAY);
+ Signature stringSignature = new Signature(SIGNATURE_STRING);
// Test describeContents, equals
assertEquals(0, byteSignature.describeContents());
assertTrue(byteSignature.equals(stringSignature));
// Test hashCode
- byteSignature = new Signature(mDiffByteArray);
+ byteSignature = new Signature(DIFF_BYTE_ARRAY);
assertNotSame(byteSignature.hashCode(), stringSignature.hashCode());
// Test writeToParcel
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraGLTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraGLTest.java
index 545ac48..816ffaa 100644
--- a/tests/tests/hardware/src/android/hardware/cts/CameraGLTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraGLTest.java
@@ -111,8 +111,7 @@
@Override
protected void tearDown() throws Exception {
if (mCamera != null) {
- mCamera.release();
- mCamera = null;
+ terminateMessageLooper();
}
// Clean up static values in stub so it can be reused
GLSurfaceViewStubActivity.resetRenderMode();
@@ -158,6 +157,7 @@
* Terminates the message looper thread.
*/
private void terminateMessageLooper() throws Exception {
+ if (LOGV) Log.v(TAG, "Shutting down camera");
mCamera.release();
mLooper.quit();
// Looper.quit() is asynchronous. The looper may still has some
@@ -168,6 +168,7 @@
mLooper.getThread().join();
mCamera = null;
mSurfaceTexture = null;
+ if (LOGV) Log.v(TAG, "Shutdown of camera complete.");
}
/** The camera preview callback. Stops capture after the first callback */
@@ -325,6 +326,10 @@
}
} finally {
wl.release();
+ // If an assert failed, camera might still be active. Clean up before next test.
+ if (mCamera != null) {
+ terminateMessageLooper();
+ }
}
}
@@ -344,7 +349,7 @@
mCamera.startPreview();
mCamera.setPreviewTexture(mSurfaceTexture);
noTimeout = waitForPreviewDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new preview callback!", noTimeout);
terminateMessageLooper();
// Check the order: setPreviewTexture->startPreview.
@@ -353,7 +358,7 @@
mCamera.setPreviewTexture(mSurfaceTexture);
mCamera.startPreview();
noTimeout = waitForPreviewDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new preview callback!", noTimeout);
// Check the order: setting preview display to null->startPreview->
// setPreviewTexture.
@@ -362,7 +367,7 @@
mCamera.startPreview();
mCamera.setPreviewTexture(mSurfaceTexture);
noTimeout = waitForPreviewDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new preview callback!", noTimeout);
terminateMessageLooper();
}
};
@@ -388,9 +393,9 @@
mCamera.startPreview();
noTimeout = waitForSurfaceTextureDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new frame from SurfaceTexture!", noTimeout);
noTimeout = waitForPreviewDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new preview callback!",noTimeout);
mGLView.requestRender();
terminateMessageLooper();
@@ -405,9 +410,9 @@
mCamera.setPreviewTexture(mSurfaceTexture);
noTimeout = waitForSurfaceTextureDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new frame from SurfaceTexture!", noTimeout);
noTimeout = waitForPreviewDone();
- assertTrue(noTimeout);
+ assertTrue("Timeout waiting for new preview callback!", noTimeout);
mGLView.requestRender();
@@ -496,7 +501,15 @@
private RunPerCamera testCameraToSurfaceTextureMetadataByCamera = new RunPerCamera() {
public void run(int cameraId) throws Exception {
- int kLoopCount = 100; // Number of frames to test over
+ // Number of frames to test over
+ int kLoopCount = 100;
+ // Ignore timestamp issues before this frame
+ int kFirstTestedFrame = 10;
+ // Slop in timestamp testing, needed because timestamps are not
+ // currently being set by driver-level code so are subject to
+ // lots of variability
+ float kTestSlopMargin = 30; // ms
+
boolean noTimeout;
initializeMessageLooper(cameraId);
Parameters parameters = mCamera.getParameters();
@@ -574,22 +587,27 @@
float expectedMaxFrameDurationMs = 1000.f * 1000.f /
fps[Parameters.PREVIEW_FPS_MIN_INDEX];
+ float slopMaxFrameDurationMs = expectedMaxFrameDurationMs +
+ kTestSlopMargin;
float expectedMinFrameDurationMs = 1000.f * 1000.f /
fps[Parameters.PREVIEW_FPS_MAX_INDEX];
+ float slopMinFrameDurationMs = expectedMinFrameDurationMs -
+ kTestSlopMargin;
- for (int i = 1; i < kLoopCount; i++) {
+ for (int i = kFirstTestedFrame; i < kLoopCount; i++) {
float frameDurationMs = (timestamps[i] - timestamps[i - 1]) / 1000000.f;
if (LOGVV) {
Log.v(TAG, "Frame " + i + " duration: " + frameDurationMs +
" ms, expecting [" + expectedMinFrameDurationMs + "," +
- expectedMaxFrameDurationMs + "]");
+ expectedMaxFrameDurationMs + "], slop range [" +
+ slopMinFrameDurationMs + "," + slopMaxFrameDurationMs + "].");
}
assertTrue("Frame " + i + " duration out of bounds! ("+
frameDurationMs + " ms, expecting [" +
- expectedMinFrameDurationMs + "," +
- expectedMaxFrameDurationMs + "] ms)",
- (frameDurationMs > expectedMinFrameDurationMs) &&
- (frameDurationMs < expectedMaxFrameDurationMs) );
+ slopMinFrameDurationMs + "," +
+ slopMaxFrameDurationMs + "] ms)",
+ (frameDurationMs > slopMinFrameDurationMs) &&
+ (frameDurationMs < slopMaxFrameDurationMs) );
}
}
}
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index d18d684..7e5b4ca 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -389,6 +389,37 @@
Thread.sleep(SLEEP_TIME);
}
+ // Test for reseting a surface during video playback
+ // After reseting, the video should continue playing
+ // from the time setDisplay() was called
+ mp.start();
+ Thread.sleep(SLEEP_TIME);
+
+ int posBefore = mp.getCurrentPosition();
+ mp.setDisplay(getActivity().getSurfaceHolder2());
+ int posAfter = mp.getCurrentPosition();
+
+ assertEquals(posAfter, posBefore);
+ assertTrue(mp.isPlaying());
+
+ Thread.sleep(SLEEP_TIME);
+
+ posBefore = mp.getCurrentPosition();
+ mp.setDisplay(getActivity().generateSurfaceHolder());
+ posAfter = mp.getCurrentPosition();
+
+ assertEquals(posAfter, posBefore);
+ assertTrue(mp.isPlaying());
+
+ Thread.sleep(SLEEP_TIME);
+
+ posBefore = mp.getCurrentPosition();
+ mp.setDisplay(null);
+ posAfter = mp.getCurrentPosition();
+
+ assertEquals(posAfter, posBefore);
+ assertTrue(mp.isPlaying());
+
mp.release();
}
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index 52b068f..2493680 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -563,9 +563,9 @@
p.recycle();
// test Parcelable[]
- Signature[] signatures = {new Signature("123"),
- new Signature("ABC"),
- new Signature("abc")};
+ Signature[] signatures = {new Signature("1234"),
+ new Signature("ABCD"),
+ new Signature("abcd")};
Parcelable[] signatures2;
p = Parcel.obtain();
p.writeValue(signatures);
@@ -2449,13 +2449,13 @@
public void testReadParcelableArray() {
Parcel p;
MockClassLoader mcl = new MockClassLoader();
- Signature[] s = {new Signature("123"),
- new Signature("ABC"),
- new Signature("abc")};
+ Signature[] s = {new Signature("1234"),
+ new Signature("ABCD"),
+ new Signature("abcd")};
- Signature[] s2 = {new Signature("123"),
+ Signature[] s2 = {new Signature("1234"),
null,
- new Signature("abc")};
+ new Signature("abcd")};
Parcelable[] s3;
// test write null
@@ -2498,13 +2498,13 @@
})
public void testReadTypedArray() {
Parcel p;
- Signature[] s = {new Signature("123"),
- new Signature("ABC"),
- new Signature("abc")};
+ Signature[] s = {new Signature("1234"),
+ new Signature("ABCD"),
+ new Signature("abcd")};
- Signature[] s2 = {new Signature("123"),
+ Signature[] s2 = {new Signature("1234"),
null,
- new Signature("abc")};
+ new Signature("abcd")};
Signature[] s3 = new Signature[3];
Signature[] s4 = new Signature[4];
@@ -2575,11 +2575,11 @@
public void testReadTypedArray2() {
Parcel p;
Signature[] s = {
- new Signature("123"), new Signature("ABC"), new Signature("abc")
+ new Signature("1234"), new Signature("ABCD"), new Signature("abcd")
};
Signature[] s2 = {
- new Signature("123"), null, new Signature("abc")
+ new Signature("1234"), null, new Signature("abcd")
};
Signature[] s3 = {
null, null, null
@@ -2625,13 +2625,13 @@
})
public void testCreateTypedArray() {
Parcel p;
- Signature[] s = {new Signature("123"),
- new Signature("ABC"),
- new Signature("abc")};
+ Signature[] s = {new Signature("1234"),
+ new Signature("ABCD"),
+ new Signature("abcd")};
- Signature[] s2 = {new Signature("123"),
+ Signature[] s2 = {new Signature("1234"),
null,
- new Signature("abc")};
+ new Signature("abcd")};
Signature[] s3;
// test write null
@@ -2676,12 +2676,12 @@
public void testReadTypedList() {
Parcel p;
ArrayList<Signature> s = new ArrayList<Signature>();
- s.add(new Signature("123"));
- s.add(new Signature("ABC"));
- s.add(new Signature("abc"));
+ s.add(new Signature("1234"));
+ s.add(new Signature("ABCD"));
+ s.add(new Signature("abcd"));
ArrayList<Signature> s2 = new ArrayList<Signature>();
- s2.add(new Signature("123"));
+ s2.add(new Signature("1234"));
s2.add(null);
ArrayList<Signature> s3 = new ArrayList<Signature>();
@@ -2728,7 +2728,7 @@
p.recycle();
s2 = new ArrayList<Signature>();
- s2.add(new Signature("123"));
+ s2.add(new Signature("1234"));
s2.add(null);
p = Parcel.obtain();
p.writeTypedList(s2);
@@ -2756,12 +2756,12 @@
public void testCreateTypedArrayList() {
Parcel p;
ArrayList<Signature> s = new ArrayList<Signature>();
- s.add(new Signature("123"));
- s.add(new Signature("ABC"));
- s.add(new Signature("abc"));
+ s.add(new Signature("1234"));
+ s.add(new Signature("ABCD"));
+ s.add(new Signature("abcd"));
ArrayList<Signature> s2 = new ArrayList<Signature>();
- s2.add(new Signature("123"));
+ s2.add(new Signature("1234"));
s2.add(null);
ArrayList<Signature> s3;