Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import android.graphics.Path;
      4 import com.xtremelabs.robolectric.Robolectric;
      5 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
      6 import org.junit.Test;
      7 import org.junit.runner.RunWith;
      8 
      9 import java.util.List;
     10 
     11 import static com.xtremelabs.robolectric.Robolectric.shadowOf;
     12 import static com.xtremelabs.robolectric.shadows.ShadowPath.Point.Type.LINE_TO;
     13 import static com.xtremelabs.robolectric.shadows.ShadowPath.Point.Type.MOVE_TO;
     14 import static org.junit.Assert.assertEquals;
     15 
     16 
     17 @RunWith(WithTestDefaultsRunner.class)
     18 public class PathTest {
     19 
     20 	@Test
     21 	public void testGradTo() {
     22 		Path path = Robolectric.newInstanceOf(Path.class);
     23 		path.quadTo(0, 5, 10, 15);
     24 		ShadowPath shadowPath = shadowOf(path);
     25 		assertEquals(shadowPath.getQuadDescription(), "Add a quadratic bezier from last point, approaching (0.0,5.0), ending at (10.0,15.0)");
     26 	}
     27 
     28     @Test
     29     public void testMoveTo() throws Exception {
     30         Path path = Robolectric.newInstanceOf(Path.class);
     31         path.moveTo(2, 3);
     32         path.moveTo(3, 4);
     33 
     34         List<ShadowPath.Point> moveToPoints = shadowOf(path).getPoints();
     35         assertEquals(2, moveToPoints.size());
     36         assertEquals(new ShadowPath.Point(2, 3, MOVE_TO), moveToPoints.get(0));
     37         assertEquals(new ShadowPath.Point(3, 4, MOVE_TO), moveToPoints.get(1));
     38     }
     39 
     40     @Test
     41     public void testLineTo() throws Exception {
     42         Path path = Robolectric.newInstanceOf(Path.class);
     43         path.lineTo(2, 3);
     44         path.lineTo(3, 4);
     45 
     46         List<ShadowPath.Point> lineToPoints = shadowOf(path).getPoints();
     47         assertEquals(2, lineToPoints.size());
     48         assertEquals(new ShadowPath.Point(2, 3, LINE_TO), lineToPoints.get(0));
     49         assertEquals(new ShadowPath.Point(3, 4, LINE_TO), lineToPoints.get(1));
     50     }
     51 }
     52