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
211 expect(frame.state).toBe(frame.WAITING);
\r
212 expect(frame.begin).toBe(0);
\r
213 expect(frame.init()).toBe(frame);
\r
216 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
217 it("should be this for the value (the valid partion)", function() {
\r
219 function appendBegin(num) {
\r
220 frame.state = frame.WAITING;
\r
221 frame.beginList = {
\r
223 next: frame.beginList
\r
227 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
228 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
229 expect(frame.begin).toBe(0);
\r
230 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
231 expect(frame.state).toBe(frame.PLAYING);
\r
232 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
233 expect(frame.state).toBe(frame.PLAYING);
\r
235 frame.state = frame.WAITING;
\r
236 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
237 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
238 expect(frame.state).toBe(frame.BEGINNING);
\r
239 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
240 expect(frame.state).toBe(frame.PLAYING);
\r
241 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
242 expect(frame.state).toBe(frame.PLAYING);
\r
243 expect(frame.updateState(3).state).toBe(frame.PLAYING);
\r
244 expect(frame.state).toBe(frame.PLAYING);
\r
245 expect(frame.updateState(4).state).toBe(frame.PLAYING);
\r
246 expect(frame.state).toBe(frame.PLAYING);
\r
249 expect(frame.getMaxList(1, frame.beginList)).toBe(1);
\r
250 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
251 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
252 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
253 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
254 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
255 expect(frame.state).toBe(frame.BEGINNING);
\r
256 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
257 expect(frame.state).toBe(frame.PLAYING);
\r
258 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
259 expect(frame.state).toBe(frame.PLAYING);
\r
260 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
263 frame.state = frame.WAITING;
\r
264 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
265 expect(frame.begin).toBe(0);
\r
266 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
267 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
268 expect(frame.begin).toBe(0);
\r
269 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
270 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
271 expect(frame.begin).toBe(1);
\r
272 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
273 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
275 function appendEnd(num) {
\r
276 frame.state = frame.WAITING;
\r
280 next: frame.endList
\r
284 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
285 expect(frame.state).toBe(frame.BEGINNING);
\r
286 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
287 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
288 expect(frame.state).toBe(frame.PLAYING);
\r
289 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
290 expect(frame.state).toBe(frame.ENDING);
\r
291 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
292 expect(frame.state).toBe(frame.POSTWAITING);
\r
295 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
296 expect(frame.state).toBe(frame.BEGINNING);
\r
297 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
298 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
299 expect(frame.state).toBe(frame.PLAYING);
\r
300 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
301 expect(frame.state).toBe(frame.ENDING);
\r
302 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
303 expect(frame.state).toBe(frame.POSTWAITING);
\r
304 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
305 expect(frame.state).toBe(frame.POSTWAITING);
\r
308 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
309 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
310 expect(frame.updateState(1).state).toBe(frame.POSTWAITING);
\r
312 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
313 it("should be this for the value (the invalid partion)", function() {
\r
314 expect(frame.updateState()).toBe(frame);
\r
315 expect(frame.updateState(null)).toBe(frame);
\r
317 describe("the setFrame method (override)", function() {
\r
318 var frame = base("$frame").$list.up("$3");
\r
319 beforeEach( function() {
\r
320 frame.timelines = [];
\r
321 frame.isPaused = false;
\r
322 frame.state = frame.WAITING;
\r
325 afterEach( function() {
\r
326 frame.timelines = [];
\r
327 frame.beginList = frame.$list.beginList;
\r
328 frame.endList = frame.$list.endList;
\r
329 frame.currentFrame = 0;
\r
331 /*境界条件を調べておく (limit value analysis)*/
\r
332 it("should be this for the value (limit value analysis)", function() {
\r
333 expect(typeof frame.setFrame).toBe("function");
\r
334 expect(frame.currentFrame).toBe(0);
\r
337 expect(frame.state).toBe(frame.WAITING);
\r
338 expect(frame.currentFrame).toBe(0);
\r
340 expect(frame.state).toBe(frame.WAITING);
\r
341 expect(frame.currentFrame).toBe(1);
\r
343 expect(typeof frame.addEvent).toBe("function");
\r
344 expect(typeof frame.addBeginList).toBe("function");
\r
345 expect(typeof frame.addEndList).toBe("function");
\r
347 expect(frame.addBeginList(1).value).toBe(1);
\r
348 expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);
\r
349 expect(frame.addEndList(1).value).toBe(1);
\r
350 expect(frame.endList.next.value).toBe(Number.MAX_VALUE);
\r
355 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
356 it("should be this for the value (the valid partion)", function() {
\r
357 function appendBegin(num) {
\r
358 frame.state = frame.WAITING;
\r
359 frame.addBeginList(num);
\r
362 expect(frame.currentFrame).toBe(0);
\r
364 expect(frame.currentFrame).toBe(0);
\r
365 expect(frame.state).toBe(frame.PLAYING);
\r
367 expect(frame.currentFrame).toBe(1);
\r
368 expect(frame.state).toBe(frame.PLAYING);
\r
373 expect(frame.state).toBe(frame.PLAYING);
\r
375 expect(frame.state).toBe(frame.PLAYING);
\r
377 expect(frame.state).toBe(frame.PLAYING);
\r
379 function appendEnd(num) {
\r
380 frame.state = frame.WAITING;
\r
382 frame.addEndList(num);
\r
387 expect(frame.state).toBe(frame.PLAYING);
\r
389 expect(frame.state).toBe(frame.PLAYING);
\r
391 expect(frame.state).toBe(frame.PLAYING);
\r
393 expect(frame.state).toBe(frame.POSTWAITING);
\r
395 expect(frame.state).toBe(frame.POSTWAITING);
\r
399 expect(frame.state).toBe(frame.PLAYING);
\r
401 expect(frame.state).toBe(frame.PLAYING);
\r
403 expect(frame.state).toBe(frame.PLAYING);
\r
405 expect(frame.state).toBe(frame.POSTWAITING);
\r
407 expect(frame.state).toBe(frame.POSTWAITING);
\r
409 expect(frame.state).toBe(frame.PLAYING);
\r
411 expect(frame.state).toBe(frame.PLAYING);
\r
415 expect(frame.state).toBe(frame.PLAYING);
\r
416 expect(frame.currentFrame).toBe(0);
\r
418 expect(frame.state).toBe(frame.PLAYING);
\r
419 expect(frame.currentFrame).toBe(1);
\r
421 expect(frame.state).toBe(frame.PLAYING);
\r
422 expect(frame.currentFrame).toBe(2);
\r
424 expect(frame.state).toBe(frame.POSTWAITING);
\r
426 expect(frame.state).toBe(frame.POSTWAITING);
\r
428 expect(frame.state).toBe(frame.PLAYING);
\r
430 expect(frame.state).toBe(frame.POSTWAITING);
\r
431 expect(frame.currentFrame).toBe(6);
\r
434 for (var i=0;i<10000;++i) {
\r
438 frame.beginList = base("$frame").$listbeginList;
\r
439 frame.endList = base("$frame").$list.endList;
\r
440 frame.state = frame.WAITING;
\r
442 var obj = { name: "", value: 0};
\r
443 frame.addEvent("begin", function(evt) { obj.name = "a";});
\r
444 frame.beginList = {
\r
446 next: frame.beginList
\r
449 expect(frame.currentFrame).toBe(0);
\r
450 expect(frame.state).toBe(frame.PLAYING);
\r
451 expect(obj.name).toBe("a");
\r
452 frame.addEvent("play", function(evt) { obj.name = "b";});
\r
454 expect(frame.state).toBe(frame.PLAYING);
\r
455 expect(obj.name).toBe("b");
\r
456 frame.addEvent("end", function(evt) { obj.value = 1;});
\r
459 next: frame.endList
\r
462 expect(frame.currentFrame).toBe(0);
\r
463 expect(frame.state).toBe(frame.POSTWAITING);
\r
464 expect(obj.value).toBe(1);
\r
466 frame.addEvent("begin", function(evt) {
\r
467 expect(evt.state).toBe(frame.BEGINNING);
\r
470 frame.addEvent("end", function(evt) {
\r
471 expect(evt.state).toBe(frame.ENDING);
\r
474 frame.addEvent("play", function(evt) {
\r
475 expect(evt.state).toBe(frame.PLAYING);
\r
483 frame.state = frame.WAITING;
\r
484 expect(frame.getMaxList(12, frame.endList)).toBe(0);
\r
485 frame.setFrame(12);
\r
486 expect(frame.state).toBe(frame.POSTWAITING);
\r
489 /*addBeginListメソッドのチェックなど*/
\r
490 expect(frame.addBeginList(1).value).toBe(1);
\r
491 expect(frame.addBeginList(0).value).toBe(0);
\r
492 expect(frame.beginList.next.value).toBe(1);
\r
493 expect(frame.addBeginList(2).value).toBe(2);
\r
494 expect(frame.beginList.next.value).toBe(0);
\r
496 expect(frame.addEndList(1).value).toBe(1);
\r
497 expect(frame.addEndList(0).value).toBe(0);
\r
498 expect(frame.endList.next.value).toBe(1);
\r
499 expect(frame.addEndList(2).value).toBe(2);
\r
500 expect(frame.endList.next.value).toBe(0);
\r
504 describe("$begin object", function() {
\r
505 var begin = base("$frame").$begin.up();
\r
506 /*境界条件を調べておく (limit value analysis)*/
\r
507 it("should be this for the value (limit value analysis)", function() {
\r
508 expect(begin.string).toBe("");
\r
509 expect(begin.isResolved).toBeFalsy();
\r
510 expect(begin.eventTarget).toBe(document.documentElement);
\r
511 expect(begin.eventOffset).toBe(0);
\r
512 expect(begin.repeat).toBe(0);
\r
513 expect(begin.accessKey).toBe("");
\r
515 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
516 it("should be this for the value (the valid partion)", function() {
\r
517 begin.string = " hoge ";
\r
518 expect(begin.string).toBe(" hoge ");
\r
519 var $list = begin.$list;
\r
520 expect(begin.$list).toBe($list);
\r
521 expect(begin.updateList().$list).not.toBe($list);
\r
523 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
524 it("should be this for the value (the invalid partion)", function() {
\r
527 describe("A trim method in $begin object", function() {
\r
528 /*境界条件を調べておく (limit value analysis)*/
\r
529 beforeEach( function() {
\r
532 it("should be this for the value (limit value analysis)", function() {
\r
533 delete begin.string;
\r
534 expect(begin.trim(" ")).toBe("");
\r
535 expect( function() {
\r
539 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
540 it("should be this for the value (the valid partion)", function() {
\r
541 expect(begin.trim(" hoge ")).toBe("hoge");
\r
542 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
543 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
544 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
546 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
547 it("should be this for the value (the invalid partion)", function() {
\r
548 expect( function() {
\r
551 expect( function() {
\r
557 describe("An offset method in $begin object", function() {
\r
558 beforeEach( function() {
\r
561 /*境界条件を調べておく (limit value analysis)*/
\r
562 it("should be this for the value (limit value analysis)", function() {
\r
563 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
564 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
565 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
566 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
567 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
568 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
570 expect(begin.offset("+0s")).toBe(0);
\r
571 expect(begin.offset("-0s")).toBe(0);
\r
572 expect(begin.offset("1s")).toBe(1000);
\r
573 expect(begin.offset("-1s")).toBe(-1000);
\r
575 expect(begin.offset("+0min")).toBe(0);
\r
576 expect(begin.offset("-0min")).toBe(0);
\r
577 expect(begin.offset("1min")).toBe(60000);
\r
578 expect(begin.offset("-1min")).toBe(-60000);
\r
580 expect(begin.offset("+0h")).toBe(0);
\r
581 expect(begin.offset("-0h")).toBe(0);
\r
582 expect(begin.offset("1h")).toBe(60*60*1000);
\r
583 expect(begin.offset("-1h")).toBe(-3600000);
\r
585 expect(begin.offset("00:0")).toBe(0);
\r
586 expect(begin.offset("00:00:0.0")).toBe(0);
\r
587 expect(begin.offset("-00:0")).toBe(0);
\r
588 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
589 expect(begin.offset("00:1")).toBe(1000);
\r
590 expect(begin.offset("-00:1")).toBe(-1000);
\r
591 expect(begin.offset("00:00:1")).toBe(1000);
\r
592 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
594 expect(begin.offset()).toBe(0);
\r
596 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
597 it("should be this for the value (the valid partion)", function() {
\r
598 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
599 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
600 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
601 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
603 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
604 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
605 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
606 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
607 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
609 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
610 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
611 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
612 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
613 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
615 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
616 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
617 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
618 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
619 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
621 expect(begin.offset("01:0")).toBe(60000);
\r
622 expect(begin.offset("-01:0")).toBe(-60000);
\r
623 expect(begin.offset("00:00:1")).toBe(1000);
\r
624 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
625 expect(begin.offset("00:01:0")).toBe(60000);
\r
626 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
627 expect(begin.offset("01:00:0")).toBe(3600000);
\r
628 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
629 expect(begin.offset("00:10")).toBe(10000);
\r
630 expect(begin.offset("00:0.01")).toBe(10);
\r
631 expect(begin.offset("01:0.01")).toBe(60010);
\r
632 expect(begin.offset("10:0")).toBe(600000);
\r
633 expect(begin.offset("-00:10")).toBe(-10000);
\r
634 expect(begin.offset("-00:0.01")).toBe(-10);
\r
635 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
636 expect(begin.offset("-10:0")).toBe(-600000);
\r
637 expect(begin.offset("00:00:20")).toBe(20000);
\r
638 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
639 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
640 expect(begin.offset("-10:0")).toBe(-600000);
\r
641 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
643 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
644 it("should be this for the value (the invalid partion)", function() {
\r
645 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
646 expect(begin.offset("ms")).toBe(0);
\r
647 expect(begin.offset(".s")).toBe(0);
\r
648 expect(begin.offset("10:")).toBe(0);
\r
649 expect(begin.offset("::")).toBe(0);
\r
650 expect(begin.offset("-:0")).toBe(0);
\r
651 expect(begin.offset("-::0")).toBe(0);
\r
654 describe("An event method in $begin object", function() {
\r
655 /*境界条件を調べておく (limit value analysis)*/
\r
656 it("should be this for the value (limit value analysis)", function() {
\r
657 var evt = begin.event();
\r
658 expect(evt.id).toBe("");
\r
659 expect(evt.event).toBe("");
\r
660 evt = begin.event("");
\r
661 expect(evt.id).toBe("");
\r
662 expect(evt.event).toBe("");
\r
663 evt = begin.event(".");
\r
664 expect(evt.id).toBe("");
\r
665 expect(evt.event).toBe("");
\r
667 evt = begin.event("a");
\r
668 expect(evt.id).toBe("");
\r
669 expect(evt.event).toBe("a");
\r
670 evt = begin.event("a.b");
\r
671 expect(evt.id).toBe("a");
\r
672 expect(evt.event).toBe("b");
\r
674 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
675 it("should be this for the value (the valid partion)", function() {
\r
676 var evt = begin.event("id.event");
\r
677 expect(evt.id).toBe("id");
\r
678 expect(evt.event).toBe("event");
\r
679 evt = begin.event("event");
\r
680 expect(evt.id).toBe("");
\r
681 expect(evt.event).toBe("event");
\r
683 evt = begin.event("event+0s");
\r
684 expect(evt.id).toBe("");
\r
685 expect(evt.event).toBe("event");
\r
686 evt = begin.event("event-0s");
\r
687 expect(evt.id).toBe("");
\r
688 expect(evt.event).toBe("event");
\r
690 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
691 it("should be this for the value (the invalid partion)", function() {
\r
692 evt = begin.event("...");
\r
693 expect(evt.id).toBe("");
\r
694 expect(evt.event).toBe("");
\r
695 evt = begin.event(".event");
\r
696 expect(evt.id).toBe("");
\r
697 expect(evt.event).toBe("");
\r
698 evt = begin.event("id.");
\r
699 expect(evt.id).toBe("");
\r
700 expect(evt.event).toBe("");
\r
704 describe("An parse method in $begin object", function() {
\r
705 beforeEach( function() {
\r
708 /*境界条件を調べておく (limit value analysis)*/
\r
709 it("should be this for the value (limit value analysis)", function() {
\r
710 expect(begin.parse().begin).toBe(0);
\r
711 expect(begin.isResolved).toBeTruthy();
\r
713 expect(begin.parse().begin).toBe(0);
\r
714 begin.string = "+1";
\r
715 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
716 begin.string = " ";
\r
717 expect(begin.parse().begin).toBe(0);
\r
718 begin.string = "1";
\r
719 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
720 begin.string = "+0ms";
\r
721 expect(begin.parse().begin).toBe(0);
\r
722 begin.string = "-0ms";
\r
723 expect(begin.parse().begin).toBe(0);
\r
724 begin.string = "-0ms;-0ms";
\r
725 expect(begin.parse().begin).toBe(0);
\r
726 begin.string = "-0ms;1";
\r
727 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
729 expect(begin.eventOffset).toBe(0);
\r
730 begin.string = "click";
\r
731 expect(begin.parse().begin).toBe(0);
\r
732 expect(begin.eventOffset).toBe(0);
\r
733 expect(begin.repeat).toBe(0);
\r
734 expect(begin.accessKey).toBe("");
\r
735 begin.string = "id.click";
\r
736 expect(begin.parse().begin).toBe(0);
\r
737 expect(begin.eventOffset).toBe(0);
\r
738 expect(begin.repeat).toBe(0);
\r
739 expect(begin.accessKey).toBe("");
\r
741 begin.string = "repeat";
\r
742 expect(begin.parse().begin).toBe(0);
\r
743 expect(begin.eventOffset).toBe(0);
\r
744 expect(begin.repeat).toBe(0);
\r
745 expect(begin.accessKey).toBe("");
\r
746 begin.string = "repeat(1)";
\r
747 expect(begin.parse().begin).toBe(0);
\r
748 expect(begin.eventOffset).toBe(0);
\r
749 expect(begin.repeat).toBe(1);
\r
750 expect(begin.accessKey).toBe("");
\r
752 begin.string = "accessKey(a)";
\r
753 expect(begin.parse().begin).toBe(0);
\r
754 expect(begin.eventOffset).toBe(0);
\r
755 expect(begin.repeat).toBe(0);
\r
756 expect(begin.accessKey).toBe("a");
\r
758 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
759 it("should be this for the value (the valid partion)", function() {
\r
760 begin.string = " 1 0 0 m s";
\r
761 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
763 begin.string = "1ms";
\r
764 begin.isResolved = false;
\r
765 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
766 expect(begin.isResolved).toBeTruthy();
\r
767 expect(begin.eventOffset).toBe(0);
\r
769 begin.string="click+0";
\r
770 expect(begin.parse().begin).toBe(0);
\r
771 expect(begin.eventOffset).toBe(0);
\r
772 expect(begin.isResolved).toBeFalsy();
\r
773 begin.string = "click+1";
\r
774 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
775 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
776 begin.string = " click ";
\r
777 expect(begin.parse().begin).toBe(0);
\r
778 expect(begin.eventOffset).toBe(0);
\r
779 begin.string = "click+0ms";
\r
780 expect(begin.parse().begin).toBe(0);
\r
781 expect(begin.eventOffset).toBe(0);
\r
782 expect(begin.isResolved).toBeFalsy();
\r
783 begin.string = "click-0ms";
\r
784 expect(begin.parse().begin).toBe(0);
\r
785 expect(begin.eventOffset).toBe(0);
\r
786 begin.string = "click+100ms";
\r
787 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
788 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
789 begin.string = "click-100ms";
\r
790 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
791 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
793 begin.string="id.click+0";
\r
794 expect(begin.parse().begin).toBe(0);
\r
795 expect(begin.eventOffset).toBe(0);
\r
796 expect(begin.isResolved).toBeFalsy();
\r
797 begin.string = "id.click+1";
\r
798 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
799 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
800 expect(begin.isResolved).toBeFalsy();
\r
801 begin.string = " id . click ";
\r
802 expect(begin.parse().begin).toBe(0);
\r
803 expect(begin.eventOffset).toBe(0);
\r
804 expect(begin.isResolved).toBeFalsy();
\r
805 begin.string = "id.click+0ms";
\r
806 expect(begin.parse().begin).toBe(0);
\r
807 expect(begin.eventOffset).toBe(0);
\r
808 begin.string = "id.click-0ms";
\r
809 expect(begin.parse().begin).toBe(0);
\r
810 expect(begin.eventOffset).toBe(0);
\r
811 begin.string = "id.click+100ms";
\r
812 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
813 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
814 begin.string = "id.click-100ms";
\r
815 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
816 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
818 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
819 it("should be this for the value (the invalid partion)", function() {
\r
820 begin.string = "ms";
\r
821 begin.isResolved = false;
\r
822 expect(begin.parse().begin).toBe(0);
\r
823 expect(begin.isResolved).toBeFalsy();
\r
825 begin.isResolved = true;
\r
826 begin.string = "indefinite";
\r
827 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
828 expect(begin.isResolved).toBeFalsy();
\r
832 describe("A $end object", function() {
\r
833 var end = base("$frame").$begin.$end.up();
\r
835 beforeEach( function() {
\r
837 end.startTime = Date.now();
\r
840 /*境界条件を調べておく (limit value analysis)*/
\r
841 it("should be this for the value (limit value analysis)", function() {
\r
842 expect(end.up().call()).toBeNull();
\r
844 expect(end.up().call()).toBe(0);
\r
845 end.string = "hoge";
\r
846 expect(end.up().call()).toBe("indefinite");
\r
849 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
850 it("should be this for the value (the valid partion)", function() {
\r
851 end.string = "hoge+0";
\r
852 expect(end.up().call()).toBe("indefinite");
\r
853 end.string = "12ms";
\r
854 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
855 end.string = "hoge+12ms";
\r
856 expect(end.up().call()).toBe("indefinite");
\r
859 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
860 it("should be this for the value (the invalid partion)", function() {
\r
862 expect(end.up().call()).toBeNull();
\r
865 describe("A $activate object", function() {
\r
866 var act = base("$frame").$begin.$activate.up();
\r
867 beforeEach( function() {
\r
868 act.dur = "indefinite";
\r
870 act.repeatCount = null;
\r
871 act.repeatDur = null;
\r
872 act.end = act.$begin.$end;
\r
873 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
875 /*境界条件を調べておく (limit value analysis)*/
\r
876 it("should be this for the value (limit value analysis)", function() {
\r
877 expect(act.dur).toBe("indefinite");
\r
878 expect(typeof act.resolvedTime).toBe("function");
\r
879 expect(act.end).toBe(act.$begin.$end);
\r
880 expect(act.repeatCount).toBeNull();
\r
881 expect(act.repeatDur).toBeNull();
\r
882 expect(act.simpleDur()).toBeNull();
\r
883 expect(act.min).toBe("0");
\r
884 expect(act.max).toBe("indefinite");
\r
887 expect(act.$a.call()).toBeNull();
\r
888 expect(act.$a.end).toBeNull();
\r
890 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
891 it("should be this for the value (the valid partion)", function() {
\r
892 expect(act.resolvedTime()).not.toBe(0);
\r
894 /*Activate Duration = dur*/
\r
896 act.$b.dur = "132ms";
\r
897 var abc = act.$b.call();
\r
898 expect(abc).toBe(Math.floor(132*act.fpms));
\r
899 expect(abc).toBe(act.$b.simpleDur);
\r
901 expect(act.up().call()).toBeNull();
\r
906 simpleDur: act.simpleDur,
910 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
911 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
914 simpleDur: act.simpleDur,
918 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
920 /*AD = repeatCount*dur*/
\r
923 simpleDur: act.simpleDur,
928 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
931 simpleDur: act.simpleDur,
935 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
936 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
941 simpleDur: act.simpleDur,
946 expect(act.$c.simpleDur).toBeNull();
\r
949 simpleDur: act.simpleDur,
953 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
954 expect(act.$c.simpleDur).toBeNull();
\r
957 simpleDur: act.simpleDur,
962 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
965 simpleDur: act.simpleDur,
969 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
970 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
972 /*AD = Min(repeatCount*d, repeatDur)*/
\r
975 simpleDur: act.simpleDur,
980 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
983 simpleDur: act.simpleDur,
987 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
988 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
991 simpleDur: act.simpleDur,
995 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
996 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
998 /*AD = repeatDur,*/
\r
1002 simpleDur: act.simpleDur,
1003 repeatCount: null,
\r
1006 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
1007 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1009 dur: "indefinite",
\r
1010 simpleDur: act.simpleDur,
1014 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1015 expect(act.$c.simpleDur).toBeNull();
\r
1017 act.end.string = null;
\r
1018 act.up("$cd").mix( {
\r
1023 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
1025 act.$cd.end = act.end;
\r
1026 act.$cd.repeatCount = null;
\r
1027 act.$cd.repeatDur = "12";
\r
1028 expect(act.$cd.call()).toBe(Math.floor(12000*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
1037 act.up("$d").mix( {
\r
1041 simpleDur: act.simpleDur
\r
1043 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1045 /*endで0が指定されている場合*/
\r
1048 act.repeatDur = null;
\r
1049 act.repeatCount = "indefinite";
\r
1051 expect(act.call()).toBeNull();
\r
1052 act.repeatCount = null;
\r
1053 act.repeatDur = "indefinite";
\r
1055 expect(act.call()).toBeNull();
\r
1056 act.repeatDur = "indefinite";
\r
1057 act.repeatCount = "indefinite";
\r
1059 expect(act.call()).toBeNull();
\r
1061 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1062 it("should be this for the value (the invalid partion)", function() {
\r
1064 act.up("$d").mix( {
\r
1068 simpleDur: act.simpleDur
\r
1070 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
1072 act.repeatDur = null;
\r
1073 act.repeatCount = "indefinite";
\r
1075 expect(act.call()).toBeNull();
\r
1076 act.repeatCount = null;
\r
1077 act.repeatDur = "indefinite";
\r
1079 expect(act.call()).toBeNull();
\r
1080 act.repeatDur = "indefinite";
\r
1081 act.repeatCount = "indefinite";
\r
1083 expect(act.call()).toBeNull();
\r
1086 describe("A $from object", function() {
\r
1087 var from = base("$from");
\r
1088 beforeEach( function() {
\r
1089 from = base("$from").up();
\r
1090 from.from = from.from.up();
\r
1093 /*境界条件を調べておく (limit value analysis)*/
\r
1094 it("should be this for the value (limit value analysis)", function() {
\r
1095 expect(from.string).toBe("");
\r
1096 expect(from.numList()).toEqual([]);
\r
1097 expect(from.strList()).toBeNull();
\r
1099 from.string = "0";
\r
1100 expect(from.numList()[0]).toBe(0);
\r
1101 expect(from.strList()).toBeNull();
\r
1103 from.string = " 0 ";
\r
1104 expect(from.numList()[0]).toBe(0);
\r
1105 expect(from.strList().join("")).toBe(" ");
\r
1107 from.string = "a";
\r
1108 expect(from.numList()).toEqual([]);
\r
1109 expect(from.strList()[0]).toBe("a");
\r
1111 /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから
\r
1112 * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/
\r
1114 from.string = null;
\r
1115 expect( function() {
\r
1118 expect( function() {
\r
1122 expect(from.additive[0]).toBe(0);
\r
1123 expect(from.accumulate[0]).toBe(0);
\r
1125 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1126 it("should be this for the value (the valid partion)", function() {
\r
1127 from.string = "0a";
\r
1128 expect(from.numList()[0]).toBe(0);
\r
1129 expect(from.strList()[0]).toBe("a");
\r
1131 from.string = "a0";
\r
1132 expect(from.numList()[0]).toBe(0);
\r
1133 expect(from.strList()[0]).toBe("a");
\r
1135 from.string = "0.1";
\r
1136 expect(from.numList()[0]).toBe(0.1);
\r
1137 expect(from.strList()).toBeNull();
\r
1139 from.string = "+0.1";
\r
1140 expect(from.numList()[0]).toBe(0.1);
\r
1141 expect(from.strList()).toBeNull();
\r
1143 from.string = "-0.1";
\r
1144 expect(from.numList()[0]).toBe(-0.1);
\r
1145 expect(from.strList()).toBeNull();
\r
1147 from.string = "1e-1";
\r
1148 expect(from.numList()[0]).toBe(1e-1);
\r
1149 expect(from.strList()).toBeNull();
\r
1151 from.string = "1E-1";
\r
1152 expect(from.numList()[0]).toBe(1E-1);
\r
1153 expect(from.strList()).toBeNull();
\r
1155 from.string = "0,0";
\r
1156 expect(from.numList().toString()).toBe("0,0");
\r
1157 expect(from.strList().join("")).toBe(",");
\r
1159 from.string = "a00a";
\r
1160 expect(from.numList()[0]).toBe(0);
\r
1161 expect(from.strList().join("")).toBe("aa");
\r
1163 from.string = "a0b0a";
\r
1164 expect(from.numList().toString()).toBe("0,0");
\r
1165 expect(from.strList().join("")).toBe("aba");
\r
1167 from.string = "0b0a";
\r
1168 expect(from.numList().toString()).toBe("0,0");
\r
1169 expect(from.strList().join("")).toBe("ba");
\r
1171 from.string = "0b-1.0a";
\r
1172 expect(from.numList()[1]).toBe(-1);
\r
1173 expect(from.strList().join("")).toBe("ba");
\r
1175 expect(from.up().call()).toBe(from.$1.numList);
\r
1176 expect(from.$1.numList[1]).toBe(-1);
\r
1177 expect(from.$1.strList.join("")).toBe("ba");
\r
1179 from.string = "あ 0b-1.0a12";
\r
1180 expect(from.numList()[1]).toBe(-1);
\r
1181 expect(from.strList().join("")).toBe("あ ba12");
\r
1183 from.string = "0b-1.0a0";
\r
1184 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1185 expect(from.strList().join("")).toBe("ba");
\r
1187 from.string = "0b .1a";
\r
1188 expect(from.numList()[1]).toBe(0.1);
\r
1189 expect(from.strList().join("")).toBe("b a");
\r
1191 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1192 it("should be this for the value (the invalid partion)", function() {
\r
1193 from.string = NaN;
\r
1194 expect(function(){
\r
1197 expect(function(){
\r
1201 from.string = "currentColor";
\r
1202 expect(from.numList()).toEqual([]);
\r
1203 expect(from.strList()[0]).toBe("currentColor");
\r
1205 from.string = "eE";
\r
1206 expect(from.numList()).toEqual([]);
\r
1207 expect(from.strList()[0]).toBe("eE");
\r
1208 expect(from.strList()[0]).toBe("eE");
\r
1211 describe("A $to object", function() {
\r
1212 var from = base("$from");
\r
1213 beforeEach( function() {
\r
1214 from = base("$from").up();
\r
1218 /*境界条件を調べておく (limit value analysis)*/
\r
1219 it("should be this for the value (limit value analysis)", function() {
\r
1220 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1221 expect(from.up().call()).toBe(from.$1.numList);
\r
1222 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1224 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1225 it("should be this for the value (the valid partion)", function() {
\r
1227 from.$to.from = from;
\r
1228 from.$to.string = "12cm-7";
\r
1229 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1230 expect(from.$to.strList().toString()).toBe("cm");
\r
1232 from.string = "7cm+8";
\r
1234 expect(from.call()).toBe(from.numList);
\r
1235 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1236 expect(from.$to.strList.join("")).toBe("cm");
\r
1237 expect(from.numList.join(",")).toBe("7,8");
\r
1238 expect(from.strList.join("")).toBe("cm");
\r
1239 expect(from.$to.from).toBe(from.numList);
\r
1242 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1243 it("should be this for the value (the invalid partion)", function() {
\r
1245 from.up("$to").mix( function() {
\r
1246 this.string = "12cm";
\r
1249 arr.string = this.string;
\r
1250 expect(this.numList).toEqual(arr);
\r
1251 expect(this.strList).toBeNull();
\r
1255 describe("An advance method", function() {
\r
1256 var from = base("$from");
\r
1257 beforeEach( function() {
\r
1258 from = base("$from").up();
\r
1261 from.$to.from = from;
\r
1263 /*境界条件を調べておく (limit value analysis)*/
\r
1264 it("should be this for the value (limit value analysis)", function() {
\r
1265 expect(from.advance()).toBe("");
\r
1266 expect(from.$to.advance()).toBe("");
\r
1267 expect(from.$to.advance(0)).toBe("");
\r
1268 expect(from.$to.advance(1)).toBe("");
\r
1269 expect(function(){
\r
1270 from.$to.advance(1.01);
\r
1271 }).toThrow("An Invalid Number Error");
\r
1272 expect(function(){
\r
1273 from.$to.advance(-0.01);
\r
1274 }).toThrow("An Invalid Number Error");
\r
1278 from = base("$from").up();
\r
1280 from.$to.from = from;
\r
1281 arr.string = from.string = "0";
\r
1282 from.$to.string = "1";
\r
1283 expect(from.$to.call()).toBe(from.$to.numList);
\r
1284 expect(from.$to.numList[0]).toBe(1);
\r
1285 expect(from.$to.strList).toBeNull();
\r
1286 expect(from.numList[0]).toBe(0);
\r
1287 expect(from.strList).toBeNull();
\r
1288 expect(from.advance(0)).toBe("");
\r
1289 expect(from.$to.from).toBe(from.numList);
\r
1290 expect(from.$to.advance(0)).toBe("0");
\r
1291 expect(from.call()).toBe(from.numList);
\r
1293 from = base("$from").up();
\r
1294 f(from.up(), "inline", "block");
\r
1295 f(from.up(), " inline", " block ");
\r
1296 function f(from, inline, block) {
\r
1298 from.$to.from = from;
\r
1299 from.string = inline;
\r
1300 arr.string = from.$to.string = block;
\r
1301 expect(from.$to.call()).toBe(from.$to.numList);
\r
1302 expect(from.$to.numList).toEqual(arr);
\r
1303 expect(from.$to.strList).toEqual([block]);
\r
1304 arr.string = from.string;
\r
1305 expect(from.numList).toEqual(arr);
\r
1306 expect(from.strList).toEqual([inline]);
\r
1307 expect(from.advance(0)).toBe("");
\r
1308 expect(from.$to.from).toBe(from.numList);
\r
1309 expect(from.$to.advance(0)).toBe("inline");
\r
1310 expect(from.$to.advance(1)).toBe("block");
\r
1311 expect(from.call()).toBe(from.numList);
\r
1314 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1315 it("should be this for the value (the valid partion)", function() {
\r
1318 from.string = "0s";
\r
1319 from.$to.string = "1s";
\r
1320 expect(from.$to.call()).toBe(from.$to.numList);
\r
1321 expect(from.$to.numList[0]).toBe(1);
\r
1322 expect(from.$to.strList[0]).toBe("");
\r
1323 expect(from.numList[0]).toBe(0);
\r
1324 expect(from.strList[0]).toBe("");
\r
1325 expect(from.advance(0)).toBe("");
\r
1326 expect(from.$to.from).toBe(from.numList);
\r
1327 expect(from.$to.advance(0)).toBe("0s");
\r
1328 from.$to.degit = deg;
\r
1329 for (var i=0;i<1;i+=0.01) {
\r
1330 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1332 expect(from.call()).toBe(from.numList);
\r
1334 from = base("$from").up();
\r
1336 from.string = "a0S";
\r
1337 from.$to.string = "a1S";
\r
1338 from.$to.from = from;
\r
1339 expect(from.$to.call()).toBe(from.$to.numList);
\r
1340 expect(from.$to.numList[0]).toBe(1);
\r
1341 expect(from.$to.strList[0]).toBe("a");
\r
1342 expect(from.numList[0]).toBe(0);
\r
1343 expect(from.strList[0]).toBe("a");
\r
1344 expect(from.advance(0)).toBe("");
\r
1345 expect(from.$to.from).toBe(from.numList);
\r
1346 expect(from.$to.advance(0)).toBe("a0S");
\r
1348 from.$to.degit = deg;
\r
1349 for (var i=0;i<1;i+=0.01) {
\r
1350 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1352 expect(from.call()).toBe(from.numList);
\r
1354 from = base("$from").up();
\r
1355 f(from.up(), "a-10s1.5", "a10s-3");
\r
1356 f(from.up(), " a-10s1.5", " a10s-3 ");
\r
1357 function f(from, fromString, toString) {
\r
1359 from.string = fromString;
\r
1360 from.$to.string = toString;
\r
1361 from.$to.from = from;
\r
1363 from.$to.degit = 1;
\r
1364 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1365 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1366 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1368 from.$to.additive[0] = 1;
\r
1369 from.$to.accumulate[1] = 2;
\r
1370 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1371 from.$to.additive[0] = 0.5;
\r
1372 from.$to.accumulate[1] = 0.8;
\r
1373 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1376 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1377 it("should be this for the value (the invalid partion)", function() {
\r
1378 expect(function(){
\r
1379 from.$to.advance(10);
\r
1380 }).toThrow("An Invalid Number Error");
\r
1381 expect(function(){
\r
1382 from.$to.advance(-10);
\r
1383 }).toThrow("An Invalid Number Error");
\r
1387 describe("A distance method", function() {
\r
1388 var from = base("$from");
\r
1389 beforeEach( function() {
\r
1390 from = base("$from").up();
\r
1394 /*境界条件を調べておく (limit value analysis)*/
\r
1395 it("should be this for the value (limit value analysis)", function() {
\r
1396 expect(from.distance()).toBe(0)
\r
1397 expect(from.$to.distance()).toBe(0);
\r
1399 from.string = "0";
\r
1400 from.$to.string = "1";
\r
1401 expect(from.distance()).toBe(0);
\r
1402 expect(from.$to.distance(from)).toBe(1);
\r
1404 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1405 it("should be this for the value (the valid partion)", function() {
\r
1406 from.string = "s 0 s 12";
\r
1407 from.$to.string = "s 0 s 0";
\r
1408 expect(from.distance()).toBe(0);
\r
1409 expect(from.$to.distance(from)).toBe(12);
\r
1410 expect(from.$to.distance(from)).toBe(12);
\r
1411 expect(from.$to.distance(from.call())).toBe(12);
\r
1413 from = base("$from").up();
\r
1415 from.string = "rgb(1, 0, 0)";
\r
1416 from.$to.string = "rgb(0, 0, 1)";
\r
1417 expect(from.distance()).toBe(0);
\r
1418 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1420 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1421 it("should be this for the value (the invalid partion)", function() {
\r
1422 from.string = "s";
\r
1423 from.$to.string = "s";
\r
1424 expect(from.$to.distance(from)).toBe(0);
\r
1427 describe("A setAdditive method", function() {
\r
1428 var from = base("$from");
\r
1429 beforeEach( function() {
\r
1430 from = base("$from").up();
\r
1434 /*境界条件を調べておく (limit value analysis)*/
\r
1435 it("should be this for the value (limit value analysis)", function() {
\r
1436 expect(from.setAdditive()).toBe(0);
\r
1437 expect(from.setAdditive("")).toBe(0);
\r
1438 expect(from.additive).toEqual([0]);
\r
1441 expect(from.setAdditive("1")).toEqual(arr);
\r
1442 expect(from.additive).toEqual(arr);
\r
1444 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1445 it("should be this for the value (the valid partion)", function() {
\r
1446 var arr = [1, 2, 3];
\r
1447 arr.string = "1 2, 3";
\r
1448 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1449 expect(from.additive).toEqual(arr);
\r
1451 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1452 it("should be this for the value (the invalid partion)", function() {
\r
1455 describe("A setAccumulate method", function() {
\r
1456 var from = base("$from");
\r
1457 beforeEach( function() {
\r
1458 from = base("$from").up();
\r
1459 from.string = "0 1";
\r
1463 /*境界条件を調べておく (limit value analysis)*/
\r
1464 it("should be this for the value (limit value analysis)", function() {
\r
1465 expect(from.setAccumulate()).toBe(0);
\r
1466 expect(from.setAccumulate(0)).toBe(0);
\r
1467 expect(from.accumulate).toEqual([0, 0]);
\r
1468 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1469 expect(from.accumulate).toEqual([0, 1]);
\r
1471 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1472 it("should be this for the value (the valid partion)", function() {
\r
1473 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1474 expect(from.accumulate).toEqual([0, 2]);
\r
1476 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1477 it("should be this for the value (the invalid partion)", function() {
\r
1478 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1481 describe("A $calcMode object", function() {
\r
1482 var calc = base("$calcMode"),
\r
1485 beforeEach( function() {
\r
1486 calc = base("$calcMode").up();
\r
1487 calc.to = base("$from").up().mix( {string: "1"} );
\r
1488 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1490 /*境界条件を調べておく (limit value analysis)*/
\r
1491 it("should be this for the value (limit value analysis)", function() {
\r
1492 expect(calc.mode).toBe("linear");
\r
1493 expect(calc.keyTime).toBe(1);
\r
1494 expect(calc.keySplines).toBeNull();
\r
1495 expect(calc.string).toBe("");
\r
1497 expect(calc.call()(0)).toBe("0");
\r
1498 expect(calc.keyTime).toBe(1);
\r
1499 expect(calc.call()(1)).toBe("1");
\r
1502 expect(calc.call()(1)).toBe("0");
\r
1505 calc.mode = "paced";
\r
1506 expect(calc.norm).toBe(1);
\r
1507 calc.to.from = from;
\r
1508 expect(calc.call()(0)).toBe("0");
\r
1509 expect(calc.keyTime).toBe(1);
\r
1510 calc.to.from = from;
\r
1511 expect(calc.call()(1)).toBe("1");
\r
1514 calc.to.from = from;
\r
1515 expect(calc.call()(1)).toBe("1");
\r
1518 calc.mode = "discrete";
\r
1519 calc.to.from = from;
\r
1521 expect(calc.call()(0)).toBe("0");
\r
1522 expect(calc.call()(1)).toBe("1");
\r
1524 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1525 it("should be this for the value (the valid partion)", function() {
\r
1526 calc.mode = "linear";
\r
1527 calc.keyTime = 0.5;
\r
1528 calc.to.degit = 1;
\r
1529 expect(calc.call()(0.2)).toBe("0.4");
\r
1530 expect(calc.call()(0.3)).toBe("0.6");
\r
1532 expect(calc.call()(0.2)).toBe("0.4");
\r
1534 calc = base("$calcMode").up();
\r
1535 calc.keyTime = 0.2;
\r
1536 calc.to = base("$from").up();
\r
1537 calc.to.from = base("$from").up();
\r
1538 calc.to.from.string = "0s";
\r
1539 calc.to.string = "1s";
\r
1540 calc.to.degit = 1;
\r
1541 expect(calc.call()(0.1)).toBe("0.5s");
\r
1543 calc = base("$calcMode").up();
\r
1544 calc.keyTime = 0.5;
\r
1545 calc.to = base("$from").up();
\r
1546 calc.to.from = base("$from").up();
\r
1547 calc.to.from.string = "rgb(100, 20, 32)";
\r
1548 calc.to.string = "rgb(0, 10, 50)";
\r
1549 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1552 calc.to = base("$from").up();
\r
1553 calc.to.from = base("$from").up();
\r
1554 calc.mode = "paced";
\r
1556 calc.to.from.string = "0s";
\r
1557 calc.to.string = "20s";
\r
1558 calc.to.degit = 1;
\r
1559 expect(calc.call()(0.1)).toBe("10.0s");
\r
1560 expect(calc.keyTime).toBe(0.2);
\r
1562 calc.to = base("$from").up();
\r
1563 calc.to.from = base("$from").up();
\r
1564 calc.mode = "paced";
\r
1566 calc.to.from.string = "rgb(0, 0, 20)";
\r
1567 calc.to.string = "rgb(0, 0, 0)";
\r
1568 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1569 expect(calc.keyTime).toBe(0.2);
\r
1572 calc.to = base("$from").up();
\r
1573 calc.to.from = base("$from").up();
\r
1574 calc.mode = "discrete";
\r
1575 calc.keyTime = 0.5;
\r
1576 calc.to.degit = 1;
\r
1577 calc.to.string = "1";
\r
1578 calc.to.from.string = "0.5";
\r
1579 expect(calc.call()(0.2)).toBe("0.5");
\r
1580 expect(calc.call()(0.3)).toBe("0.5");
\r
1582 expect(calc.call()(0.2)).toBe("0.5");
\r
1584 calc.to = base("$from").up();
\r
1585 calc.to.from = base("$from").up();
\r
1586 calc.mode = "discrete";
\r
1587 calc.keyTime = 0.5;
\r
1588 calc.to.degit = 1;
\r
1589 calc.to.string = "block";
\r
1590 calc.to.from.string = "inline";
\r
1591 expect(calc.call()(0.2)).toBe("inline");
\r
1592 expect(calc.call()(0.3)).toBe("inline");
\r
1594 calc.to = base("$from").up();
\r
1595 calc.to.from = base("$from").up();
\r
1596 calc.mode = "linear";
\r
1598 calc.to.degit = 1;
\r
1599 calc.to.string = "1 1";
\r
1600 calc.to.from.string = "0.0 1";
\r
1601 expect(calc.call()(0.2)).toBe("0.2 1.0");
\r
1602 expect(calc.call()(0.3)).toBe("0.3 1.0");
\r
1604 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1605 it("should be this for the value (the invalid partion)", function() {
\r
1606 calc.keyTime = null;
\r
1607 expect(calc.call()(1)).toBe(calc.string);
\r
1609 calc.keyTime = void 0;
\r
1610 expect(calc.call()(1)).toBe(calc.string);
\r
1612 calc.keyTime = 1/0;
\r
1613 expect(calc.call()(1)).toBe(calc.string);
\r
1615 expect(calc.call()()).toBe(calc.string);
\r
1617 calc = base("$calcMode").up();
\r
1618 calc.mode = "paced";
\r
1619 calc.to.from = from;
\r
1620 expect(calc.call()()).toBe(calc.string);
\r
1622 calc = base("$calcMode").up();
\r
1623 calc.mode = "discrete";
\r
1624 expect(calc.call()()).toBe(calc.string);
\r
1627 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1628 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1629 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1632 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1633 return function (t) {
\r
1634 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1635 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1639 expect(calc.keySplines).toBeNull();
\r
1640 calc.mode = "spline";
\r
1641 expect( calc.call()("undef")).toBe(Math.PI);
\r
1642 calc.keySplines = [0, 0, 1, 1];
\r
1643 calc.to.degit = 1;
\r
1644 calc.to.from = from;
\r
1645 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1646 calc.to.from = from;
\r
1647 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1648 calc.to.from = from;
\r
1649 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1651 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1652 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1653 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1654 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1655 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1656 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1657 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1658 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1659 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1661 var a = y4-3*(y3-y2)-y1,
\r
1662 b = 3*(y3-2*y2+y1),
\r
1664 d = y1 - bezier.apply(null, arguments)(t);
\r
1665 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1668 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1669 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1672 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1673 return function (t) {
\r
1675 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1676 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1680 calc.mode = "spline";
\r
1681 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1682 calc.to.degit = 1;
\r
1683 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1684 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1685 calc.to.from = from;
\r
1686 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1687 calc.to.from = from;
\r
1688 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1690 var ff = function(k) {
\r
1691 calc.keySplines = k;
\r
1692 calc.to.degit = 10;
\r
1693 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1694 epsilon = 1e-5; //誤差
\r
1695 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1696 calc.to.from = from;
\r
1697 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1698 calc.to.from = from;
\r
1699 b = b(Math.random());
\r
1700 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1702 for (var i=0;i<10000;++i) {
\r
1703 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1707 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1708 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1709 calc.mode = "spline";
\r
1710 calc.keySplines = [0, NaN, 1, 1];
\r
1711 calc.to.degit = 1;
\r
1712 calc.to.from = from;
\r
1713 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1716 calc.keySplines = [0, 0, 1, 2];
\r
1717 calc.to.degit = 1;
\r
1718 calc.to.from = from;
\r
1719 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1721 calc.keySplines = null;
\r
1722 calc.to.degit = 1;
\r
1723 calc.to.from = from;
\r
1724 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1727 describe("A $attribute object", function() {
\r
1728 describe("A push method", function() {
\r
1730 beforeEach( function() {
\r
1731 attr = base("$calcMode").$attribute.up("width");
\r
1732 base("$frame").timelines.length = 0;
\r
1733 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1735 afterEach( function() {
\r
1736 attr.isCSS = false;
\r
1738 /*境界条件を調べておく (limit value analysis)*/
\r
1739 it("should be this for the value (limit value analysis)", function() {
\r
1740 expect(attr.element).toBeNull();
\r
1741 expect(attr.push()).toBeNull();
\r
1742 expect(attr.element).toBeNull();
\r
1743 expect(attr.isCSS).toBeFalsy();
\r
1744 expect(base("$frame").timelines.length).toBe(0);
\r
1746 expect(attr.push(s)).toBeNull();
\r
1747 expect(attr.element).toBeNull();
\r
1748 expect(base("$frame").timelines.length).toBe(0);
\r
1749 expect(attr.hasAttrValues()).toBeFalsy();
\r
1751 var p = document.createElement("g");
\r
1753 expect(attr.push(s)).toBeNull();
\r
1754 expect(attr.element).toBe(p);
\r
1755 expect(base("$frame").timelines.length).toBe(0);
\r
1757 s.setAttribute("end", "0");
\r
1761 check("values", 4);
\r
1762 function check(attrName, num) {
\r
1763 s.setAttribute(attrName, "1");
\r
1764 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1765 var fr = attr.push(s);
\r
1766 expect(attr.element).toBe(p);
\r
1767 var timelines = base("$frame").timelines;
\r
1768 expect(timelines.length).toBe(num);
\r
1769 var line = timelines[num-1];
\r
1770 expect(line).not.toBe(fr);
\r
1771 var act = fr.$activate;
\r
1772 expect(act.dur).toBeNull();
\r
1773 expect(act.repeatCount).toBeNull();
\r
1774 expect(act.repeatDur).toBeNull();
\r
1775 expect(act.min).toBe("0");
\r
1776 expect(act.max).toBe("indefinite");
\r
1777 expect(act.simpleDur).toBeNull();
\r
1778 expect(attr.hasAttrValues()).toBeTruthy();
\r
1780 s.removeAttribute(attrName);
\r
1781 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1783 expect(attr.element).toBe(p);
\r
1784 expect(timelines.length).toBe(num);
\r
1787 /*targetElement属性のサポート*/
\r
1788 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1789 document.documentElement.appendChild(p2);
\r
1790 p2.setAttributeNS(null, "id", "p23");
\r
1791 s.setAttributeNS(null, "targetElement", "p23");
\r
1793 expect(attr.element).toBe(p2);
\r
1796 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1797 document.documentElement.appendChild(p3);
\r
1798 p3.setAttributeNS(null, "id", "p34");
\r
1799 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1801 expect(attr.element).toBe(p3);
\r
1803 /*attributeType属性のサポート*/
\r
1804 s.setAttributeNS(null, "attributeType", "CSS");
\r
1805 s.setAttributeNS(null, "values", "a;b;c");
\r
1807 expect(attr.isCSS).toBeTruthy();
\r
1809 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1810 it("should be this for the value (the valid partion )", function() {
\r
1811 s.setAttribute("from", "1");
\r
1812 var p = document.createElement("g");
\r
1814 var values = [ "0",
\r
1815 "0", null, null, null,
\r
1816 "0", "indefinite", null
\r
1819 check2("dur", "0");
\r
1820 check2("begin", "0");
\r
1822 check2("begin", "1");
\r
1824 check2("end", "0");
\r
1826 check2("repeatCount", "0");
\r
1828 check2("repeatDur", "0");
\r
1830 check2("min", "0");
\r
1832 check2("max", "0");
\r
1834 check2("begin", "12");
\r
1835 values[7] = 1000 * base("$frame").fpms;
\r
1837 check2("dur", "1");
\r
1838 function check2(attrName, value) {
\r
1839 s.setAttribute(attrName, value);
\r
1840 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1841 var fr = attr.push(s);
\r
1842 expect(attr.element).toBe(p);
\r
1843 var timelines = base("$frame").timelines;
\r
1844 var line = timelines[timelines.length-1];
\r
1845 expect(fr.string).toBe(values[0]);
\r
1846 var act = fr.$activate;
\r
1847 expect(act.dur).toBe(values[1]);
\r
1848 expect(act.repeatCount).toBe(values[3]);
\r
1849 expect(act.repeatDur).toBe(values[4]);
\r
1850 expect(act.min).toBe(values[5]);
\r
1851 expect(act.max).toBe(values[6]);
\r
1852 expect(act.simpleDur).toBe(values[7]);
\r
1856 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1857 document.documentElement.appendChild(p4);
\r
1858 p4.appendChild(s);
\r
1859 p4.setAttributeNS(null, "style", "display: none");
\r
1861 expect(attr.setAttribute()).toBeUndefined();
\r
1862 expect(attr.setAttribute("block")).toBeUndefined();
\r
1863 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1864 expect(attr.isCSS).toBeFalsy();
\r
1866 s.setAttributeNS(null, "attributeName", "display");
\r
1868 expect(attr.setAttribute("block")).toBeUndefined();
\r
1869 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1870 expect(attr.isCSS).toBeTruthy();
\r
1871 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1873 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1874 document.documentElement.appendChild(p4);
\r
1875 p4.appendChild(s);
\r
1876 p4.setAttributeNS(null, "style", "display: none");
\r
1878 expect(attr.setAttribute("block")).toBeUndefined();
\r
1879 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1880 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
1881 expect(attr.removeAttribute()).toBeUndefined();
\r
1882 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
1883 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
1885 /*attributeType属性のサポート*/
\r
1886 s.setAttributeNS(null, "values", "a;b;c");
\r
1887 s.setAttributeNS(null, "attributeName", "display");
\r
1888 attr.isCSS = false;
\r
1890 expect(attr.isCSS).toBeTruthy();
\r
1892 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1893 it("should be this for the value (the invalid partion )", function() {
\r
1894 var p = document.createElement("g");
\r
1897 s.setAttributeNS(null, "begin", "1");
\r
1899 var timelines = base("$frame").timelines;
\r
1900 expect(timelines.length).toBe(0);
\r
1901 s.setAttributeNS(null, "from", "0");
\r
1903 expect(timelines.length).toBe(1);
\r
1904 expect(attr.push(12)).toBeNull();
\r
1907 describe("A setValues method", function() {
\r
1909 beforeEach( function() {
\r
1910 attr = base("$calcMode").$attribute.up("width");
\r
1911 base("$frame").timelines.length = 0;
\r
1912 s = document.createElement("animate");
\r
1914 /*境界条件を調べておく (limit value analysis)*/
\r
1915 it("should be this for the value (limit value analysis)", function() {
\r
1916 expect(attr.$from).not.toBeUndefined();
\r
1917 expect(attr.setValues()).toBeNull();
\r
1918 expect(attr.setValues("")).toBeNull();
\r
1920 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
1921 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
1922 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
1923 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
1925 /*from-to アニメーション*/
\r
1926 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
1927 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
1929 /*from-by アニメーション*/
\r
1930 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
1931 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
1932 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
1934 /*fromなしto アニメーション*/
\r
1935 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
1936 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
1937 var aset = attr.setValues(null, null, "1")[0].to;
\r
1939 expect(aset.from[0]).toBe(0);
\r
1941 /*fromなしby アニメーション*/
\r
1942 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
1943 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
1944 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
1946 expect(aset.from[0]).toBe(0);
\r
1948 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1949 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1950 attr.$from.degit = 1;
\r
1951 var setv = attr.setValues("0;1")[0].call();
\r
1952 expect(setv(0.5)).toBe("0.5");
\r
1953 expect(setv(1)).toBe("1.0");
\r
1955 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
1956 expect(setv(0.5)).toBe("0.5");
\r
1957 expect(setv(1)).toBe("1.0");
\r
1958 setv = attr.setValues("0;1;2")[1].call();
\r
1959 expect(setv(0.4)).toBe("1.4");
\r
1960 expect(setv(1)).toBe("2.0");
\r
1962 attr.$from.degit = 2;
\r
1963 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
1964 expect(setv(0.5)).toBe("8.05");
\r
1965 expect(setv(1)).toBe("15.10");
\r
1967 var v = attr.setValues("1;1;2;1;1;15.1");
\r
1968 setv = v[4].mix( {
\r
1971 expect(setv(0.05)).toBe("8.05");
\r
1972 expect(setv(0.1)).toBe("15.10");
\r
1973 setv = v[3].mix( {
\r
1976 expect(setv(0.01)).toBe("1.00");
\r
1977 expect(setv(0.1)).toBe("1.00");
\r
1978 setv = v[2].mix( {
\r
1981 expect(setv(0.25)).toBe("1.50");
\r
1982 expect(setv(0.5)).toBe("1.00");
\r
1984 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1985 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1986 attr.$from.degit = 1;
\r
1987 expect(attr.setValues("")).toBeNull();
\r
1988 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
1991 describe("A setKey method", function() {
\r
1993 beforeEach( function() {
\r
1994 attr = base("$calcMode").$attribute.up("width");
\r
1995 base("$frame").timelines.length = 0;
\r
1996 s = document.createElement("animate");
\r
1997 document.createElement("g").appendChild(s);
\r
1999 /*境界条件を調べておく (limit value analysis)*/
\r
2000 it("should be this for the value (limit value analysis)", function() {
\r
2001 expect(attr.setKey(s)).toBeNull();
\r
2003 s.setAttributeNS(null, "from", "0");
\r
2005 s.setAttributeNS(null, "to", "0");
\r
2006 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2007 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
2008 s.setAttributeNS(null, "by", "0");
\r
2010 s.setAttributeNS(null, "values", "0;2");
\r
2011 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2012 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
2014 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
2015 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2017 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
2018 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2019 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2020 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2021 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2023 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
2024 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2025 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2026 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2027 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2029 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2030 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2031 s.setAttributeNS(null, "values", "0;2;12;30");
\r
2032 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
2033 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2034 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2035 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2036 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2037 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
2038 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
2039 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2040 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2041 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2043 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
2044 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2045 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2046 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2048 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
2049 f(0, 0,0.1,0.3,1);
\r
2050 f(1, 0.1,0.4,0.5,0.7);
\r
2051 f(2, 0.2,0.2,0.1,1);
\r
2053 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
2054 f(0, 0,0.1,0.3,1);
\r
2055 f(1, 0.1,0.4,0.5,0.7);
\r
2056 f(2, 0.2,0.2,0.1,1);
\r
2058 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
2059 f(0, 0,0.1,0.333,1);
\r
2060 f(1, 0.1,0.4,0.5,0.7);
\r
2061 f(2, 0.2,0.2,0.1,1);
\r
2062 function f (i, a, b, c, d) {
\r
2063 var splines = attr.setKey(s)[i].keySplines;
\r
2064 expect(splines[0]).toBe(a);
\r
2065 expect(splines[1]).toBe(b);
\r
2066 expect(splines[2]).toBe(c);
\r
2067 expect(splines[3]).toBe(d);
\r
2070 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2071 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2072 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2073 expect(attr.setKey(s)).toBeNull();
\r
2074 s.setAttributeNS(null, "values", "0;2;12");
\r
2075 expect(attr.setKey(s)).toBeNull();
\r
2076 s.setAttributeNS(null, "values", "0;2;12;20");
\r
2077 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
2078 expect(attr.setKey(s)).toBeNull();
\r
2082 describe("A $setElement object", function() {
\r
2083 describe("A timeline property", function() {
\r
2084 var $set, ele, frame;
\r
2085 beforeEach( function() {
\r
2086 $set = base("$calcMode").$attribute.$setElement.up();
\r
2087 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2088 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2089 p.appendChild(ele);
\r
2090 frame = base("$frame");
\r
2092 /*境界条件を調べておく (limit value analysis)*/
\r
2093 it("should be this for the value (limit value analysis)", function() {
\r
2094 expect($set.timeline).toBe(frame.$begin);
\r
2097 expect($set.timeline).toBe(frame.$begin);
\r
2098 expect($set.element).toBeNull();
\r
2102 describe("An init method", function() {
\r
2103 var $set, ele, frame;
\r
2104 beforeEach( function() {
\r
2105 $set = base("$calcMode").$attribute.$setElement.up();
\r
2106 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2107 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2108 p.appendChild(ele);
\r
2109 frame = base("$frame");
\r
2111 /*境界条件を調べておく (limit value analysis)*/
\r
2112 it("should be this for the value (limit value analysis)", function() {
\r
2113 expect($set.to).toBe("");
\r
2114 expect($set.attrName).toBe("");
\r
2115 expect($set.defaultValue).toBe("");
\r
2116 expect($set.isDefault).toBeFalsy();
\r
2117 expect($set.attrNameSpace).toBeNull();
\r
2119 expect($set.timeline).toBe(frame.$begin);
\r
2121 expect($set.to).toBe("");
\r
2122 expect($set.attrName).toBe("");
\r
2123 expect($set.isDefault).toBeFalsy();
\r
2124 expect($set.attrNameSpace).toBeNull();
\r
2125 expect($set.timeline).toBe(frame.$begin);
\r
2127 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2128 it("should be this for the value (the valid partion )", function() {
\r
2129 ele.setAttributeNS(null, "to", "t1");
\r
2131 expect($set.to).toBe("t1");
\r
2132 expect($set.attrName).toBe("");
\r
2133 expect($set.defaultValue).toBe("");
\r
2135 ele.setAttributeNS(null, "attributeName", "tt1");
\r
2137 expect($set.to).toBe("t1");
\r
2138 expect($set.attrName).toBe("tt1");
\r
2139 expect($set.defaultValue).toBe("");
\r
2141 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
2143 expect($set.defaultValue).toBe("undef");
\r
2144 expect($set.isDefault).toBeTruthy();
\r
2146 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2147 ele.parentNode.style.setProperty("font-size", "12px");
\r
2149 expect($set.defaultValue).toBe("12px");
\r
2150 expect($set.isDefault).toBeFalsy();
\r
2152 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2154 expect($set.to).toBe("t1");
\r
2155 expect($set.attrName).toBe("xlink:href");
\r
2156 expect($set.defaultValue).toBe("");
\r
2157 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2159 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2161 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2162 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2164 expect($set.to).toBe("");
\r
2165 expect($set.attrName).toBe("");
\r
2166 expect($set.defaultValue).toBe("");
\r
2169 expect($set.to).toBe("");
\r
2170 expect($set.attrName).toBe("");
\r
2171 expect($set.defaultValue).toBe("");
\r
2174 describe("Frame Set", function() {
\r
2175 var $set, ele, frame;
\r
2176 beforeEach( function() {
\r
2177 $set = base("$calcMode").$attribute.$setElement.up();
\r
2178 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2179 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2180 p.appendChild(ele);
\r
2181 frame = base("$frame");
\r
2182 frame.timelines.length = 0; //配列の初期化
\r
2183 frame.startTime = Date.now();
\r
2184 frame.setFrame(0);
\r
2186 afterEach( function() {
\r
2187 $set.isCSS = false;
\r
2189 /*境界条件を調べておく (limit value analysis)*/
\r
2190 it("should be this for the value (limit value analysis)", function() {
\r
2191 expect($set.isEnd).toBeFalsy();
\r
2192 ele.setAttributeNS(null, "dur", "1s");
\r
2193 ele.setAttributeNS(null, "attributeName", "fill");
\r
2194 ele.setAttributeNS(null, "to", "red");
\r
2196 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2197 $set.isCSS = false;
\r
2198 expect($set.timeline).not.toBe(frame.$begin);
\r
2199 frame.setFrame(0);
\r
2200 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2202 var line = $set.timeline;
\r
2203 expect(line.$list.state).toBe(line.$list.PLAYING);
\r
2204 frame.setFrame(24);
\r
2205 expect(line.$list.state).toBe(line.$list.POSTWAITING);
\r
2206 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2208 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2209 it("should be this for the value (the valid partion)", function() {
\r
2210 ele.setAttributeNS(null, "begin", "1s");
\r
2211 ele.setAttributeNS(null, "dur", "1s");
\r
2212 ele.setAttributeNS(null, "attributeName", "fill");
\r
2213 ele.setAttributeNS(null, "to", "red");
\r
2215 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2216 $set.isCSS = false;
\r
2217 var f = function(num) {
\r
2218 frame.setFrame(num);
\r
2219 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2224 frame.setFrame(24);
\r
2225 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2226 frame.setFrame(25);
\r
2227 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2231 ele.setAttributeNS(null, "fill", "freeze");
\r
2233 $set.isCSS = false;
\r
2237 frame.setFrame(24);
\r
2238 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2239 frame.setFrame(25);
\r
2240 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2241 frame.setFrame(48);
\r
2242 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2243 frame.setFrame(49);
\r
2244 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2245 ele.setAttributeNS(null, "begin", "1s");
\r
2246 ele.setAttributeNS(null, "attributeName", "fill");
\r
2247 ele.setAttributeNS(null, "to", "red");
\r
2248 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2250 $set.isCSS = false;
\r
2251 var f = function(num) {
\r
2252 frame.setFrame(num);
\r
2253 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2261 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2262 it("should be this for the value (the invalid partion)", function() {
\r
2267 describe("A $animateElement object", function() {
\r
2268 describe("An init method", function() {
\r
2269 var $animate, ele, frame;
\r
2270 beforeEach( function() {
\r
2271 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2272 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2273 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2274 p.appendChild(ele);
\r
2275 frame = base("$frame");
\r
2276 frame.timelines.length = 0;
\r
2277 frame.startTime = Date.now();
\r
2278 frame.setFrame(0);
\r
2280 /*境界条件を調べておく (limit value analysis)*/
\r
2281 it("should be this for the value (limit value analysis)", function() {
\r
2284 ele.setAttributeNS(null, "begin", "1s");
\r
2285 ele.setAttributeNS(null, "dur", "1s");
\r
2286 ele.setAttributeNS(null, "attributeName", "d");
\r
2287 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2288 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2289 $animate.init(ele);
\r
2290 expect($animate.isCSS).toBeFalsy();
\r
2291 frame.setFrame(0);
\r
2292 var p = ele.parentNode;
\r
2293 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2294 * 他のブラウザではnullを返すため、その対策をする*/
\r
2295 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2297 function f(fr, result) {
\r
2298 frame.setFrame(fr);
\r
2299 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2302 f(24, "M20.0 0.0 L20.0 30.0");
\r
2303 f(36, "M20.0 10.0 L15.0 30.0");
\r
2306 ele.setAttributeNS(null, "fill", "freeze");
\r
2307 $animate.init(ele);
\r
2308 f(24, "M20.0 0.0 L20.0 30.0");
\r
2309 f(36, "M20.0 10.0 L15.0 30.0");
\r
2310 f(48, "M20.0 20.0 L10.0 30.0");
\r
2312 frame.timelines.length = 0;
\r
2313 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2314 $animate.init(ele);
\r
2315 expect($animate.isCSS).toBeFalsy();
\r
2316 expect($animate.mode).toBe("discrete");
\r
2317 f(24, "M20.0 0.0 L20.0 30.0");
\r
2318 f(25, "M20.0 0.0 L20.0 30.0");
\r
2319 f(37, "M20.0 20.0 L10.0 30.0");
\r
2320 f(48, "M20.0 20.0 L10.0 30.0");
\r
2322 [ ["display", "inline", "none"],
\r
2323 ["visibility", "hidden", "visible"],
\r
2324 ["stroke-linecap", "round", "square"],
\r
2325 ["font-style", "italic", "normal"]
\r
2326 ].forEach( function(attr) {
\r
2327 var attrName = attr[0],
\r
2330 function g(fr, result) {
\r
2331 frame.setFrame(fr);
\r
2332 expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);
\r
2336 ele.setAttributeNS(null, "from", from);
\r
2337 ele.setAttributeNS(null, "to", to);
\r
2338 frame.timelines.length = 0;
\r
2339 ele.setAttributeNS(null, "calcMode", "linear");
\r
2340 ele.setAttributeNS(null, "attributeName", attrName);
\r
2341 $animate.init(ele);
\r
2342 expect($animate.mode).toBe("discrete");
\r
2349 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2350 it("should be this for the value (the valid partion )", function() {
\r
2352 ele.setAttributeNS(null, "begin", "0s");
\r
2353 ele.setAttributeNS(null, "dur", "100s");
\r
2354 ele.setAttributeNS(null, "attributeName", "d");
\r
2355 ele.setAttributeNS(null, "fill", "freeze");
\r
2356 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2357 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2358 $animate.init(ele);
\r
2360 var p = ele.parentNode;
\r
2361 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2363 function f(fr, result) {
\r
2364 frame.setFrame(fr);
\r
2365 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2368 for (var i=0;i<2400;++i) {
\r
2369 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2371 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2374 frame.timelines.length = 0;
\r
2375 ele.setAttributeNS(null, "begin", "0s");
\r
2376 ele.setAttributeNS(null, "dur", "1s");
\r
2377 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2378 ele.setAttributeNS(null, "attributeName", "d");
\r
2379 ele.setAttributeNS(null, "fill", "freeze");
\r
2380 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2381 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2382 $animate.init(ele);
\r
2383 f(23, "M20.0 23.0 L20.0 30.0");
\r
2384 f(24, "M20.0 0.0 L20.0 30.0");
\r
2385 f(25, "M20.0 1.0 L20.0 30.0");
\r
2386 f(48, "M20.0 24.0 L20.0 30.0");
\r
2388 frame.timelines.length = 0;
\r
2389 ele.setAttributeNS(null, "begin", "0s");
\r
2390 ele.setAttributeNS(null, "dur", "2s");
\r
2391 ele.setAttributeNS(null, "attributeName", "d");
\r
2392 ele.setAttributeNS(null, "fill", "freeze");
\r
2393 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2394 $animate.init(ele);
\r
2395 f(0, "M20.0 0.0 L20.0 30.0");
\r
2396 f(1, "M20.0 1.0 L20.0 30.0");
\r
2397 f(24, "M20.0 24.0 L20.0 30.0");
\r
2398 f(25, "M20.0 24.1 L20.0 30.0");
\r
2399 f(47, "M20.0 26.3 L20.0 30.0");
\r
2400 f(48, "M20.0 26.4 L20.0 30.0");
\r
2401 f(49, "M20.0 26.4 L20.0 30.0");
\r
2402 f(50, "M20.0 26.4 L20.0 30.0");
\r
2404 frame.timelines.length = 0;
\r
2405 ele.setAttributeNS(null, "begin", "0s");
\r
2406 ele.setAttributeNS(null, "end", "2s");
\r
2407 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2408 ele.removeAttributeNS(null, "repeatDur");
\r
2409 ele.setAttributeNS(null, "attributeName", "d");
\r
2410 ele.setAttributeNS(null, "fill", "freeze");
\r
2411 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2412 $animate.init(ele);
\r
2413 f(0, "M20.0 0.0 L20.0 30.0");
\r
2414 f(1, "M20.0 0.0 L20.0 30.0");
\r
2415 f(24, "M20.0 0.0 L20.0 30.0");
\r
2416 f(25, "M20.0 0.0 L20.0 30.0");
\r
2417 f(47, "M20.0 0.0 L20.0 30.0");
\r
2418 f(48, "M20.0 0.0 L20.0 30.0");
\r
2419 f(49, "M20.0 0.0 L20.0 30.0");
\r
2420 f(50, "M20.0 0.0 L20.0 30.0");
\r
2422 frame.timelines.length = 0;
\r
2423 ele.setAttributeNS(null, "dur", "2s");
\r
2424 ele.setAttributeNS(null, "fill", "remove");
\r
2425 var attrValue = p.getAttributeNS(null, "d");
\r
2426 $animate.init(ele);
\r
2429 frame.timelines.length = 0;
\r
2430 p.removeAttributeNS(null, "d");
\r
2431 ele.setAttributeNS(null, "fill", "freeze");
\r
2432 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2433 $animate.init(ele);
\r
2434 f(1, "M20.0 5.0 L20.0 30.0");
\r
2435 f(48, "M20.0 26.4 L20.0 30.0");
\r
2437 frame.timelines.length = 0;
\r
2438 ele.setAttributeNS(null, "fill", "freeze");
\r
2439 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2440 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2441 $animate.init(ele);
\r
2442 f(1, "M20.0 0.0 L20.0 30.0");
\r
2443 f(4, "M20.0 0.0 L20.0 30.0");
\r
2444 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2446 f(24, "M20.0 24.0 L20.0 30.0");
\r
2447 f(25, "M20.0 24.0 L20.0 30.0");
\r
2448 f(29, "M20.0 26.4 L20.0 30.0");
\r
2449 f(48, "M20.0 26.4 L20.0 30.0");
\r
2451 frame.timelines.length = 0;
\r
2452 ele.setAttributeNS(null, "calcMode", "spline");
\r
2453 ele.removeAttributeNS(null, "keyTimes");
\r
2454 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2455 ele.removeAttributeNS(null, "end");
\r
2456 ele.setAttributeNS(null, "dur", "9s");
\r
2457 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2458 $animate.init(ele);
\r
2465 frame.timelines.length = 0;
\r
2466 ele.setAttributeNS(null, "calcMode", "spline");
\r
2467 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2468 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2469 ele.setAttributeNS(null, "dur", "8s");
\r
2470 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2471 $animate.init(ele);
\r
2479 frame.timelines.length = 0;
\r
2480 ele.setAttributeNS(null, "begin", "click");
\r
2481 ele.setAttributeNS(null, "calcMode", "spline");
\r
2482 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2483 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2484 ele.setAttributeNS(null, "dur", "8s");
\r
2485 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2486 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2487 $animate.init(ele);
\r
2494 ( function(attrName) {
\r
2495 function g(fr, result) {
\r
2496 frame.setFrame(fr);
\r
2497 expect(p.style.getPropertyValue(attrName)).toBe(result);
\r
2500 frame.timelines.length = 0;
\r
2501 ele.setAttributeNS(null, "begin", "0s");
\r
2502 ele.setAttributeNS(null, "calcMode", "linear");
\r
2503 ele.setAttributeNS(null, "attributeName", attrName);
\r
2504 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2505 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2506 ele.setAttributeNS(null, "dur", "8s");
\r
2507 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2508 $animate.init(ele);
\r
2509 expect($animate.mode).toBe("discrete");
\r
2516 frame.timelines.length = 0;
\r
2517 ele.setAttributeNS(null, "begin", "click");
\r
2518 ele.setAttributeNS(null, "calcMode", "linear");
\r
2519 ele.setAttributeNS(null, "attributeName", attrName);
\r
2520 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2521 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2522 ele.setAttributeNS(null, "dur", "8s");
\r
2523 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2524 $animate.init(ele);
\r
2525 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2526 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2527 p.dispatchEvent(evt);
\r
2528 var cur = base("$frame").currentFrame;
\r
2529 expect($animate.mode).toBe("discrete");
\r
2530 g(cur+0, "inline");
\r
2531 g(cur+48, "block");
\r
2532 g(cur+96, "inline");
\r
2533 g(cur+192, "block");
\r
2534 g(cur+300, "block");
\r
2537 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2538 it("should be this for the value (the invalid partion )", function() {
\r
2539 ele.setAttributeNS(null, "begin", "0s");
\r
2540 ele.setAttributeNS(null, "dur", "100s");
\r
2541 ele.setAttributeNS(null, "attributeName", "d");
\r
2542 ele.setAttributeNS(null, "fill", "freeze");
\r
2543 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2544 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2545 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2546 $animate.init(ele);
\r
2548 var p = ele.parentNode;
\r
2549 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2551 function f(fr, result) {
\r
2552 frame.setFrame(fr);
\r
2553 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2558 frame.timelines.length = 0;
\r
2559 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2560 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2561 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2562 $animate.init(ele);
\r
2566 /*keyTimes属性が0から始まっていない*/
\r
2567 frame.timelines.length = 0;
\r
2568 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2572 function ff(mode) {
\r
2573 ele.setAttributeNS(null, "calcMode", mode);
\r
2574 $animate.init(ele);
\r
2579 frame.timelines.length = 0;
\r
2580 ele.setAttributeNS(null, "calcMode", "spline");
\r
2581 $animate.init(ele);
\r
2582 expect($animate.mode).toBe("spline");
\r
2588 describe("RGB Color", function() {
\r
2589 var $animate, ele, frame, f;
\r
2590 beforeEach( function() {
\r
2591 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2592 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2593 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2594 p.appendChild(ele);
\r
2595 frame = base("$frame");
\r
2596 frame.timelines.length = 0;
\r
2598 f = function (fr, result, attr) {
\r
2599 frame.setFrame(fr);
\r
2600 expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));
\r
2603 /*境界条件を調べておく (limit value analysis)*/
\r
2604 it("should be this for the value (limit value analysis)", function() {
\r
2605 ele.setAttributeNS(null, "begin", "0s");
\r
2606 ele.setAttributeNS(null, "dur", "1s");
\r
2607 ele.setAttributeNS(null, "attributeName", "fill");
\r
2608 ele.setAttributeNS(null, "fill", "remove");
\r
2609 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2610 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2611 $animate.init(ele);
\r
2613 f(0, "rgb(0, 0, 0)", "fill");
\r
2614 f(23, "rgb(10, 10, 1)", "fill");
\r
2616 frame.timelines.length = 0;
\r
2617 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2618 $animate.init(ele);
\r
2619 f(0, "rgb(0, 0, 0)", "stroke");
\r
2620 f(23, "rgb(10, 10, 1)", "stroke");
\r
2622 frame.timelines.length = 0;
\r
2623 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2624 $animate.init(ele);
\r
2625 f(0, "rgb(0,0,0)", "stop-color");
\r
2626 f(23, "rgb(10,10,1)", "stop-color");
\r
2628 frame.timelines.length = 0;
\r
2629 ele.setAttributeNS(null, "attributeName", "color");
\r
2630 $animate.init(ele);
\r
2631 f(0, "rgb(0,0,0)", "color");
\r
2632 f(23, "rgb(10,10,1)", "color");
\r
2634 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2635 it("should be this for the value (the valid partion )", function() {
\r
2636 ele.setAttributeNS(null, "begin", "0s");
\r
2637 ele.setAttributeNS(null, "dur", "1s");
\r
2638 ele.setAttributeNS(null, "attributeName", "fill");
\r
2639 ele.setAttributeNS(null, "fill", "remove");
\r
2640 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2641 $animate.init(ele);
\r
2643 f(0, "rgb(0, 0, 0)", "fill");
\r
2644 f(1, "rgb(1, 0, 0)", "fill");
\r
2645 f(23, "rgb(23, 2, 1)", "fill");
\r
2647 frame.timelines.length = 0;
\r
2648 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2649 $animate.init(ele);
\r
2652 f(0, "rgb(0, 8, 60)", "fill");
\r
2653 f(1, "rgb(1, 9, 60)", "fill");
\r
2654 f(23, "rgb(23, 31, 60)", "fill");
\r
2656 frame.timelines.length = 0;
\r
2657 ele.setAttributeNS(null, "fill", "freeze");
\r
2658 ele.setAttributeNS(null, "values", "black;white");
\r
2659 $animate.init(ele);
\r
2660 /*色キーワードをrgb形式に変換*/
\r
2662 f(0, "rgb(0, 0, 0)", "fill");
\r
2663 f(12, "rgb(128, 128, 128)", "fill");
\r
2664 f(24, "rgb(255, 255, 255)", "fill");
\r
2666 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2667 it("should be this for the value (the invalid partion )", function() {
\r
2668 ele.setAttributeNS(null, "begin", "0s");
\r
2669 ele.setAttributeNS(null, "dur", "1s");
\r
2670 ele.setAttributeNS(null, "attributeName", "fi");
\r
2671 ele.setAttributeNS(null, "fill", "remove");
\r
2672 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2673 $animate.init(ele);
\r
2676 function f (fr, result, attr) {
\r
2677 frame.setFrame(fr);
\r
2678 expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);
\r
2680 f(0, "#83.0C", "fi");
\r
2681 f(1, "#84.0C", "fi");
\r
2682 f(23, "#106.0C", "fi");
\r
2685 describe("$frame.$svgEvent object", function() {
\r
2686 var frame = base("$frame").$svgEvent,
\r
2688 base("$frame").pauseAnimation();
\r
2689 beforeEach( function() {
\r
2690 base("$frame").pauseAnimation();
\r
2691 frame = frame.up().mix( {isResolved: true} );
\r
2692 frame.first = null;
\r
2693 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2694 * 影響を受けるため、新たに初期化しておく*/
\r
2695 base("$frame").timelines = frame.timelines = [];
\r
2696 frame.lastTimeLine = null;
\r
2697 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2698 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2699 p.appendChild(ele);
\r
2701 /*境界条件を調べておく (limit value analysis)*/
\r
2702 it("should be this for the value (limit value analysis)", function() {
\r
2703 base("$frame").pauseAnimation();
\r
2704 frame.lastTimeLine = null;
\r
2705 expect(frame.lastTimeLine).toBeNull();
\r
2706 expect(frame.first).toBeNull();
\r
2707 frame.setTimeTable();
\r
2708 expect(frame.first).toBeNull();
\r
2709 frame.addLine( base("$frame").$begin.up().mix({
\r
2716 frame.setTimeTable();
\r
2717 expect(frame.first).toEqual(
\r
2719 eventType: "begin",
\r
2730 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2731 it("should be this for the value (the valid partion )", function() {
\r
2732 base("$frame").pauseAnimation();
\r
2733 frame.addLine( base("$frame").$begin.up().mix({
\r
2740 frame.setTimeTable();
\r
2741 frame.setTimeTable();
\r
2742 expect(frame.first).toEqual(
\r
2744 eventType: "begin",
\r
2754 frame.setTimeTable();
\r
2755 frame.setTimeTable();
\r
2756 expect(frame.first).toEqual(
\r
2758 eventType: "begin",
\r
2769 var isFiredBeginEvent = false;
\r
2770 ele.addEventListener("beginEvent", function(evt) {
\r
2771 isFiredBeginEvent = true;
\r
2772 expect(evt.target).toBe(ele);
\r
2774 ele.addEventListener("endEvent", function(evt) {
\r
2775 expect(evt.target).toBe(ele);
\r
2776 expect(isFiredBeginEvent).toBeTruthy();
\r
2778 frame.setFrame(0);
\r
2779 expect(frame.first).toBeNull();
\r
2780 frame.setFrame(0);
\r
2781 expect(frame.first).toBeNull();
\r
2783 frame.timelines = [];
\r
2784 frame.addLine( base("$frame").$begin.up().mix({
\r
2791 frame.setTimeTable();
\r
2792 var a = { frame: 0,
\r
2793 eventType: "begin",
\r
2796 next: { frame: 10,
\r
2802 expect(frame.first).toEqual(a);
\r
2804 frame.addLine( base("$frame").$begin.up().mix({
\r
2808 simpleDuration: 9,
\r
2812 frame.setTimeTable();
\r
2813 a.next.next = { frame: 1,
\r
2814 eventType: "begin",
\r
2819 eventType: "repeat",
\r
2823 next: { frame: 12,
\r
2830 expect(frame.first).toEqual(a);
\r
2831 frame.setFrame(11);
\r
2832 expect(frame.first).toEqual( {frame: 12,
\r
2838 frame.timelines = [];
\r
2839 frame.first = null;
\r
2840 frame.addLine( base("$frame").$begin.up().mix({
\r
2844 simpleDuration: 4,
\r
2848 frame.setTimeTable();
\r
2850 eventType: "begin",
\r
2855 eventType: "repeat",
\r
2861 eventType: "repeat",
\r
2865 next: { frame: 11,
\r
2873 expect(frame.first).toEqual(a);
\r
2874 frame.setFrame(0);
\r
2875 expect(frame.first).toEqual(a);
\r
2876 frame.setFrame(1);
\r
2878 expect(frame.first).toEqual(a);
\r
2879 frame.setFrame(5);
\r
2880 expect(frame.first).toEqual(a.next);
\r
2882 ele.addEventListener("repeatEvent", function(evt) {
\r
2883 expect(evt.target).toBe(ele);
\r
2885 frame.timelines = [];
\r
2886 frame.first = null;
\r
2887 frame.addLine( base("$frame").$begin.up().mix({
\r
2891 simpleDuration: 4,
\r
2895 frame.setFrame(9);
\r
2896 expect(frame.first).toEqual({
\r
2898 eventType: "repeat",
\r
2902 next: { frame: 16,
\r
2909 afterEach( function() {
\r
2910 base("$frame").startAnimation();
\r
2913 describe("A $animateTransformElemenet object", function() {
\r
2914 describe("An init method", function() {
\r
2915 var $animate, ele, frame, p;
\r
2916 beforeEach( function() {
\r
2917 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
2918 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
2919 $animate.degits = 1;
\r
2920 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2921 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
2922 p.appendChild(ele);
\r
2923 frame = base("$frame");
\r
2924 frame.timelines.length = 0;
\r
2925 frame.startTime = Date.now();
\r
2926 frame.setFrame(0);
\r
2928 afterEach( function() {
\r
2929 $animate.numberOfList = -1;
\r
2931 /*境界条件を調べておく (limit value analysis)*/
\r
2932 it("should be this for the value (limit value analysis)", function() {
\r
2933 expect($animate.numberOfList).toBe(-1);
\r
2934 expect($animate.type).toBe("translate");
\r
2935 expect(p.__transformList).toBeUndefined();
\r
2936 expect($animate.isCSS).toBeFalsy();
\r
2937 expect($animate.isSum).toBeFalsy();
\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
2948 expect($animate.numberOfList).toBe(-1);
\r
2949 expect(p.__transformList).toBeUndefined();
\r
2950 expect($animate.isCSS).toBeFalsy();
\r
2951 expect($animate.type).toBe("translate");
\r
2952 expect($animate.attrName).toBe("transform");
\r
2954 $animate.init(ele);
\r
2955 expect($animate.numberOfList).toBe(-1);
\r
2956 expect(p.__transformList).toEqual([]);
\r
2957 expect($animate.isCSS).toBeFalsy();
\r
2958 expect($animate.type).toBe("translate");
\r
2959 expect($animate.attrName).toBe("transform");
\r
2961 ele.setAttributeNS(null, "values", "0;1");
\r
2962 ele.setAttributeNS(null, "attributeName", "");
\r
2963 $animate.init(ele);
\r
2964 expect($animate.isCSS).toBeFalsy();
\r
2965 expect($animate.type).toBe("translate");
\r
2966 expect($animate.type).toBe("translate");
\r
2967 expect($animate.numberOfList).toBe(0);
\r
2968 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2969 value: "translate(0)",
\r
2974 ele.setAttributeNS(null, "type", "translate");
\r
2975 $animate.init(ele);
\r
2976 expect($animate.numberOfList).toBe(0);
\r
2977 expect($animate.isCSS).toBeFalsy();
\r
2978 expect($animate.type).toBe("translate");
\r
2979 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
2980 value: "translate(0)",
\r
2984 $animate.tocall(0);
\r
2985 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2987 ele.parentNode.appendChild(ele.cloneNode(true));
\r
2988 $animate.numberOfList = -1;
\r
2989 $animate.init(ele.parentNode.lastChild);
\r
2990 expect($animate.numberOfList).toBe(1);
\r
2991 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2992 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
2994 expect($animate.type).toBe("translate");
\r
2995 $animate.tocall(0);
\r
2996 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
2997 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
2998 $animate._setEndFrame(1);
\r
2999 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
3000 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
3002 delete p.__transformList;
\r
3003 ele.setAttributeNS(null, "type", "scale");
\r
3004 $animate.numberOfList = -1;
\r
3005 $animate.init(ele);
\r
3006 expect($animate.numberOfList).toBe(0);
\r
3007 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3008 value: "translate(0)",
\r
3012 expect($animate.type).toBe("scale");
\r
3014 delete p.__transformList;
\r
3015 $animate.numberOfList = -1;
\r
3016 ele.setAttributeNS(null, "additive", "sum");
\r
3017 ele.setAttributeNS(null, "fill", "freeze");
\r
3018 $animate.init(ele);
\r
3019 expect($animate.isSum).toBeTruthy();
\r
3020 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3021 value: "translate(0)",
\r
3025 delete p.__transformList;
\r
3026 $animate.numberOfList = -1;
\r
3027 ele.setAttributeNS(null, "additive", "replace");
\r
3028 ele.setAttributeNS(null, "fill", "remove");
\r
3029 $animate.init(ele);
\r
3030 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3031 value: "translate(0)",
\r
3036 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3037 it("should be this for the value (the valid partion )", function() {
\r
3038 ele.setAttributeNS(null, "type", "scale");
\r
3039 ele.setAttributeNS(null, "values", "0;1");
\r
3040 $animate.init(ele);
\r
3041 expect($animate.isCSS).toBeFalsy();
\r
3042 expect($animate.numberOfList).toBe(0);
\r
3043 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3044 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
3045 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
3046 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3048 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3049 $animate.numberOfList = -1;
\r
3050 $animate.init(ele.parentNode.lastChild);
\r
3051 expect($animate.numberOfList).toBe(1);
\r
3052 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3053 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3055 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3056 $animate.up("$a").numberOfList = -1;
\r
3057 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3058 $animate.$a.init(ele.parentNode.lastChild);
\r
3059 expect($animate.$a.numberOfList).toBe(2);
\r
3060 expect($animate.$a.isDefault).toBeTruthy();
\r
3061 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3062 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
3063 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
3064 $animate.defaultValue = $animate.$a.defaultValue;
\r
3065 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
3067 ele.setAttributeNS(null, "additive", "sum");
\r
3068 var parentNode = ele.parentNode;
\r
3069 parentNode.appendChild(ele.cloneNode(true));
\r
3070 parentNode.__transformList = [];
\r
3071 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
3072 parentNode.removeChild(ele);
\r
3073 $animate.numberOfList = -1;
\r
3074 $animate.init(parentNode.lastChild);
\r
3075 expect($animate.numberOfList).toBe(0);
\r
3076 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3077 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3079 parentNode.appendChild(ele.cloneNode(true));
\r
3080 $animate.up("$a").numberOfList = -1;
\r
3081 parentNode.__transformList = [];
\r
3082 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3083 $animate.$a.init(parentNode.lastChild);
\r
3084 expect($animate.$a.numberOfList).toBe(0);
\r
3085 expect($animate.$a.isDefault).toBeTruthy();
\r
3086 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3087 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3088 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3089 $animate.defaultValue = $animate.$a.defaultValue;
\r
3090 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
3092 ele.removeAttributeNS(null, "additive");
\r
3093 ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",
\r
3094 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
3095 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
3096 "scale(0.0)", "scale(1.0)");
\r
3097 function ad(first, second, a, b, c, d) {
\r
3099 while (parentNode.firstChild) {
\r
3100 parentNode.removeChild(parentNode.firstChild);
\r
3103 /*additive属性のreplaceとsumの混合*/
\r
3104 ele.setAttributeNS(null, "additive", first);
\r
3105 parentNode.appendChild(ele.cloneNode(true));
\r
3106 ele.setAttributeNS(null, "additive", second);
\r
3107 parentNode.appendChild(ele.cloneNode(true));
\r
3108 parentNode.__transformList = [];
\r
3109 $animate.numberOfList = -1;
\r
3110 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3111 $animate.up("$first").init(parentNode.firstChild);
\r
3112 $animate.up("$second").init(parentNode.lastChild);
\r
3113 expect($animate.$first.numberOfList).toBe(0);
\r
3114 expect($animate.$second.numberOfList).toBe(1);
\r
3115 expect($animate.$first.tocall(0)).toBe(a);
\r
3116 expect($animate.$second.tocall(0)).toBe(b);
\r
3117 expect($animate.$first.tocall(1)).toBe(c);
\r
3118 expect($animate.$second.tocall(1)).toBe(d);
\r
3121 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3122 it("should be this for the value (the invalid partion )", function() {
\r
3123 $animate.init(ele);
\r
3124 ele.parentNode.__transformList = null;
\r
3125 expect( function () {
\r
3126 $animate.tocall(0);
\r
3129 $animate.numberOfList = -1;
\r
3130 $animate.init(ele);
\r
3131 $animate.numberOfList = -1;
\r
3132 expect( function () {
\r
3133 $animate.tocall(0);
\r
3138 describe("A $motionElement object", function() {
\r
3139 describe("An init method", function() {
\r
3140 var $animate, ele, frame, p;
\r
3141 beforeEach( function() {
\r
3142 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3143 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3144 $animate.degits = 1;
\r
3145 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3146 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3147 p.appendChild(ele);
\r
3148 frame = base("$frame");
\r
3149 frame.timelines.length = 0;
\r
3150 frame.startTime = Date.now();
\r
3151 frame.setFrame(0);
\r
3153 afterEach( function() {
\r
3154 $animate.numberOfList = -1;
\r
3155 delete $animate.element;
\r
3156 p.__transformList = null;
\r
3158 /*境界条件を調べておく (limit value analysis)*/
\r
3159 it("should be this for the value (limit value analysis)", function() {
\r
3160 expect($animate.type).toBe("translate");
\r
3161 expect($animate.mode).toBe("paced");
\r
3162 ele.setAttributeNS(null, "type", "scale");
\r
3163 expect($animate.rotate).toBe("0");
\r
3164 $animate.init(ele);
\r
3165 expect($animate.type).toBe("translate");
\r
3166 expect($animate.mode).toBe("paced");
\r
3167 expect($animate.rotate).toBe("0");
\r
3169 ele.setAttributeNS(null, "values", "0,0;1,0");
\r
3170 $animate.up("$a").init(ele);
\r
3171 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3172 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3173 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3175 var ec = ele.cloneNode(true);
\r
3176 p.appendChild(ec);
\r
3177 ec.removeAttributeNS(null, "values");
\r
3178 ec.setAttributeNS(null, "from", "0,0");
\r
3179 ec.setAttributeNS(null, "to", "1,0");
\r
3180 $animate.up("$a").init(ec);
\r
3181 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3182 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3183 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3185 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3186 it("should be this for the value (the invalid partion )", function() {
\r
3190 describe("A hasAttrValues method", function() {
\r
3191 var $animate, ele, frame, p;
\r
3192 beforeEach( function() {
\r
3193 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3194 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3195 $animate.degits = 1;
\r
3196 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3197 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3198 p.appendChild(ele);
\r
3199 frame = base("$frame");
\r
3200 frame.timelines.length = 0;
\r
3201 frame.startTime = Date.now();
\r
3202 frame.setFrame(0);
\r
3204 afterEach( function() {
\r
3205 $animate.numberOfList = -1;
\r
3206 delete $animate.element;
\r
3207 p.__transformList = null;
\r
3209 /*境界条件を調べておく (limit value analysis)*/
\r
3210 it("should be this for the value (limit value analysis)", function() {
\r
3212 expect($animate.up("$a").hasAttrValues()).toBeFalsy();
\r
3213 $animate.up("$a").init(ele);
\r
3214 expect($animate.$a.hasAttrValues()).toBeFalsy();
\r
3216 ele.setAttributeNS(null, "path", "M");
\r
3217 expect($animate.$a.hasAttrValues()).toBeTruthy();
\r
3218 $animate.$animateTransformElement.up("$b").init(ele);
\r
3219 expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();
\r
3223 describe("Event", function() {
\r
3224 var $animate, ele, frame, p;
\r
3225 beforeEach( function() {
\r
3227 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3228 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3229 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3230 p.appendChild(ele);
\r
3231 frame = base("$frame");
\r
3232 frame.pauseAnimation();
\r
3233 frame.timelines.length = 0; //配列の初期化
\r
3234 frame.setFrame(0);
\r
3236 /*境界条件を調べておく (limit value analysis)*/
\r
3237 it("should be this for the value (limit value analysis)", function() {
\r
3238 ele.addEventListener("beginEvent", function(evt) {
\r
3239 expect(evt.target).toBe(ele);
\r
3241 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3242 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3243 ele.dispatchEvent(evt);
\r
3245 ele.setAttributeNS(null, "begin", "mousedown");
\r
3246 ele.setAttributeNS(null, "dur", "1s");
\r
3247 ele.setAttributeNS(null, "attributeName", "fill");
\r
3248 ele.setAttributeNS(null, "fill", "freeze");
\r
3249 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3250 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3251 $animate.init(ele);
\r
3252 $animate.isCSS = false;
\r
3253 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3254 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3255 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3256 p.dispatchEvent(evt);
\r
3257 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3259 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3260 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3261 frame.setFrame(frame.currentFrame);
\r
3262 expect($animate.isEnd).toBeFalsy();
\r
3263 p.dispatchEvent(evt);
\r
3264 frame.setFrame(frame.currentFrame + 1);
\r
3265 frame.setFrame(frame.currentFrame + 24);
\r
3266 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3269 describe("a beginElement method and an endElement method", function() {
\r
3270 var $animate, ele, frame, p;
\r
3271 beforeEach( function() {
\r
3272 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3273 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3274 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3275 p.appendChild(ele);
\r
3276 frame = base("$frame");
\r
3277 frame.timelines.length = 0; //配列の初期化
\r
3278 frame.setFrame(0);
\r
3279 ele.setAttributeNS(null, "begin", "indefinite");
\r
3280 ele.setAttributeNS(null, "dur", "1s");
\r
3281 ele.setAttributeNS(null, "dur", "1s");
\r
3282 ele.setAttributeNS(null, "attributeName", "fill");
\r
3283 ele.setAttributeNS(null, "fill", "freeze");
\r
3284 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3285 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3286 $animate.init(ele);
\r
3288 /*境界条件を調べておく (limit value analysis)*/
\r
3289 it("should be this for the value (limit value analysis)", function() {
\r
3290 expect(ele.beginElement()).toBeUndefined();
\r
3291 var cur = frame.currentFrame,
\r
3292 begin = frame.$begin.$1;
\r
3293 expect(begin.string).toBe("indefinite");
\r
3294 expect(begin.begin).toBe(cur);
\r
3295 expect(ele.endElement()).toBeUndefined();
\r
3297 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3298 it("should be this for the value (the valid partion )", function() {
\r
3299 ele.addEventListener("beginEvent", function(evt){
\r
3300 expect(evt.target.nodeName).toBe("animate");
\r
3302 ele.beginElement();
\r