-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #155: Switched the arcTo() function back to using double precis…
…ion. Fixed the radius checking code to match the original Batik code - in case that was part of the problem. Removed unnecessary calls toDegrees() and toRadians() calls.
- Loading branch information
1 parent
a5bf988
commit bc32019
Showing
2 changed files
with
127 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
androidsvg/src/test/java/com/caverock/androidsvg/ArcTo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.caverock.androidsvg; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.Canvas; | ||
import android.os.Build; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
import org.robolectric.shadow.api.Shadow; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest=Config.NONE, sdk = Build.VERSION_CODES.KITKAT, shadows={MockCanvas.class, MockPath.class}) | ||
public class ArcTo | ||
{ | ||
@Test | ||
public void testIssue155() throws SVGParseException | ||
{ | ||
String test = "<svg>" + | ||
" <path d=\"M 163.637 412.021 a 646225.813 646225.813 0 0 1 -36.313 162\"/>" + | ||
"</svg>"; | ||
SVG svg = SVG.getFromString(test); | ||
|
||
Bitmap newBM = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); | ||
Canvas canvas = new Canvas(newBM); | ||
|
||
svg.renderToCanvas(canvas); | ||
|
||
List<String> ops = ((MockCanvas) Shadow.extract(canvas)).getOperations(); | ||
/**/System.out.println(String.join(",", ops)); | ||
assertEquals(6, ops.size()); | ||
assertEquals("drawPath('M 163.63701 412.02103 C 151.5 466.03125 139.375 520.0156 127.32401 574.021', Paint({color=#ff000000}))", ops.get(3)); | ||
} | ||
|
||
|
||
@Test | ||
public void testIssue156() throws SVGParseException | ||
{ | ||
String test = "<svg>" + | ||
" <path d=\"M 422.776 332.659 a 539896.23 539896.23 0 0 0-22.855-26.558\"/>" + | ||
"</svg>"; | ||
SVG svg = SVG.getFromString(test); | ||
|
||
Bitmap newBM = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); | ||
Canvas canvas = new Canvas(newBM); | ||
|
||
svg.renderToCanvas(canvas); | ||
|
||
List<String> ops = ((MockCanvas) Shadow.extract(canvas)).getOperations(); | ||
/**/System.out.println(String.join(",", ops)); | ||
assertEquals(6, ops.size()); | ||
assertEquals("drawPath('M 422.77603 332.65903 C 415.15625 323.8125 407.53125 314.96875 399.92102 306.101', Paint({color=#ff000000}))", ops.get(3)); | ||
|
||
} | ||
} |