1 /*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence
\r
2 *公式ページは http://sie.sourceforge.jp/
\r
4 /* ***** BEGIN LICENSE BLOCK *****
\r
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
7 * The contents of this file are subject to the Mozilla Public License Version
\r
8 * 1.1 (the "License"); you may not use this file except in compliance with
\r
9 * the License. You may obtain a copy of the License at
\r
10 * http://www.mozilla.org/MPL/
\r
12 * Software distributed under the License is distributed on an "AS IS" basis,
\r
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
14 * for the specific language governing rights and limitations under the
\r
17 * The Original Code is the Mozilla SVG Cairo Renderer project.
\r
19 * The Initial Developer of the Original Code is IBM Corporation.
\r
20 * Portions created by the Initial Developer are Copyright (C) 2004
\r
21 * the Initial Developer. All Rights Reserved.
\r
23 * Parts of this file contain code derived from the following files(s)
\r
24 * of the Mozilla SVG project (these parts are Copyright (C) by their
\r
25 * respective copyright-holders):
\r
26 * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
\r
28 * Contributor(s):DHRNAME revulo bellbind
\r
30 * Alternatively, the contents of this file may be used under the terms of
\r
31 * either of the GNU General Public License Version 2 or later (the "GPL"),
\r
32 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
\r
33 * in which case the provisions of the GPL or the LGPL are applicable instead
\r
34 * of those above. If you wish to allow use of your version of this file only
\r
35 * under the terms of either the GPL or the LGPL, and not to allow others to
\r
36 * use your version of this file under the terms of the MPL, indicate your
\r
37 * decision by deleting the provisions above and replace them with the notice
\r
38 * and other provisions required by the GPL or the LGPL. If you do not delete
\r
39 * the provisions above, a recipient may use your version of this file under
\r
40 * the terms of any one of the MPL, the GPL or the LGPL.
\r
42 * ***** END LICENSE BLOCK ***** */
\r
44 * Copyright (c) 2000 World Wide Web Consortium,
\r
45 * (Massachusetts Institute of Technology, Institut National de
\r
46 * Recherche en Informatique et en Automatique, Keio University). All
\r
47 * Rights Reserved. This program is distributed under the W3C's Software
\r
48 * Intellectual Property License. This program is distributed in the
\r
49 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
\r
50 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
52 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
\r
55 *Copyright (c) 2008-2010 Pivotal Labs
\r
57 Permission is hereby granted, free of charge, to any person obtaining
\r
58 a copy of this software and associated documentation files (the
\r
59 "Software"), to deal in the Software without restriction, including
\r
60 without limitation the rights to use, copy, modify, merge, publish,
\r
61 distribute, sublicense, and/or sell copies of the Software, and to
\r
62 permit persons to whom the Software is furnished to do so, subject to
\r
63 the following conditions:
\r
65 The above copyright notice and this permission notice shall be
\r
66 included in all copies or substantial portions of the Software.
\r
68 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
69 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
70 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
71 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
72 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
73 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
74 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
77 describe("SMIL Animation Spec", function() {
\r
78 describe("$frame object", function() {
\r
79 var frame = base("$frame");
\r
80 beforeEach( function() {
\r
81 frame.timelines = [];
\r
82 frame.isPaused = false;
\r
84 afterEach( function() {
\r
85 frame.timelines = [];
\r
87 /*境界条件を調べておく (limit value analysis)*/
\r
88 it("should be this for the value (limit value analysis)", function() {
\r
89 expect(typeof frame.setFrame).toBe("function");
\r
90 expect(frame.timelines.length).toBe(0);
\r
91 expect(frame.rank).toBe(0);
\r
92 expect(frame.startAnimation()).toBeUndefined();
\r
98 expect(frame.addLine()).toBe(false);
\r
99 expect(frame.addLine({})).toBe(false);
\r
100 expect(frame.addLine({
\r
103 expect(frame.addLine({
\r
107 expect(frame.removeLine()).toBeUndefined();
\r
108 expect(frame.removeLine({})).toBeUndefined();
\r
111 expect(frame.currentFrame).toBe(0);
\r
113 expect(frame.currentFrame).toBe(1);
\r
115 expect(frame.isPaused).toBeFalsy();
\r
116 expect(frame.pauseAnimation()).toBeUndefined();
\r
117 expect(frame.isPaused).toBeTruthy();
\r
119 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
120 it("should be this for the value (the valid partion)", function() {
\r
122 expect(frame.currentFrame).toBe(0);
\r
123 frame.startTime = Date.now();
\r
124 for (var i=0;i<100000;i++) {
\r
128 expect(frame.begin).toBe(0);
\r
129 expect(frame.activeTime).toBe(Number.MAX_VALUE);
\r
135 expect(frame.addLine( {
\r
139 expect(frame.addLine( {
\r
143 expect(frame.addLine( {
\r
147 expect(frame.addLine( {
\r
152 expect(frame.timelines.length).toBe(1);
\r
153 var timeline = frame.timelines[0];
\r
154 expect(timeline.begin).toBe(0);
\r
155 expect(timeline.activeTime).toBe(0);
\r
157 expect(frame.timelines[0]).toBe(timeline);
\r
158 frame.addLine({begin:1, activeTime:1});
\r
159 expect(frame.timelines[1]).not.toBe(timeline);
\r
160 frame.addLine(timeline);
\r
161 expect(frame.timelines[0]).not.toBe(timeline);
\r
162 expect(frame.timelines[1]).toBe(timeline);
\r
164 timeline = frame.timelines[0];
\r
165 frame.removeLine({});
\r
166 expect(frame.timelines[0]).toBe(timeline);
\r
167 frame.removeLine(timeline);
\r
168 expect(frame.timelines[0]).not.toBe(timeline);
\r
170 frame.addLine(frame.up().mix( {
\r
173 expect(frame.timelines).not.toBe(frame.$1.timelines);
\r
175 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
176 it("should be this for the value (the invalid partion)", function() {
\r
177 expect(frame.addLine(12)).toBeFalsy();
\r
178 /*循環参照にならず、スタック領域不足にならない*/
\r
179 frame.addLine(frame);
\r
184 describe("$begin object", function() {
\r
185 var begin = base("$frame").$begin.up();
\r
186 /*境界条件を調べておく (limit value analysis)*/
\r
187 it("should be this for the value (limit value analysis)", function() {
\r
188 expect(begin.string).toBe("");
\r
189 expect(begin.isResolved).toBeFalsy();
\r
190 expect(begin.eventTarget).toBe(document.documentElement);
\r
191 expect(typeof begin.listener).toBe("function");
\r
192 expect(begin.eventOffset).toBe(0);
\r
193 expect(begin.repeat).toBe(0);
\r
194 expect(begin.accessKey).toBe("");
\r
196 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
197 it("should be this for the value (the valid partion)", function() {
\r
198 begin.string = " hoge ";
\r
199 expect(begin.string).toBe(" hoge ");
\r
201 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
202 it("should be this for the value (the invalid partion)", function() {
\r
205 describe("A trim method in $begin object", function() {
\r
206 /*境界条件を調べておく (limit value analysis)*/
\r
207 beforeEach( function() {
\r
210 it("should be this for the value (limit value analysis)", function() {
\r
211 delete begin.string;
\r
212 expect(begin.trim(" ")).toBe("");
\r
213 expect( function() {
\r
217 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
218 it("should be this for the value (the valid partion)", function() {
\r
219 expect(begin.trim(" hoge ")).toBe("hoge");
\r
220 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
221 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
222 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
224 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
225 it("should be this for the value (the invalid partion)", function() {
\r
226 expect( function() {
\r
229 expect( function() {
\r
235 describe("An offset method in $begin object", function() {
\r
236 beforeEach( function() {
\r
239 /*境界条件を調べておく (limit value analysis)*/
\r
240 it("should be this for the value (limit value analysis)", function() {
\r
241 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
242 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
243 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
244 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
245 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
246 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
248 expect(begin.offset("+0s")).toBe(0);
\r
249 expect(begin.offset("-0s")).toBe(0);
\r
250 expect(begin.offset("1s")).toBe(1000);
\r
251 expect(begin.offset("-1s")).toBe(-1000);
\r
253 expect(begin.offset("+0min")).toBe(0);
\r
254 expect(begin.offset("-0min")).toBe(0);
\r
255 expect(begin.offset("1min")).toBe(60000);
\r
256 expect(begin.offset("-1min")).toBe(-60000);
\r
258 expect(begin.offset("+0h")).toBe(0);
\r
259 expect(begin.offset("-0h")).toBe(0);
\r
260 expect(begin.offset("1h")).toBe(60*60*1000);
\r
261 expect(begin.offset("-1h")).toBe(-3600000);
\r
263 expect(begin.offset("00:0")).toBe(0);
\r
264 expect(begin.offset("00:00:0.0")).toBe(0);
\r
265 expect(begin.offset("-00:0")).toBe(0);
\r
266 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
267 expect(begin.offset("00:1")).toBe(1000);
\r
268 expect(begin.offset("-00:1")).toBe(-1000);
\r
269 expect(begin.offset("00:00:1")).toBe(1000);
\r
270 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
272 expect(begin.offset()).toBe(0);
\r
274 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
275 it("should be this for the value (the valid partion)", function() {
\r
276 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
277 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
278 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
279 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
281 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
282 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
283 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
284 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
285 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
287 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
288 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
289 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
290 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
291 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
293 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
294 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
295 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
296 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
297 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
299 expect(begin.offset("01:0")).toBe(60000);
\r
300 expect(begin.offset("-01:0")).toBe(-60000);
\r
301 expect(begin.offset("00:00:1")).toBe(1000);
\r
302 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
303 expect(begin.offset("00:01:0")).toBe(60000);
\r
304 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
305 expect(begin.offset("01:00:0")).toBe(3600000);
\r
306 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
307 expect(begin.offset("00:10")).toBe(10000);
\r
308 expect(begin.offset("00:0.01")).toBe(10);
\r
309 expect(begin.offset("01:0.01")).toBe(60010);
\r
310 expect(begin.offset("10:0")).toBe(600000);
\r
311 expect(begin.offset("-00:10")).toBe(-10000);
\r
312 expect(begin.offset("-00:0.01")).toBe(-10);
\r
313 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
314 expect(begin.offset("-10:0")).toBe(-600000);
\r
315 expect(begin.offset("00:00:20")).toBe(20000);
\r
316 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
317 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
318 expect(begin.offset("-10:0")).toBe(-600000);
\r
319 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
321 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
322 it("should be this for the value (the invalid partion)", function() {
\r
323 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
324 expect(begin.offset("ms")).toBe(0);
\r
325 expect(begin.offset(".s")).toBe(0);
\r
326 expect(begin.offset("10:")).toBe(0);
\r
327 expect(begin.offset("::")).toBe(0);
\r
328 expect(begin.offset("-:0")).toBe(0);
\r
329 expect(begin.offset("-::0")).toBe(0);
\r
332 describe("An event method in $begin object", function() {
\r
333 /*境界条件を調べておく (limit value analysis)*/
\r
334 it("should be this for the value (limit value analysis)", function() {
\r
335 var evt = begin.event();
\r
336 expect(evt.id).toBe("");
\r
337 expect(evt.event).toBe("");
\r
338 evt = begin.event("");
\r
339 expect(evt.id).toBe("");
\r
340 expect(evt.event).toBe("");
\r
341 evt = begin.event(".");
\r
342 expect(evt.id).toBe("");
\r
343 expect(evt.event).toBe("");
\r
345 evt = begin.event("a");
\r
346 expect(evt.id).toBe("");
\r
347 expect(evt.event).toBe("a");
\r
348 evt = begin.event("a.b");
\r
349 expect(evt.id).toBe("a");
\r
350 expect(evt.event).toBe("b");
\r
352 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
353 it("should be this for the value (the valid partion)", function() {
\r
354 var evt = begin.event("id.event");
\r
355 expect(evt.id).toBe("id");
\r
356 expect(evt.event).toBe("event");
\r
357 evt = begin.event("event");
\r
358 expect(evt.id).toBe("");
\r
359 expect(evt.event).toBe("event");
\r
361 evt = begin.event("event+0s");
\r
362 expect(evt.id).toBe("");
\r
363 expect(evt.event).toBe("event");
\r
364 evt = begin.event("event-0s");
\r
365 expect(evt.id).toBe("");
\r
366 expect(evt.event).toBe("event");
\r
368 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
369 it("should be this for the value (the invalid partion)", function() {
\r
370 evt = begin.event("...");
\r
371 expect(evt.id).toBe("");
\r
372 expect(evt.event).toBe("");
\r
373 evt = begin.event(".event");
\r
374 expect(evt.id).toBe("");
\r
375 expect(evt.event).toBe("");
\r
376 evt = begin.event("id.");
\r
377 expect(evt.id).toBe("");
\r
378 expect(evt.event).toBe("");
\r
382 describe("An parse method in $begin object", function() {
\r
383 beforeEach( function() {
\r
386 /*境界条件を調べておく (limit value analysis)*/
\r
387 it("should be this for the value (limit value analysis)", function() {
\r
388 expect(begin.parse().begin).toBe(0);
\r
389 expect(begin.isResolved).toBeTruthy();
\r
391 expect(begin.parse().begin).toBe(0);
\r
392 begin.string = "+1";
\r
393 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
394 begin.string = " ";
\r
395 expect(begin.parse().begin).toBe(0);
\r
396 begin.string = "1";
\r
397 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
398 begin.string = "+0ms";
\r
399 expect(begin.parse().begin).toBe(0);
\r
400 begin.string = "-0ms";
\r
401 expect(begin.parse().begin).toBe(0);
\r
403 expect(begin.eventOffset).toBe(0);
\r
404 begin.string = "click";
\r
405 expect(begin.parse().begin).toBe(0);
\r
406 expect(begin.eventOffset).toBe(0);
\r
407 expect(begin.repeat).toBe(0);
\r
408 expect(begin.accessKey).toBe("");
\r
409 begin.string = "id.click";
\r
410 expect(begin.parse().begin).toBe(0);
\r
411 expect(begin.eventOffset).toBe(0);
\r
412 expect(begin.repeat).toBe(0);
\r
413 expect(begin.accessKey).toBe("");
\r
415 begin.string = "repeat";
\r
416 expect(begin.parse().begin).toBe(0);
\r
417 expect(begin.eventOffset).toBe(0);
\r
418 expect(begin.repeat).toBe(0);
\r
419 expect(begin.accessKey).toBe("");
\r
420 begin.string = "repeat(1)";
\r
421 expect(begin.parse().begin).toBe(0);
\r
422 expect(begin.eventOffset).toBe(0);
\r
423 expect(begin.repeat).toBe(1);
\r
424 expect(begin.accessKey).toBe("");
\r
426 begin.string = "accessKey(a)";
\r
427 expect(begin.parse().begin).toBe(0);
\r
428 expect(begin.eventOffset).toBe(0);
\r
429 expect(begin.repeat).toBe(0);
\r
430 expect(begin.accessKey).toBe("a");
\r
432 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
433 it("should be this for the value (the valid partion)", function() {
\r
434 begin.string = " 1 0 0 m s";
\r
435 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
437 begin.string = "1ms";
\r
438 begin.isResolved = false;
\r
439 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
440 expect(begin.isResolved).toBeTruthy();
\r
441 expect(begin.eventOffset).toBe(0);
\r
443 begin.string="click+0";
\r
444 expect(begin.parse().begin).toBe(0);
\r
445 expect(begin.eventOffset).toBe(0);
\r
446 expect(begin.isResolved).toBeFalsy();
\r
447 begin.string = "click+1";
\r
448 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
449 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
450 begin.string = " click ";
\r
451 expect(begin.parse().begin).toBe(0);
\r
452 expect(begin.eventOffset).toBe(0);
\r
453 begin.string = "click+0ms";
\r
454 expect(begin.parse().begin).toBe(0);
\r
455 expect(begin.eventOffset).toBe(0);
\r
456 expect(begin.isResolved).toBeFalsy();
\r
457 begin.string = "click-0ms";
\r
458 expect(begin.parse().begin).toBe(0);
\r
459 expect(begin.eventOffset).toBe(0);
\r
460 begin.string = "click+100ms";
\r
461 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
462 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
463 begin.string = "click-100ms";
\r
464 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
465 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
467 begin.string="id.click+0";
\r
468 expect(begin.parse().begin).toBe(0);
\r
469 expect(begin.eventOffset).toBe(0);
\r
470 expect(begin.isResolved).toBeFalsy();
\r
471 begin.string = "id.click+1";
\r
472 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
473 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
474 expect(begin.isResolved).toBeFalsy();
\r
475 begin.string = " id . click ";
\r
476 expect(begin.parse().begin).toBe(0);
\r
477 expect(begin.eventOffset).toBe(0);
\r
478 expect(begin.isResolved).toBeFalsy();
\r
479 begin.string = "id.click+0ms";
\r
480 expect(begin.parse().begin).toBe(0);
\r
481 expect(begin.eventOffset).toBe(0);
\r
482 begin.string = "id.click-0ms";
\r
483 expect(begin.parse().begin).toBe(0);
\r
484 expect(begin.eventOffset).toBe(0);
\r
485 begin.string = "id.click+100ms";
\r
486 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
487 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
488 begin.string = "id.click-100ms";
\r
489 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
490 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
492 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
493 it("should be this for the value (the invalid partion)", function() {
\r
494 begin.string = "ms";
\r
495 begin.isResolved = false;
\r
496 expect(begin.parse().begin).toBe(0);
\r
497 expect(begin.isResolved).toBeFalsy();
\r
499 begin.isResolved = true;
\r
500 begin.string = "indefinite";
\r
501 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
502 expect(begin.isResolved).toBeFalsy();
\r
506 describe("A listener method in $begin object", function() {
\r
507 var obj = begin.up();
\r
508 beforeEach( function() {
\r
511 begin.timelines.length = 0;
\r
512 obj.$activate = begin.$activate.up();
\r
513 obj.startTime = Date.now();
\r
516 /*境界条件を調べておく (limit value analysis)*/
\r
517 it("should be this for the value (limit value analysis)", function() {
\r
518 obj.isResolved = true;
\r
520 expect(obj.begin).toBe(0);
\r
523 timeStamp: Date.now()
\r
525 expect(obj.begin).toBe(0);
\r
526 expect(obj.activeTime).toBeGreaterThan(0);
\r
527 expect(obj.timelines.length).toBe(1);
\r
529 obj.isResolved = false;
\r
531 timeStamp: Date.now()
\r
533 expect(obj.begin).toBe(0);
\r
534 expect(obj.activeTime).toBeGreaterThan(0);
\r
535 expect(obj.timelines.length).toBe(1);
\r
537 obj.timelines.length = 0;
\r
542 $activate: begin.$activate.up().mix( {
\r
547 timeStamp: Date.now()
\r
549 expect(obj.$1.begin).toBe(1);
\r
550 expect(obj.$1.activeTime).toBe(Math.floor(12000*obj.fpms));
\r
551 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
552 expect(obj.timelines[0]).toBe(obj.$1);
\r
554 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
555 it("should be this for the value (the valid partion)", function() {
\r
559 $activate: begin.$activate.up().mix( {
\r
560 end: begin.$activate.end.up().mix( {
\r
566 timeStamp: Date.now()
\r
568 expect(obj.$1.begin).toBe(1);
\r
569 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
570 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
571 expect(obj.timelines[0]).toBe(obj.$1);
\r
576 $activate: begin.$activate.up().mix( {
\r
577 end: begin.$activate.end.up().mix( {
\r
583 timeStamp: Date.now()
\r
585 expect(obj.$1.begin).toBe(1);
\r
586 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
587 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
588 expect(obj.timelines[1]).toBe(obj.$1);
\r
590 timeStamp: (Date.now() + 500)
\r
592 expect(obj.$1.begin).toBe(1);
\r
593 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
594 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
595 expect(obj.timelines[1]).toBe(obj.$1);
\r
597 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
598 it("should be this for the value (the invalid partion)", function() {
\r
602 describe("A $end object", function() {
\r
603 var end = base("$frame").$begin.$end.up();
\r
605 beforeEach( function() {
\r
607 end.startTime = Date.now();
\r
610 /*境界条件を調べておく (limit value analysis)*/
\r
611 it("should be this for the value (limit value analysis)", function() {
\r
612 expect(end.up().call()).toBeNull();
\r
614 expect(end.up().call()).toBe(0);
\r
615 end.string = "hoge";
\r
616 expect(end.up().call()).toBe("indefinite");
\r
619 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
620 it("should be this for the value (the valid partion)", function() {
\r
621 end.string = "hoge+0";
\r
622 expect(end.up().call()).toBe("indefinite");
\r
623 end.string = "12ms";
\r
624 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
625 end.string = "hoge+12ms";
\r
626 expect(end.up().call()).toBe("indefinite");
\r
629 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
630 it("should be this for the value (the invalid partion)", function() {
\r
632 expect(end.up().call()).toBeNull();
\r
635 describe("A listener method in $end object", function() {
\r
637 begin = base("$frame").$begin;
\r
638 beforeEach( function() {
\r
641 end.timelines.length = 0;
\r
643 obj.$begin = begin.up().mix( {
\r
647 obj.$begin.$activate = begin.$activate.up();
\r
648 obj.addLine(obj.$begin);
\r
650 /*境界条件を調べておく (limit value analysis)*/
\r
651 it("should be this for the value (limit value analysis)", function() {
\r
652 expect(obj.timelines[0]).toBe(obj.$begin);
\r
653 expect(obj.timelines[0]).not.toBe(obj);
\r
655 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
657 obj.addLine(obj.$begin.mix( {
\r
662 timeStamp: (Date.now() + 12)
\r
664 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
666 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
667 it("should be this for the value (the valid partion)", function() {
\r
668 obj.$begin.$activate.begin = 0;
\r
673 timeStamp: (Date.now() + 120)
\r
675 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
676 expect(obj.begin).toBe(0);
\r
677 expect(obj.$begin.activeTime).toBe(0);
\r
679 obj.addLine(obj.$begin.mix( {
\r
683 obj.$begin.$activate.begin = 0;
\r
685 string: "event+1000ms"
\r
688 timeStamp: (Date.now() + 12)
\r
690 expect(obj.timelines[0]).toBe(obj.$begin);
\r
691 expect(obj.begin).toBe(Math.ceil(1000*obj.fpms));
\r
692 expect(obj.$begin.activeTime).toBe(Math.ceil(1000*obj.fpms));
\r
694 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
695 it("should be this for the value (the invalid partion)", function() {
\r
699 describe("A $activate object", function() {
\r
700 var act = base("$frame").$begin.$activate.up();
\r
701 beforeEach( function() {
\r
702 act.dur = "indefinite";
\r
704 act.repeatCount = null;
\r
705 act.repeatDur = null;
\r
706 act.end = act.$begin.$end;
\r
707 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
709 /*境界条件を調べておく (limit value analysis)*/
\r
710 it("should be this for the value (limit value analysis)", function() {
\r
711 expect(act.dur).toBe("indefinite");
\r
712 expect(typeof act.resolvedTime).toBe("function");
\r
713 expect(act.end).toBe(act.$begin.$end);
\r
714 expect(act.repeatCount).toBeNull();
\r
715 expect(act.repeatDur).toBeNull();
\r
716 expect(act.simpleDur()).toBeNull();
\r
717 expect(act.min).toBe("0");
\r
718 expect(act.max).toBe("indefinite");
\r
721 expect(act.$a.call()).toBeNull();
\r
722 expect(act.$a.end).toBeNull();
\r
724 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
725 it("should be this for the value (the valid partion)", function() {
\r
726 expect(act.resolvedTime()).toBe((+new Date()));
\r
728 /*Activate Duration = dur*/
\r
730 act.$b.dur = "132ms";
\r
731 var abc = act.$b.call();
\r
732 expect(abc).toBe(Math.floor(132*act.fpms));
\r
733 expect(abc).toBe(act.$b.simpleDur);
\r
735 expect(act.up().call()).toBeNull();
\r
737 /*AD = end -begin*/
\r
739 act.up("$eb").end = act.end.up().mix( {string: "120ms" } );
\r
740 expect( act.$eb.mix( {
\r
742 simpleDur: act.simpleDur,
\r
745 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
746 expect( act.$eb.mix( {
\r
748 repeatCount: "indefinite",
\r
750 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
751 expect( act.$eb.mix( {
\r
753 simpleDur: act.simpleDur,
755 repeatDur: "indefinite",
\r
756 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
758 expect( act.$eb.mix( {
\r
760 simpleDur: act.simpleDur,
761 repeatCount: "indefinite",
\r
762 repeatDur: "indefinite",
\r
763 } ).call() ).toBe(Math.floor(120*act.fpms)*3 - 1);
\r
765 /*AD = Min(dur, end - begin)*/
\r
766 act.up("$c").end = act.end.up().mix( { string: "12" } );
\r
769 simpleDur: act.simpleDur,
773 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
774 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
777 simpleDur: act.simpleDur,
781 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
782 expect(act.$c.simpleDur).toBe(Math.floor(15000*act.fpms));
\r
784 /*AD = Min(repeatCount*dur, end - begin)*/
\r
785 expect(act.$c.end).toBe(Math.floor(12000*act.fpms));
\r
788 simpleDur: act.simpleDur,
792 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
793 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
796 simpleDur: act.simpleDur,
800 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
801 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
803 /*AD = Min(repeatDur, end - begin)*/
\r
806 simpleDur: act.simpleDur,
810 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
811 expect(act.$c.simpleDur).toBeNull();
\r
814 simpleDur: act.simpleDur,
818 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
819 expect(act.$c.simpleDur).toBeNull();
\r
822 simpleDur: act.simpleDur,
826 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
827 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
830 simpleDur: act.simpleDur,
834 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
835 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
837 /*AD = Min(repeatCount*d, repeatDur, end - begin)*/
\r
840 simpleDur: act.simpleDur,
844 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
845 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
848 simpleDur: act.simpleDur,
852 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
853 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
856 simpleDur: act.simpleDur,
860 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
861 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
863 /*AD = repeatDur,*/
\r
867 simpleDur: act.simpleDur,
871 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
872 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
875 simpleDur: act.simpleDur,
879 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
880 expect(act.$c.simpleDur).toBeNull();
\r
882 act.end.string = null;
\r
883 act.up("$cd").mix( {
\r
888 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
890 act.$cd.end = act.end;
\r
891 act.$cd.repeatCount = null;
\r
892 act.$cd.repeatDur = "12";
\r
893 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
895 act.up("$d").mix( {
\r
899 simpleDur: act.simpleDur
\r
901 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
902 act.up("$d").mix( {
\r
906 simpleDur: act.simpleDur
\r
908 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
910 /*endで0が指定されている場合*/
\r
913 act.repeatDur = null;
\r
914 act.repeatCount = "indefinite";
\r
916 expect(act.call()).toBe(0);
\r
917 act.repeatCount = null;
\r
918 act.repeatDur = "indefinite";
\r
920 expect(act.call()).toBe(0);
\r
921 act.repeatDur = "indefinite";
\r
922 act.repeatCount = "indefinite";
\r
924 expect(act.call()).toBe(0);
\r
926 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
927 it("should be this for the value (the invalid partion)", function() {
\r
929 act.up("$d").mix( {
\r
933 simpleDur: act.simpleDur
\r
935 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
937 act.repeatDur = null;
\r
938 act.repeatCount = "indefinite";
\r
940 expect(act.call()).toBeNull();
\r
941 act.repeatCount = null;
\r
942 act.repeatDur = "indefinite";
\r
944 expect(act.call()).toBeNull();
\r
945 act.repeatDur = "indefinite";
\r
946 act.repeatCount = "indefinite";
\r
948 expect(act.call()).toBeNull();
\r
951 describe("A $from object", function() {
\r
952 var from = base("$from");
\r
953 beforeEach( function() {
\r
954 from = base("$from").up();
\r
955 from.from = from.from.up();
\r
958 /*境界条件を調べておく (limit value analysis)*/
\r
959 it("should be this for the value (limit value analysis)", function() {
\r
960 expect(from.string).toBe("");
\r
961 expect(from.numList()).toEqual([]);
\r
962 expect(from.strList()).toBeNull();
\r
965 expect(from.numList()[0]).toBe(0);
\r
966 expect(from.strList()).toBeNull();
\r
968 from.string = " 0 ";
\r
969 expect(from.numList()[0]).toBe(0);
\r
970 expect(from.strList().join("")).toBe(" ");
\r
973 expect(from.numList()).toEqual([]);
\r
974 expect(from.strList()[0]).toBe("a");
\r
976 from.string = null;
\r
977 expect( function() {
\r
980 expect( function() {
\r
984 expect(from.additive[0]).toBe(0);
\r
985 expect(from.accumulate[0]).toBe(0);
\r
987 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
988 it("should be this for the value (the valid partion)", function() {
\r
989 from.string = "0a";
\r
990 expect(from.numList()[0]).toBe(0);
\r
991 expect(from.strList()[0]).toBe("a");
\r
993 from.string = "a0";
\r
994 expect(from.numList()[0]).toBe(0);
\r
995 expect(from.strList()[0]).toBe("a");
\r
997 from.string = "0.1";
\r
998 expect(from.numList()[0]).toBe(0.1);
\r
999 expect(from.strList()).toBeNull();
\r
1001 from.string = "+0.1";
\r
1002 expect(from.numList()[0]).toBe(0.1);
\r
1003 expect(from.strList()).toBeNull();
\r
1005 from.string = "-0.1";
\r
1006 expect(from.numList()[0]).toBe(-0.1);
\r
1007 expect(from.strList()).toBeNull();
\r
1009 from.string = "1e-1";
\r
1010 expect(from.numList()[0]).toBe(1e-1);
\r
1011 expect(from.strList()).toBeNull();
\r
1013 from.string = "1E-1";
\r
1014 expect(from.numList()[0]).toBe(1E-1);
\r
1015 expect(from.strList()).toBeNull();
\r
1017 from.string = "0,0";
\r
1018 expect(from.numList().toString()).toBe("0,0");
\r
1019 expect(from.strList().join("")).toBe(",");
\r
1021 from.string = "a00a";
\r
1022 expect(from.numList()[0]).toBe(0);
\r
1023 expect(from.strList().join("")).toBe("aa");
\r
1025 from.string = "a0b0a";
\r
1026 expect(from.numList().toString()).toBe("0,0");
\r
1027 expect(from.strList().join("")).toBe("aba");
\r
1029 from.string = "0b0a";
\r
1030 expect(from.numList().toString()).toBe("0,0");
\r
1031 expect(from.strList().join("")).toBe("ba");
\r
1033 from.string = "0b-1.0a";
\r
1034 expect(from.numList()[1]).toBe(-1);
\r
1035 expect(from.strList().join("")).toBe("ba");
\r
1037 expect(from.up().call()).toBe(from.$1.numList);
\r
1038 expect(from.$1.numList[1]).toBe(-1);
\r
1039 expect(from.$1.strList.join("")).toBe("ba");
\r
1041 from.string = "あ 0b-1.0a12";
\r
1042 expect(from.numList()[1]).toBe(-1);
\r
1043 expect(from.strList().join("")).toBe("あ ba12");
\r
1045 from.string = "0b-1.0a0";
\r
1046 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1047 expect(from.strList().join("")).toBe("ba");
\r
1049 from.string = "0b .1a";
\r
1050 expect(from.numList()[1]).toBe(0.1);
\r
1051 expect(from.strList().join("")).toBe("b a");
\r
1053 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1054 it("should be this for the value (the invalid partion)", function() {
\r
1055 from.string = NaN;
\r
1056 expect(function(){
\r
1059 expect(function(){
\r
1063 from.string = "currentColor";
\r
1064 expect(from.numList()).toEqual([]);
\r
1065 expect(from.strList()[0]).toBe("currentColor");
\r
1067 from.string = "eE";
\r
1068 expect(from.numList()).toEqual([]);
\r
1069 expect(from.strList()[0]).toBe("eE");
\r
1070 expect(from.strList()[0]).toBe("eE");
\r
1073 describe("A $to object", function() {
\r
1074 var from = base("$from");
\r
1075 beforeEach( function() {
\r
1076 from = base("$from").up();
\r
1080 /*境界条件を調べておく (limit value analysis)*/
\r
1081 it("should be this for the value (limit value analysis)", function() {
\r
1082 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1083 expect(from.up().call()).toBe(from.$1.numList);
\r
1084 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1086 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1087 it("should be this for the value (the valid partion)", function() {
\r
1089 from.$to.from = from;
\r
1090 from.$to.string = "12cm-7";
\r
1091 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1092 expect(from.$to.strList().toString()).toBe("cm");
\r
1094 from.string = "7cm+8";
\r
1096 expect(from.call()).toBe(from.numList);
\r
1097 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1098 expect(from.$to.strList.join("")).toBe("cm");
\r
1099 expect(from.numList.join(",")).toBe("7,8");
\r
1100 expect(from.strList.join("")).toBe("cm");
\r
1101 expect(from.$to.from).toBe(from.numList);
\r
1104 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1105 it("should be this for the value (the invalid partion)", function() {
\r
1107 from.up("$to").mix( function() {
\r
1108 this.string = "12cm";
\r
1111 arr.string = this.string;
\r
1112 expect(this.numList).toEqual(arr);
\r
1113 expect(this.strList).toBeNull();
\r
1117 describe("An advance method", function() {
\r
1118 var from = base("$from");
\r
1119 beforeEach( function() {
\r
1120 from = base("$from").up();
\r
1123 from.$to.from = from;
\r
1125 /*境界条件を調べておく (limit value analysis)*/
\r
1126 it("should be this for the value (limit value analysis)", function() {
\r
1127 expect(from.advance()).toBe("");
\r
1128 expect(from.$to.advance()).toBe("");
\r
1129 expect(from.$to.advance(0)).toBe("");
\r
1130 expect(from.$to.advance(1)).toBe("");
\r
1131 expect(function(){
\r
1132 from.$to.advance(1.01);
\r
1133 }).toThrow("An Invalid Number Error");
\r
1134 expect(function(){
\r
1135 from.$to.advance(-0.01);
\r
1136 }).toThrow("An Invalid Number Error");
\r
1140 from = base("$from").up();
\r
1142 from.$to.from = from;
\r
1143 arr.string = from.string = "0";
\r
1144 from.$to.string = "1";
\r
1145 expect(from.$to.call()).toBe(from.$to.numList);
\r
1146 expect(from.$to.numList[0]).toBe(1);
\r
1147 expect(from.$to.strList).toBeNull();
\r
1148 expect(from.numList[0]).toBe(0);
\r
1149 expect(from.strList).toBeNull();
\r
1150 expect(from.advance(0)).toBe("");
\r
1151 expect(from.$to.from).toBe(from.numList);
\r
1152 expect(from.$to.advance(0)).toBe("0");
\r
1153 expect(from.call()).toBe(from.numList);
\r
1155 from = base("$from").up();
\r
1157 from.$to.from = from;
\r
1158 from.string = "inline";
\r
1159 arr.string = from.$to.string = "block";
\r
1160 expect(from.$to.call()).toBe(from.$to.numList);
\r
1161 expect(from.$to.numList).toEqual(arr);
\r
1162 expect(from.$to.strList).toEqual(["block"]);
\r
1163 arr.string = from.string;
\r
1164 expect(from.numList).toEqual(arr);
\r
1165 expect(from.strList).toEqual(["inline"]);
\r
1166 expect(from.advance(0)).toBe("");
\r
1167 expect(from.$to.from).toBe(from.numList);
\r
1168 expect(from.$to.advance(0)).toBe("inline");
\r
1169 expect(from.call()).toBe(from.numList);
\r
1171 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1172 it("should be this for the value (the valid partion)", function() {
\r
1175 from.string = "0s";
\r
1176 from.$to.string = "1s";
\r
1177 expect(from.$to.call()).toBe(from.$to.numList);
\r
1178 expect(from.$to.numList[0]).toBe(1);
\r
1179 expect(from.$to.strList[0]).toBe("");
\r
1180 expect(from.numList[0]).toBe(0);
\r
1181 expect(from.strList[0]).toBe("");
\r
1182 expect(from.advance(0)).toBe("");
\r
1183 expect(from.$to.from).toBe(from.numList);
\r
1184 expect(from.$to.advance(0)).toBe("0s");
\r
1185 from.$to.degit = deg;
\r
1186 for (var i=0;i<1;i+=0.01) {
\r
1187 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1189 expect(from.call()).toBe(from.numList);
\r
1191 from = base("$from").up();
\r
1193 from.string = "a0S";
\r
1194 from.$to.string = "a1S";
\r
1195 from.$to.from = from;
\r
1196 expect(from.$to.call()).toBe(from.$to.numList);
\r
1197 expect(from.$to.numList[0]).toBe(1);
\r
1198 expect(from.$to.strList[0]).toBe("a");
\r
1199 expect(from.numList[0]).toBe(0);
\r
1200 expect(from.strList[0]).toBe("a");
\r
1201 expect(from.advance(0)).toBe("");
\r
1202 expect(from.$to.from).toBe(from.numList);
\r
1203 expect(from.$to.advance(0)).toBe("a0S");
\r
1205 from.$to.degit = deg;
\r
1206 for (var i=0;i<1;i+=0.01) {
\r
1207 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1209 expect(from.call()).toBe(from.numList);
\r
1211 from = base("$from").up();
\r
1213 from.string = "a-10s1.5";
\r
1214 from.$to.string = "a10s-3";
\r
1215 from.$to.from = from;
\r
1217 from.$to.degit = 1;
\r
1218 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1219 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1220 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1222 from.$to.additive[0] = 1;
\r
1223 from.$to.accumulate[1] = 2;
\r
1224 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1225 from.$to.additive[0] = 0.5;
\r
1226 from.$to.accumulate[1] = 0.8;
\r
1227 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1229 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1230 it("should be this for the value (the invalid partion)", function() {
\r
1231 expect(function(){
\r
1232 from.$to.advance(10);
\r
1233 }).toThrow("An Invalid Number Error");
\r
1234 expect(function(){
\r
1235 from.$to.advance(-10);
\r
1236 }).toThrow("An Invalid Number Error");
\r
1240 describe("A distance method", function() {
\r
1241 var from = base("$from");
\r
1242 beforeEach( function() {
\r
1243 from = base("$from").up();
\r
1247 /*境界条件を調べておく (limit value analysis)*/
\r
1248 it("should be this for the value (limit value analysis)", function() {
\r
1249 expect(from.distance()).toBe(0)
\r
1250 expect(from.$to.distance()).toBe(0);
\r
1252 from.string = "0";
\r
1253 from.$to.string = "1";
\r
1254 expect(from.distance()).toBe(0);
\r
1255 expect(from.$to.distance(from)).toBe(1);
\r
1257 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1258 it("should be this for the value (the valid partion)", function() {
\r
1259 from.string = "s 0 s 12";
\r
1260 from.$to.string = "s 0 s 0";
\r
1261 expect(from.distance()).toBe(0);
\r
1262 expect(from.$to.distance(from)).toBe(12);
\r
1263 expect(from.$to.distance(from)).toBe(12);
\r
1264 expect(from.$to.distance(from.call())).toBe(12);
\r
1266 from = base("$from").up();
\r
1268 from.string = "rgb(1, 0, 0)";
\r
1269 from.$to.string = "rgb(0, 0, 1)";
\r
1270 expect(from.distance()).toBe(0);
\r
1271 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1273 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1274 it("should be this for the value (the invalid partion)", function() {
\r
1275 from.string = "s";
\r
1276 from.$to.string = "s";
\r
1277 expect(from.$to.distance(from)).toBe(0);
\r
1280 describe("A setAdditive method", function() {
\r
1281 var from = base("$from");
\r
1282 beforeEach( function() {
\r
1283 from = base("$from").up();
\r
1287 /*境界条件を調べておく (limit value analysis)*/
\r
1288 it("should be this for the value (limit value analysis)", function() {
\r
1289 expect(from.setAdditive()).toBe(0);
\r
1290 expect(from.setAdditive("")).toBe(0);
\r
1291 expect(from.additive).toEqual([0]);
\r
1294 expect(from.setAdditive("1")).toEqual(arr);
\r
1295 expect(from.additive).toEqual(arr);
\r
1297 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1298 it("should be this for the value (the valid partion)", function() {
\r
1299 var arr = [1, 2, 3];
\r
1300 arr.string = "1 2, 3";
\r
1301 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1302 expect(from.additive).toEqual(arr);
\r
1304 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1305 it("should be this for the value (the invalid partion)", function() {
\r
1308 describe("A setAccumulate method", function() {
\r
1309 var from = base("$from");
\r
1310 beforeEach( function() {
\r
1311 from = base("$from").up();
\r
1312 from.string = "0 1";
\r
1316 /*境界条件を調べておく (limit value analysis)*/
\r
1317 it("should be this for the value (limit value analysis)", function() {
\r
1318 expect(from.setAccumulate()).toBe(0);
\r
1319 expect(from.setAccumulate(0)).toBe(0);
\r
1320 expect(from.accumulate).toEqual([0, 0]);
\r
1321 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1322 expect(from.accumulate).toEqual([0, 1]);
\r
1324 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1325 it("should be this for the value (the valid partion)", function() {
\r
1326 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1327 expect(from.accumulate).toEqual([0, 2]);
\r
1329 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1330 it("should be this for the value (the invalid partion)", function() {
\r
1331 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1334 describe("A $calcMode object", function() {
\r
1335 var calc = base("$calcMode"),
\r
1338 beforeEach( function() {
\r
1339 calc = base("$calcMode").up();
\r
1340 calc.to = base("$from").up().mix( {string: "1"} );
\r
1341 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1343 /*境界条件を調べておく (limit value analysis)*/
\r
1344 it("should be this for the value (limit value analysis)", function() {
\r
1345 expect(calc.mode).toBe("linear");
\r
1346 expect(calc.keyTime).toBe(1);
\r
1347 expect(calc.keySplines).toBeNull();
\r
1348 expect(calc.string).toBe("");
\r
1350 expect(calc.call()(0)).toBe("0");
\r
1351 expect(calc.keyTime).toBe(1);
\r
1352 expect(calc.call()(1)).toBe("1");
\r
1355 expect(calc.call()(1)).toBe("0");
\r
1358 calc.mode = "paced";
\r
1359 expect(calc.norm).toBe(1);
\r
1360 calc.to.from = from;
\r
1361 expect(calc.call()(0)).toBe("0");
\r
1362 expect(calc.keyTime).toBe(1);
\r
1363 calc.to.from = from;
\r
1364 expect(calc.call()(1)).toBe("1");
\r
1367 calc.to.from = from;
\r
1368 expect(calc.call()(1)).toBe("1");
\r
1371 calc.mode = "discrete";
\r
1372 calc.to.from = from;
\r
1374 expect(calc.call()(0)).toBe("0");
\r
1375 expect(calc.call()(1)).toBe("1");
\r
1377 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1378 it("should be this for the value (the valid partion)", function() {
\r
1379 calc.mode = "linear";
\r
1380 calc.keyTime = 0.5;
\r
1381 calc.to.degit = 1;
\r
1382 expect(calc.call()(0.2)).toBe("0.4");
\r
1383 expect(calc.call()(0.3)).toBe("0.6");
\r
1385 expect(calc.call()(0.2)).toBe("0.4");
\r
1387 calc = base("$calcMode").up();
\r
1388 calc.keyTime = 0.2;
\r
1389 calc.to = base("$from").up();
\r
1390 calc.to.from = base("$from").up();
\r
1391 calc.to.from.string = "0s";
\r
1392 calc.to.string = "1s";
\r
1393 calc.to.degit = 1;
\r
1394 expect(calc.call()(0.1)).toBe("0.5s");
\r
1396 calc = base("$calcMode").up();
\r
1397 calc.keyTime = 0.5;
\r
1398 calc.to = base("$from").up();
\r
1399 calc.to.from = base("$from").up();
\r
1400 calc.to.from.string = "rgb(100, 20, 32)";
\r
1401 calc.to.string = "rgb(0, 10, 50)";
\r
1402 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1405 calc.to = base("$from").up();
\r
1406 calc.to.from = base("$from").up();
\r
1407 calc.mode = "paced";
\r
1409 calc.to.from.string = "0s";
\r
1410 calc.to.string = "20s";
\r
1411 calc.to.degit = 1;
\r
1412 expect(calc.call()(0.1)).toBe("10.0s");
\r
1413 expect(calc.keyTime).toBe(0.2);
\r
1415 calc.to = base("$from").up();
\r
1416 calc.to.from = base("$from").up();
\r
1417 calc.mode = "paced";
\r
1419 calc.to.from.string = "rgb(0, 0, 20)";
\r
1420 calc.to.string = "rgb(0, 0, 0)";
\r
1421 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1422 expect(calc.keyTime).toBe(0.2);
\r
1425 calc.to = base("$from").up();
\r
1426 calc.to.from = base("$from").up();
\r
1427 calc.mode = "discrete";
\r
1428 calc.keyTime = 0.5;
\r
1429 calc.to.degit = 1;
\r
1430 calc.to.string = "1";
\r
1431 calc.to.from.string = "0.5";
\r
1432 expect(calc.call()(0.2)).toBe("0.5");
\r
1433 expect(calc.call()(0.3)).toBe("0.5");
\r
1435 expect(calc.call()(0.2)).toBe("0.5");
\r
1437 calc.to = base("$from").up();
\r
1438 calc.to.from = base("$from").up();
\r
1439 calc.mode = "discrete";
\r
1440 calc.keyTime = 0.5;
\r
1441 calc.to.degit = 1;
\r
1442 calc.to.string = "block";
\r
1443 calc.to.from.string = "inline";
\r
1444 expect(calc.call()(0.2)).toBe("inline");
\r
1445 expect(calc.call()(0.3)).toBe("inline");
\r
1447 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1448 it("should be this for the value (the invalid partion)", function() {
\r
1449 calc.keyTime = null;
\r
1450 expect(calc.call()(1)).toBe(calc.string);
\r
1452 calc.keyTime = void 0;
\r
1453 expect(calc.call()(1)).toBe(calc.string);
\r
1455 calc.keyTime = 1/0;
\r
1456 expect(calc.call()(1)).toBe(calc.string);
\r
1458 expect(calc.call()()).toBe(calc.string);
\r
1460 calc = base("$calcMode").up();
\r
1461 calc.mode = "paced";
\r
1462 calc.to.from = from;
\r
1463 expect(calc.call()()).toBe(calc.string);
\r
1465 calc = base("$calcMode").up();
\r
1466 calc.mode = "discrete";
\r
1467 expect(calc.call()()).toBe(calc.string);
\r
1470 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1471 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1472 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1475 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1476 return function (t) {
\r
1477 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1478 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1482 expect(calc.keySplines).toBeNull();
\r
1483 calc.mode = "spline";
\r
1484 expect( calc.call()("undef")).toBe(Math.PI);
\r
1485 calc.keySplines = [0, 0, 1, 1];
\r
1486 calc.to.degit = 1;
\r
1487 calc.to.from = from;
\r
1488 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1489 calc.to.from = from;
\r
1490 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1491 calc.to.from = from;
\r
1492 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1494 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1495 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1496 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1497 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1498 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1499 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1500 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1501 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1502 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1504 var a = y4-3*(y3-y2)-y1,
\r
1505 b = 3*(y3-2*y2+y1),
\r
1507 d = y1 - bezier.apply(null, arguments)(t);
\r
1508 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1511 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1512 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1515 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1516 return function (t) {
\r
1518 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1519 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1523 calc.mode = "spline";
\r
1524 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1525 calc.to.degit = 1;
\r
1526 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1527 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1528 calc.to.from = from;
\r
1529 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1530 calc.to.from = from;
\r
1531 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1533 var ff = function(k) {
\r
1534 calc.keySplines = k;
\r
1535 calc.to.degit = 10;
\r
1536 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1537 epsilon = 1e-5; //誤差
\r
1538 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1539 calc.to.from = from;
\r
1540 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1541 calc.to.from = from;
\r
1542 b = b(Math.random());
\r
1543 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1545 for (var i=0;i<10000;++i) {
\r
1546 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1550 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1551 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1552 calc.mode = "spline";
\r
1553 calc.keySplines = [0, NaN, 1, 1];
\r
1554 calc.to.degit = 1;
\r
1555 calc.to.from = from;
\r
1556 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1559 calc.keySplines = [0, 0, 1, 2];
\r
1560 calc.to.degit = 1;
\r
1561 calc.to.from = from;
\r
1562 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1564 calc.keySplines = null;
\r
1565 calc.to.degit = 1;
\r
1566 calc.to.from = from;
\r
1567 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1570 describe("A $attribute object", function() {
\r
1571 describe("A push method", function() {
\r
1573 beforeEach( function() {
\r
1574 attr = base("$calcMode").$attribute.up("width");
\r
1575 base("$frame").timelines.length = 0;
\r
1576 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1578 /*境界条件を調べておく (limit value analysis)*/
\r
1579 it("should be this for the value (limit value analysis)", function() {
\r
1580 expect(attr.element).toBeNull();
\r
1581 expect(attr.push()).toBeNull();
\r
1582 expect(attr.element).toBeNull();
\r
1583 expect(attr.isCSS).toBeFalsy();
\r
1584 expect(base("$frame").timelines.length).toBe(0);
\r
1586 expect(attr.push(s)).toBeNull();
\r
1587 expect(attr.element).toBeNull();
\r
1588 expect(base("$frame").timelines.length).toBe(0);
\r
1589 expect(attr.hasAttrValues()).toBeFalsy();
\r
1591 var p = document.createElement("g");
\r
1593 expect(attr.push(s)).toBeNull();
\r
1594 expect(attr.element).toBe(p);
\r
1595 expect(base("$frame").timelines.length).toBe(0);
\r
1597 s.setAttribute("end", "0");
\r
1601 check("values", 4);
\r
1602 function check(attrName, num) {
\r
1603 s.setAttribute(attrName, "1");
\r
1604 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1605 var l = attr.push(s);
\r
1606 expect(attr.element).toBe(p);
\r
1607 var timelines = base("$frame").timelines;
\r
1608 expect(timelines.length).toBe(num);
\r
1609 var line = timelines[num-1];
\r
1610 expect(line.string).toBe("0");
\r
1611 expect(line).toBe(l); //タイムラインのオブジェクトを返す
\r
1612 var act = line.$activate;
\r
1613 expect(act.dur).toBeNull();
\r
1614 expect(act.end).toBe(0);
\r
1615 expect(act.repeatCount).toBeNull();
\r
1616 expect(act.repeatDur).toBeNull();
\r
1617 expect(act.min).toBe("0");
\r
1618 expect(act.max).toBe("indefinite");
\r
1619 expect(act.simpleDur).toBeNull();
\r
1620 expect(attr.hasAttrValues()).toBeTruthy();
\r
1622 s.removeAttribute(attrName);
\r
1623 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1625 expect(attr.element).toBe(p);
\r
1626 expect(timelines.length).toBe(num);
\r
1629 /*targetElement属性のサポート*/
\r
1630 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1631 document.documentElement.appendChild(p2);
\r
1632 p2.setAttributeNS(null, "id", "p23");
\r
1633 s.setAttributeNS(null, "targetElement", "p23");
\r
1635 expect(attr.element).toBe(p2);
\r
1638 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1639 document.documentElement.appendChild(p3);
\r
1640 p3.setAttributeNS(null, "id", "p34");
\r
1641 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1643 expect(attr.element).toBe(p3);
\r
1645 /*attributeType属性のサポート*/
\r
1646 s.setAttributeNS(null, "attributeType", "CSS");
\r
1647 s.setAttributeNS(null, "values", "a;b;c");
\r
1649 expect(attr.isCSS).toBeTruthy();
\r
1651 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1652 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1653 s.setAttribute("from", "1");
\r
1654 var p = document.createElement("g");
\r
1656 var values = [ "0",
\r
1657 "0", null, null, null,
\r
1658 "0", "indefinite", null
\r
1661 check2("dur", "0");
\r
1662 check2("begin", "0");
\r
1664 check2("begin", "1");
\r
1666 check2("end", "0");
\r
1668 check2("repeatCount", "0");
\r
1670 check2("repeatDur", "0");
\r
1672 check2("min", "0");
\r
1674 check2("max", "0");
\r
1676 check2("begin", "12");
\r
1677 values[7] = 1000 * base("$frame").fpms;
\r
1679 check2("dur", "1");
\r
1680 function check2(attrName, value) {
\r
1681 s.setAttribute(attrName, value);
\r
1682 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1684 expect(attr.element).toBe(p);
\r
1685 var timelines = base("$frame").timelines;
\r
1686 var line = timelines[timelines.length-1];
\r
1687 expect(line.string).toBe(values[0]);
\r
1688 var act = line.$activate;
\r
1689 expect(act.dur).toBe(values[1]);
\r
1690 expect(act.end).toBe(values[2]);
\r
1691 expect(act.repeatCount).toBe(values[3]);
\r
1692 expect(act.repeatDur).toBe(values[4]);
\r
1693 expect(act.min).toBe(values[5]);
\r
1694 expect(act.max).toBe(values[6]);
\r
1695 expect(act.simpleDur).toBe(values[7]);
\r
1699 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1700 document.documentElement.appendChild(p4);
\r
1701 p4.appendChild(s);
\r
1702 p4.setAttributeNS(null, "style", "display: none");
\r
1704 expect(attr.setAttribute()).toBeUndefined();
\r
1705 expect(attr.setAttribute("block")).toBeUndefined();
\r
1706 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1707 expect(attr.isCSS).toBeFalsy();
\r
1709 s.setAttributeNS(null, "attributeName", "display");
\r
1711 expect(attr.setAttribute("block")).toBeUndefined();
\r
1712 expect(p4.hasAttributeNS(null, "display")).toBeTruthy();
\r
1713 expect(attr.isCSS).toBeTruthy();
\r
1714 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1716 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1717 document.documentElement.appendChild(p4);
\r
1718 p4.appendChild(s);
\r
1719 p4.setAttributeNS(null, "style", "display: none");
\r
1721 expect(attr.setAttribute("block")).toBeUndefined();
\r
1722 expect(p4.hasAttributeNS(null, "display")).toBeTruthy();
\r
1723 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1724 expect(attr.removeAttribute()).toBeUndefined();
\r
1725 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1726 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1728 /*attributeType属性のサポート*/
\r
1729 s.setAttributeNS(null, "values", "a;b;c");
\r
1730 s.setAttributeNS(null, "attributeName", "display");
\r
1731 attr.isCSS = false;
\r
1733 expect(attr.isCSS).toBeTruthy();
\r
1735 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1736 it("should be this for the value (the invalid partion )", function() {
\r
1737 var p = document.createElement("g");
\r
1740 s.setAttributeNS(null, "begin", "1");
\r
1742 var timelines = base("$frame").timelines;
\r
1743 expect(timelines.length).toBe(0);
\r
1744 s.setAttributeNS(null, "from", "1");
\r
1746 expect(timelines.length).toBe(1);
\r
1747 expect(attr.push(12)).toBeNull();
\r
1750 describe("A setValues method", function() {
\r
1752 beforeEach( function() {
\r
1753 attr = base("$calcMode").$attribute.up("width");
\r
1754 base("$frame").timelines.length = 0;
\r
1755 s = document.createElement("animate");
\r
1757 /*境界条件を調べておく (limit value analysis)*/
\r
1758 it("should be this for the value (limit value analysis)", function() {
\r
1759 expect(attr.$from).not.toBeUndefined();
\r
1760 expect(attr.setValues()).toBeNull();
\r
1761 expect(attr.setValues("")).toBeNull();
\r
1763 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1764 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
1765 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
1766 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
1768 /*from-to アニメーション*/
\r
1769 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1770 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
1772 /*from-by アニメーション*/
\r
1773 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1774 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1775 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1777 /*fromなしto アニメーション*/
\r
1778 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1779 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
1780 var aset = attr.setValues(null, null, "1")[0].to;
\r
1782 expect(aset.from[0]).toBe(0);
\r
1784 /*fromなしby アニメーション*/
\r
1785 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1786 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1787 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1789 expect(aset.from[0]).toBe(0);
\r
1791 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1792 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1793 attr.$from.degit = 1;
\r
1794 var setv = attr.setValues("0;1")[0].call();
\r
1795 expect(setv(0.5)).toBe("0.5");
\r
1796 expect(setv(1)).toBe("1.0");
\r
1798 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1799 expect(setv(0.5)).toBe("0.5");
\r
1800 expect(setv(1)).toBe("1.0");
\r
1801 setv = attr.setValues("0;1;2")[1].call();
\r
1802 expect(setv(0.4)).toBe("1.4");
\r
1803 expect(setv(1)).toBe("2.0");
\r
1805 attr.$from.degit = 2;
\r
1806 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
1807 expect(setv(0.5)).toBe("8.05");
\r
1808 expect(setv(1)).toBe("15.10");
\r
1810 var v = attr.setValues("1;1;2;1;1;15.1");
\r
1811 setv = v[4].mix( {
\r
1814 expect(setv(0.05)).toBe("8.05");
\r
1815 expect(setv(0.1)).toBe("15.10");
\r
1816 setv = v[3].mix( {
\r
1819 expect(setv(0.01)).toBe("1.00");
\r
1820 expect(setv(0.1)).toBe("1.00");
\r
1821 setv = v[2].mix( {
\r
1824 expect(setv(0.25)).toBe("1.50");
\r
1825 expect(setv(0.5)).toBe("1.00");
\r
1827 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1828 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1829 attr.$from.degit = 1;
\r
1830 expect(attr.setValues("")).toBeNull();
\r
1831 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
1834 describe("A setKey method", function() {
\r
1836 beforeEach( function() {
\r
1837 attr = base("$calcMode").$attribute.up("width");
\r
1838 base("$frame").timelines.length = 0;
\r
1839 s = document.createElement("animate");
\r
1840 document.createElement("g").appendChild(s);
\r
1842 /*境界条件を調べておく (limit value analysis)*/
\r
1843 it("should be this for the value (limit value analysis)", function() {
\r
1844 expect(attr.setKey(s)).toBeNull();
\r
1846 s.setAttributeNS(null, "from", "0");
\r
1848 s.setAttributeNS(null, "to", "0");
\r
1849 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1850 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
1851 s.setAttributeNS(null, "by", "0");
\r
1853 s.setAttributeNS(null, "values", "0;2");
\r
1854 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1855 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
1857 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
1858 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1860 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
1861 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1862 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1863 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1864 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1866 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
1867 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1868 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1869 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1870 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1872 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1873 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1874 s.setAttributeNS(null, "values", "0;2;12;30");
\r
1875 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
1876 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1877 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1878 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1879 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1880 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
1881 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
1882 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1883 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1884 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1886 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
1887 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1888 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1889 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1891 s.setAttributeNS(null, "keySplines", " 0,0.1,0.3,1; 0.1,0.4,0.5,0.7; 0.2,0.2,0.1 , 1 ;");
\r
1892 f(0, 0,0.1,0.3,1);
\r
1893 f(1, 0.1,0.4,0.5,0.7);
\r
1894 f(2, 0.2,0.2,0.1,1);
\r
1896 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
1897 f(0, 0,0.1,0.3,1);
\r
1898 f(1, 0.1,0.4,0.5,0.7);
\r
1899 f(2, 0.2,0.2,0.1,1);
\r
1901 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
1902 f(0, 0,0.1,0.333,1);
\r
1903 f(1, 0.1,0.4,0.5,0.7);
\r
1904 f(2, 0.2,0.2,0.1,1);
\r
1905 function f (i, a, b, c, d) {
\r
1906 var splines = attr.setKey(s)[i].keySplines;
\r
1907 expect(splines[0]).toBe(a);
\r
1908 expect(splines[1]).toBe(b);
\r
1909 expect(splines[2]).toBe(c);
\r
1910 expect(splines[3]).toBe(d);
\r
1913 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1914 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1915 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1916 expect(attr.setKey(s)).toBeNull();
\r
1917 s.setAttributeNS(null, "values", "0;2;12");
\r
1918 expect(attr.setKey(s)).toBeNull();
\r
1919 s.setAttributeNS(null, "values", "0;2;12;20");
\r
1920 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
1921 expect(attr.setKey(s)).toBeNull();
\r
1925 describe("A $setElemenet object", function() {
\r
1926 describe("A timeline property", function() {
\r
1927 var $set, ele, frame;
\r
1928 beforeEach( function() {
\r
1929 $set = base("$calcMode").$attribute.$setElement.up();
\r
1930 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1931 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1932 p.appendChild(ele);
\r
1933 frame = base("$frame");
\r
1935 /*境界条件を調べておく (limit value analysis)*/
\r
1936 it("should be this for the value (limit value analysis)", function() {
\r
1937 expect($set.timeline).toBe(frame.$begin);
\r
1940 expect($set.timeline).toBe(frame.$begin);
\r
1941 expect($set.element).toBeNull();
\r
1944 describe("An init method", function() {
\r
1945 var $set, ele, frame;
\r
1946 beforeEach( function() {
\r
1947 $set = base("$calcMode").$attribute.$setElement.up();
\r
1948 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1949 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1950 p.appendChild(ele);
\r
1951 frame = base("$frame");
\r
1953 /*境界条件を調べておく (limit value analysis)*/
\r
1954 it("should be this for the value (limit value analysis)", function() {
\r
1955 expect($set.to).toBe("");
\r
1956 expect($set.attrName).toBe("");
\r
1957 expect($set.defaultValue).toBe("");
\r
1958 expect($set.isDefault).toBeFalsy();
\r
1959 expect($set.attrNameSpace).toBeNull();
\r
1961 expect($set.timeline).toBe(frame.$begin);
\r
1963 expect($set.to).toBe("");
\r
1964 expect($set.attrName).toBe("");
\r
1965 expect($set.isDefault).toBeFalsy();
\r
1966 expect($set.attrNameSpace).toBeNull();
\r
1967 expect($set.timeline).toBe(frame.$begin);
\r
1969 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1970 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1971 ele.setAttributeNS(null, "to", "t1");
\r
1973 expect($set.to).toBe("t1");
\r
1974 expect($set.attrName).toBe("");
\r
1975 expect($set.defaultValue).toBe("");
\r
1977 ele.setAttributeNS(null, "attributeName", "tt1");
\r
1979 expect($set.to).toBe("t1");
\r
1980 expect($set.attrName).toBe("tt1");
\r
1981 expect($set.defaultValue).toBe("");
\r
1983 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
1985 expect($set.defaultValue).toBe("undef");
\r
1986 expect($set.isDefault).toBeTruthy();
\r
1988 ele.setAttributeNS(null, "attributeName", "font-size");
\r
1989 ele.parentNode.style.setProperty("font-size", "12px");
\r
1991 expect($set.defaultValue).toBe("12px");
\r
1992 expect($set.isDefault).toBeFalsy();
\r
1994 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
1996 expect($set.to).toBe("t1");
\r
1997 expect($set.attrName).toBe("xlink:href");
\r
1998 expect($set.defaultValue).toBe("");
\r
1999 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2001 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2003 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2004 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2006 expect($set.to).toBe("");
\r
2007 expect($set.attrName).toBe("");
\r
2008 expect($set.defaultValue).toBe("");
\r
2011 expect($set.to).toBe("");
\r
2012 expect($set.attrName).toBe("");
\r
2013 expect($set.defaultValue).toBe("");
\r
2016 describe("Frame Set", function() {
\r
2017 var $set, ele, frame;
\r
2018 beforeEach( function() {
\r
2019 $set = base("$calcMode").$attribute.$setElement.up();
\r
2020 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2021 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2022 p.appendChild(ele);
\r
2023 frame = base("$frame");
\r
2024 frame.timelines.length = 0; //配列の初期化
\r
2025 frame.startTime = Date.now();
\r
2026 frame.setFrame(0);
\r
2028 /*境界条件を調べておく (limit value analysis)*/
\r
2029 it("should be this for the value (limit value analysis)", function() {
\r
2030 expect($set.isEnd).toBeFalsy();
\r
2031 expect($set.state).toBe("idling");
\r
2032 ele.setAttributeNS(null, "dur", "1s");
\r
2033 ele.setAttributeNS(null, "attributeName", "fill");
\r
2034 ele.setAttributeNS(null, "to", "red");
\r
2036 expect($set.timeline).not.toBe(frame.$begin);
\r
2037 frame.setFrame(0);
\r
2038 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2039 expect($set.state).toBe("playing");
\r
2041 frame.setFrame(24);
\r
2042 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2043 expect($set.state).toBe("idling");
\r
2045 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2046 it("should be this for the value (the valid partion)", function() {
\r
2047 ele.setAttributeNS(null, "begin", "1s");
\r
2048 ele.setAttributeNS(null, "dur", "1s");
\r
2049 ele.setAttributeNS(null, "attributeName", "fill");
\r
2050 ele.setAttributeNS(null, "to", "red");
\r
2052 var f = function(num) {
\r
2053 frame.setFrame(num);
\r
2054 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2059 frame.setFrame(24);
\r
2060 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2061 frame.setFrame(25);
\r
2062 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2066 ele.setAttributeNS(null, "fill", "freeze");
\r
2071 frame.setFrame(24);
\r
2072 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2073 frame.setFrame(25);
\r
2074 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2075 frame.setFrame(48);
\r
2076 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2077 frame.setFrame(49);
\r
2078 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2079 ele.setAttributeNS(null, "begin", "1s");
\r
2080 ele.setAttributeNS(null, "attributeName", "fill");
\r
2081 ele.setAttributeNS(null, "to", "red");
\r
2082 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2084 var f = function(num) {
\r
2085 frame.setFrame(num);
\r
2086 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2094 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2095 it("should be this for the value (the invalid partion)", function() {
\r
2100 describe("A $animateElement object", function() {
\r
2101 describe("An init method", function() {
\r
2102 var $animate, ele, frame;
\r
2103 beforeEach( function() {
\r
2104 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2105 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2106 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2107 p.appendChild(ele);
\r
2108 frame = base("$frame");
\r
2109 frame.timelines.length = 0;
\r
2110 frame.startTime = Date.now();
\r
2111 frame.setFrame(0);
\r
2113 /*境界条件を調べておく (limit value analysis)*/
\r
2114 it("should be this for the value (limit value analysis)", function() {
\r
2117 ele.setAttributeNS(null, "begin", "1s");
\r
2118 ele.setAttributeNS(null, "dur", "1s");
\r
2119 ele.setAttributeNS(null, "attributeName", "d");
\r
2120 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2121 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2122 $animate.init(ele);
\r
2124 frame.setFrame(0);
\r
2125 var p = ele.parentNode;
\r
2126 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2127 * 他のブラウザではnullを返すため、その対策をする*/
\r
2128 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2130 function f(fr, result) {
\r
2131 frame.setFrame(fr);
\r
2132 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2135 f(24, "M20.0 0.0 L20.0 30.0");
\r
2136 f(36, "M20.0 10.0 L15.0 30.0");
\r
2139 ele.setAttributeNS(null, "fill", "freeze");
\r
2140 $animate.init(ele);
\r
2141 f(24, "M20.0 0.0 L20.0 30.0");
\r
2142 f(36, "M20.0 10.0 L15.0 30.0");
\r
2143 f(48, "M20.0 20.0 L10.0 30.0");
\r
2145 frame.timelines.length = 0;
\r
2146 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2147 $animate.init(ele);
\r
2148 expect($animate.mode).toBe("discrete");
\r
2149 f(24, "M20.0 0.0 L20.0 30.0");
\r
2150 f(25, "M20.0 0.0 L20.0 30.0");
\r
2151 f(37, "M20.0 20.0 L10.0 30.0");
\r
2152 f(48, "M20.0 20.0 L10.0 30.0");
\r
2154 ["display", "visibility", "xlink:href",
\r
2155 "stroke-linecap", "font-style"].forEach( function(attrName) {
\r
2156 function g(fr, result) {
\r
2157 frame.setFrame(fr);
\r
2158 expect(p.getAttribute(attrName) || "").toBe(result);
\r
2161 frame.timelines.length = 0;
\r
2162 ele.setAttributeNS(null, "calcMode", "linear");
\r
2163 ele.setAttributeNS(null, "attributeName", attrName);
\r
2164 $animate.init(ele);
\r
2165 expect($animate.mode).toBe("discrete");
\r
2166 g(24, "M20.0 0.0 L20.0 30.0");
\r
2167 g(25, "M20.0 0.0 L20.0 30.0");
\r
2168 g(37, "M20.0 20.0 L10.0 30.0");
\r
2169 g(48, "M20.0 20.0 L10.0 30.0");
\r
2172 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2173 it("should be this for the value (the valid partion )", function() {
\r
2175 ele.setAttributeNS(null, "begin", "0s");
\r
2176 ele.setAttributeNS(null, "dur", "100s");
\r
2177 ele.setAttributeNS(null, "attributeName", "d");
\r
2178 ele.setAttributeNS(null, "fill", "freeze");
\r
2179 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2180 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2181 $animate.init(ele);
\r
2183 var p = ele.parentNode;
\r
2184 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2186 function f(fr, result) {
\r
2187 frame.setFrame(fr);
\r
2188 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2191 for (var i=0;i<2400;++i) {
\r
2192 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2194 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2197 frame.timelines.length = 0;
\r
2198 ele.setAttributeNS(null, "begin", "0s");
\r
2199 ele.setAttributeNS(null, "dur", "1s");
\r
2200 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2201 ele.setAttributeNS(null, "attributeName", "d");
\r
2202 ele.setAttributeNS(null, "fill", "freeze");
\r
2203 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2204 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2205 $animate.init(ele);
\r
2206 f(23, "M20.0 23.0 L20.0 30.0");
\r
2207 f(24, "M20.0 0.0 L20.0 30.0");
\r
2208 f(25, "M20.0 1.0 L20.0 30.0");
\r
2209 f(48, "M20.0 24.0 L20.0 30.0");
\r
2211 frame.timelines.length = 0;
\r
2212 ele.setAttributeNS(null, "begin", "0s");
\r
2213 ele.setAttributeNS(null, "dur", "2s");
\r
2214 ele.setAttributeNS(null, "attributeName", "d");
\r
2215 ele.setAttributeNS(null, "fill", "freeze");
\r
2216 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2217 $animate.init(ele);
\r
2218 f(0, "M20.0 0.0 L20.0 30.0");
\r
2219 f(1, "M20.0 1.0 L20.0 30.0");
\r
2220 f(24, "M20.0 24.0 L20.0 30.0");
\r
2221 f(25, "M20.0 24.1 L20.0 30.0");
\r
2222 f(47, "M20.0 26.3 L20.0 30.0");
\r
2223 f(48, "M20.0 26.4 L20.0 30.0");
\r
2224 f(49, "M20.0 26.4 L20.0 30.0");
\r
2225 f(50, "M20.0 26.4 L20.0 30.0");
\r
2227 frame.timelines.length = 0;
\r
2228 ele.setAttributeNS(null, "begin", "0s");
\r
2229 ele.setAttributeNS(null, "end", "2s");
\r
2230 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2231 ele.removeAttributeNS(null, "repeatDur");
\r
2232 ele.setAttributeNS(null, "attributeName", "d");
\r
2233 ele.setAttributeNS(null, "fill", "freeze");
\r
2234 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2235 $animate.init(ele);
\r
2236 f(0, "M20.0 0.0 L20.0 30.0");
\r
2237 f(1, "M20.0 0.0 L20.0 30.0");
\r
2238 f(24, "M20.0 0.0 L20.0 30.0");
\r
2239 f(25, "M20.0 0.0 L20.0 30.0");
\r
2240 f(47, "M20.0 0.0 L20.0 30.0");
\r
2241 f(48, "M20.0 0.0 L20.0 30.0");
\r
2242 f(49, "M20.0 0.0 L20.0 30.0");
\r
2243 f(50, "M20.0 0.0 L20.0 30.0");
\r
2245 frame.timelines.length = 0;
\r
2246 ele.setAttributeNS(null, "dur", "2s");
\r
2247 ele.setAttributeNS(null, "fill", "remove");
\r
2248 var attrValue = p.getAttributeNS(null, "d");
\r
2249 $animate.init(ele);
\r
2252 frame.timelines.length = 0;
\r
2253 p.removeAttributeNS(null, "d");
\r
2254 ele.setAttributeNS(null, "fill", "freeze");
\r
2255 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2256 $animate.init(ele);
\r
2257 f(1, "M20.0 5.0 L20.0 30.0");
\r
2258 f(48, "M20.0 26.4 L20.0 30.0");
\r
2260 frame.timelines.length = 0;
\r
2261 ele.setAttributeNS(null, "fill", "freeze");
\r
2262 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2263 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2264 $animate.init(ele);
\r
2265 f(1, "M20.0 0.0 L20.0 30.0");
\r
2266 f(4, "M20.0 0.0 L20.0 30.0");
\r
2267 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2269 f(24, "M20.0 24.0 L20.0 30.0");
\r
2270 f(25, "M20.0 24.0 L20.0 30.0");
\r
2271 f(29, "M20.0 26.4 L20.0 30.0");
\r
2272 f(48, "M20.0 26.4 L20.0 30.0");
\r
2274 frame.timelines.length = 0;
\r
2275 ele.setAttributeNS(null, "calcMode", "spline");
\r
2276 ele.removeAttributeNS(null, "keyTimes");
\r
2277 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2278 ele.removeAttributeNS(null, "end");
\r
2279 ele.setAttributeNS(null, "dur", "9s");
\r
2280 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2281 $animate.init(ele);
\r
2288 frame.timelines.length = 0;
\r
2289 ele.setAttributeNS(null, "calcMode", "spline");
\r
2290 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2291 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2292 ele.setAttributeNS(null, "dur", "8s");
\r
2293 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2294 $animate.init(ele);
\r
2302 frame.timelines.length = 0;
\r
2303 ele.setAttributeNS(null, "begin", "click");
\r
2304 ele.setAttributeNS(null, "calcMode", "spline");
\r
2305 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2306 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2307 ele.setAttributeNS(null, "dur", "8s");
\r
2308 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2309 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2310 $animate.init(ele);
\r
2317 ["display", "visibility", "xlink:href",
\r
2318 "stroke-linecap", "font-style"].forEach( function(attrName) {
\r
2319 function g(fr, result) {
\r
2320 frame.setFrame(fr);
\r
2321 expect(p.getAttribute(attrName)).toBe(result);
\r
2324 frame.timelines.length = 0;
\r
2325 ele.setAttributeNS(null, "begin", "0s");
\r
2326 ele.setAttributeNS(null, "calcMode", "linear");
\r
2327 ele.setAttributeNS(null, "attributeName", attrName);
\r
2328 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2329 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2330 ele.setAttributeNS(null, "dur", "8s");
\r
2331 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2332 $animate.init(ele);
\r
2333 expect($animate.mode).toBe("discrete");
\r
2340 frame.timelines.length = 0;
\r
2341 ele.setAttributeNS(null, "begin", "click");
\r
2342 ele.setAttributeNS(null, "calcMode", "linear");
\r
2343 ele.setAttributeNS(null, "attributeName", attrName);
\r
2344 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2345 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2346 ele.setAttributeNS(null, "dur", "8s");
\r
2347 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2348 $animate.init(ele);
\r
2349 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2350 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2351 p.dispatchEvent(evt);
\r
2352 var cur = base("$frame").currentFrame;
\r
2353 expect($animate.mode).toBe("discrete");
\r
2354 g(cur+0, "inline");
\r
2355 g(cur+48, "block");
\r
2356 g(cur+96, "inline");
\r
2357 g(cur+192, "block");
\r
2358 g(cur+300, "block");
\r
2361 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2362 it("should be this for the value (the invalid partion )", function() {
\r
2363 ele.setAttributeNS(null, "begin", "0s");
\r
2364 ele.setAttributeNS(null, "dur", "100s");
\r
2365 ele.setAttributeNS(null, "attributeName", "d");
\r
2366 ele.setAttributeNS(null, "fill", "freeze");
\r
2367 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2368 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2369 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2370 $animate.init(ele);
\r
2372 var p = ele.parentNode;
\r
2373 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2375 function f(fr, result) {
\r
2376 frame.setFrame(fr);
\r
2377 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2382 frame.timelines.length = 0;
\r
2383 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2384 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2385 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2386 $animate.init(ele);
\r
2390 /*keyTimes属性が0から始まっていない*/
\r
2391 frame.timelines.length = 0;
\r
2392 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2396 function ff(mode) {
\r
2397 ele.setAttributeNS(null, "calcMode", mode);
\r
2398 $animate.init(ele);
\r
2403 frame.timelines.length = 0;
\r
2404 ele.setAttributeNS(null, "calcMode", "spline");
\r
2405 $animate.init(ele);
\r
2406 expect($animate.mode).toBe("spline");
\r
2412 describe("RGB Color", function() {
\r
2413 var $animate, ele, frame, f;
\r
2414 beforeEach( function() {
\r
2415 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2416 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2417 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2418 p.appendChild(ele);
\r
2419 frame = base("$frame");
\r
2420 frame.timelines.length = 0;
\r
2422 f = function (fr, result, attr) {
\r
2423 frame.setFrame(fr);
\r
2424 expect(p.getAttributeNS(null, attr)).toBe(result);
\r
2427 /*境界条件を調べておく (limit value analysis)*/
\r
2428 it("should be this for the value (limit value analysis)", function() {
\r
2429 ele.setAttributeNS(null, "begin", "0s");
\r
2430 ele.setAttributeNS(null, "dur", "1s");
\r
2431 ele.setAttributeNS(null, "attributeName", "fill");
\r
2432 ele.setAttributeNS(null, "fill", "remove");
\r
2433 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2434 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2435 $animate.init(ele);
\r
2437 f(0, "rgb(0, 0, 0)", "fill");
\r
2438 f(23, "rgb(10, 10, 1)", "fill");
\r
2440 frame.timelines.length = 0;
\r
2441 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2442 $animate.init(ele);
\r
2443 f(0, "rgb(0, 0, 0)", "stroke");
\r
2444 f(23, "rgb(10, 10, 1)", "stroke");
\r
2446 frame.timelines.length = 0;
\r
2447 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2448 $animate.init(ele);
\r
2449 f(0, "rgb(0,0,0)", "stop-color");
\r
2450 f(23, "rgb(10,10,1)", "stop-color");
\r
2452 frame.timelines.length = 0;
\r
2453 ele.setAttributeNS(null, "attributeName", "color");
\r
2454 $animate.init(ele);
\r
2455 f(0, "rgb(0,0,0)", "color");
\r
2456 f(23, "rgb(10,10,1)", "color");
\r
2458 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2459 it("should be this for the value (the valid partion )", function() {
\r
2460 ele.setAttributeNS(null, "begin", "0s");
\r
2461 ele.setAttributeNS(null, "dur", "1s");
\r
2462 ele.setAttributeNS(null, "attributeName", "fill");
\r
2463 ele.setAttributeNS(null, "fill", "remove");
\r
2464 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2465 $animate.init(ele);
\r
2467 f(0, "rgb(0, 0, 0)", "fill");
\r
2468 f(1, "rgb(1, 0, 0)", "fill");
\r
2469 f(23, "rgb(23, 2, 1)", "fill");
\r
2471 frame.timelines.length = 0;
\r
2472 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2473 $animate.init(ele);
\r
2476 f(0, "rgb(0, 8, 60)", "fill");
\r
2477 f(1, "rgb(1, 9, 60)", "fill");
\r
2478 f(23, "rgb(23, 31, 60)", "fill");
\r
2480 frame.timelines.length = 0;
\r
2481 ele.setAttributeNS(null, "fill", "freeze");
\r
2482 ele.setAttributeNS(null, "values", "black;white");
\r
2483 $animate.init(ele);
\r
2484 /*色キーワードをrgb形式に変換*/
\r
2486 f(0, "rgb(0, 0, 0)", "fill");
\r
2487 f(12, "rgb(128, 128, 128)", "fill");
\r
2488 f(24, "rgb(255, 255, 255)", "fill");
\r
2490 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2491 it("should be this for the value (the invalid partion )", function() {
\r
2492 ele.setAttributeNS(null, "begin", "0s");
\r
2493 ele.setAttributeNS(null, "dur", "1s");
\r
2494 ele.setAttributeNS(null, "attributeName", "fi");
\r
2495 ele.setAttributeNS(null, "fill", "remove");
\r
2496 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2497 $animate.init(ele);
\r
2500 f(0, "#83.0C", "fi");
\r
2501 f(1, "#84.0C", "fi");
\r
2502 f(23, "#106.0C", "fi");
\r
2505 describe("$frame.$svgEvent object", function() {
\r
2506 var frame = base("$frame").$svgEvent,
\r
2508 base("$frame").pauseAnimation();
\r
2509 beforeEach( function() {
\r
2510 base("$frame").pauseAnimation();
\r
2511 frame = frame.up();
\r
2512 frame.first = null;
\r
2513 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2514 * 影響を受けるため、新たに初期化しておく*/
\r
2515 base("$frame").timelines = frame.timelines = [];
\r
2516 frame.lastTimeLine = null;
\r
2517 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2518 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2519 p.appendChild(ele);
\r
2521 /*境界条件を調べておく (limit value analysis)*/
\r
2522 it("should be this for the value (limit value analysis)", function() {
\r
2523 base("$frame").pauseAnimation();
\r
2524 frame.lastTimeLine = null;
\r
2525 expect(frame.lastTimeLine).toBeNull();
\r
2526 expect(frame.first).toBeNull();
\r
2527 frame.setTimeTable();
\r
2528 expect(frame.first).toBeNull();
\r
2529 frame.addLine( base("$frame").$begin.up().mix({
\r
2535 frame.setTimeTable();
\r
2536 expect(frame.first).toEqual(
\r
2538 eventType: "begin",
\r
2549 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2550 it("should be this for the value (the valid partion )", function() {
\r
2551 base("$frame").pauseAnimation();
\r
2552 frame.addLine( base("$frame").$begin.up().mix({
\r
2558 frame.setTimeTable();
\r
2559 frame.setTimeTable();
\r
2560 expect(frame.first).toEqual(
\r
2562 eventType: "begin",
\r
2572 frame.setTimeTable();
\r
2573 frame.setTimeTable();
\r
2574 expect(frame.first).toEqual(
\r
2576 eventType: "begin",
\r
2587 var isFiredBeginEvent = false;
\r
2588 ele.addEventListener("beginEvent", function(evt) {
\r
2589 isFiredBeginEvent = true;
\r
2590 expect(evt.target).toBe(ele);
\r
2592 ele.addEventListener("endEvent", function(evt) {
\r
2593 expect(evt.target).toBe(ele);
\r
2594 expect(isFiredBeginEvent).toBeTruthy();
\r
2596 frame.setFrame(0);
\r
2597 expect(frame.first).toBeNull();
\r
2598 frame.setFrame(0);
\r
2599 expect(frame.first).toBeNull();
\r
2601 frame.timelines = [];
\r
2602 frame.addLine( base("$frame").$begin.up().mix({
\r
2608 frame.setTimeTable();
\r
2609 var a = { frame: 0,
\r
2610 eventType: "begin",
\r
2613 next: { frame: 10,
\r
2619 expect(frame.first).toEqual(a);
\r
2621 frame.addLine( base("$frame").$begin.up().mix({
\r
2624 simpleDuration: 9,
\r
2628 frame.setTimeTable();
\r
2629 a.next.next = { frame: 1,
\r
2630 eventType: "begin",
\r
2633 next: { firstFrame: 10,
\r
2635 eventType: "repeat",
\r
2638 simpleDuration: 9,
\r
2641 next: { frame: 12,
\r
2648 expect(frame.first).toEqual(a);
\r
2649 frame.setFrame(11);
\r
2650 expect(frame.first).toEqual( {frame: 12,
\r
2656 frame.timelines = [];
\r
2657 frame.first = null;
\r
2658 frame.addLine( base("$frame").$begin.up().mix({
\r
2661 simpleDuration: 4,
\r
2665 frame.setTimeTable();
\r
2667 eventType: "begin",
\r
2670 next: {firstFrame:5,
\r
2672 eventType: "repeat",
\r
2675 simpleDuration: 4,
\r
2678 next: { frame: 11,
\r
2685 expect(frame.first).toEqual(a);
\r
2686 frame.setFrame(0);
\r
2687 expect(frame.first).toEqual(a);
\r
2688 frame.setFrame(1);
\r
2690 expect(frame.first).toEqual(a);
\r
2691 frame.setFrame(5);
\r
2694 expect(frame.first).toEqual(a);
\r
2696 ele.addEventListener("repeatEvent", function(evt) {
\r
2697 expect(evt.target).toBe(ele);
\r
2699 frame.timelines = [];
\r
2700 frame.first = null;
\r
2701 frame.addLine( base("$frame").$begin.up().mix({
\r
2704 simpleDuration: 4,
\r
2708 frame.setFrame(9);
\r
2711 a.next.frame = 16;
\r
2712 expect(frame.first).toEqual(a);
\r
2714 afterEach( function() {
\r
2715 base("$frame").startAnimation();
\r
2718 describe("A $animateTransformElemenet object", function() {
\r
2719 describe("An init method", function() {
\r
2720 var $animate, ele, frame, p;
\r
2721 beforeEach( function() {
\r
2722 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2723 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2724 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2725 p.appendChild(ele);
\r
2726 frame = base("$frame");
\r
2727 frame.timelines.length = 0;
\r
2728 frame.startTime = Date.now();
\r
2729 frame.setFrame(0);
\r
2731 afterEach( function() {
\r
2732 $animate.numberOfList = -1;
\r
2734 /*境界条件を調べておく (limit value analysis)*/
\r
2735 it("should be this for the value (limit value analysis)", function() {
\r
2736 expect($animate.numberOfList).toBe(-1);
\r
2737 expect($animate.type).toBe("translate");
\r
2738 expect(p.__transformList).toBeUndefined();
\r
2741 expect($animate.numberOfList).toBe(-1);
\r
2742 expect(p.__transformList).toBeUndefined();
\r
2743 expect($animate.type).toBe("translate");
\r
2746 expect($animate.numberOfList).toBe(-1);
\r
2747 expect(p.__transformList).toBeUndefined();
\r
2748 expect($animate.type).toBe("translate");
\r
2750 $animate.init(ele);
\r
2751 expect($animate.numberOfList).toBe(-1);
\r
2752 expect(p.__transformList).toEqual([]);
\r
2754 ele.setAttributeNS(null, "values", "0;1");
\r
2755 $animate.init(ele);
\r
2756 expect($animate.type).toBe("translate");
\r
2757 expect($animate.numberOfList).toBe(0);
\r
2758 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2759 value: "translate(0)",
\r
2763 ele.setAttributeNS(null, "type", "translate");
\r
2764 $animate.init(ele);
\r
2765 expect($animate.numberOfList).toBe(0);
\r
2766 expect($animate.type).toBe("translate");
\r
2767 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2768 value: "translate(0)",
\r
2771 $animate.tocall(0);
\r
2772 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2774 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2775 $animate.numberOfList = -1;
\r
2776 $animate.init(ele.parentNode.lastChild);
\r
2777 expect($animate.numberOfList).toBe(1);
\r
2778 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2779 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2781 expect($animate.type).toBe("translate");
\r
2782 $animate.tocall(0);
\r
2783 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2784 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2785 $animate._setEndFrame(1);
\r
2786 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2787 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2789 delete p.__transformList;
\r
2790 ele.setAttributeNS(null, "type", "scale");
\r
2791 $animate.numberOfList = -1;
\r
2792 $animate.init(ele);
\r
2793 expect($animate.numberOfList).toBe(0);
\r
2794 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2795 value: "translate(0)",
\r
2798 expect($animate.type).toBe("scale");
\r
2800 delete p.__transformList;
\r
2801 $animate.numberOfList = -1;
\r
2802 ele.setAttributeNS(null, "additive", "sum");
\r
2803 $animate.init(ele);
\r
2804 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2805 value: "translate(0)",
\r
2808 delete p.__transformList;
\r
2809 $animate.numberOfList = -1;
\r
2810 ele.setAttributeNS(null, "additive", "replace");
\r
2811 $animate.init(ele);
\r
2812 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2813 value: "translate(0)",
\r
2817 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2818 it("should be this for the value (the valid partion )", function() {
\r
2819 ele.setAttributeNS(null, "type", "scale");
\r
2820 ele.setAttributeNS(null, "values", "0;1");
\r
2821 $animate.init(ele);
\r
2822 expect($animate.numberOfList).toBe(0);
\r
2823 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2824 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
2825 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
2826 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2828 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2829 $animate.numberOfList = -1;
\r
2830 $animate.init(ele.parentNode.lastChild);
\r
2831 expect($animate.numberOfList).toBe(1);
\r
2832 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2833 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2835 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2836 $animate.up("$a").numberOfList = -1;
\r
2837 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2838 $animate.$a.init(ele.parentNode.lastChild);
\r
2839 expect($animate.$a.numberOfList).toBe(2);
\r
2840 expect($animate.$a.isDefault).toBeTruthy();
\r
2841 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2842 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
2843 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
2844 $animate.defaultValue = $animate.$a.defaultValue;
\r
2845 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
2847 ele.setAttributeNS(null, "additive", "sum");
\r
2848 var parentNode = ele.parentNode;
\r
2849 parentNode.appendChild(ele.cloneNode(true));
\r
2850 parentNode.__transformList = [];
\r
2851 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
2852 parentNode.removeChild(ele);
\r
2853 $animate.numberOfList = -1;
\r
2854 $animate.init(parentNode.lastChild);
\r
2855 expect($animate.numberOfList).toBe(0);
\r
2856 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2857 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2859 parentNode.appendChild(ele.cloneNode(true));
\r
2860 $animate.up("$a").numberOfList = -1;
\r
2861 parentNode.__transformList = [];
\r
2862 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2863 $animate.$a.init(parentNode.lastChild);
\r
2864 expect($animate.$a.numberOfList).toBe(0);
\r
2865 expect($animate.$a.isDefault).toBeTruthy();
\r
2866 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2867 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2868 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2869 $animate.defaultValue = $animate.$a.defaultValue;
\r
2870 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
2872 ele.removeAttributeNS(null, "additive");
\r
2873 ad("replace", "sum", "scale(0.0)", "scale(0.0) scale(0.0)",
\r
2874 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
2875 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
2876 "scale(0.0)", "scale(1.0)");
\r
2877 function ad(first, second, a, b, c, d) {
\r
2879 while (parentNode.firstChild) {
\r
2880 parentNode.removeChild(parentNode.firstChild);
\r
2883 /*additive属性のreplaceとsumの混合*/
\r
2884 ele.setAttributeNS(null, "additive", first);
\r
2885 parentNode.appendChild(ele.cloneNode(true));
\r
2886 ele.setAttributeNS(null, "additive", second);
\r
2887 parentNode.appendChild(ele.cloneNode(true));
\r
2888 parentNode.__transformList = [];
\r
2889 $animate.numberOfList = -1;
\r
2890 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2891 $animate.up("$first").init(parentNode.firstChild);
\r
2892 $animate.up("$second").init(parentNode.lastChild);
\r
2893 expect($animate.$first.numberOfList).toBe(0);
\r
2894 expect($animate.$second.numberOfList).toBe(1);
\r
2895 expect($animate.$first.tocall(0)).toBe(a);
\r
2896 expect($animate.$second.tocall(0)).toBe(b);
\r
2897 expect($animate.$first.tocall(1)).toBe(c);
\r
2898 expect($animate.$second.tocall(1)).toBe(d);
\r
2901 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2902 it("should be this for the value (the invalid partion )", function() {
\r
2903 $animate.init(ele);
\r
2904 ele.parentNode.__transformList = null;
\r
2905 expect( function () {
\r
2906 $animate.tocall(0);
\r
2909 $animate.numberOfList = -1;
\r
2910 $animate.init(ele);
\r
2911 $animate.numberOfList = -1;
\r
2912 expect( function () {
\r
2913 $animate.tocall(0);
\r
2918 describe("A $motionElement object", function() {
\r
2919 describe("An init method", function() {
\r
2920 var $animate, ele, frame, p;
\r
2921 beforeEach( function() {
\r
2922 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
2923 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2924 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
2925 p.appendChild(ele);
\r
2926 frame = base("$frame");
\r
2927 frame.timelines.length = 0;
\r
2928 frame.startTime = Date.now();
\r
2929 frame.setFrame(0);
\r
2931 afterEach( function() {
\r
2932 $animate.numberOfList = -1;
\r
2933 p.__transformList = null;
\r
2935 /*境界条件を調べておく (limit value analysis)*/
\r
2936 it("should be this for the value (limit value analysis)", function() {
\r
2937 expect($animate.type).toBe("translate");
\r
2938 ele.setAttributeNS(null, "type", "scale");
\r
2939 $animate.init(ele);
\r
2940 expect($animate.type).toBe("translate");
\r
2942 ele.setAttributeNS(null, "values", "0;1");
\r
2943 $animate.up("$a").init(ele);
\r
2944 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
2945 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
2946 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
2948 var ec = ele.cloneNode(true);
\r
2949 ec.removeAttributeNS(null, "values");
\r
2950 ec.setAttributeNS(null, "from", "0");
\r
2951 ec.setAttributeNS(null, "to", "1");
\r
2952 $animate.up("$a").init(ec);
\r
2953 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
2954 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
2955 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
2960 describe("Event", function() {
\r
2961 var $animate, ele, frame, p;
\r
2962 beforeEach( function() {
\r
2964 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2965 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2966 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2967 p.appendChild(ele);
\r
2968 frame = base("$frame");
\r
2969 frame.pauseAnimation();
\r
2970 frame.timelines.length = 0; //配列の初期化
\r
2971 frame.setFrame(0);
\r
2973 /*境界条件を調べておく (limit value analysis)*/
\r
2974 it("should be this for the value (limit value analysis)", function() {
\r
2975 ele.addEventListener("beginEvent", function(evt) {
\r
2976 expect(evt.target).toBe(ele);
\r
2978 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2979 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
2980 ele.dispatchEvent(evt);
\r
2982 ele.setAttributeNS(null, "begin", "mousedown");
\r
2983 ele.setAttributeNS(null, "dur", "1s");
\r
2984 ele.setAttributeNS(null, "attributeName", "fill");
\r
2985 ele.setAttributeNS(null, "fill", "freeze");
\r
2986 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
2987 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
2988 $animate.init(ele);
\r
2989 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
2990 expect($animate.state).toBe("idling");
\r
2991 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2992 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
2993 expect($animate.state).toBe("idling");
\r
2994 p.dispatchEvent(evt);
\r
2995 expect($animate.state).toBe("idling");
\r
2996 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
2998 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2999 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3000 frame.setFrame(frame.currentFrame);
\r
3001 expect($animate.isEnd).toBeFalsy();
\r
3002 expect($animate.state).toBe("idling");
\r
3003 p.dispatchEvent(evt);
\r
3004 frame.setFrame(frame.currentFrame + 1);
\r
3005 expect($animate.state).toBe("playing");
\r
3006 frame.setFrame(frame.currentFrame + 24);
\r
3007 expect($animate.state).toBe("idling");
\r
3008 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3011 describe("a beginElement method and an endElement method", function() {
\r
3012 var $animate, ele, frame, p;
\r
3013 beforeEach( function() {
\r
3014 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3015 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3016 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3017 p.appendChild(ele);
\r
3018 frame = base("$frame");
\r
3019 frame.timelines.length = 0; //配列の初期化
\r
3020 frame.setFrame(0);
\r
3021 ele.setAttributeNS(null, "begin", "indefinite");
\r
3022 ele.setAttributeNS(null, "dur", "1s");
\r
3023 ele.setAttributeNS(null, "dur", "1s");
\r
3024 ele.setAttributeNS(null, "attributeName", "fill");
\r
3025 ele.setAttributeNS(null, "fill", "freeze");
\r
3026 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3027 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3028 $animate.init(ele);
\r
3030 /*境界条件を調べておく (limit value analysis)*/
\r
3031 it("should be this for the value (limit value analysis)", function() {
\r
3032 expect(ele.beginElement()).toBeUndefined();
\r
3033 var cur = frame.currentFrame,
\r
3034 begin = frame.$begin.$1;
\r
3035 expect(begin.string).toBe("indefinite");
\r
3036 expect(begin.begin).toBe(cur);
\r
3037 expect(ele.endElement()).toBeUndefined();
\r
3039 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3040 it("should be this for the value (the valid partion )", function() {
\r
3041 ele.addEventListener("beginEvent", function(evt){
\r
3042 expect(evt.target.nodeName).toBe("animate");
\r
3044 ele.beginElement();
\r