MCPcopy Create free account
hub / github.com/JetBrains/skija / execute

Method execute

tests/java/svg/SVGCanvasTest.java:19–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

makeMethod · 0.95
makeLTRBMethod · 0.95
drawMethod · 0.95
assertEqualsMethod · 0.80
toStringMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected