/*
 * Copyright (C) 2017 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.support.transition;

import static org.junit.Assert.assertEquals;

import android.graphics.Path;
import android.graphics.PathMeasure;

public abstract class PathMotionTest {

    public static void assertPathMatches(Path expectedPath, Path path) {
        PathMeasure expectedMeasure = new PathMeasure(expectedPath, false);
        PathMeasure pathMeasure = new PathMeasure(path, false);

        float expectedLength = expectedMeasure.getLength();
        assertEquals("Lengths differ", expectedLength, pathMeasure.getLength(), 0.01f);

        float minLength = Math.min(expectedLength, pathMeasure.getLength());

        float[] pos = new float[2];

        float increment = minLength / 5f;
        for (float along = 0; along <= minLength; along += increment) {
            expectedMeasure.getPosTan(along, pos, null);
            float expectedX = pos[0];
            float expectedY = pos[1];

            pathMeasure.getPosTan(along, pos, null);
            assertEquals("Failed at " + increment, expectedX, pos[0], 0.01f);
            assertEquals("Failed at " + increment, expectedY, pos[1], 0.01f);
        }
    }

}

@@ -695,16 +695,60 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertFalse;
 %0A%0Aimport
@@ -1059,24 +1059,141 @@
 h, false);%0A%0A
+        boolean expectedNextContour;%0A        boolean pathNextContour;%0A        int contourIndex = 0;%0A        do %7B%0A    
         floa
@@ -1240,16 +1240,20 @@
 ngth();%0A
+    
         
@@ -1329,24 +1329,28 @@
 ), 0.01f);%0A%0A
+    
         floa
@@ -1419,24 +1419,28 @@
 );%0A%0A        
+    
 float%5B%5D pos 
@@ -1452,24 +1452,28 @@
  float%5B2%5D;%0A%0A
+    
         floa
@@ -1510,16 +1510,20 @@
         
+ 
+   
 for (flo
@@ -1590,16 +1590,20 @@
         
+    
 expected
@@ -1643,32 +1643,36 @@
 l);%0A            
+ 
+   
 float expectedX 
@@ -1681,16 +1681,20 @@
 pos%5B0%5D;%0A
+    
         
@@ -1736,16 +1736,20 @@
         
+  
+  
 pathMeas
@@ -1785,32 +1785,36 @@
 l);%0A            
+    
 assertEquals(%22Fa
@@ -1826,33 +1826,89 @@
 at %22 + increment
-,
+ + %22 in contour %22 + contourIndex,%0A                       
  expectedX, pos%5B
@@ -1923,32 +1923,36 @@
 f);%0A            
+    
 assertEquals(%22Fa
@@ -1976,46 +1976,394 @@
 ment
-, expectedY, pos%5B1%5D, 0.01f);%0A        %7D
+ + %22 in contour %22 + contourIndex,%0A                        expectedY, pos%5B1%5D, 0.01f);%0A            %7D%0A            expectedNextContour = expectedMeasure.nextContour();%0A            pathNextContour = pathMeasure.nextContour();%0A            contourIndex++;%0A        %7D while (expectedNextContour && pathNextContour);%0A        assertFalse(expectedNextContour);%0A        assertFalse(pathNextContour);
 %0A   

Use proper PathMeasure to test entire path