1 /*SIE under the MIT Lisence
\r
2 *公式ページは http://sie.osdn.jp/
\r
5 *Copyright (c) 2008-2010 Pivotal Labs
\r
7 Permission is hereby granted, free of charge, to any person obtaining
\r
8 a copy of this software and associated documentation files (the
\r
9 "Software"), to deal in the Software without restriction, including
\r
10 without limitation the rights to use, copy, modify, merge, publish,
\r
11 distribute, sublicense, and/or sell copies of the Software, and to
\r
12 permit persons to whom the Software is furnished to do so, subject to
\r
13 the following conditions:
\r
15 The above copyright notice and this permission notice shall be
\r
16 included in all copies or substantial portions of the Software.
\r
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
27 describe("SMIL Animation Spec", function() {
\r
28 describe("$frame object", function() {
\r
29 var frame = base("$frame");
\r
30 beforeEach( function() {
\r
31 frame.timelines = [];
\r
32 frame.isPaused = false;
\r
34 afterEach( function() {
\r
35 frame.timelines = [];
\r
37 /*境界条件を調べておく (limit value analysis)*/
\r
38 it("should be this for the value (limit value analysis)", function() {
\r
39 expect(typeof frame.setFrame).toBe("function");
\r
40 expect(frame.timelines.length).toBe(0);
\r
41 expect(frame.isBegin).toBeFalsy();
\r
42 expect(frame.startAnimation()).toBeUndefined();
\r
43 expect(frame.begin).toBe(-Number.MAX_VALUE);
\r
50 expect(frame.addLine()).toBe(false);
\r
51 expect(frame.addLine({})).toBe(false);
\r
52 expect(frame.addLine({
\r
55 expect(frame.addLine({
\r
59 expect(frame.removeLine()).toBeUndefined();
\r
60 expect(frame.removeLine({})).toBeUndefined();
\r
63 expect(frame.currentFrame).toBe(0);
\r
65 expect(frame.currentFrame).toBe(1);
\r
67 expect(frame.isPaused).toBeFalsy();
\r
68 expect(frame.pauseAnimation()).toBeUndefined();
\r
69 expect(frame.isPaused).toBeTruthy();
\r
71 expect(frame.objList).toEqual([]);
\r
72 expect(frame.initialize()).toBeUndefined();
\r
74 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
75 it("should be this for the value (the valid partion)", function() {
\r
77 expect(frame.currentFrame).toBe(0);
\r
78 frame.startTime = Date.now();
\r
79 for (var i=0;i<100000;i++) {
\r
83 expect(frame.begin).toBe(-Number.MAX_VALUE);
\r
84 expect(frame.activeTime).toBe(Number.MAX_VALUE);
\r
90 expect(frame.addLine( {
\r
94 expect(frame.addLine( {
\r
98 expect(frame.addLine( {
\r
102 expect(frame.addLine( {
\r
107 expect(frame.timelines.length).toBe(1);
\r
108 var timeline = frame.timelines[0];
\r
109 expect(timeline.begin).toBe(0);
\r
110 expect(timeline.activeTime).toBe(0);
\r
112 expect(frame.timelines[0]).toBe(timeline);
\r
113 frame.addLine({begin:1, activeTime:1});
\r
114 expect(frame.timelines[1]).not.toBe(timeline);
\r
115 frame.addLine(timeline);
\r
116 expect(frame.timelines[0]).not.toBe(timeline);
\r
117 expect(frame.timelines[1]).toBe(timeline);
\r
119 timeline = frame.timelines[0];
\r
120 frame.removeLine({});
\r
121 expect(frame.timelines[0]).toBe(timeline);
\r
122 frame.removeLine(timeline);
\r
123 expect(frame.timelines[0]).not.toBe(timeline);
\r
125 frame.addLine(frame.up().mix( {
\r
128 expect(frame.timelines).not.toBe(frame.$1.timelines);
\r
130 frame.timelines.length = 0;
\r
143 expect(frame.timelines[2].activeTime).toBe(2);
\r
145 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
146 it("should be this for the value (the invalid partion)", function() {
\r
147 expect(frame.addLine(12)).toBeFalsy();
\r
148 /*循環参照にならず、スタック領域不足にならない*/
\r
149 frame.addLine(frame);
\r
153 describe("the $frame.$list object", function() {
\r
155 beforeEach( function() {
\r
156 frame = base("$frame").$list.up();
\r
157 frame.timelines = [];
\r
158 frame.isPaused = false;
\r
159 frame.state = frame.WAITING;
\r
162 afterEach( function() {
\r
163 frame.timelines = [];
\r
165 /*境界条件を調べておく (limit value analysis)*/
\r
166 it("should be this for the value (limit value analysis)", function() {
\r
168 expect(frame.WAITING).toBe(0);
\r
169 expect(frame.BEGINNING).toBe(1);
\r
170 expect(frame.PLAYING).toBe(2);
\r
171 expect(frame.ENDING).toBe(3);
\r
172 expect(frame.POSTWAITING).toBe(4);
\r
173 expect(frame.state).toBe(frame.WAITING);
\r
174 expect(frame.end).toBe(0);
\r
175 expect(frame.beginEnd).toBe(Number.MAX_VALUE);
\r
177 expect(frame.beginList).toEqual({
\r
179 value: Number.MAX_VALUE
\r
181 expect(frame.endList).toEqual({
\r
183 value: Number.MAX_VALUE
\r
186 expect(typeof frame.getMaxList).toBe("function");
\r
188 expect(typeof frame.updateState).toBe("function");
\r
189 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
190 expect(frame.state).toBe(frame.WAITING);
\r
191 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
192 expect(frame.state).toBe(frame.WAITING);
\r
193 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
194 expect(frame.state).toBe(frame.WAITING);
\r
195 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
196 expect(frame.state).toBe(frame.WAITING);
\r
199 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
200 expect(frame.state).toBe(frame.BEGINNING);
\r
201 expect(frame.updateState().state).toBe(frame.BEGINNING);
\r
202 expect(frame.state).toBe(frame.BEGINNING);
\r
204 expect(frame.beginList).toEqual({
\r
206 value: Number.MAX_VALUE
\r
208 expect(frame.endList).toEqual({
\r
210 value: Number.MAX_VALUE
\r
213 expect(frame.getMaxList(0, frame.beginList)).toBe(-Number.MAX_VALUE);
\r
214 expect(frame.getMaxList(0, frame.endList)).toBe(-Number.MAX_VALUE);
\r
218 expect(frame.state).toBe(frame.WAITING);
\r
219 expect(frame.begin).toBe(0);
\r
220 expect(frame.init()).toBe(frame);
\r
223 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
224 it("should be this for the value (the valid partion)", function() {
\r
226 function appendBegin(num) {
\r
227 frame.state = frame.WAITING;
\r
228 frame.beginList = {
\r
230 next: frame.beginList
\r
234 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
235 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
236 expect(frame.begin).toBe(0);
\r
237 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
238 expect(frame.state).toBe(frame.PLAYING);
\r
239 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
240 expect(frame.state).toBe(frame.PLAYING);
\r
242 frame.state = frame.WAITING;
\r
243 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
244 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
245 expect(frame.state).toBe(frame.BEGINNING);
\r
246 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
247 expect(frame.state).toBe(frame.PLAYING);
\r
248 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
249 expect(frame.state).toBe(frame.PLAYING);
\r
250 expect(frame.updateState(3).state).toBe(frame.PLAYING);
\r
251 expect(frame.state).toBe(frame.PLAYING);
\r
252 expect(frame.updateState(4).state).toBe(frame.PLAYING);
\r
253 expect(frame.state).toBe(frame.PLAYING);
\r
256 expect(frame.getMaxList(1, frame.beginList)).toBe(1);
\r
257 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
258 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
259 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
260 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
261 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
262 expect(frame.state).toBe(frame.BEGINNING);
\r
263 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
264 expect(frame.state).toBe(frame.PLAYING);
\r
265 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
266 expect(frame.state).toBe(frame.PLAYING);
\r
267 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
270 frame.state = frame.WAITING;
\r
271 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
272 expect(frame.begin).toBe(0);
\r
273 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
274 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
275 expect(frame.begin).toBe(0);
\r
276 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
277 expect(frame.end).toBe(0);
\r
278 expect(frame.beginEnd).toBe(Number.MAX_VALUE);
\r
279 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
280 expect(frame.begin).toBe(1);
\r
281 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
282 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
284 function appendEnd(num) {
\r
285 frame.state = frame.WAITING;
\r
289 next: frame.endList
\r
293 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
294 expect(frame.state).toBe(frame.BEGINNING);
\r
295 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
296 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
297 expect(frame.state).toBe(frame.PLAYING);
\r
298 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
299 expect(frame.state).toBe(frame.ENDING);
\r
300 expect(frame.end).toBe(3);
\r
301 expect(frame.beginEnd).toBe(2);
\r
302 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
303 expect(frame.state).toBe(frame.POSTWAITING);
\r
306 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
307 expect(frame.state).toBe(frame.BEGINNING);
\r
308 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
309 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
310 expect(frame.state).toBe(frame.PLAYING);
\r
311 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
312 expect(frame.state).toBe(frame.ENDING);
\r
313 expect(frame.end).toBe(3);
\r
314 expect(frame.beginEnd).toBe(2);
\r
315 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
316 expect(frame.state).toBe(frame.POSTWAITING);
\r
317 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
318 expect(frame.state).toBe(frame.POSTWAITING);
\r
321 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
322 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
323 expect(frame.end).toBe(1);
\r
324 expect(frame.beginEnd).toBe(0);
\r
325 expect(frame.updateState(1).state).toBe(frame.POSTWAITING);
\r
327 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
328 it("should be this for the value (the invalid partion)", function() {
\r
329 expect(frame.updateState()).toBe(frame);
\r
330 expect(frame.updateState(null)).toBe(frame);
\r
332 function appendBegin(num) {
\r
333 frame.state = frame.WAITING;
\r
334 frame.beginList = {
\r
336 next: frame.beginList
\r
340 appendBegin(10000);
\r
341 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
342 expect(frame.updateState(99).state).toBe(frame.WAITING);
\r
344 describe("the setFrame method (override)", function() {
\r
345 var frame = base("$frame").$list.up("$3");
\r
346 beforeEach( function() {
\r
347 frame.timelines = [];
\r
348 frame.isPaused = false;
\r
349 frame.state = frame.WAITING;
\r
352 afterEach( function() {
\r
353 frame.timelines = [];
\r
354 frame.beginList = frame.$list.beginList;
\r
355 frame.endList = frame.$list.endList;
\r
356 frame.currentFrame = 0;
\r
358 /*境界条件を調べておく (limit value analysis)*/
\r
359 it("should be this for the value (limit value analysis)", function() {
\r
360 expect(typeof frame.setFrame).toBe("function");
\r
361 expect(frame.currentFrame).toBe(0);
\r
364 expect(frame.state).toBe(frame.WAITING);
\r
365 expect(frame.currentFrame).toBe(0);
\r
367 expect(frame.state).toBe(frame.WAITING);
\r
368 expect(frame.currentFrame).toBe(1);
\r
370 expect(typeof frame.addEvent).toBe("function");
\r
371 expect(typeof frame.addBeginList).toBe("function");
\r
372 expect(typeof frame.addEndList).toBe("function");
\r
374 expect(frame.addBeginList(1).value).toBe(1);
\r
375 expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);
\r
376 expect(frame.addEndList(1).value).toBe(1);
\r
377 expect(frame.endList.next.value).toBe(Number.MAX_VALUE);
\r
379 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
380 it("should be this for the value (the valid partion)", function() {
\r
381 function appendBegin(num) {
\r
382 frame.state = frame.WAITING;
\r
383 frame.addBeginList(num);
\r
386 expect(frame.currentFrame).toBe(0);
\r
388 expect(frame.currentFrame).toBe(0);
\r
389 expect(frame.state).toBe(frame.PLAYING);
\r
391 expect(frame.currentFrame).toBe(1);
\r
392 expect(frame.state).toBe(frame.PLAYING);
\r
397 expect(frame.state).toBe(frame.PLAYING);
\r
399 expect(frame.state).toBe(frame.PLAYING);
\r
401 expect(frame.state).toBe(frame.PLAYING);
\r
403 function appendEnd(num) {
\r
404 frame.state = frame.WAITING;
\r
406 frame.addEndList(num);
\r
411 expect(frame.state).toBe(frame.PLAYING);
\r
413 expect(frame.state).toBe(frame.PLAYING);
\r
415 expect(frame.state).toBe(frame.PLAYING);
\r
417 expect(frame.state).toBe(frame.POSTWAITING);
\r
419 expect(frame.state).toBe(frame.POSTWAITING);
\r
423 expect(frame.state).toBe(frame.PLAYING);
\r
425 expect(frame.state).toBe(frame.PLAYING);
\r
427 expect(frame.state).toBe(frame.PLAYING);
\r
429 expect(frame.state).toBe(frame.POSTWAITING);
\r
431 expect(frame.state).toBe(frame.POSTWAITING);
\r
433 expect(frame.state).toBe(frame.PLAYING);
\r
435 expect(frame.state).toBe(frame.PLAYING);
\r
439 expect(frame.state).toBe(frame.PLAYING);
\r
440 expect(frame.currentFrame).toBe(0);
\r
442 expect(frame.state).toBe(frame.PLAYING);
\r
443 expect(frame.currentFrame).toBe(1);
\r
445 expect(frame.state).toBe(frame.PLAYING);
\r
446 expect(frame.currentFrame).toBe(2);
\r
448 expect(frame.state).toBe(frame.POSTWAITING);
\r
450 expect(frame.state).toBe(frame.POSTWAITING);
\r
452 expect(frame.state).toBe(frame.PLAYING);
\r
454 expect(frame.state).toBe(frame.POSTWAITING);
\r
455 expect(frame.currentFrame).toBe(6);
\r
458 for (var i=0;i<10000;++i) {
\r
462 frame.beginList = base("$frame").$listbeginList;
\r
463 frame.endList = base("$frame").$list.endList;
\r
464 frame.state = frame.WAITING;
\r
466 var obj = { name: "", value: 0};
\r
467 frame.addEvent("begin", function(evt) { obj.name = "a";});
\r
468 frame.beginList = {
\r
470 next: frame.beginList
\r
473 expect(frame.currentFrame).toBe(0);
\r
474 expect(frame.state).toBe(frame.PLAYING);
\r
475 expect(obj.name).toBe("a");
\r
476 frame.addEvent("play", function(evt) { obj.name = "b";});
\r
478 expect(frame.state).toBe(frame.PLAYING);
\r
479 expect(obj.name).toBe("b");
\r
480 frame.addEvent("end", function(evt) { obj.value = 1;});
\r
483 next: frame.endList
\r
486 expect(frame.currentFrame).toBe(0);
\r
487 expect(frame.state).toBe(frame.POSTWAITING);
\r
488 expect(obj.value).toBe(1);
\r
490 frame.addEvent("begin", function(evt) {
\r
491 expect(evt.state).toBe(frame.BEGINNING);
\r
494 frame.addEvent("end", function(evt) {
\r
495 expect(evt.state).toBe(frame.ENDING);
\r
498 frame.addEvent("play", function(evt) {
\r
499 expect(evt.state).toBe(frame.PLAYING);
\r
502 frame.state = frame.WAITING;
\r
504 expect(frame.state).toBe(frame.POSTWAITING);
\r
509 frame.state = frame.WAITING;
\r
510 expect(frame.getMaxList(12, frame.endList)).toBe(0);
\r
511 frame.setFrame(12);
\r
512 expect(frame.state).toBe(frame.POSTWAITING);
\r
515 /*addBeginListメソッドのチェックなど*/
\r
516 expect(frame.addBeginList(1).value).toBe(1);
\r
517 expect(frame.addBeginList(0).value).toBe(0);
\r
518 expect(frame.beginList.next.value).toBe(1);
\r
519 expect(frame.addBeginList(2).value).toBe(2);
\r
520 expect(frame.beginList.next.value).toBe(0);
\r
522 expect(frame.addEndList(1).value).toBe(1);
\r
523 expect(frame.addEndList(0).value).toBe(0);
\r
524 expect(frame.endList.next.value).toBe(1);
\r
525 expect(frame.addEndList(2).value).toBe(2);
\r
526 expect(frame.endList.next.value).toBe(0);
\r
530 describe("$begin object", function() {
\r
531 var begin = base("$frame").$begin.up();
\r
532 /*境界条件を調べておく (limit value analysis)*/
\r
533 it("should be this for the value (limit value analysis)", function() {
\r
534 expect(begin.string).toBe("");
\r
535 expect(begin.isResolved).toBeFalsy();
\r
536 expect(begin.eventTarget).toBe(document.documentElement);
\r
537 expect(begin.eventOffset).toBe(0);
\r
538 expect(begin.repeat).toBe(0);
\r
539 expect(begin.accessKey).toBe("");
\r
541 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
542 it("should be this for the value (the valid partion)", function() {
\r
543 begin.string = " hoge ";
\r
544 expect(begin.string).toBe(" hoge ");
\r
545 var $list = begin.$list;
\r
546 expect(begin.$list).toBe($list);
\r
547 expect(begin.updateList().$list).not.toBe($list);
\r
549 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
550 it("should be this for the value (the invalid partion)", function() {
\r
553 describe("A trim method in $begin object", function() {
\r
554 /*境界条件を調べておく (limit value analysis)*/
\r
555 beforeEach( function() {
\r
558 it("should be this for the value (limit value analysis)", function() {
\r
559 delete begin.string;
\r
560 expect(begin.trim(" ")).toBe("");
\r
561 expect( function() {
\r
565 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
566 it("should be this for the value (the valid partion)", function() {
\r
567 expect(begin.trim(" hoge ")).toBe("hoge");
\r
568 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
569 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
570 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
572 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
573 it("should be this for the value (the invalid partion)", function() {
\r
574 expect( function() {
\r
577 expect( function() {
\r
583 describe("An offset method in $begin object", function() {
\r
584 beforeEach( function() {
\r
587 /*境界条件を調べておく (limit value analysis)*/
\r
588 it("should be this for the value (limit value analysis)", function() {
\r
589 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
590 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
591 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
592 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
593 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
594 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
596 expect(begin.offset("+0s")).toBe(0);
\r
597 expect(begin.offset("-0s")).toBe(0);
\r
598 expect(begin.offset("1s")).toBe(1000);
\r
599 expect(begin.offset("-1s")).toBe(-1000);
\r
601 expect(begin.offset("+0min")).toBe(0);
\r
602 expect(begin.offset("-0min")).toBe(0);
\r
603 expect(begin.offset("1min")).toBe(60000);
\r
604 expect(begin.offset("-1min")).toBe(-60000);
\r
606 expect(begin.offset("+0h")).toBe(0);
\r
607 expect(begin.offset("-0h")).toBe(0);
\r
608 expect(begin.offset("1h")).toBe(60*60*1000);
\r
609 expect(begin.offset("-1h")).toBe(-3600000);
\r
611 expect(begin.offset("00:0")).toBe(0);
\r
612 expect(begin.offset("00:00:0.0")).toBe(0);
\r
613 expect(begin.offset("-00:0")).toBe(0);
\r
614 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
615 expect(begin.offset("00:1")).toBe(1000);
\r
616 expect(begin.offset("-00:1")).toBe(-1000);
\r
617 expect(begin.offset("00:00:1")).toBe(1000);
\r
618 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
620 expect(begin.offset()).toBe(0);
\r
622 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
623 it("should be this for the value (the valid partion)", function() {
\r
624 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
625 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
626 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
627 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
629 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
630 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
631 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
632 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
633 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
635 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
636 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
637 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
638 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
639 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
641 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
642 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
643 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
644 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
645 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
647 expect(begin.offset("01:0")).toBe(60000);
\r
648 expect(begin.offset("-01:0")).toBe(-60000);
\r
649 expect(begin.offset("00:00:1")).toBe(1000);
\r
650 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
651 expect(begin.offset("00:01:0")).toBe(60000);
\r
652 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
653 expect(begin.offset("01:00:0")).toBe(3600000);
\r
654 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
655 expect(begin.offset("00:10")).toBe(10000);
\r
656 expect(begin.offset("00:0.01")).toBe(10);
\r
657 expect(begin.offset("01:0.01")).toBe(60010);
\r
658 expect(begin.offset("10:0")).toBe(600000);
\r
659 expect(begin.offset("-00:10")).toBe(-10000);
\r
660 expect(begin.offset("-00:0.01")).toBe(-10);
\r
661 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
662 expect(begin.offset("-10:0")).toBe(-600000);
\r
663 expect(begin.offset("00:00:20")).toBe(20000);
\r
664 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
665 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
666 expect(begin.offset("-10:0")).toBe(-600000);
\r
667 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
669 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
670 it("should be this for the value (the invalid partion)", function() {
\r
671 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
672 expect(begin.offset("ms")).toBe(0);
\r
673 expect(begin.offset(".s")).toBe(0);
\r
674 expect(begin.offset("10:")).toBe(0);
\r
675 expect(begin.offset("::")).toBe(0);
\r
676 expect(begin.offset("-:0")).toBe(0);
\r
677 expect(begin.offset("-::0")).toBe(0);
\r
680 describe("An event method in $begin object", function() {
\r
681 /*境界条件を調べておく (limit value analysis)*/
\r
682 it("should be this for the value (limit value analysis)", function() {
\r
683 var evt = begin.event();
\r
684 expect(evt.id).toBe("");
\r
685 expect(evt.event).toBe("");
\r
686 evt = begin.event("");
\r
687 expect(evt.id).toBe("");
\r
688 expect(evt.event).toBe("");
\r
689 evt = begin.event(".");
\r
690 expect(evt.id).toBe("");
\r
691 expect(evt.event).toBe("");
\r
693 evt = begin.event("a");
\r
694 expect(evt.id).toBe("");
\r
695 expect(evt.event).toBe("a");
\r
696 evt = begin.event("a.b");
\r
697 expect(evt.id).toBe("a");
\r
698 expect(evt.event).toBe("b");
\r
700 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
701 it("should be this for the value (the valid partion)", function() {
\r
702 var evt = begin.event("id.event");
\r
703 expect(evt.id).toBe("id");
\r
704 expect(evt.event).toBe("event");
\r
705 evt = begin.event("event");
\r
706 expect(evt.id).toBe("");
\r
707 expect(evt.event).toBe("event");
\r
709 evt = begin.event("event+0s");
\r
710 expect(evt.id).toBe("");
\r
711 expect(evt.event).toBe("event");
\r
712 evt = begin.event("event-0s");
\r
713 expect(evt.id).toBe("");
\r
714 expect(evt.event).toBe("event");
\r
716 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
717 it("should be this for the value (the invalid partion)", function() {
\r
718 evt = begin.event("...");
\r
719 expect(evt.id).toBe("");
\r
720 expect(evt.event).toBe("");
\r
721 evt = begin.event(".event");
\r
722 expect(evt.id).toBe("");
\r
723 expect(evt.event).toBe("");
\r
724 evt = begin.event("id.");
\r
725 expect(evt.id).toBe("");
\r
726 expect(evt.event).toBe("");
\r
730 describe("An parse method in $begin object", function() {
\r
731 beforeEach( function() {
\r
734 /*境界条件を調べておく (limit value analysis)*/
\r
735 it("should be this for the value (limit value analysis)", function() {
\r
736 expect(begin.parse().begin).toBe(0);
\r
737 expect(begin.isResolved).toBeTruthy();
\r
739 expect(begin.parse().begin).toBe(0);
\r
740 begin.string = "+1";
\r
741 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
742 begin.string = " ";
\r
743 expect(begin.parse().begin).toBe(0);
\r
744 begin.string = "1";
\r
745 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
746 begin.string = "+0ms";
\r
747 expect(begin.parse().begin).toBe(0);
\r
748 begin.string = "-0ms";
\r
749 expect(begin.parse().begin).toBe(0);
\r
750 begin.string = "-0ms;-0ms";
\r
751 expect(begin.parse().begin).toBe(0);
\r
752 begin.string = "-0ms;1";
\r
753 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
755 expect(begin.eventOffset).toBe(0);
\r
756 begin.string = "click";
\r
757 expect(begin.parse().begin).toBe(0);
\r
758 expect(begin.eventOffset).toBe(0);
\r
759 expect(begin.repeat).toBe(0);
\r
760 expect(begin.accessKey).toBe("");
\r
761 begin.string = "id.click";
\r
762 expect(begin.parse().begin).toBe(0);
\r
763 expect(begin.eventOffset).toBe(0);
\r
764 expect(begin.repeat).toBe(0);
\r
765 expect(begin.accessKey).toBe("");
\r
767 begin.string = "repeat";
\r
768 expect(begin.parse().begin).toBe(0);
\r
769 expect(begin.eventOffset).toBe(0);
\r
770 expect(begin.repeat).toBe(0);
\r
771 expect(begin.accessKey).toBe("");
\r
772 begin.string = "repeat(1)";
\r
773 expect(begin.parse().begin).toBe(0);
\r
774 expect(begin.eventOffset).toBe(0);
\r
775 expect(begin.repeat).toBe(1);
\r
776 expect(begin.accessKey).toBe("");
\r
778 begin.string = "accessKey(a)";
\r
779 expect(begin.parse().begin).toBe(0);
\r
780 expect(begin.eventOffset).toBe(0);
\r
781 expect(begin.repeat).toBe(0);
\r
782 expect(begin.accessKey).toBe("a");
\r
784 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
785 it("should be this for the value (the valid partion)", function() {
\r
786 begin.string = " 1 0 0 m s";
\r
787 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
789 begin.string = "1ms";
\r
790 begin.isResolved = false;
\r
791 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
792 expect(begin.isResolved).toBeTruthy();
\r
793 expect(begin.eventOffset).toBe(0);
\r
795 begin.string="click+0";
\r
796 expect(begin.parse().begin).toBe(0);
\r
797 expect(begin.eventOffset).toBe(0);
\r
798 expect(begin.isResolved).toBeFalsy();
\r
799 begin.string = "click+1";
\r
800 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
801 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
802 begin.string = " click ";
\r
803 expect(begin.parse().begin).toBe(0);
\r
804 expect(begin.eventOffset).toBe(0);
\r
805 begin.string = "click+0ms";
\r
806 expect(begin.parse().begin).toBe(0);
\r
807 expect(begin.eventOffset).toBe(0);
\r
808 expect(begin.isResolved).toBeFalsy();
\r
809 begin.string = "click-0ms";
\r
810 expect(begin.parse().begin).toBe(0);
\r
811 expect(begin.eventOffset).toBe(0);
\r
812 begin.string = "click+100ms";
\r
813 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
814 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
815 begin.string = "click-100ms";
\r
816 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
817 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
819 begin.string="id.click+0";
\r
820 expect(begin.parse().begin).toBe(0);
\r
821 expect(begin.eventOffset).toBe(0);
\r
822 expect(begin.isResolved).toBeFalsy();
\r
823 begin.string = "id.click+1";
\r
824 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
825 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
826 expect(begin.isResolved).toBeFalsy();
\r
827 begin.string = " id . click ";
\r
828 expect(begin.parse().begin).toBe(0);
\r
829 expect(begin.eventOffset).toBe(0);
\r
830 expect(begin.isResolved).toBeFalsy();
\r
831 begin.string = "id.click+0ms";
\r
832 expect(begin.parse().begin).toBe(0);
\r
833 expect(begin.eventOffset).toBe(0);
\r
834 begin.string = "id.click-0ms";
\r
835 expect(begin.parse().begin).toBe(0);
\r
836 expect(begin.eventOffset).toBe(0);
\r
837 begin.string = "id.click+100ms";
\r
838 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
839 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
840 begin.string = "id.click-100ms";
\r
841 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
842 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
844 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
845 it("should be this for the value (the invalid partion)", function() {
\r
846 begin.string = "ms";
\r
847 begin.isResolved = false;
\r
848 expect(begin.parse().begin).toBe(0);
\r
849 expect(begin.isResolved).toBeFalsy();
\r
851 begin.isResolved = true;
\r
852 begin.string = "indefinite";
\r
853 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
854 expect(begin.isResolved).toBeFalsy();
\r
858 describe("A $end object", function() {
\r
859 var end = base("$frame").$begin.$end.up();
\r
861 beforeEach( function() {
\r
863 end.startTime = Date.now();
\r
866 /*境界条件を調べておく (limit value analysis)*/
\r
867 it("should be this for the value (limit value analysis)", function() {
\r
868 expect(end.up().call()).toBeNull();
\r
870 expect(end.up().call()).toBe(0);
\r
871 end.string = "hoge";
\r
872 expect(end.up().call()).toBe("indefinite");
\r
875 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
876 it("should be this for the value (the valid partion)", function() {
\r
877 end.string = "hoge+0";
\r
878 expect(end.up().call()).toBe("indefinite");
\r
879 end.string = "12ms";
\r
880 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
881 end.string = "hoge+12ms";
\r
882 expect(end.up().call()).toBe("indefinite");
\r
885 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
886 it("should be this for the value (the invalid partion)", function() {
\r
888 expect(end.up().call()).toBeNull();
\r
891 describe("A $activate object", function() {
\r
892 var act = base("$frame").$begin.$activate.up();
\r
893 beforeEach( function() {
\r
894 act.dur = "indefinite";
\r
896 act.repeatCount = null;
\r
897 act.repeatDur = null;
\r
898 act.end__ = act.$begin.$end;
\r
899 act.simpleDur__ = base("$frame").$begin.$activate.simpleDur__;
\r
902 /*境界条件を調べておく (limit value analysis)*/
\r
903 it("should be this for the value (limit value analysis)", function() {
\r
904 expect(act.dur).toBe("indefinite");
\r
905 expect(act.end__).toBe(act.$begin.$end);
\r
906 expect(act.repeatCount).toBeNull();
\r
907 expect(act.repeatDur).toBeNull();
\r
908 expect(act.simpleDur__()).toBeNull();
\r
909 expect(act.min).toBe("0");
\r
910 expect(act.max).toBe("indefinite");
\r
913 expect(act.$a.call()).toBeNull();
\r
914 expect(act.$a.end).toBeNull();
\r
916 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
917 it("should be this for the value (the valid partion)", function() {
\r
918 expect(act.resolvedTime__()).not.toBe(0);
\r
920 /*Activate Duration = dur*/
\r
922 act.$b.dur = "132ms";
\r
923 var abc = act.$b.call();
\r
924 expect(abc).toBe(Math.floor(132*act.fpms));
\r
925 expect(abc).toBe(act.$b.simpleDur);
\r
927 expect(act.up().call()).toBeNull();
\r
935 act.$c.initToEval();
\r
936 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
937 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
943 act.$c.initToEval();
\r
944 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
946 /*AD = repeatCount*dur*/
\r
949 simpleDur__: act.simpleDur__,
953 act.$c.initToEval();
\r
955 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
958 simpleDur__: act.simpleDur__,
962 act.$c.initToEval();
\r
963 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
964 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
969 simpleDur__: act.simpleDur__,
973 act.$c.initToEval();
\r
975 expect(act.$c.simpleDur).toBeNull();
\r
978 simpleDur__: act.simpleDur__,
982 act.$c.initToEval();
\r
983 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
984 expect(act.$c.simpleDur).toBeNull();
\r
987 simpleDur__: act.simpleDur__,
991 act.$c.initToEval();
\r
993 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
996 simpleDur__: act.simpleDur__,
1000 act.$c.initToEval();
\r
1001 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
1002 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1004 /*AD = Min(repeatCount*d, repeatDur)*/
\r
1007 simpleDur__: act.simpleDur__,
1011 act.$c.initToEval();
\r
1013 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1016 simpleDur__: act.simpleDur__,
1020 act.$c.initToEval();
\r
1021 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1022 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1025 simpleDur__: act.simpleDur__,
1029 act.$c.initToEval();
\r
1030 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
1031 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
1033 /*AD = repeatDur,*/
\r
1037 simpleDur__: act.simpleDur__,
1038 repeatCount: null,
\r
1041 act.$c.initToEval();
\r
1042 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
1043 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1045 dur: "indefinite",
\r
1046 simpleDur__: act.simpleDur__,
1050 act.$c.initToEval();
\r
1051 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1052 expect(act.$c.simpleDur).toBeNull();
\r
1054 act.end__.string = null;
\r
1055 act.up("$cd").mix( {
\r
1060 act.$cd.initToEval();
\r
1061 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
1063 act.$cd.end__ = act.end__;
\r
1064 act.$cd.repeatCount = null;
\r
1065 act.$cd.repeatDur = "12";
\r
1066 act.$cd.initToEval();
\r
1067 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
1069 act.up("$d").mix( {
\r
1073 simpleDur__: act.simpleDur__
\r
1075 act.$d.initToEval();
\r
1076 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1077 act.up("$d").mix( {
\r
1081 simpleDur__: act.simpleDur__
\r
1083 act.$d.initToEval();
\r
1084 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1086 /*endで0が指定されている場合*/
\r
1089 act.repeatDur = null;
\r
1090 act.repeatCount = "indefinite";
\r
1092 expect(act.call()).toBeNull();
\r
1093 act.repeatCount = null;
\r
1094 act.repeatDur = "indefinite";
\r
1096 expect(act.call()).toBeNull();
\r
1097 act.repeatDur = "indefinite";
\r
1098 act.repeatCount = "indefinite";
\r
1100 expect(act.call()).toBeNull();
\r
1102 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1103 it("should be this for the value (the invalid partion)", function() {
\r
1105 act.up("$d").mix( {
\r
1109 simpleDur__: act.simpleDur__
\r
1111 act.$d.initToEval();
\r
1112 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
1114 act.repeatDur = null;
\r
1115 act.repeatCount = "indefinite";
\r
1117 expect(act.call()).toBeNull();
\r
1118 act.repeatCount = null;
\r
1119 act.repeatDur = "indefinite";
\r
1121 expect(act.call()).toBeNull();
\r
1122 act.repeatDur = "indefinite";
\r
1123 act.repeatCount = "indefinite";
\r
1125 expect(act.call()).toBeNull();
\r
1128 describe("A $from object", function() {
\r
1129 var from = base("$from");
\r
1130 beforeEach( function() {
\r
1131 from = base("$from").up();
\r
1132 from.from__ = from.from__.up();
\r
1135 /*境界条件を調べておく (limit value analysis)*/
\r
1136 it("should be this for the value (limit value analysis)", function() {
\r
1137 expect(from.string).toBe("");
\r
1138 expect(from.numList__()).toEqual([]);
\r
1139 expect(from.strList__()).toBeNull();
\r
1141 from.string = "0";
\r
1142 expect(from.numList__()[0]).toBe(0);
\r
1143 expect(from.strList__()).toBeNull();
\r
1145 from.string = " 0 ";
\r
1146 expect(from.numList__()[0]).toBe(0);
\r
1147 expect(from.strList__().join("")).toBe(" ");
\r
1149 from.string = "a";
\r
1150 expect(from.numList__()).toEqual([]);
\r
1151 expect(from.strList__()[0]).toBe("a");
\r
1153 /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから
\r
1154 * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/
\r
1156 from.string = null;
\r
1157 expect( function() {
\r
1160 expect( function() {
\r
1164 expect(from.additive[0]).toBe(0);
\r
1165 expect(from.accumulate[0]).toBe(0);
\r
1167 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1168 it("should be this for the value (the valid partion)", function() {
\r
1169 from.string = "0a";
\r
1170 expect(from.numList__()[0]).toBe(0);
\r
1171 expect(from.strList__()[0]).toBe("a");
\r
1173 from.string = "a0";
\r
1174 expect(from.numList__()[0]).toBe(0);
\r
1175 expect(from.strList__()[0]).toBe("a");
\r
1177 from.string = "0.1";
\r
1178 expect(from.numList__()[0]).toBe(0.1);
\r
1179 expect(from.strList__()).toBeNull();
\r
1181 from.string = "+0.1";
\r
1182 expect(from.numList__()[0]).toBe(0.1);
\r
1183 expect(from.strList__()).toBeNull();
\r
1185 from.string = "-0.1";
\r
1186 expect(from.numList__()[0]).toBe(-0.1);
\r
1187 expect(from.strList__()).toBeNull();
\r
1189 from.string = "1e-1";
\r
1190 expect(from.numList__()[0]).toBe(1e-1);
\r
1191 expect(from.strList__()).toBeNull();
\r
1193 from.string = "1E-1";
\r
1194 expect(from.numList__()[0]).toBe(1E-1);
\r
1195 expect(from.strList__()).toBeNull();
\r
1197 from.string = "0,0";
\r
1198 expect(from.numList__().toString()).toBe("0,0");
\r
1199 expect(from.strList__().join("")).toBe(",");
\r
1201 from.string = "a00a";
\r
1202 expect(from.numList__()[0]).toBe(0);
\r
1203 expect(from.strList__().join("")).toBe("aa");
\r
1205 from.string = "a0b0a";
\r
1206 expect(from.numList__().toString()).toBe("0,0");
\r
1207 expect(from.strList__().join("")).toBe("aba");
\r
1209 from.string = "0b0a";
\r
1210 expect(from.numList__().toString()).toBe("0,0");
\r
1211 expect(from.strList__().join("")).toBe("ba");
\r
1213 from.string = "0b-1.0a";
\r
1214 expect(from.numList__()[1]).toBe(-1);
\r
1215 expect(from.strList__().join("")).toBe("ba");
\r
1217 expect(from.up().call()).toBe(from.$1.numList);
\r
1218 expect(from.$1.numList[1]).toBe(-1);
\r
1219 expect(from.$1.strList.join("")).toBe("ba");
\r
1221 from.string = "あ 0b-1.0a12";
\r
1222 expect(from.numList__()[1]).toBe(-1);
\r
1223 expect(from.strList__().join("")).toBe("あ ba12");
\r
1225 from.string = "0b-1.0a0";
\r
1226 expect(from.numList__().join(",")).toBe("0,-1,0");
\r
1227 expect(from.strList__().join("")).toBe("ba");
\r
1229 from.string = "0b .1a";
\r
1230 expect(from.numList__()[1]).toBe(0.1);
\r
1231 expect(from.strList__().join("")).toBe("b a");
\r
1233 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1234 it("should be this for the value (the invalid partion)", function() {
\r
1235 from.string = NaN;
\r
1236 expect(function(){
\r
1239 expect(function(){
\r
1243 from.string = "currentColor";
\r
1244 expect(from.numList__()).toEqual([]);
\r
1245 expect(from.strList__()[0]).toBe("currentColor");
\r
1247 from.string = "eE";
\r
1248 expect(from.numList__()).toEqual([]);
\r
1249 expect(from.strList__()[0]).toBe("eE");
\r
1250 expect(from.strList__()[0]).toBe("eE");
\r
1253 describe("A $to object", function() {
\r
1254 var from = base("$from");
\r
1255 beforeEach( function() {
\r
1256 from = base("$from").up();
\r
1260 /*境界条件を調べておく (limit value analysis)*/
\r
1261 it("should be this for the value (limit value analysis)", function() {
\r
1262 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1263 expect(from.up().call()).toBe(from.$1.numList);
\r
1264 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1266 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1267 it("should be this for the value (the valid partion)", function() {
\r
1269 from.$to.from__ = from;
\r
1270 from.$to.string = "12cm-7";
\r
1271 expect(from.$to.numList__().join(",")).toBe("12,-7");
\r
1272 expect(from.$to.strList__().toString()).toBe("cm");
\r
1274 from.string = "7cm+8";
\r
1276 expect(from.call()).toBe(from.numList);
\r
1277 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1278 expect(from.$to.strList.join("")).toBe("cm");
\r
1279 expect(from.numList.join(",")).toBe("7,8");
\r
1280 expect(from.strList.join("")).toBe("cm");
\r
1281 expect(from.$to.from).toBe(from.numList);
\r
1284 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1285 it("should be this for the value (the invalid partion)", function() {
\r
1287 from.up("$to").mix( function() {
\r
1288 this.string = "12cm";
\r
1291 arr.string = this.string;
\r
1292 expect(this.numList).toEqual(arr);
\r
1293 expect(this.strList).toBeNull();
\r
1297 describe("An advance method", function() {
\r
1298 var from = base("$from");
\r
1299 beforeEach( function() {
\r
1300 from = base("$from").up();
\r
1303 from.$to.from__ = from;
\r
1305 /*境界条件を調べておく (limit value analysis)*/
\r
1306 it("should be this for the value (limit value analysis)", function() {
\r
1307 expect(from.advance()).toBe("");
\r
1308 expect(from.$to.advance()).toBe("");
\r
1309 expect(from.$to.advance(0)).toBe("");
\r
1310 expect(from.$to.advance(1)).toBe("");
\r
1311 expect(function(){
\r
1312 from.$to.advance(1.01);
\r
1313 }).toThrow("An Invalid Number Error");
\r
1314 expect(function(){
\r
1315 from.$to.advance(-0.01);
\r
1316 }).toThrow("An Invalid Number Error");
\r
1320 from = base("$from").up();
\r
1322 from.$to.from__ = from;
\r
1323 arr.string = from.string = "0";
\r
1324 from.$to.string = "1";
\r
1325 expect(from.$to.call()).toBe(from.$to.numList);
\r
1326 expect(from.$to.numList[0]).toBe(1);
\r
1327 expect(from.$to.strList).toBeNull();
\r
1328 expect(from.numList[0]).toBe(0);
\r
1329 expect(from.strList).toBeNull();
\r
1330 expect(from.advance(0)).toBe("");
\r
1331 expect(from.$to.from).toBe(from.numList);
\r
1332 expect(from.$to.advance(0)).toBe("0");
\r
1333 expect(from.call()).toBe(from.numList);
\r
1335 from = base("$from").up();
\r
1336 f(from.up(), "inline", "block");
\r
1337 f(from.up(), " inline", " block ");
\r
1338 function f(from, inline, block) {
\r
1340 from.$to.from__ = from;
\r
1341 from.string = inline;
\r
1342 arr.string = from.$to.string = block;
\r
1343 expect(from.$to.call()).toBe(from.$to.numList);
\r
1344 expect(from.$to.numList).toEqual(arr);
\r
1345 expect(from.$to.strList).toEqual([block]);
\r
1346 arr.string = from.string;
\r
1347 expect(from.numList).toEqual(arr);
\r
1348 expect(from.strList).toEqual([inline]);
\r
1349 expect(from.advance(0)).toBe("");
\r
1350 expect(from.$to.from).toBe(from.numList);
\r
1351 expect(from.$to.advance(0)).toBe("inline");
\r
1352 expect(from.$to.advance(1)).toBe("block");
\r
1353 expect(from.call()).toBe(from.numList);
\r
1356 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1357 it("should be this for the value (the valid partion)", function() {
\r
1360 from.string = "0s";
\r
1361 from.$to.string = "1s";
\r
1362 expect(from.$to.call()).toBe(from.$to.numList);
\r
1363 expect(from.$to.numList[0]).toBe(1);
\r
1364 expect(from.$to.strList[0]).toBe("");
\r
1365 expect(from.numList[0]).toBe(0);
\r
1366 expect(from.strList[0]).toBe("");
\r
1367 expect(from.advance(0)).toBe("");
\r
1368 expect(from.$to.from).toBe(from.numList);
\r
1369 expect(from.$to.advance(0)).toBe("0s");
\r
1370 from.$to.degit = deg;
\r
1371 for (var i=0;i<1;i+=0.01) {
\r
1372 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1374 expect(from.call()).toBe(from.numList);
\r
1376 from = base("$from").up();
\r
1378 from.string = "a0S";
\r
1379 from.$to.string = "a1S";
\r
1380 from.$to.from__ = from;
\r
1381 expect(from.$to.call()).toBe(from.$to.numList);
\r
1382 expect(from.$to.numList[0]).toBe(1);
\r
1383 expect(from.$to.strList[0]).toBe("a");
\r
1384 expect(from.numList[0]).toBe(0);
\r
1385 expect(from.strList[0]).toBe("a");
\r
1386 expect(from.advance(0)).toBe("");
\r
1387 expect(from.$to.from).toBe(from.numList);
\r
1388 expect(from.$to.advance(0)).toBe("a0S");
\r
1390 from.$to.degit = deg;
\r
1391 for (var i=0;i<1;i+=0.01) {
\r
1392 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1394 expect(from.call()).toBe(from.numList);
\r
1396 from = base("$from").up();
\r
1397 f(from.up(), "a-10s1.5", "a10s-3");
\r
1398 f(from.up(), " a-10s1.5", " a10s-3 ");
\r
1399 function f(from, fromString, toString) {
\r
1401 from.string = fromString;
\r
1402 from.$to.string = toString;
\r
1403 from.$to.from__ = from;
\r
1405 from.$to.degit = 1;
\r
1406 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1407 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1408 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1410 from.$to.additive[0] = 1;
\r
1411 from.$to.accumulate[1] = 2;
\r
1412 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1413 from.$to.additive[0] = 0.5;
\r
1414 from.$to.accumulate[1] = 0.8;
\r
1415 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1418 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1419 it("should be this for the value (the invalid partion)", function() {
\r
1420 expect(function(){
\r
1421 from.$to.advance(10);
\r
1422 }).toThrow("An Invalid Number Error");
\r
1423 expect(function(){
\r
1424 from.$to.advance(-10);
\r
1425 }).toThrow("An Invalid Number Error");
\r
1429 describe("A distance method", function() {
\r
1430 var from = base("$from");
\r
1431 beforeEach( function() {
\r
1432 from = base("$from").up();
\r
1436 /*境界条件を調べておく (limit value analysis)*/
\r
1437 it("should be this for the value (limit value analysis)", function() {
\r
1438 expect(from.distance()).toBe(0)
\r
1439 expect(from.$to.distance()).toBe(0);
\r
1441 from.string = "0";
\r
1442 from.$to.string = "1";
\r
1443 expect(from.distance()).toBe(0);
\r
1444 expect(from.$to.distance(from)).toBe(1);
\r
1446 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1447 it("should be this for the value (the valid partion)", function() {
\r
1448 from.string = "s 0 s 12";
\r
1449 from.$to.string = "s 0 s 0";
\r
1450 expect(from.distance()).toBe(0);
\r
1451 expect(from.$to.distance(from)).toBe(12);
\r
1452 expect(from.$to.distance(from)).toBe(12);
\r
1453 expect(from.$to.distance(from.call())).toBe(12);
\r
1455 from = base("$from").up();
\r
1457 from.string = "rgb(1, 0, 0)";
\r
1458 from.$to.string = "rgb(0, 0, 1)";
\r
1459 expect(from.distance()).toBe(0);
\r
1460 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1462 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1463 it("should be this for the value (the invalid partion)", function() {
\r
1464 from.string = "s";
\r
1465 from.$to.string = "s";
\r
1466 expect(from.$to.distance(from)).toBe(0);
\r
1469 describe("A setAdditive method", function() {
\r
1470 var from = base("$from");
\r
1471 beforeEach( function() {
\r
1472 from = base("$from").up();
\r
1476 /*境界条件を調べておく (limit value analysis)*/
\r
1477 it("should be this for the value (limit value analysis)", function() {
\r
1478 expect(from.setAdditive()).toBe(0);
\r
1479 expect(from.setAdditive("")).toBe(0);
\r
1480 expect(from.additive).toEqual([0]);
\r
1483 expect(from.setAdditive("1")).toEqual(arr);
\r
1484 expect(from.additive).toEqual(arr);
\r
1486 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1487 it("should be this for the value (the valid partion)", function() {
\r
1488 var arr = [1, 2, 3];
\r
1489 arr.string = "1 2, 3";
\r
1490 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1491 expect(from.additive).toEqual(arr);
\r
1493 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1494 it("should be this for the value (the invalid partion)", function() {
\r
1497 describe("A setAccumulate method", function() {
\r
1498 var from = base("$from");
\r
1499 beforeEach( function() {
\r
1500 from = base("$from").up();
\r
1501 from.string = "0 1";
\r
1505 /*境界条件を調べておく (limit value analysis)*/
\r
1506 it("should be this for the value (limit value analysis)", function() {
\r
1507 expect(from.setAccumulate()).toBe(0);
\r
1508 expect(from.setAccumulate(0)).toBe(0);
\r
1509 expect(from.accumulate).toEqual([0, 0]);
\r
1510 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1511 expect(from.accumulate).toEqual([0, 1]);
\r
1513 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1514 it("should be this for the value (the valid partion)", function() {
\r
1515 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1516 expect(from.accumulate).toEqual([0, 2]);
\r
1518 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1519 it("should be this for the value (the invalid partion)", function() {
\r
1520 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1523 describe("A $calcMode object", function() {
\r
1524 var calc = base("$calcMode"),
\r
1527 beforeEach( function() {
\r
1528 calc = base("$calcMode").up();
\r
1529 calc.to = base("$from").up().mix( {string: "1"} );
\r
1530 from = calc.to.from__ = base("$from").up().mix( {string: "0"} );
\r
1532 /*境界条件を調べておく (limit value analysis)*/
\r
1533 it("should be this for the value (limit value analysis)", function() {
\r
1534 expect(calc.mode).toBe("linear");
\r
1535 expect(calc.keyTime).toBe(1);
\r
1536 expect(calc.keySplines).toBeNull();
\r
1537 expect(calc.string).toBe("");
\r
1539 expect(calc.call()(0)).toBe("0");
\r
1540 expect(calc.keyTime).toBe(1);
\r
1541 expect(calc.call()(1)).toBe("1");
\r
1544 expect(calc.call()(1)).toBe("0");
\r
1547 calc.mode = "paced";
\r
1548 expect(calc.norm).toBe(1);
\r
1549 calc.to.from__ = from;
\r
1550 expect(calc.call()(0)).toBe("0");
\r
1551 expect(calc.keyTime).toBe(1);
\r
1552 calc.to.from__ = from;
\r
1553 expect(calc.call()(1)).toBe("1");
\r
1556 calc.to.from__ = from;
\r
1557 expect(calc.call()(1)).toBe("1");
\r
1560 calc.mode = "discrete";
\r
1561 calc.to.from__ = from;
\r
1563 expect(calc.call()(0)).toBe("0");
\r
1564 expect(calc.call()(1)).toBe("1");
\r
1566 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1567 it("should be this for the value (the valid partion)", function() {
\r
1568 calc.mode = "linear";
\r
1569 calc.keyTime = 0.5;
\r
1570 calc.to.degit = 1;
\r
1571 expect(calc.call()(0.2)).toBe("0.4");
\r
1572 expect(calc.call()(0.3)).toBe("0.6");
\r
1574 expect(calc.call()(0.2)).toBe("0.4");
\r
1576 calc = base("$calcMode").up();
\r
1577 calc.keyTime = 0.2;
\r
1578 calc.to = base("$from").up();
\r
1579 calc.to.from__ = base("$from").up();
\r
1580 calc.to.from__.string = "0s";
\r
1581 calc.to.string = "1s";
\r
1582 calc.to.degit = 1;
\r
1583 expect(calc.call()(0.1)).toBe("0.5s");
\r
1585 calc = base("$calcMode").up();
\r
1586 calc.keyTime = 0.5;
\r
1587 calc.to = base("$from").up();
\r
1588 calc.to.from__ = base("$from").up();
\r
1589 calc.to.from__.string = "rgb(100, 20, 32)";
\r
1590 calc.to.string = "rgb(0, 10, 50)";
\r
1591 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1594 calc.to = base("$from").up();
\r
1595 calc.to.from__ = base("$from").up();
\r
1596 calc.mode = "paced";
\r
1598 calc.to.from__.string = "0s";
\r
1599 calc.to.string = "20s";
\r
1600 calc.to.degit = 1;
\r
1601 expect(calc.call()(0.1)).toBe("10.0s");
\r
1602 expect(calc.keyTime).toBe(0.2);
\r
1604 calc.to = base("$from").up();
\r
1605 calc.to.from__ = base("$from").up();
\r
1606 calc.mode = "paced";
\r
1608 calc.to.from__.string = "rgb(0, 0, 20)";
\r
1609 calc.to.string = "rgb(0, 0, 0)";
\r
1610 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1611 expect(calc.keyTime).toBe(0.2);
\r
1614 calc.to = base("$from").up();
\r
1615 calc.to.from__ = base("$from").up();
\r
1616 calc.mode = "discrete";
\r
1617 calc.keyTime = 0.5;
\r
1618 calc.to.degit = 1;
\r
1619 calc.to.string = "1";
\r
1620 calc.to.from__.string = "0.5";
\r
1621 expect(calc.call()(0.2)).toBe("0.5");
\r
1622 expect(calc.call()(0.3)).toBe("0.5");
\r
1624 expect(calc.call()(0.2)).toBe("0.5");
\r
1626 calc.to = base("$from").up();
\r
1627 calc.to.from__ = base("$from").up();
\r
1628 calc.mode = "discrete";
\r
1629 calc.keyTime = 0.5;
\r
1630 calc.to.degit = 1;
\r
1631 calc.to.string = "block";
\r
1632 calc.to.from__.string = "inline";
\r
1633 expect(calc.call()(0.2)).toBe("inline");
\r
1634 expect(calc.call()(0.3)).toBe("inline");
\r
1636 calc.to = base("$from").up();
\r
1637 calc.to.from__ = base("$from").up();
\r
1638 calc.mode = "linear";
\r
1640 calc.to.degit = 1;
\r
1641 calc.to.string = "1 1";
\r
1642 calc.to.from__.string = "0.0 1";
\r
1643 expect(calc.call()(0.2)).toBe("0.2 1.0");
\r
1644 expect(calc.call()(0.3)).toBe("0.3 1.0");
\r
1646 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1647 it("should be this for the value (the invalid partion)", function() {
\r
1648 calc.keyTime = null;
\r
1649 expect(calc.call()(1)).toBe(calc.string);
\r
1651 calc.keyTime = void 0;
\r
1652 expect(calc.call()(1)).toBe(calc.string);
\r
1654 calc.keyTime = 1/0;
\r
1655 expect(calc.call()(1)).toBe(calc.string);
\r
1657 expect(calc.call()()).toBe(calc.string);
\r
1659 calc = base("$calcMode").up();
\r
1660 calc.mode = "paced";
\r
1661 calc.to.from__ = from;
\r
1662 expect(calc.call()()).toBe(calc.string);
\r
1664 calc = base("$calcMode").up();
\r
1665 calc.mode = "discrete";
\r
1666 expect(calc.call()()).toBe(calc.string);
\r
1669 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1670 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1671 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1674 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1675 return function (t) {
\r
1676 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1677 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1681 expect(calc.keySplines).toBeNull();
\r
1682 calc.mode = "spline";
\r
1683 expect( calc.call()("undef")).toBe(Math.PI);
\r
1684 calc.keySplines = [0, 0, 1, 1];
\r
1685 calc.to.degit = 1;
\r
1686 calc.to.from__ = from;
\r
1687 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1688 calc.to.from__ = from;
\r
1689 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1690 calc.to.from__ = from;
\r
1691 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1693 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1694 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1695 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1696 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1697 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1698 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1699 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1700 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1701 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1703 var a = y4-3*(y3-y2)-y1,
\r
1704 b = 3*(y3-2*y2+y1),
\r
1706 d = y1 - bezier.apply(null, arguments)(t);
\r
1707 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1710 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1711 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1714 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1715 return function (t) {
\r
1717 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1718 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1722 calc.mode = "spline";
\r
1723 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1724 calc.to.degit = 1;
\r
1725 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1726 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1727 calc.to.from__ = from;
\r
1728 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1729 calc.to.from__ = from;
\r
1730 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1732 var ff = function(k) {
\r
1733 calc.keySplines = k;
\r
1734 calc.to.degit = 10;
\r
1735 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1736 epsilon = 1e-5; //誤差
\r
1737 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1738 calc.to.from__ = from;
\r
1739 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1740 calc.to.from__ = from;
\r
1741 b = b(Math.random());
\r
1742 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1744 for (var i=0;i<10000;++i) {
\r
1745 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1749 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1750 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1751 calc.mode = "spline";
\r
1752 calc.keySplines = [0, NaN, 1, 1];
\r
1753 calc.to.degit = 1;
\r
1754 calc.to.from__ = from;
\r
1755 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1758 calc.keySplines = [0, 0, 1, 2];
\r
1759 calc.to.degit = 1;
\r
1760 calc.to.from__ = from;
\r
1761 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1763 calc.keySplines = null;
\r
1764 calc.to.degit = 1;
\r
1765 calc.to.from__ = from;
\r
1766 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1769 describe("A $attribute object", function() {
\r
1770 describe("A push method", function() {
\r
1772 beforeEach( function() {
\r
1773 attr = base("$calcMode").$attribute.up("width");
\r
1774 base("$frame").timelines.length = 0;
\r
1775 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1777 afterEach( function() {
\r
1778 attr.isCSS = false;
\r
1780 /*境界条件を調べておく (limit value analysis)*/
\r
1781 it("should be this for the value (limit value analysis)", function() {
\r
1782 expect(attr.element).toBeNull();
\r
1783 expect(attr.push()).toBeNull();
\r
1784 expect(attr.element).toBeNull();
\r
1785 expect(attr.isCSS).toBeFalsy();
\r
1786 expect(base("$frame").timelines.length).toBe(0);
\r
1788 expect(attr.push(s)).toBeNull();
\r
1789 expect(attr.element).toBeNull();
\r
1790 expect(base("$frame").timelines.length).toBe(0);
\r
1791 expect(attr.hasAttrValues()).toBeFalsy();
\r
1793 var p = document.createElement("g");
\r
1795 expect(attr.push(s)).toBeNull();
\r
1796 expect(attr.element).toBe(p);
\r
1797 expect(base("$frame").timelines.length).toBe(0);
\r
1799 s.setAttribute("end", "0");
\r
1803 check("values", 4);
\r
1804 function check(attrName, num) {
\r
1805 s.setAttribute(attrName, "1");
\r
1806 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1807 var fr = attr.push(s);
\r
1808 expect(attr.element).toBe(p);
\r
1809 var timelines = base("$frame").timelines;
\r
1810 expect(timelines.length).toBe(num);
\r
1811 var line = timelines[num-1];
\r
1812 expect(line).not.toBe(fr);
\r
1813 var act = fr.$activate;
\r
1814 expect(act.dur).toBeNull();
\r
1815 expect(act.repeatCount).toBeNull();
\r
1816 expect(act.repeatDur).toBeNull();
\r
1817 expect(act.min).toBe("0");
\r
1818 expect(act.max).toBe("indefinite");
\r
1819 expect(act.simpleDur).toBeNull();
\r
1820 expect(attr.hasAttrValues()).toBeTruthy();
\r
1822 s.removeAttribute(attrName);
\r
1823 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1825 expect(attr.element).toBe(p);
\r
1826 expect(timelines.length).toBe(num);
\r
1829 /*targetElement属性のサポート*/
\r
1830 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1831 document.documentElement.appendChild(p2);
\r
1832 p2.setAttributeNS(null, "id", "p23");
\r
1833 s.setAttributeNS(null, "targetElement", "p23");
\r
1835 expect(attr.element).toBe(p2);
\r
1838 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1839 document.documentElement.appendChild(p3);
\r
1840 p3.setAttributeNS(null, "id", "p34");
\r
1841 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1843 expect(attr.element).toBe(p3);
\r
1845 /*attributeType属性のサポート*/
\r
1846 s.setAttributeNS(null, "attributeType", "CSS");
\r
1847 s.setAttributeNS(null, "values", "a;b;c");
\r
1849 expect(attr.isCSS).toBeTruthy();
\r
1851 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1852 it("should be this for the value (the valid partion )", function() {
\r
1853 s.setAttribute("from", "1");
\r
1854 var p = document.createElement("g");
\r
1856 var values = [ "0",
\r
1857 "0", null, null, null,
\r
1858 "0", "indefinite", null
\r
1861 check2("dur", "0");
\r
1862 check2("begin", "0");
\r
1864 check2("begin", "1");
\r
1866 check2("end", "0");
\r
1868 check2("repeatCount", "0");
\r
1870 check2("repeatDur", "0");
\r
1872 check2("min", "0");
\r
1874 check2("max", "0");
\r
1876 check2("begin", "12");
\r
1877 values[7] = 1000 * base("$frame").fpms;
\r
1879 check2("dur", "1");
\r
1880 function check2(attrName, value) {
\r
1881 s.setAttribute(attrName, value);
\r
1882 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1883 var fr = attr.push(s);
\r
1884 expect(attr.element).toBe(p);
\r
1885 var timelines = base("$frame").timelines;
\r
1886 var line = timelines[timelines.length-1];
\r
1887 expect(fr.string).toBe(values[0]);
\r
1888 var act = fr.$activate;
\r
1889 expect(act.dur).toBe(values[1]);
\r
1890 expect(act.repeatCount).toBe(values[3]);
\r
1891 expect(act.repeatDur).toBe(values[4]);
\r
1892 expect(act.min).toBe(values[5]);
\r
1893 expect(act.max).toBe(values[6]);
\r
1894 expect(act.simpleDur).toBe(values[7]);
\r
1898 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1899 document.documentElement.appendChild(p4);
\r
1900 p4.appendChild(s);
\r
1901 p4.setAttributeNS(null, "style", "display: none");
\r
1903 expect(attr.setAttribute()).toBeUndefined();
\r
1904 expect(attr.setAttribute("block")).toBeUndefined();
\r
1905 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1906 expect(attr.isCSS).toBeFalsy();
\r
1908 s.setAttributeNS(null, "attributeName", "display");
\r
1910 expect(attr.setAttribute("block")).toBeUndefined();
\r
1911 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1912 expect(attr.isCSS).toBeTruthy();
\r
1913 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1915 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1916 document.documentElement.appendChild(p4);
\r
1917 p4.appendChild(s);
\r
1918 p4.setAttributeNS(null, "style", "display: none");
\r
1920 expect(attr.setAttribute("block")).toBeUndefined();
\r
1921 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1922 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1923 expect(attr.removeAttribute()).toBeUndefined();
\r
1924 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1925 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1927 /*attributeType属性のサポート*/
\r
1928 s.setAttributeNS(null, "values", "a;b;c");
\r
1929 s.setAttributeNS(null, "attributeName", "display");
\r
1930 attr.isCSS = false;
\r
1932 expect(attr.isCSS).toBeTruthy();
\r
1934 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1935 it("should be this for the value (the invalid partion )", function() {
\r
1936 var p = document.createElement("g");
\r
1939 s.setAttributeNS(null, "begin", "1");
\r
1941 var timelines = base("$frame").timelines;
\r
1942 expect(timelines.length).toBe(0);
\r
1943 s.setAttributeNS(null, "from", "0");
\r
1945 expect(timelines.length).toBe(1);
\r
1946 expect(attr.push(12)).toBeNull();
\r
1949 describe("A setValues method", function() {
\r
1951 beforeEach( function() {
\r
1952 attr = base("$calcMode").$attribute.up("width");
\r
1953 base("$frame").timelines.length = 0;
\r
1954 s = document.createElement("animate");
\r
1956 /*境界条件を調べておく (limit value analysis)*/
\r
1957 it("should be this for the value (limit value analysis)", function() {
\r
1958 expect(attr.$from).not.toBeUndefined();
\r
1959 expect(attr.setValues()).toBeNull();
\r
1960 expect(attr.setValues("")).toBeNull();
\r
1962 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1963 expect(attr.setValues("0;1")[0].to.from__.string).toBe("0");
\r
1964 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from__.string).toBe("0");
\r
1965 expect(attr.setValues("0;1", null, "1", "0")[0].to.from__.string).toBe("0");
\r
1967 /*from-to アニメーション*/
\r
1968 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1969 expect(attr.setValues(null, "0", "1")[0].to.from__.string).toBe("0");
\r
1971 /*from-by アニメーション*/
\r
1972 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1973 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1974 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1976 /*fromなしto アニメーション*/
\r
1977 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1978 expect(attr.setValues(null, null, "1")[0].to.from__.string).toBe("0");
\r
1979 var aset = attr.setValues(null, null, "1")[0].to;
\r
1981 expect(aset.from[0]).toBe(0);
\r
1983 /*fromなしby アニメーション*/
\r
1984 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1985 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1986 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1988 expect(aset.from[0]).toBe(0);
\r
1990 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1991 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1992 attr.$from.degit = 1;
\r
1993 var setv = attr.setValues("0;1")[0].call();
\r
1994 expect(setv(0.5)).toBe("0.5");
\r
1995 expect(setv(1)).toBe("1.0");
\r
1997 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1998 expect(setv(0.5)).toBe("0.5");
\r
1999 expect(setv(1)).toBe("1.0");
\r
2000 setv = attr.setValues("0;1;2")[1].call();
\r
2001 expect(setv(0.4)).toBe("1.4");
\r
2002 expect(setv(1)).toBe("2.0");
\r
2004 attr.$from.degit = 2;
\r
2005 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
2006 expect(setv(0.5)).toBe("8.05");
\r
2007 expect(setv(1)).toBe("15.10");
\r
2009 var v = attr.setValues("1;1;2;1;1;15.1");
\r
2010 setv = v[4].mix( {
\r
2013 expect(setv(0.05)).toBe("8.05");
\r
2014 expect(setv(0.1)).toBe("15.10");
\r
2015 setv = v[3].mix( {
\r
2018 expect(setv(0.01)).toBe("1.00");
\r
2019 expect(setv(0.1)).toBe("1.00");
\r
2020 setv = v[2].mix( {
\r
2023 expect(setv(0.25)).toBe("1.50");
\r
2024 expect(setv(0.5)).toBe("1.00");
\r
2026 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2027 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2028 attr.$from.degit = 1;
\r
2029 expect(attr.setValues("")).toBeNull();
\r
2030 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
2033 describe("A setKey method and a isKeyError method", function() {
\r
2035 beforeEach( function() {
\r
2036 attr = base("$calcMode").$attribute.up("width");
\r
2037 base("$frame").timelines.length = 0;
\r
2038 s = document.createElement("animate");
\r
2039 document.createElement("g").appendChild(s);
\r
2041 /*境界条件を調べておく (limit value analysis)*/
\r
2042 it("should be this for the value (limit value analysis)", function() {
\r
2043 expect(attr.setKey(s)).toBeNull();
\r
2044 expect(attr.isKeyError()).toBeFalsy();
\r
2045 expect(attr.isKeyError(0, 0)).toBeFalsy();
\r
2046 expect(attr.isKeyError(1, 0)).toBeFalsy();
\r
2047 expect(attr.isKeyError(1, 1)).toBeTruthy();
\r
2049 s.setAttributeNS(null, "from", "0");
\r
2051 s.setAttributeNS(null, "to", "0");
\r
2052 expect(attr.setKey(s)[0].to.from__.string).toBe("0");
\r
2053 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
2054 s.setAttributeNS(null, "by", "0");
\r
2056 s.setAttributeNS(null, "values", "0;2");
\r
2057 expect(attr.setKey(s)[0].to.from__.string).toBe("0");
\r
2058 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
2060 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
2061 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2063 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
2064 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2065 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2066 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2067 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2069 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
2070 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2071 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2072 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2073 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2075 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2076 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2077 s.setAttributeNS(null, "values", "0;2;12;30");
\r
2078 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
2079 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2080 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2081 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2082 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2083 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
2084 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
2085 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2086 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2087 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2089 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
2090 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2091 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2092 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2094 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
2095 f(0, 0,0.1,0.3,1);
\r
2096 f(1, 0.1,0.4,0.5,0.7);
\r
2097 f(2, 0.2,0.2,0.1,1);
\r
2099 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
2100 f(0, 0,0.1,0.3,1);
\r
2101 f(1, 0.1,0.4,0.5,0.7);
\r
2102 f(2, 0.2,0.2,0.1,1);
\r
2104 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
2105 f(0, 0,0.1,0.333,1);
\r
2106 f(1, 0.1,0.4,0.5,0.7);
\r
2107 f(2, 0.2,0.2,0.1,1);
\r
2108 function f (i, a, b, c, d) {
\r
2109 var splines = attr.setKey(s)[i].keySplines;
\r
2110 expect(splines[0]).toBe(a);
\r
2111 expect(splines[1]).toBe(b);
\r
2112 expect(splines[2]).toBe(c);
\r
2113 expect(splines[3]).toBe(d);
\r
2116 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2117 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2118 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2119 expect(attr.setKey(s)).toBeNull();
\r
2120 s.setAttributeNS(null, "values", "0;2;12");
\r
2121 expect(attr.setKey(s)).toBeNull();
\r
2122 s.setAttributeNS(null, "values", "0;2;12;20");
\r
2123 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
2124 expect(attr.setKey(s)).toBeNull();
\r
2128 describe("A $setElement object", function() {
\r
2129 describe("A timeline property", function() {
\r
2130 var $set, ele, frame;
\r
2131 beforeEach( function() {
\r
2132 $set = base("$calcMode").$attribute.$setElement.up();
\r
2133 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2134 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2135 p.appendChild(ele);
\r
2136 frame = base("$frame");
\r
2138 /*境界条件を調べておく (limit value analysis)*/
\r
2139 it("should be this for the value (limit value analysis)", function() {
\r
2140 expect($set.timeline).toBe(frame.$begin);
\r
2143 expect($set.timeline).toBe(frame.$begin);
\r
2144 expect($set.element).toBeNull();
\r
2148 describe("An init method", function() {
\r
2149 var $set, ele, frame;
\r
2150 beforeEach( function() {
\r
2151 $set = base("$calcMode").$attribute.$setElement.up();
\r
2152 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2153 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2154 p.appendChild(ele);
\r
2155 frame = base("$frame");
\r
2157 /*境界条件を調べておく (limit value analysis)*/
\r
2158 it("should be this for the value (limit value analysis)", function() {
\r
2159 expect($set.to).toBe("");
\r
2160 expect($set.attrName).toBe("");
\r
2161 expect($set.defaultValue).toBe("");
\r
2162 expect($set.isDefault).toBeFalsy();
\r
2163 expect($set.attrNameSpace).toBeNull();
\r
2164 expect($set.numberOfElemList).toBe(0);
\r
2166 expect($set.timeline).toBe(frame.$begin);
\r
2168 expect($set.to).toBe("");
\r
2169 expect($set.attrName).toBe("");
\r
2170 expect($set.isDefault).toBeFalsy();
\r
2171 expect($set.attrNameSpace).toBeNull();
\r
2172 expect($set.timeline).toBe(frame.$begin);
\r
2174 expect($set.elementList.length).toBe(0);
\r
2175 $set.initialize();
\r
2176 $set.elementList = null;
\r
2177 expect($set.initialize()).toBeUndefined();
\r
2179 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2180 it("should be this for the value (the valid partion )", function() {
\r
2181 ele.setAttributeNS(null, "to", "t1");
\r
2183 expect($set.to).toBe("t1");
\r
2184 expect($set.attrName).toBe("");
\r
2185 expect($set.defaultValue).toBe("");
\r
2187 ele.setAttributeNS(null, "attributeName", "tt1");
\r
2189 expect($set.to).toBe("t1");
\r
2190 expect($set.attrName).toBe("tt1");
\r
2191 expect($set.defaultValue).toBe("");
\r
2193 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
2195 expect($set.defaultValue).toBe("undef");
\r
2196 expect($set.isDefault).toBeTruthy();
\r
2198 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2199 ele.parentNode.style.setProperty("font-size", "12px");
\r
2201 expect($set.defaultValue).toBe("12px");
\r
2202 expect($set.isDefault).toBeFalsy();
\r
2204 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2206 expect($set.to).toBe("t1");
\r
2207 expect($set.attrName).toBe("xlink:href");
\r
2208 expect($set.defaultValue).toBe("");
\r
2209 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2211 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2213 document.documentElement.appendChild(ele);
\r
2214 $set.elementList = document.getElementsByTagNameNS("http://www.w3.org/2000/svg", "set");
\r
2215 frame.timelines.length = 0;
\r
2216 var setinit = $set.initialize;
\r
2217 $set.initialize();
\r
2218 expect(frame.timelines.length).toBe(1);
\r
2220 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2221 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2223 expect($set.to).toBe("");
\r
2224 expect($set.attrName).toBe("");
\r
2225 expect($set.defaultValue).toBe("");
\r
2228 expect($set.to).toBe("");
\r
2229 expect($set.attrName).toBe("");
\r
2230 expect($set.defaultValue).toBe("");
\r
2233 describe("Frame Set", function() {
\r
2234 var $set, ele, frame;
\r
2235 beforeEach( function() {
\r
2236 $set = base("$calcMode").$attribute.$setElement.up();
\r
2237 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2238 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2239 p.appendChild(ele);
\r
2240 frame = base("$frame");
\r
2241 frame.timelines.length = 0; //配列の初期化
\r
2242 frame.startTime = Date.now();
\r
2243 frame.setFrame(0);
\r
2245 afterEach( function() {
\r
2246 $set.isCSS = false;
\r
2248 /*境界条件を調べておく (limit value analysis)*/
\r
2249 it("should be this for the value (limit value analysis)", function() {
\r
2250 expect($set.isEnd).toBeFalsy();
\r
2251 ele.setAttributeNS(null, "dur", "1s");
\r
2252 ele.setAttributeNS(null, "attributeName", "fill");
\r
2253 ele.setAttributeNS(null, "to", "red");
\r
2255 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2256 $set.isCSS = false;
\r
2257 expect($set.timeline).not.toBe(frame.$begin);
\r
2258 frame.setFrame(0);
\r
2259 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2261 var line = $set.timeline;
\r
2262 expect(line.$list.state).toBe(line.$list.PLAYING);
\r
2263 frame.setFrame(24);
\r
2264 expect(line.$list.state).toBe(line.$list.POSTWAITING);
\r
2265 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2267 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2268 it("should be this for the value (the valid partion)", function() {
\r
2269 ele.setAttributeNS(null, "begin", "1s");
\r
2270 ele.setAttributeNS(null, "dur", "1s");
\r
2271 ele.setAttributeNS(null, "attributeName", "fill");
\r
2272 ele.setAttributeNS(null, "to", "red");
\r
2274 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2275 $set.isCSS = false;
\r
2276 var f = function(num) {
\r
2277 frame.setFrame(num);
\r
2278 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2283 frame.setFrame(24);
\r
2284 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2285 frame.setFrame(25);
\r
2286 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2290 ele.setAttributeNS(null, "fill", "freeze");
\r
2292 $set.isCSS = false;
\r
2296 frame.setFrame(24);
\r
2297 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2298 frame.setFrame(25);
\r
2299 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2300 frame.setFrame(48);
\r
2301 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2302 frame.setFrame(49);
\r
2303 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2304 ele.setAttributeNS(null, "begin", "1s");
\r
2305 ele.setAttributeNS(null, "attributeName", "fill");
\r
2306 ele.setAttributeNS(null, "to", "red");
\r
2307 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2309 $set.isCSS = false;
\r
2310 var f = function(num) {
\r
2311 frame.setFrame(num);
\r
2312 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2320 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2321 it("should be this for the value (the invalid partion)", function() {
\r
2326 describe("A $animateElement object", function() {
\r
2327 describe("An init method", function() {
\r
2328 var $animate, ele, frame;
\r
2329 beforeEach( function() {
\r
2330 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2331 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2332 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2333 p.appendChild(ele);
\r
2334 frame = base("$frame");
\r
2335 frame.pauseAnimation();
\r
2336 frame.timelines.length = 0;
\r
2337 frame.startTime = Date.now();
\r
2338 frame.setFrame(0);
\r
2340 /*境界条件を調べておく (limit value analysis)*/
\r
2341 it("should be this for the value (limit value analysis)", function() {
\r
2342 expect(typeof $animate.getAdvanceEnd).toBe("function");
\r
2345 ele.setAttributeNS(null, "begin", "1s");
\r
2346 ele.setAttributeNS(null, "dur", "1s");
\r
2347 ele.setAttributeNS(null, "attributeName", "d");
\r
2348 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2349 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2350 $animate.init(ele);
\r
2351 expect($animate.isCSS).toBeFalsy();
\r
2352 frame.setFrame(0);
\r
2353 var p = ele.parentNode;
\r
2354 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2355 * 他のブラウザではnullを返すため、その対策をする*/
\r
2356 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2358 function f(fr, result) {
\r
2359 frame.setFrame(fr);
\r
2360 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2363 f(24, "M20.0 0.0 L20.0 30.0");
\r
2364 f(36, "M20.0 10.0 L15.0 30.0");
\r
2367 ele.setAttributeNS(null, "fill", "freeze");
\r
2368 $animate.init(ele);
\r
2369 f(24, "M20.0 0.0 L20.0 30.0");
\r
2370 f(36, "M20.0 10.0 L15.0 30.0");
\r
2371 f(48, "M20.0 20.0 L10.0 30.0");
\r
2373 frame.timelines.length = 0;
\r
2374 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2375 $animate.init(ele);
\r
2376 expect($animate.isCSS).toBeFalsy();
\r
2377 expect($animate.mode).toBe("discrete");
\r
2378 f(24, "M20.0 0.0 L20.0 30.0");
\r
2379 f(25, "M20.0 0.0 L20.0 30.0");
\r
2380 f(37, "M20.0 20.0 L10.0 30.0");
\r
2381 f(48, "M20.0 20.0 L10.0 30.0");
\r
2383 [ ["display", "inline", "none"],
\r
2384 ["visibility", "hidden", "visible"],
\r
2385 ["stroke-linecap", "round", "square"],
\r
2386 ["font-style", "italic", "normal"]
\r
2387 ].forEach( function(attr) {
\r
2388 var attrName = attr[0],
\r
2391 function g(fr, result) {
\r
2392 frame.setFrame(fr);
\r
2393 expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);
\r
2397 ele.setAttributeNS(null, "from", from);
\r
2398 ele.setAttributeNS(null, "to", to);
\r
2399 frame.timelines.length = 0;
\r
2400 ele.setAttributeNS(null, "calcMode", "linear");
\r
2401 ele.setAttributeNS(null, "attributeName", attrName);
\r
2402 $animate.init(ele);
\r
2403 expect($animate.mode).toBe("discrete");
\r
2410 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2411 it("should be this for the value (the valid partion )", function() {
\r
2413 ele.setAttributeNS(null, "begin", "0s");
\r
2414 ele.setAttributeNS(null, "dur", "100s");
\r
2415 ele.setAttributeNS(null, "attributeName", "d");
\r
2416 ele.setAttributeNS(null, "fill", "freeze");
\r
2417 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2418 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2419 $animate.init(ele);
\r
2421 var p = ele.parentNode;
\r
2422 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2424 function f(fr, result) {
\r
2425 frame.setFrame(fr);
\r
2426 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2429 for (var i=0;i<2400;++i) {
\r
2430 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2432 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2435 frame.timelines.length = 0;
\r
2436 ele.setAttributeNS(null, "begin", "0s");
\r
2437 ele.setAttributeNS(null, "dur", "1s");
\r
2438 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2439 ele.setAttributeNS(null, "attributeName", "d");
\r
2440 ele.setAttributeNS(null, "fill", "freeze");
\r
2441 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2442 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2443 $animate.init(ele);
\r
2444 f(23, "M20.0 23.0 L20.0 30.0");
\r
2445 f(24, "M20.0 0.0 L20.0 30.0");
\r
2446 f(25, "M20.0 1.0 L20.0 30.0");
\r
2447 f(48, "M20.0 24.0 L20.0 30.0");
\r
2449 frame.timelines.length = 0;
\r
2450 ele.setAttributeNS(null, "begin", "0s");
\r
2451 ele.setAttributeNS(null, "dur", "2s");
\r
2452 ele.setAttributeNS(null, "attributeName", "d");
\r
2453 ele.setAttributeNS(null, "fill", "freeze");
\r
2454 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2455 $animate.init(ele);
\r
2456 f(0, "M20.0 0.0 L20.0 30.0");
\r
2457 f(1, "M20.0 1.0 L20.0 30.0");
\r
2458 f(24, "M20.0 24.0 L20.0 30.0");
\r
2459 f(25, "M20.0 24.1 L20.0 30.0");
\r
2460 f(47, "M20.0 26.3 L20.0 30.0");
\r
2461 f(48, "M20.0 26.4 L20.0 30.0");
\r
2462 f(49, "M20.0 26.4 L20.0 30.0");
\r
2463 f(50, "M20.0 26.4 L20.0 30.0");
\r
2465 frame.timelines.length = 0;
\r
2466 ele.setAttributeNS(null, "begin", "0s");
\r
2467 ele.setAttributeNS(null, "end", "2s");
\r
2468 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2469 ele.removeAttributeNS(null, "repeatDur");
\r
2470 ele.setAttributeNS(null, "attributeName", "d");
\r
2471 ele.setAttributeNS(null, "fill", "freeze");
\r
2472 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2473 $animate.init(ele);
\r
2474 f(0, "M20.0 0.0 L20.0 30.0");
\r
2475 f(1, "M20.0 0.0 L20.0 30.0");
\r
2476 f(24, "M20.0 0.0 L20.0 30.0");
\r
2477 f(25, "M20.0 0.0 L20.0 30.0");
\r
2478 f(47, "M20.0 0.0 L20.0 30.0");
\r
2479 f(48, "M20.0 0.0 L20.0 30.0");
\r
2480 f(49, "M20.0 0.0 L20.0 30.0");
\r
2481 f(50, "M20.0 0.0 L20.0 30.0");
\r
2483 frame.timelines.length = 0;
\r
2484 ele.setAttributeNS(null, "dur", "2s");
\r
2485 ele.setAttributeNS(null, "fill", "remove");
\r
2486 var attrValue = p.getAttributeNS(null, "d");
\r
2487 $animate.init(ele);
\r
2490 frame.timelines.length = 0;
\r
2491 p.removeAttributeNS(null, "d");
\r
2492 ele.setAttributeNS(null, "fill", "freeze");
\r
2493 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2494 $animate.init(ele);
\r
2495 f(1, "M20.0 5.0 L20.0 30.0");
\r
2496 f(48, "M20.0 26.4 L20.0 30.0");
\r
2498 frame.timelines.length = 0;
\r
2499 ele.setAttributeNS(null, "fill", "freeze");
\r
2500 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2501 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2502 $animate.init(ele);
\r
2503 f(1, "M20.0 0.0 L20.0 30.0");
\r
2504 f(4, "M20.0 0.0 L20.0 30.0");
\r
2505 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2507 f(24, "M20.0 24.0 L20.0 30.0");
\r
2508 f(25, "M20.0 24.0 L20.0 30.0");
\r
2509 f(29, "M20.0 26.4 L20.0 30.0");
\r
2510 f(48, "M20.0 26.4 L20.0 30.0");
\r
2512 frame.timelines.length = 0;
\r
2513 ele.setAttributeNS(null, "calcMode", "spline");
\r
2514 ele.removeAttributeNS(null, "keyTimes");
\r
2515 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2516 ele.removeAttributeNS(null, "end");
\r
2517 ele.setAttributeNS(null, "dur", "9s");
\r
2518 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2519 $animate.init(ele);
\r
2526 frame.timelines.length = 0;
\r
2527 ele.setAttributeNS(null, "calcMode", "spline");
\r
2528 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2529 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2530 ele.setAttributeNS(null, "dur", "8s");
\r
2531 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2532 $animate.init(ele);
\r
2540 frame.timelines.length = 0;
\r
2541 ele.setAttributeNS(null, "begin", "click");
\r
2542 ele.setAttributeNS(null, "calcMode", "spline");
\r
2543 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2544 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2545 ele.setAttributeNS(null, "dur", "8s");
\r
2546 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2547 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2548 $animate.init(ele);
\r
2555 ( function(attrName) {
\r
2556 function g(fr, result) {
\r
2557 frame.setFrame(fr);
\r
2558 expect(p.style.getPropertyValue(attrName)).toBe(result);
\r
2561 frame.timelines.length = 0;
\r
2562 ele.setAttributeNS(null, "begin", "0s");
\r
2563 ele.setAttributeNS(null, "calcMode", "linear");
\r
2564 ele.setAttributeNS(null, "attributeName", attrName);
\r
2565 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2566 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2567 ele.setAttributeNS(null, "dur", "8s");
\r
2568 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2569 $animate.init(ele);
\r
2570 expect($animate.mode).toBe("discrete");
\r
2577 frame.timelines.length = 0;
\r
2578 ele.setAttributeNS(null, "begin", "click");
\r
2579 ele.setAttributeNS(null, "calcMode", "linear");
\r
2580 ele.setAttributeNS(null, "attributeName", attrName);
\r
2581 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2582 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2583 ele.setAttributeNS(null, "dur", "8s");
\r
2584 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2585 $animate.init(ele);
\r
2586 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2587 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2588 p.dispatchEvent(evt);
\r
2589 var cur = base("$frame").currentFrame;
\r
2590 expect($animate.mode).toBe("discrete");
\r
2591 g(cur+0, "inline");
\r
2592 g(cur+48, "block");
\r
2593 g(cur+96, "inline");
\r
2594 g(cur+192, "block");
\r
2595 g(cur+300, "block");
\r
2598 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2599 it("should be this for the value (the invalid partion )", function() {
\r
2600 ele.setAttributeNS(null, "begin", "0s");
\r
2601 ele.setAttributeNS(null, "dur", "100s");
\r
2602 ele.setAttributeNS(null, "attributeName", "d");
\r
2603 ele.setAttributeNS(null, "fill", "freeze");
\r
2604 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2605 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2606 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2607 $animate.init(ele);
\r
2609 var p = ele.parentNode;
\r
2610 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2612 function f(fr, result) {
\r
2613 frame.setFrame(fr);
\r
2614 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2619 frame.timelines.length = 0;
\r
2620 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2621 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2622 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2623 $animate.init(ele);
\r
2627 /*keyTimes属性が0から始まっていない*/
\r
2628 frame.timelines.length = 0;
\r
2629 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2633 function ff(mode) {
\r
2634 ele.setAttributeNS(null, "calcMode", mode);
\r
2635 $animate.init(ele);
\r
2640 frame.timelines.length = 0;
\r
2641 ele.setAttributeNS(null, "calcMode", "spline");
\r
2642 $animate.init(ele);
\r
2643 expect($animate.mode).toBe("spline");
\r
2649 describe("RGB Color", function() {
\r
2650 var $animate, ele, frame, f;
\r
2651 beforeEach( function() {
\r
2652 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2653 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2654 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2655 p.appendChild(ele);
\r
2656 frame = base("$frame");
\r
2657 frame.timelines.length = 0;
\r
2659 f = function (fr, result, attr) {
\r
2660 frame.setFrame(fr);
\r
2661 expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));
\r
2664 /*境界条件を調べておく (limit value analysis)*/
\r
2665 it("should be this for the value (limit value analysis)", function() {
\r
2666 ele.setAttributeNS(null, "begin", "0s");
\r
2667 ele.setAttributeNS(null, "dur", "1s");
\r
2668 ele.setAttributeNS(null, "attributeName", "fill");
\r
2669 ele.setAttributeNS(null, "fill", "remove");
\r
2670 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2671 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2672 $animate.init(ele);
\r
2674 f(0, "rgb(0, 0, 0)", "fill");
\r
2675 f(23, "rgb(10, 10, 1)", "fill");
\r
2677 frame.timelines.length = 0;
\r
2678 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2679 $animate.init(ele);
\r
2680 f(0, "rgb(0, 0, 0)", "stroke");
\r
2681 f(23, "rgb(10, 10, 1)", "stroke");
\r
2683 frame.timelines.length = 0;
\r
2684 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2685 $animate.init(ele);
\r
2686 f(0, "rgb(0,0,0)", "stop-color");
\r
2687 f(23, "rgb(10,10,1)", "stop-color");
\r
2689 frame.timelines.length = 0;
\r
2690 ele.setAttributeNS(null, "attributeName", "color");
\r
2691 $animate.init(ele);
\r
2692 f(0, "rgb(0,0,0)", "color");
\r
2693 f(23, "rgb(10,10,1)", "color");
\r
2695 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2696 it("should be this for the value (the valid partion )", function() {
\r
2697 ele.setAttributeNS(null, "begin", "0s");
\r
2698 ele.setAttributeNS(null, "dur", "1s");
\r
2699 ele.setAttributeNS(null, "attributeName", "fill");
\r
2700 ele.setAttributeNS(null, "fill", "remove");
\r
2701 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2702 $animate.init(ele);
\r
2704 f(0, "rgb(0, 0, 0)", "fill");
\r
2705 f(1, "rgb(1, 0, 0)", "fill");
\r
2706 f(23, "rgb(23, 2, 1)", "fill");
\r
2708 frame.timelines.length = 0;
\r
2709 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2710 $animate.init(ele);
\r
2713 f(0, "rgb(0, 8, 60)", "fill");
\r
2714 f(1, "rgb(1, 9, 60)", "fill");
\r
2715 f(23, "rgb(23, 31, 60)", "fill");
\r
2717 frame.timelines.length = 0;
\r
2718 ele.setAttributeNS(null, "fill", "freeze");
\r
2719 ele.setAttributeNS(null, "values", "black;white");
\r
2720 $animate.init(ele);
\r
2721 /*色キーワードをrgb形式に変換*/
\r
2723 f(0, "rgb(0, 0, 0)", "fill");
\r
2724 f(12, "rgb(128, 128, 128)", "fill");
\r
2725 f(24, "rgb(255, 255, 255)", "fill");
\r
2727 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2728 it("should be this for the value (the invalid partion )", function() {
\r
2729 ele.setAttributeNS(null, "begin", "0s");
\r
2730 ele.setAttributeNS(null, "dur", "1s");
\r
2731 ele.setAttributeNS(null, "attributeName", "fi");
\r
2732 ele.setAttributeNS(null, "fill", "remove");
\r
2733 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2734 $animate.init(ele);
\r
2737 function f (fr, result, attr) {
\r
2738 frame.setFrame(fr);
\r
2739 expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);
\r
2741 f(0, "#83.0C", "fi");
\r
2742 f(1, "#84.0C", "fi");
\r
2743 f(23, "#106.0C", "fi");
\r
2746 describe("A $animateTransformElement object", function() {
\r
2747 describe("An init method", function() {
\r
2748 var $animate, ele, frame, p;
\r
2749 beforeEach( function() {
\r
2750 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2751 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
2752 $animate.degits = 1;
\r
2753 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2754 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2755 p.appendChild(ele);
\r
2756 frame = base("$frame");
\r
2757 frame.timelines.length = 0;
\r
2758 frame.startTime = Date.now();
\r
2759 frame.setFrame(0);
\r
2761 afterEach( function() {
\r
2762 $animate.numberOfList = -1;
\r
2764 /*境界条件を調べておく (limit value analysis)*/
\r
2765 it("should be this for the value (limit value analysis)", function() {
\r
2766 expect($animate.numberOfList).toBe(-1);
\r
2767 expect($animate.type).toBe("translate");
\r
2768 expect(p.__transformList).toBeUndefined();
\r
2769 expect($animate.isCSS).toBeFalsy();
\r
2770 expect($animate.isSum).toBeFalsy();
\r
2771 expect($animate.attrName).toBe("transform");
\r
2774 expect($animate.numberOfList).toBe(-1);
\r
2775 expect(p.__transformList).toBeUndefined();
\r
2776 expect($animate.isCSS).toBeFalsy();
\r
2777 expect($animate.type).toBe("translate");
\r
2778 expect($animate.attrName).toBe("transform");
\r
2781 expect($animate.numberOfList).toBe(-1);
\r
2782 expect(p.__transformList).toBeUndefined();
\r
2783 expect($animate.isCSS).toBeFalsy();
\r
2784 expect($animate.type).toBe("translate");
\r
2785 expect($animate.attrName).toBe("transform");
\r
2787 $animate.init(ele);
\r
2788 expect($animate.numberOfList).toBe(-1);
\r
2789 expect(p.__transformList).toEqual([]);
\r
2790 expect($animate.isCSS).toBeFalsy();
\r
2791 expect($animate.type).toBe("translate");
\r
2792 expect($animate.attrName).toBe("transform");
\r
2794 ele.setAttributeNS(null, "values", "0;1");
\r
2795 ele.setAttributeNS(null, "attributeName", "");
\r
2796 $animate.init(ele);
\r
2797 expect($animate.isCSS).toBeFalsy();
\r
2798 expect($animate.type).toBe("translate");
\r
2799 expect($animate.type).toBe("translate");
\r
2800 expect($animate.numberOfList).toBe(0);
\r
2801 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2802 value: "translate(0)",
\r
2806 ele.setAttributeNS(null, "type", "translate");
\r
2807 $animate.init(ele);
\r
2808 expect($animate.numberOfList).toBe(0);
\r
2809 expect($animate.isCSS).toBeFalsy();
\r
2810 expect($animate.type).toBe("translate");
\r
2811 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2812 value: "translate(0)",
\r
2815 $animate.tocall(0);
\r
2816 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2818 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2819 $animate.numberOfList = -1;
\r
2820 $animate.init(ele.parentNode.lastChild);
\r
2821 expect($animate.numberOfList).toBe(1);
\r
2822 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2823 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2825 expect($animate.type).toBe("translate");
\r
2826 $animate.tocall(0);
\r
2827 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2828 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2829 $animate._setEndFrame(1);
\r
2830 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2831 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2833 delete p.__transformList;
\r
2834 ele.setAttributeNS(null, "type", "scale");
\r
2835 $animate.numberOfList = -1;
\r
2836 $animate.init(ele);
\r
2837 expect($animate.numberOfList).toBe(0);
\r
2838 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2839 value: "translate(0)",
\r
2842 expect($animate.type).toBe("scale");
\r
2844 delete p.__transformList;
\r
2845 $animate.numberOfList = -1;
\r
2846 ele.setAttributeNS(null, "additive", "sum");
\r
2847 ele.setAttributeNS(null, "fill", "freeze");
\r
2848 $animate.init(ele);
\r
2849 expect($animate.isSum).toBeTruthy();
\r
2850 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2851 value: "translate(0)",
\r
2854 delete p.__transformList;
\r
2855 $animate.numberOfList = -1;
\r
2856 ele.setAttributeNS(null, "additive", "replace");
\r
2857 ele.setAttributeNS(null, "fill", "remove");
\r
2858 $animate.init(ele);
\r
2859 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2860 value: "translate(0)",
\r
2864 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2865 it("should be this for the value (the valid partion )", function() {
\r
2866 ele.setAttributeNS(null, "type", "scale");
\r
2867 ele.setAttributeNS(null, "values", "0;1");
\r
2868 $animate.init(ele);
\r
2869 expect($animate.isCSS).toBeFalsy();
\r
2870 expect($animate.numberOfList).toBe(0);
\r
2871 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2872 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
2873 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
2874 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2876 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2877 $animate.numberOfList = -1;
\r
2878 $animate.init(ele.parentNode.lastChild);
\r
2879 expect($animate.numberOfList).toBe(1);
\r
2880 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
2881 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
2883 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2884 $animate.up("$a").numberOfList = -1;
\r
2885 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2886 $animate.$a.init(ele.parentNode.lastChild);
\r
2887 expect($animate.$a.numberOfList).toBe(2);
\r
2888 expect($animate.$a.isDefault).toBeTruthy();
\r
2889 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2890 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
2891 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
2892 $animate.defaultValue = $animate.$a.defaultValue;
\r
2893 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
2895 ele.setAttributeNS(null, "additive", "sum");
\r
2896 var parentNode = ele.parentNode;
\r
2897 parentNode.appendChild(ele.cloneNode(true));
\r
2898 parentNode.__transformList = [];
\r
2899 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
2900 parentNode.removeChild(ele);
\r
2901 $animate.numberOfList = -1;
\r
2902 $animate.init(parentNode.lastChild);
\r
2903 expect($animate.numberOfList).toBe(0);
\r
2904 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2905 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2907 parentNode.appendChild(ele.cloneNode(true));
\r
2908 $animate.up("$a").numberOfList = -1;
\r
2909 parentNode.__transformList = [];
\r
2910 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2911 $animate.$a.init(parentNode.lastChild);
\r
2912 expect($animate.$a.numberOfList).toBe(0);
\r
2913 expect($animate.$a.isDefault).toBeTruthy();
\r
2914 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
2915 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
2916 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
2917 $animate.defaultValue = $animate.$a.defaultValue;
\r
2918 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
2920 ele.removeAttributeNS(null, "additive");
\r
2921 ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",
\r
2922 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
2923 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
2924 "scale(0.0)", "scale(1.0)");
\r
2925 function ad(first, second, a, b, c, d) {
\r
2927 while (parentNode.firstChild) {
\r
2928 parentNode.removeChild(parentNode.firstChild);
\r
2931 /*additive属性のreplaceとsumの混合*/
\r
2932 ele.setAttributeNS(null, "additive", first);
\r
2933 parentNode.appendChild(ele.cloneNode(true));
\r
2934 ele.setAttributeNS(null, "additive", second);
\r
2935 parentNode.appendChild(ele.cloneNode(true));
\r
2936 parentNode.__transformList = [];
\r
2937 $animate.numberOfList = -1;
\r
2938 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
2939 $animate.up("$first").init(parentNode.firstChild);
\r
2940 $animate.up("$second").init(parentNode.lastChild);
\r
2941 expect($animate.$first.numberOfList).toBe(0);
\r
2942 expect($animate.$second.numberOfList).toBe(1);
\r
2943 expect($animate.$first.tocall(0)).toBe(a);
\r
2944 expect($animate.$second.tocall(0)).toBe(b);
\r
2945 expect($animate.$first.tocall(1)).toBe(c);
\r
2946 expect($animate.$second.tocall(1)).toBe(d);
\r
2949 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2950 it("should be this for the value (the invalid partion )", function() {
\r
2951 $animate.init(ele);
\r
2952 ele.parentNode.__transformList = null;
\r
2953 expect( function () {
\r
2954 $animate.tocall(0);
\r
2957 $animate.numberOfList = -1;
\r
2958 $animate.init(ele);
\r
2959 $animate.numberOfList = -1;
\r
2960 expect( function () {
\r
2961 $animate.tocall(0);
\r
2966 describe("A $motionElement object", function() {
\r
2967 describe("An init method", function() {
\r
2968 var $animate, ele, frame, p;
\r
2969 beforeEach( function() {
\r
2970 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
2971 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
2972 $animate.degits = 1;
\r
2973 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2974 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
2975 p.appendChild(ele);
\r
2976 frame = base("$frame");
\r
2977 frame.timelines.length = 0;
\r
2978 frame.startTime = Date.now();
\r
2979 frame.setFrame(0);
\r
2981 afterEach( function() {
\r
2982 $animate.numberOfList = -1;
\r
2983 delete $animate.element;
\r
2984 p.__transformList = null;
\r
2986 /*境界条件を調べておく (limit value analysis)*/
\r
2987 it("should be this for the value (limit value analysis)", function() {
\r
2988 expect($animate.type).toBe("translate");
\r
2989 expect($animate.mode).toBe("paced");
\r
2990 ele.setAttributeNS(null, "type", "scale");
\r
2991 expect($animate.rotate).toBe("0");
\r
2992 $animate.init(ele);
\r
2993 expect($animate.type).toBe("translate");
\r
2994 expect($animate.mode).toBe("paced");
\r
2995 expect($animate.rotate).toBe("0");
\r
2997 ele.setAttributeNS(null, "values", "0,0;1,0");
\r
2998 $animate.up("$a").init(ele);
\r
2999 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3000 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3001 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3003 var ec = ele.cloneNode(true);
\r
3004 p.appendChild(ec);
\r
3005 ec.removeAttributeNS(null, "values");
\r
3006 ec.setAttributeNS(null, "from", "0,0");
\r
3007 ec.setAttributeNS(null, "to", "1,0");
\r
3008 $animate.up("$a").init(ec);
\r
3009 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3010 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3011 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3013 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3014 it("should be this for the value (the invalid partion )", function() {
\r
3018 describe("A hasAttrValues method", function() {
\r
3019 var $animate, ele, frame, p;
\r
3020 beforeEach( function() {
\r
3021 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3022 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3023 $animate.degits = 1;
\r
3024 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3025 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3026 p.appendChild(ele);
\r
3027 frame = base("$frame");
\r
3028 frame.timelines.length = 0;
\r
3029 frame.startTime = Date.now();
\r
3030 frame.setFrame(0);
\r
3032 afterEach( function() {
\r
3033 $animate.numberOfList = -1;
\r
3034 delete $animate.element;
\r
3035 p.__transformList = null;
\r
3037 /*境界条件を調べておく (limit value analysis)*/
\r
3038 it("should be this for the value (limit value analysis)", function() {
\r
3040 expect($animate.up("$a").hasAttrValues()).toBeFalsy();
\r
3041 $animate.up("$a").init(ele);
\r
3042 expect($animate.$a.hasAttrValues()).toBeFalsy();
\r
3044 ele.setAttributeNS(null, "path", "M");
\r
3045 expect($animate.$a.hasAttrValues()).toBeTruthy();
\r
3046 $animate.$animateTransformElement.up("$b").init(ele);
\r
3047 expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();
\r
3051 describe("Event", function() {
\r
3052 var $animate, ele, frame, p;
\r
3053 beforeEach( function() {
\r
3055 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3056 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3057 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3058 p.appendChild(ele);
\r
3059 frame = base("$frame");
\r
3060 frame.pauseAnimation();
\r
3061 frame.timelines.length = 0; //配列の初期化
\r
3062 frame.setFrame(0);
\r
3064 /*境界条件を調べておく (limit value analysis)*/
\r
3065 it("should be this for the value (limit value analysis)", function() {
\r
3066 ele.addEventListener("beginEvent", function(evt) {
\r
3067 expect(evt.target).toBe(ele);
\r
3069 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3070 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3071 ele.dispatchEvent(evt);
\r
3073 ele.setAttributeNS(null, "begin", "mousedown");
\r
3074 ele.setAttributeNS(null, "dur", "1s");
\r
3075 ele.setAttributeNS(null, "attributeName", "fill");
\r
3076 ele.setAttributeNS(null, "fill", "freeze");
\r
3077 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3078 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3079 $animate.init(ele);
\r
3080 $animate.isCSS = false;
\r
3081 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3082 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3083 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3084 p.dispatchEvent(evt);
\r
3085 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3087 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3088 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3089 frame.setFrame(frame.currentFrame);
\r
3090 expect($animate.isEnd).toBeFalsy();
\r
3091 p.dispatchEvent(evt);
\r
3092 frame.setFrame(frame.currentFrame + 1);
\r
3093 frame.setFrame(frame.currentFrame + 24);
\r
3094 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3097 describe("a beginElement method and an endElement method", function() {
\r
3098 var $animate, ele, frame, p;
\r
3099 beforeEach( function() {
\r
3100 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3101 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3102 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3103 p.appendChild(ele);
\r
3104 frame = base("$frame");
\r
3105 frame.timelines.length = 0; //配列の初期化
\r
3106 frame.setFrame(0);
\r
3107 ele.setAttributeNS(null, "begin", "indefinite");
\r
3108 ele.setAttributeNS(null, "dur", "1s");
\r
3109 ele.setAttributeNS(null, "dur", "1s");
\r
3110 ele.setAttributeNS(null, "attributeName", "fill");
\r
3111 ele.setAttributeNS(null, "fill", "freeze");
\r
3112 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3113 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3114 $animate.init(ele);
\r
3116 /*境界条件を調べておく (limit value analysis)*/
\r
3117 it("should be this for the value (limit value analysis)", function() {
\r
3118 expect(ele.beginElement()).toBeUndefined();
\r
3119 var cur = frame.currentFrame,
\r
3120 begin = frame.$begin.$1;
\r
3121 expect(begin.string).toBe("indefinite");
\r
3122 expect(begin.begin).toBe(cur);
\r
3123 expect(ele.endElement()).toBeUndefined();
\r
3125 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3126 it("should be this for the value (the valid partion )", function() {
\r
3127 ele.addEventListener("beginEvent", function(evt){
\r
3128 expect(evt.target.nodeName).toBe("animate");
\r
3130 ele.beginElement();
\r