Add more test cases for control points management in CTS.

Change-Id: Ib7278d8344fc4c71276d9f041177cdd9c2c17160
diff --git a/tests/res/drawable/vector_icon_repeated_cq.xml b/tests/res/drawable/vector_icon_repeated_cq.xml
new file mode 100644
index 0000000..944cf5f
--- /dev/null
+++ b/tests/res/drawable/vector_icon_repeated_cq.xml
@@ -0,0 +1,48 @@
+<!--
+ 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="128"
+        android:viewportWidth="128" />
+
+    <group>
+        <path
+            android:fill="#FF00FF00"
+            android:pathData="m 30.81895 41.37989
+                v 31.00579
+                c 24.291603 52.03364 40.6086 24.840137 29.56704 6.5204926
+                45.133224 22.913471 33.052887 21.727486 33.369 61.60278
+                9.647232 22.098152 48.939598 47.470215 53.653687 62.32235
+                C 2.0560722 1.4615479 7.0928993 26.005287 40.137558 36.75628
+                11.246731 32.178127 59.367462 60.34823 57.254383 37.357815
+                47.75605 11.424667 3.3105545 51.886635 56.63027 17.12133
+                q 28.37534 32.85535 25.85654 33.57151
+                10.356537 51.850616 54.085087 35.653175
+                12.530029 52.87991 17.44696 11.780586
+                Q 2.585228 51.92801 60.000664 56.79912
+                54.18275 51.500694 9.375679 23.836113
+                60.35329 59.026245 31.058632 35.14934
+                "
+            android:stroke="#FF0000FF"
+            android:strokeWidth="1" />
+    </group>
+
+</vector>
\ No newline at end of file
diff --git a/tests/res/drawable/vector_icon_repeated_cq_golden.png b/tests/res/drawable/vector_icon_repeated_cq_golden.png
new file mode 100644
index 0000000..8d73cfd
--- /dev/null
+++ b/tests/res/drawable/vector_icon_repeated_cq_golden.png
Binary files differ
diff --git a/tests/res/drawable/vector_icon_repeated_st.xml b/tests/res/drawable/vector_icon_repeated_st.xml
new file mode 100644
index 0000000..d22bc70
--- /dev/null
+++ b/tests/res/drawable/vector_icon_repeated_st.xml
@@ -0,0 +1,48 @@
+<!--
+ 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="128"
+        android:viewportWidth="128" />
+
+    <group>
+        <path
+            android:fill="#FF00FF00"
+            android:pathData="m 20.20005 8.139153
+                h 10.053165
+                s 14.2943 49.612846 35.520653 54.904068
+                50.1405 17.044182 5.470337 40.180553
+                3.125019 34.221123 53.212563 32.862965
+                S 35.985264 35.74349 0.15337753 59.27337
+                2.2951508 44.56783 51.089413 29.829689
+                8.5599785 22.649555 4.3914986 28.139206
+                t 11.932453 44.041077
+                62.629326 7.40921
+                23.302986 54.116184
+                T 43.560753 63.370514
+                40.156204 17.60786
+                40.12051 60.803394
+                "
+            android:stroke="#FF0000FF"
+            android:strokeWidth="1" />
+    </group>
+
+</vector>
\ No newline at end of file
diff --git a/tests/res/drawable/vector_icon_repeated_st_golden.png b/tests/res/drawable/vector_icon_repeated_st_golden.png
new file mode 100644
index 0000000..6094a9a
--- /dev/null
+++ b/tests/res/drawable/vector_icon_repeated_st_golden.png
Binary files differ
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java
index 7f6fdeb..f29723a 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableTest.java
@@ -38,6 +38,7 @@
 import java.nio.ByteBuffer;
 
 public class VectorDrawableTest extends AndroidTestCase {
+    private static final String LOGTAG = VectorDrawableTest.class.getSimpleName();
     private int[] mVectorIcons = new int[] {
             R.drawable.vector_icon_create,
             R.drawable.vector_icon_delete,
@@ -46,6 +47,9 @@
             R.drawable.vector_icon_settings,
             R.drawable.vector_icon_random_path_1,
             R.drawable.vector_icon_random_path_2,
+            R.drawable.vector_icon_repeated_cq,
+            R.drawable.vector_icon_repeated_st,
+
     };
 
     private int[] mGoldenImages = new int[] {
@@ -56,6 +60,8 @@
             R.drawable.vector_icon_settings_golden,
             R.drawable.vector_icon_random_path_1_golden,
             R.drawable.vector_icon_random_path_2_golden,
+            R.drawable.vector_icon_repeated_cq_golden,
+            R.drawable.vector_icon_repeated_st_golden,
     };
 
     private static final int IMAGE_WIDTH = 64;
@@ -92,7 +98,7 @@
             XmlPullParser xpp = mResources.getXml(mVectorIcons[i]);
             AttributeSet attrs = Xml.asAttributeSet(xpp);
 
-            vectorDrawable.inflate(mResources, xpp, attrs, null);
+            vectorDrawable.inflate(mResources, xpp, attrs);
             vectorDrawable.setAnimationFraction(0);
 
             bitmap.eraseColor(0);
@@ -100,11 +106,11 @@
 
             if (DBG_DUMP_PNG) {
                 saveVectorDrawableIntoPNG(bitmap, i);
+            } else {
+                // Start to compare
+                Bitmap golden = BitmapFactory.decodeResource(mResources, mGoldenImages[i], options);
+                compareImages(bitmap, golden, mResources.getString(mVectorIcons[i]));
             }
-
-            // Start to compare
-            Bitmap golden = BitmapFactory.decodeResource(mResources, mGoldenImages[i], options);
-            compareImages(bitmap, golden);
         }
     }
 
@@ -125,6 +131,7 @@
 
             out = new FileOutputStream(outputFile, false);
             bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
+            Log.v(LOGTAG, "Write test No." + index + " to file successfully.");
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
@@ -134,7 +141,7 @@
         }
     }
 
-    public void compareImages(Bitmap ideal, Bitmap given) {
+    public void compareImages(Bitmap ideal, Bitmap given, String filename) {
         int idealWidth = ideal.getWidth();
         int idealHeight = ideal.getHeight();
 
@@ -156,10 +163,16 @@
                 totalError += Math.abs(Color.blue(idealColor) - Color.blue(givenColor));
                 totalError += Math.abs(Color.alpha(idealColor) - Color.alpha(givenColor));
 
-                assertTrue((totalError / 1024.0f) < PIXEL_ERROR_THRESHOLD);
+                if ((totalError / 1024.0f) >= PIXEL_ERROR_THRESHOLD) {
+                    fail((filename + ": totalError is " + totalError));
+                }
+
                 totalDiffPixelCount++;
             }
         }
-        assertTrue((totalDiffPixelCount / totalPixelCount) < PIXEL_ERROR_THRESHOLD);
+        if ((totalDiffPixelCount / totalPixelCount) >= PIXEL_ERROR_THRESHOLD) {
+            fail((filename +": totalDiffPixelCount is " + totalDiffPixelCount));
+        }
+
     }
 }