OSDN Git Service

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