db_smilAnimateMotion.js (8991B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* vim: set ts=2 sw=2 sts=2 et: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* testcase data for <animateMotion> */ 8 9 // Fake motion 'attribute', to satisfy testing code that expects an attribute. 10 var gMotionAttr = new AdditiveAttribute( 11 SMILUtil.getMotionFakeAttributeName(), 12 "XML", 13 "rect" 14 ); 15 16 // CTM-summary-definitions, for re-use by multiple testcase bundles below. 17 var _reusedCTMLists = { 18 pacedBasic: { 19 ctm0: [100, 200, 0], 20 ctm1_6: [105, 205, 0], 21 ctm1_3: [110, 210, 0], 22 ctm2_3: [120, 220, 0], 23 ctm1: [130, 210, 0], 24 }, 25 pacedR60: { 26 ctm0: [100, 200, Math.PI / 3], 27 ctm1_6: [105, 205, Math.PI / 3], 28 ctm1_3: [110, 210, Math.PI / 3], 29 ctm2_3: [120, 220, Math.PI / 3], 30 ctm1: [130, 210, Math.PI / 3], 31 }, 32 pacedRAuto: { 33 ctm0: [100, 200, Math.PI / 4], 34 ctm1_6: [105, 205, Math.PI / 4], 35 ctm1_3: [110, 210, Math.PI / 4], 36 ctm2_3: [120, 220, -Math.PI / 4], 37 ctm1: [130, 210, -Math.PI / 4], 38 }, 39 pacedRAutoReverse: { 40 ctm0: [100, 200, (5 * Math.PI) / 4], 41 ctm1_6: [105, 205, (5 * Math.PI) / 4], 42 ctm1_3: [110, 210, (5 * Math.PI) / 4], 43 ctm2_3: [120, 220, (3 * Math.PI) / 4], 44 ctm1: [130, 210, (3 * Math.PI) / 4], 45 }, 46 47 discreteBasic: { 48 ctm0: [100, 200, 0], 49 ctm1_6: [100, 200, 0], 50 ctm1_3: [120, 220, 0], 51 ctm2_3: [130, 210, 0], 52 ctm1: [130, 210, 0], 53 }, 54 discreteRAuto: { 55 ctm0: [100, 200, Math.PI / 4], 56 ctm1_6: [100, 200, Math.PI / 4], 57 ctm1_3: [120, 220, -Math.PI / 4], 58 ctm2_3: [130, 210, -Math.PI / 4], 59 ctm1: [130, 210, -Math.PI / 4], 60 }, 61 justMoveBasic: { 62 ctm0: [40, 80, 0], 63 ctm1_6: [40, 80, 0], 64 ctm1_3: [40, 80, 0], 65 ctm2_3: [40, 80, 0], 66 ctm1: [40, 80, 0], 67 }, 68 justMoveR60: { 69 ctm0: [40, 80, Math.PI / 3], 70 ctm1_6: [40, 80, Math.PI / 3], 71 ctm1_3: [40, 80, Math.PI / 3], 72 ctm2_3: [40, 80, Math.PI / 3], 73 ctm1: [40, 80, Math.PI / 3], 74 }, 75 justMoveRAuto: { 76 ctm0: [40, 80, Math.atan(2)], 77 ctm1_6: [40, 80, Math.atan(2)], 78 ctm1_3: [40, 80, Math.atan(2)], 79 ctm2_3: [40, 80, Math.atan(2)], 80 ctm1: [40, 80, Math.atan(2)], 81 }, 82 justMoveRAutoReverse: { 83 ctm0: [40, 80, Math.PI + Math.atan(2)], 84 ctm1_6: [40, 80, Math.PI + Math.atan(2)], 85 ctm1_3: [40, 80, Math.PI + Math.atan(2)], 86 ctm2_3: [40, 80, Math.PI + Math.atan(2)], 87 ctm1: [40, 80, Math.PI + Math.atan(2)], 88 }, 89 nullMoveBasic: { 90 ctm0: [0, 0, 0], 91 ctm1_6: [0, 0, 0], 92 ctm1_3: [0, 0, 0], 93 ctm2_3: [0, 0, 0], 94 ctm1: [0, 0, 0], 95 }, 96 nullMoveRAutoReverse: { 97 ctm0: [0, 0, Math.PI], 98 ctm1_6: [0, 0, Math.PI], 99 ctm1_3: [0, 0, Math.PI], 100 ctm2_3: [0, 0, Math.PI], 101 ctm1: [0, 0, Math.PI], 102 }, 103 }; 104 105 var gMotionBundles = [ 106 // Bundle to test basic functionality (using default calcMode='paced') 107 new TestcaseBundle(gMotionAttr, [ 108 // Basic paced-mode (default) test, with values/mpath/path 109 new AnimMotionTestcase( 110 { values: "100, 200; 120, 220; 130, 210" }, 111 _reusedCTMLists.pacedBasic 112 ), 113 new AnimMotionTestcase( 114 { path: "M100 200 L120 220 L130 210" }, 115 _reusedCTMLists.pacedBasic 116 ), 117 new AnimMotionTestcase( 118 { mpath: "M100 200 L120 220 L130 210" }, 119 _reusedCTMLists.pacedBasic 120 ), 121 122 // ..and now with rotate=constant value in degrees 123 new AnimMotionTestcase( 124 { values: "100,200; 120,220; 130, 210", rotate: "60" }, 125 _reusedCTMLists.pacedR60 126 ), 127 new AnimMotionTestcase( 128 { path: "M100 200 L120 220 L130 210", rotate: "60" }, 129 _reusedCTMLists.pacedR60 130 ), 131 new AnimMotionTestcase( 132 { mpath: "M100 200 L120 220 L130 210", rotate: "60" }, 133 _reusedCTMLists.pacedR60 134 ), 135 136 // ..and now with rotate=constant value in radians 137 new AnimMotionTestcase( 138 { path: "M100 200 L120 220 L130 210", rotate: "1.0471975512rad" }, // pi/3 139 _reusedCTMLists.pacedR60 140 ), 141 142 // ..and now with rotate=auto 143 new AnimMotionTestcase( 144 { values: "100,200; 120,220; 130, 210", rotate: "auto" }, 145 _reusedCTMLists.pacedRAuto 146 ), 147 new AnimMotionTestcase( 148 { path: "M100 200 L120 220 L130 210", rotate: "auto" }, 149 _reusedCTMLists.pacedRAuto 150 ), 151 new AnimMotionTestcase( 152 { mpath: "M100 200 L120 220 L130 210", rotate: "auto" }, 153 _reusedCTMLists.pacedRAuto 154 ), 155 156 // ..and now with rotate=auto-reverse 157 new AnimMotionTestcase( 158 { values: "100,200; 120,220; 130, 210", rotate: "auto-reverse" }, 159 _reusedCTMLists.pacedRAutoReverse 160 ), 161 new AnimMotionTestcase( 162 { path: "M100 200 L120 220 L130 210", rotate: "auto-reverse" }, 163 _reusedCTMLists.pacedRAutoReverse 164 ), 165 new AnimMotionTestcase( 166 { mpath: "M100 200 L120 220 L130 210", rotate: "auto-reverse" }, 167 _reusedCTMLists.pacedRAutoReverse 168 ), 169 ]), 170 171 // Bundle to test calcMode='discrete' 172 new TestcaseBundle(gMotionAttr, [ 173 new AnimMotionTestcase( 174 { values: "100, 200; 120, 220; 130, 210", calcMode: "discrete" }, 175 _reusedCTMLists.discreteBasic 176 ), 177 new AnimMotionTestcase( 178 { path: "M100 200 L120 220 L130 210", calcMode: "discrete" }, 179 _reusedCTMLists.discreteBasic 180 ), 181 new AnimMotionTestcase( 182 { mpath: "M100 200 L120 220 L130 210", calcMode: "discrete" }, 183 _reusedCTMLists.discreteBasic 184 ), 185 // ..and now with rotate=auto 186 new AnimMotionTestcase( 187 { 188 values: "100, 200; 120, 220; 130, 210", 189 calcMode: "discrete", 190 rotate: "auto", 191 }, 192 _reusedCTMLists.discreteRAuto 193 ), 194 new AnimMotionTestcase( 195 { 196 path: "M100 200 L120 220 L130 210", 197 calcMode: "discrete", 198 rotate: "auto", 199 }, 200 _reusedCTMLists.discreteRAuto 201 ), 202 new AnimMotionTestcase( 203 { 204 mpath: "M100 200 L120 220 L130 210", 205 calcMode: "discrete", 206 rotate: "auto", 207 }, 208 _reusedCTMLists.discreteRAuto 209 ), 210 ]), 211 212 // Bundle to test relative units ('em') 213 new TestcaseBundle(gMotionAttr, [ 214 // First with unitless values from->by... 215 new AnimMotionTestcase( 216 { from: "10, 10", by: "30, 60" }, 217 { 218 ctm0: [10, 10, 0], 219 ctm1_6: [15, 20, 0], 220 ctm1_3: [20, 30, 0], 221 ctm2_3: [30, 50, 0], 222 ctm1: [40, 70, 0], 223 } 224 ), 225 // ... then add 'em' units (with 1em=10px) on half the values 226 new AnimMotionTestcase( 227 { from: "1em, 10", by: "30, 6em" }, 228 { 229 ctm0: [10, 10, 0], 230 ctm1_6: [15, 20, 0], 231 ctm1_3: [20, 30, 0], 232 ctm2_3: [30, 50, 0], 233 ctm1: [40, 70, 0], 234 } 235 ), 236 ]), 237 238 // Bundle to test a path with just a "move" command and nothing else 239 new TestcaseBundle(gMotionAttr, [ 240 new AnimMotionTestcase({ values: "40, 80" }, _reusedCTMLists.justMoveBasic), 241 new AnimMotionTestcase({ path: "M40 80" }, _reusedCTMLists.justMoveBasic), 242 new AnimMotionTestcase({ mpath: "m40 80" }, _reusedCTMLists.justMoveBasic), 243 ]), 244 // ... and now with a fixed rotate-angle 245 new TestcaseBundle(gMotionAttr, [ 246 new AnimMotionTestcase( 247 { values: "40, 80", rotate: "60" }, 248 _reusedCTMLists.justMoveR60 249 ), 250 new AnimMotionTestcase( 251 { path: "M40 80", rotate: "60" }, 252 _reusedCTMLists.justMoveR60 253 ), 254 new AnimMotionTestcase( 255 { mpath: "m40 80", rotate: "60" }, 256 _reusedCTMLists.justMoveR60 257 ), 258 ]), 259 // ... and now with 'auto' (should use the move itself as 260 // our tangent angle, I think) 261 new TestcaseBundle(gMotionAttr, [ 262 new AnimMotionTestcase( 263 { values: "40, 80", rotate: "auto" }, 264 _reusedCTMLists.justMoveRAuto 265 ), 266 new AnimMotionTestcase( 267 { path: "M40 80", rotate: "auto" }, 268 _reusedCTMLists.justMoveRAuto 269 ), 270 new AnimMotionTestcase( 271 { mpath: "m40 80", rotate: "auto" }, 272 _reusedCTMLists.justMoveRAuto 273 ), 274 ]), 275 // ... and now with 'auto-reverse' 276 new TestcaseBundle(gMotionAttr, [ 277 new AnimMotionTestcase( 278 { values: "40, 80", rotate: "auto-reverse" }, 279 _reusedCTMLists.justMoveRAutoReverse 280 ), 281 new AnimMotionTestcase( 282 { path: "M40 80", rotate: "auto-reverse" }, 283 _reusedCTMLists.justMoveRAutoReverse 284 ), 285 new AnimMotionTestcase( 286 { mpath: "m40 80", rotate: "auto-reverse" }, 287 _reusedCTMLists.justMoveRAutoReverse 288 ), 289 ]), 290 // ... and now with a null move to make sure 'auto'/'auto-reverse' don't 291 // blow up 292 new TestcaseBundle(gMotionAttr, [ 293 new AnimMotionTestcase( 294 { values: "0, 0", rotate: "auto" }, 295 _reusedCTMLists.nullMoveBasic 296 ), 297 ]), 298 new TestcaseBundle(gMotionAttr, [ 299 new AnimMotionTestcase( 300 { values: "0, 0", rotate: "auto-reverse" }, 301 _reusedCTMLists.nullMoveRAutoReverse 302 ), 303 ]), 304 ]; 305 306 // XXXdholbert Add more tests: 307 // - keyPoints/keyTimes 308 // - paths with curves 309 // - Control path with from/by/to