summaryrefslogtreecommitdiffstats
path: root/dom/smil/test/db_smilAnimateMotion.js
blob: c4dfb4e24e1a0d878576567bf7fdd306c1c4d116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* testcase data for <animateMotion> */

// Fake motion 'attribute', to satisfy testing code that expects an attribute.
var gMotionAttr = new AdditiveAttribute(SMILUtil.getMotionFakeAttributeName(),
                                        "XML", "rect");

// CTM-summary-definitions, for re-use by multiple testcase bundles below.
var _reusedCTMLists = {
  pacedBasic:     { ctm0:   [100, 200, 0],
                    ctm1_6: [105, 205, 0],
                    ctm1_3: [110, 210, 0],
                    ctm2_3: [120, 220, 0],
                    ctm1:   [130, 210, 0]
  },
  pacedR60:       { ctm0:   [100, 200, Math.PI/3],
                    ctm1_6: [105, 205, Math.PI/3],
                    ctm1_3: [110, 210, Math.PI/3],
                    ctm2_3: [120, 220, Math.PI/3],
                    ctm1:   [130, 210, Math.PI/3]
  },
  pacedRAuto:     { ctm0:   [100, 200, Math.PI/4],
                    ctm1_6: [105, 205, Math.PI/4],
                    ctm1_3: [110, 210, Math.PI/4],
                    ctm2_3: [120, 220, -Math.PI/4],
                    ctm1:   [130, 210, -Math.PI/4]
  },
  pacedRAutoReverse : { ctm0:   [100, 200, 5*Math.PI/4],
                        ctm1_6: [105, 205, 5*Math.PI/4],
                        ctm1_3: [110, 210, 5*Math.PI/4],
                        ctm2_3: [120, 220, 3*Math.PI/4],
                        ctm1:   [130, 210, 3*Math.PI/4]
  },
  
  discreteBasic : { ctm0:   [100, 200, 0],
                    ctm1_6: [100, 200, 0],
                    ctm1_3: [120, 220, 0],
                    ctm2_3: [130, 210, 0],
                    ctm1:   [130, 210, 0]
  },
  discreteRAuto : { ctm0:   [100, 200, Math.PI/4],
                    ctm1_6: [100, 200, Math.PI/4],
                    ctm1_3: [120, 220, -Math.PI/4],
                    ctm2_3: [130, 210, -Math.PI/4],
                    ctm1:   [130, 210, -Math.PI/4]
  },
  justMoveBasic : { ctm0:   [40, 80, 0],
                    ctm1_6: [40, 80, 0],
                    ctm1_3: [40, 80, 0],
                    ctm2_3: [40, 80, 0],
                    ctm1:   [40, 80, 0]
  },
  justMoveR60 :   { ctm0:   [40, 80, Math.PI/3],
                    ctm1_6: [40, 80, Math.PI/3],
                    ctm1_3: [40, 80, Math.PI/3],
                    ctm2_3: [40, 80, Math.PI/3],
                    ctm1:   [40, 80, Math.PI/3]
  },
  justMoveRAuto : { ctm0:   [40, 80, Math.atan(2)],
                    ctm1_6: [40, 80, Math.atan(2)],
                    ctm1_3: [40, 80, Math.atan(2)],
                    ctm2_3: [40, 80, Math.atan(2)],
                    ctm1:   [40, 80, Math.atan(2)]
  },
  justMoveRAutoReverse : { ctm0:   [40, 80, Math.PI + Math.atan(2)],
                           ctm1_6: [40, 80, Math.PI + Math.atan(2)],
                           ctm1_3: [40, 80, Math.PI + Math.atan(2)],
                           ctm2_3: [40, 80, Math.PI + Math.atan(2)],
                           ctm1:   [40, 80, Math.PI + Math.atan(2)]
  },
  nullMoveBasic : { ctm0:   [0, 0, 0],
                    ctm1_6: [0, 0, 0],
                    ctm1_3: [0, 0, 0],
                    ctm2_3: [0, 0, 0],
                    ctm1:   [0, 0, 0]
  },
  nullMoveRAutoReverse : { ctm0:   [0, 0, Math.PI],
                           ctm1_6: [0, 0, Math.PI],
                           ctm1_3: [0, 0, Math.PI],
                           ctm2_3: [0, 0, Math.PI],
                           ctm1:   [0, 0, Math.PI]
  },
};

var gMotionBundles =
[
  // Bundle to test basic functionality (using default calcMode='paced')
  new TestcaseBundle(gMotionAttr, [
    // Basic paced-mode (default) test, with values/mpath/path
    new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210" },
                           _reusedCTMLists.pacedBasic),
    new AnimMotionTestcase({ "path":  "M100 200 L120 220 L130 210" },
                           _reusedCTMLists.pacedBasic),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210" },
                           _reusedCTMLists.pacedBasic),

    // ..and now with rotate=constant value in degrees
    new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
                             "rotate": "60" },
                           _reusedCTMLists.pacedR60),
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "rotate": "60" },
                           _reusedCTMLists.pacedR60),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
                             "rotate": "60" },
                           _reusedCTMLists.pacedR60),

    // ..and now with rotate=constant value in radians
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "rotate": "1.0471975512rad" }, // pi/3
                           _reusedCTMLists.pacedR60),

    // ..and now with rotate=auto
    new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
                             "rotate": "auto" },
                           _reusedCTMLists.pacedRAuto),
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "rotate": "auto" },
                           _reusedCTMLists.pacedRAuto),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
                             "rotate": "auto" },
                           _reusedCTMLists.pacedRAuto),

    // ..and now with rotate=auto-reverse
    new AnimMotionTestcase({ "values": "100,200; 120,220; 130, 210",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.pacedRAutoReverse),
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.pacedRAutoReverse),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.pacedRAutoReverse),

  ]),

  // Bundle to test calcMode='discrete'
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210",
                             "calcMode": "discrete" },
                           _reusedCTMLists.discreteBasic),
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "calcMode": "discrete" },
                           _reusedCTMLists.discreteBasic),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
                             "calcMode": "discrete" },
                           _reusedCTMLists.discreteBasic),
    // ..and now with rotate=auto
    new AnimMotionTestcase({ "values": "100, 200; 120, 220; 130, 210",
                             "calcMode": "discrete",
                             "rotate": "auto" },
                           _reusedCTMLists.discreteRAuto),
    new AnimMotionTestcase({ "path": "M100 200 L120 220 L130 210",
                             "calcMode": "discrete",
                             "rotate": "auto" },
                           _reusedCTMLists.discreteRAuto),
    new AnimMotionTestcase({ "mpath": "M100 200 L120 220 L130 210",
                             "calcMode": "discrete",
                             "rotate": "auto" },
                           _reusedCTMLists.discreteRAuto),
  ]),

  // Bundle to test relative units ('em')
  new TestcaseBundle(gMotionAttr, [
    // First with unitless values from->by...
    new AnimMotionTestcase({ "from": "10, 10",
                             "by":   "30, 60" },
                           { ctm0:   [10, 10, 0],
                             ctm1_6: [15, 20, 0],
                             ctm1_3: [20, 30, 0],
                             ctm2_3: [30, 50, 0],
                             ctm1:   [40, 70, 0]
                           }),
    // ... then add 'em' units (with 1em=10px) on half the values
    new AnimMotionTestcase({ "from": "1em, 10",
                             "by":   "30, 6em" },
                           { ctm0:   [10, 10, 0],
                             ctm1_6: [15, 20, 0],
                             ctm1_3: [20, 30, 0],
                             ctm2_3: [30, 50, 0],
                             ctm1:   [40, 70, 0]
                           }),
  ]),

  // Bundle to test a path with just a "move" command and nothing else
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "40, 80" },
                           _reusedCTMLists.justMoveBasic),
    new AnimMotionTestcase({ "path":  "M40 80" },
                           _reusedCTMLists.justMoveBasic),
    new AnimMotionTestcase({ "mpath": "m40 80" },
                           _reusedCTMLists.justMoveBasic),
  ]),
  // ... and now with a fixed rotate-angle
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "40, 80",
                             "rotate": "60" },
                           _reusedCTMLists.justMoveR60),
    new AnimMotionTestcase({ "path":  "M40 80",
                             "rotate": "60" },
                           _reusedCTMLists.justMoveR60),
    new AnimMotionTestcase({ "mpath": "m40 80",
                             "rotate": "60" },
                           _reusedCTMLists.justMoveR60),
  ]),
  // ... and now with 'auto' (should use the move itself as
  // our tangent angle, I think)
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "40, 80",
                             "rotate": "auto" },
                           _reusedCTMLists.justMoveRAuto),
    new AnimMotionTestcase({ "path":  "M40 80",
                             "rotate": "auto" },
                           _reusedCTMLists.justMoveRAuto),
    new AnimMotionTestcase({ "mpath": "m40 80",
                             "rotate": "auto" },
                           _reusedCTMLists.justMoveRAuto),
  ]),
  // ... and now with 'auto-reverse'
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "40, 80",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.justMoveRAutoReverse),
    new AnimMotionTestcase({ "path":  "M40 80",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.justMoveRAutoReverse),
    new AnimMotionTestcase({ "mpath": "m40 80",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.justMoveRAutoReverse),
  ]),
  // ... and now with a null move to make sure 'auto'/'auto-reverse' don't
  // blow up
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "0, 0",
                             "rotate": "auto" },
                           _reusedCTMLists.nullMoveBasic),
  ]),
  new TestcaseBundle(gMotionAttr, [
    new AnimMotionTestcase({ "values": "0, 0",
                             "rotate": "auto-reverse" },
                           _reusedCTMLists.nullMoveRAutoReverse),
  ]),
];

// XXXdholbert Add more tests:
//  - keyPoints/keyTimes
//  - paths with curves
//  - Control path with from/by/to