Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/animations/script-tests/animate-path-animation-Ll-Vv-Hh.js

Issue 1417593003: Use getAttribute in path animation tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description("Test path animation where coordinate modes of start and end differ. You should see PASS messages"); 1 description("Test path animation where coordinate modes of start and end differ. You should see PASS messages");
2 createSVGTestCase(); 2 createSVGTestCase();
3 3
4 // Setup test document 4 // Setup test document
5 var path = createSVGElement("path"); 5 var path = createSVGElement("path");
6 path.setAttribute("id", "path"); 6 path.setAttribute("id", "path");
7 path.setAttribute("d", "M -30 -30 L 30 0 V 30 H 0 Z"); 7 path.setAttribute("d", "M -30 -30 L 30 0 V 30 H 0 Z");
8 path.setAttribute("fill", "green"); 8 path.setAttribute("fill", "green");
9 path.setAttribute("onclick", "executeTest()"); 9 path.setAttribute("onclick", "executeTest()");
10 path.setAttribute("transform", "translate(50, 50)"); 10 path.setAttribute("transform", "translate(50, 50)");
11 11
12 var animate = createSVGElement("animate"); 12 var animate = createSVGElement("animate");
13 animate.setAttribute("id", "animation"); 13 animate.setAttribute("id", "animation");
14 animate.setAttribute("attributeName", "d"); 14 animate.setAttribute("attributeName", "d");
15 animate.setAttribute("from", "M -30 -30 L 30 0 V 30 H 0 Z"); 15 animate.setAttribute("from", "M -30 -30 L 30 0 V 30 H 0 Z");
16 animate.setAttribute("to", "M 30 30 l -60 -30 v -30 h 30 Z"); 16 animate.setAttribute("to", "M 30 30 l -60 -30 v -30 h 30 Z");
17 animate.setAttribute("begin", "click"); 17 animate.setAttribute("begin", "click");
18 animate.setAttribute("dur", "4s"); 18 animate.setAttribute("dur", "4s");
19 path.appendChild(animate); 19 path.appendChild(animate);
20 rootSVGElement.appendChild(path); 20 rootSVGElement.appendChild(path);
21 21
22 // Setup animation test 22 // Setup animation test
23 function checkBaseVal() {
24 shouldBe("path.pathSegList.numberOfItems", "5");
25 shouldBeEqualToString("path.pathSegList.getItem(0).pathSegTypeAsLetter", "M" );
26 shouldBe("path.pathSegList.getItem(0).x", "-30");
27 shouldBe("path.pathSegList.getItem(0).y", "-30");
28 shouldBeEqualToString("path.pathSegList.getItem(1).pathSegTypeAsLetter", "L" );
29 shouldBe("path.pathSegList.getItem(1).x", "30");
30 shouldBe("path.pathSegList.getItem(1).y", "0");
31 shouldBeEqualToString("path.pathSegList.getItem(2).pathSegTypeAsLetter", "V" );
32 shouldBe("path.pathSegList.getItem(2).y", "30");
33 shouldBeEqualToString("path.pathSegList.getItem(3).pathSegTypeAsLetter", "H" );
34 shouldBe("path.pathSegList.getItem(3).x", "0");
35 shouldBeEqualToString("path.pathSegList.getItem(4).pathSegTypeAsLetter", "Z" );
36 }
37
38 function sample1() { 23 function sample1() {
39 // Check initial/end conditions 24 // Check initial/end conditions
40 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 25 shouldBeEqualToString("path.getAttribute('d')", "M -30 -30 L 30 0 V 30 H 0 Z ");
41 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
42 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-30");
43 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-30");
44 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "L");
45 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "30");
46 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0");
47 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "V");
48 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "30");
49 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "H");
50 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "0");
51 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
52 checkBaseVal();
53 } 26 }
54 27
55 function sample2() { 28 function sample2() {
56 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 29 shouldBeEqualToString("path.getAttribute('d')", "M -15 -15 L 15 0 V 15 H 0 Z ");
57 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
58 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-15");
59 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-15");
60 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "L");
61 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "15");
62 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0");
63 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "V");
64 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "15");
65 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "H");
66 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "0");
67 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
68 checkBaseVal();
69 } 30 }
70 31
71 function sample3() { 32 function sample3() {
72 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 33 shouldBeEqualToString("path.getAttribute('d')", "M 15 15 l -30 -15 v -15 h 1 5 Z");
73 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
74 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "15");
75 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "15");
76 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "l");
77 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "-30");
78 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "-15");
79 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "v");
80 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "-15");
81 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "h");
82 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "15");
83 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
84 checkBaseVal();
85 } 34 }
86 35
87 function sample4() { 36 function sample4() {
88 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 37 shouldBeEqualToString("path.getAttribute('d')", "M 29.985 29.985 l -59.97 -2 9.985 v -29.985 h 29.985 Z");
89 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
90 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "30");
91 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "30");
92 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "l");
93 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "-60");
94 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "-30");
95 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "v");
96 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "-30");
97 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "h");
98 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "30");
99 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
100 checkBaseVal();
101 } 38 }
102 39
103 function executeTest() { 40 function executeTest() {
104 const expectedValues = [ 41 const expectedValues = [
105 // [animationId, time, sampleCallback] 42 // [animationId, time, sampleCallback]
106 ["animation", 0.0, sample1], 43 ["animation", 0.0, sample1],
107 ["animation", 1.0, sample2], 44 ["animation", 1.0, sample2],
108 ["animation", 3.0, sample3], 45 ["animation", 3.0, sample3],
109 ["animation", 3.999, sample4], 46 ["animation", 3.999, sample4],
110 ["animation", 4.001, sample1] 47 ["animation", 4.001, sample1]
111 ]; 48 ];
112 49
113 runAnimationTest(expectedValues); 50 runAnimationTest(expectedValues);
114 } 51 }
115 52
116 var successfullyParsed = true; 53 var successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698