()
| 18 | |
| 19 | public class SVGCanvasTest implements Executable { |
| 20 | @Override |
| 21 | public void execute() throws Exception { |
| 22 | try (var bout = new ByteArrayOutputStream(); |
| 23 | var wout = new OutputWStream(bout);) |
| 24 | { |
| 25 | var canvas = SVGCanvas.make(Rect.makeLTRB(0, 0, 200, 200), wout); |
| 26 | draw(canvas); |
| 27 | canvas.close(); |
| 28 | String expected = ("<?xml version='1.0' encoding='utf-8' ?>\n" + |
| 29 | "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='200' height='200'>\n" + |
| 30 | " <ellipse fill='#1C4' fill-opacity='0.25098041' cx='100' cy='100' rx='100' ry='100'/>\n" + |
| 31 | " <rect fill='none' stroke='#C34' stroke-width='2' stroke-miterlimit='4' transform='translate(10 20)' x='10' y='20' width='30' height='40'/>\n" + |
| 32 | " <path fill='white' stroke='white' stroke-width='2' stroke-miterlimit='4' transform='matrix(0 1 -1 0 10 20)' d='M0 0L50 60L60 70L70 50L0 0Z'/>\n" + |
| 33 | " <path fill='none' stroke='black' stroke-width='2' stroke-miterlimit='4' stroke-opacity='0.1254902' d='M0 0L200 200'/>\n" + |
| 34 | "</svg>\n").replaceAll("'", "\""); |
| 35 | String svg = bout.toString(StandardCharsets.UTF_8); |
| 36 | assertEquals(expected, svg); |
| 37 | } |
| 38 | |
| 39 | try (var bout = new ByteArrayOutputStream(); |
| 40 | var wout = new OutputWStream(bout);) |
| 41 | { |
| 42 | var canvas = SVGCanvas.make(Rect.makeLTRB(0, 0, 200, 200), wout, false, false); |
| 43 | draw(canvas); |
| 44 | canvas.close(); |
| 45 | String expected = ("<?xml version='1.0' encoding='utf-8' ?>" + |
| 46 | "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='200' height='200'>" + |
| 47 | "<ellipse fill='#1C4' fill-opacity='0.25098041' cx='100' cy='100' rx='100' ry='100'/>" + |
| 48 | "<rect fill='none' stroke='#C34' stroke-width='2' stroke-miterlimit='4' transform='translate(10 20)' x='10' y='20' width='30' height='40'/>" + |
| 49 | "<path fill='white' stroke='white' stroke-width='2' stroke-miterlimit='4' transform='matrix(0 1 -1 0 10 20)' d='M0 0L50 60L60 70L70 50L0 0Z'/>" + |
| 50 | "<path fill='none' stroke='black' stroke-width='2' stroke-miterlimit='4' stroke-opacity='0.1254902' d='M0 0L200 200'/>" + |
| 51 | "</svg>").replaceAll("'", "\""); |
| 52 | String svg = bout.toString(StandardCharsets.UTF_8); |
| 53 | assertEquals(expected, svg); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | public void draw(Canvas canvas) { |
| 58 | try (var paint = new Paint()) { |
nothing calls this directly
no test coverage detected