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
48 expect(frame.addLine()).toBe(false);
\r
49 expect(frame.addLine({})).toBe(false);
\r
50 expect(frame.addLine({
\r
53 expect(frame.addLine({
\r
57 expect(frame.removeLine()).toBeUndefined();
\r
58 expect(frame.removeLine({})).toBeUndefined();
\r
61 expect(frame.currentFrame).toBe(0);
\r
63 expect(frame.currentFrame).toBe(1);
\r
65 expect(frame.isPaused).toBeFalsy();
\r
66 expect(frame.pauseAnimation()).toBeUndefined();
\r
67 expect(frame.isPaused).toBeTruthy();
\r
70 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
71 it("should be this for the value (the valid partion)", function() {
\r
73 expect(frame.currentFrame).toBe(0);
\r
74 frame.startTime = Date.now();
\r
75 for (var i=0;i<100000;i++) {
\r
79 expect(frame.begin).toBe(0);
\r
80 expect(frame.activeTime).toBe(Number.MAX_VALUE);
\r
86 expect(frame.addLine( {
\r
90 expect(frame.addLine( {
\r
94 expect(frame.addLine( {
\r
98 expect(frame.addLine( {
\r
103 expect(frame.timelines.length).toBe(1);
\r
104 var timeline = frame.timelines[0];
\r
105 expect(timeline.begin).toBe(0);
\r
106 expect(timeline.activeTime).toBe(0);
\r
108 expect(frame.timelines[0]).toBe(timeline);
\r
109 frame.addLine({begin:1, activeTime:1});
\r
110 expect(frame.timelines[1]).not.toBe(timeline);
\r
111 frame.addLine(timeline);
\r
112 expect(frame.timelines[0]).not.toBe(timeline);
\r
113 expect(frame.timelines[1]).toBe(timeline);
\r
115 timeline = frame.timelines[0];
\r
116 frame.removeLine({});
\r
117 expect(frame.timelines[0]).toBe(timeline);
\r
118 frame.removeLine(timeline);
\r
119 expect(frame.timelines[0]).not.toBe(timeline);
\r
121 frame.addLine(frame.up().mix( {
\r
124 expect(frame.timelines).not.toBe(frame.$1.timelines);
\r
126 frame.timelines.length = 0;
\r
139 expect(frame.timelines[2].activeTime).toBe(2);
\r
141 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
142 it("should be this for the value (the invalid partion)", function() {
\r
143 expect(frame.addLine(12)).toBeFalsy();
\r
144 /*循環参照にならず、スタック領域不足にならない*/
\r
145 frame.addLine(frame);
\r
149 describe("the $frame.$list object", function() {
\r
150 var frame = base("$frame").$list.up("$2");
\r
151 beforeEach( function() {
\r
152 frame.timelines = [];
\r
153 frame.isPaused = false;
\r
154 frame.state = frame.WAITING;
\r
157 afterEach( function() {
\r
158 frame.timelines = [];
\r
160 /*境界条件を調べておく (limit value analysis)*/
\r
161 it("should be this for the value (limit value analysis)", function() {
\r
163 expect(frame.WAITING).toBe(0);
\r
164 expect(frame.BEGINNING).toBe(1);
\r
165 expect(frame.PLAYING).toBe(2);
\r
166 expect(frame.ENDING).toBe(3);
\r
167 expect(frame.POSTWAITING).toBe(4);
\r
168 expect(frame.state).toBe(frame.WAITING);
\r
170 expect(frame.beginList).toEqual({
\r
172 value: Number.MAX_VALUE
\r
174 expect(frame.endList).toEqual({
\r
176 value: Number.MAX_VALUE
\r
179 expect(typeof frame.getMaxList).toBe("function");
\r
181 expect(typeof frame.updateState).toBe("function");
\r
182 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
183 expect(frame.state).toBe(frame.WAITING);
\r
184 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
185 expect(frame.state).toBe(frame.WAITING);
\r
186 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
187 expect(frame.state).toBe(frame.WAITING);
\r
188 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
189 expect(frame.state).toBe(frame.WAITING);
\r
192 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
193 expect(frame.state).toBe(frame.BEGINNING);
\r
194 expect(frame.updateState().state).toBe(frame.BEGINNING);
\r
195 expect(frame.state).toBe(frame.BEGINNING);
\r
197 expect(frame.beginList).toEqual({
\r
199 value: Number.MAX_VALUE
\r
201 expect(frame.endList).toEqual({
\r
203 value: Number.MAX_VALUE
\r
206 expect(frame.getMaxList(0, frame.beginList)).toBe(-1);
\r
207 expect(frame.getMaxList(0, frame.endList)).toBe(-1);
\r
209 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
210 it("should be this for the value (the valid partion)", function() {
\r
212 function appendBegin(num) {
\r
213 frame.state = frame.WAITING;
\r
214 frame.beginList = {
\r
216 next: frame.beginList
\r
220 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
221 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
222 expect(frame.begin).toBe(0);
\r
223 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
224 expect(frame.state).toBe(frame.PLAYING);
\r
225 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
226 expect(frame.state).toBe(frame.PLAYING);
\r
228 frame.state = frame.WAITING;
\r
229 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
230 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
231 expect(frame.state).toBe(frame.BEGINNING);
\r
232 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
233 expect(frame.state).toBe(frame.PLAYING);
\r
234 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
235 expect(frame.state).toBe(frame.PLAYING);
\r
236 expect(frame.updateState(3).state).toBe(frame.PLAYING);
\r
237 expect(frame.state).toBe(frame.PLAYING);
\r
238 expect(frame.updateState(4).state).toBe(frame.PLAYING);
\r
239 expect(frame.state).toBe(frame.PLAYING);
\r
242 expect(frame.getMaxList(1, frame.beginList)).toBe(1);
\r
243 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
244 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
245 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
246 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
247 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
248 expect(frame.state).toBe(frame.BEGINNING);
\r
249 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
250 expect(frame.state).toBe(frame.PLAYING);
\r
251 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
252 expect(frame.state).toBe(frame.PLAYING);
\r
253 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
256 frame.state = frame.WAITING;
\r
257 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
258 expect(frame.begin).toBe(0);
\r
259 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
260 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
261 expect(frame.begin).toBe(0);
\r
262 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
263 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
264 expect(frame.begin).toBe(1);
\r
265 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
266 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
268 function appendEnd(num) {
\r
269 frame.state = frame.WAITING;
\r
273 next: frame.endList
\r
277 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
278 expect(frame.state).toBe(frame.BEGINNING);
\r
279 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
280 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
281 expect(frame.state).toBe(frame.PLAYING);
\r
282 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
283 expect(frame.state).toBe(frame.ENDING);
\r
284 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
285 expect(frame.state).toBe(frame.POSTWAITING);
\r
288 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
289 expect(frame.state).toBe(frame.BEGINNING);
\r
290 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
291 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
292 expect(frame.state).toBe(frame.PLAYING);
\r
293 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
294 expect(frame.state).toBe(frame.ENDING);
\r
295 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
296 expect(frame.state).toBe(frame.POSTWAITING);
\r
297 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
298 expect(frame.state).toBe(frame.POSTWAITING);
\r
301 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
302 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
303 expect(frame.updateState(1).state).toBe(frame.POSTWAITING);
\r
305 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
306 it("should be this for the value (the invalid partion)", function() {
\r
307 expect(frame.updateState()).toBe(frame);
\r
308 expect(frame.updateState(null)).toBe(frame);
\r
310 describe("the setFrame method (override)", function() {
\r
311 var frame = base("$frame").$list.up("$3");
\r
312 beforeEach( function() {
\r
313 frame.timelines = [];
\r
314 frame.isPaused = false;
\r
315 frame.state = frame.WAITING;
\r
318 afterEach( function() {
\r
319 frame.timelines = [];
\r
320 frame.beginList = frame.$list.beginList;
\r
321 frame.endList = frame.$list.endList;
\r
322 frame.currentFrame = 0;
\r
324 /*境界条件を調べておく (limit value analysis)*/
\r
325 it("should be this for the value (limit value analysis)", function() {
\r
326 expect(typeof frame.setFrame).toBe("function");
\r
327 expect(frame.currentFrame).toBe(0);
\r
330 expect(frame.state).toBe(frame.WAITING);
\r
331 expect(frame.currentFrame).toBe(0);
\r
333 expect(frame.state).toBe(frame.WAITING);
\r
334 expect(frame.currentFrame).toBe(1);
\r
336 expect(typeof frame.addEvent).toBe("function");
\r
337 expect(typeof frame.addBeginList).toBe("function");
\r
338 expect(typeof frame.addEndList).toBe("function");
\r
340 expect(frame.addBeginList(1).value).toBe(1);
\r
341 expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);
\r
342 expect(frame.addEndList(1).value).toBe(1);
\r
343 expect(frame.endList.next.value).toBe(Number.MAX_VALUE);
\r
348 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
349 it("should be this for the value (the valid partion)", function() {
\r
350 function appendBegin(num) {
\r
351 frame.state = frame.WAITING;
\r
352 frame.addBeginList(num);
\r
355 expect(frame.currentFrame).toBe(0);
\r
357 expect(frame.currentFrame).toBe(0);
\r
358 expect(frame.state).toBe(frame.PLAYING);
\r
360 expect(frame.currentFrame).toBe(1);
\r
361 expect(frame.state).toBe(frame.PLAYING);
\r
366 expect(frame.state).toBe(frame.PLAYING);
\r
368 expect(frame.state).toBe(frame.PLAYING);
\r
370 expect(frame.state).toBe(frame.PLAYING);
\r
372 function appendEnd(num) {
\r
373 frame.state = frame.WAITING;
\r
375 frame.addEndList(num);
\r
380 expect(frame.state).toBe(frame.PLAYING);
\r
382 expect(frame.state).toBe(frame.PLAYING);
\r
384 expect(frame.state).toBe(frame.PLAYING);
\r
386 expect(frame.state).toBe(frame.POSTWAITING);
\r
388 expect(frame.state).toBe(frame.POSTWAITING);
\r
392 expect(frame.state).toBe(frame.PLAYING);
\r
394 expect(frame.state).toBe(frame.PLAYING);
\r
396 expect(frame.state).toBe(frame.PLAYING);
\r
398 expect(frame.state).toBe(frame.POSTWAITING);
\r
400 expect(frame.state).toBe(frame.POSTWAITING);
\r
402 expect(frame.state).toBe(frame.PLAYING);
\r
404 expect(frame.state).toBe(frame.PLAYING);
\r
408 expect(frame.state).toBe(frame.PLAYING);
\r
409 expect(frame.currentFrame).toBe(0);
\r
411 expect(frame.state).toBe(frame.PLAYING);
\r
412 expect(frame.currentFrame).toBe(1);
\r
414 expect(frame.state).toBe(frame.PLAYING);
\r
415 expect(frame.currentFrame).toBe(2);
\r
417 expect(frame.state).toBe(frame.POSTWAITING);
\r
419 expect(frame.state).toBe(frame.POSTWAITING);
\r
421 expect(frame.state).toBe(frame.PLAYING);
\r
423 expect(frame.state).toBe(frame.POSTWAITING);
\r
424 expect(frame.currentFrame).toBe(6);
\r
427 for (var i=0;i<10000;++i) {
\r
431 frame.beginList = base("$frame").$listbeginList;
\r
432 frame.endList = base("$frame").$list.endList;
\r
433 frame.state = frame.WAITING;
\r
435 var obj = { name: "", value: 0};
\r
436 frame.addEvent("begin", function(evt) { obj.name = "a";});
\r
437 frame.beginList = {
\r
439 next: frame.beginList
\r
442 expect(frame.currentFrame).toBe(0);
\r
443 expect(frame.state).toBe(frame.PLAYING);
\r
444 expect(obj.name).toBe("a");
\r
445 frame.addEvent("play", function(evt) { obj.name = "b";});
\r
447 expect(frame.state).toBe(frame.PLAYING);
\r
448 expect(obj.name).toBe("b");
\r
449 frame.addEvent("end", function(evt) { obj.value = 1;});
\r
452 next: frame.endList
\r
455 expect(frame.currentFrame).toBe(0);
\r
456 expect(frame.state).toBe(frame.POSTWAITING);
\r
457 expect(obj.value).toBe(1);
\r
459 frame.addEvent("begin", function(evt) {
\r
460 expect(evt.state).toBe(frame.BEGINNING);
\r
463 frame.addEvent("end", function(evt) {
\r
464 expect(evt.state).toBe(frame.ENDING);
\r
467 frame.addEvent("play", function(evt) {
\r
468 expect(evt.state).toBe(frame.PLAYING);
\r
476 frame.state = frame.WAITING;
\r
477 expect(frame.getMaxList(12, frame.endList)).toBe(0);
\r
478 frame.setFrame(12);
\r
479 expect(frame.state).toBe(frame.POSTWAITING);
\r
482 /*addBeginListメソッドのチェックなど*/
\r
483 expect(frame.addBeginList(1).value).toBe(1);
\r
484 expect(frame.addBeginList(0).value).toBe(0);
\r
485 expect(frame.beginList.next.value).toBe(1);
\r
486 expect(frame.addBeginList(2).value).toBe(2);
\r
487 expect(frame.beginList.next.value).toBe(0);
\r
489 expect(frame.addEndList(1).value).toBe(1);
\r
490 expect(frame.addEndList(0).value).toBe(0);
\r
491 expect(frame.endList.next.value).toBe(1);
\r
492 expect(frame.addEndList(2).value).toBe(2);
\r
493 expect(frame.endList.next.value).toBe(0);
\r
497 describe("$begin object", function() {
\r
498 var begin = base("$frame").$begin.up();
\r
499 /*境界条件を調べておく (limit value analysis)*/
\r
500 it("should be this for the value (limit value analysis)", function() {
\r
501 expect(begin.string).toBe("");
\r
502 expect(begin.isResolved).toBeFalsy();
\r
503 expect(begin.eventTarget).toBe(document.documentElement);
\r
504 expect(begin.eventOffset).toBe(0);
\r
505 expect(begin.repeat).toBe(0);
\r
506 expect(begin.accessKey).toBe("");
\r
508 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
509 it("should be this for the value (the valid partion)", function() {
\r
510 begin.string = " hoge ";
\r
511 expect(begin.string).toBe(" hoge ");
\r
512 var $list = begin.$list;
\r
513 expect(begin.$list).toBe($list);
\r
514 expect(begin.updateList().$list).not.toBe($list);
\r
516 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
517 it("should be this for the value (the invalid partion)", function() {
\r
520 describe("A trim method in $begin object", function() {
\r
521 /*境界条件を調べておく (limit value analysis)*/
\r
522 beforeEach( function() {
\r
525 it("should be this for the value (limit value analysis)", function() {
\r
526 delete begin.string;
\r
527 expect(begin.trim(" ")).toBe("");
\r
528 expect( function() {
\r
532 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
533 it("should be this for the value (the valid partion)", function() {
\r
534 expect(begin.trim(" hoge ")).toBe("hoge");
\r
535 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
536 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
537 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
539 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
540 it("should be this for the value (the invalid partion)", function() {
\r
541 expect( function() {
\r
544 expect( function() {
\r
550 describe("An offset method in $begin object", function() {
\r
551 beforeEach( function() {
\r
554 /*境界条件を調べておく (limit value analysis)*/
\r
555 it("should be this for the value (limit value analysis)", function() {
\r
556 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
557 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
558 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
559 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
560 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
561 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
563 expect(begin.offset("+0s")).toBe(0);
\r
564 expect(begin.offset("-0s")).toBe(0);
\r
565 expect(begin.offset("1s")).toBe(1000);
\r
566 expect(begin.offset("-1s")).toBe(-1000);
\r
568 expect(begin.offset("+0min")).toBe(0);
\r
569 expect(begin.offset("-0min")).toBe(0);
\r
570 expect(begin.offset("1min")).toBe(60000);
\r
571 expect(begin.offset("-1min")).toBe(-60000);
\r
573 expect(begin.offset("+0h")).toBe(0);
\r
574 expect(begin.offset("-0h")).toBe(0);
\r
575 expect(begin.offset("1h")).toBe(60*60*1000);
\r
576 expect(begin.offset("-1h")).toBe(-3600000);
\r
578 expect(begin.offset("00:0")).toBe(0);
\r
579 expect(begin.offset("00:00:0.0")).toBe(0);
\r
580 expect(begin.offset("-00:0")).toBe(0);
\r
581 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
582 expect(begin.offset("00:1")).toBe(1000);
\r
583 expect(begin.offset("-00:1")).toBe(-1000);
\r
584 expect(begin.offset("00:00:1")).toBe(1000);
\r
585 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
587 expect(begin.offset()).toBe(0);
\r
589 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
590 it("should be this for the value (the valid partion)", function() {
\r
591 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
592 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
593 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
594 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
596 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
597 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
598 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
599 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
600 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
602 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
603 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
604 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
605 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
606 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
608 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
609 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
610 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
611 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
612 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
614 expect(begin.offset("01:0")).toBe(60000);
\r
615 expect(begin.offset("-01:0")).toBe(-60000);
\r
616 expect(begin.offset("00:00:1")).toBe(1000);
\r
617 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
618 expect(begin.offset("00:01:0")).toBe(60000);
\r
619 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
620 expect(begin.offset("01:00:0")).toBe(3600000);
\r
621 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
622 expect(begin.offset("00:10")).toBe(10000);
\r
623 expect(begin.offset("00:0.01")).toBe(10);
\r
624 expect(begin.offset("01:0.01")).toBe(60010);
\r
625 expect(begin.offset("10:0")).toBe(600000);
\r
626 expect(begin.offset("-00:10")).toBe(-10000);
\r
627 expect(begin.offset("-00:0.01")).toBe(-10);
\r
628 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
629 expect(begin.offset("-10:0")).toBe(-600000);
\r
630 expect(begin.offset("00:00:20")).toBe(20000);
\r
631 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
632 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
633 expect(begin.offset("-10:0")).toBe(-600000);
\r
634 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
636 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
637 it("should be this for the value (the invalid partion)", function() {
\r
638 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
639 expect(begin.offset("ms")).toBe(0);
\r
640 expect(begin.offset(".s")).toBe(0);
\r
641 expect(begin.offset("10:")).toBe(0);
\r
642 expect(begin.offset("::")).toBe(0);
\r
643 expect(begin.offset("-:0")).toBe(0);
\r
644 expect(begin.offset("-::0")).toBe(0);
\r
647 describe("An event method in $begin object", function() {
\r
648 /*境界条件を調べておく (limit value analysis)*/
\r
649 it("should be this for the value (limit value analysis)", function() {
\r
650 var evt = begin.event();
\r
651 expect(evt.id).toBe("");
\r
652 expect(evt.event).toBe("");
\r
653 evt = begin.event("");
\r
654 expect(evt.id).toBe("");
\r
655 expect(evt.event).toBe("");
\r
656 evt = begin.event(".");
\r
657 expect(evt.id).toBe("");
\r
658 expect(evt.event).toBe("");
\r
660 evt = begin.event("a");
\r
661 expect(evt.id).toBe("");
\r
662 expect(evt.event).toBe("a");
\r
663 evt = begin.event("a.b");
\r
664 expect(evt.id).toBe("a");
\r
665 expect(evt.event).toBe("b");
\r
667 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
668 it("should be this for the value (the valid partion)", function() {
\r
669 var evt = begin.event("id.event");
\r
670 expect(evt.id).toBe("id");
\r
671 expect(evt.event).toBe("event");
\r
672 evt = begin.event("event");
\r
673 expect(evt.id).toBe("");
\r
674 expect(evt.event).toBe("event");
\r
676 evt = begin.event("event+0s");
\r
677 expect(evt.id).toBe("");
\r
678 expect(evt.event).toBe("event");
\r
679 evt = begin.event("event-0s");
\r
680 expect(evt.id).toBe("");
\r
681 expect(evt.event).toBe("event");
\r
683 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
684 it("should be this for the value (the invalid partion)", function() {
\r
685 evt = begin.event("...");
\r
686 expect(evt.id).toBe("");
\r
687 expect(evt.event).toBe("");
\r
688 evt = begin.event(".event");
\r
689 expect(evt.id).toBe("");
\r
690 expect(evt.event).toBe("");
\r
691 evt = begin.event("id.");
\r
692 expect(evt.id).toBe("");
\r
693 expect(evt.event).toBe("");
\r
697 describe("An parse method in $begin object", function() {
\r
698 beforeEach( function() {
\r
701 /*境界条件を調べておく (limit value analysis)*/
\r
702 it("should be this for the value (limit value analysis)", function() {
\r
703 expect(begin.parse().begin).toBe(0);
\r
704 expect(begin.isResolved).toBeTruthy();
\r
706 expect(begin.parse().begin).toBe(0);
\r
707 begin.string = "+1";
\r
708 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
709 begin.string = " ";
\r
710 expect(begin.parse().begin).toBe(0);
\r
711 begin.string = "1";
\r
712 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
713 begin.string = "+0ms";
\r
714 expect(begin.parse().begin).toBe(0);
\r
715 begin.string = "-0ms";
\r
716 expect(begin.parse().begin).toBe(0);
\r
717 begin.string = "-0ms;-0ms";
\r
718 expect(begin.parse().begin).toBe(0);
\r
719 begin.string = "-0ms;1";
\r
720 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
722 expect(begin.eventOffset).toBe(0);
\r
723 begin.string = "click";
\r
724 expect(begin.parse().begin).toBe(0);
\r
725 expect(begin.eventOffset).toBe(0);
\r
726 expect(begin.repeat).toBe(0);
\r
727 expect(begin.accessKey).toBe("");
\r
728 begin.string = "id.click";
\r
729 expect(begin.parse().begin).toBe(0);
\r
730 expect(begin.eventOffset).toBe(0);
\r
731 expect(begin.repeat).toBe(0);
\r
732 expect(begin.accessKey).toBe("");
\r
734 begin.string = "repeat";
\r
735 expect(begin.parse().begin).toBe(0);
\r
736 expect(begin.eventOffset).toBe(0);
\r
737 expect(begin.repeat).toBe(0);
\r
738 expect(begin.accessKey).toBe("");
\r
739 begin.string = "repeat(1)";
\r
740 expect(begin.parse().begin).toBe(0);
\r
741 expect(begin.eventOffset).toBe(0);
\r
742 expect(begin.repeat).toBe(1);
\r
743 expect(begin.accessKey).toBe("");
\r
745 begin.string = "accessKey(a)";
\r
746 expect(begin.parse().begin).toBe(0);
\r
747 expect(begin.eventOffset).toBe(0);
\r
748 expect(begin.repeat).toBe(0);
\r
749 expect(begin.accessKey).toBe("a");
\r
751 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
752 it("should be this for the value (the valid partion)", function() {
\r
753 begin.string = " 1 0 0 m s";
\r
754 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
756 begin.string = "1ms";
\r
757 begin.isResolved = false;
\r
758 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
759 expect(begin.isResolved).toBeTruthy();
\r
760 expect(begin.eventOffset).toBe(0);
\r
762 begin.string="click+0";
\r
763 expect(begin.parse().begin).toBe(0);
\r
764 expect(begin.eventOffset).toBe(0);
\r
765 expect(begin.isResolved).toBeFalsy();
\r
766 begin.string = "click+1";
\r
767 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
768 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
769 begin.string = " click ";
\r
770 expect(begin.parse().begin).toBe(0);
\r
771 expect(begin.eventOffset).toBe(0);
\r
772 begin.string = "click+0ms";
\r
773 expect(begin.parse().begin).toBe(0);
\r
774 expect(begin.eventOffset).toBe(0);
\r
775 expect(begin.isResolved).toBeFalsy();
\r
776 begin.string = "click-0ms";
\r
777 expect(begin.parse().begin).toBe(0);
\r
778 expect(begin.eventOffset).toBe(0);
\r
779 begin.string = "click+100ms";
\r
780 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
781 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
782 begin.string = "click-100ms";
\r
783 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
784 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
786 begin.string="id.click+0";
\r
787 expect(begin.parse().begin).toBe(0);
\r
788 expect(begin.eventOffset).toBe(0);
\r
789 expect(begin.isResolved).toBeFalsy();
\r
790 begin.string = "id.click+1";
\r
791 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
792 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
793 expect(begin.isResolved).toBeFalsy();
\r
794 begin.string = " id . click ";
\r
795 expect(begin.parse().begin).toBe(0);
\r
796 expect(begin.eventOffset).toBe(0);
\r
797 expect(begin.isResolved).toBeFalsy();
\r
798 begin.string = "id.click+0ms";
\r
799 expect(begin.parse().begin).toBe(0);
\r
800 expect(begin.eventOffset).toBe(0);
\r
801 begin.string = "id.click-0ms";
\r
802 expect(begin.parse().begin).toBe(0);
\r
803 expect(begin.eventOffset).toBe(0);
\r
804 begin.string = "id.click+100ms";
\r
805 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
806 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
807 begin.string = "id.click-100ms";
\r
808 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
809 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
811 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
812 it("should be this for the value (the invalid partion)", function() {
\r
813 begin.string = "ms";
\r
814 begin.isResolved = false;
\r
815 expect(begin.parse().begin).toBe(0);
\r
816 expect(begin.isResolved).toBeFalsy();
\r
818 begin.isResolved = true;
\r
819 begin.string = "indefinite";
\r
820 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
821 expect(begin.isResolved).toBeFalsy();
\r
825 describe("A $end object", function() {
\r
826 var end = base("$frame").$begin.$end.up();
\r
828 beforeEach( function() {
\r
830 end.startTime = Date.now();
\r
833 /*境界条件を調べておく (limit value analysis)*/
\r
834 it("should be this for the value (limit value analysis)", function() {
\r
835 expect(end.up().call()).toBeNull();
\r
837 expect(end.up().call()).toBe(0);
\r
838 end.string = "hoge";
\r
839 expect(end.up().call()).toBe("indefinite");
\r
842 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
843 it("should be this for the value (the valid partion)", function() {
\r
844 end.string = "hoge+0";
\r
845 expect(end.up().call()).toBe("indefinite");
\r
846 end.string = "12ms";
\r
847 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
848 end.string = "hoge+12ms";
\r
849 expect(end.up().call()).toBe("indefinite");
\r
852 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
853 it("should be this for the value (the invalid partion)", function() {
\r
855 expect(end.up().call()).toBeNull();
\r
858 describe("A $activate object", function() {
\r
859 var act = base("$frame").$begin.$activate.up();
\r
860 beforeEach( function() {
\r
861 act.dur = "indefinite";
\r
863 act.repeatCount = null;
\r
864 act.repeatDur = null;
\r
865 act.end = act.$begin.$end;
\r
866 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
868 /*境界条件を調べておく (limit value analysis)*/
\r
869 it("should be this for the value (limit value analysis)", function() {
\r
870 expect(act.dur).toBe("indefinite");
\r
871 expect(typeof act.resolvedTime).toBe("function");
\r
872 expect(act.end).toBe(act.$begin.$end);
\r
873 expect(act.repeatCount).toBeNull();
\r
874 expect(act.repeatDur).toBeNull();
\r
875 expect(act.simpleDur()).toBeNull();
\r
876 expect(act.min).toBe("0");
\r
877 expect(act.max).toBe("indefinite");
\r
880 expect(act.$a.call()).toBeNull();
\r
881 expect(act.$a.end).toBeNull();
\r
883 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
884 it("should be this for the value (the valid partion)", function() {
\r
885 expect(act.resolvedTime()).not.toBe(0);
\r
887 /*Activate Duration = dur*/
\r
889 act.$b.dur = "132ms";
\r
890 var abc = act.$b.call();
\r
891 expect(abc).toBe(Math.floor(132*act.fpms));
\r
892 expect(abc).toBe(act.$b.simpleDur);
\r
894 expect(act.up().call()).toBeNull();
\r
899 simpleDur: act.simpleDur,
903 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
904 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
907 simpleDur: act.simpleDur,
911 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
913 /*AD = repeatCount*dur*/
\r
916 simpleDur: act.simpleDur,
921 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
924 simpleDur: act.simpleDur,
928 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
929 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
934 simpleDur: act.simpleDur,
939 expect(act.$c.simpleDur).toBeNull();
\r
942 simpleDur: act.simpleDur,
946 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
947 expect(act.$c.simpleDur).toBeNull();
\r
950 simpleDur: act.simpleDur,
955 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
958 simpleDur: act.simpleDur,
962 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
963 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
965 /*AD = Min(repeatCount*d, repeatDur)*/
\r
968 simpleDur: act.simpleDur,
973 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
976 simpleDur: act.simpleDur,
980 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
981 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
984 simpleDur: act.simpleDur,
988 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
989 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
991 /*AD = repeatDur,*/
\r
995 simpleDur: act.simpleDur,
999 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
1000 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1002 dur: "indefinite",
\r
1003 simpleDur: act.simpleDur,
1007 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1008 expect(act.$c.simpleDur).toBeNull();
\r
1010 act.end.string = null;
\r
1011 act.up("$cd").mix( {
\r
1016 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
1018 act.$cd.end = act.end;
\r
1019 act.$cd.repeatCount = null;
\r
1020 act.$cd.repeatDur = "12";
\r
1021 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
1023 act.up("$d").mix( {
\r
1027 simpleDur: act.simpleDur
\r
1029 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1030 act.up("$d").mix( {
\r
1034 simpleDur: act.simpleDur
\r
1036 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1038 /*endで0が指定されている場合*/
\r
1041 act.repeatDur = null;
\r
1042 act.repeatCount = "indefinite";
\r
1044 expect(act.call()).toBeNull();
\r
1045 act.repeatCount = null;
\r
1046 act.repeatDur = "indefinite";
\r
1048 expect(act.call()).toBeNull();
\r
1049 act.repeatDur = "indefinite";
\r
1050 act.repeatCount = "indefinite";
\r
1052 expect(act.call()).toBeNull();
\r
1054 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1055 it("should be this for the value (the invalid partion)", function() {
\r
1057 act.up("$d").mix( {
\r
1061 simpleDur: act.simpleDur
\r
1063 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
1065 act.repeatDur = null;
\r
1066 act.repeatCount = "indefinite";
\r
1068 expect(act.call()).toBeNull();
\r
1069 act.repeatCount = null;
\r
1070 act.repeatDur = "indefinite";
\r
1072 expect(act.call()).toBeNull();
\r
1073 act.repeatDur = "indefinite";
\r
1074 act.repeatCount = "indefinite";
\r
1076 expect(act.call()).toBeNull();
\r
1079 describe("A $from object", function() {
\r
1080 var from = base("$from");
\r
1081 beforeEach( function() {
\r
1082 from = base("$from").up();
\r
1083 from.from = from.from.up();
\r
1086 /*境界条件を調べておく (limit value analysis)*/
\r
1087 it("should be this for the value (limit value analysis)", function() {
\r
1088 expect(from.string).toBe("");
\r
1089 expect(from.numList()).toEqual([]);
\r
1090 expect(from.strList()).toBeNull();
\r
1092 from.string = "0";
\r
1093 expect(from.numList()[0]).toBe(0);
\r
1094 expect(from.strList()).toBeNull();
\r
1096 from.string = " 0 ";
\r
1097 expect(from.numList()[0]).toBe(0);
\r
1098 expect(from.strList().join("")).toBe(" ");
\r
1100 from.string = "a";
\r
1101 expect(from.numList()).toEqual([]);
\r
1102 expect(from.strList()[0]).toBe("a");
\r
1104 /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから
\r
1105 * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/
\r
1107 from.string = null;
\r
1108 expect( function() {
\r
1111 expect( function() {
\r
1115 expect(from.additive[0]).toBe(0);
\r
1116 expect(from.accumulate[0]).toBe(0);
\r
1118 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1119 it("should be this for the value (the valid partion)", function() {
\r
1120 from.string = "0a";
\r
1121 expect(from.numList()[0]).toBe(0);
\r
1122 expect(from.strList()[0]).toBe("a");
\r
1124 from.string = "a0";
\r
1125 expect(from.numList()[0]).toBe(0);
\r
1126 expect(from.strList()[0]).toBe("a");
\r
1128 from.string = "0.1";
\r
1129 expect(from.numList()[0]).toBe(0.1);
\r
1130 expect(from.strList()).toBeNull();
\r
1132 from.string = "+0.1";
\r
1133 expect(from.numList()[0]).toBe(0.1);
\r
1134 expect(from.strList()).toBeNull();
\r
1136 from.string = "-0.1";
\r
1137 expect(from.numList()[0]).toBe(-0.1);
\r
1138 expect(from.strList()).toBeNull();
\r
1140 from.string = "1e-1";
\r
1141 expect(from.numList()[0]).toBe(1e-1);
\r
1142 expect(from.strList()).toBeNull();
\r
1144 from.string = "1E-1";
\r
1145 expect(from.numList()[0]).toBe(1E-1);
\r
1146 expect(from.strList()).toBeNull();
\r
1148 from.string = "0,0";
\r
1149 expect(from.numList().toString()).toBe("0,0");
\r
1150 expect(from.strList().join("")).toBe(",");
\r
1152 from.string = "a00a";
\r
1153 expect(from.numList()[0]).toBe(0);
\r
1154 expect(from.strList().join("")).toBe("aa");
\r
1156 from.string = "a0b0a";
\r
1157 expect(from.numList().toString()).toBe("0,0");
\r
1158 expect(from.strList().join("")).toBe("aba");
\r
1160 from.string = "0b0a";
\r
1161 expect(from.numList().toString()).toBe("0,0");
\r
1162 expect(from.strList().join("")).toBe("ba");
\r
1164 from.string = "0b-1.0a";
\r
1165 expect(from.numList()[1]).toBe(-1);
\r
1166 expect(from.strList().join("")).toBe("ba");
\r
1168 expect(from.up().call()).toBe(from.$1.numList);
\r
1169 expect(from.$1.numList[1]).toBe(-1);
\r
1170 expect(from.$1.strList.join("")).toBe("ba");
\r
1172 from.string = "あ 0b-1.0a12";
\r
1173 expect(from.numList()[1]).toBe(-1);
\r
1174 expect(from.strList().join("")).toBe("あ ba12");
\r
1176 from.string = "0b-1.0a0";
\r
1177 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1178 expect(from.strList().join("")).toBe("ba");
\r
1180 from.string = "0b .1a";
\r
1181 expect(from.numList()[1]).toBe(0.1);
\r
1182 expect(from.strList().join("")).toBe("b a");
\r
1184 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1185 it("should be this for the value (the invalid partion)", function() {
\r
1186 from.string = NaN;
\r
1187 expect(function(){
\r
1190 expect(function(){
\r
1194 from.string = "currentColor";
\r
1195 expect(from.numList()).toEqual([]);
\r
1196 expect(from.strList()[0]).toBe("currentColor");
\r
1198 from.string = "eE";
\r
1199 expect(from.numList()).toEqual([]);
\r
1200 expect(from.strList()[0]).toBe("eE");
\r
1201 expect(from.strList()[0]).toBe("eE");
\r
1204 describe("A $to object", function() {
\r
1205 var from = base("$from");
\r
1206 beforeEach( function() {
\r
1207 from = base("$from").up();
\r
1211 /*境界条件を調べておく (limit value analysis)*/
\r
1212 it("should be this for the value (limit value analysis)", function() {
\r
1213 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1214 expect(from.up().call()).toBe(from.$1.numList);
\r
1215 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1217 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1218 it("should be this for the value (the valid partion)", function() {
\r
1220 from.$to.from = from;
\r
1221 from.$to.string = "12cm-7";
\r
1222 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1223 expect(from.$to.strList().toString()).toBe("cm");
\r
1225 from.string = "7cm+8";
\r
1227 expect(from.call()).toBe(from.numList);
\r
1228 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1229 expect(from.$to.strList.join("")).toBe("cm");
\r
1230 expect(from.numList.join(",")).toBe("7,8");
\r
1231 expect(from.strList.join("")).toBe("cm");
\r
1232 expect(from.$to.from).toBe(from.numList);
\r
1235 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1236 it("should be this for the value (the invalid partion)", function() {
\r
1238 from.up("$to").mix( function() {
\r
1239 this.string = "12cm";
\r
1242 arr.string = this.string;
\r
1243 expect(this.numList).toEqual(arr);
\r
1244 expect(this.strList).toBeNull();
\r
1248 describe("An advance method", function() {
\r
1249 var from = base("$from");
\r
1250 beforeEach( function() {
\r
1251 from = base("$from").up();
\r
1254 from.$to.from = from;
\r
1256 /*境界条件を調べておく (limit value analysis)*/
\r
1257 it("should be this for the value (limit value analysis)", function() {
\r
1258 expect(from.advance()).toBe("");
\r
1259 expect(from.$to.advance()).toBe("");
\r
1260 expect(from.$to.advance(0)).toBe("");
\r
1261 expect(from.$to.advance(1)).toBe("");
\r
1262 expect(function(){
\r
1263 from.$to.advance(1.01);
\r
1264 }).toThrow("An Invalid Number Error");
\r
1265 expect(function(){
\r
1266 from.$to.advance(-0.01);
\r
1267 }).toThrow("An Invalid Number Error");
\r
1271 from = base("$from").up();
\r
1273 from.$to.from = from;
\r
1274 arr.string = from.string = "0";
\r
1275 from.$to.string = "1";
\r
1276 expect(from.$to.call()).toBe(from.$to.numList);
\r
1277 expect(from.$to.numList[0]).toBe(1);
\r
1278 expect(from.$to.strList).toBeNull();
\r
1279 expect(from.numList[0]).toBe(0);
\r
1280 expect(from.strList).toBeNull();
\r
1281 expect(from.advance(0)).toBe("");
\r
1282 expect(from.$to.from).toBe(from.numList);
\r
1283 expect(from.$to.advance(0)).toBe("0");
\r
1284 expect(from.call()).toBe(from.numList);
\r
1286 from = base("$from").up();
\r
1287 f(from.up(), "inline", "block");
\r
1288 f(from.up(), " inline", " block ");
\r
1289 function f(from, inline, block) {
\r
1291 from.$to.from = from;
\r
1292 from.string = inline;
\r
1293 arr.string = from.$to.string = block;
\r
1294 expect(from.$to.call()).toBe(from.$to.numList);
\r
1295 expect(from.$to.numList).toEqual(arr);
\r
1296 expect(from.$to.strList).toEqual([block]);
\r
1297 arr.string = from.string;
\r
1298 expect(from.numList).toEqual(arr);
\r
1299 expect(from.strList).toEqual([inline]);
\r
1300 expect(from.advance(0)).toBe("");
\r
1301 expect(from.$to.from).toBe(from.numList);
\r
1302 expect(from.$to.advance(0)).toBe("inline");
\r
1303 expect(from.$to.advance(1)).toBe("block");
\r
1304 expect(from.call()).toBe(from.numList);
\r
1307 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1308 it("should be this for the value (the valid partion)", function() {
\r
1311 from.string = "0s";
\r
1312 from.$to.string = "1s";
\r
1313 expect(from.$to.call()).toBe(from.$to.numList);
\r
1314 expect(from.$to.numList[0]).toBe(1);
\r
1315 expect(from.$to.strList[0]).toBe("");
\r
1316 expect(from.numList[0]).toBe(0);
\r
1317 expect(from.strList[0]).toBe("");
\r
1318 expect(from.advance(0)).toBe("");
\r
1319 expect(from.$to.from).toBe(from.numList);
\r
1320 expect(from.$to.advance(0)).toBe("0s");
\r
1321 from.$to.degit = deg;
\r
1322 for (var i=0;i<1;i+=0.01) {
\r
1323 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1325 expect(from.call()).toBe(from.numList);
\r
1327 from = base("$from").up();
\r
1329 from.string = "a0S";
\r
1330 from.$to.string = "a1S";
\r
1331 from.$to.from = from;
\r
1332 expect(from.$to.call()).toBe(from.$to.numList);
\r
1333 expect(from.$to.numList[0]).toBe(1);
\r
1334 expect(from.$to.strList[0]).toBe("a");
\r
1335 expect(from.numList[0]).toBe(0);
\r
1336 expect(from.strList[0]).toBe("a");
\r
1337 expect(from.advance(0)).toBe("");
\r
1338 expect(from.$to.from).toBe(from.numList);
\r
1339 expect(from.$to.advance(0)).toBe("a0S");
\r
1341 from.$to.degit = deg;
\r
1342 for (var i=0;i<1;i+=0.01) {
\r
1343 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1345 expect(from.call()).toBe(from.numList);
\r
1347 from = base("$from").up();
\r
1348 f(from.up(), "a-10s1.5", "a10s-3");
\r
1349 f(from.up(), " a-10s1.5", " a10s-3 ");
\r
1350 function f(from, fromString, toString) {
\r
1352 from.string = fromString;
\r
1353 from.$to.string = toString;
\r
1354 from.$to.from = from;
\r
1356 from.$to.degit = 1;
\r
1357 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1358 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1359 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1361 from.$to.additive[0] = 1;
\r
1362 from.$to.accumulate[1] = 2;
\r
1363 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1364 from.$to.additive[0] = 0.5;
\r
1365 from.$to.accumulate[1] = 0.8;
\r
1366 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1369 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1370 it("should be this for the value (the invalid partion)", function() {
\r
1371 expect(function(){
\r
1372 from.$to.advance(10);
\r
1373 }).toThrow("An Invalid Number Error");
\r
1374 expect(function(){
\r
1375 from.$to.advance(-10);
\r
1376 }).toThrow("An Invalid Number Error");
\r
1380 describe("A distance method", function() {
\r
1381 var from = base("$from");
\r
1382 beforeEach( function() {
\r
1383 from = base("$from").up();
\r
1387 /*境界条件を調べておく (limit value analysis)*/
\r
1388 it("should be this for the value (limit value analysis)", function() {
\r
1389 expect(from.distance()).toBe(0)
\r
1390 expect(from.$to.distance()).toBe(0);
\r
1392 from.string = "0";
\r
1393 from.$to.string = "1";
\r
1394 expect(from.distance()).toBe(0);
\r
1395 expect(from.$to.distance(from)).toBe(1);
\r
1397 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1398 it("should be this for the value (the valid partion)", function() {
\r
1399 from.string = "s 0 s 12";
\r
1400 from.$to.string = "s 0 s 0";
\r
1401 expect(from.distance()).toBe(0);
\r
1402 expect(from.$to.distance(from)).toBe(12);
\r
1403 expect(from.$to.distance(from)).toBe(12);
\r
1404 expect(from.$to.distance(from.call())).toBe(12);
\r
1406 from = base("$from").up();
\r
1408 from.string = "rgb(1, 0, 0)";
\r
1409 from.$to.string = "rgb(0, 0, 1)";
\r
1410 expect(from.distance()).toBe(0);
\r
1411 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1413 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1414 it("should be this for the value (the invalid partion)", function() {
\r
1415 from.string = "s";
\r
1416 from.$to.string = "s";
\r
1417 expect(from.$to.distance(from)).toBe(0);
\r
1420 describe("A setAdditive method", function() {
\r
1421 var from = base("$from");
\r
1422 beforeEach( function() {
\r
1423 from = base("$from").up();
\r
1427 /*境界条件を調べておく (limit value analysis)*/
\r
1428 it("should be this for the value (limit value analysis)", function() {
\r
1429 expect(from.setAdditive()).toBe(0);
\r
1430 expect(from.setAdditive("")).toBe(0);
\r
1431 expect(from.additive).toEqual([0]);
\r
1434 expect(from.setAdditive("1")).toEqual(arr);
\r
1435 expect(from.additive).toEqual(arr);
\r
1437 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1438 it("should be this for the value (the valid partion)", function() {
\r
1439 var arr = [1, 2, 3];
\r
1440 arr.string = "1 2, 3";
\r
1441 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1442 expect(from.additive).toEqual(arr);
\r
1444 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1445 it("should be this for the value (the invalid partion)", function() {
\r
1448 describe("A setAccumulate method", function() {
\r
1449 var from = base("$from");
\r
1450 beforeEach( function() {
\r
1451 from = base("$from").up();
\r
1452 from.string = "0 1";
\r
1456 /*境界条件を調べておく (limit value analysis)*/
\r
1457 it("should be this for the value (limit value analysis)", function() {
\r
1458 expect(from.setAccumulate()).toBe(0);
\r
1459 expect(from.setAccumulate(0)).toBe(0);
\r
1460 expect(from.accumulate).toEqual([0, 0]);
\r
1461 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1462 expect(from.accumulate).toEqual([0, 1]);
\r
1464 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1465 it("should be this for the value (the valid partion)", function() {
\r
1466 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1467 expect(from.accumulate).toEqual([0, 2]);
\r
1469 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1470 it("should be this for the value (the invalid partion)", function() {
\r
1471 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1474 describe("A $calcMode object", function() {
\r
1475 var calc = base("$calcMode"),
\r
1478 beforeEach( function() {
\r
1479 calc = base("$calcMode").up();
\r
1480 calc.to = base("$from").up().mix( {string: "1"} );
\r
1481 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1483 /*境界条件を調べておく (limit value analysis)*/
\r
1484 it("should be this for the value (limit value analysis)", function() {
\r
1485 expect(calc.mode).toBe("linear");
\r
1486 expect(calc.keyTime).toBe(1);
\r
1487 expect(calc.keySplines).toBeNull();
\r
1488 expect(calc.string).toBe("");
\r
1490 expect(calc.call()(0)).toBe("0");
\r
1491 expect(calc.keyTime).toBe(1);
\r
1492 expect(calc.call()(1)).toBe("1");
\r
1495 expect(calc.call()(1)).toBe("0");
\r
1498 calc.mode = "paced";
\r
1499 expect(calc.norm).toBe(1);
\r
1500 calc.to.from = from;
\r
1501 expect(calc.call()(0)).toBe("0");
\r
1502 expect(calc.keyTime).toBe(1);
\r
1503 calc.to.from = from;
\r
1504 expect(calc.call()(1)).toBe("1");
\r
1507 calc.to.from = from;
\r
1508 expect(calc.call()(1)).toBe("1");
\r
1511 calc.mode = "discrete";
\r
1512 calc.to.from = from;
\r
1514 expect(calc.call()(0)).toBe("0");
\r
1515 expect(calc.call()(1)).toBe("1");
\r
1517 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1518 it("should be this for the value (the valid partion)", function() {
\r
1519 calc.mode = "linear";
\r
1520 calc.keyTime = 0.5;
\r
1521 calc.to.degit = 1;
\r
1522 expect(calc.call()(0.2)).toBe("0.4");
\r
1523 expect(calc.call()(0.3)).toBe("0.6");
\r
1525 expect(calc.call()(0.2)).toBe("0.4");
\r
1527 calc = base("$calcMode").up();
\r
1528 calc.keyTime = 0.2;
\r
1529 calc.to = base("$from").up();
\r
1530 calc.to.from = base("$from").up();
\r
1531 calc.to.from.string = "0s";
\r
1532 calc.to.string = "1s";
\r
1533 calc.to.degit = 1;
\r
1534 expect(calc.call()(0.1)).toBe("0.5s");
\r
1536 calc = base("$calcMode").up();
\r
1537 calc.keyTime = 0.5;
\r
1538 calc.to = base("$from").up();
\r
1539 calc.to.from = base("$from").up();
\r
1540 calc.to.from.string = "rgb(100, 20, 32)";
\r
1541 calc.to.string = "rgb(0, 10, 50)";
\r
1542 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1545 calc.to = base("$from").up();
\r
1546 calc.to.from = base("$from").up();
\r
1547 calc.mode = "paced";
\r
1549 calc.to.from.string = "0s";
\r
1550 calc.to.string = "20s";
\r
1551 calc.to.degit = 1;
\r
1552 expect(calc.call()(0.1)).toBe("10.0s");
\r
1553 expect(calc.keyTime).toBe(0.2);
\r
1555 calc.to = base("$from").up();
\r
1556 calc.to.from = base("$from").up();
\r
1557 calc.mode = "paced";
\r
1559 calc.to.from.string = "rgb(0, 0, 20)";
\r
1560 calc.to.string = "rgb(0, 0, 0)";
\r
1561 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1562 expect(calc.keyTime).toBe(0.2);
\r
1565 calc.to = base("$from").up();
\r
1566 calc.to.from = base("$from").up();
\r
1567 calc.mode = "discrete";
\r
1568 calc.keyTime = 0.5;
\r
1569 calc.to.degit = 1;
\r
1570 calc.to.string = "1";
\r
1571 calc.to.from.string = "0.5";
\r
1572 expect(calc.call()(0.2)).toBe("0.5");
\r
1573 expect(calc.call()(0.3)).toBe("0.5");
\r
1575 expect(calc.call()(0.2)).toBe("0.5");
\r
1577 calc.to = base("$from").up();
\r
1578 calc.to.from = base("$from").up();
\r
1579 calc.mode = "discrete";
\r
1580 calc.keyTime = 0.5;
\r
1581 calc.to.degit = 1;
\r
1582 calc.to.string = "block";
\r
1583 calc.to.from.string = "inline";
\r
1584 expect(calc.call()(0.2)).toBe("inline");
\r
1585 expect(calc.call()(0.3)).toBe("inline");
\r
1587 calc.to = base("$from").up();
\r
1588 calc.to.from = base("$from").up();
\r
1589 calc.mode = "linear";
\r
1591 calc.to.degit = 1;
\r
1592 calc.to.string = "1 1";
\r
1593 calc.to.from.string = "0.0 1";
\r
1594 expect(calc.call()(0.2)).toBe("0.2 1.0");
\r
1595 expect(calc.call()(0.3)).toBe("0.3 1.0");
\r
1597 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1598 it("should be this for the value (the invalid partion)", function() {
\r
1599 calc.keyTime = null;
\r
1600 expect(calc.call()(1)).toBe(calc.string);
\r
1602 calc.keyTime = void 0;
\r
1603 expect(calc.call()(1)).toBe(calc.string);
\r
1605 calc.keyTime = 1/0;
\r
1606 expect(calc.call()(1)).toBe(calc.string);
\r
1608 expect(calc.call()()).toBe(calc.string);
\r
1610 calc = base("$calcMode").up();
\r
1611 calc.mode = "paced";
\r
1612 calc.to.from = from;
\r
1613 expect(calc.call()()).toBe(calc.string);
\r
1615 calc = base("$calcMode").up();
\r
1616 calc.mode = "discrete";
\r
1617 expect(calc.call()()).toBe(calc.string);
\r
1620 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1621 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1622 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1625 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1626 return function (t) {
\r
1627 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1628 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1632 expect(calc.keySplines).toBeNull();
\r
1633 calc.mode = "spline";
\r
1634 expect( calc.call()("undef")).toBe(Math.PI);
\r
1635 calc.keySplines = [0, 0, 1, 1];
\r
1636 calc.to.degit = 1;
\r
1637 calc.to.from = from;
\r
1638 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1639 calc.to.from = from;
\r
1640 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1641 calc.to.from = from;
\r
1642 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1644 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1645 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1646 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1647 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1648 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1649 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1650 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1651 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1652 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1654 var a = y4-3*(y3-y2)-y1,
\r
1655 b = 3*(y3-2*y2+y1),
\r
1657 d = y1 - bezier.apply(null, arguments)(t);
\r
1658 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1661 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1662 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1665 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1666 return function (t) {
\r
1668 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1669 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1673 calc.mode = "spline";
\r
1674 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1675 calc.to.degit = 1;
\r
1676 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1677 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1678 calc.to.from = from;
\r
1679 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1680 calc.to.from = from;
\r
1681 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1683 var ff = function(k) {
\r
1684 calc.keySplines = k;
\r
1685 calc.to.degit = 10;
\r
1686 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1687 epsilon = 1e-5; //誤差
\r
1688 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1689 calc.to.from = from;
\r
1690 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1691 calc.to.from = from;
\r
1692 b = b(Math.random());
\r
1693 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1695 for (var i=0;i<10000;++i) {
\r
1696 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1700 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1701 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1702 calc.mode = "spline";
\r
1703 calc.keySplines = [0, NaN, 1, 1];
\r
1704 calc.to.degit = 1;
\r
1705 calc.to.from = from;
\r
1706 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1709 calc.keySplines = [0, 0, 1, 2];
\r
1710 calc.to.degit = 1;
\r
1711 calc.to.from = from;
\r
1712 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1714 calc.keySplines = null;
\r
1715 calc.to.degit = 1;
\r
1716 calc.to.from = from;
\r
1717 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1720 describe("A $attribute object", function() {
\r
1721 describe("A push method", function() {
\r
1723 beforeEach( function() {
\r
1724 attr = base("$calcMode").$attribute.up("width");
\r
1725 base("$frame").timelines.length = 0;
\r
1726 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1728 afterEach( function() {
\r
1729 attr.isCSS = false;
\r
1731 /*境界条件を調べておく (limit value analysis)*/
\r
1732 it("should be this for the value (limit value analysis)", function() {
\r
1733 expect(attr.element).toBeNull();
\r
1734 expect(attr.push()).toBeNull();
\r
1735 expect(attr.element).toBeNull();
\r
1736 expect(attr.isCSS).toBeFalsy();
\r
1737 expect(base("$frame").timelines.length).toBe(0);
\r
1739 expect(attr.push(s)).toBeNull();
\r
1740 expect(attr.element).toBeNull();
\r
1741 expect(base("$frame").timelines.length).toBe(0);
\r
1742 expect(attr.hasAttrValues()).toBeFalsy();
\r
1744 var p = document.createElement("g");
\r
1746 expect(attr.push(s)).toBeNull();
\r
1747 expect(attr.element).toBe(p);
\r
1748 expect(base("$frame").timelines.length).toBe(0);
\r
1750 s.setAttribute("end", "0");
\r
1754 check("values", 4);
\r
1755 function check(attrName, num) {
\r
1756 s.setAttribute(attrName, "1");
\r
1757 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1758 var fr = attr.push(s);
\r
1759 expect(attr.element).toBe(p);
\r
1760 var timelines = base("$frame").timelines;
\r
1761 expect(timelines.length).toBe(num);
\r
1762 var line = timelines[num-1];
\r
1763 expect(line).not.toBe(fr);
\r
1764 var act = fr.$activate;
\r
1765 expect(act.dur).toBeNull();
\r
1766 expect(act.repeatCount).toBeNull();
\r
1767 expect(act.repeatDur).toBeNull();
\r
1768 expect(act.min).toBe("0");
\r
1769 expect(act.max).toBe("indefinite");
\r
1770 expect(act.simpleDur).toBeNull();
\r
1771 expect(attr.hasAttrValues()).toBeTruthy();
\r
1773 s.removeAttribute(attrName);
\r
1774 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1776 expect(attr.element).toBe(p);
\r
1777 expect(timelines.length).toBe(num);
\r
1780 /*targetElement属性のサポート*/
\r
1781 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1782 document.documentElement.appendChild(p2);
\r
1783 p2.setAttributeNS(null, "id", "p23");
\r
1784 s.setAttributeNS(null, "targetElement", "p23");
\r
1786 expect(attr.element).toBe(p2);
\r
1789 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1790 document.documentElement.appendChild(p3);
\r
1791 p3.setAttributeNS(null, "id", "p34");
\r
1792 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1794 expect(attr.element).toBe(p3);
\r
1796 /*attributeType属性のサポート*/
\r
1797 s.setAttributeNS(null, "attributeType", "CSS");
\r
1798 s.setAttributeNS(null, "values", "a;b;c");
\r
1800 expect(attr.isCSS).toBeTruthy();
\r
1802 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1803 it("should be this for the value (the valid partion )", function() {
\r
1804 s.setAttribute("from", "1");
\r
1805 var p = document.createElement("g");
\r
1807 var values = [ "0",
\r
1808 "0", null, null, null,
\r
1809 "0", "indefinite", null
\r
1812 check2("dur", "0");
\r
1813 check2("begin", "0");
\r
1815 check2("begin", "1");
\r
1817 check2("end", "0");
\r
1819 check2("repeatCount", "0");
\r
1821 check2("repeatDur", "0");
\r
1823 check2("min", "0");
\r
1825 check2("max", "0");
\r
1827 check2("begin", "12");
\r
1828 values[7] = 1000 * base("$frame").fpms;
\r
1830 check2("dur", "1");
\r
1831 function check2(attrName, value) {
\r
1832 s.setAttribute(attrName, value);
\r
1833 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1834 var fr = attr.push(s);
\r
1835 expect(attr.element).toBe(p);
\r
1836 var timelines = base("$frame").timelines;
\r
1837 var line = timelines[timelines.length-1];
\r
1838 expect(fr.string).toBe(values[0]);
\r
1839 var act = fr.$activate;
\r
1840 expect(act.dur).toBe(values[1]);
\r
1841 expect(act.repeatCount).toBe(values[3]);
\r
1842 expect(act.repeatDur).toBe(values[4]);
\r
1843 expect(act.min).toBe(values[5]);
\r
1844 expect(act.max).toBe(values[6]);
\r
1845 expect(act.simpleDur).toBe(values[7]);
\r
1849 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1850 document.documentElement.appendChild(p4);
\r
1851 p4.appendChild(s);
\r
1852 p4.setAttributeNS(null, "style", "display: none");
\r
1854 expect(attr.setAttribute()).toBeUndefined();
\r
1855 expect(attr.setAttribute("block")).toBeUndefined();
\r
1856 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1857 expect(attr.isCSS).toBeFalsy();
\r
1859 s.setAttributeNS(null, "attributeName", "display");
\r
1861 expect(attr.setAttribute("block")).toBeUndefined();
\r
1862 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1863 expect(attr.isCSS).toBeTruthy();
\r
1864 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1866 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1867 document.documentElement.appendChild(p4);
\r
1868 p4.appendChild(s);
\r
1869 p4.setAttributeNS(null, "style", "display: none");
\r
1871 expect(attr.setAttribute("block")).toBeUndefined();
\r
1872 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1873 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1874 expect(attr.removeAttribute()).toBeUndefined();
\r
1875 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1876 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1878 /*attributeType属性のサポート*/
\r
1879 s.setAttributeNS(null, "values", "a;b;c");
\r
1880 s.setAttributeNS(null, "attributeName", "display");
\r
1881 attr.isCSS = false;
\r
1883 expect(attr.isCSS).toBeTruthy();
\r
1885 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1886 it("should be this for the value (the invalid partion )", function() {
\r
1887 var p = document.createElement("g");
\r
1890 s.setAttributeNS(null, "begin", "1");
\r
1892 var timelines = base("$frame").timelines;
\r
1893 expect(timelines.length).toBe(0);
\r
1894 s.setAttributeNS(null, "from", "0");
\r
1896 expect(timelines.length).toBe(1);
\r
1897 expect(attr.push(12)).toBeNull();
\r
1900 describe("A setValues method", function() {
\r
1902 beforeEach( function() {
\r
1903 attr = base("$calcMode").$attribute.up("width");
\r
1904 base("$frame").timelines.length = 0;
\r
1905 s = document.createElement("animate");
\r
1907 /*境界条件を調べておく (limit value analysis)*/
\r
1908 it("should be this for the value (limit value analysis)", function() {
\r
1909 expect(attr.$from).not.toBeUndefined();
\r
1910 expect(attr.setValues()).toBeNull();
\r
1911 expect(attr.setValues("")).toBeNull();
\r
1913 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1914 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
1915 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
1916 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
1918 /*from-to アニメーション*/
\r
1919 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1920 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
1922 /*from-by アニメーション*/
\r
1923 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1924 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1925 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1927 /*fromなしto アニメーション*/
\r
1928 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1929 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
1930 var aset = attr.setValues(null, null, "1")[0].to;
\r
1932 expect(aset.from[0]).toBe(0);
\r
1934 /*fromなしby アニメーション*/
\r
1935 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1936 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1937 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1939 expect(aset.from[0]).toBe(0);
\r
1941 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1942 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1943 attr.$from.degit = 1;
\r
1944 var setv = attr.setValues("0;1")[0].call();
\r
1945 expect(setv(0.5)).toBe("0.5");
\r
1946 expect(setv(1)).toBe("1.0");
\r
1948 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1949 expect(setv(0.5)).toBe("0.5");
\r
1950 expect(setv(1)).toBe("1.0");
\r
1951 setv = attr.setValues("0;1;2")[1].call();
\r
1952 expect(setv(0.4)).toBe("1.4");
\r
1953 expect(setv(1)).toBe("2.0");
\r
1955 attr.$from.degit = 2;
\r
1956 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
1957 expect(setv(0.5)).toBe("8.05");
\r
1958 expect(setv(1)).toBe("15.10");
\r
1960 var v = attr.setValues("1;1;2;1;1;15.1");
\r
1961 setv = v[4].mix( {
\r
1964 expect(setv(0.05)).toBe("8.05");
\r
1965 expect(setv(0.1)).toBe("15.10");
\r
1966 setv = v[3].mix( {
\r
1969 expect(setv(0.01)).toBe("1.00");
\r
1970 expect(setv(0.1)).toBe("1.00");
\r
1971 setv = v[2].mix( {
\r
1974 expect(setv(0.25)).toBe("1.50");
\r
1975 expect(setv(0.5)).toBe("1.00");
\r
1977 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1978 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1979 attr.$from.degit = 1;
\r
1980 expect(attr.setValues("")).toBeNull();
\r
1981 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
1984 describe("A setKey method", function() {
\r
1986 beforeEach( function() {
\r
1987 attr = base("$calcMode").$attribute.up("width");
\r
1988 base("$frame").timelines.length = 0;
\r
1989 s = document.createElement("animate");
\r
1990 document.createElement("g").appendChild(s);
\r
1992 /*境界条件を調べておく (limit value analysis)*/
\r
1993 it("should be this for the value (limit value analysis)", function() {
\r
1994 expect(attr.setKey(s)).toBeNull();
\r
1996 s.setAttributeNS(null, "from", "0");
\r
1998 s.setAttributeNS(null, "to", "0");
\r
1999 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2000 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
2001 s.setAttributeNS(null, "by", "0");
\r
2003 s.setAttributeNS(null, "values", "0;2");
\r
2004 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2005 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
2007 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
2008 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2010 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
2011 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2012 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2013 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2014 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2016 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
2017 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2018 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2019 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2020 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2022 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2023 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2024 s.setAttributeNS(null, "values", "0;2;12;30");
\r
2025 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
2026 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2027 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2028 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2029 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2030 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
2031 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
2032 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2033 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2034 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2036 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
2037 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2038 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2039 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2041 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
2042 f(0, 0,0.1,0.3,1);
\r
2043 f(1, 0.1,0.4,0.5,0.7);
\r
2044 f(2, 0.2,0.2,0.1,1);
\r
2046 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
2047 f(0, 0,0.1,0.3,1);
\r
2048 f(1, 0.1,0.4,0.5,0.7);
\r
2049 f(2, 0.2,0.2,0.1,1);
\r
2051 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
2052 f(0, 0,0.1,0.333,1);
\r
2053 f(1, 0.1,0.4,0.5,0.7);
\r
2054 f(2, 0.2,0.2,0.1,1);
\r
2055 function f (i, a, b, c, d) {
\r
2056 var splines = attr.setKey(s)[i].keySplines;
\r
2057 expect(splines[0]).toBe(a);
\r
2058 expect(splines[1]).toBe(b);
\r
2059 expect(splines[2]).toBe(c);
\r
2060 expect(splines[3]).toBe(d);
\r
2063 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2064 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2065 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2066 expect(attr.setKey(s)).toBeNull();
\r
2067 s.setAttributeNS(null, "values", "0;2;12");
\r
2068 expect(attr.setKey(s)).toBeNull();
\r
2069 s.setAttributeNS(null, "values", "0;2;12;20");
\r
2070 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
2071 expect(attr.setKey(s)).toBeNull();
\r
2075 describe("A $setElement object", function() {
\r
2076 describe("A timeline property", function() {
\r
2077 var $set, ele, frame;
\r
2078 beforeEach( function() {
\r
2079 $set = base("$calcMode").$attribute.$setElement.up();
\r
2080 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2081 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2082 p.appendChild(ele);
\r
2083 frame = base("$frame");
\r
2085 /*境界条件を調べておく (limit value analysis)*/
\r
2086 it("should be this for the value (limit value analysis)", function() {
\r
2087 expect($set.timeline).toBe(frame.$begin);
\r
2090 expect($set.timeline).toBe(frame.$begin);
\r
2091 expect($set.element).toBeNull();
\r
2095 describe("An init method", function() {
\r
2096 var $set, ele, frame;
\r
2097 beforeEach( function() {
\r
2098 $set = base("$calcMode").$attribute.$setElement.up();
\r
2099 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2100 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2101 p.appendChild(ele);
\r
2102 frame = base("$frame");
\r
2104 /*境界条件を調べておく (limit value analysis)*/
\r
2105 it("should be this for the value (limit value analysis)", function() {
\r
2106 expect($set.to).toBe("");
\r
2107 expect($set.attrName).toBe("");
\r
2108 expect($set.defaultValue).toBe("");
\r
2109 expect($set.isDefault).toBeFalsy();
\r
2110 expect($set.attrNameSpace).toBeNull();
\r
2112 expect($set.timeline).toBe(frame.$begin);
\r
2114 expect($set.to).toBe("");
\r
2115 expect($set.attrName).toBe("");
\r
2116 expect($set.isDefault).toBeFalsy();
\r
2117 expect($set.attrNameSpace).toBeNull();
\r
2118 expect($set.timeline).toBe(frame.$begin);
\r
2120 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2121 it("should be this for the value (the valid partion )", function() {
\r
2122 ele.setAttributeNS(null, "to", "t1");
\r
2124 expect($set.to).toBe("t1");
\r
2125 expect($set.attrName).toBe("");
\r
2126 expect($set.defaultValue).toBe("");
\r
2128 ele.setAttributeNS(null, "attributeName", "tt1");
\r
2130 expect($set.to).toBe("t1");
\r
2131 expect($set.attrName).toBe("tt1");
\r
2132 expect($set.defaultValue).toBe("");
\r
2134 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
2136 expect($set.defaultValue).toBe("undef");
\r
2137 expect($set.isDefault).toBeTruthy();
\r
2139 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2140 ele.parentNode.style.setProperty("font-size", "12px");
\r
2142 expect($set.defaultValue).toBe("12px");
\r
2143 expect($set.isDefault).toBeFalsy();
\r
2145 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2147 expect($set.to).toBe("t1");
\r
2148 expect($set.attrName).toBe("xlink:href");
\r
2149 expect($set.defaultValue).toBe("");
\r
2150 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2152 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2154 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2155 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2157 expect($set.to).toBe("");
\r
2158 expect($set.attrName).toBe("");
\r
2159 expect($set.defaultValue).toBe("");
\r
2162 expect($set.to).toBe("");
\r
2163 expect($set.attrName).toBe("");
\r
2164 expect($set.defaultValue).toBe("");
\r
2167 describe("Frame Set", function() {
\r
2168 var $set, ele, frame;
\r
2169 beforeEach( function() {
\r
2170 $set = base("$calcMode").$attribute.$setElement.up();
\r
2171 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2172 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2173 p.appendChild(ele);
\r
2174 frame = base("$frame");
\r
2175 frame.timelines.length = 0; //配列の初期化
\r
2176 frame.startTime = Date.now();
\r
2177 frame.setFrame(0);
\r
2179 afterEach( function() {
\r
2180 $set.isCSS = false;
\r
2182 /*境界条件を調べておく (limit value analysis)*/
\r
2183 it("should be this for the value (limit value analysis)", function() {
\r
2184 expect($set.isEnd).toBeFalsy();
\r
2185 ele.setAttributeNS(null, "dur", "1s");
\r
2186 ele.setAttributeNS(null, "attributeName", "fill");
\r
2187 ele.setAttributeNS(null, "to", "red");
\r
2189 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2190 $set.isCSS = false;
\r
2191 expect($set.timeline).not.toBe(frame.$begin);
\r
2192 frame.setFrame(0);
\r
2193 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2195 var line = $set.timeline;
\r
2196 expect(line.$list.state).toBe(line.$list.PLAYING);
\r
2197 frame.setFrame(24);
\r
2198 expect(line.$list.state).toBe(line.$list.POSTWAITING);
\r
2199 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2201 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2202 it("should be this for the value (the valid partion)", function() {
\r
2203 ele.setAttributeNS(null, "begin", "1s");
\r
2204 ele.setAttributeNS(null, "dur", "1s");
\r
2205 ele.setAttributeNS(null, "attributeName", "fill");
\r
2206 ele.setAttributeNS(null, "to", "red");
\r
2208 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2209 $set.isCSS = false;
\r
2210 var f = function(num) {
\r
2211 frame.setFrame(num);
\r
2212 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2217 frame.setFrame(24);
\r
2218 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2219 frame.setFrame(25);
\r
2220 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2224 ele.setAttributeNS(null, "fill", "freeze");
\r
2226 $set.isCSS = false;
\r
2230 frame.setFrame(24);
\r
2231 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2232 frame.setFrame(25);
\r
2233 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2234 frame.setFrame(48);
\r
2235 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2236 frame.setFrame(49);
\r
2237 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2238 ele.setAttributeNS(null, "begin", "1s");
\r
2239 ele.setAttributeNS(null, "attributeName", "fill");
\r
2240 ele.setAttributeNS(null, "to", "red");
\r
2241 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2243 $set.isCSS = false;
\r
2244 var f = function(num) {
\r
2245 frame.setFrame(num);
\r
2246 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2254 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2255 it("should be this for the value (the invalid partion)", function() {
\r
2260 describe("A $animateElement object", function() {
\r
2261 describe("An init method", function() {
\r
2262 var $animate, ele, frame;
\r
2263 beforeEach( function() {
\r
2264 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2265 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2266 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2267 p.appendChild(ele);
\r
2268 frame = base("$frame");
\r
2269 frame.timelines.length = 0;
\r
2270 frame.startTime = Date.now();
\r
2271 frame.setFrame(0);
\r
2273 /*境界条件を調べておく (limit value analysis)*/
\r
2274 it("should be this for the value (limit value analysis)", function() {
\r
2277 ele.setAttributeNS(null, "begin", "1s");
\r
2278 ele.setAttributeNS(null, "dur", "1s");
\r
2279 ele.setAttributeNS(null, "attributeName", "d");
\r
2280 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2281 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2282 $animate.init(ele);
\r
2283 expect($animate.isCSS).toBeFalsy();
\r
2284 frame.setFrame(0);
\r
2285 var p = ele.parentNode;
\r
2286 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2287 * 他のブラウザではnullを返すため、その対策をする*/
\r
2288 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2290 function f(fr, result) {
\r
2291 frame.setFrame(fr);
\r
2292 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2295 f(24, "M20.0 0.0 L20.0 30.0");
\r
2296 f(36, "M20.0 10.0 L15.0 30.0");
\r
2299 ele.setAttributeNS(null, "fill", "freeze");
\r
2300 $animate.init(ele);
\r
2301 f(24, "M20.0 0.0 L20.0 30.0");
\r
2302 f(36, "M20.0 10.0 L15.0 30.0");
\r
2303 f(48, "M20.0 20.0 L10.0 30.0");
\r
2305 frame.timelines.length = 0;
\r
2306 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2307 $animate.init(ele);
\r
2308 expect($animate.isCSS).toBeFalsy();
\r
2309 expect($animate.mode).toBe("discrete");
\r
2310 f(24, "M20.0 0.0 L20.0 30.0");
\r
2311 f(25, "M20.0 0.0 L20.0 30.0");
\r
2312 f(37, "M20.0 20.0 L10.0 30.0");
\r
2313 f(48, "M20.0 20.0 L10.0 30.0");
\r
2315 [ ["display", "inline", "none"],
\r
2316 ["visibility", "hidden", "visible"],
\r
2317 ["stroke-linecap", "round", "square"],
\r
2318 ["font-style", "italic", "normal"]
\r
2319 ].forEach( function(attr) {
\r
2320 var attrName = attr[0],
\r
2323 function g(fr, result) {
\r
2324 frame.setFrame(fr);
\r
2325 expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);
\r
2329 ele.setAttributeNS(null, "from", from);
\r
2330 ele.setAttributeNS(null, "to", to);
\r
2331 frame.timelines.length = 0;
\r
2332 ele.setAttributeNS(null, "calcMode", "linear");
\r
2333 ele.setAttributeNS(null, "attributeName", attrName);
\r
2334 $animate.init(ele);
\r
2335 expect($animate.mode).toBe("discrete");
\r
2342 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2343 it("should be this for the value (the valid partion )", function() {
\r
2345 ele.setAttributeNS(null, "begin", "0s");
\r
2346 ele.setAttributeNS(null, "dur", "100s");
\r
2347 ele.setAttributeNS(null, "attributeName", "d");
\r
2348 ele.setAttributeNS(null, "fill", "freeze");
\r
2349 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2350 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2351 $animate.init(ele);
\r
2353 var p = ele.parentNode;
\r
2354 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2356 function f(fr, result) {
\r
2357 frame.setFrame(fr);
\r
2358 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2361 for (var i=0;i<2400;++i) {
\r
2362 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2364 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2367 frame.timelines.length = 0;
\r
2368 ele.setAttributeNS(null, "begin", "0s");
\r
2369 ele.setAttributeNS(null, "dur", "1s");
\r
2370 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2371 ele.setAttributeNS(null, "attributeName", "d");
\r
2372 ele.setAttributeNS(null, "fill", "freeze");
\r
2373 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2374 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2375 $animate.init(ele);
\r
2376 f(23, "M20.0 23.0 L20.0 30.0");
\r
2377 f(24, "M20.0 0.0 L20.0 30.0");
\r
2378 f(25, "M20.0 1.0 L20.0 30.0");
\r
2379 f(48, "M20.0 24.0 L20.0 30.0");
\r
2381 frame.timelines.length = 0;
\r
2382 ele.setAttributeNS(null, "begin", "0s");
\r
2383 ele.setAttributeNS(null, "dur", "2s");
\r
2384 ele.setAttributeNS(null, "attributeName", "d");
\r
2385 ele.setAttributeNS(null, "fill", "freeze");
\r
2386 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2387 $animate.init(ele);
\r
2388 f(0, "M20.0 0.0 L20.0 30.0");
\r
2389 f(1, "M20.0 1.0 L20.0 30.0");
\r
2390 f(24, "M20.0 24.0 L20.0 30.0");
\r
2391 f(25, "M20.0 24.1 L20.0 30.0");
\r
2392 f(47, "M20.0 26.3 L20.0 30.0");
\r
2393 f(48, "M20.0 26.4 L20.0 30.0");
\r
2394 f(49, "M20.0 26.4 L20.0 30.0");
\r
2395 f(50, "M20.0 26.4 L20.0 30.0");
\r
2397 frame.timelines.length = 0;
\r
2398 ele.setAttributeNS(null, "begin", "0s");
\r
2399 ele.setAttributeNS(null, "end", "2s");
\r
2400 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2401 ele.removeAttributeNS(null, "repeatDur");
\r
2402 ele.setAttributeNS(null, "attributeName", "d");
\r
2403 ele.setAttributeNS(null, "fill", "freeze");
\r
2404 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2405 $animate.init(ele);
\r
2406 f(0, "M20.0 0.0 L20.0 30.0");
\r
2407 f(1, "M20.0 0.0 L20.0 30.0");
\r
2408 f(24, "M20.0 0.0 L20.0 30.0");
\r
2409 f(25, "M20.0 0.0 L20.0 30.0");
\r
2410 f(47, "M20.0 0.0 L20.0 30.0");
\r
2411 f(48, "M20.0 0.0 L20.0 30.0");
\r
2412 f(49, "M20.0 0.0 L20.0 30.0");
\r
2413 f(50, "M20.0 0.0 L20.0 30.0");
\r
2415 frame.timelines.length = 0;
\r
2416 ele.setAttributeNS(null, "dur", "2s");
\r
2417 ele.setAttributeNS(null, "fill", "remove");
\r
2418 var attrValue = p.getAttributeNS(null, "d");
\r
2419 $animate.init(ele);
\r
2422 frame.timelines.length = 0;
\r
2423 p.removeAttributeNS(null, "d");
\r
2424 ele.setAttributeNS(null, "fill", "freeze");
\r
2425 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2426 $animate.init(ele);
\r
2427 f(1, "M20.0 5.0 L20.0 30.0");
\r
2428 f(48, "M20.0 26.4 L20.0 30.0");
\r
2430 frame.timelines.length = 0;
\r
2431 ele.setAttributeNS(null, "fill", "freeze");
\r
2432 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2433 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2434 $animate.init(ele);
\r
2435 f(1, "M20.0 0.0 L20.0 30.0");
\r
2436 f(4, "M20.0 0.0 L20.0 30.0");
\r
2437 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2439 f(24, "M20.0 24.0 L20.0 30.0");
\r
2440 f(25, "M20.0 24.0 L20.0 30.0");
\r
2441 f(29, "M20.0 26.4 L20.0 30.0");
\r
2442 f(48, "M20.0 26.4 L20.0 30.0");
\r
2444 frame.timelines.length = 0;
\r
2445 ele.setAttributeNS(null, "calcMode", "spline");
\r
2446 ele.removeAttributeNS(null, "keyTimes");
\r
2447 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2448 ele.removeAttributeNS(null, "end");
\r
2449 ele.setAttributeNS(null, "dur", "9s");
\r
2450 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2451 $animate.init(ele);
\r
2458 frame.timelines.length = 0;
\r
2459 ele.setAttributeNS(null, "calcMode", "spline");
\r
2460 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2461 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2462 ele.setAttributeNS(null, "dur", "8s");
\r
2463 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2464 $animate.init(ele);
\r
2472 frame.timelines.length = 0;
\r
2473 ele.setAttributeNS(null, "begin", "click");
\r
2474 ele.setAttributeNS(null, "calcMode", "spline");
\r
2475 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2476 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2477 ele.setAttributeNS(null, "dur", "8s");
\r
2478 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2479 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2480 $animate.init(ele);
\r
2487 ( function(attrName) {
\r
2488 function g(fr, result) {
\r
2489 frame.setFrame(fr);
\r
2490 expect(p.style.getPropertyValue(attrName)).toBe(result);
\r
2493 frame.timelines.length = 0;
\r
2494 ele.setAttributeNS(null, "begin", "0s");
\r
2495 ele.setAttributeNS(null, "calcMode", "linear");
\r
2496 ele.setAttributeNS(null, "attributeName", attrName);
\r
2497 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2498 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2499 ele.setAttributeNS(null, "dur", "8s");
\r
2500 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2501 $animate.init(ele);
\r
2502 expect($animate.mode).toBe("discrete");
\r
2509 frame.timelines.length = 0;
\r
2510 ele.setAttributeNS(null, "begin", "click");
\r
2511 ele.setAttributeNS(null, "calcMode", "linear");
\r
2512 ele.setAttributeNS(null, "attributeName", attrName);
\r
2513 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2514 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2515 ele.setAttributeNS(null, "dur", "8s");
\r
2516 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2517 $animate.init(ele);
\r
2518 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2519 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2520 p.dispatchEvent(evt);
\r
2521 var cur = base("$frame").currentFrame;
\r
2522 expect($animate.mode).toBe("discrete");
\r
2523 g(cur+0, "inline");
\r
2524 g(cur+48, "block");
\r
2525 g(cur+96, "inline");
\r
2526 g(cur+192, "block");
\r
2527 g(cur+300, "block");
\r
2530 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2531 it("should be this for the value (the invalid partion )", function() {
\r
2532 ele.setAttributeNS(null, "begin", "0s");
\r
2533 ele.setAttributeNS(null, "dur", "100s");
\r
2534 ele.setAttributeNS(null, "attributeName", "d");
\r
2535 ele.setAttributeNS(null, "fill", "freeze");
\r
2536 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2537 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2538 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2539 $animate.init(ele);
\r
2541 var p = ele.parentNode;
\r
2542 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2544 function f(fr, result) {
\r
2545 frame.setFrame(fr);
\r
2546 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2551 frame.timelines.length = 0;
\r
2552 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2553 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2554 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2555 $animate.init(ele);
\r
2559 /*keyTimes属性が0から始まっていない*/
\r
2560 frame.timelines.length = 0;
\r
2561 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2565 function ff(mode) {
\r
2566 ele.setAttributeNS(null, "calcMode", mode);
\r
2567 $animate.init(ele);
\r
2572 frame.timelines.length = 0;
\r
2573 ele.setAttributeNS(null, "calcMode", "spline");
\r
2574 $animate.init(ele);
\r
2575 expect($animate.mode).toBe("spline");
\r
2581 describe("RGB Color", function() {
\r
2582 var $animate, ele, frame, f;
\r
2583 beforeEach( function() {
\r
2584 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2585 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2586 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2587 p.appendChild(ele);
\r
2588 frame = base("$frame");
\r
2589 frame.timelines.length = 0;
\r
2591 f = function (fr, result, attr) {
\r
2592 frame.setFrame(fr);
\r
2593 expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));
\r
2596 /*境界条件を調べておく (limit value analysis)*/
\r
2597 it("should be this for the value (limit value analysis)", function() {
\r
2598 ele.setAttributeNS(null, "begin", "0s");
\r
2599 ele.setAttributeNS(null, "dur", "1s");
\r
2600 ele.setAttributeNS(null, "attributeName", "fill");
\r
2601 ele.setAttributeNS(null, "fill", "remove");
\r
2602 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2603 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2604 $animate.init(ele);
\r
2606 f(0, "rgb(0, 0, 0)", "fill");
\r
2607 f(23, "rgb(10, 10, 1)", "fill");
\r
2609 frame.timelines.length = 0;
\r
2610 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2611 $animate.init(ele);
\r
2612 f(0, "rgb(0, 0, 0)", "stroke");
\r
2613 f(23, "rgb(10, 10, 1)", "stroke");
\r
2615 frame.timelines.length = 0;
\r
2616 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2617 $animate.init(ele);
\r
2618 f(0, "rgb(0,0,0)", "stop-color");
\r
2619 f(23, "rgb(10,10,1)", "stop-color");
\r
2621 frame.timelines.length = 0;
\r
2622 ele.setAttributeNS(null, "attributeName", "color");
\r
2623 $animate.init(ele);
\r
2624 f(0, "rgb(0,0,0)", "color");
\r
2625 f(23, "rgb(10,10,1)", "color");
\r
2627 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2628 it("should be this for the value (the valid partion )", function() {
\r
2629 ele.setAttributeNS(null, "begin", "0s");
\r
2630 ele.setAttributeNS(null, "dur", "1s");
\r
2631 ele.setAttributeNS(null, "attributeName", "fill");
\r
2632 ele.setAttributeNS(null, "fill", "remove");
\r
2633 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2634 $animate.init(ele);
\r
2636 f(0, "rgb(0, 0, 0)", "fill");
\r
2637 f(1, "rgb(1, 0, 0)", "fill");
\r
2638 f(23, "rgb(23, 2, 1)", "fill");
\r
2640 frame.timelines.length = 0;
\r
2641 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2642 $animate.init(ele);
\r
2645 f(0, "rgb(0, 8, 60)", "fill");
\r
2646 f(1, "rgb(1, 9, 60)", "fill");
\r
2647 f(23, "rgb(23, 31, 60)", "fill");
\r
2649 frame.timelines.length = 0;
\r
2650 ele.setAttributeNS(null, "fill", "freeze");
\r
2651 ele.setAttributeNS(null, "values", "black;white");
\r
2652 $animate.init(ele);
\r
2653 /*色キーワードをrgb形式に変換*/
\r
2655 f(0, "rgb(0, 0, 0)", "fill");
\r
2656 f(12, "rgb(128, 128, 128)", "fill");
\r
2657 f(24, "rgb(255, 255, 255)", "fill");
\r
2659 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2660 it("should be this for the value (the invalid partion )", function() {
\r
2661 ele.setAttributeNS(null, "begin", "0s");
\r
2662 ele.setAttributeNS(null, "dur", "1s");
\r
2663 ele.setAttributeNS(null, "attributeName", "fi");
\r
2664 ele.setAttributeNS(null, "fill", "remove");
\r
2665 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2666 $animate.init(ele);
\r
2669 function f (fr, result, attr) {
\r
2670 frame.setFrame(fr);
\r
2671 expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);
\r
2673 f(0, "#83.0C", "fi");
\r
2674 f(1, "#84.0C", "fi");
\r
2675 f(23, "#106.0C", "fi");
\r
2678 describe("$frame.$svgEvent object", function() {
\r
2679 var frame = base("$frame").$svgEvent,
\r
2681 base("$frame").pauseAnimation();
\r
2682 beforeEach( function() {
\r
2683 base("$frame").pauseAnimation();
\r
2684 frame = frame.up().mix( {isResolved: true} );
\r
2685 frame.first = null;
\r
2686 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2687 * 影響を受けるため、新たに初期化しておく*/
\r
2688 base("$frame").timelines = frame.timelines = [];
\r
2689 frame.lastTimeLine = null;
\r
2690 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2691 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2692 p.appendChild(ele);
\r
2694 /*境界条件を調べておく (limit value analysis)*/
\r
2695 it("should be this for the value (limit value analysis)", function() {
\r
2696 base("$frame").pauseAnimation();
\r
2697 frame.lastTimeLine = null;
\r
2698 expect(frame.lastTimeLine).toBeNull();
\r
2699 expect(frame.first).toBeNull();
\r
2700 frame.setTimeTable();
\r
2701 expect(frame.first).toBeNull();
\r
2702 frame.addLine( base("$frame").$begin.up().mix({
\r
2709 frame.setTimeTable();
\r
2710 expect(frame.first).toEqual(
\r
2712 eventType: "begin",
\r
2723 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2724 it("should be this for the value (the valid partion )", function() {
\r
2725 base("$frame").pauseAnimation();
\r
2726 frame.addLine( base("$frame").$begin.up().mix({
\r
2733 frame.setTimeTable();
\r
2734 frame.setTimeTable();
\r
2735 expect(frame.first).toEqual(
\r
2737 eventType: "begin",
\r
2747 frame.setTimeTable();
\r
2748 frame.setTimeTable();
\r
2749 expect(frame.first).toEqual(
\r
2751 eventType: "begin",
\r
2762 var isFiredBeginEvent = false;
\r
2763 ele.addEventListener("beginEvent", function(evt) {
\r
2764 isFiredBeginEvent = true;
\r
2765 expect(evt.target).toBe(ele);
\r
2767 ele.addEventListener("endEvent", function(evt) {
\r
2768 expect(evt.target).toBe(ele);
\r
2769 expect(isFiredBeginEvent).toBeTruthy();
\r
2771 frame.setFrame(0);
\r
2772 expect(frame.first).toBeNull();
\r
2773 frame.setFrame(0);
\r
2774 expect(frame.first).toBeNull();
\r
2776 frame.timelines = [];
\r
2777 frame.addLine( base("$frame").$begin.up().mix({
\r
2784 frame.setTimeTable();
\r
2785 var a = { frame: 0,
\r
2786 eventType: "begin",
\r
2789 next: { frame: 10,
\r
2795 expect(frame.first).toEqual(a);
\r
2797 frame.addLine( base("$frame").$begin.up().mix({
\r
2801 simpleDuration: 9,
\r
2805 frame.setTimeTable();
\r
2806 a.next.next = { frame: 1,
\r
2807 eventType: "begin",
\r
2812 eventType: "repeat",
\r
2816 next: { frame: 12,
\r
2823 expect(frame.first).toEqual(a);
\r
2824 frame.setFrame(11);
\r
2825 expect(frame.first).toEqual( {frame: 12,
\r
2831 frame.timelines = [];
\r
2832 frame.first = null;
\r
2833 frame.addLine( base("$frame").$begin.up().mix({
\r
2837 simpleDuration: 4,
\r
2841 frame.setTimeTable();
\r
2843 eventType: "begin",
\r
2848 eventType: "repeat",
\r
2854 eventType: "repeat",
\r
2858 next: { frame: 11,
\r
2866 expect(frame.first).toEqual(a);
\r
2867 frame.setFrame(0);
\r
2868 expect(frame.first).toEqual(a);
\r
2869 frame.setFrame(1);
\r
2871 expect(frame.first).toEqual(a);
\r
2872 frame.setFrame(5);
\r
2873 expect(frame.first).toEqual(a.next);
\r
2875 ele.addEventListener("repeatEvent", function(evt) {
\r
2876 expect(evt.target).toBe(ele);
\r
2878 frame.timelines = [];
\r
2879 frame.first = null;
\r
2880 frame.addLine( base("$frame").$begin.up().mix({
\r
2884 simpleDuration: 4,
\r
2888 frame.setFrame(9);
\r
2889 expect(frame.first).toEqual({
\r
2891 eventType: "repeat",
\r
2895 next: { frame: 16,
\r
2902 afterEach( function() {
\r
2903 base("$frame").startAnimation();
\r
2906 describe("A $animateTransformElemenet object", function() {
\r
2907 describe("An init method", function() {
\r
2908 var $animate, ele, frame, p;
\r
2909 beforeEach( function() {
\r
2910 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2911 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
2912 $animate.degits = 1;
\r
2913 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2914 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2915 p.appendChild(ele);
\r
2916 frame = base("$frame");
\r
2917 frame.timelines.length = 0;
\r
2918 frame.startTime = Date.now();
\r
2919 frame.setFrame(0);
\r
2921 afterEach( function() {
\r
2922 $animate.numberOfList = -1;
\r
2924 /*境界条件を調べておく (limit value analysis)*/
\r
2925 it("should be this for the value (limit value analysis)", function() {
\r
2926 expect($animate.numberOfList).toBe(-1);
\r
2927 expect($animate.type).toBe("translate");
\r
2928 expect(p.__transformList).toBeUndefined();
\r
2929 expect($animate.isCSS).toBeFalsy();
\r
2930 expect($animate.isSum).toBeFalsy();
\r
2931 expect($animate.attrName).toBe("transform");
\r
2934 expect($animate.numberOfList).toBe(-1);
\r
2935 expect(p.__transformList).toBeUndefined();
\r
2936 expect($animate.isCSS).toBeFalsy();
\r
2937 expect($animate.type).toBe("translate");
\r
2938 expect($animate.attrName).toBe("transform");
\r
2941 expect($animate.numberOfList).toBe(-1);
\r
2942 expect(p.__transformList).toBeUndefined();
\r
2943 expect($animate.isCSS).toBeFalsy();
\r
2944 expect($animate.type).toBe("translate");
\r
2945 expect($animate.attrName).toBe("transform");
\r
2947 $animate.init(ele);
\r
2948 expect($animate.numberOfList).toBe(-1);
\r
2949 expect(p.__transformList).toEqual([]);
\r
2950 expect($animate.isCSS).toBeFalsy();
\r
2951 expect($animate.type).toBe("translate");
\r
2952 expect($animate.attrName).toBe("transform");
\r
2954 ele.setAttributeNS(null, "values", "0;1");
\r
2955 ele.setAttributeNS(null, "attributeName", "");
\r
2956 $animate.init(ele);
\r
2957 expect($animate.isCSS).toBeFalsy();
\r
2958 expect($animate.type).toBe("translate");
\r
2959 expect($animate.type).toBe("translate");
\r
2960 expect($animate.numberOfList).toBe(0);
\r
2961 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2962 value: "translate(0)",
\r
2967 ele.setAttributeNS(null, "type", "translate");
\r
2968 $animate.init(ele);
\r
2969 expect($animate.numberOfList).toBe(0);
\r
2970 expect($animate.isCSS).toBeFalsy();
\r
2971 expect($animate.type).toBe("translate");
\r
2972 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2973 value: "translate(0)",
\r
2977 $animate.tocall(0);
\r
2978 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2980 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2981 $animate.numberOfList = -1;
\r
2982 $animate.init(ele.parentNode.lastChild);
\r
2983 expect($animate.numberOfList).toBe(1);
\r
2984 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2985 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2987 expect($animate.type).toBe("translate");
\r
2988 $animate.tocall(0);
\r
2989 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2990 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2991 $animate._setEndFrame(1);
\r
2992 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2993 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2995 delete p.__transformList;
\r
2996 ele.setAttributeNS(null, "type", "scale");
\r
2997 $animate.numberOfList = -1;
\r
2998 $animate.init(ele);
\r
2999 expect($animate.numberOfList).toBe(0);
\r
3000 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3001 value: "translate(0)",
\r
3005 expect($animate.type).toBe("scale");
\r
3007 delete p.__transformList;
\r
3008 $animate.numberOfList = -1;
\r
3009 ele.setAttributeNS(null, "additive", "sum");
\r
3010 ele.setAttributeNS(null, "fill", "freeze");
\r
3011 $animate.init(ele);
\r
3012 expect($animate.isSum).toBeTruthy();
\r
3013 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3014 value: "translate(0)",
\r
3018 delete p.__transformList;
\r
3019 $animate.numberOfList = -1;
\r
3020 ele.setAttributeNS(null, "additive", "replace");
\r
3021 ele.setAttributeNS(null, "fill", "remove");
\r
3022 $animate.init(ele);
\r
3023 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3024 value: "translate(0)",
\r
3029 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3030 it("should be this for the value (the valid partion )", function() {
\r
3031 ele.setAttributeNS(null, "type", "scale");
\r
3032 ele.setAttributeNS(null, "values", "0;1");
\r
3033 $animate.init(ele);
\r
3034 expect($animate.isCSS).toBeFalsy();
\r
3035 expect($animate.numberOfList).toBe(0);
\r
3036 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3037 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
3038 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
3039 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3041 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3042 $animate.numberOfList = -1;
\r
3043 $animate.init(ele.parentNode.lastChild);
\r
3044 expect($animate.numberOfList).toBe(1);
\r
3045 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3046 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3048 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3049 $animate.up("$a").numberOfList = -1;
\r
3050 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3051 $animate.$a.init(ele.parentNode.lastChild);
\r
3052 expect($animate.$a.numberOfList).toBe(2);
\r
3053 expect($animate.$a.isDefault).toBeTruthy();
\r
3054 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3055 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
3056 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
3057 $animate.defaultValue = $animate.$a.defaultValue;
\r
3058 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
3060 ele.setAttributeNS(null, "additive", "sum");
\r
3061 var parentNode = ele.parentNode;
\r
3062 parentNode.appendChild(ele.cloneNode(true));
\r
3063 parentNode.__transformList = [];
\r
3064 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
3065 parentNode.removeChild(ele);
\r
3066 $animate.numberOfList = -1;
\r
3067 $animate.init(parentNode.lastChild);
\r
3068 expect($animate.numberOfList).toBe(0);
\r
3069 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3070 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3072 parentNode.appendChild(ele.cloneNode(true));
\r
3073 $animate.up("$a").numberOfList = -1;
\r
3074 parentNode.__transformList = [];
\r
3075 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3076 $animate.$a.init(parentNode.lastChild);
\r
3077 expect($animate.$a.numberOfList).toBe(0);
\r
3078 expect($animate.$a.isDefault).toBeTruthy();
\r
3079 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3080 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3081 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3082 $animate.defaultValue = $animate.$a.defaultValue;
\r
3083 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
3085 ele.removeAttributeNS(null, "additive");
\r
3086 ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",
\r
3087 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
3088 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
3089 "scale(0.0)", "scale(1.0)");
\r
3090 function ad(first, second, a, b, c, d) {
\r
3092 while (parentNode.firstChild) {
\r
3093 parentNode.removeChild(parentNode.firstChild);
\r
3096 /*additive属性のreplaceとsumの混合*/
\r
3097 ele.setAttributeNS(null, "additive", first);
\r
3098 parentNode.appendChild(ele.cloneNode(true));
\r
3099 ele.setAttributeNS(null, "additive", second);
\r
3100 parentNode.appendChild(ele.cloneNode(true));
\r
3101 parentNode.__transformList = [];
\r
3102 $animate.numberOfList = -1;
\r
3103 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3104 $animate.up("$first").init(parentNode.firstChild);
\r
3105 $animate.up("$second").init(parentNode.lastChild);
\r
3106 expect($animate.$first.numberOfList).toBe(0);
\r
3107 expect($animate.$second.numberOfList).toBe(1);
\r
3108 expect($animate.$first.tocall(0)).toBe(a);
\r
3109 expect($animate.$second.tocall(0)).toBe(b);
\r
3110 expect($animate.$first.tocall(1)).toBe(c);
\r
3111 expect($animate.$second.tocall(1)).toBe(d);
\r
3114 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3115 it("should be this for the value (the invalid partion )", function() {
\r
3116 $animate.init(ele);
\r
3117 ele.parentNode.__transformList = null;
\r
3118 expect( function () {
\r
3119 $animate.tocall(0);
\r
3122 $animate.numberOfList = -1;
\r
3123 $animate.init(ele);
\r
3124 $animate.numberOfList = -1;
\r
3125 expect( function () {
\r
3126 $animate.tocall(0);
\r
3131 describe("A $motionElement object", function() {
\r
3132 describe("An init method", function() {
\r
3133 var $animate, ele, frame, p;
\r
3134 beforeEach( function() {
\r
3135 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3136 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3137 $animate.degits = 1;
\r
3138 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3139 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3140 p.appendChild(ele);
\r
3141 frame = base("$frame");
\r
3142 frame.timelines.length = 0;
\r
3143 frame.startTime = Date.now();
\r
3144 frame.setFrame(0);
\r
3146 afterEach( function() {
\r
3147 $animate.numberOfList = -1;
\r
3148 delete $animate.element;
\r
3149 p.__transformList = null;
\r
3151 /*境界条件を調べておく (limit value analysis)*/
\r
3152 it("should be this for the value (limit value analysis)", function() {
\r
3153 expect($animate.type).toBe("translate");
\r
3154 expect($animate.mode).toBe("paced");
\r
3155 ele.setAttributeNS(null, "type", "scale");
\r
3156 expect($animate.rotate).toBe("0");
\r
3157 $animate.init(ele);
\r
3158 expect($animate.type).toBe("translate");
\r
3159 expect($animate.mode).toBe("paced");
\r
3160 expect($animate.rotate).toBe("0");
\r
3162 ele.setAttributeNS(null, "values", "0,0;1,0");
\r
3163 $animate.up("$a").init(ele);
\r
3164 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3165 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3166 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3168 var ec = ele.cloneNode(true);
\r
3169 p.appendChild(ec);
\r
3170 ec.removeAttributeNS(null, "values");
\r
3171 ec.setAttributeNS(null, "from", "0,0");
\r
3172 ec.setAttributeNS(null, "to", "1,0");
\r
3173 $animate.up("$a").init(ec);
\r
3174 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3175 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3176 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3178 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3179 it("should be this for the value (the invalid partion )", function() {
\r
3183 describe("A hasAttrValues method", function() {
\r
3184 var $animate, ele, frame, p;
\r
3185 beforeEach( function() {
\r
3186 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3187 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3188 $animate.degits = 1;
\r
3189 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3190 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3191 p.appendChild(ele);
\r
3192 frame = base("$frame");
\r
3193 frame.timelines.length = 0;
\r
3194 frame.startTime = Date.now();
\r
3195 frame.setFrame(0);
\r
3197 afterEach( function() {
\r
3198 $animate.numberOfList = -1;
\r
3199 delete $animate.element;
\r
3200 p.__transformList = null;
\r
3202 /*境界条件を調べておく (limit value analysis)*/
\r
3203 it("should be this for the value (limit value analysis)", function() {
\r
3205 expect($animate.up("$a").hasAttrValues()).toBeFalsy();
\r
3206 $animate.up("$a").init(ele);
\r
3207 expect($animate.$a.hasAttrValues()).toBeFalsy();
\r
3209 ele.setAttributeNS(null, "path", "M");
\r
3210 expect($animate.$a.hasAttrValues()).toBeTruthy();
\r
3211 $animate.$animateTransformElement.up("$b").init(ele);
\r
3212 expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();
\r
3216 describe("Event", function() {
\r
3217 var $animate, ele, frame, p;
\r
3218 beforeEach( function() {
\r
3220 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3221 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3222 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3223 p.appendChild(ele);
\r
3224 frame = base("$frame");
\r
3225 frame.pauseAnimation();
\r
3226 frame.timelines.length = 0; //配列の初期化
\r
3227 frame.setFrame(0);
\r
3229 /*境界条件を調べておく (limit value analysis)*/
\r
3230 it("should be this for the value (limit value analysis)", function() {
\r
3231 ele.addEventListener("beginEvent", function(evt) {
\r
3232 expect(evt.target).toBe(ele);
\r
3234 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3235 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3236 ele.dispatchEvent(evt);
\r
3238 ele.setAttributeNS(null, "begin", "mousedown");
\r
3239 ele.setAttributeNS(null, "dur", "1s");
\r
3240 ele.setAttributeNS(null, "attributeName", "fill");
\r
3241 ele.setAttributeNS(null, "fill", "freeze");
\r
3242 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3243 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3244 $animate.init(ele);
\r
3245 $animate.isCSS = false;
\r
3246 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3247 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3248 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3249 p.dispatchEvent(evt);
\r
3250 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3252 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3253 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3254 frame.setFrame(frame.currentFrame);
\r
3255 expect($animate.isEnd).toBeFalsy();
\r
3256 p.dispatchEvent(evt);
\r
3257 frame.setFrame(frame.currentFrame + 1);
\r
3258 frame.setFrame(frame.currentFrame + 24);
\r
3259 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3262 describe("a beginElement method and an endElement method", function() {
\r
3263 var $animate, ele, frame, p;
\r
3264 beforeEach( function() {
\r
3265 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3266 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3267 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3268 p.appendChild(ele);
\r
3269 frame = base("$frame");
\r
3270 frame.timelines.length = 0; //配列の初期化
\r
3271 frame.setFrame(0);
\r
3272 ele.setAttributeNS(null, "begin", "indefinite");
\r
3273 ele.setAttributeNS(null, "dur", "1s");
\r
3274 ele.setAttributeNS(null, "dur", "1s");
\r
3275 ele.setAttributeNS(null, "attributeName", "fill");
\r
3276 ele.setAttributeNS(null, "fill", "freeze");
\r
3277 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3278 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3279 $animate.init(ele);
\r
3281 /*境界条件を調べておく (limit value analysis)*/
\r
3282 it("should be this for the value (limit value analysis)", function() {
\r
3283 expect(ele.beginElement()).toBeUndefined();
\r
3284 var cur = frame.currentFrame,
\r
3285 begin = frame.$begin.$1;
\r
3286 expect(begin.string).toBe("indefinite");
\r
3287 expect(begin.begin).toBe(cur);
\r
3288 expect(ele.endElement()).toBeUndefined();
\r
3290 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3291 it("should be this for the value (the valid partion )", function() {
\r
3292 ele.addEventListener("beginEvent", function(evt){
\r
3293 expect(evt.target.nodeName).toBe("animate");
\r
3295 ele.beginElement();
\r