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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/animations/script-tests/animate-path-to-animation.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 calcMode spline with to animation. You should see a green 100x 100 path and only PASS messages"); 1 description("Test calcMode spline with to animation. You should see a green 100x 100 path and only 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 40 40 L 60 40 L 60 60 L 40 60 z"); 7 path.setAttribute("d", "M 40 40 L 60 40 L 60 60 L 40 60 Z");
8 path.setAttribute("fill", "green"); 8 path.setAttribute("fill", "green");
9 path.setAttribute("onclick", "executeTest()"); 9 path.setAttribute("onclick", "executeTest()");
10 10
11 var animate = createSVGElement("animate"); 11 var animate = createSVGElement("animate");
12 animate.setAttribute("id", "animation"); 12 animate.setAttribute("id", "animation");
13 animate.setAttribute("attributeName", "d"); 13 animate.setAttribute("attributeName", "d");
14 animate.setAttribute("to", "M 0 0 L 100 0 L 100 100 L 0 100 z"); 14 animate.setAttribute("to", "M 0 0 L 100 0 L 100 100 L 0 100 z");
15 animate.setAttribute("begin", "click"); 15 animate.setAttribute("begin", "click");
16 animate.setAttribute("dur", "4s"); 16 animate.setAttribute("dur", "4s");
17 path.appendChild(animate); 17 path.appendChild(animate);
18 rootSVGElement.appendChild(path); 18 rootSVGElement.appendChild(path);
19 19
20 // Setup animation test 20 // Setup animation test
21 function checkBaseVal() {
22 shouldBe("path.pathSegList.numberOfItems", "5");
23 shouldBeEqualToString("path.pathSegList.getItem(0).pathSegTypeAsLetter", "M" );
24 shouldBe("path.pathSegList.getItem(0).x", "40");
25 shouldBe("path.pathSegList.getItem(0).y", "40");
26 shouldBeEqualToString("path.pathSegList.getItem(1).pathSegTypeAsLetter", "L" );
27 shouldBe("path.pathSegList.getItem(1).x", "60");
28 shouldBe("path.pathSegList.getItem(1).y", "40");
29 shouldBeEqualToString("path.pathSegList.getItem(2).pathSegTypeAsLetter", "L" );
30 shouldBe("path.pathSegList.getItem(2).x", "60");
31 shouldBe("path.pathSegList.getItem(2).y", "60");
32 shouldBeEqualToString("path.pathSegList.getItem(3).pathSegTypeAsLetter", "L" );
33 shouldBe("path.pathSegList.getItem(3).x", "40");
34 shouldBe("path.pathSegList.getItem(3).y", "60");
35 shouldBeEqualToString("path.pathSegList.getItem(4).pathSegTypeAsLetter", "Z" );
36 }
37
38 function sample1() { 21 function sample1() {
39 // Check initial/end conditions 22 // Check initial/end conditions
40 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 23 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 60 40 L 60 60 L 4 0 60 Z");
41 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
42 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "40");
43 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "40");
44 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "L");
45 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "60");
46 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40");
47 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "L");
48 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "60");
49 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "60");
50 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "L");
51 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "40");
52 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "60");
53 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
54 checkBaseVal();
55 } 24 }
56 25
57 function sample2() { 26 function sample2() {
58 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 27 shouldBeEqualToString("path.getAttribute('d')", "M 20 20 L 80 20 L 80 80 L 2 0 80 Z");
59 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
60 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "20");
61 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "20");
62 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "L");
63 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "80");
64 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "20");
65 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "L");
66 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "80");
67 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "80");
68 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "L");
69 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "20");
70 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "80");
71 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
72 checkBaseVal();
73 } 28 }
74 29
75 function sample3() { 30 function sample3() {
76 shouldBe("path.animatedPathSegList.numberOfItems", "5"); 31 shouldBeEqualToString("path.getAttribute('d')", "M 0.00999928 0.00999928 L 9 9.99 0.00999928 L 99.99 99.99 L 0.00999928 99.99 Z");
77 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett er", "M");
78 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "0");
79 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "0");
80 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett er", "L");
81 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "100");
82 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0");
83 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett er", "L");
84 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "100");
85 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "100");
86 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett er", "L");
87 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "0");
88 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "100");
89 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett er", "Z");
90 checkBaseVal();
91 } 32 }
92 33
93 function executeTest() { 34 function executeTest() {
94 const expectedValues = [ 35 const expectedValues = [
95 // [animationId, time, sampleCallback] 36 // [animationId, time, sampleCallback]
96 ["animation", 0.0, sample1], 37 ["animation", 0.0, sample1],
97 ["animation", 2.0, sample2], 38 ["animation", 2.0, sample2],
98 ["animation", 3.999, sample3], 39 ["animation", 3.999, sample3],
99 ["animation", 4.001, sample1] 40 ["animation", 4.001, sample1]
100 ]; 41 ];
101 42
102 runAnimationTest(expectedValues); 43 runAnimationTest(expectedValues);
103 } 44 }
104 45
105 var successfullyParsed = true; 46 var successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698