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.isBegin).toBeFalsy();
\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 frame.timelines.length = 0;
\r
188 expect(frame.timelines[2].activeTime).toBe(2)
\r
190 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
191 it("should be this for the value (the invalid partion)", function() {
\r
192 expect(frame.addLine(12)).toBeFalsy();
\r
193 /*循環参照にならず、スタック領域不足にならない*/
\r
194 frame.addLine(frame);
\r
199 describe("$begin object", function() {
\r
200 var begin = base("$frame").$begin.up();
\r
201 /*境界条件を調べておく (limit value analysis)*/
\r
202 it("should be this for the value (limit value analysis)", function() {
\r
203 expect(begin.string).toBe("");
\r
204 expect(begin.isResolved).toBeFalsy();
\r
205 expect(begin.eventTarget).toBe(document.documentElement);
\r
206 expect(typeof begin.listener).toBe("function");
\r
207 expect(begin.eventOffset).toBe(0);
\r
208 expect(begin.repeat).toBe(0);
\r
209 expect(begin.accessKey).toBe("");
\r
211 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
212 it("should be this for the value (the valid partion)", function() {
\r
213 begin.string = " hoge ";
\r
214 expect(begin.string).toBe(" hoge ");
\r
216 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
217 it("should be this for the value (the invalid partion)", function() {
\r
220 describe("A trim method in $begin object", function() {
\r
221 /*境界条件を調べておく (limit value analysis)*/
\r
222 beforeEach( function() {
\r
225 it("should be this for the value (limit value analysis)", function() {
\r
226 delete begin.string;
\r
227 expect(begin.trim(" ")).toBe("");
\r
228 expect( function() {
\r
232 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
233 it("should be this for the value (the valid partion)", function() {
\r
234 expect(begin.trim(" hoge ")).toBe("hoge");
\r
235 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
236 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
237 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
239 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
240 it("should be this for the value (the invalid partion)", function() {
\r
241 expect( function() {
\r
244 expect( function() {
\r
250 describe("An offset method in $begin object", function() {
\r
251 beforeEach( function() {
\r
254 /*境界条件を調べておく (limit value analysis)*/
\r
255 it("should be this for the value (limit value analysis)", function() {
\r
256 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
257 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
258 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
259 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
260 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
261 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
263 expect(begin.offset("+0s")).toBe(0);
\r
264 expect(begin.offset("-0s")).toBe(0);
\r
265 expect(begin.offset("1s")).toBe(1000);
\r
266 expect(begin.offset("-1s")).toBe(-1000);
\r
268 expect(begin.offset("+0min")).toBe(0);
\r
269 expect(begin.offset("-0min")).toBe(0);
\r
270 expect(begin.offset("1min")).toBe(60000);
\r
271 expect(begin.offset("-1min")).toBe(-60000);
\r
273 expect(begin.offset("+0h")).toBe(0);
\r
274 expect(begin.offset("-0h")).toBe(0);
\r
275 expect(begin.offset("1h")).toBe(60*60*1000);
\r
276 expect(begin.offset("-1h")).toBe(-3600000);
\r
278 expect(begin.offset("00:0")).toBe(0);
\r
279 expect(begin.offset("00:00:0.0")).toBe(0);
\r
280 expect(begin.offset("-00:0")).toBe(0);
\r
281 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
282 expect(begin.offset("00:1")).toBe(1000);
\r
283 expect(begin.offset("-00:1")).toBe(-1000);
\r
284 expect(begin.offset("00:00:1")).toBe(1000);
\r
285 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
287 expect(begin.offset()).toBe(0);
\r
289 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
290 it("should be this for the value (the valid partion)", function() {
\r
291 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
292 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
293 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
294 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
296 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
297 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
298 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
299 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
300 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
302 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
303 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
304 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
305 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
306 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
308 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
309 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
310 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
311 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
312 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
314 expect(begin.offset("01:0")).toBe(60000);
\r
315 expect(begin.offset("-01:0")).toBe(-60000);
\r
316 expect(begin.offset("00:00:1")).toBe(1000);
\r
317 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
318 expect(begin.offset("00:01:0")).toBe(60000);
\r
319 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
320 expect(begin.offset("01:00:0")).toBe(3600000);
\r
321 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
322 expect(begin.offset("00:10")).toBe(10000);
\r
323 expect(begin.offset("00:0.01")).toBe(10);
\r
324 expect(begin.offset("01:0.01")).toBe(60010);
\r
325 expect(begin.offset("10:0")).toBe(600000);
\r
326 expect(begin.offset("-00:10")).toBe(-10000);
\r
327 expect(begin.offset("-00:0.01")).toBe(-10);
\r
328 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
329 expect(begin.offset("-10:0")).toBe(-600000);
\r
330 expect(begin.offset("00:00:20")).toBe(20000);
\r
331 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
332 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
333 expect(begin.offset("-10:0")).toBe(-600000);
\r
334 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
336 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
337 it("should be this for the value (the invalid partion)", function() {
\r
338 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
339 expect(begin.offset("ms")).toBe(0);
\r
340 expect(begin.offset(".s")).toBe(0);
\r
341 expect(begin.offset("10:")).toBe(0);
\r
342 expect(begin.offset("::")).toBe(0);
\r
343 expect(begin.offset("-:0")).toBe(0);
\r
344 expect(begin.offset("-::0")).toBe(0);
\r
347 describe("An event method in $begin object", function() {
\r
348 /*境界条件を調べておく (limit value analysis)*/
\r
349 it("should be this for the value (limit value analysis)", function() {
\r
350 var evt = begin.event();
\r
351 expect(evt.id).toBe("");
\r
352 expect(evt.event).toBe("");
\r
353 evt = begin.event("");
\r
354 expect(evt.id).toBe("");
\r
355 expect(evt.event).toBe("");
\r
356 evt = begin.event(".");
\r
357 expect(evt.id).toBe("");
\r
358 expect(evt.event).toBe("");
\r
360 evt = begin.event("a");
\r
361 expect(evt.id).toBe("");
\r
362 expect(evt.event).toBe("a");
\r
363 evt = begin.event("a.b");
\r
364 expect(evt.id).toBe("a");
\r
365 expect(evt.event).toBe("b");
\r
367 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
368 it("should be this for the value (the valid partion)", function() {
\r
369 var evt = begin.event("id.event");
\r
370 expect(evt.id).toBe("id");
\r
371 expect(evt.event).toBe("event");
\r
372 evt = begin.event("event");
\r
373 expect(evt.id).toBe("");
\r
374 expect(evt.event).toBe("event");
\r
376 evt = begin.event("event+0s");
\r
377 expect(evt.id).toBe("");
\r
378 expect(evt.event).toBe("event");
\r
379 evt = begin.event("event-0s");
\r
380 expect(evt.id).toBe("");
\r
381 expect(evt.event).toBe("event");
\r
383 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
384 it("should be this for the value (the invalid partion)", function() {
\r
385 evt = begin.event("...");
\r
386 expect(evt.id).toBe("");
\r
387 expect(evt.event).toBe("");
\r
388 evt = begin.event(".event");
\r
389 expect(evt.id).toBe("");
\r
390 expect(evt.event).toBe("");
\r
391 evt = begin.event("id.");
\r
392 expect(evt.id).toBe("");
\r
393 expect(evt.event).toBe("");
\r
397 describe("An parse method in $begin object", function() {
\r
398 beforeEach( function() {
\r
401 /*境界条件を調べておく (limit value analysis)*/
\r
402 it("should be this for the value (limit value analysis)", function() {
\r
403 expect(begin.parse().begin).toBe(0);
\r
404 expect(begin.isResolved).toBeTruthy();
\r
406 expect(begin.parse().begin).toBe(0);
\r
407 begin.string = "+1";
\r
408 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
409 begin.string = " ";
\r
410 expect(begin.parse().begin).toBe(0);
\r
411 begin.string = "1";
\r
412 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
413 begin.string = "+0ms";
\r
414 expect(begin.parse().begin).toBe(0);
\r
415 begin.string = "-0ms";
\r
416 expect(begin.parse().begin).toBe(0);
\r
418 expect(begin.eventOffset).toBe(0);
\r
419 begin.string = "click";
\r
420 expect(begin.parse().begin).toBe(0);
\r
421 expect(begin.eventOffset).toBe(0);
\r
422 expect(begin.repeat).toBe(0);
\r
423 expect(begin.accessKey).toBe("");
\r
424 begin.string = "id.click";
\r
425 expect(begin.parse().begin).toBe(0);
\r
426 expect(begin.eventOffset).toBe(0);
\r
427 expect(begin.repeat).toBe(0);
\r
428 expect(begin.accessKey).toBe("");
\r
430 begin.string = "repeat";
\r
431 expect(begin.parse().begin).toBe(0);
\r
432 expect(begin.eventOffset).toBe(0);
\r
433 expect(begin.repeat).toBe(0);
\r
434 expect(begin.accessKey).toBe("");
\r
435 begin.string = "repeat(1)";
\r
436 expect(begin.parse().begin).toBe(0);
\r
437 expect(begin.eventOffset).toBe(0);
\r
438 expect(begin.repeat).toBe(1);
\r
439 expect(begin.accessKey).toBe("");
\r
441 begin.string = "accessKey(a)";
\r
442 expect(begin.parse().begin).toBe(0);
\r
443 expect(begin.eventOffset).toBe(0);
\r
444 expect(begin.repeat).toBe(0);
\r
445 expect(begin.accessKey).toBe("a");
\r
447 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
448 it("should be this for the value (the valid partion)", function() {
\r
449 begin.string = " 1 0 0 m s";
\r
450 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
452 begin.string = "1ms";
\r
453 begin.isResolved = false;
\r
454 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
455 expect(begin.isResolved).toBeTruthy();
\r
456 expect(begin.eventOffset).toBe(0);
\r
458 begin.string="click+0";
\r
459 expect(begin.parse().begin).toBe(0);
\r
460 expect(begin.eventOffset).toBe(0);
\r
461 expect(begin.isResolved).toBeFalsy();
\r
462 begin.string = "click+1";
\r
463 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
464 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
465 begin.string = " click ";
\r
466 expect(begin.parse().begin).toBe(0);
\r
467 expect(begin.eventOffset).toBe(0);
\r
468 begin.string = "click+0ms";
\r
469 expect(begin.parse().begin).toBe(0);
\r
470 expect(begin.eventOffset).toBe(0);
\r
471 expect(begin.isResolved).toBeFalsy();
\r
472 begin.string = "click-0ms";
\r
473 expect(begin.parse().begin).toBe(0);
\r
474 expect(begin.eventOffset).toBe(0);
\r
475 begin.string = "click+100ms";
\r
476 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
477 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
478 begin.string = "click-100ms";
\r
479 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
480 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
482 begin.string="id.click+0";
\r
483 expect(begin.parse().begin).toBe(0);
\r
484 expect(begin.eventOffset).toBe(0);
\r
485 expect(begin.isResolved).toBeFalsy();
\r
486 begin.string = "id.click+1";
\r
487 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
488 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
489 expect(begin.isResolved).toBeFalsy();
\r
490 begin.string = " id . click ";
\r
491 expect(begin.parse().begin).toBe(0);
\r
492 expect(begin.eventOffset).toBe(0);
\r
493 expect(begin.isResolved).toBeFalsy();
\r
494 begin.string = "id.click+0ms";
\r
495 expect(begin.parse().begin).toBe(0);
\r
496 expect(begin.eventOffset).toBe(0);
\r
497 begin.string = "id.click-0ms";
\r
498 expect(begin.parse().begin).toBe(0);
\r
499 expect(begin.eventOffset).toBe(0);
\r
500 begin.string = "id.click+100ms";
\r
501 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
502 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
503 begin.string = "id.click-100ms";
\r
504 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
505 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
507 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
508 it("should be this for the value (the invalid partion)", function() {
\r
509 begin.string = "ms";
\r
510 begin.isResolved = false;
\r
511 expect(begin.parse().begin).toBe(0);
\r
512 expect(begin.isResolved).toBeFalsy();
\r
514 begin.isResolved = true;
\r
515 begin.string = "indefinite";
\r
516 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
517 expect(begin.isResolved).toBeFalsy();
\r
521 describe("A listener method in $begin object", function() {
\r
522 var obj = begin.up();
\r
523 beforeEach( function() {
\r
526 begin.timelines.length = 0;
\r
527 obj.$activate = begin.$activate.up();
\r
528 obj.startTime = Date.now();
\r
531 /*境界条件を調べておく (limit value analysis)*/
\r
532 it("should be this for the value (limit value analysis)", function() {
\r
533 obj.isResolved = true;
\r
535 expect(obj.begin).toBe(0);
\r
538 timeStamp: Date.now()
\r
540 expect(obj.begin).toBe(0);
\r
541 expect(obj.activeTime).toBeGreaterThan(0);
\r
542 expect(obj.timelines.length).toBe(1);
\r
544 obj.isResolved = false;
\r
546 timeStamp: Date.now()
\r
548 expect(obj.begin).toBe(0);
\r
549 expect(obj.activeTime).toBeGreaterThan(0);
\r
550 expect(obj.timelines.length).toBe(1);
\r
552 obj.timelines.length = 0;
\r
557 $activate: begin.$activate.up().mix( {
\r
562 timeStamp: Date.now()
\r
564 expect(obj.$1.begin).toBe(1);
\r
565 expect(obj.$1.activeTime).toBe(Math.floor(12000*obj.fpms));
\r
566 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
567 expect(obj.timelines[0]).toBe(obj.$1);
\r
569 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
570 it("should be this for the value (the valid partion)", function() {
\r
574 $activate: begin.$activate.up().mix( {
\r
575 end: begin.$activate.end.up().mix( {
\r
581 timeStamp: Date.now()
\r
583 expect(obj.$1.begin).toBe(1);
\r
584 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
585 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
586 expect(obj.timelines[0]).toBe(obj.$1);
\r
591 $activate: begin.$activate.up().mix( {
\r
592 end: begin.$activate.end.up().mix( {
\r
598 timeStamp: Date.now()
\r
600 expect(obj.$1.begin).toBe(1);
\r
601 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
602 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
603 expect(obj.timelines[1]).toBe(obj.$1);
\r
605 timeStamp: (Date.now() + 500)
\r
607 expect(obj.$1.begin).toBe(1);
\r
608 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
609 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
610 expect(obj.timelines[1]).toBe(obj.$1);
\r
612 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
613 it("should be this for the value (the invalid partion)", function() {
\r
617 describe("A $end object", function() {
\r
618 var end = base("$frame").$begin.$end.up();
\r
620 beforeEach( function() {
\r
622 end.startTime = Date.now();
\r
625 /*境界条件を調べておく (limit value analysis)*/
\r
626 it("should be this for the value (limit value analysis)", function() {
\r
627 expect(end.up().call()).toBeNull();
\r
629 expect(end.up().call()).toBe(0);
\r
630 end.string = "hoge";
\r
631 expect(end.up().call()).toBe("indefinite");
\r
634 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
635 it("should be this for the value (the valid partion)", function() {
\r
636 end.string = "hoge+0";
\r
637 expect(end.up().call()).toBe("indefinite");
\r
638 end.string = "12ms";
\r
639 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
640 end.string = "hoge+12ms";
\r
641 expect(end.up().call()).toBe("indefinite");
\r
644 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
645 it("should be this for the value (the invalid partion)", function() {
\r
647 expect(end.up().call()).toBeNull();
\r
650 describe("A listener method in $end object", function() {
\r
652 begin = base("$frame").$begin;
\r
653 beforeEach( function() {
\r
656 end.timelines.length = 0;
\r
658 obj.$begin = begin.up().mix( {
\r
662 obj.$begin.$activate = begin.$activate.up();
\r
663 obj.addLine(obj.$begin);
\r
665 /*境界条件を調べておく (limit value analysis)*/
\r
666 it("should be this for the value (limit value analysis)", function() {
\r
667 expect(obj.timelines[0]).toBe(obj.$begin);
\r
668 expect(obj.timelines[0]).not.toBe(obj);
\r
670 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
672 obj.addLine(obj.$begin.mix( {
\r
677 timeStamp: (Date.now() + 12)
\r
679 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
681 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
682 it("should be this for the value (the valid partion)", function() {
\r
683 obj.$begin.$activate.begin = 0;
\r
688 timeStamp: (Date.now() + 120)
\r
690 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
691 expect(obj.begin).toBe(0);
\r
692 expect(obj.$begin.activeTime).toBe(0);
\r
694 obj.addLine(obj.$begin.mix( {
\r
698 obj.$begin.$activate.begin = 0;
\r
700 string: "event+1000ms"
\r
703 timeStamp: (Date.now() + 12)
\r
705 expect(obj.timelines[0]).toBe(obj.$begin);
\r
706 expect(obj.begin).toBe(Math.ceil(1000*obj.fpms));
\r
707 expect(obj.$begin.activeTime).toBe(Math.ceil(1000*obj.fpms));
\r
709 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
710 it("should be this for the value (the invalid partion)", function() {
\r
714 describe("A $activate object", function() {
\r
715 var act = base("$frame").$begin.$activate.up();
\r
716 beforeEach( function() {
\r
717 act.dur = "indefinite";
\r
719 act.repeatCount = null;
\r
720 act.repeatDur = null;
\r
721 act.end = act.$begin.$end;
\r
722 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
724 /*境界条件を調べておく (limit value analysis)*/
\r
725 it("should be this for the value (limit value analysis)", function() {
\r
726 expect(act.dur).toBe("indefinite");
\r
727 expect(typeof act.resolvedTime).toBe("function");
\r
728 expect(act.end).toBe(act.$begin.$end);
\r
729 expect(act.repeatCount).toBeNull();
\r
730 expect(act.repeatDur).toBeNull();
\r
731 expect(act.simpleDur()).toBeNull();
\r
732 expect(act.min).toBe("0");
\r
733 expect(act.max).toBe("indefinite");
\r
736 expect(act.$a.call()).toBeNull();
\r
737 expect(act.$a.end).toBeNull();
\r
739 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
740 it("should be this for the value (the valid partion)", function() {
\r
741 expect(act.resolvedTime()).toBe((+new Date()));
\r
743 /*Activate Duration = dur*/
\r
745 act.$b.dur = "132ms";
\r
746 var abc = act.$b.call();
\r
747 expect(abc).toBe(Math.floor(132*act.fpms));
\r
748 expect(abc).toBe(act.$b.simpleDur);
\r
750 expect(act.up().call()).toBeNull();
\r
752 /*AD = end -begin*/
\r
754 act.up("$eb").end = act.end.up().mix( {string: "120ms" } );
\r
755 expect( act.$eb.mix( {
\r
757 simpleDur: act.simpleDur,
\r
760 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
761 expect( act.$eb.mix( {
\r
763 repeatCount: "indefinite",
\r
765 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
766 expect( act.$eb.mix( {
\r
768 simpleDur: act.simpleDur,
770 repeatDur: "indefinite",
\r
771 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
773 expect( act.$eb.mix( {
\r
775 simpleDur: act.simpleDur,
776 repeatCount: "indefinite",
\r
777 repeatDur: "indefinite",
\r
778 } ).call() ).toBe(Math.floor(120*act.fpms)*3 - 1);
\r
780 /*AD = Min(dur, end - begin)*/
\r
781 act.up("$c").end = act.end.up().mix( { string: "12" } );
\r
784 simpleDur: act.simpleDur,
788 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
789 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
792 simpleDur: act.simpleDur,
796 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
797 expect(act.$c.simpleDur).toBe(Math.floor(15000*act.fpms));
\r
799 /*AD = Min(repeatCount*dur, end - begin)*/
\r
800 expect(act.$c.end).toBe(Math.floor(12000*act.fpms));
\r
803 simpleDur: act.simpleDur,
807 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
808 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
811 simpleDur: act.simpleDur,
815 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
816 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
818 /*AD = Min(repeatDur, end - begin)*/
\r
821 simpleDur: act.simpleDur,
825 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
826 expect(act.$c.simpleDur).toBeNull();
\r
829 simpleDur: act.simpleDur,
833 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
834 expect(act.$c.simpleDur).toBeNull();
\r
837 simpleDur: act.simpleDur,
841 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
842 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
845 simpleDur: act.simpleDur,
849 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
850 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
852 /*AD = Min(repeatCount*d, repeatDur, end - begin)*/
\r
855 simpleDur: act.simpleDur,
859 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
860 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
863 simpleDur: act.simpleDur,
867 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
868 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
871 simpleDur: act.simpleDur,
875 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
876 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
878 /*AD = repeatDur,*/
\r
882 simpleDur: act.simpleDur,
886 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
887 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
890 simpleDur: act.simpleDur,
894 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
895 expect(act.$c.simpleDur).toBeNull();
\r
897 act.end.string = null;
\r
898 act.up("$cd").mix( {
\r
903 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
905 act.$cd.end = act.end;
\r
906 act.$cd.repeatCount = null;
\r
907 act.$cd.repeatDur = "12";
\r
908 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
910 act.up("$d").mix( {
\r
914 simpleDur: act.simpleDur
\r
916 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
917 act.up("$d").mix( {
\r
921 simpleDur: act.simpleDur
\r
923 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
925 /*endで0が指定されている場合*/
\r
928 act.repeatDur = null;
\r
929 act.repeatCount = "indefinite";
\r
931 expect(act.call()).toBe(0);
\r
932 act.repeatCount = null;
\r
933 act.repeatDur = "indefinite";
\r
935 expect(act.call()).toBe(0);
\r
936 act.repeatDur = "indefinite";
\r
937 act.repeatCount = "indefinite";
\r
939 expect(act.call()).toBe(0);
\r
941 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
942 it("should be this for the value (the invalid partion)", function() {
\r
944 act.up("$d").mix( {
\r
948 simpleDur: act.simpleDur
\r
950 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
952 act.repeatDur = null;
\r
953 act.repeatCount = "indefinite";
\r
955 expect(act.call()).toBeNull();
\r
956 act.repeatCount = null;
\r
957 act.repeatDur = "indefinite";
\r
959 expect(act.call()).toBeNull();
\r
960 act.repeatDur = "indefinite";
\r
961 act.repeatCount = "indefinite";
\r
963 expect(act.call()).toBeNull();
\r
966 describe("A $from object", function() {
\r
967 var from = base("$from");
\r
968 beforeEach( function() {
\r
969 from = base("$from").up();
\r
970 from.from = from.from.up();
\r
973 /*境界条件を調べておく (limit value analysis)*/
\r
974 it("should be this for the value (limit value analysis)", function() {
\r
975 expect(from.string).toBe("");
\r
976 expect(from.numList()).toEqual([]);
\r
977 expect(from.strList()).toBeNull();
\r
980 expect(from.numList()[0]).toBe(0);
\r
981 expect(from.strList()).toBeNull();
\r
983 from.string = " 0 ";
\r
984 expect(from.numList()[0]).toBe(0);
\r
985 expect(from.strList().join("")).toBe(" ");
\r
988 expect(from.numList()).toEqual([]);
\r
989 expect(from.strList()[0]).toBe("a");
\r
991 /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから
\r
992 * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/
\r
994 from.string = null;
\r
995 expect( function() {
\r
998 expect( function() {
\r
1002 expect(from.additive[0]).toBe(0);
\r
1003 expect(from.accumulate[0]).toBe(0);
\r
1005 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1006 it("should be this for the value (the valid partion)", function() {
\r
1007 from.string = "0a";
\r
1008 expect(from.numList()[0]).toBe(0);
\r
1009 expect(from.strList()[0]).toBe("a");
\r
1011 from.string = "a0";
\r
1012 expect(from.numList()[0]).toBe(0);
\r
1013 expect(from.strList()[0]).toBe("a");
\r
1015 from.string = "0.1";
\r
1016 expect(from.numList()[0]).toBe(0.1);
\r
1017 expect(from.strList()).toBeNull();
\r
1019 from.string = "+0.1";
\r
1020 expect(from.numList()[0]).toBe(0.1);
\r
1021 expect(from.strList()).toBeNull();
\r
1023 from.string = "-0.1";
\r
1024 expect(from.numList()[0]).toBe(-0.1);
\r
1025 expect(from.strList()).toBeNull();
\r
1027 from.string = "1e-1";
\r
1028 expect(from.numList()[0]).toBe(1e-1);
\r
1029 expect(from.strList()).toBeNull();
\r
1031 from.string = "1E-1";
\r
1032 expect(from.numList()[0]).toBe(1E-1);
\r
1033 expect(from.strList()).toBeNull();
\r
1035 from.string = "0,0";
\r
1036 expect(from.numList().toString()).toBe("0,0");
\r
1037 expect(from.strList().join("")).toBe(",");
\r
1039 from.string = "a00a";
\r
1040 expect(from.numList()[0]).toBe(0);
\r
1041 expect(from.strList().join("")).toBe("aa");
\r
1043 from.string = "a0b0a";
\r
1044 expect(from.numList().toString()).toBe("0,0");
\r
1045 expect(from.strList().join("")).toBe("aba");
\r
1047 from.string = "0b0a";
\r
1048 expect(from.numList().toString()).toBe("0,0");
\r
1049 expect(from.strList().join("")).toBe("ba");
\r
1051 from.string = "0b-1.0a";
\r
1052 expect(from.numList()[1]).toBe(-1);
\r
1053 expect(from.strList().join("")).toBe("ba");
\r
1055 expect(from.up().call()).toBe(from.$1.numList);
\r
1056 expect(from.$1.numList[1]).toBe(-1);
\r
1057 expect(from.$1.strList.join("")).toBe("ba");
\r
1059 from.string = "あ 0b-1.0a12";
\r
1060 expect(from.numList()[1]).toBe(-1);
\r
1061 expect(from.strList().join("")).toBe("あ ba12");
\r
1063 from.string = "0b-1.0a0";
\r
1064 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1065 expect(from.strList().join("")).toBe("ba");
\r
1067 from.string = "0b .1a";
\r
1068 expect(from.numList()[1]).toBe(0.1);
\r
1069 expect(from.strList().join("")).toBe("b a");
\r
1071 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1072 it("should be this for the value (the invalid partion)", function() {
\r
1073 from.string = NaN;
\r
1074 expect(function(){
\r
1077 expect(function(){
\r
1081 from.string = "currentColor";
\r
1082 expect(from.numList()).toEqual([]);
\r
1083 expect(from.strList()[0]).toBe("currentColor");
\r
1085 from.string = "eE";
\r
1086 expect(from.numList()).toEqual([]);
\r
1087 expect(from.strList()[0]).toBe("eE");
\r
1088 expect(from.strList()[0]).toBe("eE");
\r
1091 describe("A $to object", function() {
\r
1092 var from = base("$from");
\r
1093 beforeEach( function() {
\r
1094 from = base("$from").up();
\r
1098 /*境界条件を調べておく (limit value analysis)*/
\r
1099 it("should be this for the value (limit value analysis)", function() {
\r
1100 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1101 expect(from.up().call()).toBe(from.$1.numList);
\r
1102 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1104 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1105 it("should be this for the value (the valid partion)", function() {
\r
1107 from.$to.from = from;
\r
1108 from.$to.string = "12cm-7";
\r
1109 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1110 expect(from.$to.strList().toString()).toBe("cm");
\r
1112 from.string = "7cm+8";
\r
1114 expect(from.call()).toBe(from.numList);
\r
1115 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1116 expect(from.$to.strList.join("")).toBe("cm");
\r
1117 expect(from.numList.join(",")).toBe("7,8");
\r
1118 expect(from.strList.join("")).toBe("cm");
\r
1119 expect(from.$to.from).toBe(from.numList);
\r
1122 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1123 it("should be this for the value (the invalid partion)", function() {
\r
1125 from.up("$to").mix( function() {
\r
1126 this.string = "12cm";
\r
1129 arr.string = this.string;
\r
1130 expect(this.numList).toEqual(arr);
\r
1131 expect(this.strList).toBeNull();
\r
1135 describe("An advance method", function() {
\r
1136 var from = base("$from");
\r
1137 beforeEach( function() {
\r
1138 from = base("$from").up();
\r
1141 from.$to.from = from;
\r
1143 /*境界条件を調べておく (limit value analysis)*/
\r
1144 it("should be this for the value (limit value analysis)", function() {
\r
1145 expect(from.advance()).toBe("");
\r
1146 expect(from.$to.advance()).toBe("");
\r
1147 expect(from.$to.advance(0)).toBe("");
\r
1148 expect(from.$to.advance(1)).toBe("");
\r
1149 expect(function(){
\r
1150 from.$to.advance(1.01);
\r
1151 }).toThrow("An Invalid Number Error");
\r
1152 expect(function(){
\r
1153 from.$to.advance(-0.01);
\r
1154 }).toThrow("An Invalid Number Error");
\r
1158 from = base("$from").up();
\r
1160 from.$to.from = from;
\r
1161 arr.string = from.string = "0";
\r
1162 from.$to.string = "1";
\r
1163 expect(from.$to.call()).toBe(from.$to.numList);
\r
1164 expect(from.$to.numList[0]).toBe(1);
\r
1165 expect(from.$to.strList).toBeNull();
\r
1166 expect(from.numList[0]).toBe(0);
\r
1167 expect(from.strList).toBeNull();
\r
1168 expect(from.advance(0)).toBe("");
\r
1169 expect(from.$to.from).toBe(from.numList);
\r
1170 expect(from.$to.advance(0)).toBe("0");
\r
1171 expect(from.call()).toBe(from.numList);
\r
1173 from = base("$from").up();
\r
1174 f(from.up(), "inline", "block");
\r
1175 f(from.up(), " inline", " block ");
\r
1176 function f(from, inline, block) {
\r
1178 from.$to.from = from;
\r
1179 from.string = inline;
\r
1180 arr.string = from.$to.string = block;
\r
1181 expect(from.$to.call()).toBe(from.$to.numList);
\r
1182 expect(from.$to.numList).toEqual(arr);
\r
1183 expect(from.$to.strList).toEqual([block]);
\r
1184 arr.string = from.string;
\r
1185 expect(from.numList).toEqual(arr);
\r
1186 expect(from.strList).toEqual([inline]);
\r
1187 expect(from.advance(0)).toBe("");
\r
1188 expect(from.$to.from).toBe(from.numList);
\r
1189 expect(from.$to.advance(0)).toBe("inline");
\r
1190 expect(from.$to.advance(1)).toBe("block");
\r
1191 expect(from.call()).toBe(from.numList);
\r
1194 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1195 it("should be this for the value (the valid partion)", function() {
\r
1198 from.string = "0s";
\r
1199 from.$to.string = "1s";
\r
1200 expect(from.$to.call()).toBe(from.$to.numList);
\r
1201 expect(from.$to.numList[0]).toBe(1);
\r
1202 expect(from.$to.strList[0]).toBe("");
\r
1203 expect(from.numList[0]).toBe(0);
\r
1204 expect(from.strList[0]).toBe("");
\r
1205 expect(from.advance(0)).toBe("");
\r
1206 expect(from.$to.from).toBe(from.numList);
\r
1207 expect(from.$to.advance(0)).toBe("0s");
\r
1208 from.$to.degit = deg;
\r
1209 for (var i=0;i<1;i+=0.01) {
\r
1210 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1212 expect(from.call()).toBe(from.numList);
\r
1214 from = base("$from").up();
\r
1216 from.string = "a0S";
\r
1217 from.$to.string = "a1S";
\r
1218 from.$to.from = from;
\r
1219 expect(from.$to.call()).toBe(from.$to.numList);
\r
1220 expect(from.$to.numList[0]).toBe(1);
\r
1221 expect(from.$to.strList[0]).toBe("a");
\r
1222 expect(from.numList[0]).toBe(0);
\r
1223 expect(from.strList[0]).toBe("a");
\r
1224 expect(from.advance(0)).toBe("");
\r
1225 expect(from.$to.from).toBe(from.numList);
\r
1226 expect(from.$to.advance(0)).toBe("a0S");
\r
1228 from.$to.degit = deg;
\r
1229 for (var i=0;i<1;i+=0.01) {
\r
1230 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1232 expect(from.call()).toBe(from.numList);
\r
1234 from = base("$from").up();
\r
1235 f(from.up(), "a-10s1.5", "a10s-3");
\r
1236 f(from.up(), " a-10s1.5", " a10s-3 ");
\r
1237 function f(from, fromString, toString) {
\r
1239 from.string = fromString;
\r
1240 from.$to.string = toString;
\r
1241 from.$to.from = from;
\r
1243 from.$to.degit = 1;
\r
1244 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1245 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1246 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1248 from.$to.additive[0] = 1;
\r
1249 from.$to.accumulate[1] = 2;
\r
1250 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1251 from.$to.additive[0] = 0.5;
\r
1252 from.$to.accumulate[1] = 0.8;
\r
1253 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1256 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1257 it("should be this for the value (the invalid partion)", function() {
\r
1258 expect(function(){
\r
1259 from.$to.advance(10);
\r
1260 }).toThrow("An Invalid Number Error");
\r
1261 expect(function(){
\r
1262 from.$to.advance(-10);
\r
1263 }).toThrow("An Invalid Number Error");
\r
1267 describe("A distance method", function() {
\r
1268 var from = base("$from");
\r
1269 beforeEach( function() {
\r
1270 from = base("$from").up();
\r
1274 /*境界条件を調べておく (limit value analysis)*/
\r
1275 it("should be this for the value (limit value analysis)", function() {
\r
1276 expect(from.distance()).toBe(0)
\r
1277 expect(from.$to.distance()).toBe(0);
\r
1279 from.string = "0";
\r
1280 from.$to.string = "1";
\r
1281 expect(from.distance()).toBe(0);
\r
1282 expect(from.$to.distance(from)).toBe(1);
\r
1284 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1285 it("should be this for the value (the valid partion)", function() {
\r
1286 from.string = "s 0 s 12";
\r
1287 from.$to.string = "s 0 s 0";
\r
1288 expect(from.distance()).toBe(0);
\r
1289 expect(from.$to.distance(from)).toBe(12);
\r
1290 expect(from.$to.distance(from)).toBe(12);
\r
1291 expect(from.$to.distance(from.call())).toBe(12);
\r
1293 from = base("$from").up();
\r
1295 from.string = "rgb(1, 0, 0)";
\r
1296 from.$to.string = "rgb(0, 0, 1)";
\r
1297 expect(from.distance()).toBe(0);
\r
1298 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1300 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1301 it("should be this for the value (the invalid partion)", function() {
\r
1302 from.string = "s";
\r
1303 from.$to.string = "s";
\r
1304 expect(from.$to.distance(from)).toBe(0);
\r
1307 describe("A setAdditive method", function() {
\r
1308 var from = base("$from");
\r
1309 beforeEach( function() {
\r
1310 from = base("$from").up();
\r
1314 /*境界条件を調べておく (limit value analysis)*/
\r
1315 it("should be this for the value (limit value analysis)", function() {
\r
1316 expect(from.setAdditive()).toBe(0);
\r
1317 expect(from.setAdditive("")).toBe(0);
\r
1318 expect(from.additive).toEqual([0]);
\r
1321 expect(from.setAdditive("1")).toEqual(arr);
\r
1322 expect(from.additive).toEqual(arr);
\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 var arr = [1, 2, 3];
\r
1327 arr.string = "1 2, 3";
\r
1328 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1329 expect(from.additive).toEqual(arr);
\r
1331 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1332 it("should be this for the value (the invalid partion)", function() {
\r
1335 describe("A setAccumulate method", function() {
\r
1336 var from = base("$from");
\r
1337 beforeEach( function() {
\r
1338 from = base("$from").up();
\r
1339 from.string = "0 1";
\r
1343 /*境界条件を調べておく (limit value analysis)*/
\r
1344 it("should be this for the value (limit value analysis)", function() {
\r
1345 expect(from.setAccumulate()).toBe(0);
\r
1346 expect(from.setAccumulate(0)).toBe(0);
\r
1347 expect(from.accumulate).toEqual([0, 0]);
\r
1348 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1349 expect(from.accumulate).toEqual([0, 1]);
\r
1351 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1352 it("should be this for the value (the valid partion)", function() {
\r
1353 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1354 expect(from.accumulate).toEqual([0, 2]);
\r
1356 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1357 it("should be this for the value (the invalid partion)", function() {
\r
1358 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1361 describe("A $calcMode object", function() {
\r
1362 var calc = base("$calcMode"),
\r
1365 beforeEach( function() {
\r
1366 calc = base("$calcMode").up();
\r
1367 calc.to = base("$from").up().mix( {string: "1"} );
\r
1368 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1370 /*境界条件を調べておく (limit value analysis)*/
\r
1371 it("should be this for the value (limit value analysis)", function() {
\r
1372 expect(calc.mode).toBe("linear");
\r
1373 expect(calc.keyTime).toBe(1);
\r
1374 expect(calc.keySplines).toBeNull();
\r
1375 expect(calc.string).toBe("");
\r
1377 expect(calc.call()(0)).toBe("0");
\r
1378 expect(calc.keyTime).toBe(1);
\r
1379 expect(calc.call()(1)).toBe("1");
\r
1382 expect(calc.call()(1)).toBe("0");
\r
1385 calc.mode = "paced";
\r
1386 expect(calc.norm).toBe(1);
\r
1387 calc.to.from = from;
\r
1388 expect(calc.call()(0)).toBe("0");
\r
1389 expect(calc.keyTime).toBe(1);
\r
1390 calc.to.from = from;
\r
1391 expect(calc.call()(1)).toBe("1");
\r
1394 calc.to.from = from;
\r
1395 expect(calc.call()(1)).toBe("1");
\r
1398 calc.mode = "discrete";
\r
1399 calc.to.from = from;
\r
1401 expect(calc.call()(0)).toBe("0");
\r
1402 expect(calc.call()(1)).toBe("1");
\r
1404 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1405 it("should be this for the value (the valid partion)", function() {
\r
1406 calc.mode = "linear";
\r
1407 calc.keyTime = 0.5;
\r
1408 calc.to.degit = 1;
\r
1409 expect(calc.call()(0.2)).toBe("0.4");
\r
1410 expect(calc.call()(0.3)).toBe("0.6");
\r
1412 expect(calc.call()(0.2)).toBe("0.4");
\r
1414 calc = base("$calcMode").up();
\r
1415 calc.keyTime = 0.2;
\r
1416 calc.to = base("$from").up();
\r
1417 calc.to.from = base("$from").up();
\r
1418 calc.to.from.string = "0s";
\r
1419 calc.to.string = "1s";
\r
1420 calc.to.degit = 1;
\r
1421 expect(calc.call()(0.1)).toBe("0.5s");
\r
1423 calc = base("$calcMode").up();
\r
1424 calc.keyTime = 0.5;
\r
1425 calc.to = base("$from").up();
\r
1426 calc.to.from = base("$from").up();
\r
1427 calc.to.from.string = "rgb(100, 20, 32)";
\r
1428 calc.to.string = "rgb(0, 10, 50)";
\r
1429 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1432 calc.to = base("$from").up();
\r
1433 calc.to.from = base("$from").up();
\r
1434 calc.mode = "paced";
\r
1436 calc.to.from.string = "0s";
\r
1437 calc.to.string = "20s";
\r
1438 calc.to.degit = 1;
\r
1439 expect(calc.call()(0.1)).toBe("10.0s");
\r
1440 expect(calc.keyTime).toBe(0.2);
\r
1442 calc.to = base("$from").up();
\r
1443 calc.to.from = base("$from").up();
\r
1444 calc.mode = "paced";
\r
1446 calc.to.from.string = "rgb(0, 0, 20)";
\r
1447 calc.to.string = "rgb(0, 0, 0)";
\r
1448 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1449 expect(calc.keyTime).toBe(0.2);
\r
1452 calc.to = base("$from").up();
\r
1453 calc.to.from = base("$from").up();
\r
1454 calc.mode = "discrete";
\r
1455 calc.keyTime = 0.5;
\r
1456 calc.to.degit = 1;
\r
1457 calc.to.string = "1";
\r
1458 calc.to.from.string = "0.5";
\r
1459 expect(calc.call()(0.2)).toBe("0.5");
\r
1460 expect(calc.call()(0.3)).toBe("0.5");
\r
1462 expect(calc.call()(0.2)).toBe("0.5");
\r
1464 calc.to = base("$from").up();
\r
1465 calc.to.from = base("$from").up();
\r
1466 calc.mode = "discrete";
\r
1467 calc.keyTime = 0.5;
\r
1468 calc.to.degit = 1;
\r
1469 calc.to.string = "block";
\r
1470 calc.to.from.string = "inline";
\r
1471 expect(calc.call()(0.2)).toBe("inline");
\r
1472 expect(calc.call()(0.3)).toBe("inline");
\r
1474 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1475 it("should be this for the value (the invalid partion)", function() {
\r
1476 calc.keyTime = null;
\r
1477 expect(calc.call()(1)).toBe(calc.string);
\r
1479 calc.keyTime = void 0;
\r
1480 expect(calc.call()(1)).toBe(calc.string);
\r
1482 calc.keyTime = 1/0;
\r
1483 expect(calc.call()(1)).toBe(calc.string);
\r
1485 expect(calc.call()()).toBe(calc.string);
\r
1487 calc = base("$calcMode").up();
\r
1488 calc.mode = "paced";
\r
1489 calc.to.from = from;
\r
1490 expect(calc.call()()).toBe(calc.string);
\r
1492 calc = base("$calcMode").up();
\r
1493 calc.mode = "discrete";
\r
1494 expect(calc.call()()).toBe(calc.string);
\r
1497 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1498 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1499 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1502 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1503 return function (t) {
\r
1504 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1505 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1509 expect(calc.keySplines).toBeNull();
\r
1510 calc.mode = "spline";
\r
1511 expect( calc.call()("undef")).toBe(Math.PI);
\r
1512 calc.keySplines = [0, 0, 1, 1];
\r
1513 calc.to.degit = 1;
\r
1514 calc.to.from = from;
\r
1515 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1516 calc.to.from = from;
\r
1517 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1518 calc.to.from = from;
\r
1519 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1521 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1522 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1523 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1524 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1525 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1526 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1527 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1528 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1529 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1531 var a = y4-3*(y3-y2)-y1,
\r
1532 b = 3*(y3-2*y2+y1),
\r
1534 d = y1 - bezier.apply(null, arguments)(t);
\r
1535 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1538 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1539 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1542 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1543 return function (t) {
\r
1545 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1546 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1550 calc.mode = "spline";
\r
1551 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1552 calc.to.degit = 1;
\r
1553 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1554 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1555 calc.to.from = from;
\r
1556 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1557 calc.to.from = from;
\r
1558 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1560 var ff = function(k) {
\r
1561 calc.keySplines = k;
\r
1562 calc.to.degit = 10;
\r
1563 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1564 epsilon = 1e-5; //誤差
\r
1565 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1566 calc.to.from = from;
\r
1567 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1568 calc.to.from = from;
\r
1569 b = b(Math.random());
\r
1570 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1572 for (var i=0;i<10000;++i) {
\r
1573 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1577 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1578 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1579 calc.mode = "spline";
\r
1580 calc.keySplines = [0, NaN, 1, 1];
\r
1581 calc.to.degit = 1;
\r
1582 calc.to.from = from;
\r
1583 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1586 calc.keySplines = [0, 0, 1, 2];
\r
1587 calc.to.degit = 1;
\r
1588 calc.to.from = from;
\r
1589 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1591 calc.keySplines = null;
\r
1592 calc.to.degit = 1;
\r
1593 calc.to.from = from;
\r
1594 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1597 describe("A $attribute object", function() {
\r
1598 describe("A push method", function() {
\r
1600 beforeEach( function() {
\r
1601 attr = base("$calcMode").$attribute.up("width");
\r
1602 base("$frame").timelines.length = 0;
\r
1603 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1605 afterEach( function() {
\r
1606 attr.isCSS = false;
\r
1608 /*境界条件を調べておく (limit value analysis)*/
\r
1609 it("should be this for the value (limit value analysis)", function() {
\r
1610 expect(attr.element).toBeNull();
\r
1611 expect(attr.push()).toBeNull();
\r
1612 expect(attr.element).toBeNull();
\r
1613 expect(attr.isCSS).toBeFalsy();
\r
1614 expect(base("$frame").timelines.length).toBe(0);
\r
1616 expect(attr.push(s)).toBeNull();
\r
1617 expect(attr.element).toBeNull();
\r
1618 expect(base("$frame").timelines.length).toBe(0);
\r
1619 expect(attr.hasAttrValues()).toBeFalsy();
\r
1621 var p = document.createElement("g");
\r
1623 expect(attr.push(s)).toBeNull();
\r
1624 expect(attr.element).toBe(p);
\r
1625 expect(base("$frame").timelines.length).toBe(0);
\r
1627 s.setAttribute("end", "0");
\r
1631 check("values", 4);
\r
1632 function check(attrName, num) {
\r
1633 s.setAttribute(attrName, "1");
\r
1634 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1635 var l = attr.push(s);
\r
1636 expect(attr.element).toBe(p);
\r
1637 var timelines = base("$frame").timelines;
\r
1638 expect(timelines.length).toBe(num);
\r
1639 var line = timelines[num-1];
\r
1640 expect(line.string).toBe("0");
\r
1641 expect(line).toBe(l); //タイムラインのオブジェクトを返す
\r
1642 var act = line.$activate;
\r
1643 expect(act.dur).toBeNull();
\r
1644 expect(act.end).toBe(0);
\r
1645 expect(act.repeatCount).toBeNull();
\r
1646 expect(act.repeatDur).toBeNull();
\r
1647 expect(act.min).toBe("0");
\r
1648 expect(act.max).toBe("indefinite");
\r
1649 expect(act.simpleDur).toBeNull();
\r
1650 expect(attr.hasAttrValues()).toBeTruthy();
\r
1652 s.removeAttribute(attrName);
\r
1653 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1655 expect(attr.element).toBe(p);
\r
1656 expect(timelines.length).toBe(num);
\r
1659 /*targetElement属性のサポート*/
\r
1660 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1661 document.documentElement.appendChild(p2);
\r
1662 p2.setAttributeNS(null, "id", "p23");
\r
1663 s.setAttributeNS(null, "targetElement", "p23");
\r
1665 expect(attr.element).toBe(p2);
\r
1668 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1669 document.documentElement.appendChild(p3);
\r
1670 p3.setAttributeNS(null, "id", "p34");
\r
1671 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1673 expect(attr.element).toBe(p3);
\r
1675 /*attributeType属性のサポート*/
\r
1676 s.setAttributeNS(null, "attributeType", "CSS");
\r
1677 s.setAttributeNS(null, "values", "a;b;c");
\r
1679 expect(attr.isCSS).toBeTruthy();
\r
1681 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1682 it("should be this for the value (the valid partion )", function() {
\r
1683 s.setAttribute("from", "1");
\r
1684 var p = document.createElement("g");
\r
1686 var values = [ "0",
\r
1687 "0", null, null, null,
\r
1688 "0", "indefinite", null
\r
1691 check2("dur", "0");
\r
1692 check2("begin", "0");
\r
1694 check2("begin", "1");
\r
1696 check2("end", "0");
\r
1698 check2("repeatCount", "0");
\r
1700 check2("repeatDur", "0");
\r
1702 check2("min", "0");
\r
1704 check2("max", "0");
\r
1706 check2("begin", "12");
\r
1707 values[7] = 1000 * base("$frame").fpms;
\r
1709 check2("dur", "1");
\r
1710 function check2(attrName, value) {
\r
1711 s.setAttribute(attrName, value);
\r
1712 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1714 expect(attr.element).toBe(p);
\r
1715 var timelines = base("$frame").timelines;
\r
1716 var line = timelines[timelines.length-1];
\r
1717 expect(line.string).toBe(values[0]);
\r
1718 var act = line.$activate;
\r
1719 expect(act.dur).toBe(values[1]);
\r
1720 expect(act.end).toBe(values[2]);
\r
1721 expect(act.repeatCount).toBe(values[3]);
\r
1722 expect(act.repeatDur).toBe(values[4]);
\r
1723 expect(act.min).toBe(values[5]);
\r
1724 expect(act.max).toBe(values[6]);
\r
1725 expect(act.simpleDur).toBe(values[7]);
\r
1729 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1730 document.documentElement.appendChild(p4);
\r
1731 p4.appendChild(s);
\r
1732 p4.setAttributeNS(null, "style", "display: none");
\r
1734 expect(attr.setAttribute()).toBeUndefined();
\r
1735 expect(attr.setAttribute("block")).toBeUndefined();
\r
1736 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1737 expect(attr.isCSS).toBeFalsy();
\r
1739 s.setAttributeNS(null, "attributeName", "display");
\r
1741 expect(attr.setAttribute("block")).toBeUndefined();
\r
1742 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1743 expect(attr.isCSS).toBeTruthy();
\r
1744 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1746 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1747 document.documentElement.appendChild(p4);
\r
1748 p4.appendChild(s);
\r
1749 p4.setAttributeNS(null, "style", "display: none");
\r
1751 expect(attr.setAttribute("block")).toBeUndefined();
\r
1752 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1753 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1754 expect(attr.removeAttribute()).toBeUndefined();
\r
1755 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1756 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1758 /*attributeType属性のサポート*/
\r
1759 s.setAttributeNS(null, "values", "a;b;c");
\r
1760 s.setAttributeNS(null, "attributeName", "display");
\r
1761 attr.isCSS = false;
\r
1763 expect(attr.isCSS).toBeTruthy();
\r
1765 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1766 it("should be this for the value (the invalid partion )", function() {
\r
1767 var p = document.createElement("g");
\r
1770 s.setAttributeNS(null, "begin", "1");
\r
1772 var timelines = base("$frame").timelines;
\r
1773 expect(timelines.length).toBe(0);
\r
1774 s.setAttributeNS(null, "from", "1");
\r
1776 expect(timelines.length).toBe(1);
\r
1777 expect(attr.push(12)).toBeNull();
\r
1780 describe("A setValues method", function() {
\r
1782 beforeEach( function() {
\r
1783 attr = base("$calcMode").$attribute.up("width");
\r
1784 base("$frame").timelines.length = 0;
\r
1785 s = document.createElement("animate");
\r
1787 /*境界条件を調べておく (limit value analysis)*/
\r
1788 it("should be this for the value (limit value analysis)", function() {
\r
1789 expect(attr.$from).not.toBeUndefined();
\r
1790 expect(attr.setValues()).toBeNull();
\r
1791 expect(attr.setValues("")).toBeNull();
\r
1793 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1794 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
1795 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
1796 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
1798 /*from-to アニメーション*/
\r
1799 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1800 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
1802 /*from-by アニメーション*/
\r
1803 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1804 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1805 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1807 /*fromなしto アニメーション*/
\r
1808 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1809 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
1810 var aset = attr.setValues(null, null, "1")[0].to;
\r
1812 expect(aset.from[0]).toBe(0);
\r
1814 /*fromなしby アニメーション*/
\r
1815 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1816 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1817 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1819 expect(aset.from[0]).toBe(0);
\r
1821 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1822 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1823 attr.$from.degit = 1;
\r
1824 var setv = attr.setValues("0;1")[0].call();
\r
1825 expect(setv(0.5)).toBe("0.5");
\r
1826 expect(setv(1)).toBe("1.0");
\r
1828 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1829 expect(setv(0.5)).toBe("0.5");
\r
1830 expect(setv(1)).toBe("1.0");
\r
1831 setv = attr.setValues("0;1;2")[1].call();
\r
1832 expect(setv(0.4)).toBe("1.4");
\r
1833 expect(setv(1)).toBe("2.0");
\r
1835 attr.$from.degit = 2;
\r
1836 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
1837 expect(setv(0.5)).toBe("8.05");
\r
1838 expect(setv(1)).toBe("15.10");
\r
1840 var v = attr.setValues("1;1;2;1;1;15.1");
\r
1841 setv = v[4].mix( {
\r
1844 expect(setv(0.05)).toBe("8.05");
\r
1845 expect(setv(0.1)).toBe("15.10");
\r
1846 setv = v[3].mix( {
\r
1849 expect(setv(0.01)).toBe("1.00");
\r
1850 expect(setv(0.1)).toBe("1.00");
\r
1851 setv = v[2].mix( {
\r
1854 expect(setv(0.25)).toBe("1.50");
\r
1855 expect(setv(0.5)).toBe("1.00");
\r
1857 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1858 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1859 attr.$from.degit = 1;
\r
1860 expect(attr.setValues("")).toBeNull();
\r
1861 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
1864 describe("A setKey method", function() {
\r
1866 beforeEach( function() {
\r
1867 attr = base("$calcMode").$attribute.up("width");
\r
1868 base("$frame").timelines.length = 0;
\r
1869 s = document.createElement("animate");
\r
1870 document.createElement("g").appendChild(s);
\r
1872 /*境界条件を調べておく (limit value analysis)*/
\r
1873 it("should be this for the value (limit value analysis)", function() {
\r
1874 expect(attr.setKey(s)).toBeNull();
\r
1876 s.setAttributeNS(null, "from", "0");
\r
1878 s.setAttributeNS(null, "to", "0");
\r
1879 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1880 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
1881 s.setAttributeNS(null, "by", "0");
\r
1883 s.setAttributeNS(null, "values", "0;2");
\r
1884 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1885 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
1887 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
1888 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1890 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
1891 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1892 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1893 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1894 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1896 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
1897 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1898 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1899 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1900 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1902 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1903 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1904 s.setAttributeNS(null, "values", "0;2;12;30");
\r
1905 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
1906 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1907 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1908 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1909 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1910 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
1911 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
1912 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1913 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1914 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1916 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
1917 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1918 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1919 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1921 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
1922 f(0, 0,0.1,0.3,1);
\r
1923 f(1, 0.1,0.4,0.5,0.7);
\r
1924 f(2, 0.2,0.2,0.1,1);
\r
1926 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
1927 f(0, 0,0.1,0.3,1);
\r
1928 f(1, 0.1,0.4,0.5,0.7);
\r
1929 f(2, 0.2,0.2,0.1,1);
\r
1931 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
1932 f(0, 0,0.1,0.333,1);
\r
1933 f(1, 0.1,0.4,0.5,0.7);
\r
1934 f(2, 0.2,0.2,0.1,1);
\r
1935 function f (i, a, b, c, d) {
\r
1936 var splines = attr.setKey(s)[i].keySplines;
\r
1937 expect(splines[0]).toBe(a);
\r
1938 expect(splines[1]).toBe(b);
\r
1939 expect(splines[2]).toBe(c);
\r
1940 expect(splines[3]).toBe(d);
\r
1943 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1944 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1945 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1946 expect(attr.setKey(s)).toBeNull();
\r
1947 s.setAttributeNS(null, "values", "0;2;12");
\r
1948 expect(attr.setKey(s)).toBeNull();
\r
1949 s.setAttributeNS(null, "values", "0;2;12;20");
\r
1950 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
1951 expect(attr.setKey(s)).toBeNull();
\r
1955 describe("A $setElement object", function() {
\r
1956 describe("A timeline property", function() {
\r
1957 var $set, ele, frame;
\r
1958 beforeEach( function() {
\r
1959 $set = base("$calcMode").$attribute.$setElement.up();
\r
1960 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1961 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1962 p.appendChild(ele);
\r
1963 frame = base("$frame");
\r
1965 /*境界条件を調べておく (limit value analysis)*/
\r
1966 it("should be this for the value (limit value analysis)", function() {
\r
1967 expect($set.timeline).toBe(frame.$begin);
\r
1970 expect($set.timeline).toBe(frame.$begin);
\r
1971 expect($set.element).toBeNull();
\r
1974 describe("An init method", function() {
\r
1975 var $set, ele, frame;
\r
1976 beforeEach( function() {
\r
1977 $set = base("$calcMode").$attribute.$setElement.up();
\r
1978 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1979 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1980 p.appendChild(ele);
\r
1981 frame = base("$frame");
\r
1983 /*境界条件を調べておく (limit value analysis)*/
\r
1984 it("should be this for the value (limit value analysis)", function() {
\r
1985 expect($set.to).toBe("");
\r
1986 expect($set.attrName).toBe("");
\r
1987 expect($set.defaultValue).toBe("");
\r
1988 expect($set.isDefault).toBeFalsy();
\r
1989 expect($set.attrNameSpace).toBeNull();
\r
1991 expect($set.timeline).toBe(frame.$begin);
\r
1993 expect($set.to).toBe("");
\r
1994 expect($set.attrName).toBe("");
\r
1995 expect($set.isDefault).toBeFalsy();
\r
1996 expect($set.attrNameSpace).toBeNull();
\r
1997 expect($set.timeline).toBe(frame.$begin);
\r
1999 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2000 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2001 ele.setAttributeNS(null, "to", "t1");
\r
2003 expect($set.to).toBe("t1");
\r
2004 expect($set.attrName).toBe("");
\r
2005 expect($set.defaultValue).toBe("");
\r
2007 ele.setAttributeNS(null, "attributeName", "tt1");
\r
2009 expect($set.to).toBe("t1");
\r
2010 expect($set.attrName).toBe("tt1");
\r
2011 expect($set.defaultValue).toBe("");
\r
2013 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
2015 expect($set.defaultValue).toBe("undef");
\r
2016 expect($set.isDefault).toBeTruthy();
\r
2018 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2019 ele.parentNode.style.setProperty("font-size", "12px");
\r
2021 expect($set.defaultValue).toBe("12px");
\r
2022 expect($set.isDefault).toBeFalsy();
\r
2024 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2026 expect($set.to).toBe("t1");
\r
2027 expect($set.attrName).toBe("xlink:href");
\r
2028 expect($set.defaultValue).toBe("");
\r
2029 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2031 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2033 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2034 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2036 expect($set.to).toBe("");
\r
2037 expect($set.attrName).toBe("");
\r
2038 expect($set.defaultValue).toBe("");
\r
2041 expect($set.to).toBe("");
\r
2042 expect($set.attrName).toBe("");
\r
2043 expect($set.defaultValue).toBe("");
\r
2046 describe("Frame Set", function() {
\r
2047 var $set, ele, frame;
\r
2048 beforeEach( function() {
\r
2049 $set = base("$calcMode").$attribute.$setElement.up();
\r
2050 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2051 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2052 p.appendChild(ele);
\r
2053 frame = base("$frame");
\r
2054 frame.timelines.length = frame.$endFrame.timelines.length = 0; //配列の初期化
\r
2055 frame.startTime = Date.now();
\r
2056 frame.setFrame(0);
\r
2057 frame.$endFrame.setFrame(0);
\r
2059 afterEach( function() {
\r
2060 $set.isCSS = false;
\r
2062 /*境界条件を調べておく (limit value analysis)*/
\r
2063 it("should be this for the value (limit value analysis)", function() {
\r
2064 expect($set.isEnd).toBeFalsy();
\r
2065 expect($set.state).toBe("idling");
\r
2066 ele.setAttributeNS(null, "dur", "1s");
\r
2067 ele.setAttributeNS(null, "attributeName", "fill");
\r
2068 ele.setAttributeNS(null, "to", "red");
\r
2070 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2071 $set.isCSS = false;
\r
2072 expect($set.timeline).not.toBe(frame.$begin);
\r
2073 frame.setFrame(0);
\r
2074 frame.$endFrame.setFrame(0);
\r
2075 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2076 expect($set.state).toBe("playing");
\r
2078 frame.setFrame(24);
\r
2079 frame.$endFrame.setFrame(24);
\r
2080 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2081 expect($set.state).toBe("idling");
\r
2083 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2084 it("should be this for the value (the valid partion)", function() {
\r
2085 ele.setAttributeNS(null, "begin", "1s");
\r
2086 ele.setAttributeNS(null, "dur", "1s");
\r
2087 ele.setAttributeNS(null, "attributeName", "fill");
\r
2088 ele.setAttributeNS(null, "to", "red");
\r
2090 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2091 $set.isCSS = false;
\r
2092 var f = function(num) {
\r
2093 frame.setFrame(num);
\r
2094 frame.$endFrame.setFrame(num);
\r
2095 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2100 frame.setFrame(24);
\r
2101 frame.$endFrame.setFrame(24);
\r
2102 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2103 frame.setFrame(25);
\r
2104 frame.$endFrame.setFrame(25);
\r
2105 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2109 ele.setAttributeNS(null, "fill", "freeze");
\r
2111 $set.isCSS = false;
\r
2115 frame.setFrame(24);
\r
2116 frame.$endFrame.setFrame(24);
\r
2117 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2118 frame.setFrame(25);
\r
2119 frame.$endFrame.setFrame(25);
\r
2120 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2121 frame.setFrame(48);
\r
2122 frame.$endFrame.setFrame(48);
\r
2123 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2124 frame.setFrame(49);
\r
2125 frame.$endFrame.setFrame(49);
\r
2126 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2127 ele.setAttributeNS(null, "begin", "1s");
\r
2128 ele.setAttributeNS(null, "attributeName", "fill");
\r
2129 ele.setAttributeNS(null, "to", "red");
\r
2130 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2132 $set.isCSS = false;
\r
2133 var f = function(num) {
\r
2134 frame.setFrame(num);
\r
2135 frame.$endFrame.setFrame(num);
\r
2136 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2144 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2145 it("should be this for the value (the invalid partion)", function() {
\r
2150 describe("A $animateElement object", function() {
\r
2151 describe("An init method", function() {
\r
2152 var $animate, ele, frame;
\r
2153 beforeEach( function() {
\r
2154 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2155 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2156 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2157 p.appendChild(ele);
\r
2158 frame = base("$frame");
\r
2159 frame.timelines.length = 0;
\r
2160 frame.startTime = Date.now();
\r
2161 frame.setFrame(0);
\r
2162 frame.$endFrame.setFrame(0);
\r
2164 /*境界条件を調べておく (limit value analysis)*/
\r
2165 it("should be this for the value (limit value analysis)", function() {
\r
2168 ele.setAttributeNS(null, "begin", "1s");
\r
2169 ele.setAttributeNS(null, "dur", "1s");
\r
2170 ele.setAttributeNS(null, "attributeName", "d");
\r
2171 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2172 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2173 $animate.init(ele);
\r
2174 expect($animate.isCSS).toBeFalsy();
\r
2175 frame.setFrame(0);
\r
2176 frame.$endFrame.setFrame(0);
\r
2177 var p = ele.parentNode;
\r
2178 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2179 * 他のブラウザではnullを返すため、その対策をする*/
\r
2180 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2182 function f(fr, result) {
\r
2183 frame.setFrame(fr);
\r
2184 frame.$endFrame.setFrame(fr);
\r
2185 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2188 f(24, "M20.0 0.0 L20.0 30.0");
\r
2189 f(36, "M20.0 10.0 L15.0 30.0");
\r
2192 ele.setAttributeNS(null, "fill", "freeze");
\r
2193 $animate.init(ele);
\r
2194 f(24, "M20.0 0.0 L20.0 30.0");
\r
2195 f(36, "M20.0 10.0 L15.0 30.0");
\r
2196 f(48, "M20.0 20.0 L10.0 30.0");
\r
2198 frame.timelines.length = 0;
\r
2199 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2200 $animate.init(ele);
\r
2201 expect($animate.isCSS).toBeFalsy();
\r
2202 expect($animate.mode).toBe("discrete");
\r
2203 f(24, "M20.0 0.0 L20.0 30.0");
\r
2204 f(25, "M20.0 0.0 L20.0 30.0");
\r
2205 f(37, "M20.0 20.0 L10.0 30.0");
\r
2206 f(48, "M20.0 20.0 L10.0 30.0");
\r
2208 [ ["display", "inline", "none"],
\r
2209 ["visibility", "hidden", "visible"],
\r
2210 ["stroke-linecap", "round", "square"],
\r
2211 ["font-style", "italic", "normal"]
\r
2212 ].forEach( function(attr) {
\r
2213 var attrName = attr[0],
\r
2216 function g(fr, result) {
\r
2217 frame.setFrame(fr);
\r
2218 frame.$endFrame.setFrame(fr);
\r
2219 expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);
\r
2223 ele.setAttributeNS(null, "from", from);
\r
2224 ele.setAttributeNS(null, "to", to);
\r
2225 frame.timelines.length = 0;
\r
2226 ele.setAttributeNS(null, "calcMode", "linear");
\r
2227 ele.setAttributeNS(null, "attributeName", attrName);
\r
2228 $animate.init(ele);
\r
2229 expect($animate.mode).toBe("discrete");
\r
2236 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2237 it("should be this for the value (the valid partion )", function() {
\r
2239 ele.setAttributeNS(null, "begin", "0s");
\r
2240 ele.setAttributeNS(null, "dur", "100s");
\r
2241 ele.setAttributeNS(null, "attributeName", "d");
\r
2242 ele.setAttributeNS(null, "fill", "freeze");
\r
2243 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2244 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2245 $animate.init(ele);
\r
2247 var p = ele.parentNode;
\r
2248 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2250 function f(fr, result) {
\r
2251 frame.setFrame(fr);
\r
2252 frame.$endFrame.setFrame(fr);
\r
2253 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2256 for (var i=0;i<2400;++i) {
\r
2257 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2259 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2262 frame.timelines.length = 0;
\r
2263 ele.setAttributeNS(null, "begin", "0s");
\r
2264 ele.setAttributeNS(null, "dur", "1s");
\r
2265 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2266 ele.setAttributeNS(null, "attributeName", "d");
\r
2267 ele.setAttributeNS(null, "fill", "freeze");
\r
2268 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2269 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2270 $animate.init(ele);
\r
2271 f(23, "M20.0 23.0 L20.0 30.0");
\r
2272 f(24, "M20.0 0.0 L20.0 30.0");
\r
2273 f(25, "M20.0 1.0 L20.0 30.0");
\r
2274 f(48, "M20.0 24.0 L20.0 30.0");
\r
2276 frame.timelines.length = 0;
\r
2277 ele.setAttributeNS(null, "begin", "0s");
\r
2278 ele.setAttributeNS(null, "dur", "2s");
\r
2279 ele.setAttributeNS(null, "attributeName", "d");
\r
2280 ele.setAttributeNS(null, "fill", "freeze");
\r
2281 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2282 $animate.init(ele);
\r
2283 f(0, "M20.0 0.0 L20.0 30.0");
\r
2284 f(1, "M20.0 1.0 L20.0 30.0");
\r
2285 f(24, "M20.0 24.0 L20.0 30.0");
\r
2286 f(25, "M20.0 24.1 L20.0 30.0");
\r
2287 f(47, "M20.0 26.3 L20.0 30.0");
\r
2288 f(48, "M20.0 26.4 L20.0 30.0");
\r
2289 f(49, "M20.0 26.4 L20.0 30.0");
\r
2290 f(50, "M20.0 26.4 L20.0 30.0");
\r
2292 frame.timelines.length = 0;
\r
2293 ele.setAttributeNS(null, "begin", "0s");
\r
2294 ele.setAttributeNS(null, "end", "2s");
\r
2295 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2296 ele.removeAttributeNS(null, "repeatDur");
\r
2297 ele.setAttributeNS(null, "attributeName", "d");
\r
2298 ele.setAttributeNS(null, "fill", "freeze");
\r
2299 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2300 $animate.init(ele);
\r
2301 f(0, "M20.0 0.0 L20.0 30.0");
\r
2302 f(1, "M20.0 0.0 L20.0 30.0");
\r
2303 f(24, "M20.0 0.0 L20.0 30.0");
\r
2304 f(25, "M20.0 0.0 L20.0 30.0");
\r
2305 f(47, "M20.0 0.0 L20.0 30.0");
\r
2306 f(48, "M20.0 0.0 L20.0 30.0");
\r
2307 f(49, "M20.0 0.0 L20.0 30.0");
\r
2308 f(50, "M20.0 0.0 L20.0 30.0");
\r
2310 frame.timelines.length = 0;
\r
2311 ele.setAttributeNS(null, "dur", "2s");
\r
2312 ele.setAttributeNS(null, "fill", "remove");
\r
2313 var attrValue = p.getAttributeNS(null, "d");
\r
2314 $animate.init(ele);
\r
2317 frame.timelines.length = 0;
\r
2318 p.removeAttributeNS(null, "d");
\r
2319 ele.setAttributeNS(null, "fill", "freeze");
\r
2320 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2321 $animate.init(ele);
\r
2322 f(1, "M20.0 5.0 L20.0 30.0");
\r
2323 f(48, "M20.0 26.4 L20.0 30.0");
\r
2325 frame.timelines.length = 0;
\r
2326 ele.setAttributeNS(null, "fill", "freeze");
\r
2327 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2328 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2329 $animate.init(ele);
\r
2330 f(1, "M20.0 0.0 L20.0 30.0");
\r
2331 f(4, "M20.0 0.0 L20.0 30.0");
\r
2332 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2334 f(24, "M20.0 24.0 L20.0 30.0");
\r
2335 f(25, "M20.0 24.0 L20.0 30.0");
\r
2336 f(29, "M20.0 26.4 L20.0 30.0");
\r
2337 f(48, "M20.0 26.4 L20.0 30.0");
\r
2339 frame.timelines.length = 0;
\r
2340 ele.setAttributeNS(null, "calcMode", "spline");
\r
2341 ele.removeAttributeNS(null, "keyTimes");
\r
2342 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2343 ele.removeAttributeNS(null, "end");
\r
2344 ele.setAttributeNS(null, "dur", "9s");
\r
2345 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2346 $animate.init(ele);
\r
2353 frame.timelines.length = 0;
\r
2354 ele.setAttributeNS(null, "calcMode", "spline");
\r
2355 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2356 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2357 ele.setAttributeNS(null, "dur", "8s");
\r
2358 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2359 $animate.init(ele);
\r
2367 frame.timelines.length = 0;
\r
2368 ele.setAttributeNS(null, "begin", "click");
\r
2369 ele.setAttributeNS(null, "calcMode", "spline");
\r
2370 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2371 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2372 ele.setAttributeNS(null, "dur", "8s");
\r
2373 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2374 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2375 $animate.init(ele);
\r
2382 ( function(attrName) {
\r
2383 function g(fr, result) {
\r
2384 frame.setFrame(fr);
\r
2385 frame.$endFrame.setFrame(fr);
\r
2386 expect(p.style.getPropertyValue(attrName)).toBe(result);
\r
2389 frame.timelines.length = 0;
\r
2390 ele.setAttributeNS(null, "begin", "0s");
\r
2391 ele.setAttributeNS(null, "calcMode", "linear");
\r
2392 ele.setAttributeNS(null, "attributeName", attrName);
\r
2393 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2394 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2395 ele.setAttributeNS(null, "dur", "8s");
\r
2396 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2397 $animate.init(ele);
\r
2398 expect($animate.mode).toBe("discrete");
\r
2405 frame.timelines.length = 0;
\r
2406 ele.setAttributeNS(null, "begin", "click");
\r
2407 ele.setAttributeNS(null, "calcMode", "linear");
\r
2408 ele.setAttributeNS(null, "attributeName", attrName);
\r
2409 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2410 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2411 ele.setAttributeNS(null, "dur", "8s");
\r
2412 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2413 $animate.init(ele);
\r
2414 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2415 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2416 p.dispatchEvent(evt);
\r
2417 var cur = base("$frame").currentFrame;
\r
2418 expect($animate.mode).toBe("discrete");
\r
2419 g(cur+0, "inline");
\r
2420 g(cur+48, "block");
\r
2421 g(cur+96, "inline");
\r
2422 g(cur+192, "block");
\r
2423 g(cur+300, "block");
\r
2426 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2427 it("should be this for the value (the invalid partion )", function() {
\r
2428 ele.setAttributeNS(null, "begin", "0s");
\r
2429 ele.setAttributeNS(null, "dur", "100s");
\r
2430 ele.setAttributeNS(null, "attributeName", "d");
\r
2431 ele.setAttributeNS(null, "fill", "freeze");
\r
2432 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2433 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2434 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2435 $animate.init(ele);
\r
2437 var p = ele.parentNode;
\r
2438 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2440 function f(fr, result) {
\r
2441 frame.setFrame(fr);
\r
2442 frame.$endFrame.setFrame(fr);
\r
2443 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2448 frame.timelines.length = 0;
\r
2449 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2450 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2451 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2452 $animate.init(ele);
\r
2456 /*keyTimes属性が0から始まっていない*/
\r
2457 frame.timelines.length = 0;
\r
2458 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2462 function ff(mode) {
\r
2463 ele.setAttributeNS(null, "calcMode", mode);
\r
2464 $animate.init(ele);
\r
2469 frame.timelines.length = 0;
\r
2470 ele.setAttributeNS(null, "calcMode", "spline");
\r
2471 $animate.init(ele);
\r
2472 expect($animate.mode).toBe("spline");
\r
2478 describe("RGB Color", function() {
\r
2479 var $animate, ele, frame, f;
\r
2480 beforeEach( function() {
\r
2481 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2482 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2483 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2484 p.appendChild(ele);
\r
2485 frame = base("$frame");
\r
2486 frame.timelines.length = 0;
\r
2488 f = function (fr, result, attr) {
\r
2489 frame.setFrame(fr);
\r
2490 frame.$endFrame.setFrame(fr);
\r
2491 expect(p.style.getPropertyValue(attr)).toBe(result);
\r
2494 /*境界条件を調べておく (limit value analysis)*/
\r
2495 it("should be this for the value (limit value analysis)", function() {
\r
2496 ele.setAttributeNS(null, "begin", "0s");
\r
2497 ele.setAttributeNS(null, "dur", "1s");
\r
2498 ele.setAttributeNS(null, "attributeName", "fill");
\r
2499 ele.setAttributeNS(null, "fill", "remove");
\r
2500 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2501 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2502 $animate.init(ele);
\r
2504 f(0, "rgb(0, 0, 0)", "fill");
\r
2505 f(23, "rgb(10, 10, 1)", "fill");
\r
2507 frame.timelines.length = 0;
\r
2508 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2509 $animate.init(ele);
\r
2510 f(0, "rgb(0, 0, 0)", "stroke");
\r
2511 f(23, "rgb(10, 10, 1)", "stroke");
\r
2513 frame.timelines.length = 0;
\r
2514 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2515 $animate.init(ele);
\r
2516 f(0, "rgb(0,0,0)", "stop-color");
\r
2517 f(23, "rgb(10,10,1)", "stop-color");
\r
2519 frame.timelines.length = 0;
\r
2520 ele.setAttributeNS(null, "attributeName", "color");
\r
2521 $animate.init(ele);
\r
2522 f(0, "rgb(0,0,0)", "color");
\r
2523 f(23, "rgb(10,10,1)", "color");
\r
2525 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2526 it("should be this for the value (the valid partion )", function() {
\r
2527 ele.setAttributeNS(null, "begin", "0s");
\r
2528 ele.setAttributeNS(null, "dur", "1s");
\r
2529 ele.setAttributeNS(null, "attributeName", "fill");
\r
2530 ele.setAttributeNS(null, "fill", "remove");
\r
2531 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2532 $animate.init(ele);
\r
2534 f(0, "rgb(0, 0, 0)", "fill");
\r
2535 f(1, "rgb(1, 0, 0)", "fill");
\r
2536 f(23, "rgb(23, 2, 1)", "fill");
\r
2538 frame.timelines.length = 0;
\r
2539 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2540 $animate.init(ele);
\r
2543 f(0, "rgb(0, 8, 60)", "fill");
\r
2544 f(1, "rgb(1, 9, 60)", "fill");
\r
2545 f(23, "rgb(23, 31, 60)", "fill");
\r
2547 frame.timelines.length = 0;
\r
2548 ele.setAttributeNS(null, "fill", "freeze");
\r
2549 ele.setAttributeNS(null, "values", "black;white");
\r
2550 $animate.init(ele);
\r
2551 /*色キーワードをrgb形式に変換*/
\r
2553 f(0, "rgb(0, 0, 0)", "fill");
\r
2554 f(12, "rgb(128, 128, 128)", "fill");
\r
2555 f(24, "rgb(255, 255, 255)", "fill");
\r
2557 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2558 it("should be this for the value (the invalid partion )", function() {
\r
2559 ele.setAttributeNS(null, "begin", "0s");
\r
2560 ele.setAttributeNS(null, "dur", "1s");
\r
2561 ele.setAttributeNS(null, "attributeName", "fi");
\r
2562 ele.setAttributeNS(null, "fill", "remove");
\r
2563 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2564 $animate.init(ele);
\r
2567 function f (fr, result, attr) {
\r
2568 frame.setFrame(fr);
\r
2569 frame.$endFrame.setFrame(fr);
\r
2570 expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);
\r
2572 f(0, "#83.0C", "fi");
\r
2573 f(1, "#84.0C", "fi");
\r
2574 f(23, "#106.0C", "fi");
\r
2577 describe("$frame.$svgEvent object", function() {
\r
2578 var frame = base("$frame").$svgEvent,
\r
2580 base("$frame").pauseAnimation();
\r
2581 beforeEach( function() {
\r
2582 base("$frame").pauseAnimation();
\r
2583 frame = frame.up();
\r
2584 frame.first = null;
\r
2585 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2586 * 影響を受けるため、新たに初期化しておく*/
\r
2587 base("$frame").timelines = frame.timelines = [];
\r
2588 frame.lastTimeLine = null;
\r
2589 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2590 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2591 p.appendChild(ele);
\r
2593 /*境界条件を調べておく (limit value analysis)*/
\r
2594 it("should be this for the value (limit value analysis)", function() {
\r
2595 base("$frame").pauseAnimation();
\r
2596 frame.lastTimeLine = null;
\r
2597 expect(frame.lastTimeLine).toBeNull();
\r
2598 expect(frame.first).toBeNull();
\r
2599 frame.setTimeTable();
\r
2600 expect(frame.first).toBeNull();
\r
2601 frame.addLine( base("$frame").$begin.up().mix({
\r
2607 frame.setTimeTable();
\r
2608 expect(frame.first).toEqual(
\r
2610 eventType: "begin",
\r
2621 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2622 it("should be this for the value (the valid partion )", function() {
\r
2623 base("$frame").pauseAnimation();
\r
2624 frame.addLine( base("$frame").$begin.up().mix({
\r
2630 frame.setTimeTable();
\r
2631 frame.setTimeTable();
\r
2632 expect(frame.first).toEqual(
\r
2634 eventType: "begin",
\r
2644 frame.setTimeTable();
\r
2645 frame.setTimeTable();
\r
2646 expect(frame.first).toEqual(
\r
2648 eventType: "begin",
\r
2659 var isFiredBeginEvent = false;
\r
2660 ele.addEventListener("beginEvent", function(evt) {
\r
2661 isFiredBeginEvent = true;
\r
2662 expect(evt.target).toBe(ele);
\r
2664 ele.addEventListener("endEvent", function(evt) {
\r
2665 expect(evt.target).toBe(ele);
\r
2666 expect(isFiredBeginEvent).toBeTruthy();
\r
2668 frame.setFrame(0);
\r
2669 frame.$endFrame.setFrame(0);
\r
2670 expect(frame.first).toBeNull();
\r
2671 frame.setFrame(0);
\r
2672 frame.$endFrame.setFrame(0);
\r
2673 expect(frame.first).toBeNull();
\r
2675 frame.timelines = [];
\r
2676 frame.addLine( base("$frame").$begin.up().mix({
\r
2682 frame.setTimeTable();
\r
2683 var a = { frame: 0,
\r
2684 eventType: "begin",
\r
2687 next: { frame: 10,
\r
2693 expect(frame.first).toEqual(a);
\r
2695 frame.addLine( base("$frame").$begin.up().mix({
\r
2698 simpleDuration: 9,
\r
2702 frame.setTimeTable();
\r
2703 a.next.next = { frame: 1,
\r
2704 eventType: "begin",
\r
2707 next: { firstFrame: 10,
\r
2709 eventType: "repeat",
\r
2712 simpleDuration: 9,
\r
2715 next: { frame: 12,
\r
2722 expect(frame.first).toEqual(a);
\r
2723 frame.setFrame(11);
\r
2724 frame.$endFrame.setFrame(11);
\r
2725 expect(frame.first).toEqual( {frame: 12,
\r
2731 frame.timelines = [];
\r
2732 frame.first = null;
\r
2733 frame.addLine( base("$frame").$begin.up().mix({
\r
2736 simpleDuration: 4,
\r
2740 frame.setTimeTable();
\r
2742 eventType: "begin",
\r
2745 next: {firstFrame:5,
\r
2747 eventType: "repeat",
\r
2750 simpleDuration: 4,
\r
2753 next: { frame: 11,
\r
2760 expect(frame.first).toEqual(a);
\r
2761 frame.setFrame(0);
\r
2762 frame.$endFrame.setFrame(0);
\r
2763 expect(frame.first).toEqual(a);
\r
2764 frame.setFrame(1);
\r
2765 frame.$endFrame.setFrame(1);
\r
2767 expect(frame.first).toEqual(a);
\r
2768 frame.setFrame(5);
\r
2769 frame.$endFrame.setFrame(5);
\r
2772 expect(frame.first).toEqual(a);
\r
2774 ele.addEventListener("repeatEvent", function(evt) {
\r
2775 expect(evt.target).toBe(ele);
\r
2777 frame.timelines = [];
\r
2778 frame.first = null;
\r
2779 frame.addLine( base("$frame").$begin.up().mix({
\r
2782 simpleDuration: 4,
\r
2786 frame.setFrame(9);
\r
2787 frame.$endFrame.setFrame(9);
\r
2790 a.next.frame = 16;
\r
2791 expect(frame.first).toEqual(a);
\r
2793 afterEach( function() {
\r
2794 base("$frame").startAnimation();
\r
2797 describe("A $animateTransformElemenet object", function() {
\r
2798 describe("An init method", function() {
\r
2799 var $animate, ele, frame, p;
\r
2800 beforeEach( function() {
\r
2801 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2802 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2803 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2804 p.appendChild(ele);
\r
2805 frame = base("$frame");
\r
2806 frame.timelines.length = 0;
\r
2807 frame.startTime = Date.now();
\r
2808 frame.setFrame(0);
\r
2809 frame.$endFrame.setFrame(0);
\r
2811 afterEach( function() {
\r
2812 $animate.numberOfList = -1;
\r
2814 /*境界条件を調べておく (limit value analysis)*/
\r
2815 it("should be this for the value (limit value analysis)", function() {
\r
2816 expect($animate.numberOfList).toBe(-1);
\r
2817 expect($animate.type).toBe("translate");
\r
2818 expect(p.__transformList).toBeUndefined();
\r
2819 expect($animate.isCSS).toBeFalsy();
\r
2820 expect($animate.isSum).toBeFalsy();
\r
2823 expect($animate.numberOfList).toBe(-1);
\r
2824 expect(p.__transformList).toBeUndefined();
\r
2825 expect($animate.type).toBe("translate");
\r
2828 expect($animate.numberOfList).toBe(-1);
\r
2829 expect(p.__transformList).toBeUndefined();
\r
2830 expect($animate.type).toBe("translate");
\r
2832 $animate.init(ele);
\r
2833 expect($animate.numberOfList).toBe(-1);
\r
2834 expect(p.__transformList).toEqual([]);
\r
2836 ele.setAttributeNS(null, "values", "0;1");
\r
2837 $animate.init(ele);
\r
2838 expect($animate.type).toBe("translate");
\r
2839 expect($animate.numberOfList).toBe(0);
\r
2840 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2841 value: "translate(0)",
\r
2845 ele.setAttributeNS(null, "type", "translate");
\r
2846 $animate.init(ele);
\r
2847 expect($animate.numberOfList).toBe(0);
\r
2848 expect($animate.type).toBe("translate");
\r
2849 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2850 value: "translate(0)",
\r
2853 $animate.tocall(0);
\r
2854 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2856 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2857 $animate.numberOfList = -1;
\r
2858 $animate.init(ele.parentNode.lastChild);
\r
2859 expect($animate.numberOfList).toBe(1);
\r
2860 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2861 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2863 expect($animate.type).toBe("translate");
\r
2864 $animate.tocall(0);
\r
2865 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2866 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2867 $animate._setEndFrame(1);
\r
2868 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2869 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2871 delete p.__transformList;
\r
2872 ele.setAttributeNS(null, "type", "scale");
\r
2873 $animate.numberOfList = -1;
\r
2874 $animate.init(ele);
\r
2875 expect($animate.numberOfList).toBe(0);
\r
2876 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2877 value: "translate(0)",
\r
2880 expect($animate.type).toBe("scale");
\r
2882 delete p.__transformList;
\r
2883 $animate.numberOfList = -1;
\r
2884 ele.setAttributeNS(null, "additive", "sum");
\r
2885 $animate.init(ele);
\r
2886 expect($animate.isSum).toBeTruthy();
\r
2887 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2888 value: "translate(0)",
\r
2891 delete p.__transformList;
\r
2892 $animate.numberOfList = -1;
\r
2893 ele.setAttributeNS(null, "additive", "replace");
\r
2894 $animate.init(ele);
\r
2895 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2896 value: "translate(0)",
\r
2900 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2901 it("should be this for the value (the valid partion )", function() {
\r
2902 ele.setAttributeNS(null, "type", "scale");
\r
2903 ele.setAttributeNS(null, "values", "0;1");
\r
2904 $animate.init(ele);
\r
2905 expect($animate.numberOfList).toBe(0);
\r
2906 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2907 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
2908 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
2909 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2911 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2912 $animate.numberOfList = -1;
\r
2913 $animate.init(ele.parentNode.lastChild);
\r
2914 expect($animate.numberOfList).toBe(1);
\r
2915 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2916 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2918 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2919 $animate.up("$a").numberOfList = -1;
\r
2920 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2921 $animate.$a.init(ele.parentNode.lastChild);
\r
2922 expect($animate.$a.numberOfList).toBe(2);
\r
2923 expect($animate.$a.isDefault).toBeTruthy();
\r
2924 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2925 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
2926 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
2927 $animate.defaultValue = $animate.$a.defaultValue;
\r
2928 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
2930 ele.setAttributeNS(null, "additive", "sum");
\r
2931 var parentNode = ele.parentNode;
\r
2932 parentNode.appendChild(ele.cloneNode(true));
\r
2933 parentNode.__transformList = [];
\r
2934 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
2935 parentNode.removeChild(ele);
\r
2936 $animate.numberOfList = -1;
\r
2937 $animate.init(parentNode.lastChild);
\r
2938 expect($animate.numberOfList).toBe(0);
\r
2939 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2940 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2942 parentNode.appendChild(ele.cloneNode(true));
\r
2943 $animate.up("$a").numberOfList = -1;
\r
2944 parentNode.__transformList = [];
\r
2945 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2946 $animate.$a.init(parentNode.lastChild);
\r
2947 expect($animate.$a.numberOfList).toBe(0);
\r
2948 expect($animate.$a.isDefault).toBeTruthy();
\r
2949 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2950 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2951 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2952 $animate.defaultValue = $animate.$a.defaultValue;
\r
2953 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
2955 ele.removeAttributeNS(null, "additive");
\r
2956 ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",
\r
2957 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
2958 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
2959 "scale(0.0)", "scale(1.0)");
\r
2960 function ad(first, second, a, b, c, d) {
\r
2962 while (parentNode.firstChild) {
\r
2963 parentNode.removeChild(parentNode.firstChild);
\r
2966 /*additive属性のreplaceとsumの混合*/
\r
2967 ele.setAttributeNS(null, "additive", first);
\r
2968 parentNode.appendChild(ele.cloneNode(true));
\r
2969 ele.setAttributeNS(null, "additive", second);
\r
2970 parentNode.appendChild(ele.cloneNode(true));
\r
2971 parentNode.__transformList = [];
\r
2972 $animate.numberOfList = -1;
\r
2973 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2974 $animate.up("$first").init(parentNode.firstChild);
\r
2975 $animate.up("$second").init(parentNode.lastChild);
\r
2976 expect($animate.$first.numberOfList).toBe(0);
\r
2977 expect($animate.$second.numberOfList).toBe(1);
\r
2978 expect($animate.$first.tocall(0)).toBe(a);
\r
2979 expect($animate.$second.tocall(0)).toBe(b);
\r
2980 expect($animate.$first.tocall(1)).toBe(c);
\r
2981 expect($animate.$second.tocall(1)).toBe(d);
\r
2984 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2985 it("should be this for the value (the invalid partion )", function() {
\r
2986 $animate.init(ele);
\r
2987 ele.parentNode.__transformList = null;
\r
2988 expect( function () {
\r
2989 $animate.tocall(0);
\r
2992 $animate.numberOfList = -1;
\r
2993 $animate.init(ele);
\r
2994 $animate.numberOfList = -1;
\r
2995 expect( function () {
\r
2996 $animate.tocall(0);
\r
3001 describe("A $motionElement object", function() {
\r
3002 describe("An init method", function() {
\r
3003 var $animate, ele, frame, p;
\r
3004 beforeEach( function() {
\r
3005 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3006 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3007 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3008 p.appendChild(ele);
\r
3009 frame = base("$frame");
\r
3010 frame.timelines.length = 0;
\r
3011 frame.startTime = Date.now();
\r
3012 frame.setFrame(0);
\r
3013 frame.$endFrame.setFrame(0);
\r
3015 afterEach( function() {
\r
3016 $animate.numberOfList = -1;
\r
3017 p.__transformList = null;
\r
3019 /*境界条件を調べておく (limit value analysis)*/
\r
3020 it("should be this for the value (limit value analysis)", function() {
\r
3021 expect($animate.type).toBe("translate");
\r
3022 expect($animate.mode).toBe("paced");
\r
3023 ele.setAttributeNS(null, "type", "scale");
\r
3024 $animate.init(ele);
\r
3025 expect($animate.type).toBe("translate");
\r
3026 expect($animate.mode).toBe("paced");
\r
3028 ele.setAttributeNS(null, "values", "0;1");
\r
3029 $animate.up("$a").init(ele);
\r
3030 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
3031 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
3032 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
3034 var ec = ele.cloneNode(true);
\r
3035 p.appendChild(ec);
\r
3036 ec.removeAttributeNS(null, "values");
\r
3037 ec.setAttributeNS(null, "from", "0");
\r
3038 ec.setAttributeNS(null, "to", "1");
\r
3039 $animate.up("$a").init(ec);
\r
3040 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
3041 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
3042 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
3045 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3046 it("should be this for the value (the invalid partion )", function() {
\r
3051 describe("Event", function() {
\r
3052 var $animate, ele, frame, p;
\r
3053 beforeEach( function() {
\r
3055 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3056 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3057 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3058 p.appendChild(ele);
\r
3059 frame = base("$frame");
\r
3060 frame.pauseAnimation();
\r
3061 frame.timelines.length = 0; //配列の初期化
\r
3062 frame.setFrame(0);
\r
3063 frame.$endFrame.setFrame(0);
\r
3065 /*境界条件を調べておく (limit value analysis)*/
\r
3066 it("should be this for the value (limit value analysis)", function() {
\r
3067 ele.addEventListener("beginEvent", function(evt) {
\r
3068 expect(evt.target).toBe(ele);
\r
3070 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3071 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3072 ele.dispatchEvent(evt);
\r
3074 ele.setAttributeNS(null, "begin", "mousedown");
\r
3075 ele.setAttributeNS(null, "dur", "1s");
\r
3076 ele.setAttributeNS(null, "attributeName", "fill");
\r
3077 ele.setAttributeNS(null, "fill", "freeze");
\r
3078 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3079 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3080 $animate.init(ele);
\r
3081 $animate.isCSS = false;
\r
3082 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3083 expect($animate.state).toBe("idling");
\r
3084 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3085 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3086 expect($animate.state).toBe("idling");
\r
3087 p.dispatchEvent(evt);
\r
3088 expect($animate.state).toBe("idling");
\r
3089 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3091 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3092 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3093 frame.setFrame(frame.currentFrame);
\r
3094 frame.$endFrame.setFrame(frame.currentFrame);
\r
3095 expect($animate.isEnd).toBeFalsy();
\r
3096 expect($animate.state).toBe("idling");
\r
3097 p.dispatchEvent(evt);
\r
3098 frame.setFrame(frame.currentFrame + 1);
\r
3099 frame.$endFrame.setFrame(frame.currentFrame + 1);
\r
3100 expect($animate.state).toBe("playing");
\r
3101 frame.setFrame(frame.currentFrame + 24);
\r
3102 frame.$endFrame.setFrame(frame.currentFrame + 24);
\r
3103 expect($animate.state).toBe("idling");
\r
3104 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3107 describe("a beginElement method and an endElement method", function() {
\r
3108 var $animate, ele, frame, p;
\r
3109 beforeEach( function() {
\r
3110 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3111 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3112 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3113 p.appendChild(ele);
\r
3114 frame = base("$frame");
\r
3115 frame.timelines.length = 0; //配列の初期化
\r
3116 frame.setFrame(0);
\r
3117 frame.$endFrame.setFrame(0);
\r
3118 ele.setAttributeNS(null, "begin", "indefinite");
\r
3119 ele.setAttributeNS(null, "dur", "1s");
\r
3120 ele.setAttributeNS(null, "dur", "1s");
\r
3121 ele.setAttributeNS(null, "attributeName", "fill");
\r
3122 ele.setAttributeNS(null, "fill", "freeze");
\r
3123 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3124 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3125 $animate.init(ele);
\r
3127 /*境界条件を調べておく (limit value analysis)*/
\r
3128 it("should be this for the value (limit value analysis)", function() {
\r
3129 expect(ele.beginElement()).toBeUndefined();
\r
3130 var cur = frame.currentFrame,
\r
3131 begin = frame.$begin.$1;
\r
3132 expect(begin.string).toBe("indefinite");
\r
3133 expect(begin.begin).toBe(cur);
\r
3134 expect(ele.endElement()).toBeUndefined();
\r
3136 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3137 it("should be this for the value (the valid partion )", function() {
\r
3138 ele.addEventListener("beginEvent", function(evt){
\r
3139 expect(evt.target.nodeName).toBe("animate");
\r
3141 ele.beginElement();
\r