Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit dcdebb1

Browse files
Edvard Thörnroschromium-wpt-export-bot
authored andcommitted
Translate 25 more svg/animation tests to WPT
This is the second commit in the series of updating all the old svg animation tests. The usage of testharness has replaced the older SVGAnimationTest.js for all where it's suitable. No functionality should have changed and the tests should cover almost the same. In all of the animations where there is a sampling at T=0, where it was assumed that no animations had started. Which didn't work flawlessly when moved to the new system, it has thus been removed. Bug: 985335 Change-Id: If5d6d879be3ccd3b14467eebaa4c9a2c03128f64 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733589 Commit-Queue: Edvard Thörnros <[email protected]> Reviewed-by: Stephen Chenney <[email protected]> Cr-Commit-Position: refs/heads/master@{#683944}
1 parent d250e8c commit dcdebb1

25 files changed

+1995
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!doctype html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>Test SVGLengthAdjustType enumeration animations</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
8+
9+
<svg>
10+
</svg>
11+
12+
<script>
13+
var rootSVGElement = document.querySelector("svg");
14+
var epsilon = 1.0;
15+
16+
// Initiate the test by clicking at (1, 50) - the 'S'.
17+
window.clickX = 1;
18+
19+
// Setup test document
20+
var text = createSVGElement("text");
21+
text.setAttribute("id", "text");
22+
text.setAttribute("y", "50");
23+
text.setAttribute("textLength", "200");
24+
text.textContent = "Stretched text";
25+
text.setAttribute("onclick", "executeTest()");
26+
rootSVGElement.appendChild(text);
27+
28+
var animate = createSVGElement("animate");
29+
animate.setAttribute("id", "animation");
30+
animate.setAttribute("attributeName", "lengthAdjust");
31+
animate.setAttribute("begin", "0s");
32+
animate.setAttribute("dur", "4s");
33+
animate.setAttribute("from", "spacing");
34+
animate.setAttribute("to", "spacingAndGlyphs");
35+
animate.setAttribute("fill", "freeze");
36+
text.appendChild(animate);
37+
38+
// Setup animation test
39+
function sample1() {
40+
assert_equals(text.lengthAdjust.animVal, SVGTextContentElement.LENGTHADJUST_SPACING);
41+
assert_equals(text.lengthAdjust.baseVal, SVGTextContentElement.LENGTHADJUST_SPACING);
42+
}
43+
44+
function sample2() {
45+
assert_equals(text.lengthAdjust.animVal, SVGTextContentElement.LENGTHADJUST_SPACINGANDGLYPHS);
46+
assert_equals(text.lengthAdjust.baseVal, SVGTextContentElement.LENGTHADJUST_SPACING);
47+
}
48+
49+
smil_async_test((t) => {
50+
const expectedValues = [
51+
// [animationId, time, sampleCallback]
52+
["animation", 0.0, sample1],
53+
["animation", 1.999, sample1],
54+
["animation", 2.001, sample2],
55+
["animation", 3.999, sample2],
56+
["animation", 4.001, sample2]
57+
];
58+
59+
runAnimationTest(t, expectedValues);
60+
});
61+
62+
</script>
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<!doctype html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>Test CompositeOperationType enumeration animations</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
8+
9+
<svg>
10+
</svg>
11+
12+
<script>
13+
var rootSVGElement = document.querySelector("svg");
14+
var epsilon = 1.0;
15+
16+
// Setup test document
17+
var defsElement = createSVGElement("defs");
18+
rootSVGElement.appendChild(defsElement);
19+
20+
var off1 = createSVGElement("feOffset");
21+
off1.setAttribute("dx", "35");
22+
off1.setAttribute("dy", "25");
23+
off1.setAttribute("result", "off1");
24+
25+
var flood1 = createSVGElement("feFlood");
26+
flood1.setAttribute("flood-color", "#408067");
27+
flood1.setAttribute("flood-opacity", ".8");
28+
flood1.setAttribute("result", "F1");
29+
30+
var overComposite1 = createSVGElement("feComposite");
31+
overComposite1.setAttribute("in", "F1");
32+
overComposite1.setAttribute("in2", "off1");
33+
overComposite1.setAttribute("operator", "over");
34+
overComposite1.setAttribute("k1", ".5");
35+
overComposite1.setAttribute("k2", ".1");
36+
overComposite1.setAttribute("k3", ".5");
37+
overComposite1.setAttribute("k4", ".3");
38+
39+
overComposite1.setAttribute("result", "C1");
40+
41+
var off2 = createSVGElement("feOffset");
42+
off2.setAttribute("in", "SourceGraphic");
43+
off2.setAttribute("dx", "60");
44+
off2.setAttribute("dy", "50");
45+
off2.setAttribute("result", "off2");
46+
47+
var flood2 = createSVGElement("feFlood");
48+
flood2.setAttribute("flood-color", "#408067");
49+
flood2.setAttribute("flood-opacity", ".6");
50+
flood2.setAttribute("result", "F2");
51+
52+
var overComposite2 = createSVGElement("feComposite");
53+
overComposite2.setAttribute("in", "F2");
54+
overComposite2.setAttribute("in2", "off2");
55+
overComposite2.setAttribute("operator", "in");
56+
overComposite2.setAttribute("result", "C2");
57+
58+
var off3 = createSVGElement("feOffset");
59+
off3.setAttribute("in", "SourceGraphic");
60+
off3.setAttribute("dx", "85");
61+
off3.setAttribute("dy", "75");
62+
off3.setAttribute("result", "off3");
63+
64+
var flood3 = createSVGElement("feFlood");
65+
flood3.setAttribute("flood-color", "#408067");
66+
flood3.setAttribute("flood-opacity", ".4");
67+
flood3.setAttribute("result", "F3");
68+
69+
var overComposite3 = createSVGElement("feComposite");
70+
overComposite3.setAttribute("in2", "off3");
71+
overComposite3.setAttribute("operator", "in");
72+
overComposite3.setAttribute("result", "C3");
73+
74+
var merge = createSVGElement("feMerge");
75+
76+
var mergeNode1 = createSVGElement("feMergeNode");
77+
mergeNode1.setAttribute("in", "C1");
78+
79+
var mergeNode2 = createSVGElement("feMergeNode");
80+
mergeNode2.setAttribute("in", "C2");
81+
82+
var mergeNode3 = createSVGElement("feMergeNode");
83+
mergeNode3.setAttribute("in", "C3");
84+
85+
var mergeNode4 = createSVGElement("feMergeNode");
86+
mergeNode4.setAttribute("in", "SourceGraphic");
87+
88+
merge.appendChild(mergeNode3);
89+
merge.appendChild(mergeNode2);
90+
merge.appendChild(mergeNode1);
91+
merge.appendChild(mergeNode4);
92+
93+
var overFilter = createSVGElement("filter");
94+
overFilter.setAttribute("id", "overFilter");
95+
overFilter.setAttribute("filterUnits", "objectBoundingBox");
96+
overFilter.setAttribute("x", "0");
97+
overFilter.setAttribute("y", "0");
98+
overFilter.setAttribute("width", "3.5");
99+
overFilter.setAttribute("height", "4");
100+
overFilter.appendChild(off1);
101+
overFilter.appendChild(flood1);
102+
overFilter.appendChild(overComposite1);
103+
overFilter.appendChild(off2);
104+
overFilter.appendChild(flood2);
105+
overFilter.appendChild(overComposite2);
106+
overFilter.appendChild(off3);
107+
overFilter.appendChild(flood3);
108+
overFilter.appendChild(overComposite3);
109+
overFilter.appendChild(merge);
110+
111+
defsElement.appendChild(overFilter);
112+
113+
// Setup test document
114+
var rect = createSVGElement("rect");
115+
rect.setAttribute("id", "rect");
116+
rect.setAttribute("width", "100");
117+
rect.setAttribute("height", "100");
118+
rect.setAttribute("fill", "#408067");
119+
rect.setAttribute("filter", "url(#overFilter)");
120+
rect.setAttribute("onclick", "executeTest()");
121+
rootSVGElement.appendChild(rect);
122+
123+
var animate = createSVGElement("animate");
124+
animate.setAttribute("id", "animation");
125+
animate.setAttribute("attributeName", "operator");
126+
animate.setAttribute("begin", "0s");
127+
animate.setAttribute("dur", "5s");
128+
animate.setAttribute("values", "in;out;atop;xor;arithmetic");
129+
overComposite1.appendChild(animate);
130+
131+
// Setup animation test
132+
function sample1() {
133+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
134+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
135+
}
136+
137+
function sample2() {
138+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_IN);
139+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
140+
}
141+
142+
function sample3() {
143+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT);
144+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
145+
}
146+
147+
function sample4() {
148+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ATOP);
149+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
150+
}
151+
152+
function sample5() {
153+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_XOR);
154+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
155+
}
156+
157+
function sample6() {
158+
assert_equals(overComposite1.operator.animVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
159+
assert_equals(overComposite1.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
160+
}
161+
162+
smil_async_test((t) => {
163+
const expectedValues = [
164+
// [animationId, time, sampleCallback]
165+
["animation", 0.0, sample1],
166+
["animation", 0.001, sample2],
167+
["animation", 0.999, sample2],
168+
["animation", 1.001, sample3],
169+
["animation", 1.999, sample3],
170+
["animation", 2.001, sample4],
171+
["animation", 2.999, sample4],
172+
["animation", 3.001, sample5],
173+
["animation", 3.999, sample5],
174+
["animation", 4.001, sample6],
175+
["animation", 4.999, sample6],
176+
["animation", 5.001, sample1]
177+
];
178+
179+
runAnimationTest(t, expectedValues);
180+
});
181+
182+
</script>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!doctype html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>Test MorphologyOperatorType enumeration animations</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
8+
9+
<svg>
10+
</svg>
11+
12+
<script>
13+
var rootSVGElement = document.querySelector("svg");
14+
var epsilon = 1.0;
15+
16+
// Setup test document
17+
var defs = createSVGElement("defs");
18+
rootSVGElement.appendChild(defs);
19+
20+
var morphology = createSVGElement("feMorphology");
21+
morphology.setAttribute("in", "SourceAlpha");
22+
morphology.setAttribute("operator", "dilate");
23+
morphology.setAttribute("radius", "4");
24+
25+
var filter = createSVGElement("filter");
26+
filter.setAttribute("id", "filter");
27+
filter.setAttribute("filterUnits", "userSpaceOnUse");
28+
filter.setAttribute("x", "0");
29+
filter.setAttribute("y", "0");
30+
filter.setAttribute("width", "700");
31+
filter.setAttribute("height", "200");
32+
filter.appendChild(morphology);
33+
defs.appendChild(filter);
34+
35+
var rect = createSVGElement("rect");
36+
rect.setAttribute("id", "rect");
37+
rect.setAttribute("width", "100");
38+
rect.setAttribute("height", "100");
39+
rect.setAttribute("fill", "#408067");
40+
rect.setAttribute("filter", "url(#filter)");
41+
rect.setAttribute("onclick", "executeTest()");
42+
rootSVGElement.appendChild(rect);
43+
44+
var animate = createSVGElement("animate");
45+
animate.setAttribute("id", "animation");
46+
animate.setAttribute("attributeName", "operator");
47+
animate.setAttribute("begin", "0s");
48+
animate.setAttribute("dur", "4s");
49+
animate.setAttribute("from", "dilate");
50+
animate.setAttribute("to", "erode");
51+
morphology.appendChild(animate);
52+
53+
// Setup animation test
54+
function sample1() {
55+
assert_equals(morphology.operator.animVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
56+
assert_equals(morphology.operator.baseVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
57+
}
58+
59+
function sample2() {
60+
assert_equals(morphology.operator.animVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_ERODE);
61+
assert_equals(morphology.operator.baseVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
62+
}
63+
64+
smil_async_test((t) => {
65+
const expectedValues = [
66+
// [animationId, time, sampleCallback]
67+
["animation", 0.0, sample1],
68+
["animation", 1.999, sample1],
69+
["animation", 2.001, sample2],
70+
["animation", 3.999, sample2],
71+
["animation", 4.001, sample1]
72+
];
73+
74+
runAnimationTest(t, expectedValues);
75+
});
76+
77+
</script>

0 commit comments

Comments
 (0)