1 /*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence
\r
2 *公式ページは http://sie.sourceforge.jp/
\r
4 /* ***** BEGIN LICENSE BLOCK *****
\r
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
7 * The contents of this file are subject to the Mozilla Public License Version
\r
8 * 1.1 (the "License"); you may not use this file except in compliance with
\r
9 * the License. You may obtain a copy of the License at
\r
10 * http://www.mozilla.org/MPL/
\r
12 * Software distributed under the License is distributed on an "AS IS" basis,
\r
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
14 * for the specific language governing rights and limitations under the
\r
17 * The Original Code is the Mozilla SVG Cairo Renderer project.
\r
19 * The Initial Developer of the Original Code is IBM Corporation.
\r
20 * Portions created by the Initial Developer are Copyright (C) 2004
\r
21 * the Initial Developer. All Rights Reserved.
\r
23 * Parts of this file contain code derived from the following files(s)
\r
24 * of the Mozilla SVG project (these parts are Copyright (C) by their
\r
25 * respective copyright-holders):
\r
26 * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
\r
28 * Contributor(s):DHRNAME revulo bellbind
\r
30 * Alternatively, the contents of this file may be used under the terms of
\r
31 * either of the GNU General Public License Version 2 or later (the "GPL"),
\r
32 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
\r
33 * in which case the provisions of the GPL or the LGPL are applicable instead
\r
34 * of those above. If you wish to allow use of your version of this file only
\r
35 * under the terms of either the GPL or the LGPL, and not to allow others to
\r
36 * use your version of this file under the terms of the MPL, indicate your
\r
37 * decision by deleting the provisions above and replace them with the notice
\r
38 * and other provisions required by the GPL or the LGPL. If you do not delete
\r
39 * the provisions above, a recipient may use your version of this file under
\r
40 * the terms of any one of the MPL, the GPL or the LGPL.
\r
42 * ***** END LICENSE BLOCK ***** */
\r
44 * Copyright (c) 2000 World Wide Web Consortium,
\r
45 * (Massachusetts Institute of Technology, Institut National de
\r
46 * Recherche en Informatique et en Automatique, Keio University). All
\r
47 * Rights Reserved. This program is distributed under the W3C's Software
\r
48 * Intellectual Property License. This program is distributed in the
\r
49 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
\r
50 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
52 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
\r
55 *Copyright (c) 2008-2010 Pivotal Labs
\r
57 Permission is hereby granted, free of charge, to any person obtaining
\r
58 a copy of this software and associated documentation files (the
\r
59 "Software"), to deal in the Software without restriction, including
\r
60 without limitation the rights to use, copy, modify, merge, publish,
\r
61 distribute, sublicense, and/or sell copies of the Software, and to
\r
62 permit persons to whom the Software is furnished to do so, subject to
\r
63 the following conditions:
\r
65 The above copyright notice and this permission notice shall be
\r
66 included in all copies or substantial portions of the Software.
\r
68 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
69 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
70 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
71 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
72 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
73 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
74 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
77 describe("SMIL Animation Spec", function() {
\r
78 describe("$frame object", function() {
\r
79 var frame = base("$frame");
\r
80 beforeEach( function() {
\r
81 frame.timelines = [];
\r
82 frame.isPaused = false;
\r
84 afterEach( function() {
\r
85 frame.timelines = [];
\r
87 /*境界条件を調べておく (limit value analysis)*/
\r
88 it("should be this for the value (limit value analysis)", function() {
\r
89 expect(typeof frame.setFrame).toBe("function");
\r
90 expect(frame.timelines.length).toBe(0);
\r
91 expect(frame.rank).toBe(0);
\r
92 expect(frame.startAnimation()).toBeUndefined();
\r
98 expect(frame.addLine()).toBe(false);
\r
99 expect(frame.addLine({})).toBe(false);
\r
100 expect(frame.addLine({
\r
103 expect(frame.addLine({
\r
107 expect(frame.removeLine()).toBeUndefined();
\r
108 expect(frame.removeLine({})).toBeUndefined();
\r
111 expect(frame.currentFrame).toBe(0);
\r
113 expect(frame.currentFrame).toBe(1);
\r
115 expect(frame.isPaused).toBeFalsy();
\r
116 expect(frame.pauseAnimation()).toBeUndefined();
\r
117 expect(frame.isPaused).toBeTruthy();
\r
119 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
120 it("should be this for the value (the valid partion)", function() {
\r
122 expect(frame.currentFrame).toBe(0);
\r
123 frame.startTime = Date.now();
\r
124 for (var i=0;i<100000;i++) {
\r
128 expect(frame.begin).toBe(0);
\r
129 expect(frame.activeTime).toBe(Number.MAX_VALUE);
\r
135 expect(frame.addLine( {
\r
139 expect(frame.addLine( {
\r
143 expect(frame.addLine( {
\r
147 expect(frame.addLine( {
\r
152 expect(frame.timelines.length).toBe(1);
\r
153 var timeline = frame.timelines[0];
\r
154 expect(timeline.begin).toBe(0);
\r
155 expect(timeline.activeTime).toBe(0);
\r
157 expect(frame.timelines[0]).toBe(timeline);
\r
158 frame.addLine({begin:1, activeTime:1});
\r
159 expect(frame.timelines[1]).not.toBe(timeline);
\r
160 frame.addLine(timeline);
\r
161 expect(frame.timelines[0]).not.toBe(timeline);
\r
162 expect(frame.timelines[1]).toBe(timeline);
\r
164 timeline = frame.timelines[0];
\r
165 frame.removeLine({});
\r
166 expect(frame.timelines[0]).toBe(timeline);
\r
167 frame.removeLine(timeline);
\r
168 expect(frame.timelines[0]).not.toBe(timeline);
\r
170 frame.addLine(frame.up().mix( {
\r
173 expect(frame.timelines).not.toBe(frame.$1.timelines);
\r
175 frame.timelines.length = 0;
\r
186 expect(frame.timelines[0].rank).toBe(1);
\r
187 expect(frame.timelines[1].rank).toBe(2);
\r
189 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
190 it("should be this for the value (the invalid partion)", function() {
\r
191 expect(frame.addLine(12)).toBeFalsy();
\r
192 /*循環参照にならず、スタック領域不足にならない*/
\r
193 frame.addLine(frame);
\r
198 describe("$begin object", function() {
\r
199 var begin = base("$frame").$begin.up();
\r
200 /*境界条件を調べておく (limit value analysis)*/
\r
201 it("should be this for the value (limit value analysis)", function() {
\r
202 expect(begin.string).toBe("");
\r
203 expect(begin.isResolved).toBeFalsy();
\r
204 expect(begin.eventTarget).toBe(document.documentElement);
\r
205 expect(typeof begin.listener).toBe("function");
\r
206 expect(begin.eventOffset).toBe(0);
\r
207 expect(begin.repeat).toBe(0);
\r
208 expect(begin.accessKey).toBe("");
\r
210 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
211 it("should be this for the value (the valid partion)", function() {
\r
212 begin.string = " hoge ";
\r
213 expect(begin.string).toBe(" hoge ");
\r
215 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
216 it("should be this for the value (the invalid partion)", function() {
\r
219 describe("A trim method in $begin object", function() {
\r
220 /*境界条件を調べておく (limit value analysis)*/
\r
221 beforeEach( function() {
\r
224 it("should be this for the value (limit value analysis)", function() {
\r
225 delete begin.string;
\r
226 expect(begin.trim(" ")).toBe("");
\r
227 expect( function() {
\r
231 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
232 it("should be this for the value (the valid partion)", function() {
\r
233 expect(begin.trim(" hoge ")).toBe("hoge");
\r
234 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
235 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
236 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
238 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
239 it("should be this for the value (the invalid partion)", function() {
\r
240 expect( function() {
\r
243 expect( function() {
\r
249 describe("An offset method in $begin object", function() {
\r
250 beforeEach( function() {
\r
253 /*境界条件を調べておく (limit value analysis)*/
\r
254 it("should be this for the value (limit value analysis)", function() {
\r
255 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
256 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
257 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
258 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
259 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
260 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
262 expect(begin.offset("+0s")).toBe(0);
\r
263 expect(begin.offset("-0s")).toBe(0);
\r
264 expect(begin.offset("1s")).toBe(1000);
\r
265 expect(begin.offset("-1s")).toBe(-1000);
\r
267 expect(begin.offset("+0min")).toBe(0);
\r
268 expect(begin.offset("-0min")).toBe(0);
\r
269 expect(begin.offset("1min")).toBe(60000);
\r
270 expect(begin.offset("-1min")).toBe(-60000);
\r
272 expect(begin.offset("+0h")).toBe(0);
\r
273 expect(begin.offset("-0h")).toBe(0);
\r
274 expect(begin.offset("1h")).toBe(60*60*1000);
\r
275 expect(begin.offset("-1h")).toBe(-3600000);
\r
277 expect(begin.offset("00:0")).toBe(0);
\r
278 expect(begin.offset("00:00:0.0")).toBe(0);
\r
279 expect(begin.offset("-00:0")).toBe(0);
\r
280 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
281 expect(begin.offset("00:1")).toBe(1000);
\r
282 expect(begin.offset("-00:1")).toBe(-1000);
\r
283 expect(begin.offset("00:00:1")).toBe(1000);
\r
284 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
286 expect(begin.offset()).toBe(0);
\r
288 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
289 it("should be this for the value (the valid partion)", function() {
\r
290 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
291 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
292 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
293 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
295 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
296 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
297 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
298 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
299 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
301 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
302 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
303 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
304 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
305 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
307 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
308 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
309 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
310 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
311 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
313 expect(begin.offset("01:0")).toBe(60000);
\r
314 expect(begin.offset("-01:0")).toBe(-60000);
\r
315 expect(begin.offset("00:00:1")).toBe(1000);
\r
316 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
317 expect(begin.offset("00:01:0")).toBe(60000);
\r
318 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
319 expect(begin.offset("01:00:0")).toBe(3600000);
\r
320 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
321 expect(begin.offset("00:10")).toBe(10000);
\r
322 expect(begin.offset("00:0.01")).toBe(10);
\r
323 expect(begin.offset("01:0.01")).toBe(60010);
\r
324 expect(begin.offset("10:0")).toBe(600000);
\r
325 expect(begin.offset("-00:10")).toBe(-10000);
\r
326 expect(begin.offset("-00:0.01")).toBe(-10);
\r
327 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
328 expect(begin.offset("-10:0")).toBe(-600000);
\r
329 expect(begin.offset("00:00:20")).toBe(20000);
\r
330 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
331 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
332 expect(begin.offset("-10:0")).toBe(-600000);
\r
333 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
335 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
336 it("should be this for the value (the invalid partion)", function() {
\r
337 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
338 expect(begin.offset("ms")).toBe(0);
\r
339 expect(begin.offset(".s")).toBe(0);
\r
340 expect(begin.offset("10:")).toBe(0);
\r
341 expect(begin.offset("::")).toBe(0);
\r
342 expect(begin.offset("-:0")).toBe(0);
\r
343 expect(begin.offset("-::0")).toBe(0);
\r
346 describe("An event method in $begin object", function() {
\r
347 /*境界条件を調べておく (limit value analysis)*/
\r
348 it("should be this for the value (limit value analysis)", function() {
\r
349 var evt = begin.event();
\r
350 expect(evt.id).toBe("");
\r
351 expect(evt.event).toBe("");
\r
352 evt = begin.event("");
\r
353 expect(evt.id).toBe("");
\r
354 expect(evt.event).toBe("");
\r
355 evt = begin.event(".");
\r
356 expect(evt.id).toBe("");
\r
357 expect(evt.event).toBe("");
\r
359 evt = begin.event("a");
\r
360 expect(evt.id).toBe("");
\r
361 expect(evt.event).toBe("a");
\r
362 evt = begin.event("a.b");
\r
363 expect(evt.id).toBe("a");
\r
364 expect(evt.event).toBe("b");
\r
366 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
367 it("should be this for the value (the valid partion)", function() {
\r
368 var evt = begin.event("id.event");
\r
369 expect(evt.id).toBe("id");
\r
370 expect(evt.event).toBe("event");
\r
371 evt = begin.event("event");
\r
372 expect(evt.id).toBe("");
\r
373 expect(evt.event).toBe("event");
\r
375 evt = begin.event("event+0s");
\r
376 expect(evt.id).toBe("");
\r
377 expect(evt.event).toBe("event");
\r
378 evt = begin.event("event-0s");
\r
379 expect(evt.id).toBe("");
\r
380 expect(evt.event).toBe("event");
\r
382 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
383 it("should be this for the value (the invalid partion)", function() {
\r
384 evt = begin.event("...");
\r
385 expect(evt.id).toBe("");
\r
386 expect(evt.event).toBe("");
\r
387 evt = begin.event(".event");
\r
388 expect(evt.id).toBe("");
\r
389 expect(evt.event).toBe("");
\r
390 evt = begin.event("id.");
\r
391 expect(evt.id).toBe("");
\r
392 expect(evt.event).toBe("");
\r
396 describe("An parse method in $begin object", function() {
\r
397 beforeEach( function() {
\r
400 /*境界条件を調べておく (limit value analysis)*/
\r
401 it("should be this for the value (limit value analysis)", function() {
\r
402 expect(begin.parse().begin).toBe(0);
\r
403 expect(begin.isResolved).toBeTruthy();
\r
405 expect(begin.parse().begin).toBe(0);
\r
406 begin.string = "+1";
\r
407 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
408 begin.string = " ";
\r
409 expect(begin.parse().begin).toBe(0);
\r
410 begin.string = "1";
\r
411 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
412 begin.string = "+0ms";
\r
413 expect(begin.parse().begin).toBe(0);
\r
414 begin.string = "-0ms";
\r
415 expect(begin.parse().begin).toBe(0);
\r
417 expect(begin.eventOffset).toBe(0);
\r
418 begin.string = "click";
\r
419 expect(begin.parse().begin).toBe(0);
\r
420 expect(begin.eventOffset).toBe(0);
\r
421 expect(begin.repeat).toBe(0);
\r
422 expect(begin.accessKey).toBe("");
\r
423 begin.string = "id.click";
\r
424 expect(begin.parse().begin).toBe(0);
\r
425 expect(begin.eventOffset).toBe(0);
\r
426 expect(begin.repeat).toBe(0);
\r
427 expect(begin.accessKey).toBe("");
\r
429 begin.string = "repeat";
\r
430 expect(begin.parse().begin).toBe(0);
\r
431 expect(begin.eventOffset).toBe(0);
\r
432 expect(begin.repeat).toBe(0);
\r
433 expect(begin.accessKey).toBe("");
\r
434 begin.string = "repeat(1)";
\r
435 expect(begin.parse().begin).toBe(0);
\r
436 expect(begin.eventOffset).toBe(0);
\r
437 expect(begin.repeat).toBe(1);
\r
438 expect(begin.accessKey).toBe("");
\r
440 begin.string = "accessKey(a)";
\r
441 expect(begin.parse().begin).toBe(0);
\r
442 expect(begin.eventOffset).toBe(0);
\r
443 expect(begin.repeat).toBe(0);
\r
444 expect(begin.accessKey).toBe("a");
\r
446 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
447 it("should be this for the value (the valid partion)", function() {
\r
448 begin.string = " 1 0 0 m s";
\r
449 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
451 begin.string = "1ms";
\r
452 begin.isResolved = false;
\r
453 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
454 expect(begin.isResolved).toBeTruthy();
\r
455 expect(begin.eventOffset).toBe(0);
\r
457 begin.string="click+0";
\r
458 expect(begin.parse().begin).toBe(0);
\r
459 expect(begin.eventOffset).toBe(0);
\r
460 expect(begin.isResolved).toBeFalsy();
\r
461 begin.string = "click+1";
\r
462 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
463 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
464 begin.string = " click ";
\r
465 expect(begin.parse().begin).toBe(0);
\r
466 expect(begin.eventOffset).toBe(0);
\r
467 begin.string = "click+0ms";
\r
468 expect(begin.parse().begin).toBe(0);
\r
469 expect(begin.eventOffset).toBe(0);
\r
470 expect(begin.isResolved).toBeFalsy();
\r
471 begin.string = "click-0ms";
\r
472 expect(begin.parse().begin).toBe(0);
\r
473 expect(begin.eventOffset).toBe(0);
\r
474 begin.string = "click+100ms";
\r
475 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
476 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
477 begin.string = "click-100ms";
\r
478 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
479 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
481 begin.string="id.click+0";
\r
482 expect(begin.parse().begin).toBe(0);
\r
483 expect(begin.eventOffset).toBe(0);
\r
484 expect(begin.isResolved).toBeFalsy();
\r
485 begin.string = "id.click+1";
\r
486 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
487 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
488 expect(begin.isResolved).toBeFalsy();
\r
489 begin.string = " id . click ";
\r
490 expect(begin.parse().begin).toBe(0);
\r
491 expect(begin.eventOffset).toBe(0);
\r
492 expect(begin.isResolved).toBeFalsy();
\r
493 begin.string = "id.click+0ms";
\r
494 expect(begin.parse().begin).toBe(0);
\r
495 expect(begin.eventOffset).toBe(0);
\r
496 begin.string = "id.click-0ms";
\r
497 expect(begin.parse().begin).toBe(0);
\r
498 expect(begin.eventOffset).toBe(0);
\r
499 begin.string = "id.click+100ms";
\r
500 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
501 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
502 begin.string = "id.click-100ms";
\r
503 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
504 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
506 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
507 it("should be this for the value (the invalid partion)", function() {
\r
508 begin.string = "ms";
\r
509 begin.isResolved = false;
\r
510 expect(begin.parse().begin).toBe(0);
\r
511 expect(begin.isResolved).toBeFalsy();
\r
513 begin.isResolved = true;
\r
514 begin.string = "indefinite";
\r
515 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
516 expect(begin.isResolved).toBeFalsy();
\r
520 describe("A listener method in $begin object", function() {
\r
521 var obj = begin.up();
\r
522 beforeEach( function() {
\r
525 begin.timelines.length = 0;
\r
526 obj.$activate = begin.$activate.up();
\r
527 obj.startTime = Date.now();
\r
530 /*境界条件を調べておく (limit value analysis)*/
\r
531 it("should be this for the value (limit value analysis)", function() {
\r
532 obj.isResolved = true;
\r
534 expect(obj.begin).toBe(0);
\r
537 timeStamp: Date.now()
\r
539 expect(obj.begin).toBe(0);
\r
540 expect(obj.activeTime).toBeGreaterThan(0);
\r
541 expect(obj.timelines.length).toBe(1);
\r
543 obj.isResolved = false;
\r
545 timeStamp: Date.now()
\r
547 expect(obj.begin).toBe(0);
\r
548 expect(obj.activeTime).toBeGreaterThan(0);
\r
549 expect(obj.timelines.length).toBe(1);
\r
551 obj.timelines.length = 0;
\r
556 $activate: begin.$activate.up().mix( {
\r
561 timeStamp: Date.now()
\r
563 expect(obj.$1.begin).toBe(1);
\r
564 expect(obj.$1.activeTime).toBe(Math.floor(12000*obj.fpms));
\r
565 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
566 expect(obj.timelines[0]).toBe(obj.$1);
\r
568 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
569 it("should be this for the value (the valid partion)", function() {
\r
573 $activate: begin.$activate.up().mix( {
\r
574 end: begin.$activate.end.up().mix( {
\r
580 timeStamp: Date.now()
\r
582 expect(obj.$1.begin).toBe(1);
\r
583 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
584 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
585 expect(obj.timelines[0]).toBe(obj.$1);
\r
590 $activate: begin.$activate.up().mix( {
\r
591 end: begin.$activate.end.up().mix( {
\r
597 timeStamp: Date.now()
\r
599 expect(obj.$1.begin).toBe(1);
\r
600 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
601 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
602 expect(obj.timelines[1]).toBe(obj.$1);
\r
604 timeStamp: (Date.now() + 500)
\r
606 expect(obj.$1.begin).toBe(1);
\r
607 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
608 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
609 expect(obj.timelines[1]).toBe(obj.$1);
\r
611 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
612 it("should be this for the value (the invalid partion)", function() {
\r
616 describe("A $end object", function() {
\r
617 var end = base("$frame").$begin.$end.up();
\r
619 beforeEach( function() {
\r
621 end.startTime = Date.now();
\r
624 /*境界条件を調べておく (limit value analysis)*/
\r
625 it("should be this for the value (limit value analysis)", function() {
\r
626 expect(end.up().call()).toBeNull();
\r
628 expect(end.up().call()).toBe(0);
\r
629 end.string = "hoge";
\r
630 expect(end.up().call()).toBe("indefinite");
\r
633 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
634 it("should be this for the value (the valid partion)", function() {
\r
635 end.string = "hoge+0";
\r
636 expect(end.up().call()).toBe("indefinite");
\r
637 end.string = "12ms";
\r
638 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
639 end.string = "hoge+12ms";
\r
640 expect(end.up().call()).toBe("indefinite");
\r
643 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
644 it("should be this for the value (the invalid partion)", function() {
\r
646 expect(end.up().call()).toBeNull();
\r
649 describe("A listener method in $end object", function() {
\r
651 begin = base("$frame").$begin;
\r
652 beforeEach( function() {
\r
655 end.timelines.length = 0;
\r
657 obj.$begin = begin.up().mix( {
\r
661 obj.$begin.$activate = begin.$activate.up();
\r
662 obj.addLine(obj.$begin);
\r
664 /*境界条件を調べておく (limit value analysis)*/
\r
665 it("should be this for the value (limit value analysis)", function() {
\r
666 expect(obj.timelines[0]).toBe(obj.$begin);
\r
667 expect(obj.timelines[0]).not.toBe(obj);
\r
669 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
671 obj.addLine(obj.$begin.mix( {
\r
676 timeStamp: (Date.now() + 12)
\r
678 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
680 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
681 it("should be this for the value (the valid partion)", function() {
\r
682 obj.$begin.$activate.begin = 0;
\r
687 timeStamp: (Date.now() + 120)
\r
689 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
690 expect(obj.begin).toBe(0);
\r
691 expect(obj.$begin.activeTime).toBe(0);
\r
693 obj.addLine(obj.$begin.mix( {
\r
697 obj.$begin.$activate.begin = 0;
\r
699 string: "event+1000ms"
\r
702 timeStamp: (Date.now() + 12)
\r
704 expect(obj.timelines[0]).toBe(obj.$begin);
\r
705 expect(obj.begin).toBe(Math.ceil(1000*obj.fpms));
\r
706 expect(obj.$begin.activeTime).toBe(Math.ceil(1000*obj.fpms));
\r
708 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
709 it("should be this for the value (the invalid partion)", function() {
\r
713 describe("A $activate object", function() {
\r
714 var act = base("$frame").$begin.$activate.up();
\r
715 beforeEach( function() {
\r
716 act.dur = "indefinite";
\r
718 act.repeatCount = null;
\r
719 act.repeatDur = null;
\r
720 act.end = act.$begin.$end;
\r
721 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
723 /*境界条件を調べておく (limit value analysis)*/
\r
724 it("should be this for the value (limit value analysis)", function() {
\r
725 expect(act.dur).toBe("indefinite");
\r
726 expect(typeof act.resolvedTime).toBe("function");
\r
727 expect(act.end).toBe(act.$begin.$end);
\r
728 expect(act.repeatCount).toBeNull();
\r
729 expect(act.repeatDur).toBeNull();
\r
730 expect(act.simpleDur()).toBeNull();
\r
731 expect(act.min).toBe("0");
\r
732 expect(act.max).toBe("indefinite");
\r
735 expect(act.$a.call()).toBeNull();
\r
736 expect(act.$a.end).toBeNull();
\r
738 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
739 it("should be this for the value (the valid partion)", function() {
\r
740 expect(act.resolvedTime()).toBe((+new Date()));
\r
742 /*Activate Duration = dur*/
\r
744 act.$b.dur = "132ms";
\r
745 var abc = act.$b.call();
\r
746 expect(abc).toBe(Math.floor(132*act.fpms));
\r
747 expect(abc).toBe(act.$b.simpleDur);
\r
749 expect(act.up().call()).toBeNull();
\r
751 /*AD = end -begin*/
\r
753 act.up("$eb").end = act.end.up().mix( {string: "120ms" } );
\r
754 expect( act.$eb.mix( {
\r
756 simpleDur: act.simpleDur,
\r
759 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
760 expect( act.$eb.mix( {
\r
762 repeatCount: "indefinite",
\r
764 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
765 expect( act.$eb.mix( {
\r
767 simpleDur: act.simpleDur,
769 repeatDur: "indefinite",
\r
770 } ).call() ).toBe(Math.floor(120*act.fpms) - 1);
\r
772 expect( act.$eb.mix( {
\r
774 simpleDur: act.simpleDur,
775 repeatCount: "indefinite",
\r
776 repeatDur: "indefinite",
\r
777 } ).call() ).toBe(Math.floor(120*act.fpms)*3 - 1);
\r
779 /*AD = Min(dur, end - begin)*/
\r
780 act.up("$c").end = act.end.up().mix( { string: "12" } );
\r
783 simpleDur: act.simpleDur,
787 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
788 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
791 simpleDur: act.simpleDur,
795 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
796 expect(act.$c.simpleDur).toBe(Math.floor(15000*act.fpms));
\r
798 /*AD = Min(repeatCount*dur, end - begin)*/
\r
799 expect(act.$c.end).toBe(Math.floor(12000*act.fpms));
\r
802 simpleDur: act.simpleDur,
806 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
807 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
810 simpleDur: act.simpleDur,
814 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
815 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
817 /*AD = Min(repeatDur, end - begin)*/
\r
820 simpleDur: act.simpleDur,
824 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
825 expect(act.$c.simpleDur).toBeNull();
\r
828 simpleDur: act.simpleDur,
832 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
833 expect(act.$c.simpleDur).toBeNull();
\r
836 simpleDur: act.simpleDur,
840 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
841 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
844 simpleDur: act.simpleDur,
848 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
849 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
851 /*AD = Min(repeatCount*d, repeatDur, end - begin)*/
\r
854 simpleDur: act.simpleDur,
858 expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);
\r
859 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
862 simpleDur: act.simpleDur,
866 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
867 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
870 simpleDur: act.simpleDur,
874 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
875 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
877 /*AD = repeatDur,*/
\r
881 simpleDur: act.simpleDur,
885 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
886 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
889 simpleDur: act.simpleDur,
893 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
894 expect(act.$c.simpleDur).toBeNull();
\r
896 act.end.string = null;
\r
897 act.up("$cd").mix( {
\r
902 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
904 act.$cd.end = act.end;
\r
905 act.$cd.repeatCount = null;
\r
906 act.$cd.repeatDur = "12";
\r
907 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
909 act.up("$d").mix( {
\r
913 simpleDur: act.simpleDur
\r
915 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
916 act.up("$d").mix( {
\r
920 simpleDur: act.simpleDur
\r
922 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
924 /*endで0が指定されている場合*/
\r
927 act.repeatDur = null;
\r
928 act.repeatCount = "indefinite";
\r
930 expect(act.call()).toBe(0);
\r
931 act.repeatCount = null;
\r
932 act.repeatDur = "indefinite";
\r
934 expect(act.call()).toBe(0);
\r
935 act.repeatDur = "indefinite";
\r
936 act.repeatCount = "indefinite";
\r
938 expect(act.call()).toBe(0);
\r
940 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
941 it("should be this for the value (the invalid partion)", function() {
\r
943 act.up("$d").mix( {
\r
947 simpleDur: act.simpleDur
\r
949 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
951 act.repeatDur = null;
\r
952 act.repeatCount = "indefinite";
\r
954 expect(act.call()).toBeNull();
\r
955 act.repeatCount = null;
\r
956 act.repeatDur = "indefinite";
\r
958 expect(act.call()).toBeNull();
\r
959 act.repeatDur = "indefinite";
\r
960 act.repeatCount = "indefinite";
\r
962 expect(act.call()).toBeNull();
\r
965 describe("A $from object", function() {
\r
966 var from = base("$from");
\r
967 beforeEach( function() {
\r
968 from = base("$from").up();
\r
969 from.from = from.from.up();
\r
972 /*境界条件を調べておく (limit value analysis)*/
\r
973 it("should be this for the value (limit value analysis)", function() {
\r
974 expect(from.string).toBe("");
\r
975 expect(from.numList()).toEqual([]);
\r
976 expect(from.strList()).toBeNull();
\r
979 expect(from.numList()[0]).toBe(0);
\r
980 expect(from.strList()).toBeNull();
\r
982 from.string = " 0 ";
\r
983 expect(from.numList()[0]).toBe(0);
\r
984 expect(from.strList().join("")).toBe(" ");
\r
987 expect(from.numList()).toEqual([]);
\r
988 expect(from.strList()[0]).toBe("a");
\r
990 from.string = null;
\r
991 expect( function() {
\r
994 expect( function() {
\r
998 expect(from.additive[0]).toBe(0);
\r
999 expect(from.accumulate[0]).toBe(0);
\r
1001 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1002 it("should be this for the value (the valid partion)", function() {
\r
1003 from.string = "0a";
\r
1004 expect(from.numList()[0]).toBe(0);
\r
1005 expect(from.strList()[0]).toBe("a");
\r
1007 from.string = "a0";
\r
1008 expect(from.numList()[0]).toBe(0);
\r
1009 expect(from.strList()[0]).toBe("a");
\r
1011 from.string = "0.1";
\r
1012 expect(from.numList()[0]).toBe(0.1);
\r
1013 expect(from.strList()).toBeNull();
\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 = "1e-1";
\r
1024 expect(from.numList()[0]).toBe(1e-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 = "0,0";
\r
1032 expect(from.numList().toString()).toBe("0,0");
\r
1033 expect(from.strList().join("")).toBe(",");
\r
1035 from.string = "a00a";
\r
1036 expect(from.numList()[0]).toBe(0);
\r
1037 expect(from.strList().join("")).toBe("aa");
\r
1039 from.string = "a0b0a";
\r
1040 expect(from.numList().toString()).toBe("0,0");
\r
1041 expect(from.strList().join("")).toBe("aba");
\r
1043 from.string = "0b0a";
\r
1044 expect(from.numList().toString()).toBe("0,0");
\r
1045 expect(from.strList().join("")).toBe("ba");
\r
1047 from.string = "0b-1.0a";
\r
1048 expect(from.numList()[1]).toBe(-1);
\r
1049 expect(from.strList().join("")).toBe("ba");
\r
1051 expect(from.up().call()).toBe(from.$1.numList);
\r
1052 expect(from.$1.numList[1]).toBe(-1);
\r
1053 expect(from.$1.strList.join("")).toBe("ba");
\r
1055 from.string = "あ 0b-1.0a12";
\r
1056 expect(from.numList()[1]).toBe(-1);
\r
1057 expect(from.strList().join("")).toBe("あ ba12");
\r
1059 from.string = "0b-1.0a0";
\r
1060 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1061 expect(from.strList().join("")).toBe("ba");
\r
1063 from.string = "0b .1a";
\r
1064 expect(from.numList()[1]).toBe(0.1);
\r
1065 expect(from.strList().join("")).toBe("b a");
\r
1067 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1068 it("should be this for the value (the invalid partion)", function() {
\r
1069 from.string = NaN;
\r
1070 expect(function(){
\r
1073 expect(function(){
\r
1077 from.string = "currentColor";
\r
1078 expect(from.numList()).toEqual([]);
\r
1079 expect(from.strList()[0]).toBe("currentColor");
\r
1081 from.string = "eE";
\r
1082 expect(from.numList()).toEqual([]);
\r
1083 expect(from.strList()[0]).toBe("eE");
\r
1084 expect(from.strList()[0]).toBe("eE");
\r
1087 describe("A $to object", function() {
\r
1088 var from = base("$from");
\r
1089 beforeEach( function() {
\r
1090 from = base("$from").up();
\r
1094 /*境界条件を調べておく (limit value analysis)*/
\r
1095 it("should be this for the value (limit value analysis)", function() {
\r
1096 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1097 expect(from.up().call()).toBe(from.$1.numList);
\r
1098 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1100 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1101 it("should be this for the value (the valid partion)", function() {
\r
1103 from.$to.from = from;
\r
1104 from.$to.string = "12cm-7";
\r
1105 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1106 expect(from.$to.strList().toString()).toBe("cm");
\r
1108 from.string = "7cm+8";
\r
1110 expect(from.call()).toBe(from.numList);
\r
1111 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1112 expect(from.$to.strList.join("")).toBe("cm");
\r
1113 expect(from.numList.join(",")).toBe("7,8");
\r
1114 expect(from.strList.join("")).toBe("cm");
\r
1115 expect(from.$to.from).toBe(from.numList);
\r
1118 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1119 it("should be this for the value (the invalid partion)", function() {
\r
1121 from.up("$to").mix( function() {
\r
1122 this.string = "12cm";
\r
1125 arr.string = this.string;
\r
1126 expect(this.numList).toEqual(arr);
\r
1127 expect(this.strList).toBeNull();
\r
1131 describe("An advance method", function() {
\r
1132 var from = base("$from");
\r
1133 beforeEach( function() {
\r
1134 from = base("$from").up();
\r
1137 from.$to.from = from;
\r
1139 /*境界条件を調べておく (limit value analysis)*/
\r
1140 it("should be this for the value (limit value analysis)", function() {
\r
1141 expect(from.advance()).toBe("");
\r
1142 expect(from.$to.advance()).toBe("");
\r
1143 expect(from.$to.advance(0)).toBe("");
\r
1144 expect(from.$to.advance(1)).toBe("");
\r
1145 expect(function(){
\r
1146 from.$to.advance(1.01);
\r
1147 }).toThrow("An Invalid Number Error");
\r
1148 expect(function(){
\r
1149 from.$to.advance(-0.01);
\r
1150 }).toThrow("An Invalid Number Error");
\r
1154 from = base("$from").up();
\r
1156 from.$to.from = from;
\r
1157 arr.string = from.string = "0";
\r
1158 from.$to.string = "1";
\r
1159 expect(from.$to.call()).toBe(from.$to.numList);
\r
1160 expect(from.$to.numList[0]).toBe(1);
\r
1161 expect(from.$to.strList).toBeNull();
\r
1162 expect(from.numList[0]).toBe(0);
\r
1163 expect(from.strList).toBeNull();
\r
1164 expect(from.advance(0)).toBe("");
\r
1165 expect(from.$to.from).toBe(from.numList);
\r
1166 expect(from.$to.advance(0)).toBe("0");
\r
1167 expect(from.call()).toBe(from.numList);
\r
1169 from = base("$from").up();
\r
1171 from.$to.from = from;
\r
1172 from.string = "inline";
\r
1173 arr.string = from.$to.string = "block";
\r
1174 expect(from.$to.call()).toBe(from.$to.numList);
\r
1175 expect(from.$to.numList).toEqual(arr);
\r
1176 expect(from.$to.strList).toEqual(["block"]);
\r
1177 arr.string = from.string;
\r
1178 expect(from.numList).toEqual(arr);
\r
1179 expect(from.strList).toEqual(["inline"]);
\r
1180 expect(from.advance(0)).toBe("");
\r
1181 expect(from.$to.from).toBe(from.numList);
\r
1182 expect(from.$to.advance(0)).toBe("inline");
\r
1183 expect(from.call()).toBe(from.numList);
\r
1185 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1186 it("should be this for the value (the valid partion)", function() {
\r
1189 from.string = "0s";
\r
1190 from.$to.string = "1s";
\r
1191 expect(from.$to.call()).toBe(from.$to.numList);
\r
1192 expect(from.$to.numList[0]).toBe(1);
\r
1193 expect(from.$to.strList[0]).toBe("");
\r
1194 expect(from.numList[0]).toBe(0);
\r
1195 expect(from.strList[0]).toBe("");
\r
1196 expect(from.advance(0)).toBe("");
\r
1197 expect(from.$to.from).toBe(from.numList);
\r
1198 expect(from.$to.advance(0)).toBe("0s");
\r
1199 from.$to.degit = deg;
\r
1200 for (var i=0;i<1;i+=0.01) {
\r
1201 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1203 expect(from.call()).toBe(from.numList);
\r
1205 from = base("$from").up();
\r
1207 from.string = "a0S";
\r
1208 from.$to.string = "a1S";
\r
1209 from.$to.from = from;
\r
1210 expect(from.$to.call()).toBe(from.$to.numList);
\r
1211 expect(from.$to.numList[0]).toBe(1);
\r
1212 expect(from.$to.strList[0]).toBe("a");
\r
1213 expect(from.numList[0]).toBe(0);
\r
1214 expect(from.strList[0]).toBe("a");
\r
1215 expect(from.advance(0)).toBe("");
\r
1216 expect(from.$to.from).toBe(from.numList);
\r
1217 expect(from.$to.advance(0)).toBe("a0S");
\r
1219 from.$to.degit = deg;
\r
1220 for (var i=0;i<1;i+=0.01) {
\r
1221 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1223 expect(from.call()).toBe(from.numList);
\r
1225 from = base("$from").up();
\r
1227 from.string = "a-10s1.5";
\r
1228 from.$to.string = "a10s-3";
\r
1229 from.$to.from = from;
\r
1231 from.$to.degit = 1;
\r
1232 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1233 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1234 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1236 from.$to.additive[0] = 1;
\r
1237 from.$to.accumulate[1] = 2;
\r
1238 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1239 from.$to.additive[0] = 0.5;
\r
1240 from.$to.accumulate[1] = 0.8;
\r
1241 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1243 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1244 it("should be this for the value (the invalid partion)", function() {
\r
1245 expect(function(){
\r
1246 from.$to.advance(10);
\r
1247 }).toThrow("An Invalid Number Error");
\r
1248 expect(function(){
\r
1249 from.$to.advance(-10);
\r
1250 }).toThrow("An Invalid Number Error");
\r
1254 describe("A distance method", function() {
\r
1255 var from = base("$from");
\r
1256 beforeEach( function() {
\r
1257 from = base("$from").up();
\r
1261 /*境界条件を調べておく (limit value analysis)*/
\r
1262 it("should be this for the value (limit value analysis)", function() {
\r
1263 expect(from.distance()).toBe(0)
\r
1264 expect(from.$to.distance()).toBe(0);
\r
1266 from.string = "0";
\r
1267 from.$to.string = "1";
\r
1268 expect(from.distance()).toBe(0);
\r
1269 expect(from.$to.distance(from)).toBe(1);
\r
1271 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1272 it("should be this for the value (the valid partion)", function() {
\r
1273 from.string = "s 0 s 12";
\r
1274 from.$to.string = "s 0 s 0";
\r
1275 expect(from.distance()).toBe(0);
\r
1276 expect(from.$to.distance(from)).toBe(12);
\r
1277 expect(from.$to.distance(from)).toBe(12);
\r
1278 expect(from.$to.distance(from.call())).toBe(12);
\r
1280 from = base("$from").up();
\r
1282 from.string = "rgb(1, 0, 0)";
\r
1283 from.$to.string = "rgb(0, 0, 1)";
\r
1284 expect(from.distance()).toBe(0);
\r
1285 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1287 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1288 it("should be this for the value (the invalid partion)", function() {
\r
1289 from.string = "s";
\r
1290 from.$to.string = "s";
\r
1291 expect(from.$to.distance(from)).toBe(0);
\r
1294 describe("A setAdditive method", function() {
\r
1295 var from = base("$from");
\r
1296 beforeEach( function() {
\r
1297 from = base("$from").up();
\r
1301 /*境界条件を調べておく (limit value analysis)*/
\r
1302 it("should be this for the value (limit value analysis)", function() {
\r
1303 expect(from.setAdditive()).toBe(0);
\r
1304 expect(from.setAdditive("")).toBe(0);
\r
1305 expect(from.additive).toEqual([0]);
\r
1308 expect(from.setAdditive("1")).toEqual(arr);
\r
1309 expect(from.additive).toEqual(arr);
\r
1311 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1312 it("should be this for the value (the valid partion)", function() {
\r
1313 var arr = [1, 2, 3];
\r
1314 arr.string = "1 2, 3";
\r
1315 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1316 expect(from.additive).toEqual(arr);
\r
1318 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1319 it("should be this for the value (the invalid partion)", function() {
\r
1322 describe("A setAccumulate method", function() {
\r
1323 var from = base("$from");
\r
1324 beforeEach( function() {
\r
1325 from = base("$from").up();
\r
1326 from.string = "0 1";
\r
1330 /*境界条件を調べておく (limit value analysis)*/
\r
1331 it("should be this for the value (limit value analysis)", function() {
\r
1332 expect(from.setAccumulate()).toBe(0);
\r
1333 expect(from.setAccumulate(0)).toBe(0);
\r
1334 expect(from.accumulate).toEqual([0, 0]);
\r
1335 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1336 expect(from.accumulate).toEqual([0, 1]);
\r
1338 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1339 it("should be this for the value (the valid partion)", function() {
\r
1340 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1341 expect(from.accumulate).toEqual([0, 2]);
\r
1343 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1344 it("should be this for the value (the invalid partion)", function() {
\r
1345 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1348 describe("A $calcMode object", function() {
\r
1349 var calc = base("$calcMode"),
\r
1352 beforeEach( function() {
\r
1353 calc = base("$calcMode").up();
\r
1354 calc.to = base("$from").up().mix( {string: "1"} );
\r
1355 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1357 /*境界条件を調べておく (limit value analysis)*/
\r
1358 it("should be this for the value (limit value analysis)", function() {
\r
1359 expect(calc.mode).toBe("linear");
\r
1360 expect(calc.keyTime).toBe(1);
\r
1361 expect(calc.keySplines).toBeNull();
\r
1362 expect(calc.string).toBe("");
\r
1364 expect(calc.call()(0)).toBe("0");
\r
1365 expect(calc.keyTime).toBe(1);
\r
1366 expect(calc.call()(1)).toBe("1");
\r
1369 expect(calc.call()(1)).toBe("0");
\r
1372 calc.mode = "paced";
\r
1373 expect(calc.norm).toBe(1);
\r
1374 calc.to.from = from;
\r
1375 expect(calc.call()(0)).toBe("0");
\r
1376 expect(calc.keyTime).toBe(1);
\r
1377 calc.to.from = from;
\r
1378 expect(calc.call()(1)).toBe("1");
\r
1381 calc.to.from = from;
\r
1382 expect(calc.call()(1)).toBe("1");
\r
1385 calc.mode = "discrete";
\r
1386 calc.to.from = from;
\r
1388 expect(calc.call()(0)).toBe("0");
\r
1389 expect(calc.call()(1)).toBe("1");
\r
1391 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1392 it("should be this for the value (the valid partion)", function() {
\r
1393 calc.mode = "linear";
\r
1394 calc.keyTime = 0.5;
\r
1395 calc.to.degit = 1;
\r
1396 expect(calc.call()(0.2)).toBe("0.4");
\r
1397 expect(calc.call()(0.3)).toBe("0.6");
\r
1399 expect(calc.call()(0.2)).toBe("0.4");
\r
1401 calc = base("$calcMode").up();
\r
1402 calc.keyTime = 0.2;
\r
1403 calc.to = base("$from").up();
\r
1404 calc.to.from = base("$from").up();
\r
1405 calc.to.from.string = "0s";
\r
1406 calc.to.string = "1s";
\r
1407 calc.to.degit = 1;
\r
1408 expect(calc.call()(0.1)).toBe("0.5s");
\r
1410 calc = base("$calcMode").up();
\r
1411 calc.keyTime = 0.5;
\r
1412 calc.to = base("$from").up();
\r
1413 calc.to.from = base("$from").up();
\r
1414 calc.to.from.string = "rgb(100, 20, 32)";
\r
1415 calc.to.string = "rgb(0, 10, 50)";
\r
1416 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1419 calc.to = base("$from").up();
\r
1420 calc.to.from = base("$from").up();
\r
1421 calc.mode = "paced";
\r
1423 calc.to.from.string = "0s";
\r
1424 calc.to.string = "20s";
\r
1425 calc.to.degit = 1;
\r
1426 expect(calc.call()(0.1)).toBe("10.0s");
\r
1427 expect(calc.keyTime).toBe(0.2);
\r
1429 calc.to = base("$from").up();
\r
1430 calc.to.from = base("$from").up();
\r
1431 calc.mode = "paced";
\r
1433 calc.to.from.string = "rgb(0, 0, 20)";
\r
1434 calc.to.string = "rgb(0, 0, 0)";
\r
1435 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1436 expect(calc.keyTime).toBe(0.2);
\r
1439 calc.to = base("$from").up();
\r
1440 calc.to.from = base("$from").up();
\r
1441 calc.mode = "discrete";
\r
1442 calc.keyTime = 0.5;
\r
1443 calc.to.degit = 1;
\r
1444 calc.to.string = "1";
\r
1445 calc.to.from.string = "0.5";
\r
1446 expect(calc.call()(0.2)).toBe("0.5");
\r
1447 expect(calc.call()(0.3)).toBe("0.5");
\r
1449 expect(calc.call()(0.2)).toBe("0.5");
\r
1451 calc.to = base("$from").up();
\r
1452 calc.to.from = base("$from").up();
\r
1453 calc.mode = "discrete";
\r
1454 calc.keyTime = 0.5;
\r
1455 calc.to.degit = 1;
\r
1456 calc.to.string = "block";
\r
1457 calc.to.from.string = "inline";
\r
1458 expect(calc.call()(0.2)).toBe("inline");
\r
1459 expect(calc.call()(0.3)).toBe("inline");
\r
1461 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1462 it("should be this for the value (the invalid partion)", function() {
\r
1463 calc.keyTime = null;
\r
1464 expect(calc.call()(1)).toBe(calc.string);
\r
1466 calc.keyTime = void 0;
\r
1467 expect(calc.call()(1)).toBe(calc.string);
\r
1469 calc.keyTime = 1/0;
\r
1470 expect(calc.call()(1)).toBe(calc.string);
\r
1472 expect(calc.call()()).toBe(calc.string);
\r
1474 calc = base("$calcMode").up();
\r
1475 calc.mode = "paced";
\r
1476 calc.to.from = from;
\r
1477 expect(calc.call()()).toBe(calc.string);
\r
1479 calc = base("$calcMode").up();
\r
1480 calc.mode = "discrete";
\r
1481 expect(calc.call()()).toBe(calc.string);
\r
1484 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1485 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1486 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1489 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1490 return function (t) {
\r
1491 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1492 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1496 expect(calc.keySplines).toBeNull();
\r
1497 calc.mode = "spline";
\r
1498 expect( calc.call()("undef")).toBe(Math.PI);
\r
1499 calc.keySplines = [0, 0, 1, 1];
\r
1500 calc.to.degit = 1;
\r
1501 calc.to.from = from;
\r
1502 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1503 calc.to.from = from;
\r
1504 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1505 calc.to.from = from;
\r
1506 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1508 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1509 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1510 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1511 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1512 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1513 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1514 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1515 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1516 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1518 var a = y4-3*(y3-y2)-y1,
\r
1519 b = 3*(y3-2*y2+y1),
\r
1521 d = y1 - bezier.apply(null, arguments)(t);
\r
1522 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1525 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1526 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1529 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1530 return function (t) {
\r
1532 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1533 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1537 calc.mode = "spline";
\r
1538 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1539 calc.to.degit = 1;
\r
1540 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1541 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1542 calc.to.from = from;
\r
1543 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1544 calc.to.from = from;
\r
1545 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1547 var ff = function(k) {
\r
1548 calc.keySplines = k;
\r
1549 calc.to.degit = 10;
\r
1550 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1551 epsilon = 1e-5; //誤差
\r
1552 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1553 calc.to.from = from;
\r
1554 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1555 calc.to.from = from;
\r
1556 b = b(Math.random());
\r
1557 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1559 for (var i=0;i<10000;++i) {
\r
1560 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1564 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1565 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1566 calc.mode = "spline";
\r
1567 calc.keySplines = [0, NaN, 1, 1];
\r
1568 calc.to.degit = 1;
\r
1569 calc.to.from = from;
\r
1570 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1573 calc.keySplines = [0, 0, 1, 2];
\r
1574 calc.to.degit = 1;
\r
1575 calc.to.from = from;
\r
1576 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1578 calc.keySplines = null;
\r
1579 calc.to.degit = 1;
\r
1580 calc.to.from = from;
\r
1581 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1584 describe("A $attribute object", function() {
\r
1585 describe("A push method", function() {
\r
1587 beforeEach( function() {
\r
1588 attr = base("$calcMode").$attribute.up("width");
\r
1589 base("$frame").timelines.length = 0;
\r
1590 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1592 /*境界条件を調べておく (limit value analysis)*/
\r
1593 it("should be this for the value (limit value analysis)", function() {
\r
1594 expect(attr.element).toBeNull();
\r
1595 expect(attr.push()).toBeNull();
\r
1596 expect(attr.element).toBeNull();
\r
1597 expect(attr.isCSS).toBeFalsy();
\r
1598 expect(base("$frame").timelines.length).toBe(0);
\r
1600 expect(attr.push(s)).toBeNull();
\r
1601 expect(attr.element).toBeNull();
\r
1602 expect(base("$frame").timelines.length).toBe(0);
\r
1603 expect(attr.hasAttrValues()).toBeFalsy();
\r
1605 var p = document.createElement("g");
\r
1607 expect(attr.push(s)).toBeNull();
\r
1608 expect(attr.element).toBe(p);
\r
1609 expect(base("$frame").timelines.length).toBe(0);
\r
1611 s.setAttribute("end", "0");
\r
1615 check("values", 4);
\r
1616 function check(attrName, num) {
\r
1617 s.setAttribute(attrName, "1");
\r
1618 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1619 var l = attr.push(s);
\r
1620 expect(attr.element).toBe(p);
\r
1621 var timelines = base("$frame").timelines;
\r
1622 expect(timelines.length).toBe(num);
\r
1623 var line = timelines[num-1];
\r
1624 expect(line.string).toBe("0");
\r
1625 expect(line).toBe(l); //タイムラインのオブジェクトを返す
\r
1626 var act = line.$activate;
\r
1627 expect(act.dur).toBeNull();
\r
1628 expect(act.end).toBe(0);
\r
1629 expect(act.repeatCount).toBeNull();
\r
1630 expect(act.repeatDur).toBeNull();
\r
1631 expect(act.min).toBe("0");
\r
1632 expect(act.max).toBe("indefinite");
\r
1633 expect(act.simpleDur).toBeNull();
\r
1634 expect(attr.hasAttrValues()).toBeTruthy();
\r
1636 s.removeAttribute(attrName);
\r
1637 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1639 expect(attr.element).toBe(p);
\r
1640 expect(timelines.length).toBe(num);
\r
1643 /*targetElement属性のサポート*/
\r
1644 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1645 document.documentElement.appendChild(p2);
\r
1646 p2.setAttributeNS(null, "id", "p23");
\r
1647 s.setAttributeNS(null, "targetElement", "p23");
\r
1649 expect(attr.element).toBe(p2);
\r
1652 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1653 document.documentElement.appendChild(p3);
\r
1654 p3.setAttributeNS(null, "id", "p34");
\r
1655 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1657 expect(attr.element).toBe(p3);
\r
1659 /*attributeType属性のサポート*/
\r
1660 s.setAttributeNS(null, "attributeType", "CSS");
\r
1661 s.setAttributeNS(null, "values", "a;b;c");
\r
1663 expect(attr.isCSS).toBeTruthy();
\r
1665 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1666 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1667 s.setAttribute("from", "1");
\r
1668 var p = document.createElement("g");
\r
1670 var values = [ "0",
\r
1671 "0", null, null, null,
\r
1672 "0", "indefinite", null
\r
1675 check2("dur", "0");
\r
1676 check2("begin", "0");
\r
1678 check2("begin", "1");
\r
1680 check2("end", "0");
\r
1682 check2("repeatCount", "0");
\r
1684 check2("repeatDur", "0");
\r
1686 check2("min", "0");
\r
1688 check2("max", "0");
\r
1690 check2("begin", "12");
\r
1691 values[7] = 1000 * base("$frame").fpms;
\r
1693 check2("dur", "1");
\r
1694 function check2(attrName, value) {
\r
1695 s.setAttribute(attrName, value);
\r
1696 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1698 expect(attr.element).toBe(p);
\r
1699 var timelines = base("$frame").timelines;
\r
1700 var line = timelines[timelines.length-1];
\r
1701 expect(line.string).toBe(values[0]);
\r
1702 var act = line.$activate;
\r
1703 expect(act.dur).toBe(values[1]);
\r
1704 expect(act.end).toBe(values[2]);
\r
1705 expect(act.repeatCount).toBe(values[3]);
\r
1706 expect(act.repeatDur).toBe(values[4]);
\r
1707 expect(act.min).toBe(values[5]);
\r
1708 expect(act.max).toBe(values[6]);
\r
1709 expect(act.simpleDur).toBe(values[7]);
\r
1713 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1714 document.documentElement.appendChild(p4);
\r
1715 p4.appendChild(s);
\r
1716 p4.setAttributeNS(null, "style", "display: none");
\r
1718 expect(attr.setAttribute()).toBeUndefined();
\r
1719 expect(attr.setAttribute("block")).toBeUndefined();
\r
1720 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1721 expect(attr.isCSS).toBeFalsy();
\r
1723 s.setAttributeNS(null, "attributeName", "display");
\r
1725 expect(attr.setAttribute("block")).toBeUndefined();
\r
1726 expect(p4.hasAttributeNS(null, "display")).toBeTruthy();
\r
1727 expect(attr.isCSS).toBeTruthy();
\r
1728 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1730 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1731 document.documentElement.appendChild(p4);
\r
1732 p4.appendChild(s);
\r
1733 p4.setAttributeNS(null, "style", "display: none");
\r
1735 expect(attr.setAttribute("block")).toBeUndefined();
\r
1736 expect(p4.hasAttributeNS(null, "display")).toBeTruthy();
\r
1737 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1738 expect(attr.removeAttribute()).toBeUndefined();
\r
1739 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1740 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1742 /*attributeType属性のサポート*/
\r
1743 s.setAttributeNS(null, "values", "a;b;c");
\r
1744 s.setAttributeNS(null, "attributeName", "display");
\r
1745 attr.isCSS = false;
\r
1747 expect(attr.isCSS).toBeTruthy();
\r
1749 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1750 it("should be this for the value (the invalid partion )", function() {
\r
1751 var p = document.createElement("g");
\r
1754 s.setAttributeNS(null, "begin", "1");
\r
1756 var timelines = base("$frame").timelines;
\r
1757 expect(timelines.length).toBe(0);
\r
1758 s.setAttributeNS(null, "from", "1");
\r
1760 expect(timelines.length).toBe(1);
\r
1761 expect(attr.push(12)).toBeNull();
\r
1764 describe("A setValues method", function() {
\r
1766 beforeEach( function() {
\r
1767 attr = base("$calcMode").$attribute.up("width");
\r
1768 base("$frame").timelines.length = 0;
\r
1769 s = document.createElement("animate");
\r
1771 /*境界条件を調べておく (limit value analysis)*/
\r
1772 it("should be this for the value (limit value analysis)", function() {
\r
1773 expect(attr.$from).not.toBeUndefined();
\r
1774 expect(attr.setValues()).toBeNull();
\r
1775 expect(attr.setValues("")).toBeNull();
\r
1777 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1778 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
1779 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
1780 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
1782 /*from-to アニメーション*/
\r
1783 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1784 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
1786 /*from-by アニメーション*/
\r
1787 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1788 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1789 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1791 /*fromなしto アニメーション*/
\r
1792 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1793 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
1794 var aset = attr.setValues(null, null, "1")[0].to;
\r
1796 expect(aset.from[0]).toBe(0);
\r
1798 /*fromなしby アニメーション*/
\r
1799 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1800 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1801 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1803 expect(aset.from[0]).toBe(0);
\r
1805 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1806 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1807 attr.$from.degit = 1;
\r
1808 var setv = attr.setValues("0;1")[0].call();
\r
1809 expect(setv(0.5)).toBe("0.5");
\r
1810 expect(setv(1)).toBe("1.0");
\r
1812 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1813 expect(setv(0.5)).toBe("0.5");
\r
1814 expect(setv(1)).toBe("1.0");
\r
1815 setv = attr.setValues("0;1;2")[1].call();
\r
1816 expect(setv(0.4)).toBe("1.4");
\r
1817 expect(setv(1)).toBe("2.0");
\r
1819 attr.$from.degit = 2;
\r
1820 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
1821 expect(setv(0.5)).toBe("8.05");
\r
1822 expect(setv(1)).toBe("15.10");
\r
1824 var v = attr.setValues("1;1;2;1;1;15.1");
\r
1825 setv = v[4].mix( {
\r
1828 expect(setv(0.05)).toBe("8.05");
\r
1829 expect(setv(0.1)).toBe("15.10");
\r
1830 setv = v[3].mix( {
\r
1833 expect(setv(0.01)).toBe("1.00");
\r
1834 expect(setv(0.1)).toBe("1.00");
\r
1835 setv = v[2].mix( {
\r
1838 expect(setv(0.25)).toBe("1.50");
\r
1839 expect(setv(0.5)).toBe("1.00");
\r
1841 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1842 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1843 attr.$from.degit = 1;
\r
1844 expect(attr.setValues("")).toBeNull();
\r
1845 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
1848 describe("A setKey method", function() {
\r
1850 beforeEach( function() {
\r
1851 attr = base("$calcMode").$attribute.up("width");
\r
1852 base("$frame").timelines.length = 0;
\r
1853 s = document.createElement("animate");
\r
1854 document.createElement("g").appendChild(s);
\r
1856 /*境界条件を調べておく (limit value analysis)*/
\r
1857 it("should be this for the value (limit value analysis)", function() {
\r
1858 expect(attr.setKey(s)).toBeNull();
\r
1860 s.setAttributeNS(null, "from", "0");
\r
1862 s.setAttributeNS(null, "to", "0");
\r
1863 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1864 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
1865 s.setAttributeNS(null, "by", "0");
\r
1867 s.setAttributeNS(null, "values", "0;2");
\r
1868 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
1869 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
1871 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
1872 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1874 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
1875 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1876 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1877 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1878 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1880 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
1881 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
1882 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
1883 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
1884 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
1886 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1887 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1888 s.setAttributeNS(null, "values", "0;2;12;30");
\r
1889 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
1890 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1891 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1892 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1893 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1894 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
1895 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
1896 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1897 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1898 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1900 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
1901 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
1902 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
1903 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
1905 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
1906 f(0, 0,0.1,0.3,1);
\r
1907 f(1, 0.1,0.4,0.5,0.7);
\r
1908 f(2, 0.2,0.2,0.1,1);
\r
1910 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
1911 f(0, 0,0.1,0.3,1);
\r
1912 f(1, 0.1,0.4,0.5,0.7);
\r
1913 f(2, 0.2,0.2,0.1,1);
\r
1915 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
1916 f(0, 0,0.1,0.333,1);
\r
1917 f(1, 0.1,0.4,0.5,0.7);
\r
1918 f(2, 0.2,0.2,0.1,1);
\r
1919 function f (i, a, b, c, d) {
\r
1920 var splines = attr.setKey(s)[i].keySplines;
\r
1921 expect(splines[0]).toBe(a);
\r
1922 expect(splines[1]).toBe(b);
\r
1923 expect(splines[2]).toBe(c);
\r
1924 expect(splines[3]).toBe(d);
\r
1927 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1928 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1929 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
1930 expect(attr.setKey(s)).toBeNull();
\r
1931 s.setAttributeNS(null, "values", "0;2;12");
\r
1932 expect(attr.setKey(s)).toBeNull();
\r
1933 s.setAttributeNS(null, "values", "0;2;12;20");
\r
1934 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
1935 expect(attr.setKey(s)).toBeNull();
\r
1939 describe("A $setElemenet object", function() {
\r
1940 describe("A timeline property", function() {
\r
1941 var $set, ele, frame;
\r
1942 beforeEach( function() {
\r
1943 $set = base("$calcMode").$attribute.$setElement.up();
\r
1944 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1945 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1946 p.appendChild(ele);
\r
1947 frame = base("$frame");
\r
1949 /*境界条件を調べておく (limit value analysis)*/
\r
1950 it("should be this for the value (limit value analysis)", function() {
\r
1951 expect($set.timeline).toBe(frame.$begin);
\r
1954 expect($set.timeline).toBe(frame.$begin);
\r
1955 expect($set.element).toBeNull();
\r
1958 describe("An init method", function() {
\r
1959 var $set, ele, frame;
\r
1960 beforeEach( function() {
\r
1961 $set = base("$calcMode").$attribute.$setElement.up();
\r
1962 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1963 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
1964 p.appendChild(ele);
\r
1965 frame = base("$frame");
\r
1967 /*境界条件を調べておく (limit value analysis)*/
\r
1968 it("should be this for the value (limit value analysis)", function() {
\r
1969 expect($set.to).toBe("");
\r
1970 expect($set.attrName).toBe("");
\r
1971 expect($set.defaultValue).toBe("");
\r
1972 expect($set.isDefault).toBeFalsy();
\r
1973 expect($set.attrNameSpace).toBeNull();
\r
1975 expect($set.timeline).toBe(frame.$begin);
\r
1977 expect($set.to).toBe("");
\r
1978 expect($set.attrName).toBe("");
\r
1979 expect($set.isDefault).toBeFalsy();
\r
1980 expect($set.attrNameSpace).toBeNull();
\r
1981 expect($set.timeline).toBe(frame.$begin);
\r
1983 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1984 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1985 ele.setAttributeNS(null, "to", "t1");
\r
1987 expect($set.to).toBe("t1");
\r
1988 expect($set.attrName).toBe("");
\r
1989 expect($set.defaultValue).toBe("");
\r
1991 ele.setAttributeNS(null, "attributeName", "tt1");
\r
1993 expect($set.to).toBe("t1");
\r
1994 expect($set.attrName).toBe("tt1");
\r
1995 expect($set.defaultValue).toBe("");
\r
1997 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
1999 expect($set.defaultValue).toBe("undef");
\r
2000 expect($set.isDefault).toBeTruthy();
\r
2002 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2003 ele.parentNode.style.setProperty("font-size", "12px");
\r
2005 expect($set.defaultValue).toBe("12px");
\r
2006 expect($set.isDefault).toBeFalsy();
\r
2008 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2010 expect($set.to).toBe("t1");
\r
2011 expect($set.attrName).toBe("xlink:href");
\r
2012 expect($set.defaultValue).toBe("");
\r
2013 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2015 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2017 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2018 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2020 expect($set.to).toBe("");
\r
2021 expect($set.attrName).toBe("");
\r
2022 expect($set.defaultValue).toBe("");
\r
2025 expect($set.to).toBe("");
\r
2026 expect($set.attrName).toBe("");
\r
2027 expect($set.defaultValue).toBe("");
\r
2030 describe("Frame Set", function() {
\r
2031 var $set, ele, frame;
\r
2032 beforeEach( function() {
\r
2033 $set = base("$calcMode").$attribute.$setElement.up();
\r
2034 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2035 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2036 p.appendChild(ele);
\r
2037 frame = base("$frame");
\r
2038 frame.timelines.length = 0; //配列の初期化
\r
2039 frame.startTime = Date.now();
\r
2040 frame.setFrame(0);
\r
2042 /*境界条件を調べておく (limit value analysis)*/
\r
2043 it("should be this for the value (limit value analysis)", function() {
\r
2044 expect($set.isEnd).toBeFalsy();
\r
2045 expect($set.state).toBe("idling");
\r
2046 ele.setAttributeNS(null, "dur", "1s");
\r
2047 ele.setAttributeNS(null, "attributeName", "fill");
\r
2048 ele.setAttributeNS(null, "to", "red");
\r
2050 expect($set.timeline).not.toBe(frame.$begin);
\r
2051 frame.setFrame(0);
\r
2052 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2053 expect($set.state).toBe("playing");
\r
2055 frame.setFrame(24);
\r
2056 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2057 expect($set.state).toBe("idling");
\r
2059 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2060 it("should be this for the value (the valid partion)", function() {
\r
2061 ele.setAttributeNS(null, "begin", "1s");
\r
2062 ele.setAttributeNS(null, "dur", "1s");
\r
2063 ele.setAttributeNS(null, "attributeName", "fill");
\r
2064 ele.setAttributeNS(null, "to", "red");
\r
2066 var f = function(num) {
\r
2067 frame.setFrame(num);
\r
2068 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2073 frame.setFrame(24);
\r
2074 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2075 frame.setFrame(25);
\r
2076 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2080 ele.setAttributeNS(null, "fill", "freeze");
\r
2085 frame.setFrame(24);
\r
2086 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2087 frame.setFrame(25);
\r
2088 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2089 frame.setFrame(48);
\r
2090 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2091 frame.setFrame(49);
\r
2092 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2093 ele.setAttributeNS(null, "begin", "1s");
\r
2094 ele.setAttributeNS(null, "attributeName", "fill");
\r
2095 ele.setAttributeNS(null, "to", "red");
\r
2096 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2098 var f = function(num) {
\r
2099 frame.setFrame(num);
\r
2100 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2108 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2109 it("should be this for the value (the invalid partion)", function() {
\r
2114 describe("A $animateElement object", function() {
\r
2115 describe("An init method", function() {
\r
2116 var $animate, ele, frame;
\r
2117 beforeEach( function() {
\r
2118 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2119 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2120 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2121 p.appendChild(ele);
\r
2122 frame = base("$frame");
\r
2123 frame.timelines.length = 0;
\r
2124 frame.startTime = Date.now();
\r
2125 frame.setFrame(0);
\r
2127 /*境界条件を調べておく (limit value analysis)*/
\r
2128 it("should be this for the value (limit value analysis)", function() {
\r
2131 ele.setAttributeNS(null, "begin", "1s");
\r
2132 ele.setAttributeNS(null, "dur", "1s");
\r
2133 ele.setAttributeNS(null, "attributeName", "d");
\r
2134 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2135 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2136 $animate.init(ele);
\r
2138 frame.setFrame(0);
\r
2139 var p = ele.parentNode;
\r
2140 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2141 * 他のブラウザではnullを返すため、その対策をする*/
\r
2142 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2144 function f(fr, result) {
\r
2145 frame.setFrame(fr);
\r
2146 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2149 f(24, "M20.0 0.0 L20.0 30.0");
\r
2150 f(36, "M20.0 10.0 L15.0 30.0");
\r
2153 ele.setAttributeNS(null, "fill", "freeze");
\r
2154 $animate.init(ele);
\r
2155 f(24, "M20.0 0.0 L20.0 30.0");
\r
2156 f(36, "M20.0 10.0 L15.0 30.0");
\r
2157 f(48, "M20.0 20.0 L10.0 30.0");
\r
2159 frame.timelines.length = 0;
\r
2160 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2161 $animate.init(ele);
\r
2162 expect($animate.mode).toBe("discrete");
\r
2163 f(24, "M20.0 0.0 L20.0 30.0");
\r
2164 f(25, "M20.0 0.0 L20.0 30.0");
\r
2165 f(37, "M20.0 20.0 L10.0 30.0");
\r
2166 f(48, "M20.0 20.0 L10.0 30.0");
\r
2168 ["display", "visibility", "xlink:href",
\r
2169 "stroke-linecap", "font-style"].forEach( function(attrName) {
\r
2170 function g(fr, result) {
\r
2171 frame.setFrame(fr);
\r
2172 expect(p.getAttribute(attrName) || "").toBe(result);
\r
2175 frame.timelines.length = 0;
\r
2176 ele.setAttributeNS(null, "calcMode", "linear");
\r
2177 ele.setAttributeNS(null, "attributeName", attrName);
\r
2178 $animate.init(ele);
\r
2179 expect($animate.mode).toBe("discrete");
\r
2180 g(24, "M20.0 0.0 L20.0 30.0");
\r
2181 g(25, "M20.0 0.0 L20.0 30.0");
\r
2182 g(37, "M20.0 20.0 L10.0 30.0");
\r
2183 g(48, "M20.0 20.0 L10.0 30.0");
\r
2186 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2187 it("should be this for the value (the valid partion )", function() {
\r
2189 ele.setAttributeNS(null, "begin", "0s");
\r
2190 ele.setAttributeNS(null, "dur", "100s");
\r
2191 ele.setAttributeNS(null, "attributeName", "d");
\r
2192 ele.setAttributeNS(null, "fill", "freeze");
\r
2193 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2194 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2195 $animate.init(ele);
\r
2197 var p = ele.parentNode;
\r
2198 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2200 function f(fr, result) {
\r
2201 frame.setFrame(fr);
\r
2202 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2205 for (var i=0;i<2400;++i) {
\r
2206 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2208 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2211 frame.timelines.length = 0;
\r
2212 ele.setAttributeNS(null, "begin", "0s");
\r
2213 ele.setAttributeNS(null, "dur", "1s");
\r
2214 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2215 ele.setAttributeNS(null, "attributeName", "d");
\r
2216 ele.setAttributeNS(null, "fill", "freeze");
\r
2217 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2218 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2219 $animate.init(ele);
\r
2220 f(23, "M20.0 23.0 L20.0 30.0");
\r
2221 f(24, "M20.0 0.0 L20.0 30.0");
\r
2222 f(25, "M20.0 1.0 L20.0 30.0");
\r
2223 f(48, "M20.0 24.0 L20.0 30.0");
\r
2225 frame.timelines.length = 0;
\r
2226 ele.setAttributeNS(null, "begin", "0s");
\r
2227 ele.setAttributeNS(null, "dur", "2s");
\r
2228 ele.setAttributeNS(null, "attributeName", "d");
\r
2229 ele.setAttributeNS(null, "fill", "freeze");
\r
2230 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2231 $animate.init(ele);
\r
2232 f(0, "M20.0 0.0 L20.0 30.0");
\r
2233 f(1, "M20.0 1.0 L20.0 30.0");
\r
2234 f(24, "M20.0 24.0 L20.0 30.0");
\r
2235 f(25, "M20.0 24.1 L20.0 30.0");
\r
2236 f(47, "M20.0 26.3 L20.0 30.0");
\r
2237 f(48, "M20.0 26.4 L20.0 30.0");
\r
2238 f(49, "M20.0 26.4 L20.0 30.0");
\r
2239 f(50, "M20.0 26.4 L20.0 30.0");
\r
2241 frame.timelines.length = 0;
\r
2242 ele.setAttributeNS(null, "begin", "0s");
\r
2243 ele.setAttributeNS(null, "end", "2s");
\r
2244 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2245 ele.removeAttributeNS(null, "repeatDur");
\r
2246 ele.setAttributeNS(null, "attributeName", "d");
\r
2247 ele.setAttributeNS(null, "fill", "freeze");
\r
2248 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2249 $animate.init(ele);
\r
2250 f(0, "M20.0 0.0 L20.0 30.0");
\r
2251 f(1, "M20.0 0.0 L20.0 30.0");
\r
2252 f(24, "M20.0 0.0 L20.0 30.0");
\r
2253 f(25, "M20.0 0.0 L20.0 30.0");
\r
2254 f(47, "M20.0 0.0 L20.0 30.0");
\r
2255 f(48, "M20.0 0.0 L20.0 30.0");
\r
2256 f(49, "M20.0 0.0 L20.0 30.0");
\r
2257 f(50, "M20.0 0.0 L20.0 30.0");
\r
2259 frame.timelines.length = 0;
\r
2260 ele.setAttributeNS(null, "dur", "2s");
\r
2261 ele.setAttributeNS(null, "fill", "remove");
\r
2262 var attrValue = p.getAttributeNS(null, "d");
\r
2263 $animate.init(ele);
\r
2266 frame.timelines.length = 0;
\r
2267 p.removeAttributeNS(null, "d");
\r
2268 ele.setAttributeNS(null, "fill", "freeze");
\r
2269 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2270 $animate.init(ele);
\r
2271 f(1, "M20.0 5.0 L20.0 30.0");
\r
2272 f(48, "M20.0 26.4 L20.0 30.0");
\r
2274 frame.timelines.length = 0;
\r
2275 ele.setAttributeNS(null, "fill", "freeze");
\r
2276 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2277 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2278 $animate.init(ele);
\r
2279 f(1, "M20.0 0.0 L20.0 30.0");
\r
2280 f(4, "M20.0 0.0 L20.0 30.0");
\r
2281 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2283 f(24, "M20.0 24.0 L20.0 30.0");
\r
2284 f(25, "M20.0 24.0 L20.0 30.0");
\r
2285 f(29, "M20.0 26.4 L20.0 30.0");
\r
2286 f(48, "M20.0 26.4 L20.0 30.0");
\r
2288 frame.timelines.length = 0;
\r
2289 ele.setAttributeNS(null, "calcMode", "spline");
\r
2290 ele.removeAttributeNS(null, "keyTimes");
\r
2291 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2292 ele.removeAttributeNS(null, "end");
\r
2293 ele.setAttributeNS(null, "dur", "9s");
\r
2294 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2295 $animate.init(ele);
\r
2302 frame.timelines.length = 0;
\r
2303 ele.setAttributeNS(null, "calcMode", "spline");
\r
2304 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2305 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2306 ele.setAttributeNS(null, "dur", "8s");
\r
2307 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2308 $animate.init(ele);
\r
2316 frame.timelines.length = 0;
\r
2317 ele.setAttributeNS(null, "begin", "click");
\r
2318 ele.setAttributeNS(null, "calcMode", "spline");
\r
2319 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2320 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2321 ele.setAttributeNS(null, "dur", "8s");
\r
2322 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2323 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2324 $animate.init(ele);
\r
2331 ["display", "visibility", "xlink:href",
\r
2332 "stroke-linecap", "font-style"].forEach( function(attrName) {
\r
2333 function g(fr, result) {
\r
2334 frame.setFrame(fr);
\r
2335 expect(p.getAttribute(attrName)).toBe(result);
\r
2338 frame.timelines.length = 0;
\r
2339 ele.setAttributeNS(null, "begin", "0s");
\r
2340 ele.setAttributeNS(null, "calcMode", "linear");
\r
2341 ele.setAttributeNS(null, "attributeName", attrName);
\r
2342 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2343 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2344 ele.setAttributeNS(null, "dur", "8s");
\r
2345 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2346 $animate.init(ele);
\r
2347 expect($animate.mode).toBe("discrete");
\r
2354 frame.timelines.length = 0;
\r
2355 ele.setAttributeNS(null, "begin", "click");
\r
2356 ele.setAttributeNS(null, "calcMode", "linear");
\r
2357 ele.setAttributeNS(null, "attributeName", attrName);
\r
2358 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2359 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2360 ele.setAttributeNS(null, "dur", "8s");
\r
2361 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2362 $animate.init(ele);
\r
2363 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2364 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2365 p.dispatchEvent(evt);
\r
2366 var cur = base("$frame").currentFrame;
\r
2367 expect($animate.mode).toBe("discrete");
\r
2368 g(cur+0, "inline");
\r
2369 g(cur+48, "block");
\r
2370 g(cur+96, "inline");
\r
2371 g(cur+192, "block");
\r
2372 g(cur+300, "block");
\r
2375 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2376 it("should be this for the value (the invalid partion )", function() {
\r
2377 ele.setAttributeNS(null, "begin", "0s");
\r
2378 ele.setAttributeNS(null, "dur", "100s");
\r
2379 ele.setAttributeNS(null, "attributeName", "d");
\r
2380 ele.setAttributeNS(null, "fill", "freeze");
\r
2381 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2382 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2383 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2384 $animate.init(ele);
\r
2386 var p = ele.parentNode;
\r
2387 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2389 function f(fr, result) {
\r
2390 frame.setFrame(fr);
\r
2391 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2396 frame.timelines.length = 0;
\r
2397 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2398 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2399 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2400 $animate.init(ele);
\r
2404 /*keyTimes属性が0から始まっていない*/
\r
2405 frame.timelines.length = 0;
\r
2406 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2410 function ff(mode) {
\r
2411 ele.setAttributeNS(null, "calcMode", mode);
\r
2412 $animate.init(ele);
\r
2417 frame.timelines.length = 0;
\r
2418 ele.setAttributeNS(null, "calcMode", "spline");
\r
2419 $animate.init(ele);
\r
2420 expect($animate.mode).toBe("spline");
\r
2426 describe("RGB Color", function() {
\r
2427 var $animate, ele, frame, f;
\r
2428 beforeEach( function() {
\r
2429 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2430 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2431 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2432 p.appendChild(ele);
\r
2433 frame = base("$frame");
\r
2434 frame.timelines.length = 0;
\r
2436 f = function (fr, result, attr) {
\r
2437 frame.setFrame(fr);
\r
2438 expect(p.getAttributeNS(null, attr)).toBe(result);
\r
2441 /*境界条件を調べておく (limit value analysis)*/
\r
2442 it("should be this for the value (limit value analysis)", function() {
\r
2443 ele.setAttributeNS(null, "begin", "0s");
\r
2444 ele.setAttributeNS(null, "dur", "1s");
\r
2445 ele.setAttributeNS(null, "attributeName", "fill");
\r
2446 ele.setAttributeNS(null, "fill", "remove");
\r
2447 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2448 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2449 $animate.init(ele);
\r
2451 f(0, "rgb(0, 0, 0)", "fill");
\r
2452 f(23, "rgb(10, 10, 1)", "fill");
\r
2454 frame.timelines.length = 0;
\r
2455 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2456 $animate.init(ele);
\r
2457 f(0, "rgb(0, 0, 0)", "stroke");
\r
2458 f(23, "rgb(10, 10, 1)", "stroke");
\r
2460 frame.timelines.length = 0;
\r
2461 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2462 $animate.init(ele);
\r
2463 f(0, "rgb(0,0,0)", "stop-color");
\r
2464 f(23, "rgb(10,10,1)", "stop-color");
\r
2466 frame.timelines.length = 0;
\r
2467 ele.setAttributeNS(null, "attributeName", "color");
\r
2468 $animate.init(ele);
\r
2469 f(0, "rgb(0,0,0)", "color");
\r
2470 f(23, "rgb(10,10,1)", "color");
\r
2472 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2473 it("should be this for the value (the valid partion )", function() {
\r
2474 ele.setAttributeNS(null, "begin", "0s");
\r
2475 ele.setAttributeNS(null, "dur", "1s");
\r
2476 ele.setAttributeNS(null, "attributeName", "fill");
\r
2477 ele.setAttributeNS(null, "fill", "remove");
\r
2478 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2479 $animate.init(ele);
\r
2481 f(0, "rgb(0, 0, 0)", "fill");
\r
2482 f(1, "rgb(1, 0, 0)", "fill");
\r
2483 f(23, "rgb(23, 2, 1)", "fill");
\r
2485 frame.timelines.length = 0;
\r
2486 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2487 $animate.init(ele);
\r
2490 f(0, "rgb(0, 8, 60)", "fill");
\r
2491 f(1, "rgb(1, 9, 60)", "fill");
\r
2492 f(23, "rgb(23, 31, 60)", "fill");
\r
2494 frame.timelines.length = 0;
\r
2495 ele.setAttributeNS(null, "fill", "freeze");
\r
2496 ele.setAttributeNS(null, "values", "black;white");
\r
2497 $animate.init(ele);
\r
2498 /*色キーワードをrgb形式に変換*/
\r
2500 f(0, "rgb(0, 0, 0)", "fill");
\r
2501 f(12, "rgb(128, 128, 128)", "fill");
\r
2502 f(24, "rgb(255, 255, 255)", "fill");
\r
2504 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2505 it("should be this for the value (the invalid partion )", function() {
\r
2506 ele.setAttributeNS(null, "begin", "0s");
\r
2507 ele.setAttributeNS(null, "dur", "1s");
\r
2508 ele.setAttributeNS(null, "attributeName", "fi");
\r
2509 ele.setAttributeNS(null, "fill", "remove");
\r
2510 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2511 $animate.init(ele);
\r
2514 f(0, "#83.0C", "fi");
\r
2515 f(1, "#84.0C", "fi");
\r
2516 f(23, "#106.0C", "fi");
\r
2519 describe("$frame.$svgEvent object", function() {
\r
2520 var frame = base("$frame").$svgEvent,
\r
2522 base("$frame").pauseAnimation();
\r
2523 beforeEach( function() {
\r
2524 base("$frame").pauseAnimation();
\r
2525 frame = frame.up();
\r
2526 frame.first = null;
\r
2527 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2528 * 影響を受けるため、新たに初期化しておく*/
\r
2529 base("$frame").timelines = frame.timelines = [];
\r
2530 frame.lastTimeLine = null;
\r
2531 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2532 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2533 p.appendChild(ele);
\r
2535 /*境界条件を調べておく (limit value analysis)*/
\r
2536 it("should be this for the value (limit value analysis)", function() {
\r
2537 base("$frame").pauseAnimation();
\r
2538 frame.lastTimeLine = null;
\r
2539 expect(frame.lastTimeLine).toBeNull();
\r
2540 expect(frame.first).toBeNull();
\r
2541 frame.setTimeTable();
\r
2542 expect(frame.first).toBeNull();
\r
2543 frame.addLine( base("$frame").$begin.up().mix({
\r
2549 frame.setTimeTable();
\r
2550 expect(frame.first).toEqual(
\r
2552 eventType: "begin",
\r
2563 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2564 it("should be this for the value (the valid partion )", function() {
\r
2565 base("$frame").pauseAnimation();
\r
2566 frame.addLine( base("$frame").$begin.up().mix({
\r
2572 frame.setTimeTable();
\r
2573 frame.setTimeTable();
\r
2574 expect(frame.first).toEqual(
\r
2576 eventType: "begin",
\r
2586 frame.setTimeTable();
\r
2587 frame.setTimeTable();
\r
2588 expect(frame.first).toEqual(
\r
2590 eventType: "begin",
\r
2601 var isFiredBeginEvent = false;
\r
2602 ele.addEventListener("beginEvent", function(evt) {
\r
2603 isFiredBeginEvent = true;
\r
2604 expect(evt.target).toBe(ele);
\r
2606 ele.addEventListener("endEvent", function(evt) {
\r
2607 expect(evt.target).toBe(ele);
\r
2608 expect(isFiredBeginEvent).toBeTruthy();
\r
2610 frame.setFrame(0);
\r
2611 expect(frame.first).toBeNull();
\r
2612 frame.setFrame(0);
\r
2613 expect(frame.first).toBeNull();
\r
2615 frame.timelines = [];
\r
2616 frame.addLine( base("$frame").$begin.up().mix({
\r
2622 frame.setTimeTable();
\r
2623 var a = { frame: 0,
\r
2624 eventType: "begin",
\r
2627 next: { frame: 10,
\r
2633 expect(frame.first).toEqual(a);
\r
2635 frame.addLine( base("$frame").$begin.up().mix({
\r
2638 simpleDuration: 9,
\r
2642 frame.setTimeTable();
\r
2643 a.next.next = { frame: 1,
\r
2644 eventType: "begin",
\r
2647 next: { firstFrame: 10,
\r
2649 eventType: "repeat",
\r
2652 simpleDuration: 9,
\r
2655 next: { frame: 12,
\r
2662 expect(frame.first).toEqual(a);
\r
2663 frame.setFrame(11);
\r
2664 expect(frame.first).toEqual( {frame: 12,
\r
2670 frame.timelines = [];
\r
2671 frame.first = null;
\r
2672 frame.addLine( base("$frame").$begin.up().mix({
\r
2675 simpleDuration: 4,
\r
2679 frame.setTimeTable();
\r
2681 eventType: "begin",
\r
2684 next: {firstFrame:5,
\r
2686 eventType: "repeat",
\r
2689 simpleDuration: 4,
\r
2692 next: { frame: 11,
\r
2699 expect(frame.first).toEqual(a);
\r
2700 frame.setFrame(0);
\r
2701 expect(frame.first).toEqual(a);
\r
2702 frame.setFrame(1);
\r
2704 expect(frame.first).toEqual(a);
\r
2705 frame.setFrame(5);
\r
2708 expect(frame.first).toEqual(a);
\r
2710 ele.addEventListener("repeatEvent", function(evt) {
\r
2711 expect(evt.target).toBe(ele);
\r
2713 frame.timelines = [];
\r
2714 frame.first = null;
\r
2715 frame.addLine( base("$frame").$begin.up().mix({
\r
2718 simpleDuration: 4,
\r
2722 frame.setFrame(9);
\r
2725 a.next.frame = 16;
\r
2726 expect(frame.first).toEqual(a);
\r
2728 afterEach( function() {
\r
2729 base("$frame").startAnimation();
\r
2732 describe("A $animateTransformElemenet object", function() {
\r
2733 describe("An init method", function() {
\r
2734 var $animate, ele, frame, p;
\r
2735 beforeEach( function() {
\r
2736 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2737 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2738 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2739 p.appendChild(ele);
\r
2740 frame = base("$frame");
\r
2741 frame.timelines.length = 0;
\r
2742 frame.startTime = Date.now();
\r
2743 frame.setFrame(0);
\r
2745 afterEach( function() {
\r
2746 $animate.numberOfList = -1;
\r
2748 /*境界条件を調べておく (limit value analysis)*/
\r
2749 it("should be this for the value (limit value analysis)", function() {
\r
2750 expect($animate.numberOfList).toBe(-1);
\r
2751 expect($animate.type).toBe("translate");
\r
2752 expect(p.__transformList).toBeUndefined();
\r
2755 expect($animate.numberOfList).toBe(-1);
\r
2756 expect(p.__transformList).toBeUndefined();
\r
2757 expect($animate.type).toBe("translate");
\r
2760 expect($animate.numberOfList).toBe(-1);
\r
2761 expect(p.__transformList).toBeUndefined();
\r
2762 expect($animate.type).toBe("translate");
\r
2764 $animate.init(ele);
\r
2765 expect($animate.numberOfList).toBe(-1);
\r
2766 expect(p.__transformList).toEqual([]);
\r
2768 ele.setAttributeNS(null, "values", "0;1");
\r
2769 $animate.init(ele);
\r
2770 expect($animate.type).toBe("translate");
\r
2771 expect($animate.numberOfList).toBe(0);
\r
2772 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2773 value: "translate(0)",
\r
2777 ele.setAttributeNS(null, "type", "translate");
\r
2778 $animate.init(ele);
\r
2779 expect($animate.numberOfList).toBe(0);
\r
2780 expect($animate.type).toBe("translate");
\r
2781 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2782 value: "translate(0)",
\r
2785 $animate.tocall(0);
\r
2786 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2788 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2789 $animate.numberOfList = -1;
\r
2790 $animate.init(ele.parentNode.lastChild);
\r
2791 expect($animate.numberOfList).toBe(1);
\r
2792 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2793 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2795 expect($animate.type).toBe("translate");
\r
2796 $animate.tocall(0);
\r
2797 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2798 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2799 $animate._setEndFrame(1);
\r
2800 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2801 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2803 delete p.__transformList;
\r
2804 ele.setAttributeNS(null, "type", "scale");
\r
2805 $animate.numberOfList = -1;
\r
2806 $animate.init(ele);
\r
2807 expect($animate.numberOfList).toBe(0);
\r
2808 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2809 value: "translate(0)",
\r
2812 expect($animate.type).toBe("scale");
\r
2814 delete p.__transformList;
\r
2815 $animate.numberOfList = -1;
\r
2816 ele.setAttributeNS(null, "additive", "sum");
\r
2817 $animate.init(ele);
\r
2818 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2819 value: "translate(0)",
\r
2822 delete p.__transformList;
\r
2823 $animate.numberOfList = -1;
\r
2824 ele.setAttributeNS(null, "additive", "replace");
\r
2825 $animate.init(ele);
\r
2826 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2827 value: "translate(0)",
\r
2831 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2832 it("should be this for the value (the valid partion )", function() {
\r
2833 ele.setAttributeNS(null, "type", "scale");
\r
2834 ele.setAttributeNS(null, "values", "0;1");
\r
2835 $animate.init(ele);
\r
2836 expect($animate.numberOfList).toBe(0);
\r
2837 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2838 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
2839 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
2840 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2842 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2843 $animate.numberOfList = -1;
\r
2844 $animate.init(ele.parentNode.lastChild);
\r
2845 expect($animate.numberOfList).toBe(1);
\r
2846 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2847 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2849 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2850 $animate.up("$a").numberOfList = -1;
\r
2851 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2852 $animate.$a.init(ele.parentNode.lastChild);
\r
2853 expect($animate.$a.numberOfList).toBe(2);
\r
2854 expect($animate.$a.isDefault).toBeTruthy();
\r
2855 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2856 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
2857 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
2858 $animate.defaultValue = $animate.$a.defaultValue;
\r
2859 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
2861 ele.setAttributeNS(null, "additive", "sum");
\r
2862 var parentNode = ele.parentNode;
\r
2863 parentNode.appendChild(ele.cloneNode(true));
\r
2864 parentNode.__transformList = [];
\r
2865 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
2866 parentNode.removeChild(ele);
\r
2867 $animate.numberOfList = -1;
\r
2868 $animate.init(parentNode.lastChild);
\r
2869 expect($animate.numberOfList).toBe(0);
\r
2870 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2871 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2873 parentNode.appendChild(ele.cloneNode(true));
\r
2874 $animate.up("$a").numberOfList = -1;
\r
2875 parentNode.__transformList = [];
\r
2876 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2877 $animate.$a.init(parentNode.lastChild);
\r
2878 expect($animate.$a.numberOfList).toBe(0);
\r
2879 expect($animate.$a.isDefault).toBeTruthy();
\r
2880 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2881 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2882 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2883 $animate.defaultValue = $animate.$a.defaultValue;
\r
2884 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
2886 ele.removeAttributeNS(null, "additive");
\r
2887 ad("replace", "sum", "scale(0.0)", "scale(0.0) scale(0.0)",
\r
2888 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
2889 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
2890 "scale(0.0)", "scale(1.0)");
\r
2891 function ad(first, second, a, b, c, d) {
\r
2893 while (parentNode.firstChild) {
\r
2894 parentNode.removeChild(parentNode.firstChild);
\r
2897 /*additive属性のreplaceとsumの混合*/
\r
2898 ele.setAttributeNS(null, "additive", first);
\r
2899 parentNode.appendChild(ele.cloneNode(true));
\r
2900 ele.setAttributeNS(null, "additive", second);
\r
2901 parentNode.appendChild(ele.cloneNode(true));
\r
2902 parentNode.__transformList = [];
\r
2903 $animate.numberOfList = -1;
\r
2904 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2905 $animate.up("$first").init(parentNode.firstChild);
\r
2906 $animate.up("$second").init(parentNode.lastChild);
\r
2907 expect($animate.$first.numberOfList).toBe(0);
\r
2908 expect($animate.$second.numberOfList).toBe(1);
\r
2909 expect($animate.$first.tocall(0)).toBe(a);
\r
2910 expect($animate.$second.tocall(0)).toBe(b);
\r
2911 expect($animate.$first.tocall(1)).toBe(c);
\r
2912 expect($animate.$second.tocall(1)).toBe(d);
\r
2915 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2916 it("should be this for the value (the invalid partion )", function() {
\r
2917 $animate.init(ele);
\r
2918 ele.parentNode.__transformList = null;
\r
2919 expect( function () {
\r
2920 $animate.tocall(0);
\r
2923 $animate.numberOfList = -1;
\r
2924 $animate.init(ele);
\r
2925 $animate.numberOfList = -1;
\r
2926 expect( function () {
\r
2927 $animate.tocall(0);
\r
2932 describe("A $motionElement object", function() {
\r
2933 describe("An init method", function() {
\r
2934 var $animate, ele, frame, p;
\r
2935 beforeEach( function() {
\r
2936 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
2937 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2938 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
2939 p.appendChild(ele);
\r
2940 frame = base("$frame");
\r
2941 frame.timelines.length = 0;
\r
2942 frame.startTime = Date.now();
\r
2943 frame.setFrame(0);
\r
2945 afterEach( function() {
\r
2946 $animate.numberOfList = -1;
\r
2947 p.__transformList = null;
\r
2949 /*境界条件を調べておく (limit value analysis)*/
\r
2950 it("should be this for the value (limit value analysis)", function() {
\r
2951 expect($animate.type).toBe("translate");
\r
2952 ele.setAttributeNS(null, "type", "scale");
\r
2953 $animate.init(ele);
\r
2954 expect($animate.type).toBe("translate");
\r
2956 ele.setAttributeNS(null, "values", "0;1");
\r
2957 $animate.up("$a").init(ele);
\r
2958 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
2959 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
2960 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
2962 var ec = ele.cloneNode(true);
\r
2963 ec.removeAttributeNS(null, "values");
\r
2964 ec.setAttributeNS(null, "from", "0");
\r
2965 ec.setAttributeNS(null, "to", "1");
\r
2966 $animate.up("$a").init(ec);
\r
2967 expect($animate.$a.tocall(0)).toBe("translate(0.0)");
\r
2968 expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");
\r
2969 expect($animate.$a.tocall(1)).toBe("translate(1.0)");
\r
2974 describe("Event", function() {
\r
2975 var $animate, ele, frame, p;
\r
2976 beforeEach( function() {
\r
2978 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2979 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2980 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2981 p.appendChild(ele);
\r
2982 frame = base("$frame");
\r
2983 frame.pauseAnimation();
\r
2984 frame.timelines.length = 0; //配列の初期化
\r
2985 frame.setFrame(0);
\r
2987 /*境界条件を調べておく (limit value analysis)*/
\r
2988 it("should be this for the value (limit value analysis)", function() {
\r
2989 ele.addEventListener("beginEvent", function(evt) {
\r
2990 expect(evt.target).toBe(ele);
\r
2992 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2993 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
2994 ele.dispatchEvent(evt);
\r
2996 ele.setAttributeNS(null, "begin", "mousedown");
\r
2997 ele.setAttributeNS(null, "dur", "1s");
\r
2998 ele.setAttributeNS(null, "attributeName", "fill");
\r
2999 ele.setAttributeNS(null, "fill", "freeze");
\r
3000 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3001 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3002 $animate.init(ele);
\r
3003 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3004 expect($animate.state).toBe("idling");
\r
3005 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3006 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3007 expect($animate.state).toBe("idling");
\r
3008 p.dispatchEvent(evt);
\r
3009 expect($animate.state).toBe("idling");
\r
3010 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3012 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3013 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3014 frame.setFrame(frame.currentFrame);
\r
3015 expect($animate.isEnd).toBeFalsy();
\r
3016 expect($animate.state).toBe("idling");
\r
3017 p.dispatchEvent(evt);
\r
3018 frame.setFrame(frame.currentFrame + 1);
\r
3019 expect($animate.state).toBe("playing");
\r
3020 frame.setFrame(frame.currentFrame + 24);
\r
3021 expect($animate.state).toBe("idling");
\r
3022 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3025 describe("a beginElement method and an endElement method", function() {
\r
3026 var $animate, ele, frame, p;
\r
3027 beforeEach( function() {
\r
3028 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3029 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3030 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3031 p.appendChild(ele);
\r
3032 frame = base("$frame");
\r
3033 frame.timelines.length = 0; //配列の初期化
\r
3034 frame.setFrame(0);
\r
3035 ele.setAttributeNS(null, "begin", "indefinite");
\r
3036 ele.setAttributeNS(null, "dur", "1s");
\r
3037 ele.setAttributeNS(null, "dur", "1s");
\r
3038 ele.setAttributeNS(null, "attributeName", "fill");
\r
3039 ele.setAttributeNS(null, "fill", "freeze");
\r
3040 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3041 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3042 $animate.init(ele);
\r
3044 /*境界条件を調べておく (limit value analysis)*/
\r
3045 it("should be this for the value (limit value analysis)", function() {
\r
3046 expect(ele.beginElement()).toBeUndefined();
\r
3047 var cur = frame.currentFrame,
\r
3048 begin = frame.$begin.$1;
\r
3049 expect(begin.string).toBe("indefinite");
\r
3050 expect(begin.begin).toBe(cur);
\r
3051 expect(ele.endElement()).toBeUndefined();
\r
3053 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3054 it("should be this for the value (the valid partion )", function() {
\r
3055 ele.addEventListener("beginEvent", function(evt){
\r
3056 expect(evt.target.nodeName).toBe("animate");
\r
3058 ele.beginElement();
\r