OSDN Git Service

Revert the addLine method
[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       /*境界条件を調べておく (limit value analysis)*/\r
1593       it("should be this for the value  (limit value analysis)", function() {\r
1594         expect(attr.element).toBeNull();\r
1595         expect(attr.push()).toBeNull();\r
1596         expect(attr.element).toBeNull();\r
1597         expect(attr.isCSS).toBeFalsy();\r
1598         expect(base("$frame").timelines.length).toBe(0);\r
1599         \r
1600         expect(attr.push(s)).toBeNull();\r
1601         expect(attr.element).toBeNull();\r
1602         expect(base("$frame").timelines.length).toBe(0);\r
1603         expect(attr.hasAttrValues()).toBeFalsy();\r
1604         \r
1605         var p = document.createElement("g");\r
1606         p.appendChild(s);\r
1607         expect(attr.push(s)).toBeNull();\r
1608         expect(attr.element).toBe(p);\r
1609         expect(base("$frame").timelines.length).toBe(0);\r
1610         \r
1611         s.setAttribute("end", "0");\r
1612         check("from", 1);\r
1613         check("to", 2);\r
1614         check("by", 3);\r
1615         check("values", 4);\r
1616         function check(attrName, num) {\r
1617           s.setAttribute(attrName, "1");\r
1618           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
1619           var l = attr.push(s);\r
1620           expect(attr.element).toBe(p);\r
1621           var timelines = base("$frame").timelines;\r
1622           expect(timelines.length).toBe(num);\r
1623           var line = timelines[num-1];\r
1624           expect(line.string).toBe("0");\r
1625           expect(line).toBe(l); //タイムラインのオブジェクトを返す\r
1626           var act = line.$activate;\r
1627           expect(act.dur).toBeNull();\r
1628           expect(act.end).toBe(0);\r
1629           expect(act.repeatCount).toBeNull();\r
1630           expect(act.repeatDur).toBeNull();\r
1631           expect(act.min).toBe("0");\r
1632           expect(act.max).toBe("indefinite");\r
1633           expect(act.simpleDur).toBeNull();\r
1634           expect(attr.hasAttrValues()).toBeTruthy();\r
1635           \r
1636           s.removeAttribute(attrName);\r
1637           expect(s.hasAttributeNS(null, attrName)).toBeFalsy();\r
1638           attr.push(s);\r
1639           expect(attr.element).toBe(p);\r
1640           expect(timelines.length).toBe(num);\r
1641         };\r
1642           \r
1643         /*targetElement属性のサポート*/\r
1644         var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1645         document.documentElement.appendChild(p2);\r
1646         p2.setAttributeNS(null, "id", "p23");\r
1647         s.setAttributeNS(null, "targetElement", "p23");\r
1648         attr.push(s);\r
1649         expect(attr.element).toBe(p2);\r
1650         \r
1651         /*ハイパーリンクのサポート*/\r
1652         var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");\r
1653         document.documentElement.appendChild(p3);\r
1654         p3.setAttributeNS(null, "id", "p34");\r
1655         s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");\r
1656         attr.push(s);\r
1657         expect(attr.element).toBe(p3);\r
1658         \r
1659         /*attributeType属性のサポート*/\r
1660         s.setAttributeNS(null, "attributeType", "CSS");\r
1661         s.setAttributeNS(null, "values", "a;b;c");\r
1662         attr.push(s);\r
1663         expect(attr.isCSS).toBeTruthy();\r
1664       } );\r
1665       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1666       it("should be this for the value (the valid partion on a spline mode )", function() {\r
1667         s.setAttribute("from", "1");\r
1668         var p = document.createElement("g");\r
1669         p.appendChild(s);\r
1670         var values = [ "0",\r
1671                       "0", null, null, null, \r
1672                       "0", "indefinite", null\r
1673                     ];\r
1674         values[7] = 0;\r
1675         check2("dur", "0");\r
1676         check2("begin", "0");\r
1677         values[0] = "1";\r
1678         check2("begin", "1");\r
1679         values[2] = 0;\r
1680         check2("end", "0");\r
1681         values[3] = "0";\r
1682         check2("repeatCount", "0");\r
1683         values[4] = "0";\r
1684         check2("repeatDur", "0");\r
1685         values[5] = "0";\r
1686         check2("min", "0");\r
1687         values[6] = "0";\r
1688         check2("max", "0");\r
1689         values[0] = "12";\r
1690         check2("begin", "12");\r
1691         values[7] = 1000 * base("$frame").fpms;\r
1692         values[1] = "1";\r
1693         check2("dur", "1");\r
1694         function check2(attrName, value) {\r
1695           s.setAttribute(attrName, value);\r
1696           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
1697           attr.push(s);\r
1698           expect(attr.element).toBe(p);\r
1699           var timelines = base("$frame").timelines;\r
1700           var line = timelines[timelines.length-1];\r
1701           expect(line.string).toBe(values[0]);\r
1702           var act = line.$activate;\r
1703           expect(act.dur).toBe(values[1]);\r
1704           expect(act.end).toBe(values[2]);\r
1705           expect(act.repeatCount).toBe(values[3]);\r
1706           expect(act.repeatDur).toBe(values[4]);\r
1707           expect(act.min).toBe(values[5]);\r
1708           expect(act.max).toBe(values[6]);\r
1709           expect(act.simpleDur).toBe(values[7]);\r
1710         };\r
1711         \r
1712                 \r
1713         var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1714         document.documentElement.appendChild(p4);\r
1715         p4.appendChild(s);\r
1716         p4.setAttributeNS(null, "style", "display: none");\r
1717         attr.push(s);\r
1718         expect(attr.setAttribute()).toBeUndefined();\r
1719         expect(attr.setAttribute("block")).toBeUndefined();\r
1720         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1721         expect(attr.isCSS).toBeFalsy();\r
1722         \r
1723         s.setAttributeNS(null, "attributeName", "display");\r
1724         attr.push(s);\r
1725         expect(attr.setAttribute("block")).toBeUndefined();\r
1726         expect(p4.hasAttributeNS(null, "display")).toBeTruthy();\r
1727         expect(attr.isCSS).toBeTruthy();\r
1728         expect(p4.style.getPropertyValue("display")).toBe("block");\r
1729         \r
1730         p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1731         document.documentElement.appendChild(p4);\r
1732         p4.appendChild(s);\r
1733         p4.setAttributeNS(null, "style", "display: none");\r
1734         attr.push(s);\r
1735         expect(attr.setAttribute("block")).toBeUndefined();\r
1736         expect(p4.hasAttributeNS(null, "display")).toBeTruthy();\r
1737         expect(p4.style.getPropertyValue("display")).toBe("block");\r
1738         expect(attr.removeAttribute()).toBeUndefined();\r
1739         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
1740         expect(p4.style.getPropertyValue("display")).toBe("none");\r
1741         \r
1742         /*attributeType属性のサポート*/\r
1743         s.setAttributeNS(null, "values", "a;b;c");\r
1744         s.setAttributeNS(null, "attributeName", "display");\r
1745         attr.isCSS = false;\r
1746         attr.push(s);\r
1747         expect(attr.isCSS).toBeTruthy();\r
1748       } );\r
1749       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1750       it("should be this for the value (the invalid partion )", function() {\r
1751         var p = document.createElement("g");\r
1752         p.appendChild(s);\r
1753         \r
1754         s.setAttributeNS(null, "begin", "1");\r
1755         attr.push(s);\r
1756         var timelines = base("$frame").timelines;\r
1757         expect(timelines.length).toBe(0);\r
1758         s.setAttributeNS(null, "from", "1");\r
1759         attr.push(s);\r
1760         expect(timelines.length).toBe(1);\r
1761         expect(attr.push(12)).toBeNull();\r
1762       } );\r
1763     } );\r
1764     describe("A setValues method", function() {\r
1765       var attr, s;\r
1766       beforeEach( function() {\r
1767         attr = base("$calcMode").$attribute.up("width");\r
1768         base("$frame").timelines.length = 0;\r
1769         s = document.createElement("animate");\r
1770       } );\r
1771       /*境界条件を調べておく (limit value analysis)*/\r
1772       it("should be this for the value  (limit value analysis)", function() {\r
1773         expect(attr.$from).not.toBeUndefined();\r
1774         expect(attr.setValues()).toBeNull();\r
1775         expect(attr.setValues("")).toBeNull();\r
1776 \r
1777         expect(attr.setValues("0;1")[0].to.string).toBe("1");\r
1778         expect(attr.setValues("0;1")[0].to.from.string).toBe("0");\r
1779         expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");\r
1780         expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0"); \r
1781                \r
1782         /*from-to アニメーション*/\r
1783         expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");\r
1784         expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");\r
1785         \r
1786         /*from-by アニメーション*/\r
1787         expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");\r
1788         expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);\r
1789         expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);\r
1790         \r
1791         /*fromなしto アニメーション*/\r
1792         expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");\r
1793         expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");\r
1794         var aset = attr.setValues(null, null, "1")[0].to;\r
1795         aset.call();\r
1796         expect(aset.from[0]).toBe(0);\r
1797         \r
1798         /*fromなしby アニメーション*/\r
1799         expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");\r
1800         expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);\r
1801         var aset = attr.setValues(null, null, null, "1")[0].to;\r
1802         aset.call();\r
1803         expect(aset.from[0]).toBe(0);\r
1804       } );\r
1805       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1806       it("should be this for the value (the valid partion on a spline mode )", function() {\r
1807         attr.$from.degit = 1;\r
1808         var setv = attr.setValues("0;1")[0].call();\r
1809         expect(setv(0.5)).toBe("0.5");\r
1810         expect(setv(1)).toBe("1.0");\r
1811         \r
1812         setv = attr.setValues(" 0;1; 2 ")[0].call();\r
1813         expect(setv(0.5)).toBe("0.5");\r
1814         expect(setv(1)).toBe("1.0");\r
1815         setv = attr.setValues("0;1;2")[1].call();\r
1816         expect(setv(0.4)).toBe("1.4");\r
1817         expect(setv(1)).toBe("2.0");\r
1818         \r
1819         attr.$from.degit = 2;\r
1820         setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();\r
1821         expect(setv(0.5)).toBe("8.05");\r
1822         expect(setv(1)).toBe("15.10");\r
1823         \r
1824         var v = attr.setValues("1;1;2;1;1;15.1");\r
1825         setv = v[4].mix( {\r
1826          keyTime: 0.1\r
1827         } ).call();\r
1828         expect(setv(0.05)).toBe("8.05");\r
1829         expect(setv(0.1)).toBe("15.10");\r
1830         setv = v[3].mix( {\r
1831          keyTime: 0.1\r
1832         } ).call();\r
1833         expect(setv(0.01)).toBe("1.00");\r
1834         expect(setv(0.1)).toBe("1.00");\r
1835         setv = v[2].mix( {\r
1836          keyTime: 0.5\r
1837         } ).call();\r
1838         expect(setv(0.25)).toBe("1.50");\r
1839         expect(setv(0.5)).toBe("1.00");\r
1840       } );\r
1841       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1842       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
1843         attr.$from.degit = 1;\r
1844         expect(attr.setValues("")).toBeNull();\r
1845         expect(attr.setValues(null, null, null, null)).toBeNull();\r
1846       } );\r
1847     } );\r
1848     describe("A setKey method", function() {\r
1849       var attr, s;\r
1850       beforeEach( function() {\r
1851         attr = base("$calcMode").$attribute.up("width");\r
1852         base("$frame").timelines.length = 0;\r
1853         s = document.createElement("animate");\r
1854         document.createElement("g").appendChild(s);\r
1855       } );\r
1856       /*境界条件を調べておく (limit value analysis)*/\r
1857       it("should be this for the value  (limit value analysis)", function() {\r
1858         expect(attr.setKey(s)).toBeNull();\r
1859         \r
1860         s.setAttributeNS(null, "from", "0");\r
1861         attr.setKey(s);\r
1862         s.setAttributeNS(null, "to", "0");\r
1863         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
1864         expect(attr.setKey(s)[0].to.string).toBe("0");\r
1865         s.setAttributeNS(null, "by", "0");\r
1866         attr.setKey(s);\r
1867         s.setAttributeNS(null, "values", "0;2");\r
1868         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
1869         expect(attr.setKey(s)[0].to.string).toBe("2");\r
1870         \r
1871         s.setAttributeNS(null, "keyTimes", "0;0.1");\r
1872         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
1873         \r
1874         s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");\r
1875         expect(attr.setKey(s)[0].keySplines[0]).toBe(0);\r
1876         expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);\r
1877         expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);\r
1878         expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);\r
1879         \r
1880         s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");\r
1881         expect(attr.setKey(s)[0].keySplines[0]).toBe(0);\r
1882         expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);\r
1883         expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);\r
1884         expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);\r
1885       } );\r
1886       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1887       it("should be this for the value (the valid partion on a spline mode )", function() {\r
1888         s.setAttributeNS(null, "values", "0;2;12;30");\r
1889         expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");\r
1890         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
1891         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
1892         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
1893         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
1894         s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");\r
1895         s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");\r
1896         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
1897         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
1898         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
1899         \r
1900         s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");\r
1901         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r
1902         expect(attr.setKey(s)[1].keyTime).toBe(0.1);\r
1903         expect(attr.setKey(s)[2].keyTime).toBe(0.8);\r
1904         \r
1905         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
1906         f(0, 0,0.1,0.3,1);\r
1907         f(1, 0.1,0.4,0.5,0.7);\r
1908         f(2, 0.2,0.2,0.1,1);\r
1909         \r
1910         s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2,  .2, .1  , 1 ;");\r
1911         f(0, 0,0.1,0.3,1);\r
1912         f(1, 0.1,0.4,0.5,0.7);\r
1913         f(2, 0.2,0.2,0.1,1);\r
1914         \r
1915         s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4  .5 .7; .2   .2  .1    1 ;");\r
1916         f(0, 0,0.1,0.333,1);\r
1917         f(1, 0.1,0.4,0.5,0.7);\r
1918         f(2, 0.2,0.2,0.1,1);\r
1919         function f (i, a, b, c, d) {\r
1920           var splines = attr.setKey(s)[i].keySplines;\r
1921           expect(splines[0]).toBe(a);\r
1922           expect(splines[1]).toBe(b);\r
1923           expect(splines[2]).toBe(c);\r
1924           expect(splines[3]).toBe(d);\r
1925         };\r
1926       } );\r
1927       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1928       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
1929         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
1930         expect(attr.setKey(s)).toBeNull();\r
1931         s.setAttributeNS(null, "values", "0;2;12");\r
1932         expect(attr.setKey(s)).toBeNull();\r
1933         s.setAttributeNS(null, "values", "0;2;12;20");\r
1934         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");\r
1935         expect(attr.setKey(s)).toBeNull();\r
1936       } );\r
1937     } );\r
1938   } );\r
1939   describe("A $setElemenet object", function() {\r
1940     describe("A timeline property", function() {\r
1941       var $set, ele, frame;\r
1942       beforeEach( function() {\r
1943         $set = base("$calcMode").$attribute.$setElement.up();\r
1944         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1945         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
1946         p.appendChild(ele);\r
1947         frame = base("$frame");\r
1948       } );\r
1949       /*境界条件を調べておく (limit value analysis)*/\r
1950       it("should be this for the value  (limit value analysis)", function() {\r
1951         expect($set.timeline).toBe(frame.$begin);\r
1952         \r
1953         $set.init();\r
1954         expect($set.timeline).toBe(frame.$begin);\r
1955         expect($set.element).toBeNull();\r
1956       } );\r
1957     } );\r
1958       describe("An init method", function() {\r
1959       var $set, ele, frame;\r
1960       beforeEach( function() {\r
1961         $set = base("$calcMode").$attribute.$setElement.up();\r
1962         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
1963         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
1964         p.appendChild(ele);\r
1965         frame = base("$frame");\r
1966       } );\r
1967       /*境界条件を調べておく (limit value analysis)*/\r
1968       it("should be this for the value  (limit value analysis)", function() {\r
1969         expect($set.to).toBe("");\r
1970         expect($set.attrName).toBe("");\r
1971         expect($set.defaultValue).toBe("");\r
1972         expect($set.isDefault).toBeFalsy();\r
1973         expect($set.attrNameSpace).toBeNull();\r
1974         $set.init();\r
1975         expect($set.timeline).toBe(frame.$begin);\r
1976         $set.init(ele);\r
1977         expect($set.to).toBe("");\r
1978         expect($set.attrName).toBe("");\r
1979         expect($set.isDefault).toBeFalsy();\r
1980         expect($set.attrNameSpace).toBeNull();\r
1981         expect($set.timeline).toBe(frame.$begin);\r
1982       } );\r
1983       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1984       it("should be this for the value (the valid partion on a spline mode )", function() {\r
1985         ele.setAttributeNS(null, "to", "t1");\r
1986         $set.init(ele);\r
1987         expect($set.to).toBe("t1");\r
1988         expect($set.attrName).toBe("");\r
1989         expect($set.defaultValue).toBe("");\r
1990 \r
1991         ele.setAttributeNS(null, "attributeName", "tt1");\r
1992         $set.init(ele);\r
1993         expect($set.to).toBe("t1");\r
1994         expect($set.attrName).toBe("tt1");\r
1995         expect($set.defaultValue).toBe("");\r
1996 \r
1997         ele.parentNode.setAttributeNS(null, "tt1", "undef");\r
1998         $set.init(ele);\r
1999         expect($set.defaultValue).toBe("undef");\r
2000         expect($set.isDefault).toBeTruthy();\r
2001 \r
2002         ele.setAttributeNS(null, "attributeName", "font-size");\r
2003         ele.parentNode.style.setProperty("font-size", "12px");\r
2004         $set.init(ele);\r
2005         expect($set.defaultValue).toBe("12px");\r
2006         expect($set.isDefault).toBeFalsy();\r
2007         \r
2008         ele.setAttributeNS(null, "attributeName", "xlink:href");\r
2009         $set.init(ele);\r
2010         expect($set.to).toBe("t1");\r
2011         expect($set.attrName).toBe("xlink:href");\r
2012         expect($set.defaultValue).toBe("");\r
2013         ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");\r
2014         $set.init(ele);\r
2015         expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");\r
2016       } );\r
2017       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2018       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
2019         $set.init(null);\r
2020         expect($set.to).toBe("");\r
2021         expect($set.attrName).toBe("");\r
2022         expect($set.defaultValue).toBe("");\r
2023 \r
2024         $set.init(12);\r
2025         expect($set.to).toBe("");\r
2026         expect($set.attrName).toBe("");\r
2027         expect($set.defaultValue).toBe("");\r
2028       } );\r
2029     } );\r
2030     describe("Frame Set", function() {\r
2031       var $set, ele, frame;\r
2032       beforeEach( function() {\r
2033         $set = base("$calcMode").$attribute.$setElement.up();\r
2034         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2035         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
2036         p.appendChild(ele);\r
2037         frame = base("$frame");\r
2038         frame.timelines.length = 0; //配列の初期化\r
2039         frame.startTime = Date.now();\r
2040         frame.setFrame(0);\r
2041       } );\r
2042       /*境界条件を調べておく (limit value analysis)*/\r
2043       it("should be this for the value  (limit value analysis)", function() {\r
2044         expect($set.isEnd).toBeFalsy();\r
2045         expect($set.state).toBe("idling");\r
2046         ele.setAttributeNS(null, "dur", "1s");\r
2047         ele.setAttributeNS(null, "attributeName", "fill");\r
2048         ele.setAttributeNS(null, "to", "red");\r
2049         $set.init(ele);\r
2050         expect($set.timeline).not.toBe(frame.$begin);\r
2051         frame.setFrame(0);\r
2052         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2053         expect($set.state).toBe("playing");\r
2054         \r
2055         frame.setFrame(24);\r
2056         expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();\r
2057         expect($set.state).toBe("idling");\r
2058       } );\r
2059       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2060       it("should be this for the value (the valid partion)", function() {\r
2061         ele.setAttributeNS(null, "begin", "1s");\r
2062         ele.setAttributeNS(null, "dur", "1s");\r
2063         ele.setAttributeNS(null, "attributeName", "fill");\r
2064         ele.setAttributeNS(null, "to", "red");\r
2065         $set.init(ele);\r
2066         var f = function(num) {\r
2067           frame.setFrame(num);\r
2068           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();\r
2069         }\r
2070         f(0);\r
2071         f(1);\r
2072         f(23);\r
2073         frame.setFrame(24);\r
2074         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2075         frame.setFrame(25);\r
2076         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2077         f(48);\r
2078         f(49);\r
2079         \r
2080         ele.setAttributeNS(null, "fill", "freeze");\r
2081         $set.init(ele);\r
2082         f(0);\r
2083         f(1);\r
2084         f(23);\r
2085         frame.setFrame(24);\r
2086         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2087         frame.setFrame(25);\r
2088         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
2089         frame.setFrame(48);\r
2090         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2091         frame.setFrame(49);\r
2092         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2093         ele.setAttributeNS(null, "begin", "1s");\r
2094         ele.setAttributeNS(null, "attributeName", "fill");\r
2095         ele.setAttributeNS(null, "to", "red");\r
2096         /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/\r
2097         $set.init(ele);\r
2098         var f = function(num) {\r
2099           frame.setFrame(num);\r
2100           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
2101         }\r
2102         f(0);\r
2103         f(1);\r
2104         f(23);\r
2105         f(24);\r
2106         f(25);\r
2107         f(48);      } );\r
2108       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2109       it("should be this for the value (the invalid partion)", function() {\r
2110 \r
2111       } );\r
2112     } );\r
2113   } );\r
2114     describe("A $animateElement object", function() {\r
2115       describe("An init method", function() {\r
2116         var $animate, ele, frame;\r
2117         beforeEach( function() {\r
2118           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
2119           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2120           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2121           p.appendChild(ele);\r
2122           frame = base("$frame");\r
2123           frame.timelines.length = 0;\r
2124           frame.startTime = Date.now();\r
2125           frame.setFrame(0);\r
2126         } );\r
2127         /*境界条件を調べておく (limit value analysis)*/\r
2128         it("should be this for the value  (limit value analysis)", function() {\r
2129           $animate.init();\r
2130           \r
2131           ele.setAttributeNS(null, "begin", "1s");\r
2132           ele.setAttributeNS(null, "dur", "1s");\r
2133           ele.setAttributeNS(null, "attributeName", "d");\r
2134           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2135           ele.setAttributeNS(null, "to", "M20 20 L10 30");\r
2136           $animate.init(ele);\r
2137           \r
2138           frame.setFrame(0);\r
2139           var p = ele.parentNode;\r
2140           /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、\r
2141            * 他のブラウザではnullを返すため、その対策をする*/\r
2142           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2143           \r
2144           function f(fr, result) {\r
2145             frame.setFrame(fr);\r
2146             expect(p.getAttributeNS(null, "d") || "").toBe(result);\r
2147           };\r
2148           \r
2149           f(24, "M20.0 0.0 L20.0 30.0");\r
2150           f(36, "M20.0 10.0 L15.0 30.0");\r
2151           f(48, "");\r
2152                     \r
2153           ele.setAttributeNS(null, "fill", "freeze");\r
2154           $animate.init(ele);\r
2155           f(24, "M20.0 0.0 L20.0 30.0");\r
2156           f(36, "M20.0 10.0 L15.0 30.0");\r
2157           f(48, "M20.0 20.0 L10.0 30.0");\r
2158           \r
2159           frame.timelines.length = 0;\r
2160           ele.setAttributeNS(null, "calcMode", "discrete");\r
2161           $animate.init(ele);\r
2162           expect($animate.mode).toBe("discrete");\r
2163           f(24, "M20.0 0.0 L20.0 30.0");\r
2164           f(25, "M20.0 0.0 L20.0 30.0");\r
2165           f(37, "M20.0 20.0 L10.0 30.0");\r
2166           f(48, "M20.0 20.0 L10.0 30.0");\r
2167           \r
2168           ["display", "visibility", "xlink:href",\r
2169            "stroke-linecap", "font-style"].forEach( function(attrName) {\r
2170             function g(fr, result) {\r
2171               frame.setFrame(fr);\r
2172               expect(p.getAttribute(attrName) || "").toBe(result);\r
2173             };\r
2174 \r
2175             frame.timelines.length = 0;\r
2176             ele.setAttributeNS(null, "calcMode", "linear");\r
2177             ele.setAttributeNS(null, "attributeName", attrName);\r
2178             $animate.init(ele);\r
2179             expect($animate.mode).toBe("discrete");\r
2180             g(24, "M20.0 0.0 L20.0 30.0");\r
2181             g(25, "M20.0 0.0 L20.0 30.0");\r
2182             g(37, "M20.0 20.0 L10.0 30.0");\r
2183             g(48, "M20.0 20.0 L10.0 30.0");\r
2184           } );\r
2185         } );\r
2186         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2187         it("should be this for the value (the valid partion )", function() {\r
2188           /*24FPSが前提*/\r
2189           ele.setAttributeNS(null, "begin", "0s");\r
2190           ele.setAttributeNS(null, "dur", "100s");\r
2191           ele.setAttributeNS(null, "attributeName", "d");\r
2192           ele.setAttributeNS(null, "fill", "freeze");\r
2193           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2194           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
2195           $animate.init(ele);\r
2196           \r
2197           var p = ele.parentNode;\r
2198           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2199           \r
2200           function f(fr, result) {\r
2201             frame.setFrame(fr);\r
2202             expect(p.getAttributeNS(null, "d")).toBe(result);\r
2203           };\r
2204           \r
2205           for (var i=0;i<2400;++i) {\r
2206             f(i, "M20.0 " +i+ ".0 L20.0 30.0");\r
2207           }\r
2208           f(2401, "M20.0 2400.0 L20.0 30.0");\r
2209           \r
2210           \r
2211           frame.timelines.length = 0;\r
2212           ele.setAttributeNS(null, "begin", "0s");\r
2213           ele.setAttributeNS(null, "dur", "1s");\r
2214           ele.setAttributeNS(null, "repeatDur", "2s");\r
2215           ele.setAttributeNS(null, "attributeName", "d");\r
2216           ele.setAttributeNS(null, "fill", "freeze");\r
2217           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2218           ele.setAttributeNS(null, "to", "M20 24 L20 30");\r
2219           $animate.init(ele);\r
2220           f(23, "M20.0 23.0 L20.0 30.0");\r
2221           f(24, "M20.0 0.0 L20.0 30.0");\r
2222           f(25, "M20.0 1.0 L20.0 30.0");\r
2223           f(48, "M20.0 24.0 L20.0 30.0");\r
2224 \r
2225           frame.timelines.length = 0;\r
2226           ele.setAttributeNS(null, "begin", "0s");\r
2227           ele.setAttributeNS(null, "dur", "2s");\r
2228           ele.setAttributeNS(null, "attributeName", "d");\r
2229           ele.setAttributeNS(null, "fill", "freeze");\r
2230           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2231           $animate.init(ele);\r
2232           f(0, "M20.0 0.0 L20.0 30.0");\r
2233           f(1, "M20.0 1.0 L20.0 30.0");\r
2234           f(24, "M20.0 24.0 L20.0 30.0");\r
2235           f(25, "M20.0 24.1 L20.0 30.0");\r
2236           f(47, "M20.0 26.3 L20.0 30.0");\r
2237           f(48, "M20.0 26.4 L20.0 30.0");\r
2238           f(49, "M20.0 26.4 L20.0 30.0");\r
2239           f(50, "M20.0 26.4 L20.0 30.0");\r
2240           \r
2241           frame.timelines.length = 0;\r
2242           ele.setAttributeNS(null, "begin", "0s");\r
2243           ele.setAttributeNS(null, "end", "2s");\r
2244           ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合\r
2245           ele.removeAttributeNS(null, "repeatDur");\r
2246           ele.setAttributeNS(null, "attributeName", "d");\r
2247           ele.setAttributeNS(null, "fill", "freeze");\r
2248           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2249           $animate.init(ele);\r
2250           f(0, "M20.0 0.0 L20.0 30.0");\r
2251           f(1, "M20.0 0.0 L20.0 30.0");\r
2252           f(24, "M20.0 0.0 L20.0 30.0");\r
2253           f(25, "M20.0 0.0 L20.0 30.0");\r
2254           f(47, "M20.0 0.0 L20.0 30.0");\r
2255           f(48, "M20.0 0.0 L20.0 30.0");\r
2256           f(49, "M20.0 0.0 L20.0 30.0");\r
2257           f(50, "M20.0 0.0 L20.0 30.0");\r
2258           \r
2259           frame.timelines.length = 0;\r
2260           ele.setAttributeNS(null, "dur", "2s");\r
2261           ele.setAttributeNS(null, "fill", "remove");\r
2262           var attrValue = p.getAttributeNS(null, "d");\r
2263           $animate.init(ele);\r
2264           f(48, attrValue);\r
2265           \r
2266           frame.timelines.length = 0;\r
2267           p.removeAttributeNS(null, "d");\r
2268           ele.setAttributeNS(null, "fill", "freeze");\r
2269           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
2270           $animate.init(ele);\r
2271           f(1, "M20.0 5.0 L20.0 30.0");\r
2272           f(48, "M20.0 26.4 L20.0 30.0");\r
2273           \r
2274           frame.timelines.length = 0;\r
2275           ele.setAttributeNS(null, "fill", "freeze");\r
2276           ele.setAttributeNS(null, "calcMode", "discrete");\r
2277           ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");\r
2278           $animate.init(ele);\r
2279           f(1, "M20.0 0.0 L20.0 30.0");\r
2280           f(4, "M20.0 0.0 L20.0 30.0");\r
2281           /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない\r
2282            * 修正の余地あり*/\r
2283           f(24, "M20.0 24.0 L20.0 30.0");\r
2284           f(25, "M20.0 24.0 L20.0 30.0");\r
2285           f(29, "M20.0 26.4 L20.0 30.0");\r
2286           f(48, "M20.0 26.4 L20.0 30.0");\r
2287           \r
2288           frame.timelines.length = 0;\r
2289           ele.setAttributeNS(null, "calcMode", "spline");\r
2290           ele.removeAttributeNS(null, "keyTimes");\r
2291           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");\r
2292           ele.removeAttributeNS(null, "end");\r
2293           ele.setAttributeNS(null, "dur", "9s");\r
2294           ele.setAttributeNS(null, "values", "210;177;121;10");\r
2295           $animate.init(ele);\r
2296           f(0, "210.0");\r
2297           f(72, "177.0");\r
2298           f(144, "121.0");\r
2299           f(216, "10.0");\r
2300           f(300, "10.0");\r
2301           \r
2302           frame.timelines.length = 0;\r
2303           ele.setAttributeNS(null, "calcMode", "spline");\r
2304           ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2305           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2306           ele.setAttributeNS(null, "dur", "8s");\r
2307           ele.setAttributeNS(null, "values", "300;255;180;30");\r
2308           $animate.init(ele);\r
2309           f(0, "300.0");\r
2310           f(48, "255.0");\r
2311           f(96, "180.0");\r
2312           f(192, "30.0");\r
2313           f(300, "30.0");\r
2314           \r
2315           /*開始時刻が未解決の場合*/\r
2316           frame.timelines.length = 0;\r
2317           ele.setAttributeNS(null, "begin", "click");\r
2318           ele.setAttributeNS(null, "calcMode", "spline");\r
2319           ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2320           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2321           ele.setAttributeNS(null, "dur", "8s");\r
2322           ele.setAttributeNS(null, "values", "300;255;180;30");\r
2323           ele.parentNode.setAttributeNS(null, "d", "300");\r
2324           $animate.init(ele);\r
2325           f(0, "300");\r
2326           f(48, "300");\r
2327           f(96, "300");\r
2328           f(192, "300");\r
2329           f(300, "300");\r
2330           \r
2331           ["display", "visibility", "xlink:href",\r
2332            "stroke-linecap", "font-style"].forEach( function(attrName) {\r
2333             function g(fr, result) {\r
2334               frame.setFrame(fr);\r
2335               expect(p.getAttribute(attrName)).toBe(result);\r
2336             };\r
2337 \r
2338             frame.timelines.length = 0;\r
2339             ele.setAttributeNS(null, "begin", "0s");\r
2340             ele.setAttributeNS(null, "calcMode", "linear");\r
2341             ele.setAttributeNS(null, "attributeName", attrName);\r
2342             ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2343             ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2344             ele.setAttributeNS(null, "dur", "8s");\r
2345             ele.setAttributeNS(null, "values", "inline;block;inline;block");\r
2346             $animate.init(ele);\r
2347             expect($animate.mode).toBe("discrete");\r
2348             g(0, "inline");\r
2349             g(48, "block");\r
2350             g(96, "inline");\r
2351             g(192, "block");\r
2352             g(300, "block");\r
2353             \r
2354             frame.timelines.length = 0;\r
2355             ele.setAttributeNS(null, "begin", "click");\r
2356             ele.setAttributeNS(null, "calcMode", "linear");\r
2357             ele.setAttributeNS(null, "attributeName", attrName);\r
2358             ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
2359             ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
2360             ele.setAttributeNS(null, "dur", "8s");\r
2361             ele.setAttributeNS(null, "values", "inline;block;inline;block");\r
2362             $animate.init(ele);\r
2363             var evt = ele.ownerDocument.createEvent("MouseEvents");\r
2364             evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
2365             p.dispatchEvent(evt);\r
2366             var cur = base("$frame").currentFrame;\r
2367             expect($animate.mode).toBe("discrete");\r
2368             g(cur+0, "inline");\r
2369             g(cur+48, "block");\r
2370             g(cur+96, "inline");\r
2371             g(cur+192, "block");\r
2372             g(cur+300, "block");\r
2373           } );\r
2374         } );\r
2375         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2376         it("should be this for the value (the invalid partion )", function() {\r
2377           ele.setAttributeNS(null, "begin", "0s");\r
2378           ele.setAttributeNS(null, "dur", "100s");\r
2379           ele.setAttributeNS(null, "attributeName", "d");\r
2380           ele.setAttributeNS(null, "fill", "freeze");\r
2381           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
2382           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
2383           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
2384           $animate.init(ele);\r
2385           \r
2386           var p = ele.parentNode;\r
2387           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
2388           \r
2389           function f(fr, result) {\r
2390             frame.setFrame(fr);\r
2391             expect(p.getAttributeNS(null, "d") || null).toBe(result);\r
2392           };\r
2393           f(0, null);\r
2394           f(1, null);\r
2395           \r
2396            frame.timelines.length = 0;\r
2397           /*keyTimes属性のリストの個数がvaluesリストと合致しない*/\r
2398           ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");\r
2399           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
2400           $animate.init(ele);\r
2401           f(0, null);\r
2402           f(1, null);\r
2403           \r
2404           /*keyTimes属性が0から始まっていない*/\r
2405           frame.timelines.length = 0;\r
2406           ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");\r
2407           ff("linear");\r
2408           ff("splines");\r
2409           ff("discrete");\r
2410           function ff(mode) {\r
2411             ele.setAttributeNS(null, "calcMode", mode);\r
2412             $animate.init(ele);\r
2413             f(0, null);\r
2414             f(1, null);\r
2415           }\r
2416           \r
2417           frame.timelines.length = 0;\r
2418           ele.setAttributeNS(null, "calcMode", "spline");\r
2419           $animate.init(ele);\r
2420           expect($animate.mode).toBe("spline");\r
2421           f(0, null);\r
2422           f(0.2, null);\r
2423           f(1, null); \r
2424         } );\r
2425       } );\r
2426       describe("RGB Color", function() {\r
2427         var $animate, ele, frame, f;\r
2428         beforeEach( function() {\r
2429           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
2430           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2431           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2432           p.appendChild(ele);\r
2433           frame = base("$frame");\r
2434           frame.timelines.length = 0;\r
2435           \r
2436           f = function (fr, result, attr) {\r
2437             frame.setFrame(fr);\r
2438             expect(p.getAttributeNS(null, attr)).toBe(result);\r
2439           };\r
2440         } );\r
2441         /*境界条件を調べておく (limit value analysis)*/\r
2442         it("should be this for the value  (limit value analysis)", function() {\r
2443           ele.setAttributeNS(null, "begin", "0s");\r
2444           ele.setAttributeNS(null, "dur", "1s");\r
2445           ele.setAttributeNS(null, "attributeName", "fill");\r
2446           ele.setAttributeNS(null, "fill", "remove");\r
2447           ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");\r
2448           ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");\r
2449           $animate.init(ele);\r
2450           \r
2451           f(0, "rgb(0, 0, 0)", "fill");\r
2452           f(23, "rgb(10, 10, 1)", "fill");\r
2453           \r
2454           frame.timelines.length = 0;\r
2455           ele.setAttributeNS(null, "attributeName", "stroke");\r
2456           $animate.init(ele);\r
2457           f(0, "rgb(0, 0, 0)", "stroke");\r
2458           f(23, "rgb(10, 10, 1)", "stroke");\r
2459 \r
2460           frame.timelines.length = 0;\r
2461           ele.setAttributeNS(null, "attributeName", "stop-color");\r
2462           $animate.init(ele);\r
2463           f(0, "rgb(0,0,0)", "stop-color");\r
2464           f(23, "rgb(10,10,1)", "stop-color");\r
2465 \r
2466           frame.timelines.length = 0;\r
2467           ele.setAttributeNS(null, "attributeName", "color");\r
2468           $animate.init(ele);\r
2469           f(0, "rgb(0,0,0)", "color");\r
2470           f(23, "rgb(10,10,1)", "color");\r
2471         } );\r
2472         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2473         it("should be this for the value (the valid partion )", function() {\r
2474           ele.setAttributeNS(null, "begin", "0s");\r
2475           ele.setAttributeNS(null, "dur", "1s");\r
2476           ele.setAttributeNS(null, "attributeName", "fill");\r
2477           ele.setAttributeNS(null, "fill", "remove");\r
2478           ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");\r
2479           $animate.init(ele);\r
2480           \r
2481           f(0, "rgb(0, 0, 0)", "fill");\r
2482           f(1, "rgb(1, 0, 0)", "fill");\r
2483           f(23, "rgb(23, 2, 1)", "fill");\r
2484 \r
2485           frame.timelines.length = 0;\r
2486           ele.setAttributeNS(null, "values", "#00083C;#18203C");\r
2487           $animate.init(ele);\r
2488           /*rgb形式に変換*/\r
2489           \r
2490           f(0, "rgb(0, 8, 60)", "fill");\r
2491           f(1, "rgb(1, 9, 60)", "fill");\r
2492           f(23, "rgb(23, 31, 60)", "fill");\r
2493           \r
2494           frame.timelines.length = 0;\r
2495           ele.setAttributeNS(null, "fill", "freeze");\r
2496           ele.setAttributeNS(null, "values", "black;white");\r
2497           $animate.init(ele);\r
2498           /*色キーワードをrgb形式に変換*/\r
2499           \r
2500           f(0, "rgb(0, 0, 0)", "fill");\r
2501           f(12, "rgb(128, 128, 128)", "fill");\r
2502           f(24, "rgb(255, 255, 255)", "fill");\r
2503         } );\r
2504         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2505         it("should be this for the value (the invalid partion )", function() {\r
2506           ele.setAttributeNS(null, "begin", "0s");\r
2507           ele.setAttributeNS(null, "dur", "1s");\r
2508           ele.setAttributeNS(null, "attributeName", "fi");\r
2509           ele.setAttributeNS(null, "fill", "remove");\r
2510           ele.setAttributeNS(null, "values", "#00083C;#00107C");\r
2511           $animate.init(ele);\r
2512           /*rgb形式に変換しない*/\r
2513           \r
2514           f(0, "#83.0C", "fi");\r
2515           f(1, "#84.0C", "fi");\r
2516           f(23, "#106.0C", "fi");   \r
2517         } );\r
2518       } );\r
2519     describe("$frame.$svgEvent object", function() {\r
2520       var frame = base("$frame").$svgEvent,\r
2521           p, ele;\r
2522       base("$frame").pauseAnimation();\r
2523       beforeEach( function() {\r
2524         base("$frame").pauseAnimation();\r
2525         frame = frame.up();\r
2526         frame.first = null;\r
2527         /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に\r
2528          * 影響を受けるため、新たに初期化しておく*/\r
2529         base("$frame").timelines = frame.timelines = [];\r
2530         frame.lastTimeLine = null;\r
2531         p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2532         ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2533         p.appendChild(ele);\r
2534       } );\r
2535       /*境界条件を調べておく (limit value analysis)*/\r
2536       it("should be this for the value  (limit value analysis)", function() {\r
2537         base("$frame").pauseAnimation();\r
2538         frame.lastTimeLine = null;\r
2539         expect(frame.lastTimeLine).toBeNull();\r
2540         expect(frame.first).toBeNull();\r
2541         frame.setTimeTable();\r
2542         expect(frame.first).toBeNull();\r
2543         frame.addLine( base("$frame").$begin.up().mix({\r
2544           timelines: [],\r
2545           begin: 0,\r
2546           activeTime: 0,\r
2547           target: ele\r
2548         }) );\r
2549         frame.setTimeTable();\r
2550         expect(frame.first).toEqual(\r
2551           { frame: 0,\r
2552             eventType: "begin",\r
2553             target: ele,\r
2554           \r
2555             next: { frame: 0,\r
2556               eventType: "end",\r
2557               target: ele,\r
2558               next: null\r
2559             }\r
2560           }\r
2561         );\r
2562       } );\r
2563       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2564       it("should be this for the value (the valid partion )", function() {\r
2565         base("$frame").pauseAnimation();\r
2566         frame.addLine( base("$frame").$begin.up().mix({\r
2567           timelines: [],\r
2568           begin: 0,\r
2569           activeTime: 0,\r
2570           target: ele\r
2571         }) );\r
2572         frame.setTimeTable();\r
2573         frame.setTimeTable();\r
2574         expect(frame.first).toEqual(\r
2575           { frame: 0,\r
2576             eventType: "begin",\r
2577             target: ele,\r
2578           \r
2579             next: { frame: 0,\r
2580               eventType: "end",\r
2581               target: ele,\r
2582               next: null\r
2583             }\r
2584           }\r
2585         );\r
2586         frame.setTimeTable();\r
2587         frame.setTimeTable();\r
2588         expect(frame.first).toEqual(\r
2589           { frame: 0,\r
2590             eventType: "begin",\r
2591             target: ele,\r
2592           \r
2593             next: { frame: 0,\r
2594               eventType: "end",\r
2595               target: ele,\r
2596               next: null\r
2597             }\r
2598           }\r
2599         );\r
2600         \r
2601         var isFiredBeginEvent = false;\r
2602         ele.addEventListener("beginEvent", function(evt) {\r
2603           isFiredBeginEvent = true;\r
2604           expect(evt.target).toBe(ele);\r
2605         } );\r
2606         ele.addEventListener("endEvent", function(evt) {\r
2607           expect(evt.target).toBe(ele);\r
2608           expect(isFiredBeginEvent).toBeTruthy();\r
2609         } );\r
2610         frame.setFrame(0);\r
2611         expect(frame.first).toBeNull();\r
2612         frame.setFrame(0);\r
2613         expect(frame.first).toBeNull();\r
2614         \r
2615         frame.timelines = [];\r
2616         frame.addLine( base("$frame").$begin.up().mix({\r
2617           timelines: [],\r
2618           begin: 0,\r
2619           activeTime: 10,\r
2620           target: ele\r
2621         }) );\r
2622         frame.setTimeTable();\r
2623         var a = { frame: 0,\r
2624             eventType: "begin",\r
2625             target: ele,\r
2626           \r
2627             next: { frame: 10,\r
2628               eventType: "end",\r
2629               target: ele,\r
2630               next: null\r
2631             }\r
2632           };\r
2633         expect(frame.first).toEqual(a);\r
2634         \r
2635         frame.addLine( base("$frame").$begin.up().mix({\r
2636           timelines: [],\r
2637           begin: 1,\r
2638           simpleDuration: 9,\r
2639           activeTime: 11,\r
2640           target: ele\r
2641         }) );\r
2642         frame.setTimeTable();\r
2643         a.next.next = { frame: 1,\r
2644             eventType: "begin",\r
2645             target: ele,\r
2646           \r
2647             next: { firstFrame: 10,\r
2648               frame: 10,\r
2649               eventType: "repeat",\r
2650               limit: 12,\r
2651               count: 1,\r
2652               simpleDuration: 9,\r
2653               target: ele,\r
2654             \r
2655               next: { frame: 12,\r
2656                 eventType: "end",\r
2657                 target: ele,\r
2658                 next: null\r
2659               }\r
2660             }\r
2661           };\r
2662         expect(frame.first).toEqual(a);\r
2663         frame.setFrame(11);\r
2664         expect(frame.first).toEqual( {frame: 12,\r
2665                 eventType: "end",\r
2666                 target: ele,\r
2667                 next: null\r
2668               } );\r
2669               \r
2670         frame.timelines = [];\r
2671         frame.first = null;\r
2672         frame.addLine( base("$frame").$begin.up().mix({\r
2673           timelines: [],\r
2674           begin: 1,\r
2675           simpleDuration: 4,\r
2676           activeTime: 10,\r
2677           target: ele\r
2678         }) );\r
2679         frame.setTimeTable();\r
2680         a =  { frame: 1,\r
2681             eventType: "begin",\r
2682             target: ele,\r
2683           \r
2684             next: {firstFrame:5,\r
2685               frame: 5,\r
2686               eventType: "repeat",\r
2687               limit: 11,\r
2688               count: 1,\r
2689               simpleDuration: 4,\r
2690               target: ele,\r
2691             \r
2692               next: { frame: 11,\r
2693                 eventType: "end",\r
2694                 target: ele,\r
2695                 next: null\r
2696               }\r
2697             }\r
2698           };\r
2699         expect(frame.first).toEqual(a);\r
2700         frame.setFrame(0);\r
2701         expect(frame.first).toEqual(a);\r
2702         frame.setFrame(1);\r
2703         a = a.next;\r
2704         expect(frame.first).toEqual(a);\r
2705         frame.setFrame(5);\r
2706         a.count = 1;\r
2707         a.frame = 9;\r
2708         expect(frame.first).toEqual(a);\r
2709 \r
2710         ele.addEventListener("repeatEvent", function(evt) {\r
2711           expect(evt.target).toBe(ele);\r
2712         } );\r
2713         frame.timelines = [];\r
2714         frame.first = null;\r
2715         frame.addLine( base("$frame").$begin.up().mix({\r
2716           timelines: [],\r
2717           begin: 1,\r
2718           simpleDuration: 4,\r
2719           activeTime: 15,\r
2720           target: ele\r
2721         }) );\r
2722         frame.setFrame(9);\r
2723         a.count = 2;\r
2724         a.limit = 16;\r
2725         a.next.frame = 16;\r
2726         expect(frame.first).toEqual(a);\r
2727       } );\r
2728       afterEach( function() {\r
2729         base("$frame").startAnimation();\r
2730       } );\r
2731     } );\r
2732     describe("A $animateTransformElemenet object", function() {\r
2733       describe("An init method", function() {\r
2734         var $animate, ele, frame, p;\r
2735         beforeEach( function() {\r
2736           $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();\r
2737           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2738           ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");\r
2739           p.appendChild(ele);\r
2740           frame = base("$frame");\r
2741           frame.timelines.length = 0;\r
2742           frame.startTime = Date.now();\r
2743           frame.setFrame(0);\r
2744         } );\r
2745         afterEach( function() {\r
2746           $animate.numberOfList = -1;\r
2747         } );\r
2748         /*境界条件を調べておく (limit value analysis)*/\r
2749         it("should be this for the value  (limit value analysis)", function() {\r
2750           expect($animate.numberOfList).toBe(-1);\r
2751           expect($animate.type).toBe("translate");\r
2752           expect(p.__transformList).toBeUndefined();\r
2753           \r
2754           $animate.init();\r
2755           expect($animate.numberOfList).toBe(-1);\r
2756           expect(p.__transformList).toBeUndefined();\r
2757           expect($animate.type).toBe("translate");\r
2758           \r
2759           $animate.init(p);\r
2760           expect($animate.numberOfList).toBe(-1);\r
2761           expect(p.__transformList).toBeUndefined();\r
2762           expect($animate.type).toBe("translate");\r
2763           \r
2764           $animate.init(ele);\r
2765           expect($animate.numberOfList).toBe(-1);\r
2766           expect(p.__transformList).toEqual([]);\r
2767           \r
2768           ele.setAttributeNS(null, "values", "0;1");\r
2769           $animate.init(ele);\r
2770           expect($animate.type).toBe("translate");\r
2771           expect($animate.numberOfList).toBe(0);\r
2772           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2773                                                value: "translate(0)",\r
2774                                                isSum: false\r
2775                                               } ]);\r
2776           \r
2777           ele.setAttributeNS(null, "type", "translate");\r
2778           $animate.init(ele);\r
2779           expect($animate.numberOfList).toBe(0);\r
2780           expect($animate.type).toBe("translate");\r
2781           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2782                                                value: "translate(0)",\r
2783                                                isSum: false\r
2784                                               } ]);\r
2785           $animate.tocall(0);\r
2786           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2787           \r
2788           ele.parentNode.appendChild(ele.cloneNode(true));\r
2789           $animate.numberOfList = -1;\r
2790           $animate.init(ele.parentNode.lastChild);\r
2791           expect($animate.numberOfList).toBe(1);\r
2792           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2793           expect(p.__transformList[1].isPlaying).toBeFalsy();\r
2794 \r
2795           expect($animate.type).toBe("translate");\r
2796           $animate.tocall(0);\r
2797           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2798           expect(p.__transformList[1].isPlaying).toBeTruthy();\r
2799           $animate._setEndFrame(1);\r
2800           expect(p.__transformList[0].isPlaying).toBeTruthy();\r
2801           expect(p.__transformList[1].isPlaying).toBeFalsy();\r
2802           \r
2803           delete p.__transformList;\r
2804           ele.setAttributeNS(null, "type", "scale");\r
2805           $animate.numberOfList = -1;\r
2806           $animate.init(ele);\r
2807           expect($animate.numberOfList).toBe(0);\r
2808           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2809                                                value: "translate(0)",\r
2810                                                isSum: false\r
2811                                               } ]);\r
2812           expect($animate.type).toBe("scale");\r
2813 \r
2814           delete p.__transformList;\r
2815           $animate.numberOfList = -1;\r
2816           ele.setAttributeNS(null, "additive", "sum");\r
2817           $animate.init(ele);\r
2818           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2819                                                value: "translate(0)",\r
2820                                                isSum: true\r
2821                                               } ]);\r
2822           delete p.__transformList;\r
2823           $animate.numberOfList = -1;\r
2824           ele.setAttributeNS(null, "additive", "replace");\r
2825           $animate.init(ele);\r
2826           expect(p.__transformList).toEqual([ {isPlaying: false,\r
2827                                                value: "translate(0)",\r
2828                                                isSum: false\r
2829                                               } ]);\r
2830         } );\r
2831         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2832         it("should be this for the value (the valid partion )", function() {\r
2833           ele.setAttributeNS(null, "type", "scale");\r
2834           ele.setAttributeNS(null, "values", "0;1");\r
2835           $animate.init(ele);\r
2836           expect($animate.numberOfList).toBe(0);\r
2837           expect($animate.tocall(0)).toBe("scale(0.0)");\r
2838           expect($animate.tocall(0.5)).toBe("scale(0.5)");\r
2839           expect($animate.tocall(0.9)).toBe("scale(0.9)");\r
2840           expect($animate.tocall(1)).toBe("scale(1.0)");\r
2841 \r
2842           ele.parentNode.appendChild(ele.cloneNode(true));\r
2843           $animate.numberOfList = -1;\r
2844           $animate.init(ele.parentNode.lastChild);\r
2845           expect($animate.numberOfList).toBe(1);\r
2846           expect($animate.tocall(0)).toBe("scale(0.0)");\r
2847           expect($animate.tocall(1)).toBe("scale(1.0)");\r
2848           \r
2849           ele.parentNode.appendChild(ele.cloneNode(true));\r
2850           $animate.up("$a").numberOfList = -1;\r
2851           ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
2852           $animate.$a.init(ele.parentNode.lastChild);\r
2853           expect($animate.$a.numberOfList).toBe(2);\r
2854           expect($animate.$a.isDefault).toBeTruthy();\r
2855           expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");\r
2856           expect($animate.$a.tocall(0)).toBe("scale(0.0)");\r
2857           expect($animate.$a.tocall(1)).toBe("scale(1.0)");\r
2858           $animate.defaultValue = $animate.$a.defaultValue;\r
2859           expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");\r
2860           \r
2861           ele.setAttributeNS(null, "additive", "sum");\r
2862           var parentNode = ele.parentNode;\r
2863           parentNode.appendChild(ele.cloneNode(true));\r
2864           parentNode.__transformList = [];\r
2865           /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/\r
2866           parentNode.removeChild(ele);\r
2867           $animate.numberOfList = -1;\r
2868           $animate.init(parentNode.lastChild);\r
2869           expect($animate.numberOfList).toBe(0);\r
2870           expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
2871           expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
2872           \r
2873           parentNode.appendChild(ele.cloneNode(true));\r
2874           $animate.up("$a").numberOfList = -1;\r
2875           parentNode.__transformList = [];\r
2876           parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
2877           $animate.$a.init(parentNode.lastChild);\r
2878           expect($animate.$a.numberOfList).toBe(0);\r
2879           expect($animate.$a.isDefault).toBeTruthy();\r
2880           expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");\r
2881           expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
2882           expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
2883           $animate.defaultValue = $animate.$a.defaultValue;\r
2884           expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");\r
2885           \r
2886           ele.removeAttributeNS(null, "additive");\r
2887           ad("replace", "sum", "scale(0.0)", "scale(0.0) scale(0.0)",\r
2888            "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");\r
2889           ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",\r
2890            "scale(0.0)", "scale(1.0)");\r
2891           function ad(first, second, a, b, c, d) {\r
2892             /*子要素を全部消す*/\r
2893             while (parentNode.firstChild) {\r
2894               parentNode.removeChild(parentNode.firstChild);\r
2895             }\r
2896             \r
2897             /*additive属性のreplaceとsumの混合*/\r
2898             ele.setAttributeNS(null, "additive", first);\r
2899             parentNode.appendChild(ele.cloneNode(true));\r
2900             ele.setAttributeNS(null, "additive", second);\r
2901             parentNode.appendChild(ele.cloneNode(true));\r
2902             parentNode.__transformList = [];\r
2903             $animate.numberOfList = -1;\r
2904             parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
2905             $animate.up("$first").init(parentNode.firstChild);\r
2906             $animate.up("$second").init(parentNode.lastChild);\r
2907             expect($animate.$first.numberOfList).toBe(0);\r
2908             expect($animate.$second.numberOfList).toBe(1);\r
2909             expect($animate.$first.tocall(0)).toBe(a);\r
2910             expect($animate.$second.tocall(0)).toBe(b);\r
2911             expect($animate.$first.tocall(1)).toBe(c);\r
2912             expect($animate.$second.tocall(1)).toBe(d);\r
2913           };\r
2914         } );\r
2915         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2916         it("should be this for the value (the invalid partion )", function() {\r
2917           $animate.init(ele);\r
2918           ele.parentNode.__transformList = null;\r
2919           expect( function () {\r
2920             $animate.tocall(0);\r
2921           } ).toThrow();\r
2922           \r
2923           $animate.numberOfList = -1;\r
2924           $animate.init(ele);\r
2925           $animate.numberOfList = -1;\r
2926           expect( function () {\r
2927             $animate.tocall(0);\r
2928           } ).toThrow();\r
2929         } );\r
2930       } );\r
2931     } );\r
2932     describe("A $motionElement object", function() {\r
2933       describe("An init method", function() {\r
2934         var $animate, ele, frame, p;\r
2935         beforeEach( function() {\r
2936           $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();\r
2937           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2938           ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");\r
2939           p.appendChild(ele);\r
2940           frame = base("$frame");\r
2941           frame.timelines.length = 0;\r
2942           frame.startTime = Date.now();\r
2943           frame.setFrame(0);\r
2944         } );\r
2945         afterEach( function() {\r
2946           $animate.numberOfList = -1;\r
2947           p.__transformList = null;\r
2948         } );\r
2949         /*境界条件を調べておく (limit value analysis)*/\r
2950         it("should be this for the value  (limit value analysis)", function() {\r
2951           expect($animate.type).toBe("translate");\r
2952           ele.setAttributeNS(null, "type", "scale");\r
2953           $animate.init(ele);\r
2954           expect($animate.type).toBe("translate");\r
2955           \r
2956           ele.setAttributeNS(null, "values", "0;1");\r
2957           $animate.up("$a").init(ele);\r
2958           expect($animate.$a.tocall(0)).toBe("translate(0.0)");\r
2959           expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");\r
2960           expect($animate.$a.tocall(1)).toBe("translate(1.0)");\r
2961           \r
2962           var ec = ele.cloneNode(true);\r
2963           ec.removeAttributeNS(null, "values");\r
2964           ec.setAttributeNS(null, "from", "0");\r
2965           ec.setAttributeNS(null, "to", "1");\r
2966           $animate.up("$a").init(ec);\r
2967           expect($animate.$a.tocall(0)).toBe("translate(0.0)");\r
2968           expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");\r
2969           expect($animate.$a.tocall(1)).toBe("translate(1.0)");\r
2970           \r
2971         } );\r
2972       } );\r
2973     } );\r
2974     describe("Event", function() {\r
2975       var $animate, ele, frame, p;\r
2976       beforeEach( function() {\r
2977         \r
2978         $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
2979         p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
2980         ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
2981         p.appendChild(ele);\r
2982         frame = base("$frame");\r
2983         frame.pauseAnimation();\r
2984         frame.timelines.length = 0; //配列の初期化\r
2985         frame.setFrame(0);\r
2986       } );\r
2987       /*境界条件を調べておく (limit value analysis)*/\r
2988       it("should be this for the value  (limit value analysis)", function() {\r
2989         ele.addEventListener("beginEvent", function(evt) {\r
2990           expect(evt.target).toBe(ele);\r
2991         } );\r
2992         var evt = ele.ownerDocument.createEvent("MouseEvents");\r
2993         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
2994         ele.dispatchEvent(evt);\r
2995         \r
2996         ele.setAttributeNS(null, "begin", "mousedown");\r
2997         ele.setAttributeNS(null, "dur", "1s");\r
2998         ele.setAttributeNS(null, "attributeName", "fill");\r
2999         ele.setAttributeNS(null, "fill", "freeze");\r
3000         ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
3001         ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
3002         $animate.init(ele);\r
3003         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
3004         expect($animate.state).toBe("idling");\r
3005         evt = ele.ownerDocument.createEvent("MouseEvents");\r
3006         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
3007         expect($animate.state).toBe("idling");\r
3008         p.dispatchEvent(evt);\r
3009         expect($animate.state).toBe("idling");\r
3010         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
3011         \r
3012         evt = ele.ownerDocument.createEvent("MouseEvents");\r
3013         evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
3014         frame.setFrame(frame.currentFrame);\r
3015         expect($animate.isEnd).toBeFalsy();\r
3016         expect($animate.state).toBe("idling");\r
3017         p.dispatchEvent(evt);\r
3018         frame.setFrame(frame.currentFrame + 1);\r
3019         expect($animate.state).toBe("playing");\r
3020         frame.setFrame(frame.currentFrame + 24);\r
3021         expect($animate.state).toBe("idling");\r
3022         expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");\r
3023       } );\r
3024     } );\r
3025       describe("a beginElement method and an endElement method", function() {\r
3026         var $animate, ele, frame, p;\r
3027         beforeEach( function() {\r
3028           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
3029           p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3030           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
3031           p.appendChild(ele);\r
3032           frame = base("$frame");\r
3033           frame.timelines.length = 0; //配列の初期化\r
3034           frame.setFrame(0);\r
3035           ele.setAttributeNS(null, "begin", "indefinite");\r
3036           ele.setAttributeNS(null, "dur", "1s");\r
3037           ele.setAttributeNS(null, "dur", "1s");\r
3038           ele.setAttributeNS(null, "attributeName", "fill");\r
3039           ele.setAttributeNS(null, "fill", "freeze");\r
3040           ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
3041           ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
3042           $animate.init(ele);\r
3043         } );\r
3044         /*境界条件を調べておく (limit value analysis)*/\r
3045         it("should be this for the value  (limit value analysis)", function() {\r
3046           expect(ele.beginElement()).toBeUndefined();\r
3047           var cur = frame.currentFrame,\r
3048               begin = frame.$begin.$1;\r
3049           expect(begin.string).toBe("indefinite");\r
3050           expect(begin.begin).toBe(cur);\r
3051           expect(ele.endElement()).toBeUndefined();\r
3052         } );\r
3053         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3054         it("should be this for the value (the valid partion )", function() {\r
3055           ele.addEventListener("beginEvent", function(evt){\r
3056             expect(evt.target.nodeName).toBe("animate");\r
3057           }, false );\r
3058           ele.beginElement();\r
3059         } );\r
3060       });\r
3061     } );\r
3062 } );\r