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

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

Issue 1413463008: Web Animations: Migrate SVG path interpolation to interpolation types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* Copyright 2015 The Chromium Authors. All rights reserved. 1 /* Copyright 2015 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Exported function: 5 * Exported function:
6 * - assertAttributeInterpolation({property, from, to, [fromComposite], [toComp osite], [underlying]}, [{at: fraction, is: value}]) 6 * - assertAttributeInterpolation({property, from, to, [fromComposite], [toComp osite], [underlying]}, [{at: fraction, is: value}])
7 * Constructs a test case for each fraction that asserts the expected val ue 7 * Constructs a test case for each fraction that asserts the expected val ue
8 * equals the value produced by interpolation between from and to composi ted 8 * equals the value produced by interpolation between from and to composi ted
9 * onto underlying by fromComposite and toComposite respectively using 9 * onto underlying by fromComposite and toComposite respectively using
10 * SMIL and Web Animations. 10 * SMIL and Web Animations.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return (parseFloat(n).toFixed(2)). 51 return (parseFloat(n).toFixed(2)).
52 replace(/\.\d+/, function(m) { 52 replace(/\.\d+/, function(m) {
53 return m.replace(/0+$/, ''); 53 return m.replace(/0+$/, '');
54 }). 54 }).
55 replace(/\.$/, ''). 55 replace(/\.$/, '').
56 replace(/^-0$/, '0'); 56 replace(/^-0$/, '0');
57 }); 57 });
58 } 58 }
59 59
60 function normalizeValue(value) { 60 function normalizeValue(value) {
61 if (value === null) {
62 return '-NULL-';
63 }
61 return roundNumbers(value). 64 return roundNumbers(value).
62 // Place whitespace between tokens. 65 // Place whitespace between tokens.
63 replace(/([\w\d.]+|[^\s])/g, '$1 '). 66 replace(/([\w\d.]+|[^\s])/g, '$1 ').
64 replace(/\s+/g, ' '); 67 replace(/\s+/g, ' ');
65 } 68 }
66 69
67 function createTarget(container) { 70 function createTarget(container) {
68 var targetContainer = createElement('div'); 71 var targetContainer = createElement('div');
69 var template = document.querySelector('#target-template'); 72 var template = document.querySelector('#target-template');
70 if (template) { 73 if (template) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 target.container.setCurrentTime(expectation.at); 310 target.container.setCurrentTime(expectation.at);
308 } else { 311 } else {
309 console.warn(`Unable to test SMIL from ${params.from} to ${params.to}` ); 312 console.warn(`Unable to test SMIL from ${params.from} to ${params.to}` );
310 target.container.remove(); 313 target.container.remove();
311 target.measure = function() {}; 314 target.measure = function() {};
312 } 315 }
313 break; 316 break;
314 case 'Web Animations': 317 case 'Web Animations':
315 // Replace 'transform' with 'svgTransform', etc. This avoids collisions with CSS properties or the Web Animations API (offset). 318 // Replace 'transform' with 'svgTransform', etc. This avoids collisions with CSS properties or the Web Animations API (offset).
316 var prefixedProperty = 'svg' + params.property[0].toUpperCase() + params .property.slice(1); 319 var prefixedProperty = 'svg' + params.property[0].toUpperCase() + params .property.slice(1);
317 target.animate([ 320 var keyFrames = [];
318 { 321 if (params.from !== '') {
322 keyFrames.push({
323 offset: 0,
319 [prefixedProperty]: params.from, 324 [prefixedProperty]: params.from,
320 composite: params.fromComposite, 325 composite: params.fromComposite,
321 }, 326 })
322 { 327 }
328 if (params.to !== '') {
329 keyFrames.push({
330 offset: 1,
323 [prefixedProperty]: params.to, 331 [prefixedProperty]: params.to,
324 composite: params.toComposite, 332 composite: params.toComposite,
325 }, 333 })
326 ], { 334 }
335 target.animate(keyFrames, {
327 fill: 'forwards', 336 fill: 'forwards',
328 duration: 1, 337 duration: 1,
329 easing: createEasing(expectation.at), 338 easing: createEasing(expectation.at),
330 delay: -0.5, 339 delay: -0.5,
331 iterations: 0.5, 340 iterations: 0.5,
332 }); 341 });
333 break; 342 break;
334 default: 343 default:
335 console.error('Unknown test method: ' + method); 344 console.error('Unknown test method: ' + method);
336 } 345 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 return loadScript('../../resources/testharnessreport.js'); 418 return loadScript('../../resources/testharnessreport.js');
410 }).then(() => { 419 }).then(() => {
411 var asyncHandle = async_test('This test uses interpolation-test.js.') 420 var asyncHandle = async_test('This test uses interpolation-test.js.')
412 requestAnimationFrame(() => { 421 requestAnimationFrame(() => {
413 runTests().then(() => asyncHandle.done()); 422 runTests().then(() => asyncHandle.done());
414 }); 423 });
415 }); 424 });
416 425
417 window.assertAttributeInterpolation = assertAttributeInterpolation; 426 window.assertAttributeInterpolation = assertAttributeInterpolation;
418 })(); 427 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698