OSDN Git Service

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