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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/animations/script-tests/animate-path-animation-lL-vV-hH-inverse.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 -60 -30 v -30 h 30 Z"); 7 path.setAttribute("d", "M 30 30 l -60 -30 v -30 h 30 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 -60 -30 v -30 h 30 Z"); 15 animate.setAttribute("from", "M 30 30 l -60 -30 v -30 h 30 Z");
16 animate.setAttribute("to", "M -30 -30 L 30 0 V 30 H 0 Z"); 16 animate.setAttribute("to", "M -30 -30 L 30 0 V 30 H 0 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", "-60");
30 shouldBe("path.pathSegList.getItem(1).y", "-30");
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", "30");
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 -60 -30 v -30 h 3 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", "-60");
46 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "-30");
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", "30");
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 -30 -15 v -15 h 1 5 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", "-30");
62 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "-15");
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", "15");
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 15 0 V 15 H 0 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", "15");
78 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0");
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", "0");
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 29.985 0 V 29.985 H 0 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", "30");
94 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0");
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", "0");
99 checkBaseVal();
100 } 38 }
101 39
102 function executeTest() { 40 function executeTest() {
103 const expectedValues = [ 41 const expectedValues = [
104 // [animationId, time, sampleCallback] 42 // [animationId, time, sampleCallback]
105 ["animation", 0.0, sample1], 43 ["animation", 0.0, sample1],
106 ["animation", 1.0, sample2], 44 ["animation", 1.0, sample2],
107 ["animation", 3.0, sample3], 45 ["animation", 3.0, sample3],
108 ["animation", 3.999, sample4], 46 ["animation", 3.999, sample4],
109 ["animation", 4.001, sample1] 47 ["animation", 4.001, sample1]
110 ]; 48 ];
111 49
112 runAnimationTest(expectedValues); 50 runAnimationTest(expectedValues);
113 } 51 }
114 52
115 var successfullyParsed = true; 53 var successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698