diff options
Diffstat (limited to 'tests')
74 files changed, 3357 insertions, 598 deletions
diff --git a/tests/Camera2Tests/CameraToo/Android.mk b/tests/Camera2Tests/CameraToo/Android.mk new file mode 100644 index 0000000..7e5911d --- /dev/null +++ b/tests/Camera2Tests/CameraToo/Android.mk @@ -0,0 +1,23 @@ +# 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. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests +LOCAL_PACKAGE_NAME := CameraToo +LOCAL_SDK_VERSION := current +LOCAL_SRC_FILES := $(call all-java-files-under,src) + +include $(BUILD_PACKAGE) diff --git a/tests/Camera2Tests/CameraToo/AndroidManifest.xml b/tests/Camera2Tests/CameraToo/AndroidManifest.xml new file mode 100644 index 0000000..a92b5d8 --- /dev/null +++ b/tests/Camera2Tests/CameraToo/AndroidManifest.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + 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. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.android.camera2.cameratoo"> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <application android:label="CameraToo"> + <activity + android:name=".CameraTooActivity" + android:screenOrientation="portrait"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/tests/Camera2Tests/CameraToo/res/layout/mainactivity.xml b/tests/Camera2Tests/CameraToo/res/layout/mainactivity.xml new file mode 100644 index 0000000..f93f177 --- /dev/null +++ b/tests/Camera2Tests/CameraToo/res/layout/mainactivity.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + 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. +--> + +<SurfaceView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/mainSurfaceView" + android:layout_height="fill_parent" + android:layout_width="fill_parent" + android:onClick="onClickOnSurfaceView" /> diff --git a/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java b/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java new file mode 100644 index 0000000..c630bad --- /dev/null +++ b/tests/Camera2Tests/CameraToo/src/com/example/android/camera2/cameratoo/CameraTooActivity.java @@ -0,0 +1,437 @@ +/* + * 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 com.example.android.camera2.cameratoo; + +import android.app.Activity; +import android.graphics.ImageFormat; +import android.hardware.camera2.CameraAccessException; +import android.hardware.camera2.CameraCharacteristics; +import android.hardware.camera2.CameraCaptureSession; +import android.hardware.camera2.CameraDevice; +import android.hardware.camera2.CameraManager; +import android.hardware.camera2.CaptureFailure; +import android.hardware.camera2.CaptureRequest; +import android.hardware.camera2.TotalCaptureResult; +import android.hardware.camera2.params.StreamConfigurationMap; +import android.media.Image; +import android.media.ImageReader; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.HandlerThread; +import android.os.Looper; +import android.util.Size; +import android.util.Log; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * A basic demonstration of how to write a point-and-shoot camera app against the new + * android.hardware.camera2 API. + */ +public class CameraTooActivity extends Activity { + /** Output files will be saved as /sdcard/Pictures/cameratoo*.jpg */ + static final String CAPTURE_FILENAME_PREFIX = "cameratoo"; + /** Tag to distinguish log prints. */ + static final String TAG = "CameraToo"; + + /** An additional thread for running tasks that shouldn't block the UI. */ + HandlerThread mBackgroundThread; + /** Handler for running tasks in the background. */ + Handler mBackgroundHandler; + /** Handler for running tasks on the UI thread. */ + Handler mForegroundHandler; + /** View for displaying the camera preview. */ + SurfaceView mSurfaceView; + /** Used to retrieve the captured image when the user takes a snapshot. */ + ImageReader mCaptureBuffer; + /** Handle to the Android camera services. */ + CameraManager mCameraManager; + /** The specific camera device that we're using. */ + CameraDevice mCamera; + /** Our image capture session. */ + CameraCaptureSession mCaptureSession; + + /** + * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose + * width and height are at least as large as the respective requested values. + * @param choices The list of sizes that the camera supports for the intended output class + * @param width The minimum desired width + * @param height The minimum desired height + * @return The optimal {@code Size}, or an arbitrary one if none were big enough + */ + static Size chooseBigEnoughSize(Size[] choices, int width, int height) { + // Collect the supported resolutions that are at least as big as the preview Surface + List<Size> bigEnough = new ArrayList<Size>(); + for (Size option : choices) { + if (option.getWidth() >= width && option.getHeight() >= height) { + bigEnough.add(option); + } + } + + // Pick the smallest of those, assuming we found any + if (bigEnough.size() > 0) { + return Collections.min(bigEnough, new CompareSizesByArea()); + } else { + Log.e(TAG, "Couldn't find any suitable preview size"); + return choices[0]; + } + } + + /** + * Compares two {@code Size}s based on their areas. + */ + static class CompareSizesByArea implements Comparator<Size> { + @Override + public int compare(Size lhs, Size rhs) { + // We cast here to ensure the multiplications won't overflow + return Long.signum((long) lhs.getWidth() * lhs.getHeight() - + (long) rhs.getWidth() * rhs.getHeight()); + } + } + + /** + * Called when our {@code Activity} gains focus. <p>Starts initializing the camera.</p> + */ + @Override + protected void onResume() { + super.onResume(); + + // Start a background thread to manage camera requests + mBackgroundThread = new HandlerThread("background"); + mBackgroundThread.start(); + mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); + mForegroundHandler = new Handler(getMainLooper()); + + mCameraManager = (CameraManager) getSystemService(CAMERA_SERVICE); + + // Inflate the SurfaceView, set it as the main layout, and attach a listener + View layout = getLayoutInflater().inflate(R.layout.mainactivity, null); + mSurfaceView = (SurfaceView) layout.findViewById(R.id.mainSurfaceView); + mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback); + setContentView(mSurfaceView); + + // Control flow continues in mSurfaceHolderCallback.surfaceChanged() + } + + /** + * Called when our {@code Activity} loses focus. <p>Tears everything back down.</p> + */ + @Override + protected void onPause() { + super.onPause(); + + try { + // Ensure SurfaceHolderCallback#surfaceChanged() will run again if the user returns + mSurfaceView.getHolder().setFixedSize(/*width*/0, /*height*/0); + + // Cancel any stale preview jobs + if (mCaptureSession != null) { + mCaptureSession.close(); + mCaptureSession = null; + } + } finally { + if (mCamera != null) { + mCamera.close(); + mCamera = null; + } + } + + // Finish processing posted messages, then join on the handling thread + mBackgroundThread.quitSafely(); + try { + mBackgroundThread.join(); + } catch (InterruptedException ex) { + Log.e(TAG, "Background worker thread was interrupted while joined", ex); + } + + // Close the ImageReader now that the background thread has stopped + if (mCaptureBuffer != null) mCaptureBuffer.close(); + } + + /** + * Called when the user clicks on our {@code SurfaceView}, which has ID {@code mainSurfaceView} + * as defined in the {@code mainactivity.xml} layout file. <p>Captures a full-resolution image + * and saves it to permanent storage.</p> + */ + public void onClickOnSurfaceView(View v) { + if (mCaptureSession != null) { + try { + CaptureRequest.Builder requester = + mCamera.createCaptureRequest(mCamera.TEMPLATE_STILL_CAPTURE); + requester.addTarget(mCaptureBuffer.getSurface()); + try { + // This handler can be null because we aren't actually attaching any callback + mCaptureSession.capture(requester.build(), /*listener*/null, /*handler*/null); + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to file actual capture request", ex); + } + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to build actual capture request", ex); + } + } else { + Log.e(TAG, "User attempted to perform a capture outside our session"); + } + + // Control flow continues in mImageCaptureListener.onImageAvailable() + } + + /** + * Callbacks invoked upon state changes in our {@code SurfaceView}. + */ + final SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() { + /** The camera device to use, or null if we haven't yet set a fixed surface size. */ + private String mCameraId; + + /** Whether we received a change callback after setting our fixed surface size. */ + private boolean mGotSecondCallback; + + @Override + public void surfaceCreated(SurfaceHolder holder) { + // This is called every time the surface returns to the foreground + Log.i(TAG, "Surface created"); + mCameraId = null; + mGotSecondCallback = false; + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + Log.i(TAG, "Surface destroyed"); + holder.removeCallback(this); + // We don't stop receiving callbacks forever because onResume() will reattach us + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + // On the first invocation, width and height were automatically set to the view's size + if (mCameraId == null) { + // Find the device's back-facing camera and set the destination buffer sizes + try { + for (String cameraId : mCameraManager.getCameraIdList()) { + CameraCharacteristics cameraCharacteristics = + mCameraManager.getCameraCharacteristics(cameraId); + if (cameraCharacteristics.get(cameraCharacteristics.LENS_FACING) == + CameraCharacteristics.LENS_FACING_BACK) { + Log.i(TAG, "Found a back-facing camera"); + StreamConfigurationMap info = cameraCharacteristics + .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); + + // Bigger is better when it comes to saving our image + Size largestSize = Collections.max( + Arrays.asList(info.getOutputSizes(ImageFormat.JPEG)), + new CompareSizesByArea()); + + // Prepare an ImageReader in case the user wants to capture images + Log.i(TAG, "Capture size: " + largestSize); + mCaptureBuffer = ImageReader.newInstance(largestSize.getWidth(), + largestSize.getHeight(), ImageFormat.JPEG, /*maxImages*/2); + mCaptureBuffer.setOnImageAvailableListener( + mImageCaptureListener, mBackgroundHandler); + + // Danger, W.R.! Attempting to use too large a preview size could + // exceed the camera bus' bandwidth limitation, resulting in + // gorgeous previews but the storage of garbage capture data. + Log.i(TAG, "SurfaceView size: " + + mSurfaceView.getWidth() + 'x' + mSurfaceView.getHeight()); + Size optimalSize = chooseBigEnoughSize( + info.getOutputSizes(SurfaceHolder.class), width, height); + + // Set the SurfaceHolder to use the camera's largest supported size + Log.i(TAG, "Preview size: " + optimalSize); + SurfaceHolder surfaceHolder = mSurfaceView.getHolder(); + surfaceHolder.setFixedSize(optimalSize.getWidth(), + optimalSize.getHeight()); + + mCameraId = cameraId; + return; + + // Control flow continues with this method one more time + // (since we just changed our own size) + } + } + } catch (CameraAccessException ex) { + Log.e(TAG, "Unable to list cameras", ex); + } + + Log.e(TAG, "Didn't find any back-facing cameras"); + // This is the second time the method is being invoked: our size change is complete + } else if (!mGotSecondCallback) { + if (mCamera != null) { + Log.e(TAG, "Aborting camera open because it hadn't been closed"); + return; + } + + // Open the camera device + try { + mCameraManager.openCamera(mCameraId, mCameraStateListener, + mBackgroundHandler); + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to configure output surface", ex); + } + mGotSecondCallback = true; + + // Control flow continues in mCameraStateListener.onOpened() + } + }}; + + /** + * Calledbacks invoked upon state changes in our {@code CameraDevice}. <p>These are run on + * {@code mBackgroundThread}.</p> + */ + final CameraDevice.StateListener mCameraStateListener = + new CameraDevice.StateListener() { + @Override + public void onOpened(CameraDevice camera) { + Log.i(TAG, "Successfully opened camera"); + mCamera = camera; + try { + List<Surface> outputs = Arrays.asList( + mSurfaceView.getHolder().getSurface(), mCaptureBuffer.getSurface()); + camera.createCaptureSession(outputs, mCaptureSessionListener, + mBackgroundHandler); + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to create a capture session", ex); + } + + // Control flow continues in mCaptureSessionListener.onConfigured() + } + + @Override + public void onDisconnected(CameraDevice camera) { + Log.e(TAG, "Camera was disconnected"); + } + + @Override + public void onError(CameraDevice camera, int error) { + Log.e(TAG, "State error on device '" + camera.getId() + "': code " + error); + }}; + + /** + * Callbacks invoked upon state changes in our {@code CameraCaptureSession}. <p>These are run on + * {@code mBackgroundThread}.</p> + */ + final CameraCaptureSession.StateListener mCaptureSessionListener = + new CameraCaptureSession.StateListener() { + @Override + public void onConfigured(CameraCaptureSession session) { + Log.i(TAG, "Finished configuring camera outputs"); + mCaptureSession = session; + + SurfaceHolder holder = mSurfaceView.getHolder(); + if (holder != null) { + try { + // Build a request for preview footage + CaptureRequest.Builder requestBuilder = + mCamera.createCaptureRequest(mCamera.TEMPLATE_PREVIEW); + requestBuilder.addTarget(holder.getSurface()); + CaptureRequest previewRequest = requestBuilder.build(); + + // Start displaying preview images + try { + session.setRepeatingRequest(previewRequest, /*listener*/null, + /*handler*/null); + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to make repeating preview request", ex); + } + } catch (CameraAccessException ex) { + Log.e(TAG, "Failed to build preview request", ex); + } + } + else { + Log.e(TAG, "Holder didn't exist when trying to formulate preview request"); + } + } + + @Override + public void onClosed(CameraCaptureSession session) { + mCaptureSession = null; + } + + @Override + public void onConfigureFailed(CameraCaptureSession session) { + Log.e(TAG, "Configuration error on device '" + mCamera.getId()); + }}; + + /** + * Callback invoked when we've received a JPEG image from the camera. + */ + final ImageReader.OnImageAvailableListener mImageCaptureListener = + new ImageReader.OnImageAvailableListener() { + @Override + public void onImageAvailable(ImageReader reader) { + // Save the image once we get a chance + mBackgroundHandler.post(new CapturedImageSaver(reader.acquireNextImage())); + + // Control flow continues in CapturedImageSaver#run() + }}; + + /** + * Deferred processor responsible for saving snapshots to disk. <p>This is run on + * {@code mBackgroundThread}.</p> + */ + static class CapturedImageSaver implements Runnable { + /** The image to save. */ + private Image mCapture; + + public CapturedImageSaver(Image capture) { + mCapture = capture; + } + + @Override + public void run() { + try { + // Choose an unused filename under the Pictures/ directory + File file = File.createTempFile(CAPTURE_FILENAME_PREFIX, ".jpg", + Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_PICTURES)); + try (FileOutputStream ostream = new FileOutputStream(file)) { + Log.i(TAG, "Retrieved image is" + + (mCapture.getFormat() == ImageFormat.JPEG ? "" : "n't") + " a JPEG"); + ByteBuffer buffer = mCapture.getPlanes()[0].getBuffer(); + Log.i(TAG, "Captured image size: " + + mCapture.getWidth() + 'x' + mCapture.getHeight()); + + // Write the image out to the chosen file + byte[] jpeg = new byte[buffer.remaining()]; + buffer.get(jpeg); + ostream.write(jpeg); + } catch (FileNotFoundException ex) { + Log.e(TAG, "Unable to open output file for writing", ex); + } catch (IOException ex) { + Log.e(TAG, "Failed to write the image to the output file", ex); + } + } catch (IOException ex) { + Log.e(TAG, "Unable to create a new output file", ex); + } finally { + mCapture.close(); + } + } + } +} diff --git a/tests/Camera2Tests/CameraToo/tests/Android.mk b/tests/Camera2Tests/CameraToo/tests/Android.mk new file mode 100644 index 0000000..0b58243 --- /dev/null +++ b/tests/Camera2Tests/CameraToo/tests/Android.mk @@ -0,0 +1,25 @@ +# 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. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests +LOCAL_PACKAGE_NAME := CameraTooTests +LOCAL_INSTRUMENTATION_FOR := CameraToo +LOCAL_SDK_VERSION := current +LOCAL_SRC_FILES := $(call all-java-files-under,src) +LOCAL_STATIC_JAVA_LIBRARIES := android-support-test mockito-target + +include $(BUILD_PACKAGE) diff --git a/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml b/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml new file mode 100644 index 0000000..30210ba --- /dev/null +++ b/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + 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. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.android.camera2.cameratoo.tests"> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <application android:label="CameraToo"> + <uses-library android:name="android.test.runner" /> + </application> + <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + android:targetPackage="com.example.android.camera2.cameratoo" + android:label="CameraToo tests" /> +</manifest> diff --git a/tests/Camera2Tests/CameraToo/tests/src/com/example/android/camera2/cameratoo/CameraTooTest.java b/tests/Camera2Tests/CameraToo/tests/src/com/example/android/camera2/cameratoo/CameraTooTest.java new file mode 100644 index 0000000..3acca5a --- /dev/null +++ b/tests/Camera2Tests/CameraToo/tests/src/com/example/android/camera2/cameratoo/CameraTooTest.java @@ -0,0 +1,189 @@ +/* + * 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 com.example.android.camera2.cameratoo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import android.media.Image; +import android.os.Environment; +import android.util.Size; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; + +import com.example.android.camera2.cameratoo.CameraTooActivity; +import org.junit.Test; + +public class CameraTooTest { + private <T> void assertComparatorEq(T lhs, T rhs, Comparator<T> rel) { + assertEquals(String.format("%s should be equal to %s", lhs, rhs), rel.compare(lhs, rhs), 0); + assertEquals(String.format("%s should be equal to %s (reverse check)", lhs, rhs), + rel.compare(rhs, lhs), 0); + } + + private <T> void assertComparatorLt(T lhs, T rhs, Comparator<T> rel) { + assertTrue(String.format("%s should be less than %s", lhs, rhs), rel.compare(lhs, rhs) < 0); + assertTrue(String.format("%s should be less than %s (reverse check)", lhs, rhs), + rel.compare(rhs, lhs) > 0); + } + + @Test + public void compareSizesByArea() { + Size empty = new Size(0, 0), fatAndFlat = new Size(100, 0), tallAndThin = new Size(0, 100); + Size smallSquare = new Size(4, 4), horizRect = new Size(8, 2), vertRect = new Size(2, 8); + Size largeSquare = new Size(5, 5); + Comparator<Size> rel = new CameraTooActivity.CompareSizesByArea(); + + assertComparatorEq(empty, fatAndFlat, rel); + assertComparatorEq(empty, tallAndThin, rel); + assertComparatorEq(fatAndFlat, empty, rel); + assertComparatorEq(fatAndFlat, tallAndThin, rel); + assertComparatorEq(tallAndThin, empty, rel); + assertComparatorEq(tallAndThin, fatAndFlat, rel); + + assertComparatorEq(smallSquare, horizRect, rel); + assertComparatorEq(smallSquare, vertRect, rel); + assertComparatorEq(horizRect, smallSquare, rel); + assertComparatorEq(horizRect, vertRect, rel); + assertComparatorEq(vertRect, smallSquare, rel); + assertComparatorEq(vertRect, horizRect, rel); + + assertComparatorLt(empty, smallSquare, rel); + assertComparatorLt(empty, horizRect, rel); + assertComparatorLt(empty, vertRect, rel); + + assertComparatorLt(fatAndFlat, smallSquare, rel); + assertComparatorLt(fatAndFlat, horizRect, rel); + assertComparatorLt(fatAndFlat, vertRect, rel); + + assertComparatorLt(tallAndThin, smallSquare, rel); + assertComparatorLt(tallAndThin, horizRect, rel); + assertComparatorLt(tallAndThin, vertRect, rel); + + assertComparatorLt(empty, largeSquare, rel); + assertComparatorLt(fatAndFlat, largeSquare, rel); + assertComparatorLt(tallAndThin, largeSquare, rel); + assertComparatorLt(smallSquare, largeSquare, rel); + assertComparatorLt(horizRect, largeSquare, rel); + assertComparatorLt(vertRect, largeSquare, rel); + } + + private void assertOptimalSize(Size[] options, int minWidth, int minHeight, Size expected) { + Size verdict = CameraTooActivity.chooseBigEnoughSize(options, minWidth, minHeight); + assertEquals(String.format("Expected optimal size %s but got %s", expected, verdict), + verdict, expected); + } + + @Test + public void chooseBigEnoughSize() { + Size empty = new Size(0, 0), fatAndFlat = new Size(100, 0), tallAndThin = new Size(0, 100); + Size smallSquare = new Size(4, 4), horizRect = new Size(8, 2), vertRect = new Size(2, 8); + Size largeSquare = new Size(5, 5); + Size[] siz = + { empty, fatAndFlat, tallAndThin, smallSquare, horizRect, vertRect, largeSquare }; + + assertOptimalSize(siz, 0, 0, empty); + + assertOptimalSize(siz, 1, 0, fatAndFlat); + assertOptimalSize(siz, 0, 1, tallAndThin); + + assertOptimalSize(siz, 4, 4, smallSquare); + assertOptimalSize(siz, 1, 1, smallSquare); + assertOptimalSize(siz, 2, 1, smallSquare); + assertOptimalSize(siz, 1, 2, smallSquare); + assertOptimalSize(siz, 3, 4, smallSquare); + assertOptimalSize(siz, 4, 3, smallSquare); + + assertOptimalSize(siz, 8, 2, horizRect); + assertOptimalSize(siz, 5, 1, horizRect); + assertOptimalSize(siz, 5, 2, horizRect); + + assertOptimalSize(siz, 2, 8, vertRect); + assertOptimalSize(siz, 1, 5, vertRect); + assertOptimalSize(siz, 2, 5, vertRect); + + assertOptimalSize(siz, 5, 5, largeSquare); + assertOptimalSize(siz, 3, 5, largeSquare); + assertOptimalSize(siz, 5, 3, largeSquare); + } + + private static final FilenameFilter OUTPUT_FILE_DECIDER = new FilenameFilter() { + @Override + public boolean accept(File dir, String filename) { + return filename.indexOf("cameratoo") == 0 && + filename.indexOf(".jpg") == filename.length() - ".jpg".length(); + }}; + + private static <T> Set<T> newlyAddedElements(Set<T> before, Set<T> after) { + Set<T> result = new HashSet<T>(after); + result.removeAll(before); + return result; + } + + @Test + public void capturedImageSaver() throws FileNotFoundException, IOException { + ByteBuffer buf = ByteBuffer.allocate(25); + for(int index = 0; index < buf.capacity(); ++index) + buf.put(index, (byte) index); + + Image.Plane plane = mock(Image.Plane.class); + when(plane.getBuffer()).thenReturn(buf); + when(plane.getPixelStride()).thenReturn(1); + when(plane.getRowStride()).thenReturn(5); + + Image.Plane[] onlyPlaneThatMatters = { plane }; + Image image = mock(Image.class); + when(image.getPlanes()).thenReturn(onlyPlaneThatMatters); + when(image.getWidth()).thenReturn(5); + when(image.getHeight()).thenReturn(5); + + File picturesFolder = + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); + Set<File> preListing = + new HashSet<File>(Arrays.asList(picturesFolder.listFiles(OUTPUT_FILE_DECIDER))); + + CameraTooActivity.CapturedImageSaver saver = + new CameraTooActivity.CapturedImageSaver(image); + saver.run(); + + Set<File> postListing = + new HashSet<File>(Arrays.asList(picturesFolder.listFiles(OUTPUT_FILE_DECIDER))); + Set<File> newFiles = newlyAddedElements(preListing, postListing); + + assertEquals(newFiles.size(), 1); + + File picture = newFiles.iterator().next(); + FileInputStream istream = new FileInputStream(picture); + + for(int count = 0; count < buf.capacity(); ++count) { + assertEquals(istream.read(), buf.get(count)); + } + assertEquals(istream.read(), -1); + assertTrue(picture.delete()); + } +} diff --git a/tests/IdleServiceTest/Android.mk b/tests/IdleServiceTest/Android.mk deleted file mode 100644 index a7879c5..0000000 --- a/tests/IdleServiceTest/Android.mk +++ /dev/null @@ -1,13 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_PACKAGE_NAME := IdleServiceTest -LOCAL_CERTIFICATE := platform - -LOCAL_PROGUARD_ENABLED := disabled - -include $(BUILD_PACKAGE) diff --git a/tests/IdleServiceTest/AndroidManifest.xml b/tests/IdleServiceTest/AndroidManifest.xml deleted file mode 100644 index 16d2324..0000000 --- a/tests/IdleServiceTest/AndroidManifest.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- 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. ---> - -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.idleservicetest"> - - <application> - <service android:name="TestService" - android:exported="true" - android:enabled="true" - android:permission="android.permission.BIND_IDLE_SERVICE" > - <intent-filter> - <action android:name="android.service.idle.IdleService" /> - </intent-filter> - </service> - - <service android:name="CrashingTestService" - android:exported="true" - android:enabled="true" - android:permission="android.permission.BIND_IDLE_SERVICE" > - <intent-filter> - <action android:name="android.service.idle.IdleService" /> - </intent-filter> - </service> - - <service android:name="TimeoutTestService" - android:exported="true" - android:enabled="true" - android:permission="android.permission.BIND_IDLE_SERVICE" > - <intent-filter> - <action android:name="android.service.idle.IdleService" /> - </intent-filter> - </service> - - <!-- UnpermissionedTestService should never run because it does - not require the necessary permission in its <service> block --> - <service android:name="UnpermissionedTestService" - android:exported="true" - android:enabled="true" > - <intent-filter> - <action android:name="android.service.idle.IdleService" /> - </intent-filter> - </service> - - </application> -</manifest> diff --git a/tests/IdleServiceTest/src/com/android/idleservicetest/CrashingTestService.java b/tests/IdleServiceTest/src/com/android/idleservicetest/CrashingTestService.java deleted file mode 100644 index 022ebcf..0000000 --- a/tests/IdleServiceTest/src/com/android/idleservicetest/CrashingTestService.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 com.android.idleservicetest; - -import android.app.maintenance.IdleService; -import android.os.Handler; -import android.util.Log; - -public class CrashingTestService extends IdleService { - static final String TAG = "CrashingTestService"; - - String mNull = null; - - @Override - public boolean onIdleStart() { - Log.i(TAG, "Idle maintenance: onIdleStart()"); - - Handler h = new Handler(); - Runnable r = new Runnable() { - @Override - public void run() { - Log.i(TAG, "Explicitly crashing"); - if (mNull.equals("")) { - Log.i(TAG, "won't happen"); - } - } - }; - Log.i(TAG, "Posting explicit crash in 15 seconds"); - h.postDelayed(r, 15 * 1000); - return true; - } - - @Override - public void onIdleStop() { - Log.i(TAG, "Idle maintenance: onIdleStop()"); - } - -} diff --git a/tests/IdleServiceTest/src/com/android/idleservicetest/TestService.java b/tests/IdleServiceTest/src/com/android/idleservicetest/TestService.java deleted file mode 100644 index 7e9805f..0000000 --- a/tests/IdleServiceTest/src/com/android/idleservicetest/TestService.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 com.android.idleservicetest; - -import android.app.maintenance.IdleService; -import android.os.Handler; -import android.util.Log; - -public class TestService extends IdleService { - static final String TAG = "TestService"; - - @Override - public boolean onIdleStart() { - Log.i(TAG, "Idle maintenance: onIdleStart()"); - - Handler h = new Handler(); - Runnable r = new Runnable() { - @Override - public void run() { - Log.i(TAG, "Explicitly finishing idle"); - finishIdle(); - } - }; - Log.i(TAG, "Posting explicit finish in 15 seconds"); - h.postDelayed(r, 15 * 1000); - return true; - } - - @Override - public void onIdleStop() { - Log.i(TAG, "Idle maintenance: onIdleStop()"); - } - -} diff --git a/tests/IdleServiceTest/src/com/android/idleservicetest/UnpermissionedTestService.java b/tests/IdleServiceTest/src/com/android/idleservicetest/UnpermissionedTestService.java deleted file mode 100644 index b9fe32b..0000000 --- a/tests/IdleServiceTest/src/com/android/idleservicetest/UnpermissionedTestService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 com.android.idleservicetest; - -import android.app.maintenance.IdleService; -import android.util.Log; - -// Should never be invoked because its manifest declaration does not -// require the necessary permission. -public class UnpermissionedTestService extends IdleService { - private static final String TAG = "UnpermissionedTestService"; - - @Override - public boolean onIdleStart() { - Log.e(TAG, "onIdleStart() for this service should never be called!"); - return false; - } - - @Override - public void onIdleStop() { - Log.e(TAG, "onIdleStop() for this service should never be called!"); - } - -} diff --git a/tests/JobSchedulerTestApp/res/layout/activity_main.xml b/tests/JobSchedulerTestApp/res/layout/activity_main.xml index 7f4961b..d3429ff 100644 --- a/tests/JobSchedulerTestApp/res/layout/activity_main.xml +++ b/tests/JobSchedulerTestApp/res/layout/activity_main.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> @@ -54,6 +54,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/constraints" + android:layout_margin="15dp" android:textSize="18dp"/> <LinearLayout android:layout_width="match_parent" @@ -83,43 +84,81 @@ </RadioGroup> </LinearLayout> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/timing"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="15dp" - android:textSize="17dp" - android:text="@string/delay"/> - <EditText - android:id="@+id/delay_time" - android:layout_width="60dp" - android:layout_height="wrap_content" - android:inputType="number"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/deadline" - android:textSize="17dp"/> - <EditText - android:id="@+id/deadline_time" - android:layout_width="60dp" - android:layout_height="wrap_content" - android:inputType="number"/> - </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/timing"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="15dp" + android:textSize="17dp" + android:text="@string/delay"/> + <EditText + android:id="@+id/delay_time" + android:layout_width="60dp" + android:layout_height="wrap_content" + android:inputType="number"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/deadline" + android:textSize="17dp"/> + <EditText + android:id="@+id/deadline_time" + android:layout_width="60dp" + android:layout_height="wrap_content" + android:inputType="number"/> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/charging_caption" + android:layout_marginRight="15dp"/> + <CheckBox + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/checkbox_charging" + android:text="@string/charging_text"/> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/idle_caption" + android:layout_marginRight="15dp"/> + <CheckBox + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/checkbox_idle" + android:text="@string/idle_mode_text"/> + </LinearLayout> </LinearLayout> <Button android:id="@+id/schedule_button" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="40dp" + android:layout_marginTop="20dp" + android:layout_marginLeft="40dp" + android:layout_marginRight="40dp" android:onClick="scheduleJob" android:text="@string/schedule_job_button_text"/> + <Button + android:id="@+id/cancel_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="40dp" + android:layout_marginRight="40dp" + android:onClick="cancelAllJobs" + android:text="@string/cancel_all_jobs_button_text"/> </LinearLayout> -</LinearLayout> +</ScrollView> diff --git a/tests/JobSchedulerTestApp/res/values/strings.xml b/tests/JobSchedulerTestApp/res/values/strings.xml index 824d4b1..eebfb19 100644 --- a/tests/JobSchedulerTestApp/res/values/strings.xml +++ b/tests/JobSchedulerTestApp/res/values/strings.xml @@ -20,9 +20,13 @@ limitations under the License. <string name="onstarttask">onStartTask</string> <string name="defaultparamtext">task params will show up here.</string> <string name="schedule_job_button_text">Schedule Job</string> + <string name="cancel_all_jobs_button_text">Cancel all</string> <string name="app_name">Job Scheduler Test</string> <string name="finish_job_button_text">taskFinished</string> - <string name="manual_sync_text">Manual Sync</string> + <string name="idle_mode_text">Requires device in idle mode.</string> + <string name="charging_caption">Charging:</string> + <string name="charging_text">Requires device plugged in.</string> + <string name="idle_caption">Idle:</string> <string name="constraints">Constraints</string> <string name="connectivity">Connectivity:</string> <string name="any">Any</string> diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java index 15050ef..e15929d 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java @@ -19,7 +19,9 @@ package com.android.demo.jobSchedulerApp; import android.app.Activity; import android.app.job.JobInfo; import android.app.job.JobParameters; +import android.app.job.JobScheduler; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; @@ -28,6 +30,7 @@ import android.os.Message; import android.os.Messenger; import android.text.TextUtils; import android.view.View; +import android.widget.CheckBox; import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; @@ -60,7 +63,8 @@ public class MainActivity extends Activity { mDeadlineEditText = (EditText) findViewById(R.id.deadline_time); mWiFiConnectivityRadioButton = (RadioButton) findViewById(R.id.checkbox_unmetered); mAnyConnectivityRadioButton = (RadioButton) findViewById(R.id.checkbox_any); - + mRequiresChargingCheckBox = (CheckBox) findViewById(R.id.checkbox_charging); + mRequiresIdleCheckbox = (CheckBox) findViewById(R.id.checkbox_idle); mServiceComponent = new ComponentName(this, TestJobService.class); // Start service and provide it a way to communicate with us. Intent startServiceIntent = new Intent(this, TestJobService.class); @@ -79,6 +83,9 @@ public class MainActivity extends Activity { EditText mDeadlineEditText; RadioButton mWiFiConnectivityRadioButton; RadioButton mAnyConnectivityRadioButton; + CheckBox mRequiresChargingCheckBox; + CheckBox mRequiresIdleCheckbox; + ComponentName mServiceComponent; /** Service object to interact scheduled jobs. */ TestJobService mTestService; @@ -124,24 +131,32 @@ public class MainActivity extends Activity { String delay = mDelayEditText.getText().toString(); if (delay != null && !TextUtils.isEmpty(delay)) { - builder.setMinimumLatency(Long.valueOf(delay)); + builder.setMinimumLatency(Long.valueOf(delay) * 1000); } String deadline = mDeadlineEditText.getText().toString(); if (deadline != null && !TextUtils.isEmpty(deadline)) { - builder.setOverrideDeadline(Long.valueOf(deadline)); + builder.setOverrideDeadline(Long.valueOf(deadline) * 1000); } - boolean requiresUnmetered = mWiFiConnectivityRadioButton.isSelected(); - boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isSelected(); + boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked(); + boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked(); if (requiresUnmetered) { builder.setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED); } else if (requiresAnyConnectivity) { builder.setRequiredNetworkCapabilities(JobInfo.NetworkType.ANY); } + builder.setRequiresDeviceIdle(mRequiresIdleCheckbox.isChecked()); + builder.setRequiresCharging(mRequiresChargingCheckBox.isChecked()); mTestService.scheduleJob(builder.build()); } + public void cancelAllJobs(View v) { + JobScheduler tm = + (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); + tm.cancelAll(); + } + /** * UI onclick listener to call jobFinished() in our service. */ diff --git a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java index c7715ad..fc5426c 100644 --- a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java +++ b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java @@ -43,7 +43,6 @@ public class MainActivity extends Activity implements OnItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - HardwareRenderer.sUseRenderThread = true; setContentView(R.layout.activity_main); ListView lv = (ListView) findViewById(android.R.id.list); lv.setDrawSelectorOnTop(true); diff --git a/tests/TtsTests/src/com/android/speech/tts/AbstractTtsSemioticClassTest.java b/tests/TtsTests/src/com/android/speech/tts/AbstractTtsSemioticClassTest.java new file mode 100644 index 0000000..31484f4 --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/AbstractTtsSemioticClassTest.java @@ -0,0 +1,189 @@ +/* + * 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 com.android.speech.tts; + +import android.test.InstrumentationTestCase; + +import android.speech.tts.Markup; +import android.speech.tts.Utterance; +import android.speech.tts.Utterance.AbstractTtsSemioticClass; + +public class AbstractTtsSemioticClassTest extends InstrumentationTestCase { + + public static class TtsMock extends AbstractTtsSemioticClass<TtsMock> { + public TtsMock() { + super(); + } + + public TtsMock(Markup markup) { + super(); + } + + public void setType(String type) { + mMarkup.setType(type); + } + } + + public void testFluentAPI() { + new TtsMock() + .setPlainText("a plaintext") // from AbstractTts + .setGender(Utterance.GENDER_MALE) // from AbstractTtsSemioticClass + .setType("test"); // from TtsMock + } + + public void testDefaultConstructor() { + new TtsMock(); + } + + public void testMarkupConstructor() { + Markup markup = new Markup(); + new TtsMock(markup); + } + + public void testGetType() { + TtsMock t = new TtsMock(); + t.setType("type1"); + assertEquals("type1", t.getType()); + t.setType(null); + assertEquals(null, t.getType()); + t.setType("type2"); + assertEquals("type2", t.getType()); + } + + + public void testDefaultGender() { + assertEquals(Utterance.GENDER_UNKNOWN, new TtsMock().getGender()); + } + + public void testSetGender() { + assertEquals(Utterance.GENDER_MALE, + new TtsMock().setGender(Utterance.GENDER_MALE).getGender()); + } + + public void testSetGenderNegative() { + try { + new TtsMock().setGender(-1); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testSetGenderOutOfBounds() { + try { + new TtsMock().setGender(4); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testDefaultAnimacy() { + assertEquals(Utterance.ANIMACY_UNKNOWN, new TtsMock().getAnimacy()); + } + + public void testSetAnimacy() { + assertEquals(Utterance.ANIMACY_ANIMATE, + new TtsMock().setAnimacy(Utterance.ANIMACY_ANIMATE).getAnimacy()); + } + + public void testSetAnimacyNegative() { + try { + new TtsMock().setAnimacy(-1); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testSetAnimacyOutOfBounds() { + try { + new TtsMock().setAnimacy(4); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testDefaultMultiplicity() { + assertEquals(Utterance.MULTIPLICITY_UNKNOWN, new TtsMock().getMultiplicity()); + } + + public void testSetMultiplicity() { + assertEquals(Utterance.MULTIPLICITY_DUAL, + new TtsMock().setMultiplicity(Utterance.MULTIPLICITY_DUAL).getMultiplicity()); + } + + public void testSetMultiplicityNegative() { + try { + new TtsMock().setMultiplicity(-1); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testSetMultiplicityOutOfBounds() { + try { + new TtsMock().setMultiplicity(4); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testDefaultCase() { + assertEquals(Utterance.CASE_UNKNOWN, new TtsMock().getCase()); + } + + public void testSetCase() { + assertEquals(Utterance.CASE_VOCATIVE, + new TtsMock().setCase(Utterance.CASE_VOCATIVE).getCase()); + } + + public void testSetCaseNegative() { + try { + new TtsMock().setCase(-1); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testSetCaseOutOfBounds() { + try { + new TtsMock().setCase(9); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testToString() { + TtsMock t = new TtsMock() + .setAnimacy(Utterance.ANIMACY_INANIMATE) + .setCase(Utterance.CASE_INSTRUMENTAL) + .setGender(Utterance.GENDER_FEMALE) + .setMultiplicity(Utterance.MULTIPLICITY_PLURAL); + String str = + "animacy: \"2\" " + + "case: \"8\" " + + "gender: \"3\" " + + "multiplicity: \"3\""; + assertEquals(str, t.toString()); + } + + public void testToStringSetToUnkown() { + TtsMock t = new TtsMock() + .setAnimacy(Utterance.ANIMACY_INANIMATE) + .setCase(Utterance.CASE_INSTRUMENTAL) + .setGender(Utterance.GENDER_FEMALE) + .setMultiplicity(Utterance.MULTIPLICITY_PLURAL) + // set back to unknown + .setAnimacy(Utterance.ANIMACY_UNKNOWN) + .setCase(Utterance.CASE_UNKNOWN) + .setGender(Utterance.GENDER_UNKNOWN) + .setMultiplicity(Utterance.MULTIPLICITY_UNKNOWN); + String str = ""; + assertEquals(str, t.toString()); + } + +} diff --git a/tests/TtsTests/src/com/android/speech/tts/AbstractTtsTest.java b/tests/TtsTests/src/com/android/speech/tts/AbstractTtsTest.java new file mode 100644 index 0000000..281c97f --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/AbstractTtsTest.java @@ -0,0 +1,106 @@ +/* + * 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 com.android.speech.tts; + +import android.test.InstrumentationTestCase; + +import android.speech.tts.Markup; +import android.speech.tts.Utterance.AbstractTts; + +public class AbstractTtsTest extends InstrumentationTestCase { + + public static class TtsMock extends AbstractTts<TtsMock> { + public TtsMock() { + super(); + } + + public TtsMock(Markup markup) { + super(); + } + + public void setType(String type) { + mMarkup.setType(type); + } + + @Override + public TtsMock setParameter(String key, String value) { + return super.setParameter(key, value); + } + + @Override + public TtsMock removeParameter(String key) { + return super.removeParameter(key); + } + } + + public void testDefaultConstructor() { + new TtsMock(); + } + + public void testMarkupConstructor() { + Markup markup = new Markup(); + new TtsMock(markup); + } + + public void testGetType() { + TtsMock t = new TtsMock(); + t.setType("type1"); + assertEquals("type1", t.getType()); + t.setType(null); + assertEquals(null, t.getType()); + t.setType("type2"); + assertEquals("type2", t.getType()); + } + + public void testGeneratePlainText() { + assertNull(new TtsMock().generatePlainText()); + } + + public void testToString() { + TtsMock t = new TtsMock(); + t.setType("a_type"); + t.setPlainText("a plaintext"); + t.setParameter("key1", "value1"); + t.setParameter("aaa", "value2"); + String str = + "type: \"a_type\" " + + "plain_text: \"a plaintext\" " + + "aaa: \"value2\" " + + "key1: \"value1\""; + assertEquals(str, t.toString()); + } + + public void testRemoveParameter() { + TtsMock t = new TtsMock(); + t.setParameter("key1", "value 1"); + t.setParameter("aaa", "value a"); + t.removeParameter("key1"); + String str = + "aaa: \"value a\""; + assertEquals(str, t.toString()); + } + + public void testRemoveParameterBySettingNull() { + TtsMock t = new TtsMock(); + t.setParameter("key1", "value 1"); + t.setParameter("aaa", "value a"); + t.setParameter("aaa", null); + String str = + "key1: \"value 1\""; + assertEquals(str, t.toString()); + } +} diff --git a/tests/TtsTests/src/com/android/speech/tts/MarkupTest.java b/tests/TtsTests/src/com/android/speech/tts/MarkupTest.java new file mode 100644 index 0000000..7ef93ce --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/MarkupTest.java @@ -0,0 +1,510 @@ +/* + * 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 com.android.speech.tts; + +import junit.framework.Assert; +import android.os.Parcel; +import android.test.InstrumentationTestCase; + +import android.speech.tts.Markup; + +public class MarkupTest extends InstrumentationTestCase { + + public void testEmptyMarkup() { + Markup markup = new Markup(); + assertNull(markup.getType()); + assertNull(markup.getPlainText()); + assertEquals(0, markup.parametersSize()); + assertEquals(0, markup.nestedMarkupSize()); + } + + public void testGetSetType() { + Markup markup = new Markup(); + markup.setType("one"); + assertEquals("one", markup.getType()); + markup.setType(null); + assertNull(markup.getType()); + markup.setType("two"); + assertEquals("two", markup.getType()); + } + + public void testGetSetPlainText() { + Markup markup = new Markup(); + markup.setPlainText("one"); + assertEquals("one", markup.getPlainText()); + markup.setPlainText(null); + assertNull(markup.getPlainText()); + markup.setPlainText("two"); + assertEquals("two", markup.getPlainText()); + } + + public void testParametersSize1() { + Markup markup = new Markup(); + markup.addNestedMarkup(new Markup()); + assertEquals(1, markup.nestedMarkupSize()); + } + + public void testParametersSize2() { + Markup markup = new Markup(); + markup.addNestedMarkup(new Markup()); + markup.addNestedMarkup(new Markup()); + assertEquals(2, markup.nestedMarkupSize()); + } + + public void testRemoveParameter() { + Markup m = new Markup("type"); + m.setParameter("key1", "value1"); + m.setParameter("key2", "value2"); + m.setParameter("key3", "value3"); + assertEquals(3, m.parametersSize()); + m.removeParameter("key1"); + assertEquals(2, m.parametersSize()); + m.removeParameter("key3"); + assertEquals(1, m.parametersSize()); + assertNull(m.getParameter("key1")); + assertEquals("value2", m.getParameter("key2")); + assertNull(m.getParameter("key3")); + } + + public void testEmptyEqual() { + Markup m1 = new Markup(); + Markup m2 = new Markup(); + assertTrue(m1.equals(m2)); + } + + public void testFilledEqual() { + Markup m1 = new Markup(); + m1.setType("type"); + m1.setPlainText("plain text"); + m1.setParameter("key1", "value1"); + m1.addNestedMarkup(new Markup()); + Markup m2 = new Markup(); + m2.setType("type"); + m2.setPlainText("plain text"); + m2.setParameter("key1", "value1"); + m2.addNestedMarkup(new Markup()); + assertTrue(m1.equals(m2)); + } + + public void testDifferentTypeEqual() { + Markup m1 = new Markup(); + m1.setType("type1"); + Markup m2 = new Markup(); + m2.setType("type2"); + assertFalse(m1.equals(m2)); + } + + public void testDifferentPlainTextEqual() { + Markup m1 = new Markup(); + m1.setPlainText("plainText1"); + Markup m2 = new Markup(); + m2.setPlainText("plainText2"); + assertFalse(m1.equals(m2)); + } + + public void testDifferentParamEqual() { + Markup m1 = new Markup(); + m1.setParameter("test", "value1"); + Markup m2 = new Markup(); + m2.setParameter("test", "value2"); + assertFalse(m1.equals(m2)); + } + + public void testDifferentParameterKeyEqual() { + Markup m1 = new Markup(); + m1.setParameter("test1", "value"); + Markup m2 = new Markup(); + m2.setParameter("test2", "value"); + assertFalse(m1.equals(m2)); + } + + public void testDifferentParameterValueEqual() { + Markup m1 = new Markup(); + m1.setParameter("test", "value1"); + Markup m2 = new Markup(); + m2.setParameter("test", "value2"); + assertFalse(m1.equals(m2)); + } + + public void testDifferentNestedMarkupEqual() { + Markup m1 = new Markup(); + Markup nested = new Markup(); + nested.setParameter("key", "value"); + m1.addNestedMarkup(nested); + Markup m2 = new Markup(); + m2.addNestedMarkup(new Markup()); + assertFalse(m1.equals(m2)); + } + + public void testEmptyToFromString() { + Markup m1 = new Markup(); + String str = m1.toString(); + assertEquals("", str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testTypeToFromString() { + Markup m1 = new Markup("atype"); + String str = m1.toString(); + assertEquals("type: \"atype\"", str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testPlainTextToFromString() { + Markup m1 = new Markup(); + m1.setPlainText("some_plainText"); + String str = m1.toString(); + assertEquals("plain_text: \"some_plainText\"", str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testParameterToFromString() { + Markup m1 = new Markup("cardinal"); + m1.setParameter("integer", "-22"); + String str = m1.toString(); + assertEquals("type: \"cardinal\" integer: \"-22\"", str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + // Parameters should be ordered alphabettically, so the output is stable. + public void testParameterOrderToFromString() { + Markup m1 = new Markup("cardinal"); + m1.setParameter("ccc", "-"); + m1.setParameter("aaa", "-"); + m1.setParameter("aa", "-"); + m1.setParameter("bbb", "-"); + String str = m1.toString(); + assertEquals( + "type: \"cardinal\" " + + "aa: \"-\" " + + "aaa: \"-\" " + + "bbb: \"-\" " + + "ccc: \"-\"", + str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testEmptyNestedToFromString() { + Markup m1 = new Markup("atype"); + m1.addNestedMarkup(new Markup()); + String str = m1.toString(); + assertEquals("type: \"atype\" markup {}", str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testNestedWithTypeToFromString() { + Markup m1 = new Markup("atype"); + m1.addNestedMarkup(new Markup("nested_type")); + String str = m1.toString(); + assertEquals( + "type: \"atype\" " + + "markup { type: \"nested_type\" }", + str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testRemoveNestedMarkup() { + Markup m = new Markup("atype"); + Markup m1 = new Markup("nested_type1"); + Markup m2 = new Markup("nested_type2"); + Markup m3 = new Markup("nested_type3"); + m.addNestedMarkup(m1); + m.addNestedMarkup(m2); + m.addNestedMarkup(m3); + m.removeNestedMarkup(m1); + m.removeNestedMarkup(m3); + String str = m.toString(); + assertEquals( + "type: \"atype\" " + + "markup { type: \"nested_type2\" }", + str); + Markup mFromString = Markup.markupFromString(str); + assertEquals(m, mFromString); + } + + public void testLotsofNestingToFromString() { + Markup m1 = new Markup("top") + .addNestedMarkup(new Markup("top_child1") + .addNestedMarkup(new Markup("top_child1_child1")) + .addNestedMarkup(new Markup("top_child1_child2"))) + .addNestedMarkup(new Markup("top_child2") + .addNestedMarkup(new Markup("top_child2_child2")) + .addNestedMarkup(new Markup("top_child2_child2"))); + + String str = m1.toString(); + assertEquals( + "type: \"top\" " + + "markup { " + + "type: \"top_child1\" " + + "markup { type: \"top_child1_child1\" } " + + "markup { type: \"top_child1_child2\" } " + + "} " + + "markup { " + + "type: \"top_child2\" " + + "markup { type: \"top_child2_child2\" } " + + "markup { type: \"top_child2_child2\" } " + + "}", + str); + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testFilledToFromString() { + Markup m1 = new Markup("measure"); + m1.setPlainText("fifty-five amps"); + m1.setParameter("unit", "meter"); + m1.addNestedMarkup(new Markup("cardinal").setParameter("integer", "55")); + String str = m1.toString(); + assertEquals( + "type: \"measure\" " + + "plain_text: \"fifty-five amps\" " + + "unit: \"meter\" " + + "markup { type: \"cardinal\" integer: \"55\" }", + str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1, m2); + } + + public void testErrorFromString() { + String str = "type: \"atype\" markup {mistake}"; + try { + Markup.markupFromString(str); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testEscapeQuotes() { + Markup m1 = new Markup("text") + .setParameter("something_unknown", "\"this\" is \"a sentence \" with quotes\""); + String str = m1.toString(); + assertEquals( + "type: \"text\" " + + "something_unknown: \"\\\"this\\\" is \\\"a sentence \\\" with quotes\\\"\"", + str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1.toString(), m2.toString()); + assertEquals(m1, m2); + } + + public void testEscapeSlashes1() { + Markup m1 = new Markup("text") + .setParameter("something_unknown", "\\ \\\\ \t \n \""); + String str = m1.toString(); + assertEquals( + "type: \"text\" " + + "something_unknown: \"\\\\ \\\\\\\\ \t \n \\\"\"", + str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1.toString(), m2.toString()); + assertEquals(m1, m2); + } + + public void testEscapeSlashes2() { + Markup m1 = new Markup("text") + .setParameter("something_unknown", "\\\"\\\"\\\\\"\"\\\\\\\"\"\""); + String str = m1.toString(); + assertEquals( + "type: \"text\" " + + "something_unknown: \"\\\\\\\"\\\\\\\"\\\\\\\\\\\"\\\"\\\\\\\\\\\\\\\"\\\"\\\"\"", + str); + + Markup m2 = Markup.markupFromString(str); + assertEquals(m1.toString(), m2.toString()); + assertEquals(m1, m2); + } + + public void testBadInput1() { + String str = "type: \"text\" text: \"\\\""; + try { + Markup.markupFromString(str); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testBadInput2() { + String str = "type: \"text\" text: \"\\a\""; + try { + Markup.markupFromString(str); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testValidParameterKey() { + Markup m = new Markup(); + m.setParameter("ke9__yk_88ey_za7_", "test"); + } + + public void testInValidParameterKeyEmpty() { + Markup m = new Markup(); + try { + m.setParameter("", "test"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testInValidParameterKeyDollar() { + Markup m = new Markup(); + try { + m.setParameter("ke9y$k88ey7", "test"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testInValidParameterKeySpace() { + Markup m = new Markup(); + try { + m.setParameter("ke9yk88ey7 ", "test"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testValidType() { + new Markup("_this_is_1_valid_type_222"); + } + + public void testInValidTypeAmpersand() { + try { + new Markup("abcde1234&"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testInValidTypeSpace() { + try { + new Markup(" "); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testSimpleParcelable() { + Markup markup = new Markup(); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testTypeParcelable() { + Markup markup = new Markup("text"); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testPlainTextsParcelable() { + Markup markup = new Markup(); + markup.setPlainText("plainText"); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testParametersParcelable() { + Markup markup = new Markup(); + markup.setParameter("key1", "value1"); + markup.setParameter("key2", "value2"); + markup.setParameter("key3", "value3"); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testNestedParcelable() { + Markup markup = new Markup(); + markup.addNestedMarkup(new Markup("first")); + markup.addNestedMarkup(new Markup("second")); + markup.addNestedMarkup(new Markup("third")); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testAllFieldsParcelable() { + Markup markup = new Markup("text"); + markup.setPlainText("plain text"); + markup.setParameter("key1", "value1"); + markup.setParameter("key2", "value2"); + markup.setParameter("key3", "value3"); + markup.addNestedMarkup(new Markup("first")); + markup.addNestedMarkup(new Markup("second")); + markup.addNestedMarkup(new Markup("third")); + + Parcel parcel = Parcel.obtain(); + markup.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + + Markup fromParcel = (Markup) Markup.CREATOR.createFromParcel(parcel); + + assertFalse(markup == fromParcel); + assertEquals(markup, fromParcel); + } + + public void testKeyCannotBeType() { + try { + new Markup().setParameter("type", "vale"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testKeyCannotBePlainText() { + try { + new Markup().setParameter("plain_text", "value"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } +} diff --git a/tests/TtsTests/src/com/android/speech/tts/TtsCardinalTest.java b/tests/TtsTests/src/com/android/speech/tts/TtsCardinalTest.java new file mode 100644 index 0000000..c34f4ac --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/TtsCardinalTest.java @@ -0,0 +1,119 @@ +/* + * 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 com.android.speech.tts; + +import junit.framework.Assert; +import android.test.InstrumentationTestCase; +import android.test.MoreAsserts; + +import android.speech.tts.Markup; +import android.speech.tts.Utterance; +import android.speech.tts.Utterance.TtsCardinal; +import android.speech.tts.Utterance.TtsText; + +public class TtsCardinalTest extends InstrumentationTestCase { + + public void testConstruct() { + assertNotNull(new TtsCardinal(0)); + } + + public void testFluentAPI() { + new TtsCardinal() + .setPlainText("a plaintext") // from AbstractTts + .setGender(Utterance.GENDER_MALE) // from AbstractTtsSemioticClass + .setInteger("-10001"); // from TtsText + } + + public void testZero() { + assertEquals("0", new TtsCardinal(0).getInteger()); + } + + public void testThirtyOne() { + assertEquals("31", new TtsCardinal(31).getInteger()); + } + + public void testMarkupZero() { + TtsCardinal c = new TtsCardinal(0); + Markup m = c.getMarkup(); + assertEquals("0", m.getParameter("integer")); + } + + public void testMarkupThirtyOne() { + TtsCardinal c = new TtsCardinal(31); + Markup m = c.getMarkup(); + assertEquals("31", m.getParameter("integer")); + } + + public void testMarkupThirtyOneString() { + TtsCardinal c = new TtsCardinal("31"); + Markup m = c.getMarkup(); + assertEquals("31", m.getParameter("integer")); + } + + public void testMarkupNegativeThirtyOne() { + TtsCardinal c = new TtsCardinal(-31); + Markup m = c.getMarkup(); + assertEquals("-31", m.getParameter("integer")); + } + + public void testMarkupMinusZero() { + TtsCardinal c = new TtsCardinal("-0"); + Markup m = c.getMarkup(); + assertEquals("-0", m.getParameter("integer")); + } + + public void testMarkupNegativeThirtyOneString() { + TtsCardinal c = new TtsCardinal("-31"); + Markup m = c.getMarkup(); + assertEquals("-31", m.getParameter("integer")); + } + + public void testOnlyLetters() { + try { + new TtsCardinal("abc"); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testOnlyMinus() { + try { + new TtsCardinal("-"); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testNegativeLetters() { + try { + new TtsCardinal("-abc"); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testLetterNumberMix() { + try { + new TtsCardinal("-0a1b2c"); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void letterNumberMix2() { + try { + new TtsCardinal("-a0b1c2"); + Assert.fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } +} diff --git a/tests/TtsTests/src/com/android/speech/tts/TtsEnginesTests.java b/tests/TtsTests/src/com/android/speech/tts/TtsEnginesTests.java new file mode 100644 index 0000000..45e5216 --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/TtsEnginesTests.java @@ -0,0 +1,64 @@ +package com.android.speech.tts; + +import android.speech.tts.TtsEngines; +import android.test.InstrumentationTestCase; + +import java.util.Locale; + +public class TtsEnginesTests extends InstrumentationTestCase { + private TtsEngines mTtsHelper; + + @Override + public void setUp() { + mTtsHelper = new TtsEngines(getInstrumentation().getContext()); + } + + public void testParseLocaleString() { + assertEquals(new Locale("en", "US"), mTtsHelper.parseLocaleString("eng-usa")); + assertEquals(new Locale("en", "US"), mTtsHelper.parseLocaleString("eng-USA")); + assertEquals(new Locale("en", "US"), mTtsHelper.parseLocaleString("en-US")); + assertEquals(new Locale("en", "US"), mTtsHelper.parseLocaleString("en_us")); + assertEquals(new Locale("en", "US"), mTtsHelper.parseLocaleString("eng_US")); + assertEquals(new Locale("en", "US", "foobar"), + mTtsHelper.parseLocaleString("eng_US-foobar")); + assertEquals(new Locale("en", "", "foobar"), mTtsHelper.parseLocaleString("eng__foobar")); + assertNull(mTtsHelper.parseLocaleString("cc_xx_barbar")); + assertNull(mTtsHelper.parseLocaleString("cc--barbar")); + + assertEquals(new Locale("en"), mTtsHelper.parseLocaleString("eng")); + assertEquals(new Locale("en","US","var"), mTtsHelper.parseLocaleString("eng-USA-var")); + } + + public void testToOldLocaleStringFormat() { + assertArraysEqual(new String[]{"deu", "DEU", ""}, + TtsEngines.toOldLocaleStringFormat(new Locale("de", "DE"))); + assertArraysEqual(new String[]{"deu", "", ""}, + TtsEngines.toOldLocaleStringFormat(new Locale("de"))); + assertArraysEqual(new String[]{"eng", "", ""}, + TtsEngines.toOldLocaleStringFormat(new Locale("en"))); + assertArraysEqual(new String[]{"eng", "USA", ""}, + TtsEngines.toOldLocaleStringFormat(new Locale("foo"))); + } + + public void testGetLocalePrefForEngine() { + assertEquals(new Locale("en", "US"), + mTtsHelper.getLocalePrefForEngine("foo","foo:en-US")); + assertEquals(new Locale("en", "US"), + mTtsHelper.getLocalePrefForEngine("foo","foo:eng-usa")); + assertEquals(new Locale("en", "US"), + mTtsHelper.getLocalePrefForEngine("foo","foo:eng_USA")); + assertEquals(new Locale("de", "DE"), + mTtsHelper.getLocalePrefForEngine("foo","foo:deu-deu")); + assertEquals(Locale.getDefault(), + mTtsHelper.getLocalePrefForEngine("foo","foo:,bar:xx")); + assertEquals(Locale.getDefault(), + mTtsHelper.getLocalePrefForEngine("other","foo:,bar:xx")); + } + + private void assertArraysEqual(String[] expected, String[] actual) { + assertEquals("array length", expected.length, actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals("index " + i, expected[i], actual[i]); + } + } +}
\ No newline at end of file diff --git a/tests/TtsTests/src/com/android/speech/tts/TtsTextTest.java b/tests/TtsTests/src/com/android/speech/tts/TtsTextTest.java new file mode 100644 index 0000000..35fd453 --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/TtsTextTest.java @@ -0,0 +1,74 @@ +/* + * 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 com.android.speech.tts; + +import android.test.InstrumentationTestCase; + +import android.speech.tts.Markup; +import android.speech.tts.Utterance; +import android.speech.tts.Utterance.TtsText; + +public class TtsTextTest extends InstrumentationTestCase { + + public void testConstruct() { + assertNotNull(new TtsText()); + } + + public void testFluentAPI() { + new TtsText() + .setPlainText("a plaintext") // from AbstractTts + .setGender(Utterance.GENDER_MALE) // from AbstractTtsSemioticClass + .setText("text"); // from TtsText + } + + public void testConstructEmptyString() { + assertTrue(new TtsText("").getText().isEmpty()); + } + + public void testConstructString() { + assertEquals("this is a test.", new TtsText("this is a test.").getText()); + } + + public void testSetText() { + assertEquals("This is a test.", new TtsText().setText("This is a test.").getText()); + } + + public void testEmptyMarkup() { + TtsText t = new TtsText(); + Markup m = t.getMarkup(); + assertEquals("text", m.getType()); + assertNull(m.getPlainText()); + assertEquals(0, m.nestedMarkupSize()); + } + + public void testConstructStringMarkup() { + TtsText t = new TtsText("test"); + Markup m = t.getMarkup(); + assertEquals("text", m.getType()); + assertEquals("test", m.getParameter("text")); + assertEquals(0, m.nestedMarkupSize()); + } + + public void testSetStringMarkup() { + TtsText t = new TtsText(); + t.setText("test"); + Markup m = t.getMarkup(); + assertEquals("text", m.getType()); + assertEquals("test", m.getParameter("text")); + assertEquals(0, m.nestedMarkupSize()); + } +} diff --git a/tests/TtsTests/src/com/android/speech/tts/UtteranceTest.java b/tests/TtsTests/src/com/android/speech/tts/UtteranceTest.java new file mode 100644 index 0000000..8014dd1 --- /dev/null +++ b/tests/TtsTests/src/com/android/speech/tts/UtteranceTest.java @@ -0,0 +1,248 @@ +/* + * 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 com.android.speech.tts; + +import android.speech.tts.Markup; +import android.speech.tts.Utterance; +import android.speech.tts.Utterance.TtsCardinal; +import android.speech.tts.Utterance.TtsText; + +import android.test.InstrumentationTestCase; + +public class UtteranceTest extends InstrumentationTestCase { + + public void testEmptyUtterance() { + Utterance utt = new Utterance(); + assertEquals(0, utt.size()); + } + + public void testSizeCardinal() { + Utterance utt = new Utterance() + .append(new TtsCardinal(42)); + assertEquals(1, utt.size()); + } + + public void testSizeCardinalString() { + Utterance utt = new Utterance() + .append(new TtsCardinal(42)) + .append(new TtsText("is the answer")); + assertEquals(2, utt.size()); + } + + public void testMarkupEmpty() { + Markup m = new Utterance().createMarkup(); + assertEquals("utterance", m.getType()); + assertEquals("", m.getPlainText()); + } + + public void testMarkupCardinal() { + Utterance utt = new Utterance() + .append(new TtsCardinal(42)); + Markup markup = utt.createMarkup(); + assertEquals("utterance", markup.getType()); + assertEquals("42", markup.getPlainText()); + assertEquals("42", markup.getNestedMarkup(0).getParameter("integer")); + assertEquals("42", markup.getNestedMarkup(0).getPlainText()); + } + + public void testMarkupCardinalString() { + Utterance utt = new Utterance() + .append(new TtsCardinal(42)) + .append(new TtsText("is not just a number.")); + Markup markup = utt.createMarkup(); + assertEquals("utterance", markup.getType()); + assertEquals("42 is not just a number.", markup.getPlainText()); + assertEquals("cardinal", markup.getNestedMarkup(0).getType()); + assertEquals("42", markup.getNestedMarkup(0).getParameter("integer")); + assertEquals("42", markup.getNestedMarkup(0).getPlainText()); + assertEquals("text", markup.getNestedMarkup(1).getType()); + assertEquals("is not just a number.", markup.getNestedMarkup(1).getParameter("text")); + assertEquals("is not just a number.", markup.getNestedMarkup(1).getPlainText()); + } + + public void testTextCardinalToFromString() { + Utterance utt = new Utterance() + .append(new TtsCardinal(55)) + .append(new TtsText("this is a text.")); + String str = utt.toString(); + assertEquals( + "type: \"utterance\" " + + "markup { " + + "type: \"cardinal\" " + + "integer: \"55\" " + + "} " + + "markup { " + + "type: \"text\" " + + "text: \"this is a text.\" " + + "}" + , str); + + Utterance utt_new = Utterance.utteranceFromString(str); + assertEquals(str, utt_new.toString()); + } + + public void testNotUtteranceFromString() { + String str = + "type: \"this_is_not_an_utterance\" " + + "markup { " + + "type: \"cardinal\" " + + "plain_text: \"55\" " + + "integer: \"55\" " + + "}"; + try { + Utterance.utteranceFromString(str); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) {} + } + + public void testFromMarkup() { + String markup_str = + "type: \"utterance\" " + + "markup { " + + "type: \"cardinal\" " + + "plain_text: \"55\" " + + "integer: \"55\" " + + "} " + + "markup { " + + "type: \"text\" " + + "plain_text: \"this is a text.\" " + + "text: \"this is a text.\" " + + "}"; + Utterance utt = Utterance.utteranceFromString(markup_str); + assertEquals(markup_str, utt.toString()); + } + + public void testsetPlainText() { + Utterance utt = new Utterance() + .append(new TtsCardinal(-100).setPlainText("minus one hundred")); + assertEquals("minus one hundred", utt.get(0).getPlainText()); + } + + public void testRemoveTextThroughSet() { + Utterance utt = new Utterance() + .append(new TtsText().setText("test").setText(null)); + assertNull(((TtsText) utt.get(0)).getText()); + } + + public void testUnknownNodeWithPlainText() { + String str = + "type: \"utterance\" " + + "markup { " + + "type: \"some_future_feature\" " + + "plain_text: \"biep bob bob\" " + + "bombom: \"lorum ipsum\" " + + "}"; + Utterance utt = Utterance.utteranceFromString(str); + assertNotNull(utt); + assertEquals("text", utt.get(0).getType()); + assertEquals("biep bob bob", ((TtsText) utt.get(0)).getText()); + } + + public void testUnknownNodeWithNoPlainTexts() { + String str = + "type: \"utterance\" " + + "markup { " + + "type: \"some_future_feature\" " + + "bombom: \"lorum ipsum\" " + + "markup { type: \"cardinal\" integer: \"10\" } " + + "markup { type: \"text\" text: \"pears\" } " + + "}"; + Utterance utt = Utterance.utteranceFromString(str); + assertEquals( + "type: \"utterance\" " + + "markup { type: \"cardinal\" integer: \"10\" } " + + "markup { type: \"text\" text: \"pears\" }", utt.toString()); + } + + public void testCreateWarningOnFallbackTrue() { + Utterance utt = new Utterance() + .append(new TtsText("test")) + .setNoWarningOnFallback(true); + assertEquals( + "type: \"utterance\" " + + "no_warning_on_fallback: \"true\" " + + "markup { " + + "type: \"text\" " + + "text: \"test\" " + + "}", utt.toString()); + } + + public void testCreateWarningOnFallbackFalse() { + Utterance utt = new Utterance() + .append(new TtsText("test")) + .setNoWarningOnFallback(false); + assertEquals( + "type: \"utterance\" " + + "no_warning_on_fallback: \"false\" " + + "markup { " + + "type: \"text\" " + + "text: \"test\" " + + "}", utt.toString()); + } + + public void testCreatePlainTexts() { + Utterance utt = new Utterance() + .append(new TtsText("test")) + .append(new TtsCardinal(-55)); + assertEquals( + "type: \"utterance\" " + + "plain_text: \"test -55\" " + + "markup { type: \"text\" plain_text: \"test\" text: \"test\" } " + + "markup { type: \"cardinal\" plain_text: \"-55\" integer: \"-55\" }", + utt.createMarkup().toString() + ); + } + + public void testDontOverwritePlainTexts() { + Utterance utt = new Utterance() + .append(new TtsText("test").setPlainText("else")) + .append(new TtsCardinal(-55).setPlainText("44")); + assertEquals( + "type: \"utterance\" " + + "plain_text: \"else 44\" " + + "markup { type: \"text\" plain_text: \"else\" text: \"test\" } " + + "markup { type: \"cardinal\" plain_text: \"44\" integer: \"-55\" }", + utt.createMarkup().toString() + ); + } + + public void test99BottlesOnWallMarkup() { + Utterance utt = new Utterance() + .append("there are") + .append(99) + .append("bottles on the wall."); + assertEquals( + "type: \"utterance\" " + + "plain_text: \"there are 99 bottles on the wall.\" " + + "markup { type: \"text\" plain_text: \"there are\" text: \"there are\" } " + + "markup { type: \"cardinal\" plain_text: \"99\" integer: \"99\" } " + + "markup { type: \"text\" plain_text: \"bottles on the wall.\" text: \"bottles on the wall.\" }", + utt.createMarkup().toString()); + assertEquals("99", utt.createMarkup().getNestedMarkup(1).getPlainText()); + Markup markup = new Markup(utt.createMarkup()); + assertEquals("99", markup.getNestedMarkup(1).getPlainText()); + } + + public void testWhat() { + Utterance utt = new Utterance() + .append("there are") + .append(99) + .append("bottles on the wall."); + Markup m = utt.createMarkup(); + m.getNestedMarkup(1).getPlainText().equals("99"); + } +} diff --git a/tests/VectorDrawableTest/AndroidManifest.xml b/tests/VectorDrawableTest/AndroidManifest.xml index 28c5f33..890214f 100644 --- a/tests/VectorDrawableTest/AndroidManifest.xml +++ b/tests/VectorDrawableTest/AndroidManifest.xml @@ -17,12 +17,41 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.test.dynamic" > + <uses-sdk android:minSdkVersion="20" /> <application android:hardwareAccelerated="true" android:label="vector" > <activity + android:name="VectorDrawablePerformance" + android:label="Vector Performance" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="com.android.test.dynamic.TEST" /> + </intent-filter> + </activity> + <activity + android:name="BitmapDrawableDupe" + android:label="Bitmap Performance of clones" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="com.android.test.dynamic.TEST" /> + </intent-filter> + + </activity> + <activity + android:name="VectorDrawableAnimation" + android:label="VectorTestAnimation" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="com.android.test.dynamic.TEST" /> + </intent-filter> + </activity> + <activity android:name="VectorDrawableTest" android:label="Vector Icon" > <intent-filter> @@ -33,27 +62,24 @@ </intent-filter> </activity> <activity - android:name="VectorDrawable01" - android:label="VectorTest1" > + android:name="AnimatedVectorDrawableTest" + android:label="AnimatedVectorDrawableTest" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> </activity> - - <activity - android:name="VectorDrawablePerformance" - android:label="Vector Performance" > + <activity + android:name="VectorDrawable01" + android:label="VectorTest1" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> - </activity> - - <activity + <activity android:name="VectorDrawableDupPerf" android:label="Vector Performance of clones" > <intent-filter> @@ -61,7 +87,6 @@ <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> - </activity> <activity android:name="VectorDrawableStaticPerf" @@ -71,9 +96,7 @@ <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> - </activity> - <activity android:name="VectorCheckbox" android:label="On a Checkbox" > @@ -82,7 +105,6 @@ <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> - </activity> <activity android:name="VectorPathChecking" @@ -92,7 +114,6 @@ <category android:name="com.android.test.dynamic.TEST" /> </intent-filter> - </activity> </application> diff --git a/tests/VectorDrawableTest/res/anim/trim_path_animation01.xml b/tests/VectorDrawableTest/res/anim/trim_path_animation01.xml new file mode 100644 index 0000000..d47e019 --- /dev/null +++ b/tests/VectorDrawableTest/res/anim/trim_path_animation01.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" > + + <set android:ordering="sequentially" > + <objectAnimator + android:duration="5000" + android:propertyName="trimPathEnd" + android:valueFrom="0" + android:valueTo="1" + android:valueType="floatType" /> + <objectAnimator + android:duration="5000" + android:propertyName="trimPathEnd" + android:valueFrom="1" + android:valueTo="0" + android:valueType="floatType" /> + </set> + +</set>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/anim/trim_path_animation02.xml b/tests/VectorDrawableTest/res/anim/trim_path_animation02.xml new file mode 100644 index 0000000..3bf2865 --- /dev/null +++ b/tests/VectorDrawableTest/res/anim/trim_path_animation02.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" > + + <objectAnimator + android:duration="5000" + android:propertyName="fill" + android:valueFrom="#FF000000" + android:valueTo="#FFFF0000"/> + +</set>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/anim/trim_path_animation03.xml b/tests/VectorDrawableTest/res/anim/trim_path_animation03.xml new file mode 100644 index 0000000..0c1073e --- /dev/null +++ b/tests/VectorDrawableTest/res/anim/trim_path_animation03.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" > + + <objectAnimator + android:duration="6000" + android:propertyName="rotation" + android:valueFrom="0" + android:valueTo="360" + android:interpolator="@interpolator/custom_path_interpolator" + /> + +</set>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/anim/trim_path_animation04.xml b/tests/VectorDrawableTest/res/anim/trim_path_animation04.xml new file mode 100644 index 0000000..4d0aae1 --- /dev/null +++ b/tests/VectorDrawableTest/res/anim/trim_path_animation04.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" > + <objectAnimator + android:duration="9000" + android:propertyXName="translateX" + android:propertyYName="translateY" + android:pathData="m0,0 q 150, 300 150, 0 t 150, 0, t 150, 0 t -150 0 t -150 0 t -150 0 z" /> +</set>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable-nodpi/bitmap_drawable01.jpg b/tests/VectorDrawableTest/res/drawable-nodpi/bitmap_drawable01.jpg Binary files differnew file mode 100644 index 0000000..dc8c197 --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable-nodpi/bitmap_drawable01.jpg diff --git a/tests/VectorDrawableTest/res/drawable/animation_drawable_vector.xml b/tests/VectorDrawableTest/res/drawable/animation_drawable_vector.xml new file mode 100644 index 0000000..a588960 --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/animation_drawable_vector.xml @@ -0,0 +1,36 @@ +<!-- + 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. +--> +<animation-list xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/animation_drawable_vector" android:oneshot="false"> + <item android:drawable="@drawable/vector_drawable01" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable02" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable03" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable04" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable05" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable06" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable07" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable08" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable09" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable10" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable11" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable12" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable13" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable14" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable15" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable16" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable17" android:duration="300" /> + <item android:drawable="@drawable/vector_drawable18" android:duration="300" /> + </animation-list> diff --git a/tests/VectorDrawableTest/res/drawable/animation_vector_drawable01.xml b/tests/VectorDrawableTest/res/drawable/animation_vector_drawable01.xml new file mode 100644 index 0000000..0900b7c --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/animation_vector_drawable01.xml @@ -0,0 +1,39 @@ +<!-- + 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. +--> +<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/vector_drawable12" > + + <target + android:name="pie1" + android:animation="@anim/trim_path_animation01" /> + <target + android:name="v" + android:animation="@anim/trim_path_animation02" /> + + <target + android:name="rotationGroup" + android:animation="@anim/trim_path_animation03" /> + <target + android:name="rotationGroup3" + android:animation="@anim/trim_path_animation03" /> + <target + android:name="rotationGroupBlue" + android:animation="@anim/trim_path_animation03" /> + <target + android:name="rotationGroup" + android:animation="@anim/trim_path_animation04" /> + +</animated-vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable01.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable01.xml index 118f258..66a9452 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable01.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable01.xml @@ -13,8 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:versionCode="1" > +<vector xmlns:android="http://schemas.android.com/apk/res/android"> <size android:height="48dp" @@ -24,12 +23,13 @@ android:viewportHeight="480" android:viewportWidth="480" /> - <path - android:name="box1" - android:fill="?android:attr/colorControlActivated" - android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z" - android:stroke="?android:attr/colorControlActivated" - android:strokeLineCap="round" - android:strokeLineJoin="round" /> - -</vector>
\ No newline at end of file + <group> + <path + android:name="box1" + android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z" + android:fill="?android:attr/colorControlActivated" + android:stroke="?android:attr/colorControlActivated" + android:strokeLineCap="round" + android:strokeLineJoin="round" /> + </group> +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable02.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable02.xml index 034f7a0..40f23f0 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable02.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable02.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -16,23 +15,22 @@ <vector xmlns:android="http://schemas.android.com/apk/res/android" > <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> - <viewport - android:viewportHeight="320" - android:viewportWidth="320" /> - - <path - android:name="house" - android:fill="#ff440000" - android:pathData="M 130,225 L 130,115 L 130,115 L 70,15 L 10,115 L 10,115 L 10,225 z" - android:pivotX="70" - android:pivotY="120" + <viewport android:viewportWidth="320" + android:viewportHeight="320"/> + <group android:rotation="180" - android:stroke="#FF00FF00" - android:strokeWidth="10" - android:trimPathEnd=".9" - android:trimPathStart=".1" /> - -</vector>
\ No newline at end of file + android:pivotX="70" + android:pivotY="120"> + <path + android:name="house" + android:pathData="M 130,225 L 130,115 L 130,115 L 70,15 L 10,115 L 10,115 L 10,225 z" + android:fill="#ff440000" + android:stroke="#FF00FF00" + android:strokeWidth="10" + android:trimPathStart=".1" + android:trimPathEnd=".9"/> + </group> +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml index 451b28e..5b4c4ab 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml @@ -23,40 +23,47 @@ android:viewportHeight="12.25" android:viewportWidth="7.30625" /> - <path - android:name="clip1" - android:clipToPath="true" - android:pathData=" - M 0, 0 - l 7.3, 0 - l 0, 0 - l -7.3, 0 - z" + <group android:pivotX="3.65" android:pivotY="6.125" - android:rotation="-30" /> - <path - android:name="one" - android:fill="#ff88ff" - android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 - l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0 - l -5.046875,0.0 0.0,-1.0Z" /> - <path - android:name="clip2" - android:clipToPath="true" - android:pathData=" - M 0, 0 + android:rotation="-30" > + <path + android:name="clip1" + android:clipToPath="true" + android:pathData=" + M 0, 6.125 l 7.3, 0 l 0, 12.25 l -7.3, 0 - z" + z" /> + </group> + <group> + <path + android:name="one" + android:fill="#ff88ff" + android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 + l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0 + l -5.046875,0.0 0.0,-1.0Z" /> + </group> + <group android:pivotX="3.65" android:pivotY="6.125" - android:rotation="-30" /> - <path - android:name="two" - android:fill="#ff88ff" - android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 + android:rotation="-30" > + <path + android:name="clip2" + android:clipToPath="true" + android:pathData=" + M 0, 0 + l 7.3, 0 + l 0, 6.125 + l -7.3, 0 + z" /> + </group> + <group> + <path + android:name="two" + android:fill="#ff88ff" + android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625 q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625 q -0.484375,-0.4375 -1.2656252,-0.4375 -0.5625,0.0 -1.1875,0.1875 @@ -65,5 +72,6 @@ q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625 q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375 q -0.78125024,0.8125 -2.2187502,2.265625Z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml index 6f9caa8..90694fb 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable04.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -13,44 +12,48 @@ See the License for the specific language governing permissions and limitations under the License. --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" > +<vector xmlns:android="http://schemas.android.com/apk/res/android"> <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> <viewport - android:viewportHeight="12.25" - android:viewportWidth="7.30625" /> + android:viewportWidth="7.30625" + android:viewportHeight="12.25"/> - <path - android:name="clip1" - android:clipToPath="true" - android:fill="#112233" - android:pathData=" + <group> + <path + android:name="clip1" + android:pathData=" M 3.65, 6.125 m -.001, 0 a .001,.001 0 1,0 .002,0 - a .001,.001 0 1,0 -.002,0z" /> - <path - android:name="one" - android:fill="#ff88ff" - android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 + a .001,.001 0 1,0 -.002,0z" + android:clipToPath="true" + android:fill="#112233" + /> + + <path + android:name="one" + android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0 - l -5.046875,0.0 0.0,-1.0Z" /> - <path - android:name="clip2" - android:clipToPath="true" - android:fill="#112233" - android:pathData=" + l -5.046875,0.0 0.0,-1.0Z" + android:fill="#ff88ff" + /> + <path + android:name="clip2" + android:pathData=" M 3.65, 6.125 m -6, 0 a 6,6 0 1,0 12,0 - a 6,6 0 1,0 -12,0z" /> - <path - android:name="two" - android:fill="#ff88ff" - android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 + a 6,6 0 1,0 -12,0z" + android:clipToPath="true" + android:fill="#112233" + /> + <path + android:name="two" + android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625 q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625 q -0.484375,-0.4375 -1.2656252,-0.4375 -0.5625,0.0 -1.1875,0.1875 @@ -58,6 +61,8 @@ q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875 q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625 q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375 - q -0.78125024,0.8125 -2.2187502,2.265625Z" /> - -</vector>
\ No newline at end of file + q -0.78125024,0.8125 -2.2187502,2.265625Z" + android:fill="#ff88ff" + /> + </group> +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml index e6c2557..c6595fa 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml @@ -23,17 +23,18 @@ android:viewportHeight="12.25" android:viewportWidth="7.30625" /> - <path - android:name="one" - android:fill="#ffff00" - android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 + <group> + <path + android:name="one" + android:fill="#ffff00" + android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125 l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0 l -5.046875,0.0 0.0,-1.0Z" /> - <path - android:name="two" - android:fill="#ffff00" - android:fillOpacity="0" - android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 + <path + android:name="two" + android:fill="#ffff00" + android:fillOpacity="0" + android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375 q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625 q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625 q -0.484375,-0.4375 -1.2656252,-0.4375 -0.5625,0.0 -1.1875,0.1875 @@ -42,5 +43,5 @@ q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625 q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375 q -0.78125024,0.8125 -2.2187502,2.265625Z" /> - + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable06.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable06.xml index 3f8cc09..ab5f7f4 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable06.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable06.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -16,38 +15,38 @@ <vector xmlns:android="http://schemas.android.com/apk/res/android" > <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> <viewport - android:viewportHeight="700" - android:viewportWidth="700" /> + android:viewportWidth="700" + android:viewportHeight="700"/> - <path - android:name="path2451" - android:pathData="M 569.374 461.472L 569.374 160.658L 160.658 160.658L 160.658 461.472L 569.374 461.472z" - android:stroke="#FF000000" - android:strokeWidth="30.65500000000000" /> - <path - android:name="path2453" - android:pathData="M 365.015 311.066" - android:stroke="#FF000000" - android:strokeWidth="30.655000000000001" /> - <path - android:name="path2455" - android:fill="#FFFFFFFF" - android:pathData="M 164.46 164.49L 340.78 343.158C 353.849 356.328 377.63 356.172 390.423 343.278L 566.622 165.928" - android:stroke="#FF000000" - android:strokeWidth="30.655000000000001" /> - <path - android:name="path2457" - android:pathData="M 170.515 451.566L 305.61 313.46" - android:stroke="#000000" - android:strokeWidth="30.655000000000001" /> - <path - android:name="path2459" - android:pathData="M 557.968 449.974L 426.515 315.375" - android:stroke="#000000" - android:strokeWidth="30.655000000000001" /> - -</vector>
\ No newline at end of file + <group> + <path android:pathData="M 569.374 461.472L 569.374 160.658L 160.658 160.658L 160.658 461.472L 569.374 461.472z" + android:name="path2451" + android:fill="#00000000" + android:stroke="#FF000000" + android:strokeWidth="30.65500000000000"/> + <path android:pathData="M 365.015 311.066" + android:name="path2453" + android:fill="#00000000" + android:stroke="#FF000000" + android:strokeWidth="30.655000000000001"/> + <path android:pathData="M 164.46 164.49L 340.78 343.158C 353.849 356.328 377.63 356.172 390.423 343.278L 566.622 165.928" + android:name="path2455" + android:stroke="#FF000000" + android:fill="#FFFFFFFF" + android:strokeWidth="30.655000000000001"/> + <path android:pathData="M 170.515 451.566L 305.61 313.46" + android:name="path2457" + android:fill="#00000000" + android:stroke="#000000" + android:strokeWidth="30.655000000000001"/> + <path android:pathData="M 557.968 449.974L 426.515 315.375" + android:name="path2459" + android:fill="#00000000" + android:stroke="#000000" + android:strokeWidth="30.655000000000001"/> + </group> +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable07.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable07.xml index 4db5090..7c7e679 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable07.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable07.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -13,21 +12,21 @@ See the License for the specific language governing permissions and limitations under the License. --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" > - +<vector xmlns:android="http://schemas.android.com/apk/res/android" > <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> - <viewport - android:viewportHeight="110" - android:viewportWidth="140" /> + <viewport android:viewportWidth="140" + android:viewportHeight="110"/> - <path - android:name="back" - android:fill="#ffffffff" - android:pathData="M 20,55 l 35.3,-35.3 7.07,7.07 -35.3,35.3 z + <group> + <path + android:name="back" + android:pathData="M 20,55 l 35.3,-35.3 7.07,7.07 -35.3,35.3 z M 27,50 l 97,0 0,10 -97,0 z - M 20,55 l 7.07,-7.07 35.3,35.3 -7.07,7.07 z" /> - -</vector>
\ No newline at end of file + M 20,55 l 7.07,-7.07 35.3,35.3 -7.07,7.07 z" + android:fill="#ffffffff" + /> + </group> +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable08.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable08.xml index 44ef979..59f7459 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable08.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable08.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -16,18 +15,20 @@ <vector xmlns:android="http://schemas.android.com/apk/res/android" > <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> - <viewport - android:viewportHeight="600" - android:viewportWidth="600" /> - <path - android:name="pie1" - android:fill="#ffffcc00" - android:pathData="M535.441,412.339A280.868,280.868 0 1,1 536.186,161.733L284.493,286.29Z" - android:stroke="#FF00FF00" - android:strokeWidth="1" /> + <viewport android:viewportWidth="600" + android:viewportHeight="600"/> -</vector>
\ No newline at end of file + <group> + <path + android:name="pie1" + android:pathData="M535.441,412.339A280.868,280.868 0 1,1 536.186,161.733L284.493,286.29Z" + android:fill="#ffffcc00" + android:stroke="#FF00FF00" + android:strokeWidth="1"/> + </group> + +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable09.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable09.xml index 248a143..c93c85f 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable09.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable09.xml @@ -23,12 +23,14 @@ android:viewportHeight="200" android:viewportWidth="200" /> - <path - android:name="house" - android:fill="#ffffffff" - android:pathData="M 100,20 l 0,0 0,140 -80,0 z M 100,20 l 0,0 80,140 -80,0 z" + <group android:pivotX="100" android:pivotY="100" - android:rotation="90" /> + android:rotation="90"> + <path + android:name="house" + android:fill="#ffffffff" + android:pathData="M 100,20 l 0,0 0,140 -80,0 z M 100,20 l 0,0 80,140 -80,0 z"/> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable10.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable10.xml index 56c2972..8484e9e 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable10.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable10.xml @@ -21,24 +21,26 @@ android:width="64dp" /> <viewport - android:viewportHeight="200" - android:viewportWidth="200" /> + android:viewportWidth="200" + android:viewportHeight="200"/> - <path - android:name="bar3" - android:fill="#FFFFFFFF" - android:pathData="M49.001,60c-5.466,0 -9.899,4.478 -9.899,10s4.434,10,9.899,10c5.468,0,9.899 -4.478,9.899 -10S54.469,60,49.001,60z" /> - <path - android:name="bar2" - android:fill="#FFFFFFFF" - android:pathData="M28.001,48.787l7,7.07c7.731 -7.811,20.269 -7.81,28.001,0l6.999 -7.07C58.403,37.071,39.599,37.071,28.001,48.787z" /> - <path - android:name="bar1" - android:fill="#FF555555" - android:pathData="M14.001,34.645 L21,41.716c15.464 -15.621,40.536 -15.621,56,0l7.001 -7.071C64.672,15.119,33.33,15.119,14.001,34.645z" /> - <path - android:name="bar0" - android:fill="#FF555555" - android:pathData="M0,20.502l6.999,7.071 c23.196 -23.431,60.806 -23.431,84.002,0L98,20.503C70.938 -6.834,27.063 -6.834,0,20.502z" /> + <group> + <path + android:name="bar3" + android:fill="#FFFFFFFF" + android:pathData="M49.001,60c-5.466,0 -9.899,4.478 -9.899,10s4.434,10,9.899,10c5.468,0,9.899 -4.478,9.899 -10S54.469,60,49.001,60z" /> + <path + android:name="bar2" + android:fill="#FFFFFFFF" + android:pathData="M28.001,48.787l7,7.07c7.731 -7.811,20.269 -7.81,28.001,0l6.999 -7.07C58.403,37.071,39.599,37.071,28.001,48.787z" /> + <path + android:name="bar1" + android:fill="#FF555555" + android:pathData="M14.001,34.645 L21,41.716c15.464 -15.621,40.536 -15.621,56,0l7.001 -7.071C64.672,15.119,33.33,15.119,14.001,34.645z" /> + <path + android:name="bar0" + android:fill="#FF555555" + android:pathData="M0,20.502l6.999,7.071 c23.196 -23.431,60.806 -23.431,84.002,0L98,20.503C70.938 -6.834,27.063 -6.834,0,20.502z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable11.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable11.xml index 16d8b48..3422bbf 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable11.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable11.xml @@ -23,16 +23,17 @@ android:viewportHeight="80" android:viewportWidth="40" /> - <path - android:name="battery" - android:fill="#3388ff" - android:pathData="M 20.28125,2.0000002 C 17.352748,2.0000002 15,4.3527485 15,7.2812502 L 15,8.0000002 L 13.15625,8.0000002 C 9.7507553,8.0000002 7,10.750759 7,14.15625 L 7,39.84375 C 7,43.24924 9.7507558,46 13.15625,46 L 33.84375,46 C 37.249245,46 39.999999,43.24924 40,39.84375 L 40,14.15625 C 40,10.75076 37.249243,8.0000002 33.84375,8.0000002 L 32,8.0000002 L 32,7.2812502 C 32,4.3527485 29.647252,2.0000002 26.71875,2.0000002 L 20.28125,2.0000002 z" - android:rotation="0" - android:stroke="#ff8833" - android:strokeWidth="1" /> - <path - android:name="spark" - android:fill="#FFFF0000" - android:pathData="M 30,18.031528 L 25.579581,23.421071 L 29.370621,26.765348 L 20.096792,37 L 21.156922,28.014053 L 17,24.902844 L 20.880632,18 L 30,18.031528 z" /> + <group> + <path + android:name="battery" + android:fill="#3388ff" + android:pathData="M 20.28125,2.0000002 C 17.352748,2.0000002 15,4.3527485 15,7.2812502 L 15,8.0000002 L 13.15625,8.0000002 C 9.7507553,8.0000002 7,10.750759 7,14.15625 L 7,39.84375 C 7,43.24924 9.7507558,46 13.15625,46 L 33.84375,46 C 37.249245,46 39.999999,43.24924 40,39.84375 L 40,14.15625 C 40,10.75076 37.249243,8.0000002 33.84375,8.0000002 L 32,8.0000002 L 32,7.2812502 C 32,4.3527485 29.647252,2.0000002 26.71875,2.0000002 L 20.28125,2.0000002 z" + android:stroke="#ff8833" + android:strokeWidth="1" /> + <path + android:name="spark" + android:fill="#FFFF0000" + android:pathData="M 30,18.031528 L 25.579581,23.421071 L 29.370621,26.765348 L 20.096792,37 L 21.156922,28.014053 L 17,24.902844 L 20.880632,18 L 30,18.031528 z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable12.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable12.xml index 0a0407d..e28ec41 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable12.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable12.xml @@ -23,20 +23,83 @@ android:viewportHeight="600" android:viewportWidth="600" /> - <path - android:name="pie1" - android:pathData="M300,70 a230,230 0 1,0 1,0 z" - android:stroke="#FF00FF00" - android:strokeWidth="70" - android:trimPathEnd=".75" - android:trimPathOffset="0" - android:trimPathStart="0" /> - <path - android:name="v" - android:fill="#FF00FF00" - android:pathData="M300,70 l 0,-70 70,70 -70,70z" - android:pivotX="300" - android:pivotY="300" - android:rotation="0" /> + <group + android:name="rotationGroup" + android:pivotX="300.0" + android:pivotY="300.0" + android:rotation="45.0" > + <path + android:name="pie1" + android:fill="#00000000" + android:pathData="M300,70 a230,230 0 1,0 1,0 z" + android:stroke="#FF00FF00" + android:strokeWidth="70" + android:trimPathEnd=".75" + android:trimPathOffset="0" + android:trimPathStart="0" /> + <path + android:name="v" + android:fill="#FF00FF00" + android:pathData="M300,70 l 0,-70 70,70 -70,70z" /> + + <group + android:name="translateToCenterGroup" + android:rotation="0.0" + android:translateX="200.0" + android:translateY="200.0" > + <path + android:name="twoLines" + android:pathData="@string/twoLinePathData" + android:stroke="#FFFF0000" + android:strokeWidth="20" /> + + <group + android:name="rotationGroup2" + android:pivotX="0.0" + android:pivotY="0.0" + android:rotation="-45.0" > + <path + android:name="twoLines1" + android:pathData="@string/twoLinePathData" + android:stroke="#FF00FF00" + android:strokeWidth="20" /> + + <group + android:name="translateGroupHalf" + android:translateX="65.0" + android:translateY="80.0" > + <group + android:name="rotationGroup3" + android:pivotX="-65.0" + android:pivotY="-80.0" + android:rotation="-45.0" > + <path + android:name="twoLines2" + android:fill="#FF00FF00" + android:pathData="@string/twoLinePathData" + android:stroke="#FF00FF00" + android:strokeWidth="20" /> + + <group + android:name="translateGroup" + android:translateX="65.0" + android:translateY="80.0" > + <group + android:name="rotationGroupBlue" + android:pivotX="-65.0" + android:pivotY="-80.0" + android:rotation="-45.0" > + <path + android:name="twoLines3" + android:pathData="@string/twoLinePathData" + android:stroke="#FF0000FF" + android:strokeWidth="20" /> + </group> + </group> + </group> + </group> + </group> + </group> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable13.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable13.xml index 385b1e9..8c946df 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable13.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable13.xml @@ -23,20 +23,19 @@ android:viewportHeight="400" android:viewportWidth="600" /> - <path - android:name="pie1" - android:fill="#ffffffff" - android:pathData="M300,200 h-150 a150,150 0 1,0 150,-150 z" - android:stroke="#FF00FF00" - android:strokeWidth="1" /> - <path - android:name="half" - android:fill="#FFFF0000" - android:pathData="M275,175 v-150 a150,150 0 0,0 -150,150 z" - android:pivotX="300" - android:pivotY="200" - android:rotation="0" - android:stroke="#FF0000FF" - android:strokeWidth="5" /> + <group> + <path + android:name="pie1" + android:fill="#ffffffff" + android:pathData="M300,200 h-150 a150,150 0 1,0 150,-150 z" + android:stroke="#FF00FF00" + android:strokeWidth="1" /> + <path + android:name="half" + android:fill="#FFFF0000" + android:pathData="M275,175 v-150 a150,150 0 0,0 -150,150 z" + android:stroke="#FF0000FF" + android:strokeWidth="5" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable14.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable14.xml index b701b35..8d4ca61 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable14.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable14.xml @@ -23,17 +23,20 @@ android:viewportHeight="500" android:viewportWidth="800" /> - <path - android:name="pie2" - android:pathData="M200,350 l 50,-25 + <group + android:pivotX="90" + android:pivotY="100" + android:rotation="20"> + <path + android:name="pie2" + android:pathData="M200,350 l 50,-25 a25,12 -30 0,1 100,-50 l 50,-25 a25,25 -30 0,1 100,-50 l 50,-25 a25,37 -30 0,1 100,-50 l 50,-25 a25,50 -30 0,1 100,-50 l 50,-25" - android:pivotX="90" - android:pivotY="100" - android:rotation="20" - android:stroke="#FF00FF00" - android:strokeWidth="10" /> + android:fill="#00000000" + android:stroke="#FF00FF00" + android:strokeWidth="10" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable15.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable15.xml index 8d773e1..b08e157 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable15.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable15.xml @@ -23,14 +23,16 @@ android:viewportHeight="400" android:viewportWidth="500" /> - <path - android:name="house" - android:fill="#ff440000" - android:pathData="M100,200 C100,100 250,100 250,200 S400,300 400,200" + <group android:pivotX="250" android:pivotY="200" - android:rotation="180" - android:stroke="#FFFF0000" - android:strokeWidth="10" /> + android:rotation="180"> + <path + android:name="house" + android:fill="#ff440000" + android:pathData="M100,200 C100,100 250,100 250,200 S400,300 400,200" + android:stroke="#FFFF0000" + android:strokeWidth="10" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable16.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable16.xml index 3b7926c..ae85d9b 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable16.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable16.xml @@ -23,13 +23,29 @@ android:viewportHeight="200" android:viewportWidth="200" /> - <path - android:name="house" - android:pathData="M 100,10 v 90 M 10,100 h 90" + <group> + <path + android:name="background1" + android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" + android:fill="#FF000000"/> + <path + android:name="background2" + android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" + android:fill="#FF000000"/> + </group> + <group android:pivotX="100" android:pivotY="100" - android:rotation="360" - android:stroke="#FF00FF00" - android:strokeWidth="10" /> + android:rotation="90" + android:scaleX="0.75" + android:scaleY="0.5" + android:translateX="0.0" + android:translateY="100.0"> + <path + android:name="twoLines" + android:pathData="M 100,10 v 90 M 10,100 h 90" + android:stroke="#FF00FF00" + android:strokeWidth="10" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable17.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable17.xml index 1ec72be..c28aff4 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable17.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable17.xml @@ -1,5 +1,4 @@ -<!-- - Copyright (C) 2014 The Android Open Source Project +<!-- 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. @@ -16,20 +15,19 @@ <vector xmlns:android="http://schemas.android.com/apk/res/android" > <size - android:height="64dp" - android:width="64dp" /> + android:width="64dp" + android:height="64dp"/> - <viewport - android:viewportHeight="600" - android:viewportWidth="1200" /> + <viewport android:viewportWidth="1200" + android:viewportHeight="600"/> - <path - android:name="house" - android:pathData="M200,300 Q400,50 600,300 T1000,300" - android:pivotX="600" - android:pivotY="300" - android:rotation="360" - android:stroke="#FFFF0000" - android:strokeWidth="10" /> + <group> + <path + android:name="house" + android:pathData="M200,300 Q400,50 600,300 T1000,300" + android:fill="#00000000" + android:stroke="#FFFF0000" + android:strokeWidth="10"/> + </group> -</vector>
\ No newline at end of file +</vector> diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable18.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable18.xml index 12d0e93..d7042fd 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable18.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable18.xml @@ -23,13 +23,13 @@ android:viewportHeight="400" android:viewportWidth="500" /> - <path - android:name="house" - android:pathData="M100,200 C100,100 250,100 250,200 S400,300 400,200" - android:pivotX="250" - android:pivotY="200" - android:rotation="360" - android:stroke="#FFFFFF00" - android:strokeWidth="10" /> + <group> + <path + android:name="house" + android:pathData="M100,200 C100,100 250,100 250,200 S400,300 400,200" + android:fill="#00000000" + android:stroke="#FFFFFF00" + android:strokeWidth="10" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable19.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable19.xml index 017e04c..47a9574 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable19.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable19.xml @@ -23,12 +23,15 @@ android:viewportHeight="800" android:viewportWidth="1000" /> - <path - android:name="house" - android:pathData="M10,300 Q400,550 600,300 T1000,300" - android:pivotX="90" - android:pivotY="100" - android:stroke="#FFFF0000" - android:strokeWidth="60" /> + <group> + <path + android:name="house" + android:pathData="M10,300 Q400,550 600,300 T1000,300" + android:pivotX="90" + android:pivotY="100" + android:fill="#00000000" + android:stroke="#FFFF0000" + android:strokeWidth="60" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable20.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable20.xml index b7002a3..b8af7e2 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable20.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable20.xml @@ -23,14 +23,16 @@ android:viewportHeight="480" android:viewportWidth="480" /> - <path - android:name="edit" - android:fill="#FF00FFFF" - android:pathData="M406.667,180c0,0 -100 -100 -113.334 -113.333 + <group> + <path + android:name="edit" + android:fill="#FF00FFFF" + android:pathData="M406.667,180c0,0 -100 -100 -113.334 -113.333 c-13.333 -13.334 -33.333,0 -33.333,0l-160,160c0,0 -40,153.333 -40,173.333c0,13.333,13.333,13.333,13.333,13.333l173.334 -40 c0,0,146.666 -146.666,160 -160C420,200,406.667,180,406.667,180z M226.399,356.823L131.95,378.62l-38.516 -38.522 c7.848 -34.675,20.152 -82.52,23.538 -95.593l3.027,2.162l106.667,106.666L226.399,356.823z" - android:stroke="#FF000000" - android:strokeWidth="10" /> + android:stroke="#FF000000" + android:strokeWidth="10" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable21.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable21.xml new file mode 100644 index 0000000..e0013e7 --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable21.xml @@ -0,0 +1,51 @@ +<!-- + 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="64dp" + android:width="64dp" /> + + <viewport + android:viewportHeight="200" + android:viewportWidth="200" /> + + <group> + <path + android:name="background1" + android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" + android:fill="#FF000000"/> + <path + android:name="background2" + android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" + android:fill="#FF000000"/> + </group> + <group + android:pivotX="0" + android:pivotY="0" + android:rotation="90" + android:scaleX="0.75" + android:scaleY="0.5" + android:translateX="100.0" + android:translateY="100.0"> + <path + android:name="twoLines" + android:pathData="M 100,10 v 90 M 10,100 h 90" + android:stroke="#FF00FF00" + android:strokeWidth="10" /> + </group> + +</vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable22.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable22.xml new file mode 100644 index 0000000..8d38cb5 --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable22.xml @@ -0,0 +1,72 @@ +<!-- + 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="64dp" + android:width="64dp" /> + + <viewport + android:viewportHeight="400" + android:viewportWidth="400" /> + + <group android:name="backgroundGroup" > + <path + android:name="background1" + android:fill="#80000000" + android:pathData="M 0,0 l 200,0 l 0, 200 l -200, 0 z" /> + <path + android:name="background2" + android:fill="#80000000" + android:pathData="M 200,200 l 200,0 l 0, 200 l -200, 0 z" /> + </group> + <group + android:name="translateToCenterGroup" + android:translateX="50.0" + android:translateY="90.0" > + <path + android:name="twoLines" + android:pathData="M 0,0 v 100 M 0,0 h 100" + android:stroke="#FFFF0000" + android:strokeWidth="20" /> + + <group + android:name="rotationGroup" + android:pivotX="0.0" + android:pivotY="0.0" + android:rotation="-45.0" > + <path + android:name="twoLines1" + android:pathData="M 0,0 v 100 M 0,0 h 100" + android:stroke="#FF00FF00" + android:strokeWidth="20" /> + + <group + android:name="translateGroup" + android:translateX="130.0" + android:translateY="160.0" > + <group android:name="scaleGroup" > + <path + android:name="twoLines2" + android:pathData="M 0,0 v 100 M 0,0 h 100" + android:stroke="#FF0000FF" + android:strokeWidth="20" /> + </group> + </group> + </group> + </group> + +</vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable23.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable23.xml new file mode 100644 index 0000000..52acd7a --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable23.xml @@ -0,0 +1,86 @@ +<!-- + 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="64dp" + android:width="64dp" /> + + <viewport + android:viewportHeight="400" + android:viewportWidth="400" /> + + <group android:name="backgroundGroup" > + <path + android:name="background1" + android:fill="#80000000" + android:pathData="M 0,0 l 200,0 l 0, 200 l -200, 0 z" /> + <path + android:name="background2" + android:fill="#80000000" + android:pathData="M 200,200 l 200,0 l 0, 200 l -200, 0 z" /> + </group> + <group + android:name="translateToCenterGroup" + android:translateX="50.0" + android:translateY="90.0" > + <path + android:name="twoLines" + android:pathData="@string/twoLinePathData" + android:stroke="#FFFF0000" + android:strokeWidth="20" /> + + <group + android:name="rotationGroup" + android:pivotX="0.0" + android:pivotY="0.0" + android:rotation="-45.0" > + <path + android:name="twoLines1" + android:pathData="@string/twoLinePathData" + android:stroke="#FF00FF00" + android:strokeWidth="20" /> + + <group + android:name="translateGroup" + android:translateX="130.0" + android:translateY="160.0" > + <group android:name="scaleGroup" > + <path + android:name="twoLines3" + android:pathData="@string/twoLinePathData" + android:stroke="#FF0000FF" + android:strokeWidth="20" /> + </group> + </group> + + <group + android:name="translateGroupHalf" + android:translateX="65.0" + android:translateY="80.0" > + <group android:name="scaleGroup" > + <path + android:name="twoLines2" + android:pathData="@string/twoLinePathData" + android:fill="?android:attr/colorForeground" + android:stroke="?android:attr/colorForeground" + android:strokeWidth="20" /> + </group> + </group> + </group> + </group> + +</vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable24.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable24.xml new file mode 100644 index 0000000..c062d70 --- /dev/null +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable24.xml @@ -0,0 +1,91 @@ +<!-- + 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="64dp" + android:width="64dp" /> + + <viewport + android:viewportHeight="400" + android:viewportWidth="400" /> + + <group android:name="backgroundGroup" + android:alpha = "0.5" > + <path + android:name="background1" + android:fill="#FF000000" + android:pathData="M 0,0 l 200,0 l 0, 200 l -200, 0 z" /> + <path + android:name="background2" + android:fill="#FF000000" + android:pathData="M 200,200 l 200,0 l 0, 200 l -200, 0 z" /> + </group> + <group + android:name="translateToCenterGroup" + android:translateX="50.0" + android:translateY="90.0" + android:alpha = "0.5" > + <path + android:name="twoLines" + android:pathData="@string/twoLinePathData" + android:stroke="#FFFF0000" + android:strokeWidth="20" /> + + <group + android:name="rotationGroup" + android:pivotX="0.0" + android:pivotY="0.0" + android:rotation="-45.0" + android:alpha = "0.5" > + <path + android:name="twoLines1" + android:pathData="@string/twoLinePathData" + android:stroke="#FF00FF00" + android:strokeWidth="20" /> + + <group + android:name="translateGroup" + android:translateX="130.0" + android:translateY="160.0" + android:alpha = "0.5"> + <group android:name="scaleGroup" > + <path + android:name="twoLines3" + android:pathData="@string/twoLinePathData" + android:stroke="#FF0000FF" + android:strokeWidth="20" /> + </group> + </group> + + <group + android:name="translateGroupHalf" + android:translateX="65.0" + android:translateY="80.0" + android:alpha = "0.5"> + <group android:name="scaleGroup" > + <path + android:name="twoLines2" + android:pathData="@string/twoLinePathData" + android:fill="?android:attr/colorForeground" + android:stroke="?android:attr/colorForeground" + android:strokeWidth="20" /> + </group> + </group> + </group> + </group> + +</vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_icon_create.xml b/tests/VectorDrawableTest/res/drawable/vector_icon_create.xml index cda213d..22ce795 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_icon_create.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_icon_create.xml @@ -23,8 +23,10 @@ limitations under the License. android:viewportHeight="24" android:viewportWidth="24" /> - <path - android:fill="#FF000000" - android:pathData="M3.0,17.25L3.0,21.0l3.75,0.0L17.813995,9.936001l-3.75,-3.75L3.0,17.25zM20.707,7.0429993c0.391,-0.391 0.391,-1.023 0.0,-1.414l-2.336,-2.336c-0.391,-0.391 -1.023,-0.391 -1.414,0.0l-1.832,1.832l3.75,3.75L20.707,7.0429993z" /> + <group> + <path + android:fill="#FF000000" + android:pathData="M3.0,17.25L3.0,21.0l3.75,0.0L17.813995,9.936001l-3.75,-3.75L3.0,17.25zM20.707,7.0429993c0.391,-0.391 0.391,-1.023 0.0,-1.414l-2.336,-2.336c-0.391,-0.391 -1.023,-0.391 -1.414,0.0l-1.832,1.832l3.75,3.75L20.707,7.0429993z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_icon_delete.xml b/tests/VectorDrawableTest/res/drawable/vector_icon_delete.xml index 2cb6381..042173c 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_icon_delete.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_icon_delete.xml @@ -23,8 +23,10 @@ limitations under the License. android:viewportHeight="24" android:viewportWidth="24" /> - <path - android:fill="#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" /> + <group> + <path + android:fill="#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" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_icon_heart.xml b/tests/VectorDrawableTest/res/drawable/vector_icon_heart.xml index d58942e..6b6f43d 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_icon_heart.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_icon_heart.xml @@ -23,8 +23,10 @@ limitations under the License. android:viewportHeight="24" android:viewportWidth="24" /> - <path - android:fill="#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" /> + <group> + <path + android:fill="#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" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_icon_schedule.xml b/tests/VectorDrawableTest/res/drawable/vector_icon_schedule.xml index 4717be4..ba8ebca 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_icon_schedule.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_icon_schedule.xml @@ -23,11 +23,13 @@ limitations under the License. android:viewportHeight="24" android:viewportWidth="24" /> - <path - android:fillOpacity="0.9" - android:pathData="M11.994999,2.0C6.4679985,2.0 2.0,6.4780006 2.0,12.0s4.468,10.0 9.995,10.0S22.0,17.522 22.0,12.0S17.521,2.0 11.994999,2.0zM12.0,20.0c-4.42,0.0 -8.0,-3.582 -8.0,-8.0s3.58,-8.0 8.0,-8.0s8.0,3.582 8.0,8.0S16.419998,20.0 12.0,20.0z" /> - <path - android:fillOpacity="0.9" - android:pathData="M12.5,6.0l-1.5,0.0 0.0,7.0 5.3029995,3.1819992 0.75,-1.249999 -4.5529995,-2.7320004z" /> + <group> + <path + android:fillOpacity="0.9" + android:pathData="M11.994999,2.0C6.4679985,2.0 2.0,6.4780006 2.0,12.0s4.468,10.0 9.995,10.0S22.0,17.522 22.0,12.0S17.521,2.0 11.994999,2.0zM12.0,20.0c-4.42,0.0 -8.0,-3.582 -8.0,-8.0s3.58,-8.0 8.0,-8.0s8.0,3.582 8.0,8.0S16.419998,20.0 12.0,20.0z" /> + <path + android:fillOpacity="0.9" + android:pathData="M12.5,6.0l-1.5,0.0 0.0,7.0 5.3029995,3.1819992 0.75,-1.249999 -4.5529995,-2.7320004z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_icon_settings.xml b/tests/VectorDrawableTest/res/drawable/vector_icon_settings.xml index c626325..896a938 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_icon_settings.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_icon_settings.xml @@ -23,8 +23,10 @@ limitations under the License. android:viewportHeight="24" android:viewportWidth="24" /> - <path - android:fill="#FF000000" - android:pathData="M19.429,12.975998c0.042,-0.32 0.07,-0.645 0.07,-0.976s-0.029,-0.655 -0.07,-0.976l2.113,-1.654c0.188,-0.151 0.243,-0.422 0.118,-0.639l-2.0,-3.463c-0.125,-0.217 -0.386,-0.304 -0.612,-0.218l-2.49,1.004c-0.516,-0.396 -1.081,-0.731 -1.69,-0.984l-0.375,-2.648C14.456,2.1829987 14.25,2.0 14.0,2.0l-4.0,0.0C9.75,2.0 9.544,2.1829987 9.506,2.422001L9.131,5.0699997C8.521,5.322998 7.957,5.6570015 7.44,6.054001L4.952,5.0509987C4.726,4.965 4.464,5.052002 4.34,5.269001l-2.0,3.463C2.2150002,8.947998 2.27,9.219002 2.4580002,9.369999l2.112,1.653C4.528,11.344002 4.5,11.668999 4.5,12.0s0.029,0.656 0.071,0.977L2.4580002,14.630001c-0.188,0.151 -0.243,0.422 -0.118,0.639l2.0,3.463c0.125,0.217 0.386,0.304 0.612,0.218l2.489,-1.004c0.516,0.396 1.081,0.731 1.69,0.984l0.375,2.648C9.544,21.817001 9.75,22.0 10.0,22.0l4.0,0.0c0.25,0.0 0.456,-0.183 0.494,-0.422l0.375,-2.648c0.609,-0.253 1.174,-0.588 1.689,-0.984l2.49,1.004c0.226,0.086 0.487,-0.001 0.612,-0.218l2.0,-3.463c0.125,-0.217 0.07,-0.487 -0.118,-0.639L19.429,12.975998zM12.0,16.0c-2.21,0.0 -4.0,-1.791 -4.0,-4.0c0.0,-2.21 1.79,-4.0 4.0,-4.0c2.208,0.0 4.0,1.79 4.0,4.0C16.0,14.209 14.208,16.0 12.0,16.0z" /> + <group> + <path + android:fill="#FF000000" + android:pathData="M19.429,12.975998c0.042,-0.32 0.07,-0.645 0.07,-0.976s-0.029,-0.655 -0.07,-0.976l2.113,-1.654c0.188,-0.151 0.243,-0.422 0.118,-0.639l-2.0,-3.463c-0.125,-0.217 -0.386,-0.304 -0.612,-0.218l-2.49,1.004c-0.516,-0.396 -1.081,-0.731 -1.69,-0.984l-0.375,-2.648C14.456,2.1829987 14.25,2.0 14.0,2.0l-4.0,0.0C9.75,2.0 9.544,2.1829987 9.506,2.422001L9.131,5.0699997C8.521,5.322998 7.957,5.6570015 7.44,6.054001L4.952,5.0509987C4.726,4.965 4.464,5.052002 4.34,5.269001l-2.0,3.463C2.2150002,8.947998 2.27,9.219002 2.4580002,9.369999l2.112,1.653C4.528,11.344002 4.5,11.668999 4.5,12.0s0.029,0.656 0.071,0.977L2.4580002,14.630001c-0.188,0.151 -0.243,0.422 -0.118,0.639l2.0,3.463c0.125,0.217 0.386,0.304 0.612,0.218l2.489,-1.004c0.516,0.396 1.081,0.731 1.69,0.984l0.375,2.648C9.544,21.817001 9.75,22.0 10.0,22.0l4.0,0.0c0.25,0.0 0.456,-0.183 0.494,-0.422l0.375,-2.648c0.609,-0.253 1.174,-0.588 1.689,-0.984l2.49,1.004c0.226,0.086 0.487,-0.001 0.612,-0.218l2.0,-3.463c0.125,-0.217 0.07,-0.487 -0.118,-0.639L19.429,12.975998zM12.0,16.0c-2.21,0.0 -4.0,-1.791 -4.0,-4.0c0.0,-2.21 1.79,-4.0 4.0,-4.0c2.208,0.0 4.0,1.79 4.0,4.0C16.0,14.209 14.208,16.0 12.0,16.0z" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_test01.xml b/tests/VectorDrawableTest/res/drawable/vector_test01.xml index bad5a46..fc2a15c 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_test01.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_test01.xml @@ -23,10 +23,13 @@ limitations under the License. android:viewportHeight="512" android:viewportWidth="512" /> - <path - android:name="002b" - android:pathData="M100,200c0,-100 150,-100 150,0s150,100 150,0t-200,299" - android:stroke="#FF0000FF" - android:strokeWidth="4" /> + <group> + <path + android:name="002b" + android:pathData="M100,200c0,-100 150,-100 150,0s150,100 150,0t-200,299" + android:stroke="#FF0000FF" + android:strokeWidth="4" + android:fill="#00000000" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_test02.xml b/tests/VectorDrawableTest/res/drawable/vector_test02.xml index c92b6f4..9f4abbf 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_test02.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_test02.xml @@ -23,10 +23,13 @@ limitations under the License. android:viewportHeight="512" android:viewportWidth="512" /> - <path - android:name="002b" - android:pathData="M100,200c0,-100 150,-100 150,0s150,100 150,0T-200,299" - android:stroke="#FF0000FF" - android:strokeWidth="4" /> + <group> + <path + android:name="002b" + android:pathData="M100,200c0,-100 150,-100 150,0s150,100 150,0T-200,299" + android:stroke="#FF0000FF" + android:strokeWidth="4" + android:fill="#00000000" /> + </group> </vector>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/interpolator/custom_path_interpolator.xml b/tests/VectorDrawableTest/res/interpolator/custom_path_interpolator.xml new file mode 100644 index 0000000..0cffa0a --- /dev/null +++ b/tests/VectorDrawableTest/res/interpolator/custom_path_interpolator.xml @@ -0,0 +1,2 @@ +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:pathData="m0,0q0.4,0.05 0.6,0.3t0.3,0.3l0.1,0.4" />
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/values/strings.xml b/tests/VectorDrawableTest/res/values/strings.xml index 64163c2..b49a1aa 100644 --- a/tests/VectorDrawableTest/res/values/strings.xml +++ b/tests/VectorDrawableTest/res/values/strings.xml @@ -15,4 +15,5 @@ --> <resources> + <string name="twoLinePathData" >"M 0,0 v 100 M 0,0 h 100"</string> </resources> diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java new file mode 100644 index 0000000..6e864fa --- /dev/null +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java @@ -0,0 +1,42 @@ +/* + * 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 com.android.test.dynamic; + +import android.app.Activity; +import android.graphics.drawable.AnimatedVectorDrawable; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +public class AnimatedVectorDrawableTest extends Activity { + private static final String LOGCAT = "VectorDrawableAnimationTest"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Button button = new Button(this); + button.setBackgroundResource(R.drawable.animation_vector_drawable01); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnimatedVectorDrawable frameAnimation = (AnimatedVectorDrawable) v.getBackground(); + frameAnimation.start(); + } + }); + + setContentView(button); + } +} diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/BitmapDrawableDupe.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/BitmapDrawableDupe.java new file mode 100644 index 0000000..36c8f2b --- /dev/null +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/BitmapDrawableDupe.java @@ -0,0 +1,78 @@ +/* + * 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 com.android.test.dynamic; + +import android.app.Activity; +import android.content.res.Resources; +import android.graphics.drawable.BitmapDrawable; +import android.os.Bundle; +import android.widget.TextView; +import android.widget.Button; +import android.widget.GridLayout; +import android.widget.ScrollView; + +import java.text.DecimalFormat; + +@SuppressWarnings({"UnusedDeclaration"}) +public class BitmapDrawableDupe extends Activity { + private static final String LOGCAT = "VectorDrawable1"; + protected int[] icon = { + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + R.drawable.bitmap_drawable01, + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ScrollView scrollView = new ScrollView(this); + GridLayout container = new GridLayout(this); + scrollView.addView(container); + container.setColumnCount(5); + container.setBackgroundColor(0xFF888888); + + DecimalFormat df = new DecimalFormat("#.##"); + long time = android.os.SystemClock.elapsedRealtimeNanos(); + for (int i = 0; i < icon.length; i++) { + Button button = new Button(this); + button.setWidth(200); + button.setBackgroundResource(icon[i]); + container.addView(button); + } + + setContentView(scrollView); + time = android.os.SystemClock.elapsedRealtimeNanos()-time; + TextView t = new TextView(this); + t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms"); + container.addView(t); + } +} diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java index 7ba01b1..a23d819 100644 --- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java @@ -61,6 +61,8 @@ public class VectorDrawable01 extends Activity { button.setWidth(200); button.setBackgroundResource(icon[i]); container.addView(button); + VectorDrawable vd = (VectorDrawable) button.getBackground(); + vd.setAlpha((i + 1) * (0xFF / (icon.length + 1))); } setContentView(container); diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawableAnimation.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawableAnimation.java new file mode 100644 index 0000000..93b06b6 --- /dev/null +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawableAnimation.java @@ -0,0 +1,46 @@ +/* + * 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 com.android.test.dynamic; + +import android.animation.ValueAnimator; +import android.app.Activity; +import android.graphics.drawable.AnimationDrawable; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +public class VectorDrawableAnimation extends Activity { + private static final String LOGCAT = "VectorDrawableAnimation"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final Button button = new Button(this); + button.setBackgroundResource(R.drawable.animation_drawable_vector); + + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground(); + // Start the animation (looped playback by default). + frameAnimation.start(); + } + }); + + setContentView(button); + } + +} diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java index b918cdd..814deb8 100644 --- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java @@ -17,11 +17,11 @@ import android.app.Activity; import android.content.res.Resources; import android.graphics.drawable.VectorDrawable; import android.os.Bundle; -import android.view.View; import android.widget.TextView; import android.widget.Button; import android.widget.GridLayout; import android.widget.ScrollView; + import java.text.DecimalFormat; @SuppressWarnings({"UnusedDeclaration"}) @@ -47,7 +47,11 @@ public class VectorDrawablePerformance extends Activity { R.drawable.vector_drawable17, R.drawable.vector_drawable18, R.drawable.vector_drawable19, - R.drawable.vector_drawable20 + R.drawable.vector_drawable20, + R.drawable.vector_drawable21, + R.drawable.vector_drawable22, + R.drawable.vector_drawable23, + R.drawable.vector_drawable24, }; @Override @@ -68,7 +72,6 @@ public class VectorDrawablePerformance extends Activity { TextView t = new TextView(this); DecimalFormat df = new DecimalFormat("#.##"); t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms"); - t.setBackgroundColor(0xFF000000); container.addView(t); time = android.os.SystemClock.elapsedRealtimeNanos(); for (int i = 0; i < icon.length; i++) { @@ -81,7 +84,6 @@ public class VectorDrawablePerformance extends Activity { time = android.os.SystemClock.elapsedRealtimeNanos()-time; t = new TextView(this); t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms"); - t.setBackgroundColor(0xFF000000); container.addView(t); } } diff --git a/tests/VoiceEnrollment/Android.mk b/tests/VoiceEnrollment/Android.mk new file mode 100644 index 0000000..2ab3d02 --- /dev/null +++ b/tests/VoiceEnrollment/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := VoiceEnrollment + +LOCAL_MODULE_TAGS := optional + +LOCAL_PRIVILEGED_MODULE := true + +include $(BUILD_PACKAGE) diff --git a/tests/VoiceEnrollment/AndroidManifest.xml b/tests/VoiceEnrollment/AndroidManifest.xml new file mode 100644 index 0000000..6321222 --- /dev/null +++ b/tests/VoiceEnrollment/AndroidManifest.xml @@ -0,0 +1,16 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.test.voiceenrollment"> + + <application + android:permission="android.permission.MANAGE_VOICE_KEYPHRASES"> + <activity android:name="TestEnrollmentActivity" android:label="Voice Enrollment Application" + android:theme="@android:style/Theme.Material.Light.Voice"> + <intent-filter> + <action android:name="com.android.intent.action.MANAGE_VOICE_KEYPHRASES" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + <meta-data android:name="android.voice_enrollment" + android:resource="@xml/enrollment_application"/> + </application> +</manifest> diff --git a/tests/VoiceEnrollment/res/xml/enrollment_application.xml b/tests/VoiceEnrollment/res/xml/enrollment_application.xml new file mode 100644 index 0000000..710a0ac --- /dev/null +++ b/tests/VoiceEnrollment/res/xml/enrollment_application.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * 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. + */ +--> + +<voice-enrollment-application xmlns:android="http://schemas.android.com/apk/res/android" + android:searchKeyphraseId="101" + android:searchKeyphrase="Hello There" + android:searchKeyphraseSupportedLocales="en-US,en-GB,fr-FR,de-DE" /> diff --git a/tests/IdleServiceTest/src/com/android/idleservicetest/TimeoutTestService.java b/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java index b2ba21b..7fbd965 100644 --- a/tests/IdleServiceTest/src/com/android/idleservicetest/TimeoutTestService.java +++ b/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java @@ -14,23 +14,10 @@ * limitations under the License. */ -package com.android.idleservicetest; +package com.android.test.voiceenrollment; -import android.app.maintenance.IdleService; -import android.util.Log; - -public class TimeoutTestService extends IdleService { - private static final String TAG = "TimeoutTestService"; - - @Override - public boolean onIdleStart() { - Log.i(TAG, "onIdleStart() but anticipating time-slice timeout"); - return true; - } - - @Override - public void onIdleStop() { - Log.i(TAG, "onIdleStop() so we're done"); - } +import android.app.Activity; +public class TestEnrollmentActivity extends Activity { + // TODO(sansid): Add a test enrollment flow here. } diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java index d40b05f..00c2c64 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java @@ -21,6 +21,8 @@ import android.os.Bundle; import android.service.voice.VoiceInteractionService; import android.util.Log; +import java.util.Arrays; + public class MainInteractionService extends VoiceInteractionService { static final String TAG = "MainInteractionService"; @@ -28,6 +30,9 @@ public class MainInteractionService extends VoiceInteractionService { public void onCreate() { super.onCreate(); Log.i(TAG, "Creating " + this); + Log.i(TAG, "Keyphrase enrollment error? " + getKeyphraseEnrollmentInfo().getParseError()); + Log.i(TAG, "Keyphrase enrollment meta-data: " + + Arrays.toString(getKeyphraseEnrollmentInfo().getKeyphrases())); } @Override |
