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

Unified Diff: third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js

Issue 1459093002: Make neutral keyframes explicit in SVG attribute interpolation test API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review changes Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/animations/svg-attribute-composition/svg-z-composition.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js
diff --git a/third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js b/third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js
index 6e24685ba098206b429ab55e75d6bf01141b577d..923c587954a94ca9570070d7dc211dd7d2ddf1ba 100644
--- a/third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js
+++ b/third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js
@@ -3,22 +3,26 @@
* found in the LICENSE file.
*
* Exported function:
- * - assertAttributeInterpolation({property, [from], [to], [fromComposite], [toComposite], [underlying]}, [{at: fraction, is: value}])
+ * - assertAttributeInterpolation({property, from, to, [fromComposite], [toComposite], [underlying]}, [{at: fraction, is: value}])
* Constructs a test case for each fraction that asserts the expected value
* equals the value produced by interpolation between from and to composited
* onto underlying by fromComposite and toComposite respectively using
* SMIL and Web Animations.
- * If from or to are missing then a neutral keyframe will be used and the
- * composite mode will be forced to be 'add'.
+ * Set from/to to the exported neutralKeyframe object to specify neutral keyframes.
* SMIL will only be tested with equal fromComposite and toComposite values.
*/
'use strict';
(() => {
var interpolationTests = [];
+ var neutralKeyframe = {};
// Set to true to output rebaselined test expectations.
var rebaselineTests = false;
+ function isNeutralKeyframe(keyframe) {
+ return keyframe === neutralKeyframe;
+ }
+
function createElement(tagName, container) {
var element = document.createElement(tagName);
if (container) {
@@ -320,23 +324,19 @@
// Replace 'transform' with 'svgTransform', etc. This avoids collisions with CSS properties or the Web Animations API (offset).
var prefixedProperty = 'svg' + params.property[0].toUpperCase() + params.property.slice(1);
var keyframes = [];
- if ('from' in params) {
+ if (!isNeutralKeyframe(params.from)) {
keyframes.push({
offset: 0,
[prefixedProperty]: params.from,
composite: params.fromComposite,
});
- } else {
- console.assert(params.fromComposite === 'add');
}
- if ('to' in params) {
+ if (!isNeutralKeyframe(params.to)) {
keyframes.push({
offset: 1,
[prefixedProperty]: params.to,
composite: params.toComposite,
});
- } else {
- console.assert(params.toComposite === 'add');
}
target.animate(keyframes, {
fill: 'forwards',
@@ -372,29 +372,44 @@
var targets = [];
for (var interpolationTest of interpolationTests) {
var params = interpolationTest.params;
- params.fromComposite = 'from' in params ? (params.fromComposite || 'replace') : 'add';
- params.toComposite = 'to' in params ? (params.toComposite || 'replace') : 'add';
+ assert_true('property' in params);
+ assert_true('from' in params);
+ assert_true('to' in params);
+ params.fromComposite = isNeutralKeyframe(params.from) ? 'add' : (params.fromComposite || 'replace');
+ params.toComposite = isNeutralKeyframe(params.to) ? 'add' : (params.toComposite || 'replace');
var underlyingText = params.underlying ? `with underlying [${params.underlying}] ` : '';
- var fromText = 'from' in params ? `${params.fromComposite} [${params.from}]` : 'neutral';
- var toText = 'to' in params ? `${params.toComposite} [${params.to}]` : 'neutral';
+ var fromText = isNeutralKeyframe(params.from) ? 'neutral' : `${params.fromComposite} [${params.from}]`;
+ var toText = isNeutralKeyframe(params.to) ? 'neutral' : `${params.toComposite} [${params.to}]`;
var description = `Interpolate attribute <${params.property}> ${underlyingText}from ${fromText} to ${toText}`;
if (rebaselineTests) {
var rebaseline = createElement('pre', rebaselineContainer);
- var fromCode = 'from' in params ? `
- from: '${params.from}',
- fromComposite: '${params.fromComposite}',` : '';
+ var assertionCode =
+ `assertAttributeInterpolation({\n` +
+ ` property: '${params.property}',\n` +
+ ` underlying: '${params.underlying}',\n`;
+
+
+ if (isNeutralKeyframe(params.from)) {
+ assertionCode += ` from: neutralKeyframe,\n`;
+ } else {
+ assertionCode +=
+ ` from: '${params.from}',\n` +
+ ` fromComposite: '${params.fromComposite}',\n`;
+ }
+
+ if (isNeutralKeyframe(params.to)) {
+ assertionCode += ` to: neutralKeyframe,\n`;
+ } else {
+ assertionCode +=
+ ` to: '${params.to}',\n` +
+ ` fromComposite: '${params.fromComposite}',\n`;
+ }
- var toCode = 'to' in params ? `
- to: '${params.to}',
- toComposite: '${params.toComposite}',` : '';
+ assertionCode += `\n}, [\n`;
- rebaseline.appendChild(document.createTextNode(`\
-assertAttributeInterpolation({
- property: '${params.property}',
- underlying: '${params.underlying}',${fromCode}${toCode}
-}, [\n`));
+ rebaseline.appendChild(document.createTextNode(assertionCode));
var rebaselineExpectation;
rebaseline.appendChild(rebaselineExpectation = document.createTextNode(''));
rebaseline.appendChild(document.createTextNode(']);\n\n'));
@@ -461,4 +476,5 @@ assertAttributeInterpolation({
});
window.assertAttributeInterpolation = assertAttributeInterpolation;
+ window.neutralKeyframe = neutralKeyframe;
})();
« no previous file with comments | « third_party/WebKit/LayoutTests/animations/svg-attribute-composition/svg-z-composition.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698