1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/test/db_smilAnimateMotion.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,253 @@ 1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 sw=2 sts=2 et: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* testcase data for <animateMotion> */ 1.11 + 1.12 +// Fake motion 'attribute', to satisfy testing code that expects an attribute. 1.13 +var gMotionAttr = new AdditiveAttribute(SMILUtil.getMotionFakeAttributeName(), 1.14 + "XML", "rect"); 1.15 + 1.16 +// CTM-summary-definitions, for re-use by multiple testcase bundles below. 1.17 +var _reusedCTMLists = { 1.18 + pacedBasic: { ctm0: [100, 200, 0], 1.19 + ctm1_6: [105, 205, 0], 1.20 + ctm1_3: [110, 210, 0], 1.21 + ctm2_3: [120, 220, 0], 1.22 + ctm1: [130, 210, 0] 1.23 + }, 1.24 + pacedR60: { ctm0: [100, 200, Math.PI/3], 1.25 + ctm1_6: [105, 205, Math.PI/3], 1.26 + ctm1_3: [110, 210, Math.PI/3], 1.27 + ctm2_3: [120, 220, Math.PI/3], 1.28 + ctm1: [130, 210, Math.PI/3] 1.29 + }, 1.30 + pacedRAuto: { ctm0: [100, 200, Math.PI/4], 1.31 + ctm1_6: [105, 205, Math.PI/4], 1.32 + ctm1_3: [110, 210, Math.PI/4], 1.33 + ctm2_3: [120, 220, -Math.PI/4], 1.34 + ctm1: [130, 210, -Math.PI/4] 1.35 + }, 1.36 + pacedRAutoReverse : { ctm0: [100, 200, 5*Math.PI/4], 1.37 + ctm1_6: [105, 205, 5*Math.PI/4], 1.38 + ctm1_3: [110, 210, 5*Math.PI/4], 1.39 + ctm2_3: [120, 220, 3*Math.PI/4], 1.40 + ctm1: [130, 210, 3*Math.PI/4] 1.41 + }, 1.42 + 1.43 + discreteBasic : { ctm0: [100, 200, 0], 1.44 + ctm1_6: [100, 200, 0], 1.45 + ctm1_3: [120, 220, 0], 1.46 + ctm2_3: [130, 210, 0], 1.47 + ctm1: [130, 210, 0] 1.48 + }, 1.49 + discreteRAuto : { ctm0: [100, 200, Math.PI/4], 1.50 + ctm1_6: [100, 200, Math.PI/4], 1.51 + ctm1_3: [120, 220, -Math.PI/4], 1.52 + ctm2_3: [130, 210, -Math.PI/4], 1.53 + ctm1: [130, 210, -Math.PI/4] 1.54 + }, 1.55 + justMoveBasic : { ctm0: [40, 80, 0], 1.56 + ctm1_6: [40, 80, 0], 1.57 + ctm1_3: [40, 80, 0], 1.58 + ctm2_3: [40, 80, 0], 1.59 + ctm1: [40, 80, 0] 1.60 + }, 1.61 + justMoveR60 : { ctm0: [40, 80, Math.PI/3], 1.62 + ctm1_6: [40, 80, Math.PI/3], 1.63 + ctm1_3: [40, 80, Math.PI/3], 1.64 + ctm2_3: [40, 80, Math.PI/3], 1.65 + ctm1: [40, 80, Math.PI/3] 1.66 + }, 1.67 + justMoveRAuto : { ctm0: [40, 80, Math.atan(2)], 1.68 + ctm1_6: [40, 80, Math.atan(2)], 1.69 + ctm1_3: [40, 80, Math.atan(2)], 1.70 + ctm2_3: [40, 80, Math.atan(2)], 1.71 + ctm1: [40, 80, Math.atan(2)] 1.72 + }, 1.73 + justMoveRAutoReverse : { ctm0: [40, 80, Math.PI + Math.atan(2)], 1.74 + ctm1_6: [40, 80, Math.PI + Math.atan(2)], 1.75 + ctm1_3: [40, 80, Math.PI + Math.atan(2)], 1.76 + ctm2_3: [40, 80, Math.PI + Math.atan(2)], 1.77 + ctm1: [40, 80, Math.PI + Math.atan(2)] 1.78 + }, 1.79 + nullMoveBasic : { ctm0: [0, 0, 0], 1.80 + ctm1_6: [0, 0, 0], 1.81 + ctm1_3: [0, 0, 0], 1.82 + ctm2_3: [0, 0, 0], 1.83 + ctm1: [0, 0, 0] 1.84 + }, 1.85 + nullMoveRAutoReverse : { ctm0: [0, 0, Math.PI], 1.86 + ctm1_6: [0, 0, Math.PI], 1.87 + ctm1_3: [0, 0, Math.PI], 1.88 + ctm2_3: [0, 0, Math.PI], 1.89 + ctm1: [0, 0, Math.PI] 1.90 + }, 1.91 +}; 1.92 + 1.93 +var gMotionBundles = 1.94 +[ 1.95 + // Bundle to test basic functionality (using default calcMode='paced') 1.96 + new TestcaseBundle(gMotionAttr, [ 1.97 + // Basic paced-mode (default) test, with values/mpath/path 1.98 + new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210" }, 1.99 + _reusedCTMLists.pacedBasic), 1.100 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210" }, 1.101 + _reusedCTMLists.pacedBasic), 1.102 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210" }, 1.103 + _reusedCTMLists.pacedBasic), 1.104 + 1.105 + // ..and now with rotate=constant value in degrees 1.106 + new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210", 1.107 + "rotate": "60" }, 1.108 + _reusedCTMLists.pacedR60), 1.109 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.110 + "rotate": "60" }, 1.111 + _reusedCTMLists.pacedR60), 1.112 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210", 1.113 + "rotate": "60" }, 1.114 + _reusedCTMLists.pacedR60), 1.115 + 1.116 + // ..and now with rotate=constant value in radians 1.117 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.118 + "rotate": "1.0471975512rad" }, // pi/3 1.119 + _reusedCTMLists.pacedR60), 1.120 + 1.121 + // ..and now with rotate=auto 1.122 + new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210", 1.123 + "rotate": "auto" }, 1.124 + _reusedCTMLists.pacedRAuto), 1.125 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.126 + "rotate": "auto" }, 1.127 + _reusedCTMLists.pacedRAuto), 1.128 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210", 1.129 + "rotate": "auto" }, 1.130 + _reusedCTMLists.pacedRAuto), 1.131 + 1.132 + // ..and now with rotate=auto-reverse 1.133 + new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210", 1.134 + "rotate": "auto-reverse" }, 1.135 + _reusedCTMLists.pacedRAutoReverse), 1.136 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.137 + "rotate": "auto-reverse" }, 1.138 + _reusedCTMLists.pacedRAutoReverse), 1.139 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210", 1.140 + "rotate": "auto-reverse" }, 1.141 + _reusedCTMLists.pacedRAutoReverse), 1.142 + 1.143 + ]), 1.144 + 1.145 + // Bundle to test calcMode='discrete' 1.146 + new TestcaseBundle(gMotionAttr, [ 1.147 + new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210", 1.148 + "calcMode": "discrete" }, 1.149 + _reusedCTMLists.discreteBasic), 1.150 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.151 + "calcMode": "discrete" }, 1.152 + _reusedCTMLists.discreteBasic), 1.153 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210", 1.154 + "calcMode": "discrete" }, 1.155 + _reusedCTMLists.discreteBasic), 1.156 + // ..and now with rotate=auto 1.157 + new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210", 1.158 + "calcMode": "discrete", 1.159 + "rotate": "auto" }, 1.160 + _reusedCTMLists.discreteRAuto), 1.161 + new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210", 1.162 + "calcMode": "discrete", 1.163 + "rotate": "auto" }, 1.164 + _reusedCTMLists.discreteRAuto), 1.165 + new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210", 1.166 + "calcMode": "discrete", 1.167 + "rotate": "auto" }, 1.168 + _reusedCTMLists.discreteRAuto), 1.169 + ]), 1.170 + 1.171 + // Bundle to test relative units ('em') 1.172 + new TestcaseBundle(gMotionAttr, [ 1.173 + // First with unitless values from->by... 1.174 + new AnimMotionTestcase({ "from": "10, 10", 1.175 + "by": "30, 60" }, 1.176 + { ctm0: [10, 10, 0], 1.177 + ctm1_6: [15, 20, 0], 1.178 + ctm1_3: [20, 30, 0], 1.179 + ctm2_3: [30, 50, 0], 1.180 + ctm1: [40, 70, 0] 1.181 + }), 1.182 + // ... then add 'em' units (with 1em=10px) on half the values 1.183 + new AnimMotionTestcase({ "from": "1em, 10", 1.184 + "by": "30, 6em" }, 1.185 + { ctm0: [10, 10, 0], 1.186 + ctm1_6: [15, 20, 0], 1.187 + ctm1_3: [20, 30, 0], 1.188 + ctm2_3: [30, 50, 0], 1.189 + ctm1: [40, 70, 0] 1.190 + }), 1.191 + ]), 1.192 + 1.193 + // Bundle to test a path with just a "move" command and nothing else 1.194 + new TestcaseBundle(gMotionAttr, [ 1.195 + new AnimMotionTestcase({ "values": "40, 80" }, 1.196 + _reusedCTMLists.justMoveBasic), 1.197 + new AnimMotionTestcase({ "path": "M40 80" }, 1.198 + _reusedCTMLists.justMoveBasic), 1.199 + new AnimMotionTestcase({ "mpath": "m40 80" }, 1.200 + _reusedCTMLists.justMoveBasic), 1.201 + ]), 1.202 + // ... and now with a fixed rotate-angle 1.203 + new TestcaseBundle(gMotionAttr, [ 1.204 + new AnimMotionTestcase({ "values": "40, 80", 1.205 + "rotate": "60" }, 1.206 + _reusedCTMLists.justMoveR60), 1.207 + new AnimMotionTestcase({ "path": "M40 80", 1.208 + "rotate": "60" }, 1.209 + _reusedCTMLists.justMoveR60), 1.210 + new AnimMotionTestcase({ "mpath": "m40 80", 1.211 + "rotate": "60" }, 1.212 + _reusedCTMLists.justMoveR60), 1.213 + ]), 1.214 + // ... and now with 'auto' (should use the move itself as 1.215 + // our tangent angle, I think) 1.216 + new TestcaseBundle(gMotionAttr, [ 1.217 + new AnimMotionTestcase({ "values": "40, 80", 1.218 + "rotate": "auto" }, 1.219 + _reusedCTMLists.justMoveRAuto), 1.220 + new AnimMotionTestcase({ "path": "M40 80", 1.221 + "rotate": "auto" }, 1.222 + _reusedCTMLists.justMoveRAuto), 1.223 + new AnimMotionTestcase({ "mpath": "m40 80", 1.224 + "rotate": "auto" }, 1.225 + _reusedCTMLists.justMoveRAuto), 1.226 + ]), 1.227 + // ... and now with 'auto-reverse' 1.228 + new TestcaseBundle(gMotionAttr, [ 1.229 + new AnimMotionTestcase({ "values": "40, 80", 1.230 + "rotate": "auto-reverse" }, 1.231 + _reusedCTMLists.justMoveRAutoReverse), 1.232 + new AnimMotionTestcase({ "path": "M40 80", 1.233 + "rotate": "auto-reverse" }, 1.234 + _reusedCTMLists.justMoveRAutoReverse), 1.235 + new AnimMotionTestcase({ "mpath": "m40 80", 1.236 + "rotate": "auto-reverse" }, 1.237 + _reusedCTMLists.justMoveRAutoReverse), 1.238 + ]), 1.239 + // ... and now with a null move to make sure 'auto'/'auto-reverse' don't 1.240 + // blow up 1.241 + new TestcaseBundle(gMotionAttr, [ 1.242 + new AnimMotionTestcase({ "values": "0, 0", 1.243 + "rotate": "auto" }, 1.244 + _reusedCTMLists.nullMoveBasic), 1.245 + ]), 1.246 + new TestcaseBundle(gMotionAttr, [ 1.247 + new AnimMotionTestcase({ "values": "0, 0", 1.248 + "rotate": "auto-reverse" }, 1.249 + _reusedCTMLists.nullMoveRAutoReverse), 1.250 + ]), 1.251 +]; 1.252 + 1.253 +// XXXdholbert Add more tests: 1.254 +// - keyPoints/keyTimes 1.255 +// - paths with curves 1.256 +// - Control path with from/by/to