OLD | NEW |
---|---|
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 var interpolationTests = []; | 56 var interpolationTests = []; |
57 var compositionTests = []; | 57 var compositionTests = []; |
58 var cssAnimationsData = { | 58 var cssAnimationsData = { |
59 sharedStyle: null, | 59 sharedStyle: null, |
60 nextID: 0, | 60 nextID: 0, |
61 }; | 61 }; |
62 var webAnimationsEnabled = typeof Element.prototype.animate === 'function'; | 62 var webAnimationsEnabled = typeof Element.prototype.animate === 'function'; |
63 var expectNoInterpolation = {}; | 63 var expectNoInterpolation = {}; |
64 var afterTestHook = function() {}; | 64 var afterTestHook = function() {}; |
65 | 65 |
66 function toCamelCase(property) { | |
67 for (var i = property.length - 2; i > 0; --i) { | |
68 if (property[i] === '-') { | |
69 property = property.substring(0, i) + property[i + 1].toUpperCase() + pr operty.substring(i + 2); | |
70 } | |
71 } | |
72 return property; | |
73 } | |
74 | |
alancutter (OOO until 2018)
2016/03/07 03:08:53
This helper function should be below the configura
Eric Willigers
2016/03/09 03:21:21
Done.
| |
66 var cssAnimationsInterpolation = { | 75 var cssAnimationsInterpolation = { |
67 name: 'CSS Animations', | 76 name: 'CSS Animations', |
68 supportsProperty: function() {return true;}, | 77 supportsProperty: function() {return true;}, |
69 supportsValue: function() {return true;}, | 78 supportsValue: function() {return true;}, |
70 setup: function() {}, | 79 setup: function() {}, |
71 nonInterpolationExpectations: function(from, to) { | 80 nonInterpolationExpectations: function(from, to) { |
72 return expectFlip(from, to, 0.5); | 81 return expectFlip(from, to, 0.5); |
73 }, | 82 }, |
74 interpolate: function(property, from, to, at, target) { | 83 interpolate: function(property, from, to, at, target) { |
75 var id = cssAnimationsData.nextID++; | 84 var id = cssAnimationsData.nextID++; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 120 |
112 var webAnimationsInterpolation = { | 121 var webAnimationsInterpolation = { |
113 name: 'Web Animations', | 122 name: 'Web Animations', |
114 supportsProperty: function(property) {return property.indexOf('-webkit-') != = 0;}, | 123 supportsProperty: function(property) {return property.indexOf('-webkit-') != = 0;}, |
115 supportsValue: function(value) {return value !== '';}, | 124 supportsValue: function(value) {return value !== '';}, |
116 setup: function() {}, | 125 setup: function() {}, |
117 nonInterpolationExpectations: function(from, to) { | 126 nonInterpolationExpectations: function(from, to) { |
118 return expectFlip(from, to, 0.5); | 127 return expectFlip(from, to, 0.5); |
119 }, | 128 }, |
120 interpolate: function(property, from, to, at, target) { | 129 interpolate: function(property, from, to, at, target) { |
121 // Convert to camelCase | 130 property = toCamelCase(property); |
122 for (var i = property.length - 2; i > 0; --i) { | |
123 if (property[i] === '-') { | |
124 property = property.substring(0, i) + property[i + 1].toUpperCase() + property.substring(i + 2); | |
125 } | |
126 } | |
127 this.interpolateKeyframes([ | 131 this.interpolateKeyframes([ |
128 {offset: 0, [property]: from}, | 132 {offset: 0, [property]: from}, |
129 {offset: 1, [property]: to}, | 133 {offset: 1, [property]: to}, |
130 ], at, target); | 134 ], at, target); |
131 }, | 135 }, |
132 interpolateKeyframes: function(keyframes, at, target) { | 136 interpolateKeyframes: function(keyframes, at, target) { |
133 target.animate(keyframes, { | 137 target.animate(keyframes, { |
134 fill: 'forwards', | 138 fill: 'forwards', |
135 duration: 1, | 139 duration: 1, |
136 easing: createEasing(at), | 140 easing: createEasing(at), |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 return compositionTest.expectations.map(function(expectation) { | 336 return compositionTest.expectations.map(function(expectation) { |
333 var actualTargetContainer = createTargetContainer(testContainer, 'actual') ; | 337 var actualTargetContainer = createTargetContainer(testContainer, 'actual') ; |
334 var expectedTargetContainer = createTargetContainer(testContainer, 'expect ed'); | 338 var expectedTargetContainer = createTargetContainer(testContainer, 'expect ed'); |
335 expectedTargetContainer.target.style[property] = expectation.is; | 339 expectedTargetContainer.target.style[property] = expectation.is; |
336 var target = actualTargetContainer.target; | 340 var target = actualTargetContainer.target; |
337 target.style[property] = underlying; | 341 target.style[property] = underlying; |
338 target.interpolate = function() { | 342 target.interpolate = function() { |
339 webAnimationsInterpolation.interpolateKeyframes([{ | 343 webAnimationsInterpolation.interpolateKeyframes([{ |
340 offset: 0, | 344 offset: 0, |
341 composite: fromComposite, | 345 composite: fromComposite, |
342 [property]: from, | 346 [toCamelCase(property)]: from, |
343 }, { | 347 }, { |
344 offset: 1, | 348 offset: 1, |
345 composite: toComposite, | 349 composite: toComposite, |
346 [property]: to, | 350 [toCamelCase(property)]: to, |
347 }], expectation.at, target); | 351 }], expectation.at, target); |
348 }; | 352 }; |
349 target.measure = function() { | 353 target.measure = function() { |
350 var actualValue = getComputedStyle(target)[property]; | 354 var actualValue = getComputedStyle(target)[property]; |
351 test(function() { | 355 test(function() { |
352 assert_equals( | 356 assert_equals( |
353 normalizeValue(actualValue), | 357 normalizeValue(actualValue), |
354 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop erty])); | 358 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop erty])); |
355 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `); | 359 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}] `); |
356 if (rebaselineExpectation) { | 360 if (rebaselineExpectation) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 loadScript('../../resources/testharness.js').then(function() { | 417 loadScript('../../resources/testharness.js').then(function() { |
414 return loadScript('../../resources/testharnessreport.js'); | 418 return loadScript('../../resources/testharnessreport.js'); |
415 }).then(function() { | 419 }).then(function() { |
416 var asyncHandle = async_test('This test uses interpolation-test.js.') | 420 var asyncHandle = async_test('This test uses interpolation-test.js.') |
417 requestAnimationFrame(function() { | 421 requestAnimationFrame(function() { |
418 runTests(); | 422 runTests(); |
419 asyncHandle.done() | 423 asyncHandle.done() |
420 }); | 424 }); |
421 }); | 425 }); |
422 })(); | 426 })(); |
OLD | NEW |