Bug 1359786 - reuse existing lengthPairType for positionType in web animations' web-platform-tests. draft
authorJeremy Chen <jeremychen@mozilla.com>
Sat, 29 Apr 2017 21:41:43 +0800
changeset 570610 9880ee8893f9c837c918493808740442add97193
parent 570609 83f74fb346586455f06c4c88612b2f74efbc1071
child 570611 3dbbe82b9ed7f7856be45e9378dba00508a67020
push id56530
push userjichen@mozilla.com
push dateSat, 29 Apr 2017 13:45:21 +0000
bugs1359786
milestone55.0a1
Bug 1359786 - reuse existing lengthPairType for positionType in web animations' web-platform-tests. Since lengthPairType and positionType share the same testing logics, we shall just reuse lengthPairType::{testInterpolation, testAddition} for positionType. MozReview-Commit-ID: 1nBBHmTB3U9
testing/web-platform/tests/web-animations/animation-model/animation-types/property-types.js
--- a/testing/web-platform/tests/web-animations/animation-model/animation-types/property-types.js
+++ b/testing/web-platform/tests/web-animations/animation-model/animation-types/property-types.js
@@ -1127,63 +1127,31 @@ const boxShadowListType = {
         [ { time: 0, expected: 'rgb(0, 0, 0) 0px 0px 0px 0px, ' +
                                'rgb(120, 120, 120) 10px 10px 10px 0px' }]);
     }, property + ': shadow');
   },
 };
 
 const positionType = {
   testInterpolation: function(property, setup) {
-    test(function(t) {
-      var idlName = propertyToIDL(property);
-      var target = createTestElement(t, setup);
-      var animation = target.animate({ [idlName]: ['10px 10px', '50px 50px'] },
-                                     { duration: 1000, fill: 'both' });
-      testAnimationSamples(animation, idlName,
-                           [{ time: 500,  expected: '30px 30px' }]);
-    }, property + ' supports animating as a position');
-
-    test(function(t) {
-      var idlName = propertyToIDL(property);
-      var target = createTestElement(t, setup);
-      var animation = target.animate({ [idlName]: ['1rem 1rem', '5rem 5rem'] },
-                                     { duration: 1000, fill: 'both' });
-      testAnimationSamples(animation, idlName,
-                           [{ time: 500,  expected: '30px 30px' }]);
-    }, property + ' supports animating as a position of rem');
+    lengthPairType.testInterpolation(property, setup);
 
     test(function(t) {
       var idlName = propertyToIDL(property);
       var target = createTestElement(t, setup);
       var animation = target.animate({ [idlName]: ['10% 10%', '50% 50%'] },
                                      { duration: 1000, fill: 'both' });
       testAnimationSamples(
         animation, idlName,
         [{ time: 500,  expected: calcFromPercentage(idlName, '30% 30%') }]);
     }, property + ' supports animating as a position of percent');
   },
 
   testAddition: function(property, setup) {
-    test(function(t) {
-      var idlName = propertyToIDL(property);
-      var target = createTestElement(t, setup);
-      target.style[idlName] = '10px 10px';
-      var animation = target.animate({ [idlName]: ['10px 10px', '50px 50px'] },
-                                     { duration: 1000, composite: 'add' });
-      testAnimationSamples(animation, idlName, [{ time: 0, expected: '20px 20px' }]);
-    }, property + ': position');
-
-    test(function(t) {
-      var idlName = propertyToIDL(property);
-      var target = createTestElement(t, setup);
-      target.style[idlName] = '1rem 1rem';
-      var animation = target.animate({ [idlName]: ['1rem 1rem', '5rem 5rem'] },
-                                     { duration: 1000, composite: 'add' });
-      testAnimationSamples(animation, idlName, [{ time: 0, expected: '20px 20px' }]);
-    }, property + ': position of rem');
+    lengthPairType.testAddition(property, setup);
 
     test(function(t) {
       var idlName = propertyToIDL(property);
       var target = createTestElement(t, setup);
       target.style[idlName] = '60% 60%';
       var animation = target.animate({ [idlName]: ['70% 70%', '100% 100%'] },
                                      { duration: 1000, composite: 'add' });
       testAnimationSamples(