1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<!doctype html>
<html>
<meta charset="utf-8">
<title>Test ChannelSelectorType enumeration animations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
<svg>
</svg>
<script>
var rootSVGElement = document.querySelector("svg");
var epsilon = 1.0;
// Setup test document
var defsElement = createSVGElement("defs");
rootSVGElement.appendChild(defsElement);
var feImage1 = createSVGElement("feImage");
feImage1.setAttribute("result", "Map");
feImage1.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/sphere.png");
var feImage2 = createSVGElement("feImage");
feImage2.setAttribute("result", "Texture");
feImage2.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/DisplaceChecker.png");
var displacementMap = createSVGElement("feDisplacementMap");
displacementMap.setAttribute("in", "Texture");
displacementMap.setAttribute("in2", "Map");
displacementMap.setAttribute("scale", "64");
displacementMap.setAttribute("xChannelSelector", "B");
displacementMap.setAttribute("yChannelSelector", "G");
var filter = createSVGElement("filter");
filter.setAttribute("id", "filter");
filter.setAttribute("filterUnit", "objectBoundingBox");
filter.setAttribute("x", "0");
filter.setAttribute("y", "0");
filter.setAttribute("width", "1");
filter.setAttribute("height", "1");
filter.appendChild(feImage1);
filter.appendChild(feImage2);
filter.appendChild(displacementMap);
defsElement.appendChild(filter);
var rect = createSVGElement("rect");
rect.setAttribute("id", "rect");
rect.setAttribute("onclick", "executeTest()");
rect.setAttribute("width", "100");
rect.setAttribute("height", "100");
rect.setAttribute("filter", "url(#filter)");
rootSVGElement.appendChild(rect);
var animate1 = createSVGElement("animate");
animate1.setAttribute("id", "animation");
animate1.setAttribute("attributeName", "xChannelSelector");
animate1.setAttribute("begin", "0s");
animate1.setAttribute("dur", "4s");
animate1.setAttribute("values", "R;G;B;A");
animate1.setAttribute("fill", "freeze");
displacementMap.appendChild(animate1);
// Setup animation test
function sample1() {
assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
}
function sample2() {
assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_R);
assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
}
function sample3() {
assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_G);
assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
}
function sample4() {
assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_A);
assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
}
smil_async_test((t) => {
const expectedValues = [
// [animationId, time, sampleCallback]
["animation", 0.0, sample1],
["animation", 0.001, sample2],
["animation", 0.999, sample2],
["animation", 1.001, sample3],
["animation", 1.999, sample3],
["animation", 2.001, sample1],
["animation", 2.999, sample1],
["animation", 3.001, sample4],
["animation", 3.999, sample4],
["animation", 4.001, sample4]
];
runAnimationTest(t, expectedValues);
});
</script>
|