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

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

Issue 1416703004: Web Animations: Add SVGIntegerOptionalIntegerInterpolationType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_svgNONInterpolationType
Patch Set: Fix test 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], [to Composite], [underlying]}, [{at: fraction, is: value}]) 6 * - assertAttributeInterpolation({property, [from], [to], [fromComposite], [to Composite], [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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 assert_equals( 362 assert_equals(
363 normalizeValue(actualResult), 363 normalizeValue(actualResult),
364 normalizeValue(getAttributeValue(expected, params.property))); 364 normalizeValue(getAttributeValue(expected, params.property)));
365 }, `${method}: ${description} at (${expectation.at}) is [${expectation.is} ]`); 365 }, `${method}: ${description} at (${expectation.at}) is [${expectation.is} ]`);
366 }; 366 };
367 367
368 return target; 368 return target;
369 } 369 }
370 370
371 function reprKeyframe(x) {
dstockwell 2015/11/23 04:51:43 this isn't python. repr is a bit weird.
alancutter (OOO until 2018) 2015/11/23 06:10:36 This change is out of date with other landed patch
372 return (typeof x === 'string') ? "'" + x + "'" : null;
373 }
374
371 function createTestTargets(interpolationTests, container, rebaselineContainer) { 375 function createTestTargets(interpolationTests, container, rebaselineContainer) {
372 var targets = []; 376 var targets = [];
373 for (var interpolationTest of interpolationTests) { 377 for (var interpolationTest of interpolationTests) {
374 var params = interpolationTest.params; 378 var params = interpolationTest.params;
375 params.fromComposite = 'from' in params ? (params.fromComposite || 'replac e') : 'add'; 379 params.fromComposite = 'from' in params ? (params.fromComposite || 'replac e') : 'add';
376 params.toComposite = 'to' in params ? (params.toComposite || 'replace') : 'add'; 380 params.toComposite = 'to' in params ? (params.toComposite || 'replace') : 'add';
377 var underlyingText = params.underlying ? `with underlying [${params.underl ying}] ` : ''; 381 var underlyingText = params.underlying ? `with underlying [${params.underl ying}] ` : '';
378 var fromText = 'from' in params ? `${params.fromComposite} [${params.from} ]` : 'neutral'; 382 var fromText = 'from' in params ? `${params.fromComposite} [${params.from} ]` : 'neutral';
379 var toText = 'to' in params ? `${params.toComposite} [${params.to}]` : 'ne utral'; 383 var toText = 'to' in params ? `${params.toComposite} [${params.to}]` : 'ne utral';
380 var description = `Interpolate attribute <${params.property}> ${underlying Text}from ${fromText} to ${toText}`; 384 var description = `Interpolate attribute <${params.property}> ${underlying Text}from ${fromText} to ${toText}`;
381 385
382 if (rebaselineTests) { 386 if (rebaselineTests) {
383 var rebaseline = createElement('pre', rebaselineContainer); 387 var rebaseline = createElement('pre', rebaselineContainer);
384
385 var fromCode = 'from' in params ? `
386 from: '${params.from}',
387 fromComposite: '${params.fromComposite}',` : '';
388
389 var toCode = 'to' in params ? `
390 to: '${params.to}',
391 toComposite: '${params.toComposite}',` : '';
392
393 rebaseline.appendChild(document.createTextNode(`\ 388 rebaseline.appendChild(document.createTextNode(`\
394 assertAttributeInterpolation({ 389 assertAttributeInterpolation({
395 property: '${params.property}', 390 property: '${params.property}',
396 underlying: '${params.underlying}',${fromCode}${toCode} 391 underlying: '${params.underlying}',
392 from: ${reprKeyframe(params.from)},
393 fromComposite: '${params.fromComposite}',
394 to: ${reprKeyframe(params.to)},
395 toComposite: '${params.toComposite}',
397 }, [\n`)); 396 }, [\n`));
398 var rebaselineExpectation; 397 var rebaselineExpectation;
399 rebaseline.appendChild(rebaselineExpectation = document.createTextNode(' ')); 398 rebaseline.appendChild(rebaselineExpectation = document.createTextNode(' '));
400 rebaseline.appendChild(document.createTextNode(']);\n\n')); 399 rebaseline.appendChild(document.createTextNode(']);\n\n'));
401 } 400 }
402 401
403 for (var method of ['SMIL', 'Web Animations']) { 402 for (var method of ['SMIL', 'Web Animations']) {
404 if (method === 'SMIL' && params.fromComposite !== params.toComposite) { 403 if (method === 'SMIL' && params.fromComposite !== params.toComposite) {
405 continue; 404 continue;
406 } 405 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 return loadScript('../../resources/testharnessreport.js'); 454 return loadScript('../../resources/testharnessreport.js');
456 }).then(() => { 455 }).then(() => {
457 var asyncHandle = async_test('This test uses interpolation-test.js.') 456 var asyncHandle = async_test('This test uses interpolation-test.js.')
458 requestAnimationFrame(() => { 457 requestAnimationFrame(() => {
459 runTests().then(() => asyncHandle.done()); 458 runTests().then(() => asyncHandle.done());
460 }); 459 });
461 }); 460 });
462 461
463 window.assertAttributeInterpolation = assertAttributeInterpolation; 462 window.assertAttributeInterpolation = assertAttributeInterpolation;
464 })(); 463 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698