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

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

Issue 2891743003: Enable interpolation of CSS property font-variation-settings (Closed)
Patch Set: updatetest Created 3 years, 7 months 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 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 function assertInterpolation(options, expectations) { 271 function assertInterpolation(options, expectations) {
272 interpolationTests.push({options, expectations}); 272 interpolationTests.push({options, expectations});
273 } 273 }
274 274
275 function assertComposition(options, expectations) { 275 function assertComposition(options, expectations) {
276 compositionTests.push({options, expectations}); 276 compositionTests.push({options, expectations});
277 } 277 }
278 278
279 function stringify(text) {
280 if (!text.includes("'")) {
281 return `'${text}'`;
282 }
283 return `"${text.replace('"', '\\"')}"`;
284 }
285
279 function keyframeText(keyframe) { 286 function keyframeText(keyframe) {
280 return isNeutralKeyframe(keyframe) ? 'neutral' : `[${keyframe}]`; 287 return isNeutralKeyframe(keyframe) ? 'neutral' : `[${keyframe}]`;
281 } 288 }
282 289
283 function keyframeCode(keyframe) { 290 function keyframeCode(keyframe) {
284 return isNeutralKeyframe(keyframe) ? 'neutralKeyframe' : `'${keyframe}'`; 291 return isNeutralKeyframe(keyframe) ? 'neutralKeyframe' : `${stringify(keyfra me)}`;
285 } 292 }
286 293
287 function createInterpolationTestTargets(interpolationMethod, interpolationMeth odContainer, interpolationTest, rebaselineContainer) { 294 function createInterpolationTestTargets(interpolationMethod, interpolationMeth odContainer, interpolationTest, rebaselineContainer) {
288 var property = interpolationTest.options.property; 295 var property = interpolationTest.options.property;
289 var from = interpolationTest.options.from; 296 var from = interpolationTest.options.from;
290 var to = interpolationTest.options.to; 297 var to = interpolationTest.options.to;
291 if ((interpolationTest.options.method && interpolationTest.options.method != interpolationMethod.name) 298 if ((interpolationTest.options.method && interpolationTest.options.method != interpolationMethod.name)
292 || !interpolationMethod.supportsProperty(property) 299 || !interpolationMethod.supportsProperty(property)
293 || !interpolationMethod.supportsValue(from) 300 || !interpolationMethod.supportsValue(from)
294 || !interpolationMethod.supportsValue(to)) { 301 || !interpolationMethod.supportsValue(to)) {
(...skipping 28 matching lines...) Expand all
323 interpolationMethod.interpolate(property, from, to, expectation.at, targ et); 330 interpolationMethod.interpolate(property, from, to, expectation.at, targ et);
324 }; 331 };
325 target.measure = function() { 332 target.measure = function() {
326 var actualValue = getComputedStyle(target).getPropertyValue(property); 333 var actualValue = getComputedStyle(target).getPropertyValue(property);
327 test(function() { 334 test(function() {
328 assert_equals( 335 assert_equals(
329 normalizeValue(actualValue), 336 normalizeValue(actualValue),
330 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP ropertyValue(property))); 337 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP ropertyValue(property)));
331 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `); 338 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `);
332 if (rebaselineExpectation) { 339 if (rebaselineExpectation) {
333 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$ {actualValue}'},\n`; 340 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: ${ stringify(actualValue)}},\n`;
334 } 341 }
335 }; 342 };
336 return target; 343 return target;
337 }); 344 });
338 } 345 }
339 346
340 function createCompositionTestTargets(compositionContainer, compositionTest, r ebaselineContainer) { 347 function createCompositionTestTargets(compositionContainer, compositionTest, r ebaselineContainer) {
341 var options = compositionTest.options; 348 var options = compositionTest.options;
342 var property = options.property; 349 var property = options.property;
343 var underlying = options.underlying; 350 var underlying = options.underlying;
344 var from = options.addFrom || options.replaceFrom; 351 var from = options.addFrom || options.replaceFrom;
345 var to = options.addTo || options.replaceTo; 352 var to = options.addTo || options.replaceTo;
346 var fromComposite = 'addFrom' in options ? 'add' : 'replace'; 353 var fromComposite = 'addFrom' in options ? 'add' : 'replace';
347 var toComposite = 'addTo' in options ? 'add' : 'replace'; 354 var toComposite = 'addTo' in options ? 'add' : 'replace';
348 if ('addFrom' in options === 'replaceFrom' in options 355 if ('addFrom' in options === 'replaceFrom' in options
349 || 'addTo' in options === 'replaceTo' in options) { 356 || 'addTo' in options === 'replaceTo' in options) {
350 test(function() { 357 test(function() {
351 assert_true('addFrom' in options !== 'replaceFrom' in options, 'addFrom xor replaceFrom must be specified'); 358 assert_true('addFrom' in options !== 'replaceFrom' in options, 'addFrom xor replaceFrom must be specified');
352 assert_true('addTo' in options !== 'replaceTo' in options, 'addTo xor re placeTo must be specified'); 359 assert_true('addTo' in options !== 'replaceTo' in options, 'addTo xor re placeTo must be specified');
353 }, `Composition tests must use addFrom xor replaceFrom, and addTo xor repl aceTo`); 360 }, `Composition tests must use addFrom xor replaceFrom, and addTo xor repl aceTo`);
354 } 361 }
355 validateTestInputs(property, from, to, underlying); 362 validateTestInputs(property, from, to, underlying);
356 363
357 if (webAnimationsInterpolation.rebaseline) { 364 if (webAnimationsInterpolation.rebaseline) {
358 var rebaseline = createElement(rebaselineContainer, 'pre'); 365 var rebaseline = createElement(rebaselineContainer, 'pre');
359 rebaseline.appendChild(document.createTextNode(`\ 366 rebaseline.appendChild(document.createTextNode(`\
360 assertComposition({ 367 assertComposition({
361 property: '${property}', 368 property: '${property}',
362 underlying: '${underlying}', 369 underlying: '${stringify(underlying)}',
363 ${fromComposite}From: '${from}', 370 ${fromComposite}From: '${stringify(from)}',
364 ${toComposite}To: '${to}', 371 ${toComposite}To: '${stringify(to)}',
365 }, [\n`)); 372 }, [\n`));
366 var rebaselineExpectation; 373 var rebaselineExpectation;
367 rebaseline.appendChild(rebaselineExpectation = document.createTextNode('') ); 374 rebaseline.appendChild(rebaselineExpectation = document.createTextNode('') );
368 rebaseline.appendChild(document.createTextNode(']);\n\n')); 375 rebaseline.appendChild(document.createTextNode(']);\n\n'));
369 } 376 }
370 var testText = `Compositing: property <${property}> underlying [${underlying }] from ${fromComposite} [${from}] to ${toComposite} [${to}]`; 377 var testText = `Compositing: property <${property}> underlying [${underlying }] from ${fromComposite} [${from}] to ${toComposite} [${to}]`;
371 var testContainer = createElement(compositionContainer, 'div', testText); 378 var testContainer = createElement(compositionContainer, 'div', testText);
372 createElement(testContainer, 'br'); 379 createElement(testContainer, 'br');
373 return compositionTest.expectations.map(function(expectation) { 380 return compositionTest.expectations.map(function(expectation) {
374 var actualTargetContainer = createTargetContainer(testContainer, 'actual') ; 381 var actualTargetContainer = createTargetContainer(testContainer, 'actual') ;
375 var expectedTargetContainer = createTargetContainer(testContainer, 'expect ed'); 382 var expectedTargetContainer = createTargetContainer(testContainer, 'expect ed');
376 expectedTargetContainer.target.style.setProperty(property, expectation.is) ; 383 expectedTargetContainer.target.style.setProperty(property, expectation.is) ;
377 var target = actualTargetContainer.target; 384 var target = actualTargetContainer.target;
378 target.style.setProperty(property, underlying); 385 target.style.setProperty(property, underlying);
379 target.interpolate = function() { 386 target.interpolate = function() {
380 webAnimationsInterpolation.interpolateComposite(property, from, fromComp osite, to, toComposite, expectation.at, target); 387 webAnimationsInterpolation.interpolateComposite(property, from, fromComp osite, to, toComposite, expectation.at, target);
381 }; 388 };
382 target.measure = function() { 389 target.measure = function() {
383 var actualValue = getComputedStyle(target).getPropertyValue(property); 390 var actualValue = getComputedStyle(target).getPropertyValue(property);
384 test(function() { 391 test(function() {
385 assert_equals( 392 assert_equals(
386 normalizeValue(actualValue), 393 normalizeValue(actualValue),
387 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP ropertyValue(property))); 394 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP ropertyValue(property)));
388 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `); 395 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `);
389 if (rebaselineExpectation) { 396 if (rebaselineExpectation) {
390 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$ {actualValue}'},\n`; 397 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: ${ stringify(actualValue)}},\n`;
391 } 398 }
392 }; 399 };
393 return target; 400 return target;
394 }); 401 });
395 } 402 }
396 403
397 function validateTestInputs(property, from, to, underlying) { 404 function validateTestInputs(property, from, to, underlying) {
398 if (from && from !== neutralKeyframe && !CSS.supports(property, from)) { 405 if (from && from !== neutralKeyframe && !CSS.supports(property, from)) {
399 test(function() { 406 test(function() {
400 assert_unreached('from value not supported'); 407 assert_unreached('from value not supported');
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 asyncHandle.done() 475 asyncHandle.done()
469 }); 476 });
470 }); 477 });
471 478
472 window.assertInterpolation = assertInterpolation; 479 window.assertInterpolation = assertInterpolation;
473 window.assertNoInterpolation = assertNoInterpolation; 480 window.assertNoInterpolation = assertNoInterpolation;
474 window.assertComposition = assertComposition; 481 window.assertComposition = assertComposition;
475 window.afterTest = afterTest; 482 window.afterTest = afterTest;
476 window.neutralKeyframe = neutralKeyframe; 483 window.neutralKeyframe = neutralKeyframe;
477 })(); 484 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698