OSDN Git Service

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