OLD | NEW |
1 // Inspired by Layoutests/animations/animation-test-helpers.js | 1 // Inspired by Layoutests/animations/animation-test-helpers.js |
2 | 2 |
3 function isCloseEnough(actual, desired, tolerance) { | 3 function isCloseEnough(actual, desired, tolerance) { |
4 var diff = Math.abs(actual - desired); | 4 var diff = Math.abs(actual - desired); |
5 return diff <= tolerance; | 5 return diff <= tolerance; |
6 } | 6 } |
7 | 7 |
8 function shouldBeCloseEnough(_a, _b, tolerance) { | 8 function shouldBeCloseEnough(_a, _b, tolerance) { |
9 if (typeof tolerance != "number") | 9 if (typeof tolerance != "number") |
10 tolerance = 0.1 // Default | 10 tolerance = 0.1 // Default |
(...skipping 25 matching lines...) Expand all Loading... |
36 shouldBeCloseEnough(actualMatrix + ".d", expectedD, tolerance); | 36 shouldBeCloseEnough(actualMatrix + ".d", expectedD, tolerance); |
37 shouldBeCloseEnough(actualMatrix + ".e", expectedE, tolerance); | 37 shouldBeCloseEnough(actualMatrix + ".e", expectedE, tolerance); |
38 shouldBeCloseEnough(actualMatrix + ".f", expectedF, tolerance); | 38 shouldBeCloseEnough(actualMatrix + ".f", expectedF, tolerance); |
39 } | 39 } |
40 | 40 |
41 function expectTranslationMatrix(actualMatrix, expectedE, expectedF, tolerance)
{ | 41 function expectTranslationMatrix(actualMatrix, expectedE, expectedF, tolerance)
{ |
42 shouldBeCloseEnough(actualMatrix + ".e", expectedE, tolerance); | 42 shouldBeCloseEnough(actualMatrix + ".e", expectedE, tolerance); |
43 shouldBeCloseEnough(actualMatrix + ".f", expectedF, tolerance); | 43 shouldBeCloseEnough(actualMatrix + ".f", expectedF, tolerance); |
44 } | 44 } |
45 | 45 |
| 46 function getTransformToElement(rootElement, element) { |
| 47 return element.getCTM().inverse().multiply(rootElement.getCTM()); |
| 48 } |
| 49 |
46 function expectColor(element, red, green, blue, property) { | 50 function expectColor(element, red, green, blue, property) { |
47 if (typeof property != "string") | 51 if (typeof property != "string") |
48 color = getComputedStyle(element).getPropertyValue("color"); | 52 color = getComputedStyle(element).getPropertyValue("color"); |
49 else | 53 else |
50 color = getComputedStyle(element).getPropertyValue(property); | 54 color = getComputedStyle(element).getPropertyValue(property); |
51 | 55 |
52 var re = new RegExp("rgba?\\(([^, ]*), ([^, ]*), ([^, ]*)(?:, )?([^, ]*)\\)"
); | 56 var re = new RegExp("rgba?\\(([^, ]*), ([^, ]*), ([^, ]*)(?:, )?([^, ]*)\\)"
); |
53 colorComponents = re.exec(color); | 57 colorComponents = re.exec(color); |
54 | 58 |
55 // Allow a tolerance of 1 for color values, as they are integers. | 59 // Allow a tolerance of 1 for color values, as they are integers. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (expectedResults[0][1] == 0) { | 140 if (expectedResults[0][1] == 0) { |
137 expectedResults[0][2](); | 141 expectedResults[0][2](); |
138 ++currentTest; | 142 ++currentTest; |
139 } | 143 } |
140 | 144 |
141 if (window.testRunner) | 145 if (window.testRunner) |
142 setTimeout(sampleAnimation, 0); | 146 setTimeout(sampleAnimation, 0); |
143 else | 147 else |
144 setTimeout(sampleAnimation, 50); | 148 setTimeout(sampleAnimation, 50); |
145 } | 149 } |
OLD | NEW |