am 24ce1582: am d7639577: Merge "media: VideoEncoderTest: set input buffer size for playback" into lmp-mr1-dev
* commit '24ce15826be9171100f751b7c8402e81ba34f7b0':
media: VideoEncoderTest: set input buffer size for playback
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 16f9ec1..0581a5d 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -109,6 +109,7 @@
CtsAdminTestCases \
CtsAnimationTestCases \
CtsAppTestCases \
+ CtsAppWidgetTestCases \
CtsBluetoothTestCases \
CtsCalendarcommon2TestCases \
CtsContentTestCases \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index ddd2b8f..adfe110 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="5"
- android:versionName="5.0_r1.94">
+ android:versionName="5.0_r1.91">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21"/>
@@ -1118,8 +1118,6 @@
<meta-data android:name="test_category" android:value="@string/test_category_other" />
<meta-data android:name="test_required_features"
android:value="android.software.app_widgets" />
- <meta-data android:name="test_excluded_features"
- android:value="android.software.leanback" />
</activity>
<activity android:name=".deskclock.DeskClockTestsActivity"
diff --git a/apps/CtsVerifier/proguard.flags b/apps/CtsVerifier/proguard.flags
index ca4680f..fe7eed8 100644
--- a/apps/CtsVerifier/proguard.flags
+++ b/apps/CtsVerifier/proguard.flags
@@ -19,3 +19,5 @@
-dontwarn android.hardware.Sensor
-dontwarn android.test.AndroidTestRunner
-dontwarn java.util.concurrent.ConcurrentLinkedDeque
+-dontwarn android.cts.util.**
+-dontwarn junit.**
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 2413432..b1947f1 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -7,13 +7,6 @@
bug: 17536113
},
{
- description: "the ConnectivityConstraintTest are not yet stable",
- names: [
- "android.jobscheduler.cts.ConnectivityConstraintTest"
- ],
- bug: 18117279
-},
-{
description: "tests a fragile by nature as they rely on hardcoded behavior",
names: [
"android.accessibilityservice.cts.AccessibilityTextTraversalTest#testActionNextAndPreviousAtGranularityPageOverText",
@@ -76,6 +69,26 @@
bug: 16720689
},
{
+ description: "test can only run properly on a user build device when the bug is resolved",
+ names: [
+ "android.appwidget.cts.AppWidgetTest#testAppWidgetProviderCallbacks",
+ "android.appwidget.cts.AppWidgetTest#testBindAppWidget",
+ "android.appwidget.cts.AppWidgetTest#testCollectionWidgets",
+ "android.appwidget.cts.AppWidgetTest#testDeleteHost",
+ "android.appwidget.cts.AppWidgetTest#testDeleteHosts",
+ "android.appwidget.cts.AppWidgetTest#testGetAppWidgetIds",
+ "android.appwidget.cts.AppWidgetTest#testGetAppWidgetInfo",
+ "android.appwidget.cts.AppWidgetTest#testGetAppWidgetOptions",
+ "android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetId",
+ "android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetIds",
+ "android.appwidget.cts.AppWidgetTest#testTwoAppWidgetProviderCallbacks",
+ "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaComponentName",
+ "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetId",
+ "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetIds"
+ ],
+ bug: 17993121
+},
+{
description: "A few WebGL tests are known to fail in WebView",
names: [
"android.webgl.cts.WebGLTest#test_conformance_extensions_oes_texture_float_with_video_html",
diff --git a/tests/tests/graphics/res/drawable/vector_icon_delete.xml b/tests/tests/graphics/res/drawable/vector_icon_delete.xml
index 8d9c21c..7b8f2aa 100644
--- a/tests/tests/graphics/res/drawable/vector_icon_delete.xml
+++ b/tests/tests/graphics/res/drawable/vector_icon_delete.xml
@@ -24,6 +24,6 @@
<path
android:fillColor="#FF000000"
- android:pathData="M6.0,19.0c0.0,1.104 0.896,2.0 2.0,2.0l8.0,0.0c1.104,0.0 2.0-0.896 2.0-2.0l0.0-12.0L6.0,7.0L6.0,19.0zM18.0,4.0l-2.5,0.0l-1.0-1.0l-5.0,0.0l-1.0,1.0L6.0,4.0C5.4469986,4.0 5.0,4.4469986 5.0,5.0l0.0,1.0l14.0,0.0l0.0-1.0C19.0,4.4469986 18.552002,4.0 18.0,4.0z" />
+ android:pathData="M6.0,19.0c0.0,1.104 896e-3,2.0 2.0,2.0l8.0,0.0c1.104,0.0 2.0-896e-3 2.0-2.0l0.0-12.0L6.0,7.0L6.0,19.0zM18.0,4.0l-2.5,0.0l-1.0-1.0l-5.0,0.0l-1.0,1.0L6.0,4.0C5.4469986,4.0 5.0,4.4469986 5.0,5.0l0.0,1.0l14.0,0.0l0.0-1.0C19.0,4.4469986 18.552002,4.0 18.0,4.0z" />
</vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/res/drawable/vector_icon_heart.xml b/tests/tests/graphics/res/drawable/vector_icon_heart.xml
index ff55fe5..ad991c9 100644
--- a/tests/tests/graphics/res/drawable/vector_icon_heart.xml
+++ b/tests/tests/graphics/res/drawable/vector_icon_heart.xml
@@ -24,6 +24,6 @@
<path
android:fillColor="#FF000000"
- android:pathData="M16.0,5.0c-1.955,0.0 -3.83,1.268 -4.5,3.0c-0.67-1.732 -2.547-3.0 -4.5-3.0C4.4570007,5.0 2.5,6.931999 2.5,9.5c0.0,3.529 3.793,6.258 9.0,11.5c5.207-5.242 9.0-7.971 9.0-11.5C20.5,6.931999 18.543,5.0 16.0,5.0z" />
+ android:pathData="M16.0,5.0c-1.955.0 -3.83,1.268 -4.5,3.0c-0.67-1.732 -2.547-3.0 -4.5-3.0C4.4570007,5.0 2.5,6.931999 2.5,9.5c0.0,3.529 3.793,6.258 9.0,11.5c5.207-5.242 9.0-7.971 9.0-11.5C20.5,6.931999 18.543,5.0 16.0,5.0z" />
</vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index 1f709d3..bac72b2 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -19,6 +19,7 @@
import android.graphics.ColorFilter;
import android.graphics.MaskFilter;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Cap;
@@ -28,6 +29,8 @@
import android.graphics.PathEffect;
import android.graphics.Rasterizer;
import android.graphics.Shader;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
import android.graphics.Typeface;
import android.graphics.Xfermode;
import android.os.Build;
@@ -190,7 +193,7 @@
assertEquals(m, p2.getMaskFilter());
assertEquals(e, p2.getPathEffect());
assertEquals(r, p2.getRasterizer());
- assertNotSame(s, p2.getShader());
+ assertEquals(s, p2.getShader());
assertEquals(t, p2.getTypeface());
assertEquals(x, p2.getXfermode());
@@ -199,7 +202,7 @@
assertEquals(m, p2.getMaskFilter());
assertEquals(e, p2.getPathEffect());
assertEquals(r, p2.getRasterizer());
- assertNotSame(s, p2.getShader());
+ assertEquals(s, p2.getShader());
assertEquals(t, p2.getTypeface());
assertEquals(x, p2.getXfermode());
@@ -271,6 +274,35 @@
assertNull(p.getShader());
}
+ public void testShaderLocalMatrix() {
+ int width = 80;
+ int height = 120;
+ int[] color = new int[width * height];
+ Bitmap bitmap = Bitmap.createBitmap(color, width, height, Bitmap.Config.RGB_565);
+
+ Paint p = new Paint();
+ Matrix m = new Matrix();
+ Shader s = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+
+ // set the shaders matrix to a non identity value and attach to paint
+ m.setScale(10, 0);
+ s.setLocalMatrix(m);
+ p.setShader(s);
+
+ Matrix m2 = new Matrix();
+ assertTrue(p.getShader().getLocalMatrix(m2));
+ assertEquals(m, m2);
+
+ // updated the matrix again and set it on the shader but NOT the paint
+ m.setScale(0, 10);
+ s.setLocalMatrix(m);
+
+ // assert that the matrix on the paint's shader also changed
+ Matrix m3 = new Matrix();
+ assertTrue(p.getShader().getLocalMatrix(m3));
+ assertEquals(m, m3);
+ }
+
public void testSetAntiAlias() {
Paint p = new Paint();
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
new file mode 100644
index 0000000..ce6b9cd
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
@@ -0,0 +1,618 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.camera2.cts;
+
+import static android.hardware.camera2.cts.CameraTestUtils.*;
+
+import android.graphics.ImageFormat;
+import android.graphics.Rect;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.cts.CameraTestUtils.SimpleCaptureCallback;
+import android.hardware.camera2.cts.CameraTestUtils.SimpleImageReaderListener;
+import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.Image;
+import android.util.Log;
+import android.util.Range;
+import android.util.Size;
+
+import java.util.ArrayList;
+
+/**
+ * Basic tests for burst capture in RAW10/16.
+ */
+public class BurstCaptureRawTest extends Camera2SurfaceViewTestCase {
+ private static final String TAG = "BurstCaptureRawTest";
+ private static final int RAW_FORMATS[] = {
+ ImageFormat.RAW10, ImageFormat.RAW_SENSOR };
+ private static final long EXPOSURE_MULTIPLIERS[] = {
+ 1, 3, 5 };
+ private static final int SENSITIVITY_MLTIPLIERS[] = {
+ 1, 3, 5 };
+ private static final int MAX_FRAMES_BURST =
+ EXPOSURE_MULTIPLIERS.length * SENSITIVITY_MLTIPLIERS.length;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Verify raw sensor size information is correctly configured.
+ */
+ public void testRawSensorSize() throws Exception {
+ Log.i(TAG, "Begin testRawSensorSize");
+ for (String id : mCameraIds) {
+ try {
+ openDevice(id);
+
+ ArrayList<Integer> supportedRawList = new ArrayList<Integer>(RAW_FORMATS.length);
+ if (!checkCapability(supportedRawList)) {
+ Log.i(TAG, "Capability is not supported on camera " + id
+ + ". Skip the test.");
+ continue;
+ }
+
+ Size[] rawSizes = mStaticInfo.getRawOutputSizesChecked();
+ assertTrue("No capture sizes available for RAW format!", rawSizes.length != 0);
+
+ Rect activeArray = mStaticInfo.getActiveArraySizeChecked();
+ Size size = new Size(activeArray.width(), activeArray.height());
+ mCollector.expectTrue("Missing ActiveArraySize",
+ activeArray.width() > 0 && activeArray.height() > 0);
+ mCollector.expectContains(
+ "Available sizes for RAW format must include ActiveArraySize",
+ rawSizes, size);
+
+ } finally {
+ closeDevice();
+ }
+ }
+ Log.i(TAG, "End testRawSensorSize");
+ }
+
+ /**
+ * Round [exposure, gain] down, rather than to the nearest, in RAW 10/16
+ * <p>
+ * Verify the value of metadata (exposure and sensitivity) is rounded down if the request cannot
+ * be honored.
+ * </p>
+ */
+ public void testMetadataRoundDown() throws Exception {
+ Log.i(TAG, "Begin testMetadataRoundDown");
+
+ performTestRoutine(new TestMetaDataRoundDownRoutine());
+
+ Log.i(TAG, "End testMetadataRoundDown");
+ }
+
+ /**
+ * Manual and Auto setting test in RAW10/16
+ * <p>
+ * Make sure switching between manual and auto setting would not make the capture results out of
+ * sync.
+ * </p>
+ */
+ public void testManualAutoSwitch() throws Exception {
+ Log.i(TAG, "Begin testManualAutoSwitch");
+
+ performTestRoutine(new TestManualAutoSwitch());
+
+ Log.i(TAG, "End testManualAutoSwitch");
+ }
+
+ /*
+ * Below are private infrastructure for all tests
+ */
+
+ /**
+ * A structure encapsulates all the parameters for setting up preview, and RAW capture.
+ */
+ class CaptureSetup
+ {
+ public CaptureSetup(Size previewCaptureSize, Size rawCaptureSize,
+ CaptureRequest.Builder previewRequestBuilder,
+ CaptureRequest.Builder rawRequestBuilder,
+ SimpleCaptureCallback previewCaptureCallback,
+ SimpleCaptureCallback rawCaptureCallback,
+ SimpleImageReaderListener rawReaderListener)
+ {
+ mPreviewCaptureSize = previewCaptureSize;
+ mRawCaptureSize = rawCaptureSize;
+ mPreviewRequestBuilder = previewRequestBuilder;
+ mRawRequestBuilder = rawRequestBuilder;
+ mPreviewCaptureCallback = previewCaptureCallback;
+ mRawCaptureCallback = rawCaptureCallback;
+ mRawReaderListener = rawReaderListener;
+ }
+
+ public Size getPreviewCaptureSize()
+ {
+ return mPreviewCaptureSize;
+ }
+
+ public Size getRawCaptureSize()
+ {
+ return mRawCaptureSize;
+ }
+
+ public CaptureRequest.Builder getPreviewRequestBuilder()
+ {
+ return mPreviewRequestBuilder;
+ }
+
+ public CaptureRequest.Builder getRawRequestBuilder() {
+ return mRawRequestBuilder;
+ }
+
+ public SimpleCaptureCallback getPreviewCaptureCallback() {
+ return mPreviewCaptureCallback;
+ }
+
+ public SimpleCaptureCallback getRawCaptureCallback() {
+ return mRawCaptureCallback;
+ }
+
+ public SimpleImageReaderListener getRawReaderListener() {
+ return mRawReaderListener;
+ }
+
+ private Size mPreviewCaptureSize;
+ private Size mRawCaptureSize;
+ private CaptureRequest.Builder mPreviewRequestBuilder;
+ private CaptureRequest.Builder mRawRequestBuilder;
+
+ /** all the non-testing requests are sent to here */
+ private SimpleCaptureCallback mPreviewCaptureCallback;
+ /** all the testing requests are sent to here */
+ private SimpleCaptureCallback mRawCaptureCallback;
+ /** all the testing framebuffers are sent to here */
+ private SimpleImageReaderListener mRawReaderListener;
+ }
+
+ /**
+ * Interface for the test routines that are being called by performTestRoutines(). Implement
+ * different test cases in execute().
+ */
+ interface TestRoutine {
+ public void execute(CaptureRequest.Builder rawBurstBuilder,
+ SimpleCaptureCallback rawCaptureCallback,
+ SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception;
+ }
+
+ /**
+ * Implementation of metadata round down test.
+ */
+ class TestMetaDataRoundDownRoutine implements TestRoutine
+ {
+ @Override
+ public void execute(CaptureRequest.Builder rawBurstBuilder,
+ SimpleCaptureCallback rawCaptureCallback,
+ SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception
+ {
+ // build burst capture
+ ArrayList<CaptureRequest> rawRequestList = createBurstRequest(rawBurstBuilder);
+
+ // submit captrue
+ Log.i(TAG, "Submitting Burst Request.");
+ mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+ // verify metadata
+ for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+ CaptureResult result = rawCaptureCallback.getCaptureResult(
+ CAPTURE_IMAGE_TIMEOUT_MS);
+
+ long resultExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
+ int resultSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
+ long desiredExposure = rawRequestList.get(i).get(
+ CaptureRequest.SENSOR_EXPOSURE_TIME);
+ int desiredSensitivity = rawRequestList.get(i).get(
+ CaptureRequest.SENSOR_SENSITIVITY);
+
+ Log.i(TAG, String.format(
+ "Received capture result, exposure = %d, sensitivity = %d. "
+ + "Requested exposure = %d, sensitivity = %d.",
+ resultExposure,
+ resultSensitivity, desiredExposure, desiredSensitivity));
+
+ mCollector.expectTrue(
+ String.format("Exposure value is greater than requested: "
+ + "requested = %d, result = %d.",
+ desiredExposure, resultExposure),
+ resultExposure <= desiredExposure);
+
+ mCollector.expectTrue(
+ String.format("Sensitivity value is greater than requested: "
+ + "requested = %d, result = %d.",
+ desiredSensitivity, resultSensitivity),
+ resultSensitivity <= desiredSensitivity);
+ }
+ }
+ }
+
+ /**
+ * Implementation of manual-auto switching test.
+ */
+ class TestManualAutoSwitch implements TestRoutine
+ {
+ @Override
+ public void execute(CaptureRequest.Builder rawBurstBuilder,
+ SimpleCaptureCallback rawCaptureCallback,
+ SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception
+ {
+ // create a capture request builder to preserve all the original values
+ CaptureRequest.Builder originBuilder = mCamera.createCaptureRequest(
+ CameraDevice.TEMPLATE_STILL_CAPTURE);
+ copyBurstRequetBuilder(originBuilder, rawBurstBuilder);
+
+ // build burst capture
+ ArrayList<CaptureRequest> rawRequestList = createBurstRequest(rawBurstBuilder);
+
+ // submit captrue but ignore
+ mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+ // drain the capture result
+ drainQueues(rawReaderListener, rawCaptureCallback);
+
+ // reset and build capture with 3A
+ copyBurstRequetBuilder(rawBurstBuilder, originBuilder);
+ rawRequestList = createBurstRequestWith3A(rawBurstBuilder);
+
+ // submit captrue but ignore
+ mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+ // drain the capture result
+ drainQueues(rawReaderListener, rawCaptureCallback);
+
+ // reset and rebuild manual raw burst capture
+ copyBurstRequetBuilder(rawBurstBuilder, originBuilder);
+ rawRequestList = createBurstRequest(rawBurstBuilder);
+
+ // submit capture
+ Log.i(TAG, "Submitting Burst Request.");
+ mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+ // verify metadata
+ for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+ CaptureResult result = rawCaptureCallback.getCaptureResult(
+ CAPTURE_IMAGE_TIMEOUT_MS);
+
+ long resultExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
+ int resultSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
+ int resultEdgeMode = result.get(CaptureResult.EDGE_MODE);
+ int resultNoiseReductionMode = result.get(
+ CaptureResult.NOISE_REDUCTION_MODE);
+ long desiredExposure = rawRequestList.get(i).get(
+ CaptureRequest.SENSOR_EXPOSURE_TIME);
+ int desiredSensitivity = rawRequestList.get(i).get(
+ CaptureRequest.SENSOR_SENSITIVITY);
+
+ Log.i(TAG, String.format(
+ "Received capture result, exposure = %d, sensitivity = %d. "
+ + "Requested exposure = %d, sensitivity = %d.",
+ resultExposure,
+ resultSensitivity, desiredExposure, desiredSensitivity));
+
+ mCollector.expectTrue(String.format("Edge mode is not turned off."),
+ resultEdgeMode == CaptureRequest.EDGE_MODE_OFF);
+
+ mCollector.expectTrue(String.format("Noise reduction is not turned off."),
+ resultNoiseReductionMode
+ == CaptureRequest.NOISE_REDUCTION_MODE_OFF);
+
+ mCollector.expectTrue(
+ String.format("Exposure value is greater than requested: "
+ + "requested = %d, result = %d.",
+ desiredExposure, resultExposure),
+ resultExposure <= desiredExposure);
+
+ mCollector.expectTrue(
+ String.format("Sensitivity value is greater than requested: "
+ + "requested = %d, result = %d.",
+ desiredSensitivity, resultSensitivity),
+ resultSensitivity <= desiredSensitivity);
+ }
+
+ }
+ }
+
+ /**
+ * Check sensor capability prior to the test.
+ *
+ * @return true if the it is has the capability to execute the test.
+ */
+ private boolean checkCapability(ArrayList<Integer> supportedRawList) {
+ // make sure the sensor has manual support
+ if (!mStaticInfo.isCapabilitySupported(
+ CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)) {
+ Log.w(TAG, "Full hardware level is not supported");
+ return false;
+ }
+
+ // get the list of supported RAW format
+ StreamConfigurationMap config = mStaticInfo.getValueFromKeyNonNull(
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+
+ // check for the RAW support
+ supportedRawList.clear();
+ for (int rawFormat : RAW_FORMATS) {
+ if (!config.isOutputSupportedFor(rawFormat)) {
+ continue;
+ }
+ supportedRawList.add(rawFormat);
+ }
+
+ if (supportedRawList.size() == 0)
+ {
+ Log.w(TAG, "RAW output is not supported!");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return the sensor format to human readable string.
+ *
+ * @param format Sensor image format.
+ * @return Human readable string.
+ */
+ private String imageFormatToString(int format) {
+ switch (format) {
+ case ImageFormat.RAW10:
+ return "RAW10";
+ case ImageFormat.RAW_SENSOR:
+ return "RAW_SENSOR";
+ }
+
+ return "Unknown";
+ }
+
+ /**
+ * Setting up various classes prior to the request, e.g.: capture size, builder, callback and
+ * listener
+ *
+ * @return initialized variables that can be directly fed into prepareCaptureAndStartPreview().
+ */
+ private CaptureSetup initCaptureSetupForPreviewAndRaw() throws Exception
+ {
+ // capture size
+ Size previewSize = mOrderedPreviewSizes.get(0);
+ Rect activeArray = mStaticInfo.getActiveArraySizeChecked();
+ Size rawSize = new Size(activeArray.width(), activeArray.height());
+
+ // builder
+ CaptureRequest.Builder previewCaptureBuilder = mCamera.createCaptureRequest(
+ CameraDevice.TEMPLATE_PREVIEW);
+ CaptureRequest.Builder rawCaptureBuilder = mCamera.createCaptureRequest(
+ CameraDevice.TEMPLATE_STILL_CAPTURE);
+
+ // callback
+ SimpleCaptureCallback previewCaptureCallback = new SimpleCaptureCallback();
+ SimpleCaptureCallback rawCaptureCallback = new SimpleCaptureCallback();
+ SimpleImageReaderListener rawReaderListener = new SimpleImageReaderListener();
+
+ CaptureSetup setup = new CaptureSetup(previewSize, rawSize, previewCaptureBuilder,
+ rawCaptureBuilder, previewCaptureCallback, rawCaptureCallback, rawReaderListener);
+
+ return setup;
+ }
+
+ /**
+ * Construct an array of burst request with manual exposure and sensitivity.
+ * <p>
+ * For each capture request, 3A and post processing (noise reduction, sharpening, etc) will be
+ * turned off. Then exposure and sensitivity value will be configured, which are determined by
+ * EXPOSURE_MULIPLIERS and SENSITIVITY_MULTIPLIERS.
+ * </p>
+ *
+ * @param rawBurstBuilder The builder needs to have targets setup.
+ * @return An array list capture request for burst.
+ */
+ private ArrayList<CaptureRequest> createBurstRequest(CaptureRequest.Builder rawBurstBuilder) {
+ // set manual mode
+ rawBurstBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
+ rawBurstBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_OFF);
+ rawBurstBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+ CaptureRequest.NOISE_REDUCTION_MODE_OFF);
+ rawBurstBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_OFF);
+ // exposure has higher priority over frame duration; therefore the frame readout time:
+ // exposure time + overhead
+ rawBurstBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, 0L);
+
+ // get the exposure and sensitivity range
+ Range<Long> exposureRangeNs = new Range<Long>(mStaticInfo.getExposureMinimumOrDefault(),
+ mStaticInfo.getExposureMaximumOrDefault());
+
+ Range<Integer> isoRange = new Range<Integer>(mStaticInfo.getSensitivityMinimumOrDefault(),
+ mStaticInfo.getSensitivityMaximumOrDefault());
+
+ Log.i(TAG, String.format("Exposure time - max: %d, min: %d.", exposureRangeNs.getUpper(),
+ exposureRangeNs.getLower()));
+ Log.i(TAG, String.format("Sensitivity - max: %d, min: %d.", isoRange.getUpper(),
+ isoRange.getLower()));
+
+ // building burst request
+ Log.i(TAG, String.format("Setting up burst = %d frames.", MAX_FRAMES_BURST));
+ ArrayList<CaptureRequest> rawRequestList = new ArrayList<CaptureRequest>(MAX_FRAMES_BURST);
+
+ for (int i = 0; i < EXPOSURE_MULTIPLIERS.length; i++) {
+ for (int j = 0; j < SENSITIVITY_MLTIPLIERS.length; j++) {
+ long desiredExposure = Math.min(
+ exposureRangeNs.getLower() * EXPOSURE_MULTIPLIERS[i],
+ exposureRangeNs.getUpper());
+
+ int desiredSensitivity =
+ Math.min(isoRange.getLower() * SENSITIVITY_MLTIPLIERS[j],
+ isoRange.getUpper());
+
+ rawBurstBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, desiredExposure);
+ rawBurstBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, desiredSensitivity);
+
+ rawRequestList.add(rawBurstBuilder.build());
+ }
+ }
+ return rawRequestList;
+ }
+
+ /**
+ * Construct an array of burst request with 3A
+ * <p>
+ * For each capture request, 3A and post processing (noise reduction, sharpening, etc) will be
+ * turned on.
+ * </p>
+ *
+ * @param rawBurstBuilder The builder needs to have targets setup.
+ * @return An array list capture request for burst.
+ */
+ private ArrayList<CaptureRequest> createBurstRequestWith3A(
+ CaptureRequest.Builder rawBurstBuilder)
+ {
+ // set 3A mode to simulate regular still capture
+ rawBurstBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
+ rawBurstBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
+ rawBurstBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+ CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY);
+ rawBurstBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_HIGH_QUALITY);
+
+ // building burst request
+ Log.i(TAG, String.format("Setting up burst = %d frames.", MAX_FRAMES_BURST));
+ ArrayList<CaptureRequest> rawRequestList = new ArrayList<CaptureRequest>(MAX_FRAMES_BURST);
+
+ for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+ rawRequestList.add(rawBurstBuilder.build());
+ }
+
+ return rawRequestList;
+ }
+
+ /**
+ * An utility method to copy capture request builders. This is used for recovery purpose to
+ * reverse the changes we made to the builder.
+ *
+ * @param dst the builder to write into.
+ * @param src the builder that needs to be copied.
+ */
+ private void copyBurstRequetBuilder(CaptureRequest.Builder dst, CaptureRequest.Builder src)
+ {
+ dst.set(CaptureRequest.CONTROL_AE_MODE, src.get(CaptureRequest.CONTROL_AE_MODE));
+ dst.set(CaptureRequest.CONTROL_AWB_MODE, src.get(CaptureRequest.CONTROL_AWB_MODE));
+ dst.set(CaptureRequest.NOISE_REDUCTION_MODE, src.get(CaptureRequest.NOISE_REDUCTION_MODE));
+ dst.set(CaptureRequest.EDGE_MODE, src.get(CaptureRequest.EDGE_MODE));
+ dst.set(CaptureRequest.SENSOR_FRAME_DURATION,
+ src.get(CaptureRequest.SENSOR_FRAME_DURATION));
+ dst.set(CaptureRequest.SENSOR_EXPOSURE_TIME, src.get(CaptureRequest.SENSOR_EXPOSURE_TIME));
+ dst.set(CaptureRequest.SENSOR_SENSITIVITY, src.get(CaptureRequest.SENSOR_SENSITIVITY));
+ }
+
+ /**
+ * Draining the image reader and capture callback queue
+ *
+ * @param readerListener Image reader listener needs to be drained.
+ * @param captureCallback Capture callback needs to be drained.
+ * @throws Exception Exception from the queue.
+ */
+ private void drainQueues(SimpleImageReaderListener readerListener,
+ SimpleCaptureCallback captureCallback) throws Exception
+ {
+ for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+ Image image = readerListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
+ image.close();
+
+ CaptureResult result = captureCallback.getCaptureResult(
+ CAPTURE_IMAGE_TIMEOUT_MS);
+ long timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
+ Log.d(TAG, String.format("timestamp = %d", timestamp));
+ }
+ }
+
+ /**
+ * Stop preview and remove the target surfaces inside the CaptureRequest.Builder.
+ *
+ * @param previewBuilder Configured builder for preview.
+ * @param rawBurstBuilder Configured builder for RAW.
+ * @throws Exception Exceptions from stopPreview.
+ */
+ private void stopPreviewAndClearSurface(CaptureRequest.Builder previewBuilder,
+ CaptureRequest.Builder rawBurstBuilder) throws Exception
+ {
+ previewBuilder.removeTarget(mPreviewSurface);
+ rawBurstBuilder.removeTarget(mPreviewSurface);
+ rawBurstBuilder.removeTarget(mReaderSurface);
+
+ stopPreview();
+ }
+
+ private void performTestRoutine(TestRoutine routine) throws Exception
+ {
+ for (String id : mCameraIds) {
+ try {
+ openDevice(id);
+
+ ArrayList<Integer> supportedRawList = new ArrayList<Integer>(RAW_FORMATS.length);
+ if (!checkCapability(supportedRawList)) {
+ Log.i(TAG, "Capability is not supported on camera " + id
+ + ". Skip the test.");
+ continue;
+ }
+
+ // test each supported RAW format
+ for (int rawFormat : supportedRawList) {
+ Log.i(TAG, "Testing format " + imageFormatToString(rawFormat) + ".");
+
+ // prepare preview and still RAW capture
+ CaptureSetup captureSetup = initCaptureSetupForPreviewAndRaw();
+
+ Size previewCaptureSize = captureSetup.getPreviewCaptureSize();
+ Size rawCaptureSize = captureSetup.getRawCaptureSize();
+
+ CaptureRequest.Builder previewBuilder = captureSetup.getPreviewRequestBuilder();
+ CaptureRequest.Builder rawBurstBuilder = captureSetup.getRawRequestBuilder();
+
+ SimpleCaptureCallback previewCaptureCallback =
+ captureSetup.getPreviewCaptureCallback();
+ SimpleCaptureCallback rawCaptureCallback = captureSetup.getRawCaptureCallback();
+ SimpleImageReaderListener rawReaderListener = captureSetup
+ .getRawReaderListener();
+
+ // start preview and prepare RAW capture
+ prepareCaptureAndStartPreview(previewBuilder, rawBurstBuilder,
+ previewCaptureSize, rawCaptureSize, rawFormat, previewCaptureCallback,
+ MAX_FRAMES_BURST, rawReaderListener);
+
+ // execute test routine
+ routine.execute(rawBurstBuilder, rawCaptureCallback, rawReaderListener,
+ rawFormat);
+
+ // clear out the surface and camera session
+ stopPreviewAndClearSurface(previewBuilder, rawBurstBuilder);
+ closeImageReader();
+ }
+ } finally {
+ closeDevice();
+ }
+ }
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
index 67473e1..dbb609d 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -1310,13 +1310,11 @@
/* test if the explicitly named codec is present on the system */
if (explicitCodecName != null) {
- try {
- MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
- if (codec != null) {
- codec.release();
- add(new Codec(explicitCodecName, null, mediaList));
- }
- } catch (Exception e) {}
+ MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
+ if (codec != null) {
+ codec.release();
+ add(new Codec(explicitCodecName, null, mediaList));
+ }
}
} catch (Throwable t) {
Log.wtf("Constructor failed", t);
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackTest.java b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
index 4f6d27f..9698e99 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
@@ -1396,18 +1396,18 @@
final long MILLISECONDS_PER_SECOND = 1000;
AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR,
TEST_CONF, TEST_FORMAT, bufferSize, TEST_MODE);
- assertEquals(TEST_NAME, track.getState(), AudioTrack.STATE_NO_STATIC_DATA);
+ assertEquals(TEST_NAME, AudioTrack.STATE_NO_STATIC_DATA, track.getState());
// -------- test --------------
// test setLoopPoints and setPosition can be called here.
assertEquals(TEST_NAME,
- track.setPlaybackHeadPosition(bufferFrames/2),
- android.media.AudioTrack.SUCCESS);
+ android.media.AudioTrack.SUCCESS,
+ track.setPlaybackHeadPosition(bufferFrames/2));
assertEquals(TEST_NAME,
+ android.media.AudioTrack.SUCCESS,
track.setLoopPoints(
- 0 /*startInFrames*/, bufferFrames, 10 /*loopCount*/),
- android.media.AudioTrack.SUCCESS);
+ 0 /*startInFrames*/, bufferFrames, 10 /*loopCount*/));
// only need to write once to the static track
switch (TEST_FORMAT) {
case AudioFormat.ENCODING_PCM_8BIT: {
@@ -1415,35 +1415,35 @@
bufferSamples, TEST_SR,
testFrequency, TEST_SWEEP);
assertEquals(TEST_NAME,
- track.write(data, 0 /*offsetInBytes*/, data.length),
- bufferSamples);
+ bufferSamples,
+ track.write(data, 0 /*offsetInBytes*/, data.length));
} break;
case AudioFormat.ENCODING_PCM_16BIT: {
short data[] = createSoundDataInShortArray(
bufferSamples, TEST_SR,
testFrequency, TEST_SWEEP);
assertEquals(TEST_NAME,
- track.write(data, 0 /*offsetInBytes*/, data.length),
- bufferSamples);
+ bufferSamples,
+ track.write(data, 0 /*offsetInBytes*/, data.length));
} break;
case AudioFormat.ENCODING_PCM_FLOAT: {
float data[] = createSoundDataInFloatArray(
bufferSamples, TEST_SR,
testFrequency, TEST_SWEEP);
assertEquals(TEST_NAME,
+ bufferSamples,
track.write(data, 0 /*offsetInBytes*/, data.length,
- AudioTrack.WRITE_BLOCKING),
- bufferSamples);
+ AudioTrack.WRITE_BLOCKING));
} break;
}
- assertEquals(TEST_NAME, track.getState(), AudioTrack.STATE_INITIALIZED);
+ assertEquals(TEST_NAME, AudioTrack.STATE_INITIALIZED, track.getState());
// test setLoopPoints and setPosition can be called here.
assertEquals(TEST_NAME,
- track.setPlaybackHeadPosition(0 /*positionInFrames*/),
- android.media.AudioTrack.SUCCESS);
+ android.media.AudioTrack.SUCCESS,
+ track.setPlaybackHeadPosition(0 /*positionInFrames*/));
assertEquals(TEST_NAME,
- track.setLoopPoints(0 /*startInFrames*/, bufferFrames, TEST_LOOPS),
- android.media.AudioTrack.SUCCESS);
+ android.media.AudioTrack.SUCCESS,
+ track.setLoopPoints(0 /*startInFrames*/, bufferFrames, TEST_LOOPS));
track.play();
Thread.sleep(seconds * MILLISECONDS_PER_SECOND * (TEST_LOOPS + 1));
@@ -1452,7 +1452,7 @@
// Check position after looping. AudioTrack.getPlaybackHeadPosition() returns
// the running count of frames played, not the actual static buffer position.
int position = track.getPlaybackHeadPosition();
- assertEquals(TEST_NAME, position, bufferFrames * (TEST_LOOPS + 1));
+ assertEquals(TEST_NAME, bufferFrames * (TEST_LOOPS + 1), position);
track.stop();
Thread.sleep(WAIT_MSEC);
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 3002ca3..6069ee6 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -28,8 +28,7 @@
public class BuildVersionTest extends TestCase {
private static final String LOG_TAG = "BuildVersionTest";
- private static final Set<String> EXPECTED_RELEASES =
- new HashSet<String>(Arrays.asList("5.0.1", "5.0.2"));
+ private static final Set<String> EXPECTED_RELEASES = new HashSet<String>(Arrays.asList("5.0"));
private static final int EXPECTED_SDK = 21;
private static final String EXPECTED_BUILD_VARIANT = "user";
private static final String EXPECTED_TAG = "release-keys";
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index f3163be..7edd659 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -115,6 +115,25 @@
private static native boolean supportsXattr();
+ /**
+ * ICMP redirects should be disabled.
+ */
+ public void testNoIcmpRedirects() throws IOException {
+ try {
+ assertEquals("ICMP redirects are enabled for IPv4.",
+ "0", getFile("/proc/sys/net/ipv4/conf/all/accept_redirects"));
+ } catch (FileNotFoundException e) {
+ // Odd. The file doesn't exist... Assume we're ok.
+ }
+
+ try {
+ assertEquals("ICMP redirects are enabled for IPv6.",
+ "0", getFile("/proc/sys/net/ipv6/conf/all/accept_redirects"));
+ } catch (FileNotFoundException e) {
+ // Odd. The file doesn't exist... Assume we're ok.
+ }
+ }
+
private String getFile(String filename) throws IOException {
BufferedReader in = null;
try {
diff --git a/tests/tests/speech/Android.mk b/tests/tests/speech/Android.mk
index 6bec012..3ab78b8 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/Android.mk
@@ -27,6 +27,7 @@
LOCAL_PACKAGE_NAME := CtsSpeechTestCases
-LOCAL_SDK_VERSION := current
+# Needed for testing M API
+#LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java b/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
index 5e6bb41..7b5baca 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
@@ -20,12 +20,17 @@
import android.speech.tts.SynthesisRequest;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeechService;
+import android.util.Log;
/**
* Stub implementation of {@link TextToSpeechService}. Used for testing the
* TTS engine API.
*/
public class StubTextToSpeechService extends TextToSpeechService {
+ private static final String LOG_TAG = "StubTextToSpeechService";
+
+ // Object that onSynthesizeText will #wait on, if set to non-null
+ public static volatile Object sSynthesizeTextWait;
@Override
protected String[] onGetLanguage() {
@@ -51,6 +56,18 @@
if (callback.start(16000, AudioFormat.ENCODING_PCM_16BIT, 1) != TextToSpeech.SUCCESS) {
return;
}
+
+ final Object synthesizeTextWait = sSynthesizeTextWait;
+ if (synthesizeTextWait != null) {
+ synchronized (synthesizeTextWait) {
+ try {
+ synthesizeTextWait.wait(10000); // 10s timeout
+ } catch (InterruptedException e) {
+ Log.e(LOG_TAG, "onSynthesizeText wait interrupted", e);
+ }
+ }
+ }
+
byte[] data = { 0x01, 0x2 };
if (callback.audioAvailable(data, 0, data.length) != TextToSpeech.SUCCESS) {
return;
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
index c19f6c0..7425ecf 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
@@ -37,6 +37,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ StubTextToSpeechService.sSynthesizeTextWait = null;
mTts = TextToSpeechWrapper.createTextToSpeechMockWrapper(getContext());
assertNotNull(mTts);
}
@@ -74,6 +75,31 @@
assertTrue("speak() completion timeout", waitForUtterance());
}
+ public void testSpeakStop() throws Exception {
+ final Object synthesizeTextWait = new Object();
+ StubTextToSpeechService.sSynthesizeTextWait = synthesizeTextWait;
+
+ getTts().stop();
+ final int iterations = 20;
+ for (int i = 0; i < iterations; i++) {
+ int result = getTts().speak(UTTERANCE, TextToSpeech.QUEUE_ADD, null,
+ UTTERANCE_ID + Integer.toString(i));
+ assertEquals("speak() failed", TextToSpeech.SUCCESS, result);
+ }
+ getTts().stop();
+
+ // Wake up the Stubs #onSynthesizeSpeech (one that will be stopped in-progress)
+ synchronized (synthesizeTextWait) {
+ synthesizeTextWait.notify();
+ }
+
+ for (int i = 0; i < iterations; i++) {
+ assertTrue("speak() stop callback timeout", mTts.waitForStop(
+ UTTERANCE_ID + Integer.toString(i)));
+ }
+ }
+
+
public void testMediaPlayerFails() throws Exception {
File sampleFile = new File(Environment.getExternalStorageDirectory(), "notsound.wav");
try {
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
index 69acdd0..c83304c 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
@@ -124,6 +124,22 @@
assertTrue("speak() completion timeout", waitForUtterance());
}
+
+ public void testSpeakStop() throws Exception {
+ getTts().stop();
+ final int iterations = 20;
+ for (int i = 0; i < iterations; i++) {
+ int result = getTts().speak(SAMPLE_TEXT, TextToSpeech.QUEUE_ADD, null,
+ UTTERANCE_ID + Integer.toString(i));
+ assertEquals("speak() failed", TextToSpeech.SUCCESS, result);
+ }
+ getTts().stop();
+ for (int i = 0; i < iterations; i++) {
+ assertTrue("speak() stop callback timeout", mTts.waitForStop(
+ UTTERANCE_ID + Integer.toString(i)));
+ }
+ }
+
public void testGetEnginesIncludesDefault() throws Exception {
if (mTts == null) {
return;
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
index f0d55bf..9d460e2 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
@@ -19,9 +19,10 @@
import android.media.MediaPlayer;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
-import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
+import android.speech.tts.UtteranceProgressListener;
import android.util.Log;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
@@ -65,7 +66,7 @@
if (!mInitListener.waitForInit()) {
return false;
}
- mTts.setOnUtteranceCompletedListener(mUtteranceListener);
+ mTts.setOnUtteranceProgressListener(mUtteranceListener);
return true;
}
@@ -73,6 +74,10 @@
return mUtteranceListener.waitForComplete(utteranceId);
}
+ public boolean waitForStop(String utteranceId) throws InterruptedException {
+ return mUtteranceListener.waitForStop(utteranceId);
+ }
+
public TextToSpeech getTts() {
return mTts;
}
@@ -139,12 +144,16 @@
/**
* Listener for waiting for utterance completion.
*/
- private static class UtteranceWaitListener implements OnUtteranceCompletedListener {
+ private static class UtteranceWaitListener extends UtteranceProgressListener {
private final Lock mLock = new ReentrantLock();
private final Condition mDone = mLock.newCondition();
+ private final HashSet<String> mStartedUtterances = new HashSet<String>();
+ private final HashSet<String> mStoppedUtterances = new HashSet<String>();
+ private final HashMap<String, Integer> mErredUtterances = new HashMap<String, Integer>();
private final HashSet<String> mCompletedUtterances = new HashSet<String>();
- public void onUtteranceCompleted(String utteranceId) {
+ @Override
+ public void onDone(String utteranceId) {
mLock.lock();
try {
mCompletedUtterances.add(utteranceId);
@@ -154,6 +163,49 @@
}
}
+ @Override
+ public void onError(String utteranceId) {
+ mLock.lock();
+ try {
+ mErredUtterances.put(utteranceId, -1);
+ mDone.signal();
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ @Override
+ public void onError(String utteranceId, int errorCode) {
+ mLock.lock();
+ try {
+ mErredUtterances.put(utteranceId, errorCode);
+ mDone.signal();
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ @Override
+ public void onStart(String utteranceId) {
+ mLock.lock();
+ try {
+ mStartedUtterances.add(utteranceId);
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ @Override
+ public void onStop(String utteranceId, boolean isStarted) {
+ mLock.lock();
+ try {
+ mStoppedUtterances.add(utteranceId);
+ mDone.signal();
+ } finally {
+ mLock.unlock();
+ }
+ }
+
public boolean waitForComplete(String utteranceId)
throws InterruptedException {
long timeOutNanos = TimeUnit.MILLISECONDS.toNanos(TTS_INIT_MAX_WAIT_TIME);
@@ -170,6 +222,23 @@
mLock.unlock();
}
}
+
+ public boolean waitForStop(String utteranceId)
+ throws InterruptedException {
+ long timeOutNanos = TimeUnit.MILLISECONDS.toNanos(TTS_INIT_MAX_WAIT_TIME);
+ mLock.lock();
+ try {
+ while (!mStoppedUtterances.remove(utteranceId)) {
+ if (timeOutNanos <= 0) {
+ return false;
+ }
+ timeOutNanos = mDone.awaitNanos(timeOutNanos);
+ }
+ return true;
+ } finally {
+ mLock.unlock();
+ }
+ }
}
/**
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
new file mode 100644
index 0000000..5b88525
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.telephony.cts;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.telephony.CellInfo;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import java.util.List;
+
+/**
+ * Test TelephonyManager.getAllCellInfo()
+ * <p>
+ * TODO(chesnutt): test onCellInfoChanged() once the implementation
+ * of async callbacks is complete (see http://b/13788638)
+ */
+public class CellInfoTest extends AndroidTestCase{
+ private final Object mLock = new Object();
+ private TelephonyManager mTelephonyManager;
+ private static ConnectivityManager mCm;
+ private static final String TAG = "android.telephony.cts.CellInfoTest";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTelephonyManager =
+ (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
+ mCm = (ConnectivityManager)getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ }
+
+ public void testCellInfo() throws Throwable {
+ if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
+ Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
+ return;
+ }
+
+ // getAllCellInfo should never return null, and there should
+ // be at least one entry.
+ List<CellInfo> allCellInfo = mTelephonyManager.getAllCellInfo();
+ assertNotNull("TelephonyManager.getAllCellInfo() returned NULL!", allCellInfo);
+ assertTrue("TelephonyManager.getAllCellInfo() returned zero-length list!",
+ allCellInfo.size() > 0);
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
index c1f5757..9205f0e 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
@@ -60,6 +60,14 @@
return;
}
+ // getCellLocation should never return null,
+ // but that is allowed if the cell network type
+ // is LTE (since there is no LteCellLocation class)
+ if (mTelephonyManager.getNetworkType() != TelephonyManager.NETWORK_TYPE_LTE) {
+ assertNotNull("TelephonyManager.getCellLocation() returned null!",
+ mTelephonyManager.getCellLocation());
+ }
+
CellLocation cl = CellLocation.getEmpty();
if (cl instanceof GsmCellLocation) {
GsmCellLocation gcl = (GsmCellLocation) cl;
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
index c612886..856b4aa 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
@@ -319,8 +319,6 @@
assertFalse(anyDeleted.get());
}
- /*
- TODO: uncomment when acceptThirdPartyCookies implementation lands
public void testThirdPartyCookie() throws Throwable {
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
@@ -377,7 +375,6 @@
mOnUiThread.getSettings().setJavaScriptEnabled(false);
}
}
- */
public void testb3167208() throws Exception {
if (!NullWebViewUtils.isWebViewAvailable()) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 1e22acc..f72a70d 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -122,6 +122,11 @@
*/
private static final long SCROLL_WAIT_INTERVAL_MS = 200;
+ /**
+ * Epsilon used in page scale value comparisons.
+ */
+ private static final float PAGE_SCALE_EPSILON = 0.0001f;
+
private WebView mWebView;
private CtsTestServer mWebServer;
private WebViewOnUiThread mOnUiThread;
@@ -330,7 +335,7 @@
// that a scale change does *not* happen.
Thread.sleep(500);
currScale = mOnUiThread.getScale();
- assertEquals(currScale, previousScale);
+ assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
assertTrue(mOnUiThread.zoomOut());
previousScale = currScale;
@@ -354,7 +359,7 @@
// that a scale change does *not* happen.
Thread.sleep(500);
currScale = mOnUiThread.getScale();
- assertEquals(currScale, previousScale);
+ assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
mOnUiThread.zoomBy(1.25f);
previousScale = currScale;
@@ -378,7 +383,7 @@
// that a scale change does *not* happen.
Thread.sleep(500);
currScale = mOnUiThread.getScale();
- assertEquals(currScale, previousScale);
+ assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
mOnUiThread.zoomBy(0.8f);
previousScale = currScale;
@@ -402,7 +407,7 @@
// that a scale change does *not* happen.
Thread.sleep(500);
currScale = mOnUiThread.getScale();
- assertEquals(currScale, previousScale);
+ assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
}
@UiThreadTest
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 7e8a19e..2ee649d 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 = "5.0_r1.94";
+ public static final String CTS_BUILD_VERSION = "5.0_r1.91";
/**
* {@inheritDoc}
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 4d04e1a..b2ab4d6 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -158,6 +158,7 @@
# CTS Stable plan
plan = tools.TestPlan(packages)
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-stable')
@@ -166,6 +167,7 @@
plan = tools.TestPlan(packages)
plan.Exclude('.*')
plan.Include(r'com\.android\.cts\.browserbench')
+ plan.Include(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.Include(package+'$')
plan.IncludeTests(package, test_list)
@@ -173,7 +175,6 @@
small_tests = BuildAospSmallSizeTestList()
medium_tests = BuildAospMediumSizeTestList()
- new_test_packages = BuildCtsVettedNewPackagesList()
# CTS - sub plan for public, small size tests
plan = tools.TestPlan(packages)
@@ -181,6 +182,7 @@
for package, test_list in small_tests.iteritems():
plan.Include(package+'$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-kitkat-small')
@@ -191,6 +193,7 @@
for package, test_list in medium_tests.iteritems():
plan.Include(package+'$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-kitkat-medium')
@@ -200,6 +203,7 @@
plan.Exclude('.*')
plan.Include(r'android\.hardware$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-hardware')
@@ -210,6 +214,7 @@
plan.Include(r'android\.media$')
plan.Include(r'android\.view$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-media')
@@ -219,48 +224,27 @@
plan.Exclude('.*')
plan.Include(r'android\.mediastress$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-mediastress')
- # CTS - sub plan for new tests that is vetted for L launch
- plan = tools.TestPlan(packages)
- plan.Exclude('.*')
- for package, test_list in new_test_packages.iteritems():
- plan.Include(package+'$')
- plan.Exclude(r'com\.android\.cts\.browserbench')
- for package, test_list in flaky_tests.iteritems():
- plan.ExcludeTests(package, test_list)
- self.__WritePlan(plan, 'CTS-l-tests')
-
- #CTS - sub plan for new test packages added for staging
+ # CTS - sub plan for new test packages added for staging
plan = tools.TestPlan(packages)
for package, test_list in small_tests.iteritems():
plan.Exclude(package+'$')
for package, test_list in medium_tests.iteritems():
plan.Exclude(package+'$')
- for package, tests_list in new_test_packages.iteritems():
- plan.Exclude(package+'$')
plan.Exclude(r'android\.hardware$')
plan.Exclude(r'android\.media$')
plan.Exclude(r'android\.view$')
plan.Exclude(r'android\.mediastress$')
plan.Exclude(r'com\.android\.cts\.browserbench')
+ plan.Exclude(r'com\.android\.cts\.filesystemperf\.RandomRWTest$')
for package, test_list in flaky_tests.iteritems():
plan.ExcludeTests(package, test_list)
self.__WritePlan(plan, 'CTS-staging')
- plan = tools.TestPlan(packages)
- plan.Exclude('.*')
- plan.Include(r'com\.drawelements\.')
- self.__WritePlan(plan, 'CTS-DEQP')
-
- plan = tools.TestPlan(packages)
- plan.Exclude('.*')
- plan.Include(r'android\.webgl')
- self.__WritePlan(plan, 'CTS-webview')
-
-
def BuildAospMediumSizeTestList():
""" Construct a defaultdic that lists package names of medium tests
already published to aosp. """
@@ -342,42 +326,9 @@
'com.android.cts.videoperf' : [],
'zzz.android.monkey' : []}
-def BuildCtsVettedNewPackagesList():
- """ Construct a defaultdict that maps package names that is vetted for L. """
- return {
- 'android.JobScheduler' : [],
- 'android.core.tests.libcore.package.harmony_annotation' : [],
- 'android.core.tests.libcore.package.harmony_beans' : [],
- 'android.core.tests.libcore.package.harmony_java_io' : [],
- 'android.core.tests.libcore.package.harmony_java_lang' : [],
- 'android.core.tests.libcore.package.harmony_java_math' : [],
- 'android.core.tests.libcore.package.harmony_java_net' : [],
- 'android.core.tests.libcore.package.harmony_java_nio' : [],
- 'android.core.tests.libcore.package.harmony_java_util' : [],
- 'android.core.tests.libcore.package.harmony_java_text' : [],
- 'android.core.tests.libcore.package.harmony_javax_security' : [],
- 'android.core.tests.libcore.package.harmony_logging' : [],
- 'android.core.tests.libcore.package.harmony_prefs' : [],
- 'android.core.tests.libcore.package.harmony_sql' : [],
- 'android.core.tests.libcore.package.jsr166' : [],
- 'android.core.tests.libcore.package.okhttp' : [],
- 'android.display' : [],
- 'android.host.theme' : [],
- 'android.jdwp' : [],
- 'android.location2' : [],
- 'android.print' : [],
- 'android.renderscriptlegacy' : [],
- 'android.signature' : [],
- 'android.tv' : [],
- 'android.uiautomation' : [],
- 'android.uirendering' : [],
- 'android.webgl' : [],
- 'com.drawelements.deqp.gles3' : [],
- 'com.drawelements.deqp.gles31' : []}
-
def BuildCtsFlakyTestList():
""" Construct a defaultdict that maps package name to a list of tests
- that are known to be flaky in the lab or not passing on userdebug builds. """
+ that are known to be flaky. """
return {
'android.app' : [
'cts.ActivityManagerTest#testIsRunningInTestHarness',],
@@ -412,11 +363,7 @@
'cts.SELinuxDomainTest#testSuDomain',
'cts.SELinuxHostTest#testAllEnforcing',],
'android.webkit' : [
- 'cts.WebViewClientTest#testOnUnhandledKeyEvent',],
- 'com.android.cts.filesystemperf' : [
- 'RandomRWTest#testRandomRead',
- 'RandomRWTest#testRandomUpdate',],
- '' : []}
+ 'cts.WebViewClientTest#testOnUnhandledKeyEvent',]}
def LogGenerateDescription(name):
print 'Generating test description for package %s' % name
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 88f2a53..059ac75 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -14,6 +14,29 @@
LOCAL_PATH := $(call my-dir)
+# test dex library
+# ============================================================
+include $(CLEAR_VARS)
+
+# custom variables used to generate test description. do not touch!
+LOCAL_SRC_FILES := $(call all-java-files-under, src/dot)
+
+LOCAL_MODULE := cts-tf-dalvik-lib
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LIBRARIES := junit-hostdex
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+
+include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
+
+cts-tf-dalvik-lib.jack := $(full_classes_jack)
+
+private_jill_jarjar_asm := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,jill-jarjar-asm.jar)
+$(private_jill_jarjar_asm) : PRIVATE_JARJAR_RULES := $(LOCAL_PATH)/jill-jarjar-rules.txt
+$(private_jill_jarjar_asm) : $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,jill.jar) | $(JARJAR)
+ @echo JarJar: $@
+ $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+
# buildutil java library
# ============================================================
include $(CLEAR_VARS)
@@ -29,16 +52,53 @@
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+LOCAL_JAVA_LIBRARIES += jack
+
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR) $(private_jill_jarjar_asm)
include $(BUILD_HOST_JAVA_LIBRARY)
# Buid android.core.vm-tests-tf.jar
# ============================================================
#
+
intermediates := $(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
vmteststf_jar := $(intermediates)/android.core.vm-tests-tf.jar
vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit.jar)
+vmteststf_dep_jars += $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, jack.jar)
+vmteststf_dep_jars += $(private_jill_jarjar_asm)
+
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(DEFAULT_JACK_VM_ARGS)
+ifneq ($(ANDROID_JACK_VM_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(ANDROID_JACK_VM_ARGS)
+endif
+ifneq ($(LOCAL_JACK_VM_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(LOCAL_JACK_VM_ARGS)
+endif
+
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(DEFAULT_JACK_EXTRA_ARGS)
+ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
+endif
+ifneq ($(LOCAL_JACK_EXTRA_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
+endif
+
+$(vmteststf_jar): PRIVATE_JACK_VM := $(DEFAULT_JACK_VM)
+ifneq ($(strip $(ANDROID_JACK_VM)),)
+$(vmteststf_jar): PRIVATE_JACK_VM := $(ANDROID_JACK_VM)
+endif
+
+ifeq ($(strip $(LOCAL_USE_JACK)),true)
+ vmteststf_dep_jars += $(cts-tf-dalvik-lib.jack)
+endif
+
+$(intermediates)/junit.jack:$(LOCAL_PATH)/lib/junit.jar | $(JILL_JAR) $(JACK_JAR)
+ $(transform-jar-to-jack)
+
+$(intermediates)/tradefed-prebuilt.jack:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar | $(JILL_JAR) $(JACK_JAR)
+ $(transform-jar-to-jack)
+
$(vmteststf_jar): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
$(vmteststf_jar): PRIVATE_LIB_FOLDER := $(LOCAL_PATH)/lib
$(vmteststf_jar): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
@@ -47,7 +107,8 @@
$(vmteststf_jar): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
$(vmteststf_jar): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
$(vmteststf_jar): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
-$(vmteststf_jar) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+ifneq ($(strip $(LOCAL_USE_JACK)),true)
+$(vmteststf_jar) : $(vmteststf_dep_jars) $(JACK_JAR) $(JILL_JAR) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
# generated and compile the host side junit tests
@@ -62,6 +123,26 @@
$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+else # LOCAL_USE_JACK
+$(vmteststf_jar) : $(vmteststf_dep_jars) $(JACK_JAR) $(JILL_JAR) out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jack $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar $(LOCAL_PATH)/lib/junit.jar $(intermediates)/tradefed-prebuilt.jack $(intermediates)/junit.jack
+ $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
+ $(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
+ # generated and compile the host side junit tests
+ @echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
+ $(hide) java -cp $(PRIVATE_CLASS_PATH) util.build.JackBuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+ out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jack:$(cts-tf-dalvik-lib.jack):$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar:$(LOCAL_PATH)/lib/junit.jar:$(PRIVATE_INTERMEDIATES)/junit.jack:$(PRIVATE_INTERMEDIATES)/tradefed-prebuilt.jack \
+ $(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
+ @echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
+ $(hide) jar -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
+ $(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
+ $(hide) $(JILL) --output $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar
+ $(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
+ $(hide) $(call call-jack,$(PRIVATE_JACK_VM),$(PRIVATE_JACK_VM_ARGS),$(PRIVATE_JACK_EXTRA_ARGS)) --output-dex $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+ $(if $(NO_OPTIMIZE_DX), -D jack.dex.optimize "false") --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
+ $(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
+ $(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
+ $(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+endif # LOCAL_USE_JACK
# Clean up temp vars
intermediates :=
diff --git a/tools/vm-tests-tf/jill-jarjar-rules.txt b/tools/vm-tests-tf/jill-jarjar-rules.txt
new file mode 100644
index 0000000..ee6f403
--- /dev/null
+++ b/tools/vm-tests-tf/jill-jarjar-rules.txt
@@ -0,0 +1 @@
+rule org.objectweb.** com.android.jill.@0
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index c772c33..4ce8c38 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -78,6 +78,7 @@
private int testClassCnt = 0;
private int testMethodsCnt = 0;
+ private boolean useJack;
/*
* using a linked hashmap to keep the insertion order for iterators.
@@ -101,39 +102,47 @@
*/
public static void main(String[] args) throws IOException {
- if (args.length > 5) {
- JAVASRC_FOLDER = args[0];
- OUTPUT_FOLDER = args[1];
- CLASS_PATH = args[2];
- MAIN_SRC_OUTPUT_FOLDER = args[3];
- CLASSES_OUTPUT_FOLDER = MAIN_SRC_OUTPUT_FOLDER + "/classes";
-
- COMPILED_CLASSES_FOLDER = args[4];
-
- HOSTJUNIT_SRC_OUTPUT_FOLDER = args[5];
- HOSTJUNIT_CLASSES_OUTPUT_FOLDER = HOSTJUNIT_SRC_OUTPUT_FOLDER + "/classes";
-
- if (args.length > 6) {
- // optional: restrict to e.g. "opcodes.add_double"
- restrictTo = args[6];
- System.out.println("restricting build to: " + restrictTo);
- }
-
- } else {
- System.out.println("usage: java-src-folder output-folder classpath " +
- "generated-main-files compiled_output generated-main-files " +
- "[restrict-to-opcode]");
- System.exit(-1);
- }
+ parseArgs(args);
long start = System.currentTimeMillis();
- BuildDalvikSuite cat = new BuildDalvikSuite();
+ BuildDalvikSuite cat = new BuildDalvikSuite(false);
cat.compose();
long end = System.currentTimeMillis();
System.out.println("elapsed seconds: " + (end - start) / 1000);
}
+ public static void parseArgs(String[] args) {
+ if (args.length > 5) {
+ JAVASRC_FOLDER = args[0];
+ OUTPUT_FOLDER = args[1];
+ CLASS_PATH = args[2];
+ MAIN_SRC_OUTPUT_FOLDER = args[3];
+ CLASSES_OUTPUT_FOLDER = MAIN_SRC_OUTPUT_FOLDER + "/classes";
+
+ COMPILED_CLASSES_FOLDER = args[4];
+
+ HOSTJUNIT_SRC_OUTPUT_FOLDER = args[5];
+ HOSTJUNIT_CLASSES_OUTPUT_FOLDER = HOSTJUNIT_SRC_OUTPUT_FOLDER + "/classes";
+
+ if (args.length > 6) {
+ // optional: restrict to e.g. "opcodes.add_double"
+ restrictTo = args[6];
+ System.out.println("restricting build to: " + restrictTo);
+ }
+
+ } else {
+ System.out.println("usage: java-src-folder output-folder classpath " +
+ "generated-main-files compiled_output generated-main-files " +
+ "[restrict-to-opcode]");
+ System.exit(-1);
+ }
+ }
+
+ public BuildDalvikSuite(boolean useJack) {
+ this.useJack = useJack;
+ }
+
public void compose() throws IOException {
System.out.println("Collecting all junit tests...");
new TestRunner() {
@@ -182,19 +191,21 @@
li.add(method);
}
private String curJunitFileName = null;
+ private String curJunitName = null;
private String curJunitFileData = "";
- private JavacBuildStep javacHostJunitBuildStep;
+ private SourceBuildStep hostJunitBuildStep;
private void flushHostJunitFile() {
if (curJunitFileName != null) {
File toWrite = new File(curJunitFileName);
String absPath = toWrite.getAbsolutePath();
// add to java source files for later compilation
- javacHostJunitBuildStep.addSourceFile(absPath);
+ hostJunitBuildStep.addSourceFile(absPath);
// write file
curJunitFileData += "\n}\n";
writeToFileMkdir(toWrite, curJunitFileData);
+
curJunitFileName = null;
curJunitFileData = "";
}
@@ -267,11 +278,11 @@
String datafileContent = "";
Set<BuildStep> targets = new TreeSet<BuildStep>();
- javacHostJunitBuildStep = new JavacBuildStep(HOSTJUNIT_CLASSES_OUTPUT_FOLDER, CLASS_PATH);
+ SourceBuildStep srcBuildStep;
+ hostJunitBuildStep = new JavacBuildStep(
+ HOSTJUNIT_CLASSES_OUTPUT_FOLDER, CLASS_PATH);
-
- JavacBuildStep javacBuildStep = new JavacBuildStep(
- CLASSES_OUTPUT_FOLDER, CLASS_PATH);
+ srcBuildStep = new JavacBuildStep(CLASSES_OUTPUT_FOLDER, CLASS_PATH);
for (Entry<String, List<String>> entry : map.entrySet()) {
@@ -334,19 +345,25 @@
" public static void main(String[] args) throws Exception {" +
methodContent + "\n}\n";
- String fileName = getFileName(pName, method, ".java");
File sourceFile = getFileFromPackage(pName, method);
- File classFile = new File(CLASSES_OUTPUT_FOLDER + "/" +
- getFileName(pName, method, ".class"));
- // if (sourceFile.lastModified() > classFile.lastModified()) {
writeToFile(sourceFile, content);
- javacBuildStep.addSourceFile(sourceFile.getAbsolutePath());
+ if (useJack) {
+ File jackFile = new File(CLASSES_OUTPUT_FOLDER + "/" +
+ getFileName(pName, method, ".jack"));
+ JackBuildStep step = new JackBuildStep(jackFile.getAbsolutePath(), CLASS_PATH);
+ step.addSourceFile(sourceFile.getAbsolutePath());
+ if (!step.build()) {
+ System.out.println("main src dalvik-cts-buildutil build step failed");
+ System.exit(1);
+ }
+ } else {
+ srcBuildStep.addSourceFile(sourceFile.getAbsolutePath());
+ }
BuildStep dexBuildStep = generateDexBuildStep(
- CLASSES_OUTPUT_FOLDER, getFileName(pName, method, ""));
+ CLASSES_OUTPUT_FOLDER, getFileName(pName, method, ""), null);
targets.add(dexBuildStep);
- // }
// prepare the entry in the data file for the bash script.
@@ -442,22 +459,23 @@
scriptDataDir.mkdirs();
writeToFile(new File(scriptDataDir, "scriptdata"), datafileContent);
- if (!javacHostJunitBuildStep.build()) {
+ if (!hostJunitBuildStep.build()) {
System.out.println("main javac cts-host-hostjunit-classes build step failed");
System.exit(1);
}
- if (javacBuildStep.build()) {
- for (BuildStep buildStep : targets) {
- if (!buildStep.build()) {
- System.out.println("building failed. buildStep: " +
- buildStep.getClass().getName() + ", " + buildStep);
- System.exit(1);
- }
+ if (!useJack) {
+ if (!srcBuildStep.build()) {
+ System.out.println("main src dalvik-cts-buildutil build step failed");
+ System.exit(1);
}
- } else {
- System.out.println("main javac dalvik-cts-buildutil build step failed");
- System.exit(1);
+ }
+ for (BuildStep buildStep : targets) {
+ if (!buildStep.build()) {
+ System.out.println("building failed. buildStep: " +
+ buildStep.getClass().getName() + ", " + buildStep);
+ System.exit(1);
+ }
}
}
@@ -514,19 +532,37 @@
return;
}
- if (new File(sourceFolder, fileName + ".java").exists()) {
-
+ File srcFile = new File(sourceFolder, fileName + ".java");
+ if (srcFile.exists()) {
+ JackBuildStep jackBuildStep = null;
+ if (useJack) {
+ jackBuildStep = new JackBuildStep(
+ COMPILED_CLASSES_FOLDER + File.separator + fileName + ".jack",
+ CLASS_PATH);
+ jackBuildStep.addSourceFile(srcFile.getAbsolutePath());
+ }
BuildStep dexBuildStep = generateDexBuildStep(
- COMPILED_CLASSES_FOLDER, fileName);
+ COMPILED_CLASSES_FOLDER, fileName, jackBuildStep);
targets.add(dexBuildStep);
return;
}
try {
if (Class.forName(dependentTestClassName) != null) {
+ JillBuildStep jillBuildStep = null;
+ if (useJack) {
+ BuildStep.BuildFile classFile = new BuildStep.BuildFile(
+ COMPILED_CLASSES_FOLDER, fileName + ".class");
+ BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
+ COMPILED_CLASSES_FOLDER,
+ fileName + ".jack");
+
+ jillBuildStep = new JillBuildStep(classFile,
+ jackFile);
+ }
BuildStep dexBuildStep = generateDexBuildStep(
- COMPILED_CLASSES_FOLDER, fileName);
+ COMPILED_CLASSES_FOLDER, fileName, jillBuildStep);
targets.add(dexBuildStep);
return;
}
@@ -539,24 +575,50 @@
}
private BuildStep generateDexBuildStep(String classFileFolder,
- String classFileName) {
- BuildStep.BuildFile classFile = new BuildStep.BuildFile(
- classFileFolder, classFileName + ".class");
+ String classFileName, BuildStep dependency) {
+ if (!useJack) {
+ BuildStep.BuildFile classFile = new BuildStep.BuildFile(
+ classFileFolder, classFileName + ".class");
- BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(OUTPUT_FOLDER,
- classFileName + "_tmp.jar");
+ BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(
+ OUTPUT_FOLDER,
+ classFileName + "_tmp.jar");
- JarBuildStep jarBuildStep = new JarBuildStep(classFile, classFileName +
- ".class", tmpJarFile, false);
+ JarBuildStep jarBuildStep = new JarBuildStep(classFile,
+ classFileName + ".class", tmpJarFile, false);
- BuildStep.BuildFile outputFile = new BuildStep.BuildFile(OUTPUT_FOLDER,
- classFileName + ".jar");
+ if (dependency != null) {
+ jarBuildStep.addChild(dependency);
+ }
- DexBuildStep dexBuildStep = new DexBuildStep(tmpJarFile, outputFile,
- true);
+ BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
+ OUTPUT_FOLDER,
+ classFileName + ".jar");
- dexBuildStep.addChild(jarBuildStep);
- return dexBuildStep;
+ DxBuildStep dexBuildStep = new DxBuildStep(tmpJarFile,
+ outputFile,
+ true);
+
+ dexBuildStep.addChild(jarBuildStep);
+ return dexBuildStep;
+ } else {
+ BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
+ classFileFolder, classFileName + ".jack");
+
+ BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
+ OUTPUT_FOLDER,
+ classFileName + ".jar");
+
+ JackDexBuildStep dexBuildStep = new JackDexBuildStep(jackFile,
+ outputFile,
+ true);
+
+ if (dependency != null) {
+ dexBuildStep.addChild(dependency);
+ }
+ return dexBuildStep;
+
+ }
}
@@ -747,7 +809,7 @@
private void writeToFile(File file, String content) {
try {
- if (file.length() == content.length()) {
+ if (file.exists() && file.length() == content.length()) {
FileReader reader = new FileReader(file);
char[] charContents = new char[(int) file.length()];
reader.read(charContents);
diff --git a/tools/vm-tests-tf/src/util/build/DexBuildStep.java b/tools/vm-tests-tf/src/util/build/DxBuildStep.java
similarity index 93%
rename from tools/vm-tests-tf/src/util/build/DexBuildStep.java
rename to tools/vm-tests-tf/src/util/build/DxBuildStep.java
index 6aba51c..6e347b2 100644
--- a/tools/vm-tests-tf/src/util/build/DexBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/DxBuildStep.java
@@ -19,11 +19,11 @@
import com.android.dx.command.dexer.Main;
import java.io.IOException;
-public class DexBuildStep extends BuildStep {
+public class DxBuildStep extends BuildStep {
private final boolean deleteInputFileAfterBuild;
- DexBuildStep(BuildFile inputFile, BuildFile outputFile,
+ DxBuildStep(BuildFile inputFile, BuildFile outputFile,
boolean deleteInputFileAfterBuild) {
super(inputFile, outputFile);
this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
@@ -71,7 +71,7 @@
@Override
public boolean equals(Object obj) {
if (super.equals(obj)) {
- DexBuildStep other = (DexBuildStep) obj;
+ DxBuildStep other = (DxBuildStep) obj;
return inputFile.equals(other.inputFile)
&& outputFile.equals(other.outputFile);
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
new file mode 100644
index 0000000..a508e5b
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 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 util.build;
+
+import java.io.IOException;
+
+public class JackBuildDalvikSuite {
+
+ public static void main(String[] args) throws IOException {
+
+ BuildDalvikSuite.parseArgs(args);
+
+ long start = System.currentTimeMillis();
+ BuildDalvikSuite cat = new BuildDalvikSuite(true);
+ cat.compose();
+ long end = System.currentTimeMillis();
+
+ System.out.println("elapsed seconds: " + (end - start) / 1000);
+ }
+}
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildStep.java b/tools/vm-tests-tf/src/util/build/JackBuildStep.java
new file mode 100644
index 0000000..9e93475
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackBuildStep.java
@@ -0,0 +1,91 @@
+/*
+ * 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 util.build;
+
+import com.android.jack.Jack;
+import com.android.jack.Main;
+import com.android.jack.Options;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class JackBuildStep extends SourceBuildStep {
+
+ private final String destPath;
+ private final String classPath;
+ private final Set<String> sourceFiles = new HashSet<String>();
+
+ public JackBuildStep(String destPath, String classPath) {
+ this.destPath = destPath;
+ this.classPath = classPath;
+ }
+
+ @Override
+ public void addSourceFile(String sourceFile) {
+ sourceFiles.add(sourceFile);
+ }
+
+ @Override
+ boolean build() {
+ if (super.build()) {
+ if (sourceFiles.isEmpty()) {
+ return true;
+ }
+
+ File outDir = new File(destPath).getParentFile();
+ if (!outDir.exists() && !outDir.mkdirs()) {
+ System.err.println("failed to create output dir: "
+ + outDir.getAbsolutePath());
+ return false;
+ }
+ List<String> commandLine = new ArrayList(4 + sourceFiles.size());
+ commandLine.add("--classpath");
+ commandLine.add(classPath);
+ commandLine.add("--output-jack");
+ commandLine.add(destPath);
+ commandLine.addAll(sourceFiles);
+
+ try {
+ Options options = Main.parseCommandLine(commandLine);
+ Jack.run(options);
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (super.equals(obj)) {
+ JackBuildStep other = (JackBuildStep) obj;
+ return destPath.equals(other.destPath) && classPath.equals(other.classPath)
+ && sourceFiles.equals(other.sourceFiles);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return destPath.hashCode() ^ classPath.hashCode() ^ sourceFiles.hashCode();
+ }
+}
diff --git a/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java b/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
new file mode 100644
index 0000000..8d9771c
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 util.build;
+
+import com.android.jack.Jack;
+import com.android.jack.Main;
+import com.android.jack.Options;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JackDexBuildStep extends BuildStep {
+
+ private final boolean deleteInputFileAfterBuild;
+
+ JackDexBuildStep(BuildFile inputFile, BuildFile outputFile,
+ boolean deleteInputFileAfterBuild) {
+ super(inputFile, outputFile);
+ this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
+ }
+
+ @Override
+ boolean build() {
+
+ if (super.build()) {
+ String outputFilePath = outputFile.fileName.getAbsolutePath();
+ if (outputFilePath.endsWith(".dex")) {
+ throw new AssertionError(
+ "DexBuildStep does not support dex output outside of an archive");
+ }
+
+ File outDir = outputFile.fileName.getParentFile();
+ if (!outDir.exists() && !outDir.mkdirs()) {
+ System.err.println("failed to create output dir: "
+ + outDir.getAbsolutePath());
+ return false;
+ }
+
+ List<String> commandLine = new ArrayList<String>(4);
+ commandLine.add("--output-dex-zip");
+ commandLine.add(outputFilePath);
+ commandLine.add("--import");
+ commandLine.add(inputFile.fileName.getAbsolutePath());
+
+ try {
+ Options options = Main.parseCommandLine(commandLine);
+ Jack.run(options);
+ if (deleteInputFileAfterBuild) {
+ inputFile.fileName.delete();
+ }
+ return true;
+ } catch (Throwable ex) {
+ System.err.println("exception while dexing "
+ + inputFile.fileName.getAbsolutePath() + " to "
+ + outputFile.fileName.getAbsolutePath());
+ ex.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return inputFile.hashCode() ^ outputFile.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (super.equals(obj)) {
+ JackDexBuildStep other = (JackDexBuildStep) obj;
+
+ return inputFile.equals(other.inputFile)
+ && outputFile.equals(other.outputFile);
+ }
+ return false;
+ }
+
+
+}
diff --git a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
index 7d7033f..d08a2c6 100644
--- a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
@@ -23,7 +23,7 @@
import java.util.HashSet;
import java.util.Set;
-public class JavacBuildStep extends BuildStep {
+public class JavacBuildStep extends SourceBuildStep {
private final String destPath;
private final String classPath;
@@ -32,12 +32,13 @@
this.destPath = destPath;
this.classPath = classPath;
}
-
+
+ @Override
public void addSourceFile(String sourceFile)
{
sourceFiles.add(sourceFile);
}
-
+
@Override
boolean build() {
if (super.build())
@@ -46,7 +47,7 @@
{
return true;
}
-
+
File destFile = new File(destPath);
if (!destFile.exists() && !destFile.mkdirs())
{
@@ -59,13 +60,12 @@
commandLine[1] = classPath;
commandLine[2] = "-d";
commandLine[3] = destPath;
-
+
String[] files = new String[sourceFiles.size()];
sourceFiles.toArray(files);
-
+
System.arraycopy(files, 0, commandLine, args, files.length);
-
-
+
return Main.compile(commandLine, new PrintWriter(System.err)) == 0;
}
return false;
@@ -73,17 +73,16 @@
@Override
public boolean equals(Object obj) {
- // TODO Auto-generated method stub
if (super.equals(obj))
{
JavacBuildStep other = (JavacBuildStep) obj;
- return destPath.equals(other.destPath)
+ return destPath.equals(other.destPath)
&& classPath.equals(other.classPath)
&& sourceFiles.equals(other.sourceFiles);
}
return false;
}
-
+
@Override
public int hashCode() {
return destPath.hashCode() ^ classPath.hashCode() ^ sourceFiles.hashCode();
diff --git a/tools/vm-tests-tf/src/util/build/JillBuildStep.java b/tools/vm-tests-tf/src/util/build/JillBuildStep.java
new file mode 100644
index 0000000..aff3bb0
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JillBuildStep.java
@@ -0,0 +1,74 @@
+/*
+ * 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 util.build;
+
+import com.android.jill.Main;
+import com.android.jill.Options;
+
+import java.io.File;
+
+public class JillBuildStep extends BuildStep {
+
+ JillBuildStep(BuildFile inputFile, BuildFile outputFile) {
+ super(inputFile, outputFile);
+ }
+
+ @Override
+ boolean build() {
+ if (super.build()) {
+
+ File outDir = outputFile.fileName.getParentFile();
+ if (!outDir.exists() && !outDir.mkdirs()) {
+ System.err.println("failed to create output dir: "
+ + outDir.getAbsolutePath());
+ return false;
+ }
+
+ int args = 3;
+ String[] commandLine = new String[args];
+ commandLine[0] = "--output";
+ commandLine[1] = outputFile.fileName.getAbsolutePath();
+ commandLine[2] = inputFile.fileName.getAbsolutePath();
+
+ try {
+ Options options = Main.getOptions(commandLine);
+ Main.run(options);
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (super.equals(obj)) {
+ JillBuildStep other = (JillBuildStep) obj;
+
+ return inputFile.equals(other.inputFile) && outputFile.equals(other.outputFile);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return inputFile.hashCode() ^ outputFile.hashCode();
+ }
+}
diff --git a/tools/vm-tests-tf/src/util/build/SourceBuildStep.java b/tools/vm-tests-tf/src/util/build/SourceBuildStep.java
new file mode 100644
index 0000000..4a68a05
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/SourceBuildStep.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 util.build;
+
+public abstract class SourceBuildStep extends BuildStep {
+
+ public abstract void addSourceFile(String sourceFile);
+
+}