1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.svg;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.htmlunit.junit.annotation.HtmlUnitNYI;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24
25
26
27
28
29 @RunWith(BrowserRunner.class)
30 public class SVGPathElementTest extends WebDriverTestCase {
31
32
33
34
35 @Test
36 @Alerts("function SVGPathElement() { [native code] }")
37 public void simpleScriptable() throws Exception {
38 final String html = DOCTYPE_HTML
39 + "<html><head>\n"
40 + "<script>\n"
41 + LOG_TITLE_FUNCTION
42 + " function test() {\n"
43 + " log(window.SVGPathElement);\n"
44 + " }\n"
45 + "</script>\n"
46 + "</head><body onload='test()'>\n"
47 + "</body></html>";
48
49 loadPageVerifyTitle2(html);
50 }
51
52
53
54
55 @Test
56 @Alerts({"[object SVGPathElement]", "true"})
57 public void getTotalLengthAvailable() throws Exception {
58 final String html = DOCTYPE_HTML
59 + "<html><head>\n"
60 + "<script>\n"
61 + LOG_TITLE_FUNCTION
62 + " function test() {\n"
63 + " if (window.SVGPathElement) {\n"
64 + " var path = document.getElementById('myId');\n"
65 + " log(path);\n"
66 + " log(path.getTotalLength() > 0);\n"
67 + " }\n"
68 + " }\n"
69 + "</script>\n"
70 + "</head><body onload='test()'>\n"
71 + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n"
72 + " <path id='myId' d='M 100 100 L 300 100 L 200 300 z' stroke='black' stroke-width='3' />\n"
73 + "</svg>\n"
74 + "</body></html>";
75
76 loadPageVerifyTitle2(html);
77 }
78
79
80
81
82 @Test
83 @Alerts({"[object SVGPathElement]", "647.213623046875"})
84 @HtmlUnitNYI(CHROME = {"[object SVGPathElement]", "1"},
85 EDGE = {"[object SVGPathElement]", "1"},
86 FF = {"[object SVGPathElement]", "1"},
87 FF_ESR = {"[object SVGPathElement]", "1"})
88 public void getTotalLength() throws Exception {
89 final String html = DOCTYPE_HTML
90 + "<html><head>\n"
91 + "<script>\n"
92 + LOG_TITLE_FUNCTION
93 + " function test() {\n"
94 + " if (window.SVGPathElement) {\n"
95 + " var path = document.getElementById('myId');\n"
96 + " log(path);\n"
97 + " log(path.getTotalLength());\n"
98 + " }\n"
99 + " }\n"
100 + "</script>\n"
101 + "</head><body onload='test()'>\n"
102 + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n"
103 + " <path id='myId' d='M 100 100 L 300 100 L 200 300 z' stroke='black' stroke-width='3' />\n"
104 + "</svg>\n"
105 + "</body></html>";
106
107 loadPageVerifyTitle2(html);
108 }
109 }