Merge "Add CTS test for VectorDrawable size"
diff --git a/tests/tests/uirendering/res/drawable/rectangle.xml b/tests/tests/uirendering/res/drawable/rectangle.xml
new file mode 100644
index 0000000..43c539f
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/rectangle.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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"
+ android:height="90px"
+ android:width="90px"
+ android:viewportHeight="1"
+ android:viewportWidth="1" >
+
+ <group>
+ <path
+ android:name="box0"
+ android:pathData="m0,0l1,0l0,1l-1,0l0-1z"
+ android:fillColor="#FF0000" />
+ </group>
+</vector>
\ No newline at end of file
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableTests.java
new file mode 100644
index 0000000..2a64ac4
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableTests.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.uirendering.cts.testclasses;
+
+import android.graphics.Color;
+import android.graphics.Rect;
+import android.graphics.drawable.VectorDrawable;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.uirendering.cts.R;
+import android.uirendering.cts.bitmapverifiers.RectVerifier;
+import android.uirendering.cts.testinfrastructure.ActivityTestBase;
+
+import org.junit.Test;
+
+@MediumTest
+public class VectorDrawableTests extends ActivityTestBase {
+ @Test
+ public void testScaleDown() {
+ VectorDrawable vd = (VectorDrawable) getActivity().getResources().getDrawable(
+ R.drawable.rectangle, null);
+ createTest()
+ .addCanvasClient((canvas, width, height) -> {
+ canvas.scale(0.5f, 0.5f);
+ vd.setBounds(new Rect(0, 0, 50, 50));
+ vd.draw(canvas);
+ })
+ .runWithVerifier(
+ new RectVerifier(Color.WHITE, Color.RED, new Rect(0, 0, 25, 25)));
+ }
+}
+