OSDN Git Service

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