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

Side by Side Diff: LayoutTests/svg/animations/script-tests/animate-color-rgba-calcMode-discrete.js

Issue 700843006: Don't require getPropertyCSSValue in svg tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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 discrete with from-to animation on colors with alpha channel. You should see a green 100x100 rect and only PASS messages"); 1 description("Test calcMode discrete with from-to animation on colors with alpha channel. You should see a green 100x100 rect and only PASS messages");
2 createSVGTestCase(); 2 createSVGTestCase();
3 3
4 // Setup test document 4 // Setup test document
5 var rect = createSVGElement("rect"); 5 var rect = createSVGElement("rect");
6 rect.setAttribute("id", "rect"); 6 rect.setAttribute("id", "rect");
7 rect.setAttribute("width", "100"); 7 rect.setAttribute("width", "100");
8 rect.setAttribute("height", "100"); 8 rect.setAttribute("height", "100");
9 rect.setAttribute("color", "rgba(0,255,255, 0.4)"); 9 rect.setAttribute("color", "rgba(0,255,255, 0.4)");
10 rect.setAttribute("fill", "currentColor"); 10 rect.setAttribute("fill", "currentColor");
11 rect.setAttribute("onclick", "executeTest()"); 11 rect.setAttribute("onclick", "executeTest()");
12 12
13 var animate = createSVGElement("animate"); 13 var animate = createSVGElement("animate");
14 animate.setAttribute("id", "animation"); 14 animate.setAttribute("id", "animation");
15 animate.setAttribute("attributeName", "color"); 15 animate.setAttribute("attributeName", "color");
16 animate.setAttribute("from", "rgba(255,0,0,0.6)"); 16 animate.setAttribute("from", "rgba(255,0,0,0.6)");
17 animate.setAttribute("to", "rgba(0,255,255,0.8)"); 17 animate.setAttribute("to", "rgba(0,255,255,0.8)");
18 animate.setAttribute("begin", "click"); 18 animate.setAttribute("begin", "click");
19 animate.setAttribute("dur", "4s"); 19 animate.setAttribute("dur", "4s");
20 animate.setAttribute("calcMode", "discrete"); 20 animate.setAttribute("calcMode", "discrete");
21 rect.appendChild(animate); 21 rect.appendChild(animate);
22 rootSVGElement.appendChild(rect); 22 rootSVGElement.appendChild(rect);
23 23
24 function parseAlphaFromColor() {
25 // As alpha is not exposed via CSS OM, we have to parse it from the color st ring, to be able
26 // to use shouldBeCloseEnough() - otherwise we can't allow tolerances, and t his test is flaky.
27 colorString = getComputedStyle(rect).getPropertyValue('color');
28 return colorString.replace(/rgba.*\,/, "").replace(/\)$/, "");
29 }
30
31 function expectRGBAColor(red, green, blue, alpha) { 24 function expectRGBAColor(red, green, blue, alpha) {
32 rgbColor = getComputedStyle(rect).getPropertyCSSValue('color').getRGBColorVa lue(); 25 colors = getComputedStyle(rect).color.replace("rgba(", "").replace(")", ""). split(",");
33 shouldBeCloseEnough("rgbColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER )", "" + red, 1); 26 shouldBeCloseEnough("colors[0]", "" + red, 1);
34 shouldBeCloseEnough("rgbColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMB ER)", "" + green, 1); 27 shouldBeCloseEnough("colors[1]", "" + green, 1);
35 shouldBeCloseEnough("rgbColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBE R)", "" + blue, 1); 28 shouldBeCloseEnough("colors[2]", "" + blue, 1);
36 shouldBeCloseEnough("parseAlphaFromColor()", "" + alpha, 0.1); 29 shouldBeCloseEnough("colors[3]", "" + alpha, 0.1);
37 } 30 }
38 31
39 // Setup animation test 32 // Setup animation test
40 function sample1() { 33 function sample1() {
41 expectRGBAColor(255, 0, 0, 0.6); 34 expectRGBAColor(255, 0, 0, 0.6);
42 } 35 }
43 36
44 function sample2() { 37 function sample2() {
45 expectRGBAColor(0, 255, 255, 0.8); 38 expectRGBAColor(0, 255, 255, 0.8);
46 } 39 }
(...skipping 10 matching lines...) Expand all
57 ["animation", 1.0, sample1], 50 ["animation", 1.0, sample1],
58 ["animation", 3.0, sample2], 51 ["animation", 3.0, sample2],
59 ["animation", 3.999, sample2], 52 ["animation", 3.999, sample2],
60 ["animation", 4.001, sample3] 53 ["animation", 4.001, sample3]
61 ]; 54 ];
62 55
63 runAnimationTest(expectedValues); 56 runAnimationTest(expectedValues);
64 } 57 }
65 58
66 var successfullyParsed = true; 59 var successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698