OSDN Git Service

Modify the _setFrame method
[sie/sie.git] / tool / Spec / spec / SvgDomSpec.js
1 /*SIE under the MIT Lisence\r
2  *公式ページは http://sie.osdn.jp/\r
3  */\r
4 /*\r
5  *Copyright (c) 2008-2010 Pivotal Labs\r
6 \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
14 \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
17 \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
25  */\r
26 \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
33     } );\r
34     afterEach( function() {\r
35         frame.timelines = [];\r
36     } );\r
37     /*境界条件を調べておく (limit value analysis)*/\r
38     it("should be this for the value  (limit value analysis)", function() {\r
39       expect(typeof frame.setFrame).toBe("function");\r
40       expect(frame.timelines.length).toBe(0);\r
41       expect(frame.isBegin).toBeFalsy();\r
42       expect(frame.startAnimation()).toBeUndefined();\r
43       frame.setFrame();\r
44       frame.setFrame(0);\r
45       /*負の値も許される*/\r
46       frame.setFrame(-1);\r
47       \r
48       expect(frame.addLine()).toBe(false);\r
49       expect(frame.addLine({})).toBe(false);\r
50       expect(frame.addLine({\r
51         begin: 0\r
52       })).toBe(false);\r
53       expect(frame.addLine({\r
54         activeTime: 1\r
55       })).toBe(false);\r
56       \r
57       expect(frame.removeLine()).toBeUndefined();\r
58       expect(frame.removeLine({})).toBeUndefined();\r
59       \r
60       frame.setFrame(0);\r
61       expect(frame.currentFrame).toBe(0);\r
62       frame.setFrame(1);\r
63       expect(frame.currentFrame).toBe(1);\r
64       \r
65       expect(frame.isPaused).toBeFalsy();\r
66       expect(frame.pauseAnimation()).toBeUndefined();\r
67       expect(frame.isPaused).toBeTruthy();\r
68 \r
69     });\r
70     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
71     it("should be this for the value (the valid partion)", function() {\r
72       frame.setFrame(0);\r
73       expect(frame.currentFrame).toBe(0);\r
74       frame.startTime = Date.now();\r
75       for (var i=0;i<100000;i++) {\r
76         /*負荷をかけて、時間を進める*/\r
77         1;\r
78       }\r
79       expect(frame.begin).toBe(0);\r
80       expect(frame.activeTime).toBe(Number.MAX_VALUE);\r
81       frame.begin = 10;\r
82       frame.setFrame(0);\r
83       frame.begin = -10;\r
84       frame.setFrame(0);\r
85 \r
86       expect(frame.addLine( {\r
87         begin: 0,\r
88         activeTime: 0\r
89       })).toBe(true);\r
90       expect(frame.addLine( {\r
91         begin: null,\r
92         activeTime: null\r
93       })).toBe(false);\r
94       expect(frame.addLine( {\r
95         begin: 0,\r
96         activeTime: null\r
97       })).toBe(false);\r
98       expect(frame.addLine( {\r
99         begin: null,\r
100         activeTime: 0\r
101       })).toBe(false);\r
102       \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
107       /*timelineの再追加*/\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
114 \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
120       \r
121       frame.addLine(frame.up().mix( {\r
122         timelines: [] \r
123         } ));\r
124       expect(frame.timelines).not.toBe(frame.$1.timelines);\r
125       \r
126       frame.timelines.length = 0;\r
127       frame.addLine( {\r
128         begin: 1,\r
129         activeTime: 1\r
130       } );\r
131       frame.addLine( {\r
132         begin: 1,\r
133         activeTime: 1\r
134       } );\r
135       frame.addLine( {\r
136         begin: 1,\r
137         activeTime: 2\r
138       } );\r
139       expect(frame.timelines[2].activeTime).toBe(2);\r
140     });\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
146       frame.setFrame(0);\r
147     });\r
148   } );\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
155         frame.begin = 0;\r
156     } );\r
157     afterEach( function() {\r
158         frame.timelines = [];\r
159     } );\r
160     /*境界条件を調べておく (limit value analysis)*/\r
161     it("should be this for the value  (limit value analysis)", function() {\r
162             \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
169       \r
170       expect(frame.beginList).toEqual({\r
171               next: null,\r
172               value: Number.MAX_VALUE\r
173             });\r
174       expect(frame.endList).toEqual({\r
175               next: null,\r
176               value: Number.MAX_VALUE\r
177             });\r
178             \r
179       expect(typeof frame.getMaxList).toBe("function");\r
180       \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
190       \r
191       frame.state = 100;\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
196       \r
197       expect(frame.beginList).toEqual({\r
198           next: null,\r
199           value: Number.MAX_VALUE\r
200         });\r
201       expect(frame.endList).toEqual({\r
202           next: null,\r
203           value: Number.MAX_VALUE\r
204         });\r
205         \r
206       expect(frame.getMaxList(0, frame.beginList)).toBe(-1);\r
207       expect(frame.getMaxList(0, frame.endList)).toBe(-1);\r
208     } );\r
209     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
210     it("should be this for the value (the valid partion)", function() {\r
211       \r
212       function appendBegin(num) {\r
213         frame.state = frame.WAITING;\r
214         frame.beginList = {\r
215           value: num,\r
216           next: frame.beginList\r
217         };\r
218       };\r
219       appendBegin(0);\r
220       expect(frame.getMaxList(0, frame.beginList)).toBe(0);\r
221       expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
222       expect(frame.begin).toBe(0);\r
223       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
224       expect(frame.state).toBe(frame.PLAYING);\r
225       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
226       expect(frame.state).toBe(frame.PLAYING);\r
227       \r
228       frame.state = frame.WAITING;\r
229       expect(frame.getMaxList(0, frame.beginList)).toBe(0);\r
230       expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
231       expect(frame.state).toBe(frame.BEGINNING);\r
232       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
233       expect(frame.state).toBe(frame.PLAYING);\r
234       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
235       expect(frame.state).toBe(frame.PLAYING);\r
236       expect(frame.updateState(3).state).toBe(frame.PLAYING);\r
237       expect(frame.state).toBe(frame.PLAYING);\r
238       expect(frame.updateState(4).state).toBe(frame.PLAYING);\r
239       expect(frame.state).toBe(frame.PLAYING);\r
240       \r
241       appendBegin(1);\r
242       expect(frame.getMaxList(1, frame.beginList)).toBe(1);\r
243       expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
244       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
245       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
246       expect(frame.updateState(1).state).toBe(frame.ENDING);\r
247       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
248       expect(frame.state).toBe(frame.BEGINNING);\r
249       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
250       expect(frame.state).toBe(frame.PLAYING);\r
251       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
252       expect(frame.state).toBe(frame.PLAYING);\r
253       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
254       \r
255       frame.begin = 0;\r
256       frame.state = frame.WAITING;\r
257       expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
258       expect(frame.begin).toBe(0);\r
259       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
260       expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
261       expect(frame.begin).toBe(0);\r
262       expect(frame.updateState(1).state).toBe(frame.ENDING);\r
263       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
264       expect(frame.begin).toBe(1);\r
265       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
266       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
267       \r
268       function appendEnd(num) {\r
269         frame.state = frame.WAITING;\r
270         frame.begin = 0;\r
271         frame.endList = {\r
272             value: num,\r
273             next: frame.endList\r
274         };\r
275       };\r
276       appendEnd(3);\r
277       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
278       expect(frame.state).toBe(frame.BEGINNING);\r
279       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
280       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
281       expect(frame.state).toBe(frame.PLAYING);\r
282       expect(frame.updateState(3).state).toBe(frame.ENDING);\r
283       expect(frame.state).toBe(frame.ENDING);\r
284       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
285       expect(frame.state).toBe(frame.POSTWAITING);\r
286       \r
287       appendEnd(4);\r
288       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
289       expect(frame.state).toBe(frame.BEGINNING);\r
290       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
291       expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
292       expect(frame.state).toBe(frame.PLAYING);\r
293       expect(frame.updateState(3).state).toBe(frame.ENDING);\r
294       expect(frame.state).toBe(frame.ENDING);\r
295       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
296       expect(frame.state).toBe(frame.POSTWAITING);\r
297       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
298       expect(frame.state).toBe(frame.POSTWAITING);\r
299       \r
300       appendEnd(1);\r
301       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
302       expect(frame.updateState(1).state).toBe(frame.ENDING);\r
303       expect(frame.updateState(1).state).toBe(frame.POSTWAITING);\r
304     } );\r
305     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
306     it("should be this for the value (the invalid partion)", function() {\r
307       expect(frame.updateState()).toBe(frame);\r
308       expect(frame.updateState(null)).toBe(frame);\r
309     });\r
310     describe("the setFrame method (override)", function() {\r
311       var frame = base("$frame").$list.up("$3");\r
312       beforeEach( function() {\r
313           frame.timelines = [];\r
314           frame.isPaused = false;\r
315           frame.state = frame.WAITING;\r
316           frame.begin = 0;\r
317       } );\r
318       afterEach( function() {\r
319           frame.timelines = [];\r
320           frame.beginList = frame.$list.beginList;\r
321           frame.endList = frame.$list.endList;\r
322           frame.currentFrame = 0;\r
323       } );\r
324       /*境界条件を調べておく (limit value analysis)*/\r
325       it("should be this for the value  (limit value analysis)", function() {\r
326         expect(typeof frame.setFrame).toBe("function");\r
327         expect(frame.currentFrame).toBe(0);\r
328         \r
329         frame.setFrame(0);\r
330         expect(frame.state).toBe(frame.WAITING);\r
331         expect(frame.currentFrame).toBe(0);\r
332         frame.setFrame(1);\r
333         expect(frame.state).toBe(frame.WAITING);\r
334         expect(frame.currentFrame).toBe(1);\r
335         \r
336         expect(typeof frame.addEvent).toBe("function");\r
337         expect(typeof frame.addBeginList).toBe("function");\r
338         expect(typeof frame.addEndList).toBe("function");\r
339         \r
340         expect(frame.addBeginList(1).value).toBe(1);\r
341         expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);\r
342         expect(frame.addEndList(1).value).toBe(1);\r
343         expect(frame.endList.next.value).toBe(Number.MAX_VALUE);\r
344         \r
345 \r
346 \r
347       } );\r
348       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
349       it("should be this for the value (the valid partion)", function() {\r
350         function appendBegin(num) {\r
351           frame.state = frame.WAITING;\r
352           frame.addBeginList(num);\r
353         };\r
354         appendBegin(0);\r
355         expect(frame.currentFrame).toBe(0);\r
356         frame.setFrame(0);\r
357         expect(frame.currentFrame).toBe(0);\r
358         expect(frame.state).toBe(frame.PLAYING);\r
359         frame.setFrame(1);\r
360         expect(frame.currentFrame).toBe(1);\r
361         expect(frame.state).toBe(frame.PLAYING);\r
362         \r
363         frame.begin = 0;\r
364         appendBegin(1);\r
365         frame.setFrame(0);\r
366         expect(frame.state).toBe(frame.PLAYING);\r
367         frame.setFrame(1);\r
368         expect(frame.state).toBe(frame.PLAYING);\r
369         frame.setFrame(2);\r
370         expect(frame.state).toBe(frame.PLAYING);\r
371         \r
372         function appendEnd(num) {\r
373           frame.state = frame.WAITING;\r
374           frame.begin = 0;\r
375           frame.addEndList(num);\r
376         };\r
377         \r
378         appendEnd(3);\r
379         frame.setFrame(0);\r
380         expect(frame.state).toBe(frame.PLAYING);\r
381         frame.setFrame(1);\r
382         expect(frame.state).toBe(frame.PLAYING);\r
383         frame.setFrame(2);\r
384         expect(frame.state).toBe(frame.PLAYING);\r
385         frame.setFrame(3);\r
386         expect(frame.state).toBe(frame.POSTWAITING);\r
387         frame.setFrame(4);\r
388         expect(frame.state).toBe(frame.POSTWAITING);\r
389         \r
390         appendBegin(5);\r
391         frame.setFrame(0);\r
392         expect(frame.state).toBe(frame.PLAYING);\r
393         frame.setFrame(1);\r
394         expect(frame.state).toBe(frame.PLAYING);\r
395         frame.setFrame(2);\r
396         expect(frame.state).toBe(frame.PLAYING);\r
397         frame.setFrame(3);\r
398         expect(frame.state).toBe(frame.POSTWAITING);\r
399         frame.setFrame(4);\r
400         expect(frame.state).toBe(frame.POSTWAITING);\r
401         frame.setFrame(5);\r
402         expect(frame.state).toBe(frame.PLAYING);\r
403         frame.setFrame(6);\r
404         expect(frame.state).toBe(frame.PLAYING);\r
405         \r
406         appendEnd(6);\r
407         frame.setFrame(0);\r
408         expect(frame.state).toBe(frame.PLAYING);\r
409         expect(frame.currentFrame).toBe(0);\r
410         frame.setFrame(1);\r
411         expect(frame.state).toBe(frame.PLAYING);\r
412         expect(frame.currentFrame).toBe(1);\r
413         frame.setFrame(2);\r
414         expect(frame.state).toBe(frame.PLAYING);\r
415         expect(frame.currentFrame).toBe(2);\r
416         frame.setFrame(3);\r
417         expect(frame.state).toBe(frame.POSTWAITING);\r
418         frame.setFrame(4);\r
419         expect(frame.state).toBe(frame.POSTWAITING);\r
420         frame.setFrame(5);\r
421         expect(frame.state).toBe(frame.PLAYING);\r
422         frame.setFrame(6);\r
423         expect(frame.state).toBe(frame.POSTWAITING);\r
424         expect(frame.currentFrame).toBe(6);\r
425         \r
426         /*負荷テスト*/\r
427         for (var i=0;i<10000;++i) {\r
428           frame.setFrame(i);\r
429         }\r
430         \r
431         frame.beginList = base("$frame").$listbeginList;\r
432         frame.endList = base("$frame").$list.endList;\r
433         frame.state = frame.WAITING;\r
434         frame.begin = 0;\r
435         var obj = { name: "", value: 0};\r
436         frame.addEvent("begin", function(evt) { obj.name = "a";});\r
437         frame.beginList = {\r
438             value: 0,\r
439             next: frame.beginList\r
440         };\r
441         frame.setFrame(0);\r
442         expect(frame.currentFrame).toBe(0);\r
443         expect(frame.state).toBe(frame.PLAYING);\r
444         expect(obj.name).toBe("a");\r
445         frame.addEvent("play", function(evt) { obj.name = "b";});\r
446         frame.setFrame(1);\r
447         expect(frame.state).toBe(frame.PLAYING);\r
448         expect(obj.name).toBe("b");\r
449         frame.addEvent("end", function(evt) { obj.value = 1;});\r
450         frame.endList = {\r
451             value: 0,\r
452             next: frame.endList\r
453         };\r
454         frame.setFrame(0);\r
455         expect(frame.currentFrame).toBe(0);\r
456         expect(frame.state).toBe(frame.POSTWAITING);\r
457         expect(obj.value).toBe(1);\r
458         var t = 0;\r
459         frame.addEvent("begin", function(evt) {\r
460           expect(evt.state).toBe(frame.BEGINNING);\r
461           t = 1;\r
462         });\r
463         frame.addEvent("end", function(evt) {\r
464           expect(evt.state).toBe(frame.ENDING);\r
465           t = 2;\r
466         });\r
467         frame.addEvent("play", function(evt) {\r
468           expect(evt.state).toBe(frame.PLAYING);\r
469           t = 3;\r
470         });\r
471         frame.setFrame(0);\r
472         expect(t).toBe(2);\r
473         \r
474         t=0;\r
475         frame.begin = 0;\r
476         frame.state = frame.WAITING;\r
477         expect(frame.getMaxList(12, frame.endList)).toBe(0);\r
478         frame.setFrame(12);\r
479         expect(frame.state).toBe(frame.POSTWAITING);\r
480         expect(t).toBe(2);\r
481         \r
482         /*addBeginListメソッドのチェックなど*/\r
483         expect(frame.addBeginList(1).value).toBe(1);\r
484         expect(frame.addBeginList(0).value).toBe(0);\r
485         expect(frame.beginList.next.value).toBe(1);\r
486         expect(frame.addBeginList(2).value).toBe(2);\r
487         expect(frame.beginList.next.value).toBe(0);\r
488         \r
489         expect(frame.addEndList(1).value).toBe(1);\r
490         expect(frame.addEndList(0).value).toBe(0);\r
491         expect(frame.endList.next.value).toBe(1);\r
492         expect(frame.addEndList(2).value).toBe(2);\r
493         expect(frame.endList.next.value).toBe(0);\r
494       } );\r
495     } );\r
496   } );\r
497   describe("$begin object", function() {\r
498     var begin = base("$frame").$begin.up();\r
499     /*境界条件を調べておく (limit value analysis)*/\r
500     it("should be this for the value  (limit value analysis)", function() {\r
501       expect(begin.string).toBe("");\r
502       expect(begin.isResolved).toBeFalsy();\r
503       expect(begin.eventTarget).toBe(document.documentElement);\r
504       expect(begin.eventOffset).toBe(0);\r
505       expect(begin.repeat).toBe(0);\r
506       expect(begin.accessKey).toBe("");\r
507     } );\r
508     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
509     it("should be this for the value (the valid partion)", function() {\r
510       begin.string = " hoge ";\r
511       expect(begin.string).toBe(" hoge ");\r
512       var $list = begin.$list;\r
513       expect(begin.$list).toBe($list);\r
514       expect(begin.updateList().$list).not.toBe($list);\r
515     } );\r
516     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
517     it("should be this for the value (the invalid partion)", function() {\r
518     } );\r
519     \r
520     describe("A trim method in $begin object", function() {\r
521       /*境界条件を調べておく (limit value analysis)*/\r
522       beforeEach( function() {\r
523         begin.string = "";\r
524       } );\r
525       it("should be this for the value  (limit value analysis)", function() {\r
526         delete begin.string;\r
527         expect(begin.trim(" ")).toBe("");\r
528         expect( function() {\r
529           begin.trim();\r
530         } ).toThrow();\r
531       } );\r
532       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
533       it("should be this for the value (the valid partion)", function() {\r
534         expect(begin.trim(" hoge ")).toBe("hoge");\r
535         expect(begin.trim(" h o g e ")).toBe("hoge");\r
536         expect(begin.trim(" h  o  g     e ")).toBe("hoge");\r
537         expect(begin.trim("   h  o  g    12 +  e   ")).toBe("hog12+e");\r
538       } );\r
539       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
540       it("should be this for the value (the invalid partion)", function() {\r
541         expect( function() {\r
542           begin.trim(1);\r
543         } ).toThrow();\r
544         expect( function() {\r
545           begin.trim({});\r
546         } ).toThrow();\r
547       } );\r
548     } );\r
549 \r
550     describe("An offset method in $begin object", function() {\r
551       beforeEach( function() {\r
552         begin.string = "";\r
553       } );\r
554       /*境界条件を調べておく (limit value analysis)*/\r
555       it("should be this for the value  (limit value analysis)", function() {\r
556         expect(begin.offset(begin.trim(" "))).toBe(0);\r
557         expect(begin.offset(begin.trim(" 0 "))).toBe(0);\r
558         expect(begin.offset(begin.trim("+0ms"))).toBe(0);\r
559         expect(begin.offset(begin.trim("-0ms"))).toBe(0);\r
560         expect(begin.offset(begin.trim("1ms"))).toBe(1);\r
561         expect(begin.offset(begin.trim("-1ms"))).toBe(-1);\r
562 \r
563         expect(begin.offset("+0s")).toBe(0);\r
564         expect(begin.offset("-0s")).toBe(0);\r
565         expect(begin.offset("1s")).toBe(1000);\r
566         expect(begin.offset("-1s")).toBe(-1000);\r
567 \r
568         expect(begin.offset("+0min")).toBe(0);\r
569         expect(begin.offset("-0min")).toBe(0);\r
570         expect(begin.offset("1min")).toBe(60000);\r
571         expect(begin.offset("-1min")).toBe(-60000);\r
572 \r
573         expect(begin.offset("+0h")).toBe(0);\r
574         expect(begin.offset("-0h")).toBe(0);\r
575         expect(begin.offset("1h")).toBe(60*60*1000);\r
576         expect(begin.offset("-1h")).toBe(-3600000);\r
577 \r
578         expect(begin.offset("00:0")).toBe(0);\r
579         expect(begin.offset("00:00:0.0")).toBe(0);\r
580         expect(begin.offset("-00:0")).toBe(0);\r
581         expect(begin.offset("-00:00:0.0")).toBe(0);\r
582         expect(begin.offset("00:1")).toBe(1000);\r
583         expect(begin.offset("-00:1")).toBe(-1000);\r
584         expect(begin.offset("00:00:1")).toBe(1000);\r
585         expect(begin.offset("-00:00:1")).toBe(-1000);\r
586 \r
587         expect(begin.offset()).toBe(0);\r
588       } );\r
589       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
590       it("should be this for the value (the valid partion)", function() {\r
591         expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);\r
592         expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);\r
593         expect(begin.offset(begin.trim("1000ms"))).toBe(1000);\r
594         expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);\r
595 \r
596         expect(begin.offset("+100s")).toBe(100 * 1000);\r
597         expect(begin.offset("-121s")).toBe(-121 * 1000);\r
598         expect(begin.offset("1.25s")).toBe(1.25 * 1000);\r
599         expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);\r
600         expect(begin.offset(".20s")).toBe(0.20 * 1000);\r
601 \r
602         expect(begin.offset("+100min")).toBe(100 * 60000);\r
603         expect(begin.offset("-121min")).toBe(-121 * 60000);\r
604         expect(begin.offset("1.25min")).toBe(1.25 * 60000);\r
605         expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);\r
606         expect(begin.offset(".20min")).toBe(0.20 * 60000);\r
607 \r
608         expect(begin.offset("+100h")).toBe(100 * 3600000);\r
609         expect(begin.offset("-121h")).toBe(-121 * 3600000);\r
610         expect(begin.offset("1.25h")).toBe(1.25 * 3600000);\r
611         expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);\r
612         expect(begin.offset(".20h")).toBe(0.20 * 3600000);\r
613 \r
614         expect(begin.offset("01:0")).toBe(60000);\r
615         expect(begin.offset("-01:0")).toBe(-60000);\r
616         expect(begin.offset("00:00:1")).toBe(1000);\r
617         expect(begin.offset("-00:00:1")).toBe(-1000);\r
618         expect(begin.offset("00:01:0")).toBe(60000);\r
619         expect(begin.offset("-00:01:0")).toBe(-60000);\r
620         expect(begin.offset("01:00:0")).toBe(3600000);\r
621         expect(begin.offset("-01:00:0")).toBe(-3600000);\r
622         expect(begin.offset("00:10")).toBe(10000);\r
623         expect(begin.offset("00:0.01")).toBe(10);\r
624         expect(begin.offset("01:0.01")).toBe(60010);\r
625         expect(begin.offset("10:0")).toBe(600000);\r
626         expect(begin.offset("-00:10")).toBe(-10000);\r
627         expect(begin.offset("-00:0.01")).toBe(-10);\r
628         expect(begin.offset("-01:0.01")).toBe(-60010);\r
629         expect(begin.offset("-10:0")).toBe(-600000);\r
630         expect(begin.offset("00:00:20")).toBe(20000);\r
631         expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);\r
632         expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);\r
633         expect(begin.offset("-10:0")).toBe(-600000);\r
634         expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);\r
635       } );\r
636       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
637       it("should be this for the value (the invalid partion)", function() {\r
638         expect(begin.offset(begin.trim(" h  o  g     1e "))).toBe(0);\r
639         expect(begin.offset("ms")).toBe(0);\r
640         expect(begin.offset(".s")).toBe(0);\r
641         expect(begin.offset("10:")).toBe(0);\r
642         expect(begin.offset("::")).toBe(0);\r
643         expect(begin.offset("-:0")).toBe(0);\r
644         expect(begin.offset("-::0")).toBe(0);\r
645       } );\r
646     } );\r
647     describe("An event method in $begin object", function() {\r
648       /*境界条件を調べておく (limit value analysis)*/\r
649       it("should be this for the value  (limit value analysis)", function() {\r
650         var evt = begin.event();\r
651         expect(evt.id).toBe("");\r
652         expect(evt.event).toBe("");\r
653         evt = begin.event("");\r
654         expect(evt.id).toBe("");\r
655         expect(evt.event).toBe("");\r
656         evt = begin.event(".");\r
657         expect(evt.id).toBe("");\r
658         expect(evt.event).toBe("");\r
659 \r
660         evt = begin.event("a");\r
661         expect(evt.id).toBe("");\r
662         expect(evt.event).toBe("a");\r
663         evt = begin.event("a.b");\r
664         expect(evt.id).toBe("a");\r
665         expect(evt.event).toBe("b");\r
666       } );\r
667       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
668       it("should be this for the value (the valid partion)", function() {\r
669         var evt = begin.event("id.event");\r
670         expect(evt.id).toBe("id");\r
671         expect(evt.event).toBe("event");\r
672         evt = begin.event("event");\r
673         expect(evt.id).toBe("");\r
674         expect(evt.event).toBe("event");\r
675         \r
676         evt = begin.event("event+0s");\r
677         expect(evt.id).toBe("");\r
678         expect(evt.event).toBe("event");\r
679         evt = begin.event("event-0s");\r
680         expect(evt.id).toBe("");\r
681         expect(evt.event).toBe("event");\r
682       } );\r
683       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
684       it("should be this for the value (the invalid partion)", function() {\r
685         evt = begin.event("...");\r
686         expect(evt.id).toBe("");\r
687         expect(evt.event).toBe("");\r
688         evt = begin.event(".event");\r
689         expect(evt.id).toBe("");\r
690         expect(evt.event).toBe("");\r
691         evt = begin.event("id.");\r
692         expect(evt.id).toBe("");\r
693         expect(evt.event).toBe("");\r
694       } );\r
695     } );\r
696     \r
697     describe("An parse method in $begin object", function() {\r
698        beforeEach( function() {\r
699         begin.string = "";\r
700       } );\r
701       /*境界条件を調べておく (limit value analysis)*/\r
702       it("should be this for the value  (limit value analysis)", function() {\r
703         expect(begin.parse().begin).toBe(0);\r
704         expect(begin.isResolved).toBeTruthy();\r
705         begin.string="+0";\r
706         expect(begin.parse().begin).toBe(0);\r
707         begin.string = "+1";\r
708         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
709         begin.string = " ";\r
710         expect(begin.parse().begin).toBe(0);\r
711         begin.string = "1";\r
712         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
713         begin.string = "+0ms";\r
714         expect(begin.parse().begin).toBe(0);\r
715         begin.string = "-0ms";\r
716         expect(begin.parse().begin).toBe(0);\r
717         begin.string = "-0ms;-0ms";\r
718         expect(begin.parse().begin).toBe(0);\r
719         begin.string = "-0ms;1";\r
720         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
721         \r
722         expect(begin.eventOffset).toBe(0);\r
723         begin.string = "click";\r
724         expect(begin.parse().begin).toBe(0);\r
725         expect(begin.eventOffset).toBe(0);\r
726         expect(begin.repeat).toBe(0);\r
727         expect(begin.accessKey).toBe("");\r
728         begin.string = "id.click";\r
729         expect(begin.parse().begin).toBe(0);\r
730         expect(begin.eventOffset).toBe(0);\r
731         expect(begin.repeat).toBe(0);\r
732         expect(begin.accessKey).toBe("");\r
733         \r
734         begin.string = "repeat";\r
735         expect(begin.parse().begin).toBe(0);\r
736         expect(begin.eventOffset).toBe(0);\r
737         expect(begin.repeat).toBe(0);\r
738         expect(begin.accessKey).toBe("");\r
739         begin.string = "repeat(1)";\r
740         expect(begin.parse().begin).toBe(0);\r
741         expect(begin.eventOffset).toBe(0);\r
742         expect(begin.repeat).toBe(1);\r
743         expect(begin.accessKey).toBe("");\r
744         \r
745         begin.string = "accessKey(a)";\r
746         expect(begin.parse().begin).toBe(0);\r
747         expect(begin.eventOffset).toBe(0);\r
748         expect(begin.repeat).toBe(0);\r
749         expect(begin.accessKey).toBe("a");\r
750       } );\r
751       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
752       it("should be this for the value (the valid partion)", function() {\r
753         begin.string = " 1 0 0 m s";\r
754         expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));\r
755 \r
756         begin.string = "1ms";\r
757         begin.isResolved = false;\r
758         expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));\r
759         expect(begin.isResolved).toBeTruthy();\r
760         expect(begin.eventOffset).toBe(0);\r
761 \r
762         begin.string="click+0";\r
763         expect(begin.parse().begin).toBe(0);\r
764         expect(begin.eventOffset).toBe(0);\r
765         expect(begin.isResolved).toBeFalsy();\r
766         begin.string = "click+1";\r
767         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
768         expect(begin.eventOffset).toBe(1000*begin.fpms);\r
769         begin.string = " click ";\r
770         expect(begin.parse().begin).toBe(0);\r
771         expect(begin.eventOffset).toBe(0);\r
772         begin.string = "click+0ms";\r
773         expect(begin.parse().begin).toBe(0);\r
774         expect(begin.eventOffset).toBe(0);\r
775         expect(begin.isResolved).toBeFalsy();\r
776         begin.string = "click-0ms";\r
777         expect(begin.parse().begin).toBe(0);\r
778         expect(begin.eventOffset).toBe(0);\r
779         begin.string = "click+100ms";\r
780         expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));\r
781         expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));\r
782         begin.string = "click-100ms";\r
783         expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));\r
784         expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));\r
785 \r
786         begin.string="id.click+0";\r
787         expect(begin.parse().begin).toBe(0);\r
788         expect(begin.eventOffset).toBe(0);\r
789         expect(begin.isResolved).toBeFalsy();\r
790         begin.string = "id.click+1";\r
791         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
792         expect(begin.eventOffset).toBe(1000*begin.fpms);\r
793         expect(begin.isResolved).toBeFalsy();\r
794         begin.string = " id . click ";\r
795         expect(begin.parse().begin).toBe(0);\r
796         expect(begin.eventOffset).toBe(0);\r
797         expect(begin.isResolved).toBeFalsy();\r
798         begin.string = "id.click+0ms";\r
799         expect(begin.parse().begin).toBe(0);\r
800         expect(begin.eventOffset).toBe(0);\r
801         begin.string = "id.click-0ms";\r
802         expect(begin.parse().begin).toBe(0);\r
803         expect(begin.eventOffset).toBe(0);\r
804         begin.string = "id.click+100ms";\r
805         expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));\r
806         expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));\r
807         begin.string = "id.click-100ms";\r
808         expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));\r
809         expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));\r
810       } );\r
811       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
812       it("should be this for the value (the invalid partion)", function() {\r
813         begin.string = "ms";\r
814         begin.isResolved = false;\r
815         expect(begin.parse().begin).toBe(0);\r
816         expect(begin.isResolved).toBeFalsy();\r
817         \r
818         begin.isResolved = true;\r
819         begin.string = "indefinite";\r
820         expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));\r
821         expect(begin.isResolved).toBeFalsy();\r
822       } );\r
823     } );\r
824   } );\r
825   describe("A $end object", function() {\r
826     var end = base("$frame").$begin.$end.up();\r
827     end.startTime = 0;\r
828     beforeEach( function() {\r
829       end.string = "";\r
830       end.startTime = Date.now();\r
831       end.setFrame(0);\r
832     } );\r
833     /*境界条件を調べておく (limit value analysis)*/\r
834     it("should be this for the value  (limit value analysis)", function() {\r
835       expect(end.up().call()).toBeNull();\r
836       end.string = "0";\r
837       expect(end.up().call()).toBe(0);\r
838       end.string = "hoge";\r
839       expect(end.up().call()).toBe("indefinite");\r
840       \r
841     } );\r
842     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
843     it("should be this for the value (the valid partion)", function() {\r
844       end.string = "hoge+0";\r
845       expect(end.up().call()).toBe("indefinite");\r
846       end.string = "12ms";\r
847       expect(end.up().call()).toBe(Math.floor(12*end.fpms));\r
848       end.string = "hoge+12ms";\r
849       expect(end.up().call()).toBe("indefinite");\r
850 \r
851     } );\r
852     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
853     it("should be this for the value (the invalid partion)", function() {\r
854       end.string = null;\r
855       expect(end.up().call()).toBeNull();\r
856     } );\r
857   } );\r
858   describe("A $activate object", function() {\r
859     var act = base("$frame").$begin.$activate.up();\r
860      beforeEach( function() {\r
861       act.dur = "indefinite";\r
862       act.begin = 0;\r
863       act.repeatCount = null;\r
864       act.repeatDur = null;\r
865       act.end = act.$begin.$end;\r
866       act.simpleDur = base("$frame").$begin.$activate.simpleDur;\r
867     } );\r
868     /*境界条件を調べておく (limit value analysis)*/\r
869     it("should be this for the value  (limit value analysis)", function() {\r
870       expect(act.dur).toBe("indefinite");\r
871       expect(typeof act.resolvedTime).toBe("function");\r
872       expect(act.end).toBe(act.$begin.$end);\r
873       expect(act.repeatCount).toBeNull();\r
874       expect(act.repeatDur).toBeNull();\r
875       expect(act.simpleDur()).toBeNull();\r
876       expect(act.min).toBe("0");\r
877       expect(act.max).toBe("indefinite");\r
878 \r
879       act.up("$a");\r
880       expect(act.$a.call()).toBeNull();\r
881       expect(act.$a.end).toBeNull();\r
882     } );\r
883     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
884     it("should be this for the value (the valid partion)", function() {\r
885       expect(act.resolvedTime()).not.toBe(0);\r
886 \r
887       /*Activate Duration = dur*/\r
888       act.up("$b");\r
889       act.$b.dur = "132ms";\r
890       var abc = act.$b.call();\r
891       expect(abc).toBe(Math.floor(132*act.fpms));\r
892       expect(abc).toBe(act.$b.simpleDur);\r
893       act.dur = null;\r
894       expect(act.up().call()).toBeNull();\r
895 \r
896       act.up("$c");\r
897       act.$c.mix( {\r
898         dur: "10",\r
899         simpleDur: act.simpleDur,
900         repeatCount: null,\r
901         repeatDur: null\r
902       } );\r
903       expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
904       expect(act.$c.call()).toBe(act.$c.simpleDur);\r
905       act.$c.mix( {\r
906         dur: "15",\r
907         simpleDur: act.simpleDur,
908         repeatCount: null,\r
909         repeatDur: null\r
910       } );\r
911       expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));\r
912 \r
913       /*AD = repeatCount*dur*/\r
914       act.$c.mix( {\r
915         dur: "10",\r
916         simpleDur: act.simpleDur,
917         repeatCount: 2,\r
918         repeatDur: null\r
919       } );\r
920       act.$c.call();\r
921       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
922       act.$c.mix( {\r
923         dur: "10",\r
924         simpleDur: act.simpleDur,
925         repeatCount: 1,\r
926         repeatDur: null\r
927       } );\r
928       expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
929       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
930 \r
931       /*AD = repeatDur*/\r
932       act.$c.mix( {\r
933         dur: "indefinite",\r
934         simpleDur: act.simpleDur,
935         repeatCount: 2,\r
936         repeatDur: "15"\r
937       } );\r
938       act.$c.call();\r
939       expect(act.$c.simpleDur).toBeNull();\r
940       act.$c.mix( {\r
941         dur: "indefinite",\r
942         simpleDur: act.simpleDur,
943         repeatCount: 2,\r
944         repeatDur: "10"\r
945       } );\r
946       expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
947       expect(act.$c.simpleDur).toBeNull();\r
948       act.$c.mix( {\r
949         dur: "10",\r
950         simpleDur: act.simpleDur,
951         repeatCount: null,\r
952         repeatDur: "15"\r
953       } );\r
954       act.$c.call();\r
955       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
956       act.$c.mix( {\r
957         dur: "10",\r
958         simpleDur: act.simpleDur,
959         repeatCount: null,\r
960         repeatDur: "11"\r
961       } );\r
962       expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));\r
963       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
964       \r
965       /*AD = Min(repeatCount*d, repeatDur)*/\r
966       act.$c.mix( {\r
967         dur: "10",\r
968         simpleDur: act.simpleDur,
969         repeatCount: 2,\r
970         repeatDur: "15"\r
971       } );\r
972       act.$c.call();\r
973       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
974       act.$c.mix( {\r
975         dur: "10",\r
976         simpleDur: act.simpleDur,
977         repeatCount: 1,\r
978         repeatDur: "15"\r
979       } );\r
980       expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
981       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
982       act.$c.mix( {\r
983         dur: "11",\r
984         simpleDur: act.simpleDur,
985         repeatCount: 1,\r
986         repeatDur: "9"\r
987       } );\r
988       expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));\r
989       expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));\r
990 \r
991       /*AD = repeatDur,*/\r
992       act.$c.mix( {\r
993         end: null,\r
994         dur: "10",\r
995         simpleDur: act.simpleDur,
996         repeatCount: null,\r
997         repeatDur: "15"\r
998       } );\r
999       expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));\r
1000       expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
1001       act.$c.mix( {\r
1002         dur: "indefinite",\r
1003         simpleDur: act.simpleDur,
1004         repeatCount: 2,\r
1005         repeatDur: "10"\r
1006       } );\r
1007       expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
1008       expect(act.$c.simpleDur).toBeNull();\r
1009 \r
1010       act.end.string = null;\r
1011       act.up("$cd").mix( {\r
1012         dur: "10",\r
1013         end: act.end,\r
1014         repeatCount: 2\r
1015       } );\r
1016       expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);\r
1017       \r
1018       act.$cd.end = act.end;\r
1019       act.$cd.repeatCount = null;\r
1020       act.$cd.repeatDur = "12";\r
1021       expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));\r
1022       \r
1023       act.up("$d").mix( {\r
1024         min: "2",\r
1025         max: "3",\r
1026         dur: "1",\r
1027         simpleDur: act.simpleDur\r
1028       } );\r
1029       expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));\r
1030       act.up("$d").mix( {\r
1031         min: "1",\r
1032         max: "2",\r
1033         dur: "12",\r
1034         simpleDur: act.simpleDur\r
1035       } );\r
1036       expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));\r
1037       \r
1038       /*endで0が指定されている場合*/\r
1039       act.begin = 0;\r
1040       act.end = 0;\r
1041       act.repeatDur = null;\r
1042       act.repeatCount = "indefinite";\r
1043       act.dur = "1";\r
1044       expect(act.call()).toBeNull();\r
1045       act.repeatCount = null;\r
1046       act.repeatDur = "indefinite";\r
1047       act.dur = "1";\r
1048       expect(act.call()).toBeNull();\r
1049       act.repeatDur = "indefinite";\r
1050       act.repeatCount = "indefinite";\r
1051       act.dur = "1";\r
1052       expect(act.call()).toBeNull();\r
1053     } );\r
1054     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1055     it("should be this for the value (the invalid partion)", function() {\r
1056       /*min > max*/\r
1057       act.up("$d").mix( {\r
1058         min: "3",\r
1059         max: "2",\r
1060         dur: "1",\r
1061         simpleDur: act.simpleDur\r
1062       } );\r
1063       expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));\r
1064       \r
1065       act.repeatDur = null;\r
1066       act.repeatCount = "indefinite";\r
1067       act.dur = "1";\r
1068       expect(act.call()).toBeNull();\r
1069       act.repeatCount = null;\r
1070       act.repeatDur = "indefinite";\r
1071       act.dur = "1";\r
1072       expect(act.call()).toBeNull();\r
1073       act.repeatDur = "indefinite";\r
1074       act.repeatCount = "indefinite";\r
1075       act.dur = "1";\r
1076       expect(act.call()).toBeNull();\r
1077     } );\r
1078   } );\r
1079   describe("A $from object", function() {\r
1080     var from = base("$from");\r
1081      beforeEach( function() {\r
1082        from = base("$from").up();\r
1083        from.from = from.from.up();\r
1084        from.string = "";\r
1085      } );\r
1086     /*境界条件を調べておく (limit value analysis)*/\r
1087     it("should be this for the value  (limit value analysis)", function() {\r
1088       expect(from.string).toBe("");\r
1089       expect(from.numList()).toEqual([]);\r
1090       expect(from.strList()).toBeNull();\r
1091 \r
1092       from.string = "0";\r
1093       expect(from.numList()[0]).toBe(0);\r
1094       expect(from.strList()).toBeNull();\r
1095       \r
1096       from.string = " 0 ";\r
1097       expect(from.numList()[0]).toBe(0);\r
1098       expect(from.strList().join("")).toBe("  ");\r
1099 \r
1100       from.string = "a";\r
1101       expect(from.numList()).toEqual([]);\r
1102       expect(from.strList()[0]).toBe("a");\r
1103       \r
1104       /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから\r
1105        * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/\r
1106       \r
1107       from.string = null;\r
1108       expect( function() {\r
1109         from.numList();\r
1110       } ).toThrow();\r
1111       expect( function() {\r
1112         from.strList();\r
1113       } ).toThrow();\r
1114       \r
1115       expect(from.additive[0]).toBe(0);\r
1116       expect(from.accumulate[0]).toBe(0);\r
1117     } );\r
1118     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1119     it("should be this for the value (the valid partion)", function() {\r
1120       from.string = "0a";\r
1121       expect(from.numList()[0]).toBe(0);\r
1122       expect(from.strList()[0]).toBe("a");\r
1123 \r
1124       from.string = "a0";\r
1125       expect(from.numList()[0]).toBe(0);\r
1126       expect(from.strList()[0]).toBe("a");\r
1127 \r
1128       from.string = "0.1";\r
1129       expect(from.numList()[0]).toBe(0.1);\r
1130       expect(from.strList()).toBeNull();\r
1131 \r
1132       from.string = "+0.1";\r
1133       expect(from.numList()[0]).toBe(0.1);\r
1134       expect(from.strList()).toBeNull();\r
1135 \r
1136       from.string = "-0.1";\r
1137       expect(from.numList()[0]).toBe(-0.1);\r
1138       expect(from.strList()).toBeNull();\r
1139 \r
1140       from.string = "1e-1";\r
1141       expect(from.numList()[0]).toBe(1e-1);\r
1142       expect(from.strList()).toBeNull();\r
1143 \r
1144       from.string = "1E-1";\r
1145       expect(from.numList()[0]).toBe(1E-1);\r
1146       expect(from.strList()).toBeNull();\r
1147 \r
1148       from.string = "0,0";\r
1149       expect(from.numList().toString()).toBe("0,0");\r
1150       expect(from.strList().join("")).toBe(",");\r
1151 \r
1152       from.string = "a00a";\r
1153       expect(from.numList()[0]).toBe(0);\r
1154       expect(from.strList().join("")).toBe("aa");\r
1155 \r
1156       from.string = "a0b0a";\r
1157       expect(from.numList().toString()).toBe("0,0");\r
1158       expect(from.strList().join("")).toBe("aba");\r
1159 \r
1160       from.string = "0b0a";\r
1161       expect(from.numList().toString()).toBe("0,0");\r
1162       expect(from.strList().join("")).toBe("ba");\r
1163 \r
1164       from.string = "0b-1.0a";\r
1165       expect(from.numList()[1]).toBe(-1);\r
1166       expect(from.strList().join("")).toBe("ba");\r
1167 \r
1168       expect(from.up().call()).toBe(from.$1.numList);\r
1169       expect(from.$1.numList[1]).toBe(-1);\r
1170       expect(from.$1.strList.join("")).toBe("ba");\r
1171 \r
1172       from.string = "あ 0b-1.0a12";\r
1173       expect(from.numList()[1]).toBe(-1);\r
1174       expect(from.strList().join("")).toBe("あ ba12");\r
1175 \r
1176       from.string = "0b-1.0a0";\r
1177       expect(from.numList().join(",")).toBe("0,-1,0");\r
1178       expect(from.strList().join("")).toBe("ba");\r
1179 \r
1180       from.string = "0b .1a";\r
1181       expect(from.numList()[1]).toBe(0.1);\r
1182       expect(from.strList().join("")).toBe("b a");\r
1183     } );\r
1184     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1185     it("should be this for the value (the invalid partion)", function() {\r
1186       from.string = NaN;\r
1187       expect(function(){\r
1188         from.numList();\r
1189       } ).toThrow();\r
1190       expect(function(){\r
1191         from.strList();\r
1192       } ).toThrow();      \r
1193       \r
1194       from.string = "currentColor";\r
1195       expect(from.numList()).toEqual([]);\r
1196       expect(from.strList()[0]).toBe("currentColor");\r
1197 \r
1198       from.string = "eE";\r
1199       expect(from.numList()).toEqual([]);\r
1200       expect(from.strList()[0]).toBe("eE");\r
1201       expect(from.strList()[0]).toBe("eE");\r
1202     } )\r
1203   } );\r
1204   describe("A $to object", function() {\r
1205     var from = base("$from");\r
1206      beforeEach( function() {\r
1207        from = base("$from").up();\r
1208        from.up("$to");\r
1209        from.string = "";\r
1210      } );\r
1211     /*境界条件を調べておく (limit value analysis)*/\r
1212     it("should be this for the value  (limit value analysis)", function() {\r
1213       expect(from.$to instanceof from.constructor).toBeTruthy();\r
1214       expect(from.up().call()).toBe(from.$1.numList);\r
1215       expect(from.$to.up().call()).toBe(from.$to.$1.numList);\r
1216     } );\r
1217     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1218     it("should be this for the value (the valid partion)", function() {\r
1219       from.up("$to");\r
1220       from.$to.from = from;\r
1221       from.$to.string = "12cm-7";\r
1222       expect(from.$to.numList().join(",")).toBe("12,-7");\r
1223       expect(from.$to.strList().toString()).toBe("cm");\r
1224       \r
1225       from.string = "7cm+8";\r
1226       from.$to.call();\r
1227       expect(from.call()).toBe(from.numList);\r
1228       expect(from.$to.numList.join(",")).toBe("12,-7");\r
1229       expect(from.$to.strList.join("")).toBe("cm");\r
1230       expect(from.numList.join(",")).toBe("7,8");\r
1231       expect(from.strList.join("")).toBe("cm");\r
1232       expect(from.$to.from).toBe(from.numList);\r
1233 \r
1234     } );\r
1235     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1236     it("should be this for the value (the invalid partion)", function() {\r
1237       from.call();\r
1238       from.up("$to").mix( function() {\r
1239         this.string = "12cm";\r
1240         this.call();\r
1241         var arr = [];\r
1242         arr.string = this.string;\r
1243         expect(this.numList).toEqual(arr);\r
1244         expect(this.strList).toBeNull();\r
1245       } );\r
1246     } );\r
1247     \r
1248     describe("An advance method", function() {\r
1249       var from = base("$from");\r
1250        beforeEach( function() {\r
1251          from = base("$from").up();\r
1252          from.string = "";\r
1253          from.up("$to");\r
1254          from.$to.from = from;\r
1255        } );\r
1256       /*境界条件を調べておく (limit value analysis)*/\r
1257       it("should be this for the value  (limit value analysis)", function() {\r
1258         expect(from.advance()).toBe("");\r
1259         expect(from.$to.advance()).toBe("");\r
1260         expect(from.$to.advance(0)).toBe("");\r
1261         expect(from.$to.advance(1)).toBe("");\r
1262         expect(function(){\r
1263           from.$to.advance(1.01);\r
1264         }).toThrow("An Invalid Number Error");\r
1265         expect(function(){\r
1266           from.$to.advance(-0.01);\r
1267         }).toThrow("An Invalid Number Error");\r
1268         \r
1269         var arr = [];\r
1270         \r
1271         from = base("$from").up();\r
1272         from.up("$to");\r
1273         from.$to.from = from;\r
1274         arr.string = from.string = "0";\r
1275         from.$to.string = "1";\r
1276         expect(from.$to.call()).toBe(from.$to.numList);\r
1277         expect(from.$to.numList[0]).toBe(1);\r
1278         expect(from.$to.strList).toBeNull();\r
1279         expect(from.numList[0]).toBe(0);\r
1280         expect(from.strList).toBeNull();\r
1281         expect(from.advance(0)).toBe("");\r
1282         expect(from.$to.from).toBe(from.numList);\r
1283         expect(from.$to.advance(0)).toBe("0");       \r
1284         expect(from.call()).toBe(from.numList);\r
1285         \r
1286         from = base("$from").up();\r
1287         f(from.up(), "inline", "block");\r
1288         f(from.up(), " inline", " block ");\r
1289         function f(from, inline, block) {\r
1290           from.up("$to");\r
1291           from.$to.from = from;\r
1292           from.string = inline;\r
1293           arr.string = from.$to.string = block;\r
1294           expect(from.$to.call()).toBe(from.$to.numList);\r
1295           expect(from.$to.numList).toEqual(arr);\r
1296           expect(from.$to.strList).toEqual([block]);\r
1297           arr.string = from.string;\r
1298           expect(from.numList).toEqual(arr);\r
1299           expect(from.strList).toEqual([inline]);\r
1300           expect(from.advance(0)).toBe("");\r
1301           expect(from.$to.from).toBe(from.numList);\r
1302           expect(from.$to.advance(0)).toBe("inline");\r
1303           expect(from.$to.advance(1)).toBe("block");\r
1304           expect(from.call()).toBe(from.numList);\r
1305         }\r
1306       } );\r
1307       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1308       it("should be this for the value (the valid partion)", function() {\r
1309         var deg = 3;\r
1310         \r
1311         from.string = "0s";\r
1312         from.$to.string = "1s";\r
1313         expect(from.$to.call()).toBe(from.$to.numList);\r
1314         expect(from.$to.numList[0]).toBe(1);\r
1315         expect(from.$to.strList[0]).toBe("");\r
1316         expect(from.numList[0]).toBe(0);\r
1317         expect(from.strList[0]).toBe("");\r
1318         expect(from.advance(0)).toBe("");\r
1319         expect(from.$to.from).toBe(from.numList);\r
1320         expect(from.$to.advance(0)).toBe("0s");\r
1321         from.$to.degit = deg;\r
1322         for (var i=0;i<1;i+=0.01) {\r
1323           expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");\r
1324         }\r
1325         expect(from.call()).toBe(from.numList);\r
1326         \r
1327         from = base("$from").up();\r
1328         from.up("$to");\r
1329         from.string = "a0S";\r
1330         from.$to.string = "a1S";\r
1331         from.$to.from = from;\r
1332         expect(from.$to.call()).toBe(from.$to.numList);\r
1333         expect(from.$to.numList[0]).toBe(1);\r
1334         expect(from.$to.strList[0]).toBe("a");\r
1335         expect(from.numList[0]).toBe(0);\r
1336         expect(from.strList[0]).toBe("a");\r
1337         expect(from.advance(0)).toBe("");\r
1338         expect(from.$to.from).toBe(from.numList);\r
1339         expect(from.$to.advance(0)).toBe("a0S");\r
1340 \r
1341         from.$to.degit = deg;\r
1342         for (var i=0;i<1;i+=0.01) {\r
1343           expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");\r
1344         }\r
1345         expect(from.call()).toBe(from.numList);\r
1346         \r
1347         from = base("$from").up();\r
1348         f(from.up(), "a-10s1.5", "a10s-3");\r
1349         f(from.up(), " a-10s1.5", " a10s-3 ");\r
1350         function f(from, fromString, toString) {\r
1351           from.up("$to");\r
1352           from.string = fromString;\r
1353           from.$to.string = toString;\r
1354           from.$to.from = from;\r
1355           from.$to.call();\r
1356           from.$to.degit = 1;\r
1357           expect(from.$to.advance(0)).toBe("a-10.0s1.5");\r
1358           expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");\r
1359           expect(from.$to.advance(1)).toBe("a10.0s-3.0");\r
1360 \r
1361           from.$to.additive[0] = 1;\r
1362           from.$to.accumulate[1] = 2;\r
1363           expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");\r
1364           from.$to.additive[0] = 0.5;\r
1365           from.$to.accumulate[1] = 0.8;\r
1366           expect(from.$to.advance(1)).toBe("a10.5s-2.2");\r
1367         }\r
1368       } );\r
1369       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1370       it("should be this for the value (the invalid partion)", function() {\r
1371         expect(function(){\r
1372           from.$to.advance(10);\r
1373         }).toThrow("An Invalid Number Error");\r
1374         expect(function(){\r
1375           from.$to.advance(-10);\r
1376         }).toThrow("An Invalid Number Error");\r
1377       } );\r
1378     } )\r
1379   } );\r
1380   describe("A distance method", function() {\r
1381       var from = base("$from");\r
1382        beforeEach( function() {\r
1383          from = base("$from").up();\r
1384          from.string = "";\r
1385          from.up("$to");\r
1386        } );\r
1387       /*境界条件を調べておく (limit value analysis)*/\r
1388       it("should be this for the value  (limit value analysis)", function() {\r
1389         expect(from.distance()).toBe(0)\r
1390         expect(from.$to.distance()).toBe(0);\r
1391         \r
1392         from.string = "0";\r
1393         from.$to.string = "1";\r
1394         expect(from.distance()).toBe(0);\r
1395         expect(from.$to.distance(from)).toBe(1);\r
1396       } );\r
1397       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1398       it("should be this for the value (the valid partion)", function() {\r
1399         from.string = "s 0 s 12";\r
1400         from.$to.string = "s 0 s 0";\r
1401         expect(from.distance()).toBe(0);\r
1402         expect(from.$to.distance(from)).toBe(12);\r
1403         expect(from.$to.distance(from)).toBe(12);\r
1404         expect(from.$to.distance(from.call())).toBe(12);\r
1405   \r
1406         from = base("$from").up();\r
1407         from.up("$to");\r
1408         from.string = "rgb(1, 0, 0)";\r
1409         from.$to.string = "rgb(0, 0, 1)";\r
1410         expect(from.distance()).toBe(0);\r
1411         expect(from.$to.distance(from)).toBe(Math.sqrt(2));\r
1412       } );\r
1413       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1414       it("should be this for the value (the invalid partion)", function() {\r
1415         from.string = "s";\r
1416         from.$to.string = "s";\r
1417         expect(from.$to.distance(from)).toBe(0);\r
1418       } );\r
1419   } );\r
1420   describe("A setAdditive method", function() {\r
1421       var from = base("$from");\r
1422        beforeEach( function() {\r
1423          from = base("$from").up();\r
1424          from.string = "";\r
1425          from.up("$to");\r
1426        } );\r
1427       /*境界条件を調べておく (limit value analysis)*/\r
1428       it("should be this for the value  (limit value analysis)", function() {\r
1429         expect(from.setAdditive()).toBe(0);\r
1430         expect(from.setAdditive("")).toBe(0);\r
1431         expect(from.additive).toEqual([0]);\r
1432         var arr = [1];\r
1433         arr.string = "1";\r
1434         expect(from.setAdditive("1")).toEqual(arr);\r
1435         expect(from.additive).toEqual(arr);\r
1436       } );\r
1437       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1438       it("should be this for the value (the valid partion)", function() {\r
1439         var arr = [1, 2, 3];\r
1440         arr.string = "1 2, 3";\r
1441         expect(from.setAdditive("1 2, 3")).toEqual(arr);\r
1442         expect(from.additive).toEqual(arr);\r
1443       } );\r
1444       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1445       it("should be this for the value (the invalid partion)", function() {\r
1446       } );\r
1447   } );\r
1448   describe("A setAccumulate method", function() {\r
1449       var from = base("$from");\r
1450        beforeEach( function() {\r
1451          from = base("$from").up();\r
1452          from.string = "0 1";\r
1453          from.up("$to");\r
1454          from.call();\r
1455        } );\r
1456       /*境界条件を調べておく (limit value analysis)*/\r
1457       it("should be this for the value  (limit value analysis)", function() {\r
1458         expect(from.setAccumulate()).toBe(0);\r
1459         expect(from.setAccumulate(0)).toBe(0);\r
1460         expect(from.accumulate).toEqual([0, 0]);\r
1461         expect(from.setAccumulate(1)).toEqual([0, 1]);\r
1462         expect(from.accumulate).toEqual([0, 1]);\r
1463       } );\r
1464       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1465       it("should be this for the value (the valid partion)", function() {\r
1466         expect(from.setAccumulate(2)).toEqual([0, 2]);\r
1467         expect(from.accumulate).toEqual([0, 2]);\r
1468       } );\r
1469       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1470       it("should be this for the value (the invalid partion)", function() {\r
1471         expect(from.setAccumulate(NaN)).toEqual(0);\r
1472       } );\r
1473   } );\r
1474   describe("A $calcMode object", function() {\r
1475     var calc = base("$calcMode"),\r
1476         to = calc.to,\r
1477         from;\r
1478      beforeEach( function() {\r
1479        calc = base("$calcMode").up();\r
1480        calc.to = base("$from").up().mix( {string: "1"} );\r
1481        from = calc.to.from = base("$from").up().mix( {string: "0"} );\r
1482      } );\r
1483     /*境界条件を調べておく (limit value analysis)*/\r
1484     it("should be this for the value  (limit value analysis)", function() {\r
1485       expect(calc.mode).toBe("linear");\r
1486       expect(calc.keyTime).toBe(1);\r
1487       expect(calc.keySplines).toBeNull();\r
1488       expect(calc.string).toBe("");\r
1489 \r
1490       expect(calc.call()(0)).toBe("0");\r
1491       expect(calc.keyTime).toBe(1);\r
1492       expect(calc.call()(1)).toBe("1");\r
1493       \r
1494       calc.keyTime = 0;\r
1495       expect(calc.call()(1)).toBe("0");\r
1496       \r
1497       /*paced mode*/\r
1498       calc.mode = "paced";\r
1499       expect(calc.norm).toBe(1);\r
1500       calc.to.from = from;\r
1501       expect(calc.call()(0)).toBe("0");\r
1502       expect(calc.keyTime).toBe(1);\r
1503       calc.to.from = from;\r
1504       expect(calc.call()(1)).toBe("1");\r
1505       \r
1506       calc.keyTime = 0;\r
1507       calc.to.from = from;\r
1508       expect(calc.call()(1)).toBe("1");\r
1509       \r
1510       /*discrete mode*/\r
1511       calc.mode = "discrete";\r
1512       calc.to.from = from;\r
1513       calc.keyTime = 1;\r
1514       expect(calc.call()(0)).toBe("0");\r
1515       expect(calc.call()(1)).toBe("1");\r
1516     } );\r
1517     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1518     it("should be this for the value (the valid partion)", function() {\r
1519       calc.mode = "linear";\r
1520       calc.keyTime = 0.5;\r
1521       calc.to.degit = 1;\r
1522       expect(calc.call()(0.2)).toBe("0.4");\r
1523       expect(calc.call()(0.3)).toBe("0.6");\r
1524       /*もう一度確かめる*/\r
1525       expect(calc.call()(0.2)).toBe("0.4");\r
1526       \r
1527       calc = base("$calcMode").up();\r
1528       calc.keyTime = 0.2;\r
1529       calc.to = base("$from").up();\r
1530       calc.to.from = base("$from").up();    \r
1531       calc.to.from.string = "0s";\r
1532       calc.to.string = "1s";\r
1533       calc.to.degit = 1;\r
1534       expect(calc.call()(0.1)).toBe("0.5s");\r
1535 \r
1536       calc = base("$calcMode").up();\r
1537       calc.keyTime = 0.5;\r
1538       calc.to = base("$from").up();\r
1539       calc.to.from = base("$from").up();    \r
1540       calc.to.from.string = "rgb(100, 20, 32)";\r
1541       calc.to.string = "rgb(0, 10, 50)";\r
1542       expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");\r
1543       \r
1544       /*paced mode*/\r
1545       calc.to = base("$from").up();\r
1546       calc.to.from = base("$from").up();    \r
1547       calc.mode = "paced";\r
1548       calc.norm = 100;\r
1549       calc.to.from.string = "0s";\r
1550       calc.to.string = "20s";\r
1551       calc.to.degit = 1;\r
1552       expect(calc.call()(0.1)).toBe("10.0s");\r
1553       expect(calc.keyTime).toBe(0.2);\r
1554 \r
1555       calc.to = base("$from").up();\r
1556       calc.to.from = base("$from").up();    \r
1557       calc.mode = "paced";\r
1558       calc.norm = 100;\r
1559       calc.to.from.string = "rgb(0, 0, 20)";\r
1560       calc.to.string = "rgb(0, 0, 0)";\r
1561       expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");\r
1562       expect(calc.keyTime).toBe(0.2);\r
1563       \r
1564       /*discrete mode*/\r
1565       calc.to = base("$from").up();\r
1566       calc.to.from = base("$from").up();    \r
1567       calc.mode = "discrete";\r
1568       calc.keyTime = 0.5;\r
1569       calc.to.degit = 1;\r
1570       calc.to.string = "1";\r
1571       calc.to.from.string = "0.5";\r
1572       expect(calc.call()(0.2)).toBe("0.5");\r
1573       expect(calc.call()(0.3)).toBe("0.5");\r
1574       /*もう一度確かめる*/\r
1575       expect(calc.call()(0.2)).toBe("0.5");\r
1576       \r
1577       calc.to = base("$from").up();\r
1578       calc.to.from = base("$from").up();    \r
1579       calc.mode = "discrete";\r
1580       calc.keyTime = 0.5;\r
1581       calc.to.degit = 1;\r
1582       calc.to.string = "block";\r
1583       calc.to.from.string = "inline";\r
1584       expect(calc.call()(0.2)).toBe("inline");\r
1585       expect(calc.call()(0.3)).toBe("inline");\r
1586       \r
1587       calc.to = base("$from").up();\r
1588       calc.to.from = base("$from").up();    \r
1589       calc.mode = "linear";\r
1590       calc.keyTime = 1;\r
1591       calc.to.degit = 1;\r
1592       calc.to.string = "1 1";\r
1593       calc.to.from.string = "0.0 1";\r
1594       expect(calc.call()(0.2)).toBe("0.2 1.0");\r
1595       expect(calc.call()(0.3)).toBe("0.3 1.0");\r
1596     } );\r
1597     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1598     it("should be this for the value (the invalid partion)", function() {\r
1599       calc.keyTime = null;\r
1600       expect(calc.call()(1)).toBe(calc.string);\r
1601       \r
1602       calc.keyTime = void 0;\r
1603       expect(calc.call()(1)).toBe(calc.string);\r
1604       \r
1605       calc.keyTime = 1/0;\r
1606       expect(calc.call()(1)).toBe(calc.string);\r
1607 \r
1608       expect(calc.call()()).toBe(calc.string);\r
1609 \r
1610       calc = base("$calcMode").up();\r
1611       calc.mode = "paced";\r
1612       calc.to.from = from;\r
1613       expect(calc.call()()).toBe(calc.string);\r
1614       \r
1615       calc = base("$calcMode").up();\r
1616       calc.mode = "discrete";\r
1617       expect(calc.call()()).toBe(calc.string);\r
1618     } );\r
1619     \r
1620     /*splineモードの境界条件を調べておく (limit value analysis)*/\r
1621     it("should be this for the value  (spline mode limit value analysis)", function() {\r
1622       /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/\r
1623       var x = 0,\r
1624           y = 0,\r
1625           bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
1626             return function (t) {\r
1627               x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
1628               y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
1629               return y;\r
1630             };\r
1631           };\r
1632       expect(calc.keySplines).toBeNull();\r
1633       calc.mode = "spline";\r
1634       expect( calc.call()("undef")).toBe(Math.PI);\r
1635       calc.keySplines = [0, 0, 1, 1];\r
1636       calc.to.degit = 1;\r
1637       calc.to.from = from;\r
1638       expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
1639       calc.to.from = from;\r
1640       expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
1641       calc.to.from = from;\r
1642       expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
1643       \r
1644       df(0,0, 0,0, 1,1, 1,1, 0.1);\r
1645       df(0,0, 0,0, 1,1, 1,1, 0.5);\r
1646       df(0,0, 0,0, 1,1, 1,1, 0.8);\r
1647       df(0,0, 0,0, 1,1, 1,1, 0.9);\r
1648       df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);\r
1649       df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);\r
1650       df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);\r
1651       df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);\r
1652       function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {\r
1653       /*自作のニュートン法*/\r
1654         var a = y4-3*(y3-y2)-y1,\r
1655             b = 3*(y3-2*y2+y1),\r
1656             c = 3*(y2-y1),\r
1657             d = y1 - bezier.apply(null, arguments)(t);\r
1658         expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);\r
1659       };\r
1660     } );\r
1661     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1662     it("should be this for the value (the valid partion on a spline mode )", function() {\r
1663       var x = 0,\r
1664           y = 0,\r
1665           bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
1666             return function (t) {\r
1667               return {\r
1668                   x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,\r
1669                   y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1\r
1670                 };\r
1671             };\r
1672           };\r
1673       calc.mode = "spline";\r
1674       calc.keySplines = [0, 0.5, 0.5, 1];\r
1675       calc.to.degit = 1;\r
1676       var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);\r
1677       expect(calc.call()(0)).toBe(b(0).y+".0");\r
1678       calc.to.from = from;\r
1679       expect(calc.call()(1)).toBe(b(1).y+".0");\r
1680       calc.to.from = from;\r
1681       expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));\r
1682       \r
1683       var ff = function(k) {\r
1684         calc.keySplines = k;\r
1685         calc.to.degit = 10;\r
1686         var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),\r
1687             epsilon = 1e-5; //誤差\r
1688         expect(calc.call()(0)).toBe(b(0).y.toFixed(10));\r
1689         calc.to.from = from;\r
1690         expect(calc.call()(1)).toBe(b(1).y.toFixed(10));\r
1691         calc.to.from = from;\r
1692         b = b(Math.random());\r
1693         expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);\r
1694       };\r
1695       for (var i=0;i<10000;++i) {\r
1696         var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});\r
1697         ff(rand);\r
1698       }\r
1699     } );\r
1700     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1701     it("should be this for the value (the invalid partion on a spline mode )", function() {\r
1702       calc.mode = "spline";\r
1703       calc.keySplines = [0, NaN, 1, 1];\r
1704       calc.to.degit = 1;\r
1705       calc.to.from = from;\r
1706       expect( calc.up().call()("undef")).toBe(Math.PI);\r
1707 \r
1708       \r
1709       calc.keySplines = [0, 0, 1, 2];\r
1710       calc.to.degit = 1;\r
1711       calc.to.from = from;\r
1712       expect( calc.up().call()("undef")).toBe(Math.PI);\r
1713       \r
1714       calc.keySplines = null;\r
1715       calc.to.degit = 1;\r
1716       calc.to.from = from;\r
1717       expect( calc.up().call()("undef")).toBe(Math.PI);\r
1718     } );\r
1719   } );\r
1720   describe("A $attribute object", function() {\r
1721     describe("A push method", function() {\r
1722       var attr, s;\r
1723       beforeEach( function() {\r
1724         attr = base("$calcMode").$attribute.up("width");\r
1725         base("$frame").timelines.length = 0;\r
1726         s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");\r
1727       } );\r
1728       afterEach( function() {\r
1729         attr.isCSS = false;\r
1730       } );\r
1731       /*境界条件を調べておく (limit value analysis)*/\r
1732       it("should be this for the value  (limit value analysis)", function() {\r
1733         expect(attr.element).toBeNull();\r
1734         expect(attr.push()).toBeNull();\r
1735         expect(attr.element).toBeNull();\r
1736         expect(attr.isCSS).toBeFalsy();\r
1737         expect(base("$frame").timelines.length).toBe(0);\r
1738         \r
1739         expect(attr.push(s)).toBeNull();\r
1740         expect(attr.element).toBeNull();\r
1741         expect(base("$frame").timelines.length).toBe(0);\r
1742         expect(attr.hasAttrValues()).toBeFalsy();\r
1743         \r
1744         var p = document.createElement("g");\r
1745         p.appendChild(s);\r
1746         expect(attr.push(s)).toBeNull();\r
1747         expect(attr.element).toBe(p);\r
1748         expect(base("$frame").timelines.length).toBe(0);\r
1749         \r
1750         s.setAttribute("end", "0");\r
1751         check("from", 1);\r
1752         check("to", 2);\r
1753         check("by", 3);\r
1754         check("values", 4);\r
1755         function check(attrName, num) {\r
1756           s.setAttribute(attrName, "1");\r
1757           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
1758           var fr = attr.push(s);\r
1759           expect(attr.element).toBe(p);\r
1760           var timelines = base("$frame").timelines;\r
1761           expect(timelines.length).toBe(num);\r
1762           var line = timelines[num-1];\r
1763           expect(line).not.toBe(fr);\r
1764           var act = fr.$activate;\r
1765           expect(act.dur).toBeNull();\r
1766           expect(act.repeatCount).toBeNull();\r
1767           expect(act.repeatDur).toBeNull();\r
1768           expect(act.min).toBe("0");\r
1769           expect(act.max).toBe("indefinite");\r
1770           expect(act.simpleDur).toBeNull();\r
1771           expect(attr.hasAttrValues()).toBeTruthy();\r
1772           \r
1773           s.removeAttribute(attrName);\r
1774           expect(s.hasAttributeNS(null, attrName)).toBeFalsy();\r
1775           attr.push(s);\r
1776           expect(attr.element).toBe(p);\r
1777           expect(timelines.length).toBe(num);\r
1778         };\r
1779           \r
1780         /*targetElement属性のサポート*/\r
1781         var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1782         document.documentElement.appendChild(p2);\r
1783         p2.setAttributeNS(null, "id", "p23");\r
1784         s.setAttributeNS(null, "targetElement", "p23");\r
1785         attr.push(s);\r
1786         expect(attr.element).toBe(p2);\r
1787         \r
1788         /*ハイパーリンクのサポート*/\r
1789         var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");\r
1790         document.documentElement.appendChild(p3);\r
1791         p3.setAttributeNS(null, "id", "p34");\r
1792         s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");\r
1793         attr.push(s);\r
1794         expect(attr.element).toBe(p3);\r
1795         \r
1796         /*attributeType属性のサポート*/\r
1797         s.setAttributeNS(null, "attributeType", "CSS");\r
1798         s.setAttributeNS(null, "values", "a;b;c");\r
1799         attr.push(s);\r
1800         expect(attr.isCSS).toBeTruthy();\r
1801       } );\r
1802       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1803       it("should be this for the value (the valid partion )", function() {\r
1804         s.setAttribute("from", "1");\r
1805         var p = document.createElement("g");\r
1806         p.appendChild(s);\r
1807         var values = [ "0",\r
1808                       "0", null, null, null, \r
1809                       "0", "indefinite", null\r
1810                     ];\r
1811         values[7] = 0;\r
1812         check2("dur", "0");\r
1813         check2("begin", "0");\r
1814         values[0] = "1";\r
1815         check2("begin", "1");\r
1816         values[2] = 0;\r
1817         check2("end", "0");\r
1818         values[3] = "0";\r
1819         check2("repeatCount", "0");\r
1820         values[4] = "0";\r
1821         check2("repeatDur", "0");\r
1822         values[5] = "0";\r
1823         check2("min", "0");\r
1824         values[6] = "0";\r
1825         check2("max", "0");\r
1826         values[0] = "12";\r
1827         check2("begin", "12");\r
1828         values[7] = 1000 * base("$frame").fpms;\r
1829         values[1] = "1";\r
1830         check2("dur", "1");\r
1831         function check2(attrName, value) {\r
1832           s.setAttribute(attrName, value);\r
1833           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
1834           var fr = attr.push(s);\r
1835           expect(attr.element).toBe(p);\r
1836           var timelines = base("$frame").timelines;\r
1837           var line = timelines[timelines.length-1];\r
1838           expect(fr.string).toBe(values[0]);\r
1839           var act = fr.$activate;\r
1840           expect(act.dur).toBe(values[1]);\r
1841           expect(act.repeatCount).toBe(values[3]);\r
1842           expect(act.repeatDur).toBe(values[4]);\r
1843           expect(act.min).toBe(values[5]);\r
1844           expect(act.max).toBe(values[6]);\r
1845           expect(act.simpleDur).toBe(values[7]);\r
1846         };\r
1847         \r
1848                 \r
1849         var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1850         document.documentElement.appendChild(p4);\r
1851         p4.appendChild(s);\r
1852         p4.setAttributeNS(null, "style", "display: none");\r
1853         attr.push(s);\r
1854         expect(attr.setAttribute()).toBeUndefined();\r
1855         expect(attr.setAttribute("block")).toBeUndefined();\r
1856         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1857         expect(attr.isCSS).toBeFalsy();\r
1858         \r
1859         s.setAttributeNS(null, "attributeName", "display");\r
1860         attr.push(s);\r
1861         expect(attr.setAttribute("block")).toBeUndefined();\r
1862         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1863         expect(attr.isCSS).toBeTruthy();\r
1864         expect(p4.style.getPropertyValue("display")).toBe("block");\r
1865         \r
1866         p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1867         document.documentElement.appendChild(p4);\r
1868         p4.appendChild(s);\r
1869         p4.setAttributeNS(null, "style", "display: none");\r
1870         attr.push(s);\r
1871         expect(attr.setAttribute("block")).toBeUndefined();\r
1872         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1873         expect(p4.style.getPropertyValue("display")).toBe("block");\r
1874         expect(attr.removeAttribute()).toBeUndefined();\r
1875         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1876         expect(p4.style.getPropertyValue("display")).toBe("none");\r
1877         \r
1878         /*attributeType属性のサポート*/\r
1879         s.setAttributeNS(null, "values", "a;b;c");\r
1880         s.setAttributeNS(null, "attributeName", "display");\r
1881         attr.isCSS = false;\r
1882         attr.push(s);\r
1883         expect(attr.isCSS).toBeTruthy();\r
1884       } );\r
1885       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1886       it("should be this for the value (the invalid partion )", function() {\r
1887         var p = document.createElement("g");\r
1888         p.appendChild(s);\r
1889         \r
1890         s.setAttributeNS(null, "begin", "1");\r
1891         attr.push(s);\r
1892         var timelines = base("$frame").timelines;\r
1893         expect(timelines.length).toBe(0);\r
1894         s.setAttributeNS(null, "from", "0");\r
1895         attr.push(s);\r
1896         expect(timelines.length).toBe(1);\r
1897         expect(attr.push(12)).toBeNull();\r
1898       } );\r
1899     } );\r
1900     describe("A setValues method", function() {\r
1901       var attr, s;\r
1902       beforeEach( function() {\r
1903         attr = base("$calcMode").$attribute.up("width");\r
1904         base("$frame").timelines.length = 0;\r
1905         s = document.createElement("animate");\r
1906       } );\r
1907       /*境界条件を調べておく (limit value analysis)*/\r
1908       it("should be this for the value  (limit value analysis)", function() {\r
1909         expect(attr.$from).not.toBeUndefined();\r
1910         expect(attr.setValues()).toBeNull();\r
1911         expect(attr.setValues("")).toBeNull();\r
1912 \r
1913         expect(attr.setValues("0;1")[0].to.string).toBe("1");\r
1914         expect(attr.setValues("0;1")[0].to.from.string).toBe("0");\r
1915         expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");\r
1916         expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0"); \r
1917                \r
1918         /*from-to アニメーション*/\r
1919         expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");\r
1920         expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");\r
1921         \r
1922         /*from-by アニメーション*/\r
1923         expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");\r
1924         expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);\r
1925         expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);\r
1926         \r
1927         /*fromなしto アニメーション*/\r
1928         expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");\r
1929         expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");\r
1930         var aset = attr.setValues(null, null, "1")[0].to;\r
1931         aset.call();\r
1932         expect(aset.from[0]).toBe(0);\r
1933         \r
1934         /*fromなしby アニメーション*/\r
1935         expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");\r
1936         expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);\r
1937         var aset = attr.setValues(null, null, null, "1")[0].to;\r
1938         aset.call();\r
1939         expect(aset.from[0]).toBe(0);\r
1940       } );\r
1941       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1942       it("should be this for the value (the valid partion on a spline mode )", function() {\r
1943         attr.$from.degit = 1;\r
1944         var setv = attr.setValues("0;1")[0].call();\r
1945         expect(setv(0.5)).toBe("0.5");\r
1946         expect(setv(1)).toBe("1.0");\r
1947         \r
1948         setv = attr.setValues(" 0;1; 2 ")[0].call();\r
1949         expect(setv(0.5)).toBe("0.5");\r
1950         expect(setv(1)).toBe("1.0");\r
1951         setv = attr.setValues("0;1;2")[1].call();\r
1952         expect(setv(0.4)).toBe("1.4");\r
1953         expect(setv(1)).toBe("2.0");\r
1954         \r
1955         attr.$from.degit = 2;\r
1956         setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();\r
1957         expect(setv(0.5)).toBe("8.05");\r
1958         expect(setv(1)).toBe("15.10");\r
1959         \r
1960         var v = attr.setValues("1;1;2;1;1;15.1");\r
1961         setv = v[4].mix( {\r
1962          keyTime: 0.1\r
1963         } ).call();\r
1964         expect(setv(0.05)).toBe("8.05");\r
1965         expect(setv(0.1)).toBe("15.10");\r
1966         setv = v[3].mix( {\r
1967          keyTime: 0.1\r
1968         } ).call();\r
1969         expect(setv(0.01)).toBe("1.00");\r
1970         expect(setv(0.1)).toBe("1.00");\r
1971         setv = v[2].mix( {\r
1972          keyTime: 0.5\r
1973         } ).call();\r
1974         expect(setv(0.25)).toBe("1.50");\r
1975         expect(setv(0.5)).toBe("1.00");\r
1976       } );\r
1977       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1978       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
1979         attr.$from.degit = 1;\r
1980         expect(attr.setValues("")).toBeNull();\r
1981         expect(attr.setValues(null, null, null, null)).toBeNull();\r
1982       } );\r
1983     } );\r
1984     describe("A setKey method", function() {\r
1985       var attr, s;\r
1986       beforeEach( function() {\r
1987         attr = base("$calcMode").$attribute.up("width");\r
1988         base("$frame").timelines.length = 0;\r
1989         s = document.createElement("animate");\r
1990         document.createElement("g").appendChild(s);\r
1991       } );\r
1992       /*境界条件を調べておく (limit value analysis)*/\r
1993       it("should be this for the value  (limit value analysis)", function() {\r
1994         expect(attr.setKey(s)).toBeNull();\r
1995         \r
1996         s.setAttributeNS(null, "from", "0");\r
1997         attr.setKey(s);\r
1998         s.setAttributeNS(null, "to", "0");\r
1999         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
2000         expect(attr.setKey(s)[0].to.string).toBe("0");\r
2001         s.setAttributeNS(null, "by", "0");\r
2002         attr.setKey(s);\r
2003         s.setAttributeNS(null, "values", "0;2");\r
2004         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
2005         expect(attr.setKey(s)[0].to.string).toBe("2");\r
2006         \r
2007         s.setAttributeNS(null, "keyTimes", "0;0.1");\r
2008         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
2009         \r
2010         s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");\r
2011         expect(attr.setKey(s)[0].keySplines[0]).toBe(0);\r
2012         expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);\r
2013         expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);\r
2014         expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);\r
2015         \r
2016         s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");\r
2017         expect(attr.setKey(s)[0].keySplines[0]).toBe(0);\r
2018         expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);\r
2019         expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);\r
2020         expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);\r
2021       } );\r
2022       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2023       it("should be this for the value (the valid partion on a spline mode )", function() {\r
2024         s.setAttributeNS(null, "values", "0;2;12;30");\r
2025         expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");\r
2026         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
2027         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
2028         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
2029         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
2030         s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");\r
2031         s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");\r
2032         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
2033         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
2034         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
2035         \r
2036         s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");\r
2037         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
2038         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
2039         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
2040         \r
2041         s.setAttributeNS(null, "keySplines", " 0,0.1,0.3,1; 0.1,0.4,0.5,0.7; 0.2,0.2,0.1  , 1 ;");\r
2042         f(0, 0,0.1,0.3,1);\r
2043         f(1, 0.1,0.4,0.5,0.7);\r
2044         f(2, 0.2,0.2,0.1,1);\r
2045         \r
2046         s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2,  .2, .1  , 1 ;");\r
2047         f(0, 0,0.1,0.3,1);\r
2048         f(1, 0.1,0.4,0.5,0.7);\r
2049         f(2, 0.2,0.2,0.1,1);\r
2050         \r
2051         s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4  .5 .7; .2   .2  .1    1 ;");\r
2052         f(0, 0,0.1,0.333,1);\r
2053         f(1, 0.1,0.4,0.5,0.7);\r
2054         f(2, 0.2,0.2,0.1,1);\r
2055         function f (i, a, b, c, d) {\r
2056           var splines = attr.setKey(s)[i].keySplines;\r
2057           expect(splines[0]).toBe(a);\r
2058           expect(splines[1]).toBe(b);\r
2059           expect(splines[2]).toBe(c);\r
2060           expect(splines[3]).toBe(d);\r
2061         };\r
2062       } );\r
2063       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2064       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
2065         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
2066         expect(attr.setKey(s)).toBeNull();\r
2067         s.setAttributeNS(null, "values", "0;2;12");\r
2068         expect(attr.setKey(s)).toBeNull();\r
2069         s.setAttributeNS(null, "values", "0;2;12;20");\r
2070         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");\r
2071         expect(attr.setKey(s)).toBeNull();\r
2072       } );\r
2073     } );\r
2074   } );\r
2075   describe("A $setElement object", function() {\r
2076     describe("A timeline property", function() {\r
2077       var $set, ele, frame;\r
2078       beforeEach( function() {\r
2079         $set = base("$calcMode").$attribute.$setElement.up();\r
2080         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2081         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
2082         p.appendChild(ele);\r
2083         frame = base("$frame");\r
2084       } );\r
2085       /*境界条件を調べておく (limit value analysis)*/\r
2086       it("should be this for the value  (limit value analysis)", function() {\r
2087         expect($set.timeline).toBe(frame.$begin);\r
2088         \r
2089         $set.init();\r
2090         expect($set.timeline).toBe(frame.$begin);\r
2091         expect($set.element).toBeNull();\r
2092       } );\r
2093     } );\r
2094     \r
2095       describe("An init method", function() {\r
2096       var $set, ele, frame;\r
2097       beforeEach( function() {\r
2098         $set = base("$calcMode").$attribute.$setElement.up();\r
2099         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2100         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
2101         p.appendChild(ele);\r
2102         frame = base("$frame");\r
2103       } );\r
2104       /*境界条件を調べておく (limit value analysis)*/\r
2105       it("should be this for the value  (limit value analysis)", function() {\r
2106         expect($set.to).toBe("");\r
2107         expect($set.attrName).toBe("");\r
2108         expect($set.defaultValue).toBe("");\r
2109         expect($set.isDefault).toBeFalsy();\r
2110         expect($set.attrNameSpace).toBeNull();\r
2111         $set.init();\r
2112         expect($set.timeline).toBe(frame.$begin);\r
2113         $set.init(ele);\r
2114         expect($set.to).toBe("");\r
2115         expect($set.attrName).toBe("");\r
2116         expect($set.isDefault).toBeFalsy();\r
2117         expect($set.attrNameSpace).toBeNull();\r
2118         expect($set.timeline).toBe(frame.$begin);\r
2119       } );\r
2120       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2121       it("should be this for the value (the valid partion  )", function() {\r
2122         ele.setAttributeNS(null, "to", "t1");\r
2123         $set.init(ele);\r
2124         expect($set.to).toBe("t1");\r
2125         expect($set.attrName).toBe("");\r
2126         expect($set.defaultValue).toBe("");\r
2127 \r
2128         ele.setAttributeNS(null, "attributeName", "tt1");\r
2129         $set.init(ele);\r
2130         expect($set.to).toBe("t1");\r
2131         expect($set.attrName).toBe("tt1");\r
2132         expect($set.defaultValue).toBe("");\r
2133 \r
2134         ele.parentNode.setAttributeNS(null, "tt1", "undef");\r
2135         $set.init(ele);\r
2136         expect($set.defaultValue).toBe("undef");\r
2137         expect($set.isDefault).toBeTruthy();\r
2138 \r
2139         ele.setAttributeNS(null, "attributeName", "font-size");\r
2140         ele.parentNode.style.setProperty("font-size", "12px");\r
2141         $set.init(ele);\r
2142         expect($set.defaultValue).toBe("12px");\r
2143         expect($set.isDefault).toBeFalsy();\r
2144         \r
2145         ele.setAttributeNS(null, "attributeName", "xlink:href");\r
2146         $set.init(ele);\r
2147         expect($set.to).toBe("t1");\r
2148         expect($set.attrName).toBe("xlink:href");\r
2149         expect($set.defaultValue).toBe("");\r
2150         ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");\r
2151         $set.init(ele);\r
2152         expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");\r
2153       } );\r
2154       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2155       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
2156         $set.init(null);\r
2157         expect($set.to).toBe("");\r
2158         expect($set.attrName).toBe("");\r
2159         expect($set.defaultValue).toBe("");\r
2160 \r
2161         $set.init(12);\r
2162         expect($set.to).toBe("");\r
2163         expect($set.attrName).toBe("");\r
2164         expect($set.defaultValue).toBe("");\r
2165       } );\r
2166     } );\r
2167     describe("Frame Set", function() {\r
2168       var $set, ele, frame;\r
2169       beforeEach( function() {\r
2170         $set = base("$calcMode").$attribute.$setElement.up();\r
2171         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2172         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
2173         p.appendChild(ele);\r
2174         frame = base("$frame");\r
2175         frame.timelines.length = 0; //配列の初期化\r
2176         frame.startTime = Date.now();\r
2177         frame.setFrame(0);\r
2178       } );\r
2179       afterEach( function() {\r
2180         $set.isCSS = false;\r
2181       } );\r
2182       /*境界条件を調べておく (limit value analysis)*/\r
2183       it("should be this for the value  (limit value analysis)", function() {\r
2184         expect($set.isEnd).toBeFalsy();\r
2185         ele.setAttributeNS(null, "dur", "1s");\r
2186         ele.setAttributeNS(null, "attributeName", "fill");\r
2187         ele.setAttributeNS(null, "to", "red");\r
2188         $set.init(ele);\r
2189         /*テストしやすくするために、CSSではなくXML属性として扱う*/\r
2190         $set.isCSS = false;\r
2191         expect($set.timeline).not.toBe(frame.$begin);\r
2192         frame.setFrame(0);\r
2193         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2194         \r
2195         var line = $set.timeline;\r
2196         expect(line.$list.state).toBe(line.$list.PLAYING);\r
2197         frame.setFrame(24);\r
2198         expect(line.$list.state).toBe(line.$list.POSTWAITING);\r
2199         expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();\r
2200       } );\r
2201       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2202       it("should be this for the value (the valid partion)", function() {\r
2203         ele.setAttributeNS(null, "begin", "1s");\r
2204         ele.setAttributeNS(null, "dur", "1s");\r
2205         ele.setAttributeNS(null, "attributeName", "fill");\r
2206         ele.setAttributeNS(null, "to", "red");\r
2207         $set.init(ele);\r
2208         /*テストしやすくするために、CSSではなくXML属性として扱う*/\r
2209         $set.isCSS = false;\r
2210         var f = function(num) {\r
2211           frame.setFrame(num);\r
2212           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();\r
2213         }\r
2214         f(0);\r
2215         f(1);\r
2216         f(23);\r
2217         frame.setFrame(24);\r
2218         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2219         frame.setFrame(25);\r
2220         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2221         f(48);\r
2222         f(49);\r
2223         \r
2224         ele.setAttributeNS(null, "fill", "freeze");\r
2225         $set.init(ele);\r
2226         $set.isCSS = false;\r
2227         f(0);\r
2228         f(1);\r
2229         f(23);\r
2230         frame.setFrame(24);\r
2231         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2232         frame.setFrame(25);\r
2233         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2234         frame.setFrame(48);\r
2235         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2236         frame.setFrame(49);\r
2237         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2238         ele.setAttributeNS(null, "begin", "1s");\r
2239         ele.setAttributeNS(null, "attributeName", "fill");\r
2240         ele.setAttributeNS(null, "to", "red");\r
2241         /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/\r
2242         $set.init(ele);\r
2243         $set.isCSS = false;\r
2244         var f = function(num) {\r
2245           frame.setFrame(num);\r
2246           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2247         }\r
2248         f(0);\r
2249         f(1);\r
2250         f(23);\r
2251         f(24);\r
2252         f(25);\r
2253         f(48);      } );\r
2254       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2255       it("should be this for the value (the invalid partion)", function() {\r
2256 \r
2257       } );\r
2258     } );\r
2259   } );\r
2260     describe("A $animateElement object", function() {\r
2261       describe("An init method", function() {\r
2262         var $animate, ele, frame;\r
2263         beforeEach( function() {\r
2264           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
2265           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2266           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2267           p.appendChild(ele);\r
2268           frame = base("$frame");\r
2269           frame.timelines.length = 0;\r
2270           frame.startTime = Date.now();\r
2271           frame.setFrame(0);\r
2272         } );\r
2273         /*境界条件を調べておく (limit value analysis)*/\r
2274         it("should be this for the value  (limit value analysis)", function() {\r
2275           $animate.init();\r
2276           \r
2277           ele.setAttributeNS(null, "begin", "1s");\r
2278           ele.setAttributeNS(null, "dur", "1s");\r
2279           ele.setAttributeNS(null, "attributeName", "d");\r
2280           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2281           ele.setAttributeNS(null, "to", "M20 20 L10 30");\r
2282           $animate.init(ele);\r
2283           expect($animate.isCSS).toBeFalsy();\r
2284           frame.setFrame(0);\r
2285           var p = ele.parentNode;\r
2286           /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、\r
2287            * 他のブラウザではnullを返すため、その対策をする*/\r
2288           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2289           \r
2290           function f(fr, result) {\r
2291             frame.setFrame(fr);\r
2292             expect(p.getAttributeNS(null, "d") || "").toBe(result);\r
2293           };\r
2294           \r
2295           f(24, "M20.0 0.0 L20.0 30.0");\r
2296           f(36, "M20.0 10.0 L15.0 30.0");\r
2297           f(48, "");\r
2298                     \r
2299           ele.setAttributeNS(null, "fill", "freeze");\r
2300           $animate.init(ele);\r
2301           f(24, "M20.0 0.0 L20.0 30.0");\r
2302           f(36, "M20.0 10.0 L15.0 30.0");\r
2303           f(48, "M20.0 20.0 L10.0 30.0");\r
2304           \r
2305           frame.timelines.length = 0;\r
2306           ele.setAttributeNS(null, "calcMode", "discrete");\r
2307           $animate.init(ele);\r
2308           expect($animate.isCSS).toBeFalsy();\r
2309           expect($animate.mode).toBe("discrete");\r
2310           f(24, "M20.0 0.0 L20.0 30.0");\r
2311           f(25, "M20.0 0.0 L20.0 30.0");\r
2312           f(37, "M20.0 20.0 L10.0 30.0");\r
2313           f(48, "M20.0 20.0 L10.0 30.0");\r
2314           \r
2315           [ ["display", "inline", "none"],\r
2316             ["visibility", "hidden", "visible"],\r
2317             ["stroke-linecap", "round", "square"],\r
2318             ["font-style", "italic", "normal"]\r
2319           ].forEach( function(attr) {\r
2320             var attrName = attr[0],\r
2321                 from = attr[1],\r
2322                 to = attr[2];\r
2323             function g(fr, result) {\r
2324               frame.setFrame(fr);\r
2325               expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);\r
2326             };\r
2327 \r
2328             \r
2329             ele.setAttributeNS(null, "from", from);\r
2330             ele.setAttributeNS(null, "to", to);\r
2331             frame.timelines.length = 0;\r
2332             ele.setAttributeNS(null, "calcMode", "linear");\r
2333             ele.setAttributeNS(null, "attributeName", attrName);\r
2334             $animate.init(ele);\r
2335             expect($animate.mode).toBe("discrete");\r
2336             g(24, from);\r
2337             g(25, from);\r
2338             g(37, to);\r
2339             g(48, to);\r
2340           } );\r
2341         } );\r
2342         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2343         it("should be this for the value (the valid partion )", function() {\r
2344           /*24FPSが前提*/\r
2345           ele.setAttributeNS(null, "begin", "0s");\r
2346           ele.setAttributeNS(null, "dur", "100s");\r
2347           ele.setAttributeNS(null, "attributeName", "d");\r
2348           ele.setAttributeNS(null, "fill", "freeze");\r
2349           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2350           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
2351           $animate.init(ele);\r
2352           \r
2353           var p = ele.parentNode;\r
2354           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2355           \r
2356           function f(fr, result) {\r
2357             frame.setFrame(fr);\r
2358             expect(p.getAttributeNS(null, "d")).toBe(result);\r
2359           };\r
2360           \r
2361           for (var i=0;i<2400;++i) {\r
2362             f(i, "M20.0 " +i+ ".0 L20.0 30.0");\r
2363           }\r
2364           f(2401, "M20.0 2400.0 L20.0 30.0");\r
2365           \r
2366           \r
2367           frame.timelines.length = 0;\r
2368           ele.setAttributeNS(null, "begin", "0s");\r
2369           ele.setAttributeNS(null, "dur", "1s");\r
2370           ele.setAttributeNS(null, "repeatDur", "2s");\r
2371           ele.setAttributeNS(null, "attributeName", "d");\r
2372           ele.setAttributeNS(null, "fill", "freeze");\r
2373           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2374           ele.setAttributeNS(null, "to", "M20 24 L20 30");\r
2375           $animate.init(ele);\r
2376           f(23, "M20.0 23.0 L20.0 30.0");\r
2377           f(24, "M20.0 0.0 L20.0 30.0");\r
2378           f(25, "M20.0 1.0 L20.0 30.0");\r
2379           f(48, "M20.0 24.0 L20.0 30.0");\r
2380 \r
2381           frame.timelines.length = 0;\r
2382           ele.setAttributeNS(null, "begin", "0s");\r
2383           ele.setAttributeNS(null, "dur", "2s");\r
2384           ele.setAttributeNS(null, "attributeName", "d");\r
2385           ele.setAttributeNS(null, "fill", "freeze");\r
2386           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2387           $animate.init(ele);\r
2388           f(0, "M20.0 0.0 L20.0 30.0");\r
2389           f(1, "M20.0 1.0 L20.0 30.0");\r
2390           f(24, "M20.0 24.0 L20.0 30.0");\r
2391           f(25, "M20.0 24.1 L20.0 30.0");\r
2392           f(47, "M20.0 26.3 L20.0 30.0");\r
2393           f(48, "M20.0 26.4 L20.0 30.0");\r
2394           f(49, "M20.0 26.4 L20.0 30.0");\r
2395           f(50, "M20.0 26.4 L20.0 30.0");\r
2396           \r
2397           frame.timelines.length = 0;\r
2398           ele.setAttributeNS(null, "begin", "0s");\r
2399           ele.setAttributeNS(null, "end", "2s");\r
2400           ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合\r
2401           ele.removeAttributeNS(null, "repeatDur");\r
2402           ele.setAttributeNS(null, "attributeName", "d");\r
2403           ele.setAttributeNS(null, "fill", "freeze");\r
2404           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2405           $animate.init(ele);\r
2406           f(0, "M20.0 0.0 L20.0 30.0");\r
2407           f(1, "M20.0 0.0 L20.0 30.0");\r
2408           f(24, "M20.0 0.0 L20.0 30.0");\r
2409           f(25, "M20.0 0.0 L20.0 30.0");\r
2410           f(47, "M20.0 0.0 L20.0 30.0");\r
2411           f(48, "M20.0 0.0 L20.0 30.0");\r
2412           f(49, "M20.0 0.0 L20.0 30.0");\r
2413           f(50, "M20.0 0.0 L20.0 30.0");\r
2414           \r
2415           frame.timelines.length = 0;\r
2416           ele.setAttributeNS(null, "dur", "2s");\r
2417           ele.setAttributeNS(null, "fill", "remove");\r
2418           var attrValue = p.getAttributeNS(null, "d");\r
2419           $animate.init(ele);\r
2420           f(48, attrValue);\r
2421           \r
2422           frame.timelines.length = 0;\r
2423           p.removeAttributeNS(null, "d");\r
2424           ele.setAttributeNS(null, "fill", "freeze");\r
2425           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
2426           $animate.init(ele);\r
2427           f(1, "M20.0 5.0 L20.0 30.0");\r
2428           f(48, "M20.0 26.4 L20.0 30.0");\r
2429           \r
2430           frame.timelines.length = 0;\r
2431           ele.setAttributeNS(null, "fill", "freeze");\r
2432           ele.setAttributeNS(null, "calcMode", "discrete");\r
2433           ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");\r
2434           $animate.init(ele);\r
2435           f(1, "M20.0 0.0 L20.0 30.0");\r
2436           f(4, "M20.0 0.0 L20.0 30.0");\r
2437           /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない\r
2438            * 修正の余地あり*/\r
2439           f(24, "M20.0 24.0 L20.0 30.0");\r
2440           f(25, "M20.0 24.0 L20.0 30.0");\r
2441           f(29, "M20.0 26.4 L20.0 30.0");\r
2442           f(48, "M20.0 26.4 L20.0 30.0");\r
2443           \r
2444           frame.timelines.length = 0;\r
2445           ele.setAttributeNS(null, "calcMode", "spline");\r
2446           ele.removeAttributeNS(null, "keyTimes");\r
2447           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");\r
2448           ele.removeAttributeNS(null, "end");\r
2449           ele.setAttributeNS(null, "dur", "9s");\r
2450           ele.setAttributeNS(null, "values", "210;177;121;10");\r
2451           $animate.init(ele);\r
2452           f(0, "210.0");\r
2453           f(72, "177.0");\r
2454           f(144, "121.0");\r
2455           f(216, "10.0");\r
2456           f(300, "10.0");\r
2457           \r
2458           frame.timelines.length = 0;\r
2459           ele.setAttributeNS(null, "calcMode", "spline");\r
2460           ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2461           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2462           ele.setAttributeNS(null, "dur", "8s");\r
2463           ele.setAttributeNS(null, "values", "300;255;180;30");\r
2464           $animate.init(ele);\r
2465           f(0, "300.0");\r
2466           f(48, "255.0");\r
2467           f(96, "180.0");\r
2468           f(192, "30.0");\r
2469           f(300, "30.0");\r
2470           \r
2471           /*開始時刻が未解決の場合*/\r
2472           frame.timelines.length = 0;\r
2473           ele.setAttributeNS(null, "begin", "click");\r
2474           ele.setAttributeNS(null, "calcMode", "spline");\r
2475           ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2476           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2477           ele.setAttributeNS(null, "dur", "8s");\r
2478           ele.setAttributeNS(null, "values", "300;255;180;30");\r
2479           ele.parentNode.setAttributeNS(null, "d", "300");\r
2480           $animate.init(ele);\r
2481           f(0, "300");\r
2482           f(48, "300");\r
2483           f(96, "300");\r
2484           f(192, "300");\r
2485           f(300, "300");\r
2486           \r
2487           ( function(attrName) {\r
2488             function g(fr, result) {\r
2489               frame.setFrame(fr);\r
2490               expect(p.style.getPropertyValue(attrName)).toBe(result);\r
2491             };\r
2492 \r
2493             frame.timelines.length = 0;\r
2494             ele.setAttributeNS(null, "begin", "0s");\r
2495             ele.setAttributeNS(null, "calcMode", "linear");\r
2496             ele.setAttributeNS(null, "attributeName", attrName);\r
2497             ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2498             ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2499             ele.setAttributeNS(null, "dur", "8s");\r
2500             ele.setAttributeNS(null, "values", "inline;block;inline;block");\r
2501             $animate.init(ele);\r
2502             expect($animate.mode).toBe("discrete");\r
2503             g(0, "inline");\r
2504             g(48, "block");\r
2505             g(96, "inline");\r
2506             g(192, "block");\r
2507             g(300, "block");\r
2508             \r
2509             frame.timelines.length = 0;\r
2510             ele.setAttributeNS(null, "begin", "click");\r
2511             ele.setAttributeNS(null, "calcMode", "linear");\r
2512             ele.setAttributeNS(null, "attributeName", attrName);\r
2513             ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2514             ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2515             ele.setAttributeNS(null, "dur", "8s");\r
2516             ele.setAttributeNS(null, "values", "inline;block;inline;block");\r
2517             $animate.init(ele);\r
2518             var evt = ele.ownerDocument.createEvent("MouseEvents");\r
2519             evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
2520             p.dispatchEvent(evt);\r
2521             var cur = base("$frame").currentFrame;\r
2522             expect($animate.mode).toBe("discrete");\r
2523             g(cur+0, "inline");\r
2524             g(cur+48, "block");\r
2525             g(cur+96, "inline");\r
2526             g(cur+192, "block");\r
2527             g(cur+300, "block");\r
2528           } )("display");\r
2529         } );\r
2530         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2531         it("should be this for the value (the invalid partion )", function() {\r
2532           ele.setAttributeNS(null, "begin", "0s");\r
2533           ele.setAttributeNS(null, "dur", "100s");\r
2534           ele.setAttributeNS(null, "attributeName", "d");\r
2535           ele.setAttributeNS(null, "fill", "freeze");\r
2536           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2537           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
2538           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
2539           $animate.init(ele);\r
2540           \r
2541           var p = ele.parentNode;\r
2542           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2543           \r
2544           function f(fr, result) {\r
2545             frame.setFrame(fr);\r
2546             expect(p.getAttributeNS(null, "d") || null).toBe(result);\r
2547           };\r
2548           f(0, null);\r
2549           f(1, null);\r
2550           \r
2551            frame.timelines.length = 0;\r
2552           /*keyTimes属性のリストの個数がvaluesリストと合致しない*/\r
2553           ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");\r
2554           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2555           $animate.init(ele);\r
2556           f(0, null);\r
2557           f(1, null);\r
2558           \r
2559           /*keyTimes属性が0から始まっていない*/\r
2560           frame.timelines.length = 0;\r
2561           ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");\r
2562           ff("linear");\r
2563           ff("splines");\r
2564           ff("discrete");\r
2565           function ff(mode) {\r
2566             ele.setAttributeNS(null, "calcMode", mode);\r
2567             $animate.init(ele);\r
2568             f(0, null);\r
2569             f(1, null);\r
2570           }\r
2571           \r
2572           frame.timelines.length = 0;\r
2573           ele.setAttributeNS(null, "calcMode", "spline");\r
2574           $animate.init(ele);\r
2575           expect($animate.mode).toBe("spline");\r
2576           f(0, null);\r
2577           f(0.2, null);\r
2578           f(1, null); \r
2579         } );\r
2580       } );\r
2581       describe("RGB Color", function() {\r
2582         var $animate, ele, frame, f;\r
2583         beforeEach( function() {\r
2584           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
2585           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2586           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2587           p.appendChild(ele);\r
2588           frame = base("$frame");\r
2589           frame.timelines.length = 0;\r
2590           \r
2591           f = function (fr, result, attr) {\r
2592             frame.setFrame(fr);\r
2593             expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));\r
2594           };\r
2595         } );\r
2596         /*境界条件を調べておく (limit value analysis)*/\r
2597         it("should be this for the value  (limit value analysis)", function() {\r
2598           ele.setAttributeNS(null, "begin", "0s");\r
2599           ele.setAttributeNS(null, "dur", "1s");\r
2600           ele.setAttributeNS(null, "attributeName", "fill");\r
2601           ele.setAttributeNS(null, "fill", "remove");\r
2602           ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");\r
2603           ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");\r
2604           $animate.init(ele);\r
2605           \r
2606           f(0, "rgb(0, 0, 0)", "fill");\r
2607           f(23, "rgb(10, 10, 1)", "fill");\r
2608           \r
2609           frame.timelines.length = 0;\r
2610           ele.setAttributeNS(null, "attributeName", "stroke");\r
2611           $animate.init(ele);\r
2612           f(0, "rgb(0, 0, 0)", "stroke");\r
2613           f(23, "rgb(10, 10, 1)", "stroke");\r
2614 \r
2615           frame.timelines.length = 0;\r
2616           ele.setAttributeNS(null, "attributeName", "stop-color");\r
2617           $animate.init(ele);\r
2618           f(0, "rgb(0,0,0)", "stop-color");\r
2619           f(23, "rgb(10,10,1)", "stop-color");\r
2620 \r
2621           frame.timelines.length = 0;\r
2622           ele.setAttributeNS(null, "attributeName", "color");\r
2623           $animate.init(ele);\r
2624           f(0, "rgb(0,0,0)", "color");\r
2625           f(23, "rgb(10,10,1)", "color");\r
2626         } );\r
2627         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2628         it("should be this for the value (the valid partion )", function() {\r
2629           ele.setAttributeNS(null, "begin", "0s");\r
2630           ele.setAttributeNS(null, "dur", "1s");\r
2631           ele.setAttributeNS(null, "attributeName", "fill");\r
2632           ele.setAttributeNS(null, "fill", "remove");\r
2633           ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");\r
2634           $animate.init(ele);\r
2635           \r
2636           f(0, "rgb(0, 0, 0)", "fill");\r
2637           f(1, "rgb(1, 0, 0)", "fill");\r
2638           f(23, "rgb(23, 2, 1)", "fill");\r
2639 \r
2640           frame.timelines.length = 0;\r
2641           ele.setAttributeNS(null, "values", "#00083C;#18203C");\r
2642           $animate.init(ele);\r
2643           /*rgb形式に変換*/\r
2644           \r
2645           f(0, "rgb(0, 8, 60)", "fill");\r
2646           f(1, "rgb(1, 9, 60)", "fill");\r
2647           f(23, "rgb(23, 31, 60)", "fill");\r
2648           \r
2649           frame.timelines.length = 0;\r
2650           ele.setAttributeNS(null, "fill", "freeze");\r
2651           ele.setAttributeNS(null, "values", "black;white");\r
2652           $animate.init(ele);\r
2653           /*色キーワードをrgb形式に変換*/\r
2654           \r
2655           f(0, "rgb(0, 0, 0)", "fill");\r
2656           f(12, "rgb(128, 128, 128)", "fill");\r
2657           f(24, "rgb(255, 255, 255)", "fill");\r
2658         } );\r
2659         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2660         it("should be this for the value (the invalid partion )", function() {\r
2661           ele.setAttributeNS(null, "begin", "0s");\r
2662           ele.setAttributeNS(null, "dur", "1s");\r
2663           ele.setAttributeNS(null, "attributeName", "fi");\r
2664           ele.setAttributeNS(null, "fill", "remove");\r
2665           ele.setAttributeNS(null, "values", "#00083C;#00107C");\r
2666           $animate.init(ele);\r
2667           /*rgb形式に変換しない*/\r
2668           \r
2669           function f (fr, result, attr) {\r
2670             frame.setFrame(fr);\r
2671             expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);\r
2672           };\r
2673           f(0, "#83.0C", "fi");\r
2674           f(1, "#84.0C", "fi");\r
2675           f(23, "#106.0C", "fi");   \r
2676         } );\r
2677       } );\r
2678     describe("$frame.$svgEvent object", function() {\r
2679       var frame = base("$frame").$svgEvent,\r
2680           p, ele;\r
2681       base("$frame").pauseAnimation();\r
2682       beforeEach( function() {\r
2683         base("$frame").pauseAnimation();\r
2684         frame = frame.up().mix( {isResolved: true} );\r
2685         frame.first = null;\r
2686         /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に\r
2687          * 影響を受けるため、新たに初期化しておく*/\r
2688         base("$frame").timelines = frame.timelines = [];\r
2689         frame.lastTimeLine = null;\r
2690         p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2691         ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2692         p.appendChild(ele);\r
2693       } );\r
2694       /*境界条件を調べておく (limit value analysis)*/\r
2695       it("should be this for the value  (limit value analysis)", function() {\r
2696         base("$frame").pauseAnimation();\r
2697         frame.lastTimeLine = null;\r
2698         expect(frame.lastTimeLine).toBeNull();\r
2699         expect(frame.first).toBeNull();\r
2700         frame.setTimeTable();\r
2701         expect(frame.first).toBeNull();\r
2702         frame.addLine( base("$frame").$begin.up().mix({\r
2703           isResolved: true,\r
2704           timelines: [],\r
2705           begin: 0,\r
2706           activeTime: 0,\r
2707           target: ele\r
2708         }) );\r
2709         frame.setTimeTable();\r
2710         expect(frame.first).toEqual(\r
2711           { frame: 0,\r
2712             eventType: "begin",\r
2713             target: ele,\r
2714           \r
2715             next: { frame: 0,\r
2716               eventType: "end",\r
2717               target: ele,\r
2718               next: null\r
2719             }\r
2720           }\r
2721         );\r
2722       } );\r
2723       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2724       it("should be this for the value (the valid partion )", function() {\r
2725         base("$frame").pauseAnimation();\r
2726         frame.addLine( base("$frame").$begin.up().mix({\r
2727           isResolved: true,\r
2728           timelines: [],\r
2729           begin: 0,\r
2730           activeTime: 0,\r
2731           target: ele\r
2732         }) );\r
2733         frame.setTimeTable();\r
2734         frame.setTimeTable();\r
2735         expect(frame.first).toEqual(\r
2736           { frame: 0,\r
2737             eventType: "begin",\r
2738             target: ele,\r
2739           \r
2740             next: { frame: 0,\r
2741               eventType: "end",\r
2742               target: ele,\r
2743               next: null\r
2744             }\r
2745           }\r
2746         );\r
2747         frame.setTimeTable();\r
2748         frame.setTimeTable();\r
2749         expect(frame.first).toEqual(\r
2750           { frame: 0,\r
2751             eventType: "begin",\r
2752             target: ele,\r
2753           \r
2754             next: { frame: 0,\r
2755               eventType: "end",\r
2756               target: ele,\r
2757               next: null\r
2758             }\r
2759           }\r
2760         );\r
2761         \r
2762         var isFiredBeginEvent = false;\r
2763         ele.addEventListener("beginEvent", function(evt) {\r
2764           isFiredBeginEvent = true;\r
2765           expect(evt.target).toBe(ele);\r
2766         } );\r
2767         ele.addEventListener("endEvent", function(evt) {\r
2768           expect(evt.target).toBe(ele);\r
2769           expect(isFiredBeginEvent).toBeTruthy();\r
2770         } );\r
2771         frame.setFrame(0);\r
2772         expect(frame.first).toBeNull();\r
2773         frame.setFrame(0);\r
2774         expect(frame.first).toBeNull();\r
2775         \r
2776         frame.timelines = [];\r
2777         frame.addLine( base("$frame").$begin.up().mix({\r
2778           isResolved: true,\r
2779           timelines: [],\r
2780           begin: 0,\r
2781           activeTime: 10,\r
2782           target: ele\r
2783         }) );\r
2784         frame.setTimeTable();\r
2785         var a = { frame: 0,\r
2786             eventType: "begin",\r
2787             target: ele,\r
2788           \r
2789             next: { frame: 10,\r
2790               eventType: "end",\r
2791               target: ele,\r
2792               next: null\r
2793             }\r
2794           };\r
2795         expect(frame.first).toEqual(a);\r
2796         \r
2797         frame.addLine( base("$frame").$begin.up().mix({\r
2798           isResolved: true,\r
2799           timelines: [],\r
2800           begin: 1,\r
2801           simpleDuration: 9,\r
2802           activeTime: 11,\r
2803           target: ele\r
2804         }) );\r
2805         frame.setTimeTable();\r
2806         a.next.next = { frame: 1,\r
2807             eventType: "begin",\r
2808             target: ele,\r
2809           \r
2810             next: {\r
2811               frame: 10,\r
2812               eventType: "repeat",\r
2813               count: 1,\r
2814               target: ele,\r
2815             \r
2816               next: { frame: 12,\r
2817                 eventType: "end",\r
2818                 target: ele,\r
2819                 next: null\r
2820               }\r
2821             }\r
2822           };\r
2823         expect(frame.first).toEqual(a);\r
2824         frame.setFrame(11);\r
2825         expect(frame.first).toEqual( {frame: 12,\r
2826                 eventType: "end",\r
2827                 target: ele,\r
2828                 next: null\r
2829               } );\r
2830               \r
2831         frame.timelines = [];\r
2832         frame.first = null;\r
2833         frame.addLine( base("$frame").$begin.up().mix({\r
2834           isResolved: true,\r
2835           timelines: [],\r
2836           begin: 1,\r
2837           simpleDuration: 4,\r
2838           activeTime: 10,\r
2839           target: ele\r
2840         }) );\r
2841         frame.setTimeTable();\r
2842         a =  { frame: 1,\r
2843             eventType: "begin",\r
2844             target: ele,\r
2845           \r
2846             next: {\r
2847               frame: 5,\r
2848               eventType: "repeat",\r
2849               count: 1,\r
2850               target: ele,\r
2851             \r
2852               next: {\r
2853                 frame: 9,\r
2854                 eventType: "repeat",\r
2855                 count: 2,\r
2856                 target: ele,\r
2857               \r
2858                 next: { frame: 11,\r
2859                   eventType: "end",\r
2860                   target: ele,\r
2861                   next: null\r
2862                 }\r
2863               }\r
2864             }\r
2865           };\r
2866         expect(frame.first).toEqual(a);\r
2867         frame.setFrame(0);\r
2868         expect(frame.first).toEqual(a);\r
2869         frame.setFrame(1);\r
2870         a = a.next;\r
2871         expect(frame.first).toEqual(a);\r
2872         frame.setFrame(5);\r
2873         expect(frame.first).toEqual(a.next);\r
2874 \r
2875         ele.addEventListener("repeatEvent", function(evt) {\r
2876           expect(evt.target).toBe(ele);\r
2877         } );\r
2878         frame.timelines = [];\r
2879         frame.first = null;\r
2880         frame.addLine( base("$frame").$begin.up().mix({\r
2881           isResolved: true,\r
2882           timelines: [],\r
2883           begin: 1,\r
2884           simpleDuration: 4,\r
2885           activeTime: 15,\r
2886           target: ele\r
2887         }) );\r
2888         frame.setFrame(9);\r
2889         expect(frame.first).toEqual({\r
2890                 frame: 13,\r
2891                 eventType: "repeat",\r
2892                 count: 3,\r
2893                 target: ele,\r
2894               \r
2895                 next: { frame: 16,\r
2896                   eventType: "end",\r
2897                   target: ele,\r
2898                   next: null\r
2899                 }\r
2900               } );\r
2901       } );\r
2902       afterEach( function() {\r
2903         base("$frame").startAnimation();\r
2904       } );\r
2905     } );\r
2906     describe("A $animateTransformElemenet object", function() {\r
2907       describe("An init method", function() {\r
2908         var $animate, ele, frame, p;\r
2909         beforeEach( function() {\r
2910           $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();\r
2911           /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
2912           $animate.degits = 1;\r
2913           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2914           ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");\r
2915           p.appendChild(ele);\r
2916           frame = base("$frame");\r
2917           frame.timelines.length = 0;\r
2918           frame.startTime = Date.now();\r
2919           frame.setFrame(0);\r
2920         } );\r
2921         afterEach( function() {\r
2922           $animate.numberOfList = -1;\r
2923         } );\r
2924         /*境界条件を調べておく (limit value analysis)*/\r
2925         it("should be this for the value  (limit value analysis)", function() {\r
2926           expect($animate.numberOfList).toBe(-1);\r
2927           expect($animate.type).toBe("translate");\r
2928           expect(p.__transformList).toBeUndefined();\r
2929           expect($animate.isCSS).toBeFalsy();\r
2930           expect($animate.isSum).toBeFalsy();\r
2931           expect($animate.attrName).toBe("transform");\r
2932           \r
2933           $animate.init();\r
2934           expect($animate.numberOfList).toBe(-1);\r
2935           expect(p.__transformList).toBeUndefined();\r
2936           expect($animate.isCSS).toBeFalsy();\r
2937           expect($animate.type).toBe("translate");\r
2938           expect($animate.attrName).toBe("transform");\r
2939           \r
2940           $animate.init(p);\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
2946           \r
2947           $animate.init(ele);\r
2948           expect($animate.numberOfList).toBe(-1);\r
2949           expect(p.__transformList).toEqual([]);\r
2950           expect($animate.isCSS).toBeFalsy();\r
2951           expect($animate.type).toBe("translate");\r
2952           expect($animate.attrName).toBe("transform");\r
2953           \r
2954           ele.setAttributeNS(null, "values", "0;1");\r
2955           ele.setAttributeNS(null, "attributeName", "");\r
2956           $animate.init(ele);\r
2957           expect($animate.isCSS).toBeFalsy();\r
2958           expect($animate.type).toBe("translate");\r
2959           expect($animate.type).toBe("translate");\r
2960           expect($animate.numberOfList).toBe(0);\r
2961           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2962                                                value: "translate(0)",\r
2963                                                isSum: false,\r
2964                                                isRemove: true\r
2965                                               } ]);\r
2966           \r
2967           ele.setAttributeNS(null, "type", "translate");\r
2968           $animate.init(ele);\r
2969           expect($animate.numberOfList).toBe(0);\r
2970           expect($animate.isCSS).toBeFalsy();\r
2971           expect($animate.type).toBe("translate");\r
2972           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2973                                                value: "translate(0)",\r
2974                                                isSum: false,\r
2975                                                isRemove: true\r
2976                                               } ]);\r
2977           $animate.tocall(0);\r
2978           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2979           \r
2980           ele.parentNode.appendChild(ele.cloneNode(true));\r
2981           $animate.numberOfList = -1;\r
2982           $animate.init(ele.parentNode.lastChild);\r
2983           expect($animate.numberOfList).toBe(1);\r
2984           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2985           expect(p.__transformList[1].isPlaying).toBeFalsy();\r
2986 \r
2987           expect($animate.type).toBe("translate");\r
2988           $animate.tocall(0);\r
2989           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2990           expect(p.__transformList[1].isPlaying).toBeTruthy();\r
2991           $animate._setEndFrame(1);\r
2992           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2993           expect(p.__transformList[1].isPlaying).toBeTruthy();\r
2994           \r
2995           delete p.__transformList;\r
2996           ele.setAttributeNS(null, "type", "scale");\r
2997           $animate.numberOfList = -1;\r
2998           $animate.init(ele);\r
2999           expect($animate.numberOfList).toBe(0);\r
3000           expect(p.__transformList).toEqual([ {isPlaying: false,\r
3001                                                value: "translate(0)",\r
3002                                                isSum: false,\r
3003                                                isRemove: true\r
3004                                               } ]);\r
3005           expect($animate.type).toBe("scale");\r
3006 \r
3007           delete p.__transformList;\r
3008           $animate.numberOfList = -1;\r
3009           ele.setAttributeNS(null, "additive", "sum");\r
3010           ele.setAttributeNS(null, "fill", "freeze");\r
3011           $animate.init(ele);\r
3012           expect($animate.isSum).toBeTruthy();\r
3013           expect(p.__transformList).toEqual([ {isPlaying: false,\r
3014                                                value: "translate(0)",\r
3015                                                isSum: true,\r
3016                                                isRemove: false\r
3017                                               } ]);\r
3018           delete p.__transformList;\r
3019           $animate.numberOfList = -1;\r
3020           ele.setAttributeNS(null, "additive", "replace");\r
3021           ele.setAttributeNS(null, "fill", "remove");\r
3022           $animate.init(ele);\r
3023           expect(p.__transformList).toEqual([ {isPlaying: false,\r
3024                                                value: "translate(0)",\r
3025                                                isSum: false,\r
3026                                                isRemove: true\r
3027                                               } ]);\r
3028         } );\r
3029         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3030         it("should be this for the value (the valid partion )", function() {\r
3031           ele.setAttributeNS(null, "type", "scale");\r
3032           ele.setAttributeNS(null, "values", "0;1");\r
3033           $animate.init(ele);\r
3034           expect($animate.isCSS).toBeFalsy();\r
3035           expect($animate.numberOfList).toBe(0);\r
3036           expect($animate.tocall(0)).toBe("scale(0.0)");\r
3037           expect($animate.tocall(0.5)).toBe("scale(0.5)");\r
3038           expect($animate.tocall(0.9)).toBe("scale(0.9)");\r
3039           expect($animate.tocall(1)).toBe("scale(1.0)");\r
3040 \r
3041           ele.parentNode.appendChild(ele.cloneNode(true));\r
3042           $animate.numberOfList = -1;\r
3043           $animate.init(ele.parentNode.lastChild);\r
3044           expect($animate.numberOfList).toBe(1);\r
3045           expect($animate.tocall(0)).toBe("scale(0.0)");\r
3046           expect($animate.tocall(1)).toBe("scale(1.0)");\r
3047           \r
3048           ele.parentNode.appendChild(ele.cloneNode(true));\r
3049           $animate.up("$a").numberOfList = -1;\r
3050           ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
3051           $animate.$a.init(ele.parentNode.lastChild);\r
3052           expect($animate.$a.numberOfList).toBe(2);\r
3053           expect($animate.$a.isDefault).toBeTruthy();\r
3054           expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");\r
3055           expect($animate.$a.tocall(0)).toBe("scale(0.0)");\r
3056           expect($animate.$a.tocall(1)).toBe("scale(1.0)");\r
3057           $animate.defaultValue = $animate.$a.defaultValue;\r
3058           expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");\r
3059           \r
3060           ele.setAttributeNS(null, "additive", "sum");\r
3061           var parentNode = ele.parentNode;\r
3062           parentNode.appendChild(ele.cloneNode(true));\r
3063           parentNode.__transformList = [];\r
3064           /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/\r
3065           parentNode.removeChild(ele);\r
3066           $animate.numberOfList = -1;\r
3067           $animate.init(parentNode.lastChild);\r
3068           expect($animate.numberOfList).toBe(0);\r
3069           expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
3070           expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
3071           \r
3072           parentNode.appendChild(ele.cloneNode(true));\r
3073           $animate.up("$a").numberOfList = -1;\r
3074           parentNode.__transformList = [];\r
3075           parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
3076           $animate.$a.init(parentNode.lastChild);\r
3077           expect($animate.$a.numberOfList).toBe(0);\r
3078           expect($animate.$a.isDefault).toBeTruthy();\r
3079           expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");\r
3080           expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
3081           expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
3082           $animate.defaultValue = $animate.$a.defaultValue;\r
3083           expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");\r
3084           \r
3085           ele.removeAttributeNS(null, "additive");\r
3086           ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",\r
3087            "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");\r
3088           ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",\r
3089            "scale(0.0)", "scale(1.0)");\r
3090           function ad(first, second, a, b, c, d) {\r
3091             /*子要素を全部消す*/\r
3092             while (parentNode.firstChild) {\r
3093               parentNode.removeChild(parentNode.firstChild);\r
3094             }\r
3095             \r
3096             /*additive属性のreplaceとsumの混合*/\r
3097             ele.setAttributeNS(null, "additive", first);\r
3098             parentNode.appendChild(ele.cloneNode(true));\r
3099             ele.setAttributeNS(null, "additive", second);\r
3100             parentNode.appendChild(ele.cloneNode(true));\r
3101             parentNode.__transformList = [];\r
3102             $animate.numberOfList = -1;\r
3103             parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
3104             $animate.up("$first").init(parentNode.firstChild);\r
3105             $animate.up("$second").init(parentNode.lastChild);\r
3106             expect($animate.$first.numberOfList).toBe(0);\r
3107             expect($animate.$second.numberOfList).toBe(1);\r
3108             expect($animate.$first.tocall(0)).toBe(a);\r
3109             expect($animate.$second.tocall(0)).toBe(b);\r
3110             expect($animate.$first.tocall(1)).toBe(c);\r
3111             expect($animate.$second.tocall(1)).toBe(d);\r
3112           };\r
3113         } );\r
3114         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3115         it("should be this for the value (the invalid partion )", function() {\r
3116           $animate.init(ele);\r
3117           ele.parentNode.__transformList = null;\r
3118           expect( function () {\r
3119             $animate.tocall(0);\r
3120           } ).toThrow();\r
3121           \r
3122           $animate.numberOfList = -1;\r
3123           $animate.init(ele);\r
3124           $animate.numberOfList = -1;\r
3125           expect( function () {\r
3126             $animate.tocall(0);\r
3127           } ).toThrow();\r
3128         } );\r
3129       } );\r
3130     } );\r
3131     describe("A $motionElement object", function() {\r
3132       describe("An init method", function() {\r
3133         var $animate, ele, frame, p;\r
3134         beforeEach( function() {\r
3135           $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();\r
3136           /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
3137           $animate.degits = 1;\r
3138           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3139           ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");\r
3140           p.appendChild(ele);\r
3141           frame = base("$frame");\r
3142           frame.timelines.length = 0;\r
3143           frame.startTime = Date.now();\r
3144           frame.setFrame(0);\r
3145         } );\r
3146         afterEach( function() {\r
3147           $animate.numberOfList = -1;\r
3148           delete $animate.element;\r
3149           p.__transformList = null;\r
3150         } );\r
3151         /*境界条件を調べておく (limit value analysis)*/\r
3152         it("should be this for the value  (limit value analysis)", function() {\r
3153           expect($animate.type).toBe("translate");\r
3154           expect($animate.mode).toBe("paced");\r
3155           ele.setAttributeNS(null, "type", "scale");\r
3156           expect($animate.rotate).toBe("0");\r
3157           $animate.init(ele);\r
3158           expect($animate.type).toBe("translate");\r
3159           expect($animate.mode).toBe("paced");\r
3160           expect($animate.rotate).toBe("0");\r
3161           \r
3162           ele.setAttributeNS(null, "values", "0,0;1,0");\r
3163           $animate.up("$a").init(ele);\r
3164           expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");\r
3165           expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");\r
3166           expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");\r
3167           \r
3168           var ec = ele.cloneNode(true);\r
3169           p.appendChild(ec);\r
3170           ec.removeAttributeNS(null, "values");\r
3171           ec.setAttributeNS(null, "from", "0,0");\r
3172           ec.setAttributeNS(null, "to", "1,0");\r
3173           $animate.up("$a").init(ec);\r
3174           expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");\r
3175           expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");\r
3176           expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");\r
3177         } );\r
3178         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3179         it("should be this for the value (the invalid partion )", function() {\r
3180           $animate.init();\r
3181         } );\r
3182       } );\r
3183       describe("A hasAttrValues method", function() {\r
3184         var $animate, ele, frame, p;\r
3185         beforeEach( function() {\r
3186           $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();\r
3187           /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
3188           $animate.degits = 1;\r
3189           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3190           ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");\r
3191           p.appendChild(ele);\r
3192           frame = base("$frame");\r
3193           frame.timelines.length = 0;\r
3194           frame.startTime = Date.now();\r
3195           frame.setFrame(0);\r
3196         } );\r
3197         afterEach( function() {\r
3198           $animate.numberOfList = -1;\r
3199           delete $animate.element;\r
3200           p.__transformList = null;\r
3201         } );\r
3202         /*境界条件を調べておく (limit value analysis)*/\r
3203         it("should be this for the value  (limit value analysis)", function() {\r
3204                     \r
3205           expect($animate.up("$a").hasAttrValues()).toBeFalsy();\r
3206           $animate.up("$a").init(ele);\r
3207           expect($animate.$a.hasAttrValues()).toBeFalsy();\r
3208           \r
3209           ele.setAttributeNS(null, "path", "M");\r
3210           expect($animate.$a.hasAttrValues()).toBeTruthy();\r
3211           $animate.$animateTransformElement.up("$b").init(ele);\r
3212           expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();\r
3213         } );\r
3214       } );\r
3215     } );\r
3216     describe("Event", function() {\r
3217       var $animate, ele, frame, p;\r
3218       beforeEach( function() {\r
3219         \r
3220         $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
3221         p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3222         ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
3223         p.appendChild(ele);\r
3224         frame = base("$frame");\r
3225         frame.pauseAnimation();\r
3226         frame.timelines.length = 0; //配列の初期化\r
3227         frame.setFrame(0);\r
3228       } );\r
3229       /*境界条件を調べておく (limit value analysis)*/\r
3230       it("should be this for the value  (limit value analysis)", function() {\r
3231         ele.addEventListener("beginEvent", function(evt) {\r
3232           expect(evt.target).toBe(ele);\r
3233         } );\r
3234         var evt = ele.ownerDocument.createEvent("MouseEvents");\r
3235         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
3236         ele.dispatchEvent(evt);\r
3237         \r
3238         ele.setAttributeNS(null, "begin", "mousedown");\r
3239         ele.setAttributeNS(null, "dur", "1s");\r
3240         ele.setAttributeNS(null, "attributeName", "fill");\r
3241         ele.setAttributeNS(null, "fill", "freeze");\r
3242         ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
3243         ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
3244         $animate.init(ele);\r
3245         $animate.isCSS = false;\r
3246         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
3247         evt = ele.ownerDocument.createEvent("MouseEvents");\r
3248         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
3249         p.dispatchEvent(evt);\r
3250         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
3251         \r
3252         evt = ele.ownerDocument.createEvent("MouseEvents");\r
3253         evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
3254         frame.setFrame(frame.currentFrame);\r
3255         expect($animate.isEnd).toBeFalsy();\r
3256         p.dispatchEvent(evt);\r
3257         frame.setFrame(frame.currentFrame + 1);\r
3258         frame.setFrame(frame.currentFrame + 24);\r
3259         expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");\r
3260       } );\r
3261     } );\r
3262       describe("a beginElement method and an endElement method", function() {\r
3263         var $animate, ele, frame, p;\r
3264         beforeEach( function() {\r
3265           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
3266           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3267           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
3268           p.appendChild(ele);\r
3269           frame = base("$frame");\r
3270           frame.timelines.length = 0; //配列の初期化\r
3271           frame.setFrame(0);\r
3272           ele.setAttributeNS(null, "begin", "indefinite");\r
3273           ele.setAttributeNS(null, "dur", "1s");\r
3274           ele.setAttributeNS(null, "dur", "1s");\r
3275           ele.setAttributeNS(null, "attributeName", "fill");\r
3276           ele.setAttributeNS(null, "fill", "freeze");\r
3277           ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
3278           ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
3279           $animate.init(ele);\r
3280         } );\r
3281         /*境界条件を調べておく (limit value analysis)*/\r
3282         it("should be this for the value  (limit value analysis)", function() {\r
3283           expect(ele.beginElement()).toBeUndefined();\r
3284           var cur = frame.currentFrame,\r
3285               begin = frame.$begin.$1;\r
3286           expect(begin.string).toBe("indefinite");\r
3287           expect(begin.begin).toBe(cur);\r
3288           expect(ele.endElement()).toBeUndefined();\r
3289         } );\r
3290         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3291         it("should be this for the value (the valid partion )", function() {\r
3292           ele.addEventListener("beginEvent", function(evt){\r
3293             expect(evt.target.nodeName).toBe("animate");\r
3294           }, false );\r
3295           ele.beginElement();\r
3296         } );\r
3297       });\r
3298     } );\r
3299 } );\r