• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.transition;
18 
19 import static org.junit.Assert.assertSame;
20 
21 import android.graphics.Path;
22 import android.graphics.RectF;
23 import android.support.test.filters.SmallTest;
24 import android.support.test.runner.AndroidJUnit4;
25 
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 
29 @SmallTest
30 @RunWith(AndroidJUnit4.class)
31 public class PatternPathMotionTest extends PathMotionTest {
32 
33     @Test
testStraightPath()34     public void testStraightPath() {
35         Path pattern = new Path();
36         pattern.moveTo(100, 500);
37         pattern.lineTo(300, 1000);
38 
39         PatternPathMotion pathMotion = new PatternPathMotion(pattern);
40         assertPathMatches(pattern, pathMotion.getPatternPath());
41 
42         Path expected = new Path();
43         expected.moveTo(0, 0);
44         expected.lineTo(100, 100);
45 
46         assertPathMatches(expected, pathMotion.getPath(0, 0, 100, 100));
47     }
48 
49     @Test
testCurve()50     public void testCurve() {
51         RectF oval = new RectF();
52         Path pattern = new Path();
53         oval.set(0, 0, 100, 100);
54         pattern.addArc(oval, 0, 180);
55 
56         PatternPathMotion pathMotion = new PatternPathMotion(pattern);
57         assertPathMatches(pattern, pathMotion.getPatternPath());
58 
59         Path expected = new Path();
60         oval.set(-50, 0, 50, 100);
61         expected.addArc(oval, -90, 180);
62 
63         assertPathMatches(expected, pathMotion.getPath(0, 0, 0, 100));
64     }
65 
66     @Test
testSetPatternPath()67     public void testSetPatternPath() {
68         Path pattern = new Path();
69         RectF oval = new RectF(0, 0, 100, 100);
70         pattern.addArc(oval, 0, 180);
71 
72         PatternPathMotion patternPathMotion = new PatternPathMotion();
73         patternPathMotion.setPatternPath(pattern);
74         assertSame(pattern, patternPathMotion.getPatternPath());
75     }
76 
77 }
78