1 /*SIE under the MIT Lisence
\r
2 *公式ページは http://sie.osdn.jp/
\r
5 *Copyright (c) 2008-2010 Pivotal Labs
\r
7 Permission is hereby granted, free of charge, to any person obtaining
\r
8 a copy of this software and associated documentation files (the
\r
9 "Software"), to deal in the Software without restriction, including
\r
10 without limitation the rights to use, copy, modify, merge, publish,
\r
11 distribute, sublicense, and/or sell copies of the Software, and to
\r
12 permit persons to whom the Software is furnished to do so, subject to
\r
13 the following conditions:
\r
15 The above copyright notice and this permission notice shall be
\r
16 included in all copies or substantial portions of the Software.
\r
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
27 describe("SMIL Animation Spec", function() {
\r
28 describe("$frame object", function() {
\r
29 var frame = base("$frame");
\r
30 beforeEach( function() {
\r
31 frame.timelines = [];
\r
32 frame.isPaused = false;
\r
34 afterEach( function() {
\r
35 frame.timelines = [];
\r
37 /*境界条件を調べておく (limit value analysis)*/
\r
38 it("should be this for the value (limit value analysis)", function() {
\r
39 expect(typeof frame.setFrame).toBe("function");
\r
40 expect(frame.timelines.length).toBe(0);
\r
41 expect(frame.isBegin).toBeFalsy();
\r
42 expect(frame.startAnimation()).toBeUndefined();
\r
48 expect(frame.addLine()).toBe(false);
\r
49 expect(frame.addLine({})).toBe(false);
\r
50 expect(frame.addLine({
\r
53 expect(frame.addLine({
\r
57 expect(frame.removeLine()).toBeUndefined();
\r
58 expect(frame.removeLine({})).toBeUndefined();
\r
61 expect(frame.currentFrame).toBe(0);
\r
63 expect(frame.currentFrame).toBe(1);
\r
65 expect(frame.isPaused).toBeFalsy();
\r
66 expect(frame.pauseAnimation()).toBeUndefined();
\r
67 expect(frame.isPaused).toBeTruthy();
\r
70 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
71 it("should be this for the value (the valid partion)", function() {
\r
73 expect(frame.currentFrame).toBe(0);
\r
74 frame.startTime = Date.now();
\r
75 for (var i=0;i<100000;i++) {
\r
79 expect(frame.begin).toBe(0);
\r
80 expect(frame.activeTime).toBe(Number.MAX_VALUE);
\r
86 expect(frame.addLine( {
\r
90 expect(frame.addLine( {
\r
94 expect(frame.addLine( {
\r
98 expect(frame.addLine( {
\r
103 expect(frame.timelines.length).toBe(1);
\r
104 var timeline = frame.timelines[0];
\r
105 expect(timeline.begin).toBe(0);
\r
106 expect(timeline.activeTime).toBe(0);
\r
108 expect(frame.timelines[0]).toBe(timeline);
\r
109 frame.addLine({begin:1, activeTime:1});
\r
110 expect(frame.timelines[1]).not.toBe(timeline);
\r
111 frame.addLine(timeline);
\r
112 expect(frame.timelines[0]).not.toBe(timeline);
\r
113 expect(frame.timelines[1]).toBe(timeline);
\r
115 timeline = frame.timelines[0];
\r
116 frame.removeLine({});
\r
117 expect(frame.timelines[0]).toBe(timeline);
\r
118 frame.removeLine(timeline);
\r
119 expect(frame.timelines[0]).not.toBe(timeline);
\r
121 frame.addLine(frame.up().mix( {
\r
124 expect(frame.timelines).not.toBe(frame.$1.timelines);
\r
126 frame.timelines.length = 0;
\r
139 expect(frame.timelines[2].activeTime).toBe(2);
\r
141 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
142 it("should be this for the value (the invalid partion)", function() {
\r
143 expect(frame.addLine(12)).toBeFalsy();
\r
144 /*循環参照にならず、スタック領域不足にならない*/
\r
145 frame.addLine(frame);
\r
149 describe("the $frame.$list object", function() {
\r
150 var frame = base("$frame").$list.up("$2");
\r
151 beforeEach( function() {
\r
152 frame.timelines = [];
\r
153 frame.isPaused = false;
\r
154 frame.state = frame.WAITING;
\r
157 afterEach( function() {
\r
158 frame.timelines = [];
\r
160 /*境界条件を調べておく (limit value analysis)*/
\r
161 it("should be this for the value (limit value analysis)", function() {
\r
163 expect(frame.WAITING).toBe(0);
\r
164 expect(frame.BEGINNING).toBe(1);
\r
165 expect(frame.PLAYING).toBe(2);
\r
166 expect(frame.ENDING).toBe(3);
\r
167 expect(frame.POSTWAITING).toBe(4);
\r
168 expect(frame.state).toBe(frame.WAITING);
\r
170 expect(frame.beginList).toEqual({
\r
172 value: Number.MAX_VALUE
\r
174 expect(frame.endList).toEqual({
\r
176 value: Number.MAX_VALUE
\r
179 expect(typeof frame.getMaxList).toBe("function");
\r
181 expect(typeof frame.updateState).toBe("function");
\r
182 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
183 expect(frame.state).toBe(frame.WAITING);
\r
184 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
185 expect(frame.state).toBe(frame.WAITING);
\r
186 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
187 expect(frame.state).toBe(frame.WAITING);
\r
188 expect(frame.updateState(0).state).toBe(frame.WAITING);
\r
189 expect(frame.state).toBe(frame.WAITING);
\r
192 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
193 expect(frame.state).toBe(frame.BEGINNING);
\r
194 expect(frame.updateState().state).toBe(frame.BEGINNING);
\r
195 expect(frame.state).toBe(frame.BEGINNING);
\r
197 expect(frame.beginList).toEqual({
\r
199 value: Number.MAX_VALUE
\r
201 expect(frame.endList).toEqual({
\r
203 value: Number.MAX_VALUE
\r
206 expect(frame.getMaxList(0, frame.beginList)).toBe(-1);
\r
207 expect(frame.getMaxList(0, frame.endList)).toBe(-1);
\r
209 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
210 it("should be this for the value (the valid partion)", function() {
\r
212 function appendBegin(num) {
\r
213 frame.state = frame.WAITING;
\r
214 frame.beginList = {
\r
216 next: frame.beginList
\r
220 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
221 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
222 expect(frame.begin).toBe(0);
\r
223 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
224 expect(frame.state).toBe(frame.PLAYING);
\r
225 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
226 expect(frame.state).toBe(frame.PLAYING);
\r
228 frame.state = frame.WAITING;
\r
229 expect(frame.getMaxList(0, frame.beginList)).toBe(0);
\r
230 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
231 expect(frame.state).toBe(frame.BEGINNING);
\r
232 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
233 expect(frame.state).toBe(frame.PLAYING);
\r
234 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
235 expect(frame.state).toBe(frame.PLAYING);
\r
236 expect(frame.updateState(3).state).toBe(frame.PLAYING);
\r
237 expect(frame.state).toBe(frame.PLAYING);
\r
238 expect(frame.updateState(4).state).toBe(frame.PLAYING);
\r
239 expect(frame.state).toBe(frame.PLAYING);
\r
242 expect(frame.getMaxList(1, frame.beginList)).toBe(1);
\r
243 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
244 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
245 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
246 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
247 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
248 expect(frame.state).toBe(frame.BEGINNING);
\r
249 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
250 expect(frame.state).toBe(frame.PLAYING);
\r
251 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
252 expect(frame.state).toBe(frame.PLAYING);
\r
253 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
256 frame.state = frame.WAITING;
\r
257 expect(frame.updateState(0).state).toBe(frame.BEGINNING);
\r
258 expect(frame.begin).toBe(0);
\r
259 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
260 expect(frame.updateState(0).state).toBe(frame.PLAYING);
\r
261 expect(frame.begin).toBe(0);
\r
262 expect(frame.updateState(1).state).toBe(frame.ENDING);
\r
263 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
264 expect(frame.begin).toBe(1);
\r
265 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
266 expect(frame.updateState(1).state).toBe(frame.PLAYING);
\r
268 function appendEnd(num) {
\r
269 frame.state = frame.WAITING;
\r
273 next: frame.endList
\r
277 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
278 expect(frame.state).toBe(frame.BEGINNING);
\r
279 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
280 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
281 expect(frame.state).toBe(frame.PLAYING);
\r
282 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
283 expect(frame.state).toBe(frame.ENDING);
\r
284 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
285 expect(frame.state).toBe(frame.POSTWAITING);
\r
288 expect(frame.updateState(1).state).toBe(frame.BEGINNING);
\r
289 expect(frame.state).toBe(frame.BEGINNING);
\r
290 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
291 expect(frame.updateState(2).state).toBe(frame.PLAYING);
\r
292 expect(frame.state).toBe(frame.PLAYING);
\r
293 expect(frame.updateState(3).state).toBe(frame.ENDING);
\r
294 expect(frame.state).toBe(frame.ENDING);
\r
295 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
296 expect(frame.state).toBe(frame.POSTWAITING);
\r
297 expect(frame.updateState(4).state).toBe(frame.POSTWAITING);
\r
298 expect(frame.state).toBe(frame.POSTWAITING);
\r
300 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
301 it("should be this for the value (the invalid partion)", function() {
\r
302 expect(frame.updateState()).toBe(frame);
\r
303 expect(frame.updateState(null)).toBe(frame);
\r
305 describe("the setFrame method (override)", function() {
\r
306 var frame = base("$frame").$list.up("$3");
\r
307 beforeEach( function() {
\r
308 frame.timelines = [];
\r
309 frame.isPaused = false;
\r
310 frame.state = frame.WAITING;
\r
313 afterEach( function() {
\r
314 frame.timelines = [];
\r
315 frame.beginList = frame.$list.beginList;
\r
316 frame.endList = frame.$list.endList;
\r
317 frame.currentFrame = 0;
\r
319 /*境界条件を調べておく (limit value analysis)*/
\r
320 it("should be this for the value (limit value analysis)", function() {
\r
321 expect(typeof frame.setFrame).toBe("function");
\r
322 expect(frame.currentFrame).toBe(0);
\r
325 expect(frame.state).toBe(frame.WAITING);
\r
326 expect(frame.currentFrame).toBe(0);
\r
328 expect(frame.state).toBe(frame.WAITING);
\r
329 expect(frame.currentFrame).toBe(1);
\r
331 expect(typeof frame.addEvent).toBe("function");
\r
332 expect(typeof frame.addBeginList).toBe("function");
\r
333 expect(typeof frame.addEndList).toBe("function");
\r
335 expect(frame.addBeginList(1).value).toBe(1);
\r
336 expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);
\r
337 expect(frame.addEndList(1).value).toBe(1);
\r
338 expect(frame.endList.next.value).toBe(Number.MAX_VALUE);
\r
343 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
344 it("should be this for the value (the valid partion)", function() {
\r
345 function appendBegin(num) {
\r
346 frame.state = frame.WAITING;
\r
347 frame.addBeginList(num);
\r
350 expect(frame.currentFrame).toBe(0);
\r
352 expect(frame.currentFrame).toBe(0);
\r
353 expect(frame.state).toBe(frame.PLAYING);
\r
355 expect(frame.currentFrame).toBe(1);
\r
356 expect(frame.state).toBe(frame.PLAYING);
\r
361 expect(frame.state).toBe(frame.PLAYING);
\r
363 expect(frame.state).toBe(frame.PLAYING);
\r
365 expect(frame.state).toBe(frame.PLAYING);
\r
367 function appendEnd(num) {
\r
368 frame.state = frame.WAITING;
\r
370 frame.addEndList(num);
\r
375 expect(frame.state).toBe(frame.PLAYING);
\r
377 expect(frame.state).toBe(frame.PLAYING);
\r
379 expect(frame.state).toBe(frame.PLAYING);
\r
381 expect(frame.state).toBe(frame.POSTWAITING);
\r
383 expect(frame.state).toBe(frame.POSTWAITING);
\r
387 expect(frame.state).toBe(frame.PLAYING);
\r
389 expect(frame.state).toBe(frame.PLAYING);
\r
391 expect(frame.state).toBe(frame.PLAYING);
\r
393 expect(frame.state).toBe(frame.POSTWAITING);
\r
395 expect(frame.state).toBe(frame.POSTWAITING);
\r
397 expect(frame.state).toBe(frame.PLAYING);
\r
399 expect(frame.state).toBe(frame.PLAYING);
\r
403 expect(frame.state).toBe(frame.PLAYING);
\r
404 expect(frame.currentFrame).toBe(0);
\r
406 expect(frame.state).toBe(frame.PLAYING);
\r
407 expect(frame.currentFrame).toBe(1);
\r
409 expect(frame.state).toBe(frame.PLAYING);
\r
410 expect(frame.currentFrame).toBe(2);
\r
412 expect(frame.state).toBe(frame.POSTWAITING);
\r
414 expect(frame.state).toBe(frame.POSTWAITING);
\r
416 expect(frame.state).toBe(frame.PLAYING);
\r
418 expect(frame.state).toBe(frame.POSTWAITING);
\r
419 expect(frame.currentFrame).toBe(6);
\r
422 for (var i=0;i<10000;++i) {
\r
426 frame.beginList = frame.$list.beginList;
\r
427 frame.endList = frame.$list.endList;
\r
428 frame.state = frame.WAITING;
\r
430 var obj = { name: "", value: 0};
\r
431 frame.addEvent("begin", function(evt) { obj.name = "a";});
\r
432 frame.beginList = {
\r
434 next: frame.beginList
\r
437 expect(frame.currentFrame).toBe(0);
\r
438 expect(frame.state).toBe(frame.PLAYING);
\r
439 expect(obj.name).toBe("a");
\r
440 frame.addEvent("play", function(evt) { obj.name = "b";});
\r
442 expect(frame.state).toBe(frame.PLAYING);
\r
443 expect(obj.name).toBe("b");
\r
444 frame.addEvent("end", function(evt) { obj.value = 1;});
\r
447 next: frame.endList
\r
450 expect(frame.currentFrame).toBe(0);
\r
451 expect(frame.state).toBe(frame.POSTWAITING);
\r
452 expect(obj.value).toBe(1);
\r
453 frame.addEvent("begin", function(evt) {
\r
454 expect(evt.state).toBe(frame.BEGINNING);
\r
456 frame.addEvent("end", function(evt) {
\r
457 expect(evt.state).toBe(frame.ENDING);
\r
459 frame.addEvent("play", function(evt) {
\r
460 expect(evt.state).toBe(frame.PLAYING);
\r
464 /*addBeginListメソッドのチェックなど*/
\r
465 expect(frame.addBeginList(1).value).toBe(1);
\r
466 expect(frame.addBeginList(0).value).toBe(0);
\r
467 expect(frame.beginList.next.value).toBe(1);
\r
468 expect(frame.addBeginList(2).value).toBe(2);
\r
469 expect(frame.beginList.next.value).toBe(0);
\r
471 expect(frame.addEndList(1).value).toBe(1);
\r
472 expect(frame.addEndList(0).value).toBe(0);
\r
473 expect(frame.endList.next.value).toBe(1);
\r
474 expect(frame.addEndList(2).value).toBe(2);
\r
475 expect(frame.endList.next.value).toBe(0);
\r
479 describe("$begin object", function() {
\r
480 var begin = base("$frame").$begin.up();
\r
481 /*境界条件を調べておく (limit value analysis)*/
\r
482 it("should be this for the value (limit value analysis)", function() {
\r
483 expect(begin.string).toBe("");
\r
484 expect(begin.isResolved).toBeFalsy();
\r
485 expect(begin.eventTarget).toBe(document.documentElement);
\r
486 expect(typeof begin.listener).toBe("function");
\r
487 expect(begin.eventOffset).toBe(0);
\r
488 expect(begin.repeat).toBe(0);
\r
489 expect(begin.accessKey).toBe("");
\r
491 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
492 it("should be this for the value (the valid partion)", function() {
\r
493 begin.string = " hoge ";
\r
494 expect(begin.string).toBe(" hoge ");
\r
496 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
497 it("should be this for the value (the invalid partion)", function() {
\r
500 describe("A trim method in $begin object", function() {
\r
501 /*境界条件を調べておく (limit value analysis)*/
\r
502 beforeEach( function() {
\r
505 it("should be this for the value (limit value analysis)", function() {
\r
506 delete begin.string;
\r
507 expect(begin.trim(" ")).toBe("");
\r
508 expect( function() {
\r
512 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
513 it("should be this for the value (the valid partion)", function() {
\r
514 expect(begin.trim(" hoge ")).toBe("hoge");
\r
515 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
516 expect(begin.trim(" h o g e ")).toBe("hoge");
\r
517 expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e");
\r
519 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
520 it("should be this for the value (the invalid partion)", function() {
\r
521 expect( function() {
\r
524 expect( function() {
\r
530 describe("An offset method in $begin object", function() {
\r
531 beforeEach( function() {
\r
534 /*境界条件を調べておく (limit value analysis)*/
\r
535 it("should be this for the value (limit value analysis)", function() {
\r
536 expect(begin.offset(begin.trim(" "))).toBe(0);
\r
537 expect(begin.offset(begin.trim(" 0 "))).toBe(0);
\r
538 expect(begin.offset(begin.trim("+0ms"))).toBe(0);
\r
539 expect(begin.offset(begin.trim("-0ms"))).toBe(0);
\r
540 expect(begin.offset(begin.trim("1ms"))).toBe(1);
\r
541 expect(begin.offset(begin.trim("-1ms"))).toBe(-1);
\r
543 expect(begin.offset("+0s")).toBe(0);
\r
544 expect(begin.offset("-0s")).toBe(0);
\r
545 expect(begin.offset("1s")).toBe(1000);
\r
546 expect(begin.offset("-1s")).toBe(-1000);
\r
548 expect(begin.offset("+0min")).toBe(0);
\r
549 expect(begin.offset("-0min")).toBe(0);
\r
550 expect(begin.offset("1min")).toBe(60000);
\r
551 expect(begin.offset("-1min")).toBe(-60000);
\r
553 expect(begin.offset("+0h")).toBe(0);
\r
554 expect(begin.offset("-0h")).toBe(0);
\r
555 expect(begin.offset("1h")).toBe(60*60*1000);
\r
556 expect(begin.offset("-1h")).toBe(-3600000);
\r
558 expect(begin.offset("00:0")).toBe(0);
\r
559 expect(begin.offset("00:00:0.0")).toBe(0);
\r
560 expect(begin.offset("-00:0")).toBe(0);
\r
561 expect(begin.offset("-00:00:0.0")).toBe(0);
\r
562 expect(begin.offset("00:1")).toBe(1000);
\r
563 expect(begin.offset("-00:1")).toBe(-1000);
\r
564 expect(begin.offset("00:00:1")).toBe(1000);
\r
565 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
567 expect(begin.offset()).toBe(0);
\r
569 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
570 it("should be this for the value (the valid partion)", function() {
\r
571 expect(begin.offset(begin.trim(" + 0 ms"))).toBe(0);
\r
572 expect(begin.offset(begin.trim(" -1m s "))).toBe(-1);
\r
573 expect(begin.offset(begin.trim("1000ms"))).toBe(1000);
\r
574 expect(begin.offset(begin.trim(" -1212ms"))).toBe(-1212);
\r
576 expect(begin.offset("+100s")).toBe(100 * 1000);
\r
577 expect(begin.offset("-121s")).toBe(-121 * 1000);
\r
578 expect(begin.offset("1.25s")).toBe(1.25 * 1000);
\r
579 expect(begin.offset("-0.20s")).toBe(-0.20 * 1000);
\r
580 expect(begin.offset(".20s")).toBe(0.20 * 1000);
\r
582 expect(begin.offset("+100min")).toBe(100 * 60000);
\r
583 expect(begin.offset("-121min")).toBe(-121 * 60000);
\r
584 expect(begin.offset("1.25min")).toBe(1.25 * 60000);
\r
585 expect(begin.offset("-0.20min")).toBe(-0.20 * 60000);
\r
586 expect(begin.offset(".20min")).toBe(0.20 * 60000);
\r
588 expect(begin.offset("+100h")).toBe(100 * 3600000);
\r
589 expect(begin.offset("-121h")).toBe(-121 * 3600000);
\r
590 expect(begin.offset("1.25h")).toBe(1.25 * 3600000);
\r
591 expect(begin.offset("-0.20h")).toBe(-0.20 * 3600000);
\r
592 expect(begin.offset(".20h")).toBe(0.20 * 3600000);
\r
594 expect(begin.offset("01:0")).toBe(60000);
\r
595 expect(begin.offset("-01:0")).toBe(-60000);
\r
596 expect(begin.offset("00:00:1")).toBe(1000);
\r
597 expect(begin.offset("-00:00:1")).toBe(-1000);
\r
598 expect(begin.offset("00:01:0")).toBe(60000);
\r
599 expect(begin.offset("-00:01:0")).toBe(-60000);
\r
600 expect(begin.offset("01:00:0")).toBe(3600000);
\r
601 expect(begin.offset("-01:00:0")).toBe(-3600000);
\r
602 expect(begin.offset("00:10")).toBe(10000);
\r
603 expect(begin.offset("00:0.01")).toBe(10);
\r
604 expect(begin.offset("01:0.01")).toBe(60010);
\r
605 expect(begin.offset("10:0")).toBe(600000);
\r
606 expect(begin.offset("-00:10")).toBe(-10000);
\r
607 expect(begin.offset("-00:0.01")).toBe(-10);
\r
608 expect(begin.offset("-01:0.01")).toBe(-60010);
\r
609 expect(begin.offset("-10:0")).toBe(-600000);
\r
610 expect(begin.offset("00:00:20")).toBe(20000);
\r
611 expect(begin.offset("00:11:20")).toBe(11*60*1000 + 20000);
\r
612 expect(begin.offset("12:11:20")).toBe(12*60*60*1000 + 11*60*1000 + 20000);
\r
613 expect(begin.offset("-10:0")).toBe(-600000);
\r
614 expect(begin.offset("-01:01:0.1")).toBe(-1*60*60*1000 - 60000 - 100);
\r
616 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
617 it("should be this for the value (the invalid partion)", function() {
\r
618 expect(begin.offset(begin.trim(" h o g 1e "))).toBe(0);
\r
619 expect(begin.offset("ms")).toBe(0);
\r
620 expect(begin.offset(".s")).toBe(0);
\r
621 expect(begin.offset("10:")).toBe(0);
\r
622 expect(begin.offset("::")).toBe(0);
\r
623 expect(begin.offset("-:0")).toBe(0);
\r
624 expect(begin.offset("-::0")).toBe(0);
\r
627 describe("An event method in $begin object", function() {
\r
628 /*境界条件を調べておく (limit value analysis)*/
\r
629 it("should be this for the value (limit value analysis)", function() {
\r
630 var evt = begin.event();
\r
631 expect(evt.id).toBe("");
\r
632 expect(evt.event).toBe("");
\r
633 evt = begin.event("");
\r
634 expect(evt.id).toBe("");
\r
635 expect(evt.event).toBe("");
\r
636 evt = begin.event(".");
\r
637 expect(evt.id).toBe("");
\r
638 expect(evt.event).toBe("");
\r
640 evt = begin.event("a");
\r
641 expect(evt.id).toBe("");
\r
642 expect(evt.event).toBe("a");
\r
643 evt = begin.event("a.b");
\r
644 expect(evt.id).toBe("a");
\r
645 expect(evt.event).toBe("b");
\r
647 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
648 it("should be this for the value (the valid partion)", function() {
\r
649 var evt = begin.event("id.event");
\r
650 expect(evt.id).toBe("id");
\r
651 expect(evt.event).toBe("event");
\r
652 evt = begin.event("event");
\r
653 expect(evt.id).toBe("");
\r
654 expect(evt.event).toBe("event");
\r
656 evt = begin.event("event+0s");
\r
657 expect(evt.id).toBe("");
\r
658 expect(evt.event).toBe("event");
\r
659 evt = begin.event("event-0s");
\r
660 expect(evt.id).toBe("");
\r
661 expect(evt.event).toBe("event");
\r
663 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
664 it("should be this for the value (the invalid partion)", function() {
\r
665 evt = begin.event("...");
\r
666 expect(evt.id).toBe("");
\r
667 expect(evt.event).toBe("");
\r
668 evt = begin.event(".event");
\r
669 expect(evt.id).toBe("");
\r
670 expect(evt.event).toBe("");
\r
671 evt = begin.event("id.");
\r
672 expect(evt.id).toBe("");
\r
673 expect(evt.event).toBe("");
\r
677 describe("An parse method in $begin object", function() {
\r
678 beforeEach( function() {
\r
681 /*境界条件を調べておく (limit value analysis)*/
\r
682 it("should be this for the value (limit value analysis)", function() {
\r
683 expect(begin.parse().begin).toBe(0);
\r
684 expect(begin.isResolved).toBeTruthy();
\r
686 expect(begin.parse().begin).toBe(0);
\r
687 begin.string = "+1";
\r
688 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
689 begin.string = " ";
\r
690 expect(begin.parse().begin).toBe(0);
\r
691 begin.string = "1";
\r
692 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
693 begin.string = "+0ms";
\r
694 expect(begin.parse().begin).toBe(0);
\r
695 begin.string = "-0ms";
\r
696 expect(begin.parse().begin).toBe(0);
\r
697 begin.string = "-0ms;-0ms";
\r
698 expect(begin.parse().begin).toBe(0);
\r
699 begin.string = "-0ms;1";
\r
700 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
702 expect(begin.eventOffset).toBe(0);
\r
703 begin.string = "click";
\r
704 expect(begin.parse().begin).toBe(0);
\r
705 expect(begin.eventOffset).toBe(0);
\r
706 expect(begin.repeat).toBe(0);
\r
707 expect(begin.accessKey).toBe("");
\r
708 begin.string = "id.click";
\r
709 expect(begin.parse().begin).toBe(0);
\r
710 expect(begin.eventOffset).toBe(0);
\r
711 expect(begin.repeat).toBe(0);
\r
712 expect(begin.accessKey).toBe("");
\r
714 begin.string = "repeat";
\r
715 expect(begin.parse().begin).toBe(0);
\r
716 expect(begin.eventOffset).toBe(0);
\r
717 expect(begin.repeat).toBe(0);
\r
718 expect(begin.accessKey).toBe("");
\r
719 begin.string = "repeat(1)";
\r
720 expect(begin.parse().begin).toBe(0);
\r
721 expect(begin.eventOffset).toBe(0);
\r
722 expect(begin.repeat).toBe(1);
\r
723 expect(begin.accessKey).toBe("");
\r
725 begin.string = "accessKey(a)";
\r
726 expect(begin.parse().begin).toBe(0);
\r
727 expect(begin.eventOffset).toBe(0);
\r
728 expect(begin.repeat).toBe(0);
\r
729 expect(begin.accessKey).toBe("a");
\r
731 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
732 it("should be this for the value (the valid partion)", function() {
\r
733 begin.string = " 1 0 0 m s";
\r
734 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
736 begin.string = "1ms";
\r
737 begin.isResolved = false;
\r
738 expect(begin.parse().begin).toBe(Math.floor(1*begin.fpms));
\r
739 expect(begin.isResolved).toBeTruthy();
\r
740 expect(begin.eventOffset).toBe(0);
\r
742 begin.string="click+0";
\r
743 expect(begin.parse().begin).toBe(0);
\r
744 expect(begin.eventOffset).toBe(0);
\r
745 expect(begin.isResolved).toBeFalsy();
\r
746 begin.string = "click+1";
\r
747 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
748 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
749 begin.string = " click ";
\r
750 expect(begin.parse().begin).toBe(0);
\r
751 expect(begin.eventOffset).toBe(0);
\r
752 begin.string = "click+0ms";
\r
753 expect(begin.parse().begin).toBe(0);
\r
754 expect(begin.eventOffset).toBe(0);
\r
755 expect(begin.isResolved).toBeFalsy();
\r
756 begin.string = "click-0ms";
\r
757 expect(begin.parse().begin).toBe(0);
\r
758 expect(begin.eventOffset).toBe(0);
\r
759 begin.string = "click+100ms";
\r
760 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
761 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
762 begin.string = "click-100ms";
\r
763 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
764 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
766 begin.string="id.click+0";
\r
767 expect(begin.parse().begin).toBe(0);
\r
768 expect(begin.eventOffset).toBe(0);
\r
769 expect(begin.isResolved).toBeFalsy();
\r
770 begin.string = "id.click+1";
\r
771 expect(begin.parse().begin).toBe(1000*begin.fpms);
\r
772 expect(begin.eventOffset).toBe(1000*begin.fpms);
\r
773 expect(begin.isResolved).toBeFalsy();
\r
774 begin.string = " id . click ";
\r
775 expect(begin.parse().begin).toBe(0);
\r
776 expect(begin.eventOffset).toBe(0);
\r
777 expect(begin.isResolved).toBeFalsy();
\r
778 begin.string = "id.click+0ms";
\r
779 expect(begin.parse().begin).toBe(0);
\r
780 expect(begin.eventOffset).toBe(0);
\r
781 begin.string = "id.click-0ms";
\r
782 expect(begin.parse().begin).toBe(0);
\r
783 expect(begin.eventOffset).toBe(0);
\r
784 begin.string = "id.click+100ms";
\r
785 expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));
\r
786 expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));
\r
787 begin.string = "id.click-100ms";
\r
788 expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));
\r
789 expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));
\r
791 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
792 it("should be this for the value (the invalid partion)", function() {
\r
793 begin.string = "ms";
\r
794 begin.isResolved = false;
\r
795 expect(begin.parse().begin).toBe(0);
\r
796 expect(begin.isResolved).toBeFalsy();
\r
798 begin.isResolved = true;
\r
799 begin.string = "indefinite";
\r
800 expect(begin.parse().begin).toBe(Math.floor( Number.MAX_VALUE * begin.fpms));
\r
801 expect(begin.isResolved).toBeFalsy();
\r
805 describe("A listener method in $begin object", function() {
\r
806 var obj = begin.up();
\r
807 beforeEach( function() {
\r
810 begin.timelines.length = 0;
\r
811 obj.$activate = begin.$activate.up();
\r
812 obj.startTime = Date.now();
\r
815 /*境界条件を調べておく (limit value analysis)*/
\r
816 it("should be this for the value (limit value analysis)", function() {
\r
817 obj.isResolved = true;
\r
819 expect(obj.begin).toBe(0);
\r
822 timeStamp: Date.now()
\r
824 expect(obj.begin).toBe(0);
\r
825 expect(obj.activeTime).toBeGreaterThan(0);
\r
826 expect(obj.timelines.length).toBe(1);
\r
828 obj.isResolved = false;
\r
830 timeStamp: Date.now()
\r
832 expect(obj.begin).toBe(0);
\r
833 expect(obj.activeTime).toBeGreaterThan(0);
\r
834 expect(obj.timelines.length).toBe(1);
\r
836 obj.timelines.length = 0;
\r
841 $activate: begin.$activate.up().mix( {
\r
846 timeStamp: Date.now()
\r
848 expect(obj.$1.begin).toBe(1);
\r
849 expect(obj.$1.activeTime).toBe(Math.floor(12000*obj.fpms));
\r
850 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
851 expect(obj.timelines[0]).toBe(obj.$1);
\r
853 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
854 it("should be this for the value (the valid partion)", function() {
\r
858 $activate: begin.$activate.up().mix( {
\r
859 end: begin.$activate.end.up().mix( {
\r
865 timeStamp: Date.now()
\r
867 expect(obj.$1.begin).toBe(1);
\r
868 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
869 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
870 expect(obj.timelines[0]).toBe(obj.$1);
\r
875 $activate: begin.$activate.up().mix( {
\r
876 end: begin.$activate.end.up().mix( {
\r
882 timeStamp: Date.now()
\r
884 expect(obj.$1.begin).toBe(1);
\r
885 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
886 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
887 expect(obj.timelines[1]).toBe(obj.$1);
\r
889 timeStamp: (Date.now() + 500)
\r
891 expect(obj.$1.begin).toBe(1);
\r
892 expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);
\r
893 expect(obj.$1.$activate.begin).toBe(obj.$1.begin);
\r
894 expect(obj.timelines[1]).toBe(obj.$1);
\r
896 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
897 it("should be this for the value (the invalid partion)", function() {
\r
901 describe("A $end object", function() {
\r
902 var end = base("$frame").$begin.$end.up();
\r
904 beforeEach( function() {
\r
906 end.startTime = Date.now();
\r
909 /*境界条件を調べておく (limit value analysis)*/
\r
910 it("should be this for the value (limit value analysis)", function() {
\r
911 expect(end.up().call()).toBeNull();
\r
913 expect(end.up().call()).toBe(0);
\r
914 end.string = "hoge";
\r
915 expect(end.up().call()).toBe("indefinite");
\r
918 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
919 it("should be this for the value (the valid partion)", function() {
\r
920 end.string = "hoge+0";
\r
921 expect(end.up().call()).toBe("indefinite");
\r
922 end.string = "12ms";
\r
923 expect(end.up().call()).toBe(Math.floor(12*end.fpms));
\r
924 end.string = "hoge+12ms";
\r
925 expect(end.up().call()).toBe("indefinite");
\r
928 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
929 it("should be this for the value (the invalid partion)", function() {
\r
931 expect(end.up().call()).toBeNull();
\r
934 describe("A listener method in $end object", function() {
\r
936 begin = base("$frame").$begin;
\r
937 beforeEach( function() {
\r
940 end.timelines.length = 0;
\r
942 obj.$begin = begin.up().mix( {
\r
946 obj.$begin.$activate = begin.$activate.up();
\r
947 obj.addLine(obj.$begin);
\r
949 /*境界条件を調べておく (limit value analysis)*/
\r
950 it("should be this for the value (limit value analysis)", function() {
\r
951 expect(obj.timelines[0]).toBe(obj.$begin);
\r
952 expect(obj.timelines[0]).not.toBe(obj);
\r
954 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
956 obj.addLine(obj.$begin.mix( {
\r
961 timeStamp: (Date.now() + 12)
\r
963 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
965 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
966 it("should be this for the value (the valid partion)", function() {
\r
967 obj.$begin.$activate.begin = 0;
\r
972 timeStamp: (Date.now() + 120)
\r
974 expect(obj.timelines[0]).not.toBe(obj.$begin);
\r
975 expect(obj.begin).toBe(0);
\r
976 expect(obj.$begin.activeTime).toBe(0);
\r
978 obj.addLine(obj.$begin.mix( {
\r
982 obj.$begin.$activate.begin = 0;
\r
984 string: "event+1000ms"
\r
987 timeStamp: (Date.now() + 12)
\r
989 expect(obj.timelines[0]).toBe(obj.$begin);
\r
990 expect(obj.begin).toBe(Math.ceil(1000*obj.fpms));
\r
991 expect(obj.$begin.activeTime).toBe(Math.ceil(1000*obj.fpms));
\r
993 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
994 it("should be this for the value (the invalid partion)", function() {
\r
998 describe("A $activate object", function() {
\r
999 var act = base("$frame").$begin.$activate.up();
\r
1000 beforeEach( function() {
\r
1001 act.dur = "indefinite";
\r
1003 act.repeatCount = null;
\r
1004 act.repeatDur = null;
\r
1005 act.end = act.$begin.$end;
\r
1006 act.simpleDur = base("$frame").$begin.$activate.simpleDur;
\r
1008 /*境界条件を調べておく (limit value analysis)*/
\r
1009 it("should be this for the value (limit value analysis)", function() {
\r
1010 expect(act.dur).toBe("indefinite");
\r
1011 expect(typeof act.resolvedTime).toBe("function");
\r
1012 expect(act.end).toBe(act.$begin.$end);
\r
1013 expect(act.repeatCount).toBeNull();
\r
1014 expect(act.repeatDur).toBeNull();
\r
1015 expect(act.simpleDur()).toBeNull();
\r
1016 expect(act.min).toBe("0");
\r
1017 expect(act.max).toBe("indefinite");
\r
1020 expect(act.$a.call()).toBeNull();
\r
1021 expect(act.$a.end).toBeNull();
\r
1023 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1024 it("should be this for the value (the valid partion)", function() {
\r
1025 expect(act.resolvedTime()).not.toBe(0);
\r
1027 /*Activate Duration = dur*/
\r
1029 act.$b.dur = "132ms";
\r
1030 var abc = act.$b.call();
\r
1031 expect(abc).toBe(Math.floor(132*act.fpms));
\r
1032 expect(abc).toBe(act.$b.simpleDur);
\r
1034 expect(act.up().call()).toBeNull();
\r
1039 simpleDur: act.simpleDur,
1040 repeatCount: null,
\r
1043 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1044 expect(act.$c.call()).toBe(act.$c.simpleDur);
\r
1047 simpleDur: act.simpleDur,
1048 repeatCount: null,
\r
1051 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
1053 /*AD = repeatCount*dur*/
\r
1056 simpleDur: act.simpleDur,
1061 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1064 simpleDur: act.simpleDur,
1068 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1069 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1071 /*AD = repeatDur*/
\r
1073 dur: "indefinite",
\r
1074 simpleDur: act.simpleDur,
1079 expect(act.$c.simpleDur).toBeNull();
\r
1081 dur: "indefinite",
\r
1082 simpleDur: act.simpleDur,
1086 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1087 expect(act.$c.simpleDur).toBeNull();
\r
1090 simpleDur: act.simpleDur,
1091 repeatCount: null,
\r
1095 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1098 simpleDur: act.simpleDur,
1099 repeatCount: null,
\r
1102 expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));
\r
1103 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1105 /*AD = Min(repeatCount*d, repeatDur)*/
\r
1108 simpleDur: act.simpleDur,
1113 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1116 simpleDur: act.simpleDur,
1120 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1121 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1124 simpleDur: act.simpleDur,
1128 expect(act.$c.call()).toBe(Math.floor(9000*act.fpms));
\r
1129 expect(act.$c.simpleDur).toBe(Math.floor(11000*act.fpms));
\r
1131 /*AD = repeatDur,*/
\r
1135 simpleDur: act.simpleDur,
1136 repeatCount: null,
\r
1139 expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));
\r
1140 expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));
\r
1142 dur: "indefinite",
\r
1143 simpleDur: act.simpleDur,
1147 expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));
\r
1148 expect(act.$c.simpleDur).toBeNull();
\r
1150 act.end.string = null;
\r
1151 act.up("$cd").mix( {
\r
1156 expect(act.$cd.call()).toBe(Math.floor(10000*act.fpms) * 2);
\r
1158 act.$cd.end = act.end;
\r
1159 act.$cd.repeatCount = null;
\r
1160 act.$cd.repeatDur = "12";
\r
1161 expect(act.$cd.call()).toBe(Math.floor(12000*act.fpms));
\r
1163 act.up("$d").mix( {
\r
1167 simpleDur: act.simpleDur
\r
1169 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1170 act.up("$d").mix( {
\r
1174 simpleDur: act.simpleDur
\r
1176 expect(act.$d.call()).toBe(Math.floor(2000*act.fpms));
\r
1178 /*endで0が指定されている場合*/
\r
1181 act.repeatDur = null;
\r
1182 act.repeatCount = "indefinite";
\r
1184 expect(act.call()).toBeNull();
\r
1185 act.repeatCount = null;
\r
1186 act.repeatDur = "indefinite";
\r
1188 expect(act.call()).toBeNull();
\r
1189 act.repeatDur = "indefinite";
\r
1190 act.repeatCount = "indefinite";
\r
1192 expect(act.call()).toBeNull();
\r
1194 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1195 it("should be this for the value (the invalid partion)", function() {
\r
1197 act.up("$d").mix( {
\r
1201 simpleDur: act.simpleDur
\r
1203 expect(act.$d.call()).toBe(Math.floor(1000*act.fpms));
\r
1205 act.repeatDur = null;
\r
1206 act.repeatCount = "indefinite";
\r
1208 expect(act.call()).toBeNull();
\r
1209 act.repeatCount = null;
\r
1210 act.repeatDur = "indefinite";
\r
1212 expect(act.call()).toBeNull();
\r
1213 act.repeatDur = "indefinite";
\r
1214 act.repeatCount = "indefinite";
\r
1216 expect(act.call()).toBeNull();
\r
1219 describe("A $from object", function() {
\r
1220 var from = base("$from");
\r
1221 beforeEach( function() {
\r
1222 from = base("$from").up();
\r
1223 from.from = from.from.up();
\r
1226 /*境界条件を調べておく (limit value analysis)*/
\r
1227 it("should be this for the value (limit value analysis)", function() {
\r
1228 expect(from.string).toBe("");
\r
1229 expect(from.numList()).toEqual([]);
\r
1230 expect(from.strList()).toBeNull();
\r
1232 from.string = "0";
\r
1233 expect(from.numList()[0]).toBe(0);
\r
1234 expect(from.strList()).toBeNull();
\r
1236 from.string = " 0 ";
\r
1237 expect(from.numList()[0]).toBe(0);
\r
1238 expect(from.strList().join("")).toBe(" ");
\r
1240 from.string = "a";
\r
1241 expect(from.numList()).toEqual([]);
\r
1242 expect(from.strList()[0]).toBe("a");
\r
1244 /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから
\r
1245 * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/
\r
1247 from.string = null;
\r
1248 expect( function() {
\r
1251 expect( function() {
\r
1255 expect(from.additive[0]).toBe(0);
\r
1256 expect(from.accumulate[0]).toBe(0);
\r
1258 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1259 it("should be this for the value (the valid partion)", function() {
\r
1260 from.string = "0a";
\r
1261 expect(from.numList()[0]).toBe(0);
\r
1262 expect(from.strList()[0]).toBe("a");
\r
1264 from.string = "a0";
\r
1265 expect(from.numList()[0]).toBe(0);
\r
1266 expect(from.strList()[0]).toBe("a");
\r
1268 from.string = "0.1";
\r
1269 expect(from.numList()[0]).toBe(0.1);
\r
1270 expect(from.strList()).toBeNull();
\r
1272 from.string = "+0.1";
\r
1273 expect(from.numList()[0]).toBe(0.1);
\r
1274 expect(from.strList()).toBeNull();
\r
1276 from.string = "-0.1";
\r
1277 expect(from.numList()[0]).toBe(-0.1);
\r
1278 expect(from.strList()).toBeNull();
\r
1280 from.string = "1e-1";
\r
1281 expect(from.numList()[0]).toBe(1e-1);
\r
1282 expect(from.strList()).toBeNull();
\r
1284 from.string = "1E-1";
\r
1285 expect(from.numList()[0]).toBe(1E-1);
\r
1286 expect(from.strList()).toBeNull();
\r
1288 from.string = "0,0";
\r
1289 expect(from.numList().toString()).toBe("0,0");
\r
1290 expect(from.strList().join("")).toBe(",");
\r
1292 from.string = "a00a";
\r
1293 expect(from.numList()[0]).toBe(0);
\r
1294 expect(from.strList().join("")).toBe("aa");
\r
1296 from.string = "a0b0a";
\r
1297 expect(from.numList().toString()).toBe("0,0");
\r
1298 expect(from.strList().join("")).toBe("aba");
\r
1300 from.string = "0b0a";
\r
1301 expect(from.numList().toString()).toBe("0,0");
\r
1302 expect(from.strList().join("")).toBe("ba");
\r
1304 from.string = "0b-1.0a";
\r
1305 expect(from.numList()[1]).toBe(-1);
\r
1306 expect(from.strList().join("")).toBe("ba");
\r
1308 expect(from.up().call()).toBe(from.$1.numList);
\r
1309 expect(from.$1.numList[1]).toBe(-1);
\r
1310 expect(from.$1.strList.join("")).toBe("ba");
\r
1312 from.string = "あ 0b-1.0a12";
\r
1313 expect(from.numList()[1]).toBe(-1);
\r
1314 expect(from.strList().join("")).toBe("あ ba12");
\r
1316 from.string = "0b-1.0a0";
\r
1317 expect(from.numList().join(",")).toBe("0,-1,0");
\r
1318 expect(from.strList().join("")).toBe("ba");
\r
1320 from.string = "0b .1a";
\r
1321 expect(from.numList()[1]).toBe(0.1);
\r
1322 expect(from.strList().join("")).toBe("b a");
\r
1324 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1325 it("should be this for the value (the invalid partion)", function() {
\r
1326 from.string = NaN;
\r
1327 expect(function(){
\r
1330 expect(function(){
\r
1334 from.string = "currentColor";
\r
1335 expect(from.numList()).toEqual([]);
\r
1336 expect(from.strList()[0]).toBe("currentColor");
\r
1338 from.string = "eE";
\r
1339 expect(from.numList()).toEqual([]);
\r
1340 expect(from.strList()[0]).toBe("eE");
\r
1341 expect(from.strList()[0]).toBe("eE");
\r
1344 describe("A $to object", function() {
\r
1345 var from = base("$from");
\r
1346 beforeEach( function() {
\r
1347 from = base("$from").up();
\r
1351 /*境界条件を調べておく (limit value analysis)*/
\r
1352 it("should be this for the value (limit value analysis)", function() {
\r
1353 expect(from.$to instanceof from.constructor).toBeTruthy();
\r
1354 expect(from.up().call()).toBe(from.$1.numList);
\r
1355 expect(from.$to.up().call()).toBe(from.$to.$1.numList);
\r
1357 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1358 it("should be this for the value (the valid partion)", function() {
\r
1360 from.$to.from = from;
\r
1361 from.$to.string = "12cm-7";
\r
1362 expect(from.$to.numList().join(",")).toBe("12,-7");
\r
1363 expect(from.$to.strList().toString()).toBe("cm");
\r
1365 from.string = "7cm+8";
\r
1367 expect(from.call()).toBe(from.numList);
\r
1368 expect(from.$to.numList.join(",")).toBe("12,-7");
\r
1369 expect(from.$to.strList.join("")).toBe("cm");
\r
1370 expect(from.numList.join(",")).toBe("7,8");
\r
1371 expect(from.strList.join("")).toBe("cm");
\r
1372 expect(from.$to.from).toBe(from.numList);
\r
1375 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1376 it("should be this for the value (the invalid partion)", function() {
\r
1378 from.up("$to").mix( function() {
\r
1379 this.string = "12cm";
\r
1382 arr.string = this.string;
\r
1383 expect(this.numList).toEqual(arr);
\r
1384 expect(this.strList).toBeNull();
\r
1388 describe("An advance method", function() {
\r
1389 var from = base("$from");
\r
1390 beforeEach( function() {
\r
1391 from = base("$from").up();
\r
1394 from.$to.from = from;
\r
1396 /*境界条件を調べておく (limit value analysis)*/
\r
1397 it("should be this for the value (limit value analysis)", function() {
\r
1398 expect(from.advance()).toBe("");
\r
1399 expect(from.$to.advance()).toBe("");
\r
1400 expect(from.$to.advance(0)).toBe("");
\r
1401 expect(from.$to.advance(1)).toBe("");
\r
1402 expect(function(){
\r
1403 from.$to.advance(1.01);
\r
1404 }).toThrow("An Invalid Number Error");
\r
1405 expect(function(){
\r
1406 from.$to.advance(-0.01);
\r
1407 }).toThrow("An Invalid Number Error");
\r
1411 from = base("$from").up();
\r
1413 from.$to.from = from;
\r
1414 arr.string = from.string = "0";
\r
1415 from.$to.string = "1";
\r
1416 expect(from.$to.call()).toBe(from.$to.numList);
\r
1417 expect(from.$to.numList[0]).toBe(1);
\r
1418 expect(from.$to.strList).toBeNull();
\r
1419 expect(from.numList[0]).toBe(0);
\r
1420 expect(from.strList).toBeNull();
\r
1421 expect(from.advance(0)).toBe("");
\r
1422 expect(from.$to.from).toBe(from.numList);
\r
1423 expect(from.$to.advance(0)).toBe("0");
\r
1424 expect(from.call()).toBe(from.numList);
\r
1426 from = base("$from").up();
\r
1427 f(from.up(), "inline", "block");
\r
1428 f(from.up(), " inline", " block ");
\r
1429 function f(from, inline, block) {
\r
1431 from.$to.from = from;
\r
1432 from.string = inline;
\r
1433 arr.string = from.$to.string = block;
\r
1434 expect(from.$to.call()).toBe(from.$to.numList);
\r
1435 expect(from.$to.numList).toEqual(arr);
\r
1436 expect(from.$to.strList).toEqual([block]);
\r
1437 arr.string = from.string;
\r
1438 expect(from.numList).toEqual(arr);
\r
1439 expect(from.strList).toEqual([inline]);
\r
1440 expect(from.advance(0)).toBe("");
\r
1441 expect(from.$to.from).toBe(from.numList);
\r
1442 expect(from.$to.advance(0)).toBe("inline");
\r
1443 expect(from.$to.advance(1)).toBe("block");
\r
1444 expect(from.call()).toBe(from.numList);
\r
1447 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1448 it("should be this for the value (the valid partion)", function() {
\r
1451 from.string = "0s";
\r
1452 from.$to.string = "1s";
\r
1453 expect(from.$to.call()).toBe(from.$to.numList);
\r
1454 expect(from.$to.numList[0]).toBe(1);
\r
1455 expect(from.$to.strList[0]).toBe("");
\r
1456 expect(from.numList[0]).toBe(0);
\r
1457 expect(from.strList[0]).toBe("");
\r
1458 expect(from.advance(0)).toBe("");
\r
1459 expect(from.$to.from).toBe(from.numList);
\r
1460 expect(from.$to.advance(0)).toBe("0s");
\r
1461 from.$to.degit = deg;
\r
1462 for (var i=0;i<1;i+=0.01) {
\r
1463 expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");
\r
1465 expect(from.call()).toBe(from.numList);
\r
1467 from = base("$from").up();
\r
1469 from.string = "a0S";
\r
1470 from.$to.string = "a1S";
\r
1471 from.$to.from = from;
\r
1472 expect(from.$to.call()).toBe(from.$to.numList);
\r
1473 expect(from.$to.numList[0]).toBe(1);
\r
1474 expect(from.$to.strList[0]).toBe("a");
\r
1475 expect(from.numList[0]).toBe(0);
\r
1476 expect(from.strList[0]).toBe("a");
\r
1477 expect(from.advance(0)).toBe("");
\r
1478 expect(from.$to.from).toBe(from.numList);
\r
1479 expect(from.$to.advance(0)).toBe("a0S");
\r
1481 from.$to.degit = deg;
\r
1482 for (var i=0;i<1;i+=0.01) {
\r
1483 expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");
\r
1485 expect(from.call()).toBe(from.numList);
\r
1487 from = base("$from").up();
\r
1488 f(from.up(), "a-10s1.5", "a10s-3");
\r
1489 f(from.up(), " a-10s1.5", " a10s-3 ");
\r
1490 function f(from, fromString, toString) {
\r
1492 from.string = fromString;
\r
1493 from.$to.string = toString;
\r
1494 from.$to.from = from;
\r
1496 from.$to.degit = 1;
\r
1497 expect(from.$to.advance(0)).toBe("a-10.0s1.5");
\r
1498 expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");
\r
1499 expect(from.$to.advance(1)).toBe("a10.0s-3.0");
\r
1501 from.$to.additive[0] = 1;
\r
1502 from.$to.accumulate[1] = 2;
\r
1503 expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");
\r
1504 from.$to.additive[0] = 0.5;
\r
1505 from.$to.accumulate[1] = 0.8;
\r
1506 expect(from.$to.advance(1)).toBe("a10.5s-2.2");
\r
1509 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1510 it("should be this for the value (the invalid partion)", function() {
\r
1511 expect(function(){
\r
1512 from.$to.advance(10);
\r
1513 }).toThrow("An Invalid Number Error");
\r
1514 expect(function(){
\r
1515 from.$to.advance(-10);
\r
1516 }).toThrow("An Invalid Number Error");
\r
1520 describe("A distance method", function() {
\r
1521 var from = base("$from");
\r
1522 beforeEach( function() {
\r
1523 from = base("$from").up();
\r
1527 /*境界条件を調べておく (limit value analysis)*/
\r
1528 it("should be this for the value (limit value analysis)", function() {
\r
1529 expect(from.distance()).toBe(0)
\r
1530 expect(from.$to.distance()).toBe(0);
\r
1532 from.string = "0";
\r
1533 from.$to.string = "1";
\r
1534 expect(from.distance()).toBe(0);
\r
1535 expect(from.$to.distance(from)).toBe(1);
\r
1537 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1538 it("should be this for the value (the valid partion)", function() {
\r
1539 from.string = "s 0 s 12";
\r
1540 from.$to.string = "s 0 s 0";
\r
1541 expect(from.distance()).toBe(0);
\r
1542 expect(from.$to.distance(from)).toBe(12);
\r
1543 expect(from.$to.distance(from)).toBe(12);
\r
1544 expect(from.$to.distance(from.call())).toBe(12);
\r
1546 from = base("$from").up();
\r
1548 from.string = "rgb(1, 0, 0)";
\r
1549 from.$to.string = "rgb(0, 0, 1)";
\r
1550 expect(from.distance()).toBe(0);
\r
1551 expect(from.$to.distance(from)).toBe(Math.sqrt(2));
\r
1553 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1554 it("should be this for the value (the invalid partion)", function() {
\r
1555 from.string = "s";
\r
1556 from.$to.string = "s";
\r
1557 expect(from.$to.distance(from)).toBe(0);
\r
1560 describe("A setAdditive method", function() {
\r
1561 var from = base("$from");
\r
1562 beforeEach( function() {
\r
1563 from = base("$from").up();
\r
1567 /*境界条件を調べておく (limit value analysis)*/
\r
1568 it("should be this for the value (limit value analysis)", function() {
\r
1569 expect(from.setAdditive()).toBe(0);
\r
1570 expect(from.setAdditive("")).toBe(0);
\r
1571 expect(from.additive).toEqual([0]);
\r
1574 expect(from.setAdditive("1")).toEqual(arr);
\r
1575 expect(from.additive).toEqual(arr);
\r
1577 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1578 it("should be this for the value (the valid partion)", function() {
\r
1579 var arr = [1, 2, 3];
\r
1580 arr.string = "1 2, 3";
\r
1581 expect(from.setAdditive("1 2, 3")).toEqual(arr);
\r
1582 expect(from.additive).toEqual(arr);
\r
1584 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1585 it("should be this for the value (the invalid partion)", function() {
\r
1588 describe("A setAccumulate method", function() {
\r
1589 var from = base("$from");
\r
1590 beforeEach( function() {
\r
1591 from = base("$from").up();
\r
1592 from.string = "0 1";
\r
1596 /*境界条件を調べておく (limit value analysis)*/
\r
1597 it("should be this for the value (limit value analysis)", function() {
\r
1598 expect(from.setAccumulate()).toBe(0);
\r
1599 expect(from.setAccumulate(0)).toBe(0);
\r
1600 expect(from.accumulate).toEqual([0, 0]);
\r
1601 expect(from.setAccumulate(1)).toEqual([0, 1]);
\r
1602 expect(from.accumulate).toEqual([0, 1]);
\r
1604 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1605 it("should be this for the value (the valid partion)", function() {
\r
1606 expect(from.setAccumulate(2)).toEqual([0, 2]);
\r
1607 expect(from.accumulate).toEqual([0, 2]);
\r
1609 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1610 it("should be this for the value (the invalid partion)", function() {
\r
1611 expect(from.setAccumulate(NaN)).toEqual(0);
\r
1614 describe("A $calcMode object", function() {
\r
1615 var calc = base("$calcMode"),
\r
1618 beforeEach( function() {
\r
1619 calc = base("$calcMode").up();
\r
1620 calc.to = base("$from").up().mix( {string: "1"} );
\r
1621 from = calc.to.from = base("$from").up().mix( {string: "0"} );
\r
1623 /*境界条件を調べておく (limit value analysis)*/
\r
1624 it("should be this for the value (limit value analysis)", function() {
\r
1625 expect(calc.mode).toBe("linear");
\r
1626 expect(calc.keyTime).toBe(1);
\r
1627 expect(calc.keySplines).toBeNull();
\r
1628 expect(calc.string).toBe("");
\r
1630 expect(calc.call()(0)).toBe("0");
\r
1631 expect(calc.keyTime).toBe(1);
\r
1632 expect(calc.call()(1)).toBe("1");
\r
1635 expect(calc.call()(1)).toBe("0");
\r
1638 calc.mode = "paced";
\r
1639 expect(calc.norm).toBe(1);
\r
1640 calc.to.from = from;
\r
1641 expect(calc.call()(0)).toBe("0");
\r
1642 expect(calc.keyTime).toBe(1);
\r
1643 calc.to.from = from;
\r
1644 expect(calc.call()(1)).toBe("1");
\r
1647 calc.to.from = from;
\r
1648 expect(calc.call()(1)).toBe("1");
\r
1651 calc.mode = "discrete";
\r
1652 calc.to.from = from;
\r
1654 expect(calc.call()(0)).toBe("0");
\r
1655 expect(calc.call()(1)).toBe("1");
\r
1657 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1658 it("should be this for the value (the valid partion)", function() {
\r
1659 calc.mode = "linear";
\r
1660 calc.keyTime = 0.5;
\r
1661 calc.to.degit = 1;
\r
1662 expect(calc.call()(0.2)).toBe("0.4");
\r
1663 expect(calc.call()(0.3)).toBe("0.6");
\r
1665 expect(calc.call()(0.2)).toBe("0.4");
\r
1667 calc = base("$calcMode").up();
\r
1668 calc.keyTime = 0.2;
\r
1669 calc.to = base("$from").up();
\r
1670 calc.to.from = base("$from").up();
\r
1671 calc.to.from.string = "0s";
\r
1672 calc.to.string = "1s";
\r
1673 calc.to.degit = 1;
\r
1674 expect(calc.call()(0.1)).toBe("0.5s");
\r
1676 calc = base("$calcMode").up();
\r
1677 calc.keyTime = 0.5;
\r
1678 calc.to = base("$from").up();
\r
1679 calc.to.from = base("$from").up();
\r
1680 calc.to.from.string = "rgb(100, 20, 32)";
\r
1681 calc.to.string = "rgb(0, 10, 50)";
\r
1682 expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");
\r
1685 calc.to = base("$from").up();
\r
1686 calc.to.from = base("$from").up();
\r
1687 calc.mode = "paced";
\r
1689 calc.to.from.string = "0s";
\r
1690 calc.to.string = "20s";
\r
1691 calc.to.degit = 1;
\r
1692 expect(calc.call()(0.1)).toBe("10.0s");
\r
1693 expect(calc.keyTime).toBe(0.2);
\r
1695 calc.to = base("$from").up();
\r
1696 calc.to.from = base("$from").up();
\r
1697 calc.mode = "paced";
\r
1699 calc.to.from.string = "rgb(0, 0, 20)";
\r
1700 calc.to.string = "rgb(0, 0, 0)";
\r
1701 expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");
\r
1702 expect(calc.keyTime).toBe(0.2);
\r
1705 calc.to = base("$from").up();
\r
1706 calc.to.from = base("$from").up();
\r
1707 calc.mode = "discrete";
\r
1708 calc.keyTime = 0.5;
\r
1709 calc.to.degit = 1;
\r
1710 calc.to.string = "1";
\r
1711 calc.to.from.string = "0.5";
\r
1712 expect(calc.call()(0.2)).toBe("0.5");
\r
1713 expect(calc.call()(0.3)).toBe("0.5");
\r
1715 expect(calc.call()(0.2)).toBe("0.5");
\r
1717 calc.to = base("$from").up();
\r
1718 calc.to.from = base("$from").up();
\r
1719 calc.mode = "discrete";
\r
1720 calc.keyTime = 0.5;
\r
1721 calc.to.degit = 1;
\r
1722 calc.to.string = "block";
\r
1723 calc.to.from.string = "inline";
\r
1724 expect(calc.call()(0.2)).toBe("inline");
\r
1725 expect(calc.call()(0.3)).toBe("inline");
\r
1727 calc.to = base("$from").up();
\r
1728 calc.to.from = base("$from").up();
\r
1729 calc.mode = "linear";
\r
1731 calc.to.degit = 1;
\r
1732 calc.to.string = "1 1";
\r
1733 calc.to.from.string = "0.0 1";
\r
1734 expect(calc.call()(0.2)).toBe("0.2 1.0");
\r
1735 expect(calc.call()(0.3)).toBe("0.3 1.0");
\r
1737 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1738 it("should be this for the value (the invalid partion)", function() {
\r
1739 calc.keyTime = null;
\r
1740 expect(calc.call()(1)).toBe(calc.string);
\r
1742 calc.keyTime = void 0;
\r
1743 expect(calc.call()(1)).toBe(calc.string);
\r
1745 calc.keyTime = 1/0;
\r
1746 expect(calc.call()(1)).toBe(calc.string);
\r
1748 expect(calc.call()()).toBe(calc.string);
\r
1750 calc = base("$calcMode").up();
\r
1751 calc.mode = "paced";
\r
1752 calc.to.from = from;
\r
1753 expect(calc.call()()).toBe(calc.string);
\r
1755 calc = base("$calcMode").up();
\r
1756 calc.mode = "discrete";
\r
1757 expect(calc.call()()).toBe(calc.string);
\r
1760 /*splineモードの境界条件を調べておく (limit value analysis)*/
\r
1761 it("should be this for the value (spline mode limit value analysis)", function() {
\r
1762 /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/
\r
1765 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1766 return function (t) {
\r
1767 x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;
\r
1768 y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;
\r
1772 expect(calc.keySplines).toBeNull();
\r
1773 calc.mode = "spline";
\r
1774 expect( calc.call()("undef")).toBe(Math.PI);
\r
1775 calc.keySplines = [0, 0, 1, 1];
\r
1776 calc.to.degit = 1;
\r
1777 calc.to.from = from;
\r
1778 expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");
\r
1779 calc.to.from = from;
\r
1780 expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");
\r
1781 calc.to.from = from;
\r
1782 expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");
\r
1784 df(0,0, 0,0, 1,1, 1,1, 0.1);
\r
1785 df(0,0, 0,0, 1,1, 1,1, 0.5);
\r
1786 df(0,0, 0,0, 1,1, 1,1, 0.8);
\r
1787 df(0,0, 0,0, 1,1, 1,1, 0.9);
\r
1788 df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);
\r
1789 df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);
\r
1790 df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);
\r
1791 df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);
\r
1792 function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {
\r
1794 var a = y4-3*(y3-y2)-y1,
\r
1795 b = 3*(y3-2*y2+y1),
\r
1797 d = y1 - bezier.apply(null, arguments)(t);
\r
1798 expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);
\r
1801 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1802 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
1805 bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {
\r
1806 return function (t) {
\r
1808 x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,
\r
1809 y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1
\r
1813 calc.mode = "spline";
\r
1814 calc.keySplines = [0, 0.5, 0.5, 1];
\r
1815 calc.to.degit = 1;
\r
1816 var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);
\r
1817 expect(calc.call()(0)).toBe(b(0).y+".0");
\r
1818 calc.to.from = from;
\r
1819 expect(calc.call()(1)).toBe(b(1).y+".0");
\r
1820 calc.to.from = from;
\r
1821 expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));
\r
1823 var ff = function(k) {
\r
1824 calc.keySplines = k;
\r
1825 calc.to.degit = 10;
\r
1826 var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),
\r
1827 epsilon = 1e-5; //誤差
\r
1828 expect(calc.call()(0)).toBe(b(0).y.toFixed(10));
\r
1829 calc.to.from = from;
\r
1830 expect(calc.call()(1)).toBe(b(1).y.toFixed(10));
\r
1831 calc.to.from = from;
\r
1832 b = b(Math.random());
\r
1833 expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);
\r
1835 for (var i=0;i<10000;++i) {
\r
1836 var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});
\r
1840 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
1841 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
1842 calc.mode = "spline";
\r
1843 calc.keySplines = [0, NaN, 1, 1];
\r
1844 calc.to.degit = 1;
\r
1845 calc.to.from = from;
\r
1846 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1849 calc.keySplines = [0, 0, 1, 2];
\r
1850 calc.to.degit = 1;
\r
1851 calc.to.from = from;
\r
1852 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1854 calc.keySplines = null;
\r
1855 calc.to.degit = 1;
\r
1856 calc.to.from = from;
\r
1857 expect( calc.up().call()("undef")).toBe(Math.PI);
\r
1860 describe("A $attribute object", function() {
\r
1861 describe("A push method", function() {
\r
1863 beforeEach( function() {
\r
1864 attr = base("$calcMode").$attribute.up("width");
\r
1865 base("$frame").timelines.length = 0;
\r
1866 s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");
\r
1868 afterEach( function() {
\r
1869 attr.isCSS = false;
\r
1871 /*境界条件を調べておく (limit value analysis)*/
\r
1872 it("should be this for the value (limit value analysis)", function() {
\r
1873 expect(attr.element).toBeNull();
\r
1874 expect(attr.push()).toBeNull();
\r
1875 expect(attr.element).toBeNull();
\r
1876 expect(attr.isCSS).toBeFalsy();
\r
1877 expect(base("$frame").timelines.length).toBe(0);
\r
1879 expect(attr.push(s)).toBeNull();
\r
1880 expect(attr.element).toBeNull();
\r
1881 expect(base("$frame").timelines.length).toBe(0);
\r
1882 expect(attr.hasAttrValues()).toBeFalsy();
\r
1884 var p = document.createElement("g");
\r
1886 expect(attr.push(s)).toBeNull();
\r
1887 expect(attr.element).toBe(p);
\r
1888 expect(base("$frame").timelines.length).toBe(0);
\r
1890 s.setAttribute("end", "0");
\r
1894 check("values", 4);
\r
1895 function check(attrName, num) {
\r
1896 s.setAttribute(attrName, "1");
\r
1897 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1898 var l = attr.push(s);
\r
1899 expect(attr.element).toBe(p);
\r
1900 var timelines = base("$frame").timelines;
\r
1901 expect(timelines.length).toBe(num);
\r
1902 var line = timelines[num-1];
\r
1903 expect(line.string).toBe("0");
\r
1904 expect(line).toBe(l); //タイムラインのオブジェクトを返す
\r
1905 var act = line.$activate;
\r
1906 expect(act.dur).toBeNull();
\r
1907 expect(act.end).toBe(0);
\r
1908 expect(act.repeatCount).toBeNull();
\r
1909 expect(act.repeatDur).toBeNull();
\r
1910 expect(act.min).toBe("0");
\r
1911 expect(act.max).toBe("indefinite");
\r
1912 expect(act.simpleDur).toBeNull();
\r
1913 expect(attr.hasAttrValues()).toBeTruthy();
\r
1915 s.removeAttribute(attrName);
\r
1916 expect(s.hasAttributeNS(null, attrName)).toBeFalsy();
\r
1918 expect(attr.element).toBe(p);
\r
1919 expect(timelines.length).toBe(num);
\r
1922 /*targetElement属性のサポート*/
\r
1923 var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1924 document.documentElement.appendChild(p2);
\r
1925 p2.setAttributeNS(null, "id", "p23");
\r
1926 s.setAttributeNS(null, "targetElement", "p23");
\r
1928 expect(attr.element).toBe(p2);
\r
1931 var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");
\r
1932 document.documentElement.appendChild(p3);
\r
1933 p3.setAttributeNS(null, "id", "p34");
\r
1934 s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");
\r
1936 expect(attr.element).toBe(p3);
\r
1938 /*attributeType属性のサポート*/
\r
1939 s.setAttributeNS(null, "attributeType", "CSS");
\r
1940 s.setAttributeNS(null, "values", "a;b;c");
\r
1942 expect(attr.isCSS).toBeTruthy();
\r
1944 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
1945 it("should be this for the value (the valid partion )", function() {
\r
1946 s.setAttribute("from", "1");
\r
1947 var p = document.createElement("g");
\r
1949 var values = [ "0",
\r
1950 "0", null, null, null,
\r
1951 "0", "indefinite", null
\r
1954 check2("dur", "0");
\r
1955 check2("begin", "0");
\r
1957 check2("begin", "1");
\r
1959 check2("end", "0");
\r
1961 check2("repeatCount", "0");
\r
1963 check2("repeatDur", "0");
\r
1965 check2("min", "0");
\r
1967 check2("max", "0");
\r
1969 check2("begin", "12");
\r
1970 values[7] = 1000 * base("$frame").fpms;
\r
1972 check2("dur", "1");
\r
1973 function check2(attrName, value) {
\r
1974 s.setAttribute(attrName, value);
\r
1975 expect(s.hasAttributeNS(null, attrName)).toBeTruthy();
\r
1977 expect(attr.element).toBe(p);
\r
1978 var timelines = base("$frame").timelines;
\r
1979 var line = timelines[timelines.length-1];
\r
1980 expect(line.string).toBe(values[0]);
\r
1981 var act = line.$activate;
\r
1982 expect(act.dur).toBe(values[1]);
\r
1983 expect(act.end).toBe(values[2]);
\r
1984 expect(act.repeatCount).toBe(values[3]);
\r
1985 expect(act.repeatDur).toBe(values[4]);
\r
1986 expect(act.min).toBe(values[5]);
\r
1987 expect(act.max).toBe(values[6]);
\r
1988 expect(act.simpleDur).toBe(values[7]);
\r
1992 var p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
1993 document.documentElement.appendChild(p4);
\r
1994 p4.appendChild(s);
\r
1995 p4.setAttributeNS(null, "style", "display: none");
\r
1997 expect(attr.setAttribute()).toBeUndefined();
\r
1998 expect(attr.setAttribute("block")).toBeUndefined();
\r
1999 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
2000 expect(attr.isCSS).toBeFalsy();
\r
2002 s.setAttributeNS(null, "attributeName", "display");
\r
2004 expect(attr.setAttribute("block")).toBeUndefined();
\r
2005 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
2006 expect(attr.isCSS).toBeTruthy();
\r
2007 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
2009 p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2010 document.documentElement.appendChild(p4);
\r
2011 p4.appendChild(s);
\r
2012 p4.setAttributeNS(null, "style", "display: none");
\r
2014 expect(attr.setAttribute("block")).toBeUndefined();
\r
2015 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
2016 expect(p4.style.getPropertyValue("display")).toBe("block");
\r
2017 expect(attr.removeAttribute()).toBeUndefined();
\r
2018 expect(p4.hasAttributeNS(null, "display")).toBeFalsy();
\r
2019 expect(p4.style.getPropertyValue("display")).toBe("none");
\r
2021 /*attributeType属性のサポート*/
\r
2022 s.setAttributeNS(null, "values", "a;b;c");
\r
2023 s.setAttributeNS(null, "attributeName", "display");
\r
2024 attr.isCSS = false;
\r
2026 expect(attr.isCSS).toBeTruthy();
\r
2028 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2029 it("should be this for the value (the invalid partion )", function() {
\r
2030 var p = document.createElement("g");
\r
2033 s.setAttributeNS(null, "begin", "1");
\r
2035 var timelines = base("$frame").timelines;
\r
2036 expect(timelines.length).toBe(0);
\r
2037 s.setAttributeNS(null, "from", "0");
\r
2039 expect(timelines.length).toBe(1);
\r
2040 expect(attr.push(12)).toBeNull();
\r
2043 describe("A setValues method", function() {
\r
2045 beforeEach( function() {
\r
2046 attr = base("$calcMode").$attribute.up("width");
\r
2047 base("$frame").timelines.length = 0;
\r
2048 s = document.createElement("animate");
\r
2050 /*境界条件を調べておく (limit value analysis)*/
\r
2051 it("should be this for the value (limit value analysis)", function() {
\r
2052 expect(attr.$from).not.toBeUndefined();
\r
2053 expect(attr.setValues()).toBeNull();
\r
2054 expect(attr.setValues("")).toBeNull();
\r
2056 expect(attr.setValues("0;1")[0].to.string).toBe("1");
\r
2057 expect(attr.setValues("0;1")[0].to.from.string).toBe("0");
\r
2058 expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");
\r
2059 expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0");
\r
2061 /*from-to アニメーション*/
\r
2062 expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");
\r
2063 expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");
\r
2065 /*from-by アニメーション*/
\r
2066 expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");
\r
2067 expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toBe(1);
\r
2068 expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toBe(2);
\r
2070 /*fromなしto アニメーション*/
\r
2071 expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");
\r
2072 expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");
\r
2073 var aset = attr.setValues(null, null, "1")[0].to;
\r
2075 expect(aset.from[0]).toBe(0);
\r
2077 /*fromなしby アニメーション*/
\r
2078 expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");
\r
2079 expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toBe(0);
\r
2080 var aset = attr.setValues(null, null, null, "1")[0].to;
\r
2082 expect(aset.from[0]).toBe(0);
\r
2084 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2085 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2086 attr.$from.degit = 1;
\r
2087 var setv = attr.setValues("0;1")[0].call();
\r
2088 expect(setv(0.5)).toBe("0.5");
\r
2089 expect(setv(1)).toBe("1.0");
\r
2091 setv = attr.setValues(" 0;1; 2 ")[0].call();
\r
2092 expect(setv(0.5)).toBe("0.5");
\r
2093 expect(setv(1)).toBe("1.0");
\r
2094 setv = attr.setValues("0;1;2")[1].call();
\r
2095 expect(setv(0.4)).toBe("1.4");
\r
2096 expect(setv(1)).toBe("2.0");
\r
2098 attr.$from.degit = 2;
\r
2099 setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();
\r
2100 expect(setv(0.5)).toBe("8.05");
\r
2101 expect(setv(1)).toBe("15.10");
\r
2103 var v = attr.setValues("1;1;2;1;1;15.1");
\r
2104 setv = v[4].mix( {
\r
2107 expect(setv(0.05)).toBe("8.05");
\r
2108 expect(setv(0.1)).toBe("15.10");
\r
2109 setv = v[3].mix( {
\r
2112 expect(setv(0.01)).toBe("1.00");
\r
2113 expect(setv(0.1)).toBe("1.00");
\r
2114 setv = v[2].mix( {
\r
2117 expect(setv(0.25)).toBe("1.50");
\r
2118 expect(setv(0.5)).toBe("1.00");
\r
2120 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2121 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2122 attr.$from.degit = 1;
\r
2123 expect(attr.setValues("")).toBeNull();
\r
2124 expect(attr.setValues(null, null, null, null)).toBeNull();
\r
2127 describe("A setKey method", function() {
\r
2129 beforeEach( function() {
\r
2130 attr = base("$calcMode").$attribute.up("width");
\r
2131 base("$frame").timelines.length = 0;
\r
2132 s = document.createElement("animate");
\r
2133 document.createElement("g").appendChild(s);
\r
2135 /*境界条件を調べておく (limit value analysis)*/
\r
2136 it("should be this for the value (limit value analysis)", function() {
\r
2137 expect(attr.setKey(s)).toBeNull();
\r
2139 s.setAttributeNS(null, "from", "0");
\r
2141 s.setAttributeNS(null, "to", "0");
\r
2142 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2143 expect(attr.setKey(s)[0].to.string).toBe("0");
\r
2144 s.setAttributeNS(null, "by", "0");
\r
2146 s.setAttributeNS(null, "values", "0;2");
\r
2147 expect(attr.setKey(s)[0].to.from.string).toBe("0");
\r
2148 expect(attr.setKey(s)[0].to.string).toBe("2");
\r
2150 s.setAttributeNS(null, "keyTimes", "0;0.1");
\r
2151 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2153 s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");
\r
2154 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2155 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2156 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2157 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2159 s.setAttributeNS(null, "keySplines", "0 0.1 0.3 0.4");
\r
2160 expect(attr.setKey(s)[0].keySplines[0]).toBe(0);
\r
2161 expect(attr.setKey(s)[0].keySplines[1]).toBe(0.1);
\r
2162 expect(attr.setKey(s)[0].keySplines[2]).toBe(0.3);
\r
2163 expect(attr.setKey(s)[0].keySplines[3]).toBe(0.4);
\r
2165 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2166 it("should be this for the value (the valid partion on a spline mode )", function() {
\r
2167 s.setAttributeNS(null, "values", "0;2;12;30");
\r
2168 expect(attr.setKey(s)[0].keyTime.toFixed(3)).toBe("0.333");
\r
2169 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2170 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2171 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2172 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2173 s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");
\r
2174 s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");
\r
2175 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2176 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2177 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2179 s.setAttributeNS(null, "keyTimes", " 0; .1; .2 ; 1 ");
\r
2180 expect(attr.setKey(s)[0].keyTime).toBe(0.1);
\r
2181 expect(attr.setKey(s)[1].keyTime).toBe(0.1);
\r
2182 expect(attr.setKey(s)[2].keyTime).toBe(0.8);
\r
2184 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
2185 f(0, 0,0.1,0.3,1);
\r
2186 f(1, 0.1,0.4,0.5,0.7);
\r
2187 f(2, 0.2,0.2,0.1,1);
\r
2189 s.setAttributeNS(null, "keySplines", " 0,.1,.3,1; .1,.4, .5,.7; .2, .2, .1 , 1 ;");
\r
2190 f(0, 0,0.1,0.3,1);
\r
2191 f(1, 0.1,0.4,0.5,0.7);
\r
2192 f(2, 0.2,0.2,0.1,1);
\r
2194 s.setAttributeNS(null, "keySplines", " 0 .1 .333,1; .1 .4 .5 .7; .2 .2 .1 1 ;");
\r
2195 f(0, 0,0.1,0.333,1);
\r
2196 f(1, 0.1,0.4,0.5,0.7);
\r
2197 f(2, 0.2,0.2,0.1,1);
\r
2198 function f (i, a, b, c, d) {
\r
2199 var splines = attr.setKey(s)[i].keySplines;
\r
2200 expect(splines[0]).toBe(a);
\r
2201 expect(splines[1]).toBe(b);
\r
2202 expect(splines[2]).toBe(c);
\r
2203 expect(splines[3]).toBe(d);
\r
2206 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2207 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2208 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");
\r
2209 expect(attr.setKey(s)).toBeNull();
\r
2210 s.setAttributeNS(null, "values", "0;2;12");
\r
2211 expect(attr.setKey(s)).toBeNull();
\r
2212 s.setAttributeNS(null, "values", "0;2;12;20");
\r
2213 s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");
\r
2214 expect(attr.setKey(s)).toBeNull();
\r
2218 describe("A $setElement object", function() {
\r
2219 describe("A timeline property", function() {
\r
2220 var $set, ele, frame;
\r
2221 beforeEach( function() {
\r
2222 $set = base("$calcMode").$attribute.$setElement.up();
\r
2223 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2224 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2225 p.appendChild(ele);
\r
2226 frame = base("$frame");
\r
2228 /*境界条件を調べておく (limit value analysis)*/
\r
2229 it("should be this for the value (limit value analysis)", function() {
\r
2230 expect($set.timeline).toBe(frame.$begin);
\r
2233 expect($set.timeline).toBe(frame.$begin);
\r
2234 expect($set.element).toBeNull();
\r
2237 describe("An checkEnd method", function() {
\r
2238 var $set, ele, frame;
\r
2239 beforeEach( function() {
\r
2240 $set = base("$calcMode").$attribute.$setElement.up();
\r
2241 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2242 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2243 p.appendChild(ele);
\r
2244 frame = base("$frame");
\r
2246 /*境界条件を調べておく (limit value analysis)*/
\r
2247 it("should be this for the value (limit value analysis)", function() {
\r
2248 expect($set.checkEnd()).toBeFalsy();
\r
2250 frame.setFrame(0);
\r
2251 frame.$endFrame.setFrame(0);
\r
2252 expect($set.checkEnd()).toBeFalsy();
\r
2254 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2255 it("should be this for the value (the valid partion)", function() {
\r
2256 ele.setAttributeNS(null, "dur", "1s");
\r
2257 ele.setAttributeNS(null, "attributeName", "fill");
\r
2258 ele.setAttributeNS(null, "to", "red");
\r
2260 expect($set.checkEnd(0)).toBeFalsy();
\r
2261 expect($set.checkEnd(24)).toBeFalsy();
\r
2262 $set.state = "playing";
\r
2263 expect($set.checkEnd(25)).toBeTruthy();
\r
2264 expect($set.state).toBe("idling");
\r
2265 expect($set.checkEnd(26)).toBeFalsy();
\r
2267 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2268 it("should be this for the value (the invalid partion)", function() {
\r
2269 $set.timeline.isResolved = false;
\r
2270 expect($set.checkEnd(0)).toBeFalsy();
\r
2271 $set.timeline.activeTime = null;
\r
2272 expect($set.checkEnd(0)).toBeFalsy();
\r
2273 $set.timeline = null;
\r
2274 expect(function() {
\r
2280 describe("An init method", function() {
\r
2281 var $set, ele, frame;
\r
2282 beforeEach( function() {
\r
2283 $set = base("$calcMode").$attribute.$setElement.up();
\r
2284 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2285 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2286 p.appendChild(ele);
\r
2287 frame = base("$frame");
\r
2289 /*境界条件を調べておく (limit value analysis)*/
\r
2290 it("should be this for the value (limit value analysis)", function() {
\r
2291 expect($set.to).toBe("");
\r
2292 expect($set.attrName).toBe("");
\r
2293 expect($set.defaultValue).toBe("");
\r
2294 expect($set.isDefault).toBeFalsy();
\r
2295 expect($set.attrNameSpace).toBeNull();
\r
2297 expect($set.timeline).toBe(frame.$begin);
\r
2299 expect($set.to).toBe("");
\r
2300 expect($set.attrName).toBe("");
\r
2301 expect($set.isDefault).toBeFalsy();
\r
2302 expect($set.attrNameSpace).toBeNull();
\r
2303 expect($set.timeline).toBe(frame.$begin);
\r
2305 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2306 it("should be this for the value (the valid partion )", function() {
\r
2307 ele.setAttributeNS(null, "to", "t1");
\r
2309 expect($set.to).toBe("t1");
\r
2310 expect($set.attrName).toBe("");
\r
2311 expect($set.defaultValue).toBe("");
\r
2313 ele.setAttributeNS(null, "attributeName", "tt1");
\r
2315 expect($set.to).toBe("t1");
\r
2316 expect($set.attrName).toBe("tt1");
\r
2317 expect($set.defaultValue).toBe("");
\r
2319 ele.parentNode.setAttributeNS(null, "tt1", "undef");
\r
2321 expect($set.defaultValue).toBe("undef");
\r
2322 expect($set.isDefault).toBeTruthy();
\r
2324 ele.setAttributeNS(null, "attributeName", "font-size");
\r
2325 ele.parentNode.style.setProperty("font-size", "12px");
\r
2327 expect($set.defaultValue).toBe("12px");
\r
2328 expect($set.isDefault).toBeFalsy();
\r
2330 ele.setAttributeNS(null, "attributeName", "xlink:href");
\r
2332 expect($set.to).toBe("t1");
\r
2333 expect($set.attrName).toBe("xlink:href");
\r
2334 expect($set.defaultValue).toBe("");
\r
2335 ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");
\r
2337 expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");
\r
2339 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2340 it("should be this for the value (the invalid partion on a spline mode )", function() {
\r
2342 expect($set.to).toBe("");
\r
2343 expect($set.attrName).toBe("");
\r
2344 expect($set.defaultValue).toBe("");
\r
2347 expect($set.to).toBe("");
\r
2348 expect($set.attrName).toBe("");
\r
2349 expect($set.defaultValue).toBe("");
\r
2352 describe("Frame Set", function() {
\r
2353 var $set, ele, frame;
\r
2354 beforeEach( function() {
\r
2355 $set = base("$calcMode").$attribute.$setElement.up();
\r
2356 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2357 ele = document.createElementNS("http://www.w3.org/2000/svg", "set");
\r
2358 p.appendChild(ele);
\r
2359 frame = base("$frame");
\r
2360 frame.timelines.length = frame.$endFrame.timelines.length = 0; //配列の初期化
\r
2361 frame.startTime = Date.now();
\r
2362 frame.setFrame(0);
\r
2363 frame.$endFrame.setFrame(0);
\r
2365 afterEach( function() {
\r
2366 $set.isCSS = false;
\r
2368 /*境界条件を調べておく (limit value analysis)*/
\r
2369 it("should be this for the value (limit value analysis)", function() {
\r
2370 expect($set.isEnd).toBeFalsy();
\r
2371 expect($set.state).toBe("idling");
\r
2372 ele.setAttributeNS(null, "dur", "1s");
\r
2373 ele.setAttributeNS(null, "attributeName", "fill");
\r
2374 ele.setAttributeNS(null, "to", "red");
\r
2376 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2377 $set.isCSS = false;
\r
2378 expect($set.timeline).not.toBe(frame.$begin);
\r
2379 frame.setFrame(0);
\r
2380 frame.$endFrame.setFrame(0);
\r
2381 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2382 expect($set.state).toBe("playing");
\r
2384 frame.setFrame(24);
\r
2385 frame.$endFrame.setFrame(24);
\r
2386 expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();
\r
2387 expect($set.state).toBe("idling");
\r
2389 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2390 it("should be this for the value (the valid partion)", function() {
\r
2391 ele.setAttributeNS(null, "begin", "1s");
\r
2392 ele.setAttributeNS(null, "dur", "1s");
\r
2393 ele.setAttributeNS(null, "attributeName", "fill");
\r
2394 ele.setAttributeNS(null, "to", "red");
\r
2396 /*テストしやすくするために、CSSではなくXML属性として扱う*/
\r
2397 $set.isCSS = false;
\r
2398 var f = function(num) {
\r
2399 frame.setFrame(num);
\r
2400 frame.$endFrame.setFrame(num);
\r
2401 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();
\r
2406 frame.setFrame(24);
\r
2407 frame.$endFrame.setFrame(24);
\r
2408 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2409 frame.setFrame(25);
\r
2410 frame.$endFrame.setFrame(25);
\r
2411 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2415 ele.setAttributeNS(null, "fill", "freeze");
\r
2417 $set.isCSS = false;
\r
2421 frame.setFrame(24);
\r
2422 frame.$endFrame.setFrame(24);
\r
2423 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2424 frame.setFrame(25);
\r
2425 frame.$endFrame.setFrame(25);
\r
2426 expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");
\r
2427 frame.setFrame(48);
\r
2428 frame.$endFrame.setFrame(48);
\r
2429 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2430 frame.setFrame(49);
\r
2431 frame.$endFrame.setFrame(49);
\r
2432 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2433 ele.setAttributeNS(null, "begin", "1s");
\r
2434 ele.setAttributeNS(null, "attributeName", "fill");
\r
2435 ele.setAttributeNS(null, "to", "red");
\r
2436 /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/
\r
2438 $set.isCSS = false;
\r
2439 var f = function(num) {
\r
2440 frame.setFrame(num);
\r
2441 frame.$endFrame.setFrame(num);
\r
2442 expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");
\r
2450 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2451 it("should be this for the value (the invalid partion)", function() {
\r
2456 describe("A $animateElement object", function() {
\r
2457 describe("An init method", function() {
\r
2458 var $animate, ele, frame;
\r
2459 beforeEach( function() {
\r
2460 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2461 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2462 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2463 p.appendChild(ele);
\r
2464 frame = base("$frame");
\r
2465 frame.timelines.length = 0;
\r
2466 frame.startTime = Date.now();
\r
2467 frame.setFrame(0);
\r
2468 frame.$endFrame.setFrame(0);
\r
2470 /*境界条件を調べておく (limit value analysis)*/
\r
2471 it("should be this for the value (limit value analysis)", function() {
\r
2474 ele.setAttributeNS(null, "begin", "1s");
\r
2475 ele.setAttributeNS(null, "dur", "1s");
\r
2476 ele.setAttributeNS(null, "attributeName", "d");
\r
2477 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2478 ele.setAttributeNS(null, "to", "M20 20 L10 30");
\r
2479 $animate.init(ele);
\r
2480 expect($animate.isCSS).toBeFalsy();
\r
2481 frame.setFrame(0);
\r
2482 frame.$endFrame.setFrame(0);
\r
2483 var p = ele.parentNode;
\r
2484 /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、
\r
2485 * 他のブラウザではnullを返すため、その対策をする*/
\r
2486 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2488 function f(fr, result) {
\r
2489 frame.setFrame(fr);
\r
2490 frame.$endFrame.setFrame(fr);
\r
2491 expect(p.getAttributeNS(null, "d") || "").toBe(result);
\r
2494 f(24, "M20.0 0.0 L20.0 30.0");
\r
2495 f(36, "M20.0 10.0 L15.0 30.0");
\r
2498 ele.setAttributeNS(null, "fill", "freeze");
\r
2499 $animate.init(ele);
\r
2500 f(24, "M20.0 0.0 L20.0 30.0");
\r
2501 f(36, "M20.0 10.0 L15.0 30.0");
\r
2502 f(48, "M20.0 20.0 L10.0 30.0");
\r
2504 frame.timelines.length = 0;
\r
2505 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2506 $animate.init(ele);
\r
2507 expect($animate.isCSS).toBeFalsy();
\r
2508 expect($animate.mode).toBe("discrete");
\r
2509 f(24, "M20.0 0.0 L20.0 30.0");
\r
2510 f(25, "M20.0 0.0 L20.0 30.0");
\r
2511 f(37, "M20.0 20.0 L10.0 30.0");
\r
2512 f(48, "M20.0 20.0 L10.0 30.0");
\r
2514 [ ["display", "inline", "none"],
\r
2515 ["visibility", "hidden", "visible"],
\r
2516 ["stroke-linecap", "round", "square"],
\r
2517 ["font-style", "italic", "normal"]
\r
2518 ].forEach( function(attr) {
\r
2519 var attrName = attr[0],
\r
2522 function g(fr, result) {
\r
2523 frame.setFrame(fr);
\r
2524 frame.$endFrame.setFrame(fr);
\r
2525 expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);
\r
2529 ele.setAttributeNS(null, "from", from);
\r
2530 ele.setAttributeNS(null, "to", to);
\r
2531 frame.timelines.length = 0;
\r
2532 ele.setAttributeNS(null, "calcMode", "linear");
\r
2533 ele.setAttributeNS(null, "attributeName", attrName);
\r
2534 $animate.init(ele);
\r
2535 expect($animate.mode).toBe("discrete");
\r
2542 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2543 it("should be this for the value (the valid partion )", function() {
\r
2545 ele.setAttributeNS(null, "begin", "0s");
\r
2546 ele.setAttributeNS(null, "dur", "100s");
\r
2547 ele.setAttributeNS(null, "attributeName", "d");
\r
2548 ele.setAttributeNS(null, "fill", "freeze");
\r
2549 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2550 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2551 $animate.init(ele);
\r
2553 var p = ele.parentNode;
\r
2554 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2556 function f(fr, result) {
\r
2557 frame.setFrame(fr);
\r
2558 frame.$endFrame.setFrame(fr);
\r
2559 expect(p.getAttributeNS(null, "d")).toBe(result);
\r
2562 for (var i=0;i<2400;++i) {
\r
2563 f(i, "M20.0 " +i+ ".0 L20.0 30.0");
\r
2565 f(2401, "M20.0 2400.0 L20.0 30.0");
\r
2568 frame.timelines.length = 0;
\r
2569 ele.setAttributeNS(null, "begin", "0s");
\r
2570 ele.setAttributeNS(null, "dur", "1s");
\r
2571 ele.setAttributeNS(null, "repeatDur", "2s");
\r
2572 ele.setAttributeNS(null, "attributeName", "d");
\r
2573 ele.setAttributeNS(null, "fill", "freeze");
\r
2574 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2575 ele.setAttributeNS(null, "to", "M20 24 L20 30");
\r
2576 $animate.init(ele);
\r
2577 f(23, "M20.0 23.0 L20.0 30.0");
\r
2578 f(24, "M20.0 0.0 L20.0 30.0");
\r
2579 f(25, "M20.0 1.0 L20.0 30.0");
\r
2580 f(48, "M20.0 24.0 L20.0 30.0");
\r
2582 frame.timelines.length = 0;
\r
2583 ele.setAttributeNS(null, "begin", "0s");
\r
2584 ele.setAttributeNS(null, "dur", "2s");
\r
2585 ele.setAttributeNS(null, "attributeName", "d");
\r
2586 ele.setAttributeNS(null, "fill", "freeze");
\r
2587 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2588 $animate.init(ele);
\r
2589 f(0, "M20.0 0.0 L20.0 30.0");
\r
2590 f(1, "M20.0 1.0 L20.0 30.0");
\r
2591 f(24, "M20.0 24.0 L20.0 30.0");
\r
2592 f(25, "M20.0 24.1 L20.0 30.0");
\r
2593 f(47, "M20.0 26.3 L20.0 30.0");
\r
2594 f(48, "M20.0 26.4 L20.0 30.0");
\r
2595 f(49, "M20.0 26.4 L20.0 30.0");
\r
2596 f(50, "M20.0 26.4 L20.0 30.0");
\r
2598 frame.timelines.length = 0;
\r
2599 ele.setAttributeNS(null, "begin", "0s");
\r
2600 ele.setAttributeNS(null, "end", "2s");
\r
2601 ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合
\r
2602 ele.removeAttributeNS(null, "repeatDur");
\r
2603 ele.setAttributeNS(null, "attributeName", "d");
\r
2604 ele.setAttributeNS(null, "fill", "freeze");
\r
2605 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2606 $animate.init(ele);
\r
2607 f(0, "M20.0 0.0 L20.0 30.0");
\r
2608 f(1, "M20.0 0.0 L20.0 30.0");
\r
2609 f(24, "M20.0 0.0 L20.0 30.0");
\r
2610 f(25, "M20.0 0.0 L20.0 30.0");
\r
2611 f(47, "M20.0 0.0 L20.0 30.0");
\r
2612 f(48, "M20.0 0.0 L20.0 30.0");
\r
2613 f(49, "M20.0 0.0 L20.0 30.0");
\r
2614 f(50, "M20.0 0.0 L20.0 30.0");
\r
2616 frame.timelines.length = 0;
\r
2617 ele.setAttributeNS(null, "dur", "2s");
\r
2618 ele.setAttributeNS(null, "fill", "remove");
\r
2619 var attrValue = p.getAttributeNS(null, "d");
\r
2620 $animate.init(ele);
\r
2623 frame.timelines.length = 0;
\r
2624 p.removeAttributeNS(null, "d");
\r
2625 ele.setAttributeNS(null, "fill", "freeze");
\r
2626 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2627 $animate.init(ele);
\r
2628 f(1, "M20.0 5.0 L20.0 30.0");
\r
2629 f(48, "M20.0 26.4 L20.0 30.0");
\r
2631 frame.timelines.length = 0;
\r
2632 ele.setAttributeNS(null, "fill", "freeze");
\r
2633 ele.setAttributeNS(null, "calcMode", "discrete");
\r
2634 ele.setAttributeNS(null, "keyTimes", "0;0.5;0.6");
\r
2635 $animate.init(ele);
\r
2636 f(1, "M20.0 0.0 L20.0 30.0");
\r
2637 f(4, "M20.0 0.0 L20.0 30.0");
\r
2638 /*本来は24フレーム目で、変化するはずだが、不具合があるため、そうならない
\r
2640 f(24, "M20.0 24.0 L20.0 30.0");
\r
2641 f(25, "M20.0 24.0 L20.0 30.0");
\r
2642 f(29, "M20.0 26.4 L20.0 30.0");
\r
2643 f(48, "M20.0 26.4 L20.0 30.0");
\r
2645 frame.timelines.length = 0;
\r
2646 ele.setAttributeNS(null, "calcMode", "spline");
\r
2647 ele.removeAttributeNS(null, "keyTimes");
\r
2648 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");
\r
2649 ele.removeAttributeNS(null, "end");
\r
2650 ele.setAttributeNS(null, "dur", "9s");
\r
2651 ele.setAttributeNS(null, "values", "210;177;121;10");
\r
2652 $animate.init(ele);
\r
2659 frame.timelines.length = 0;
\r
2660 ele.setAttributeNS(null, "calcMode", "spline");
\r
2661 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2662 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2663 ele.setAttributeNS(null, "dur", "8s");
\r
2664 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2665 $animate.init(ele);
\r
2673 frame.timelines.length = 0;
\r
2674 ele.setAttributeNS(null, "begin", "click");
\r
2675 ele.setAttributeNS(null, "calcMode", "spline");
\r
2676 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2677 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2678 ele.setAttributeNS(null, "dur", "8s");
\r
2679 ele.setAttributeNS(null, "values", "300;255;180;30");
\r
2680 ele.parentNode.setAttributeNS(null, "d", "300");
\r
2681 $animate.init(ele);
\r
2688 ( function(attrName) {
\r
2689 function g(fr, result) {
\r
2690 frame.setFrame(fr);
\r
2691 frame.$endFrame.setFrame(fr);
\r
2692 expect(p.style.getPropertyValue(attrName)).toBe(result);
\r
2695 frame.timelines.length = 0;
\r
2696 ele.setAttributeNS(null, "begin", "0s");
\r
2697 ele.setAttributeNS(null, "calcMode", "linear");
\r
2698 ele.setAttributeNS(null, "attributeName", attrName);
\r
2699 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2700 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2701 ele.setAttributeNS(null, "dur", "8s");
\r
2702 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2703 $animate.init(ele);
\r
2704 expect($animate.mode).toBe("discrete");
\r
2711 frame.timelines.length = 0;
\r
2712 ele.setAttributeNS(null, "begin", "click");
\r
2713 ele.setAttributeNS(null, "calcMode", "linear");
\r
2714 ele.setAttributeNS(null, "attributeName", attrName);
\r
2715 ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");
\r
2716 ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");
\r
2717 ele.setAttributeNS(null, "dur", "8s");
\r
2718 ele.setAttributeNS(null, "values", "inline;block;inline;block");
\r
2719 $animate.init(ele);
\r
2720 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
2721 evt.initMouseEvent("click",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
2722 p.dispatchEvent(evt);
\r
2723 var cur = base("$frame").currentFrame;
\r
2724 expect($animate.mode).toBe("discrete");
\r
2725 g(cur+0, "inline");
\r
2726 g(cur+48, "block");
\r
2727 g(cur+96, "inline");
\r
2728 g(cur+192, "block");
\r
2729 g(cur+300, "block");
\r
2732 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2733 it("should be this for the value (the invalid partion )", function() {
\r
2734 ele.setAttributeNS(null, "begin", "0s");
\r
2735 ele.setAttributeNS(null, "dur", "100s");
\r
2736 ele.setAttributeNS(null, "attributeName", "d");
\r
2737 ele.setAttributeNS(null, "fill", "freeze");
\r
2738 ele.setAttributeNS(null, "from", "M20 0 L20 30");
\r
2739 ele.setAttributeNS(null, "to", "M20 2400 L20 30");
\r
2740 ele.setAttributeNS(null, "keyTimes", "0;0.1;1");
\r
2741 $animate.init(ele);
\r
2743 var p = ele.parentNode;
\r
2744 expect(p.getAttributeNS(null, "d") || null).toBeNull();
\r
2746 function f(fr, result) {
\r
2747 frame.setFrame(fr);
\r
2748 frame.$endFrame.setFrame(fr);
\r
2749 expect(p.getAttributeNS(null, "d") || null).toBe(result);
\r
2754 frame.timelines.length = 0;
\r
2755 /*keyTimes属性のリストの個数がvaluesリストと合致しない*/
\r
2756 ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");
\r
2757 ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");
\r
2758 $animate.init(ele);
\r
2762 /*keyTimes属性が0から始まっていない*/
\r
2763 frame.timelines.length = 0;
\r
2764 ele.setAttributeNS(null, "keyTimes", "0.1;0.3;1");
\r
2768 function ff(mode) {
\r
2769 ele.setAttributeNS(null, "calcMode", mode);
\r
2770 $animate.init(ele);
\r
2775 frame.timelines.length = 0;
\r
2776 ele.setAttributeNS(null, "calcMode", "spline");
\r
2777 $animate.init(ele);
\r
2778 expect($animate.mode).toBe("spline");
\r
2784 describe("RGB Color", function() {
\r
2785 var $animate, ele, frame, f;
\r
2786 beforeEach( function() {
\r
2787 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
2788 var p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2789 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2790 p.appendChild(ele);
\r
2791 frame = base("$frame");
\r
2792 frame.timelines.length = 0;
\r
2794 f = function (fr, result, attr) {
\r
2795 frame.setFrame(fr);
\r
2796 frame.$endFrame.setFrame(fr);
\r
2797 expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));
\r
2800 /*境界条件を調べておく (limit value analysis)*/
\r
2801 it("should be this for the value (limit value analysis)", function() {
\r
2802 ele.setAttributeNS(null, "begin", "0s");
\r
2803 ele.setAttributeNS(null, "dur", "1s");
\r
2804 ele.setAttributeNS(null, "attributeName", "fill");
\r
2805 ele.setAttributeNS(null, "fill", "remove");
\r
2806 ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");
\r
2807 ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");
\r
2808 $animate.init(ele);
\r
2810 f(0, "rgb(0, 0, 0)", "fill");
\r
2811 f(23, "rgb(10, 10, 1)", "fill");
\r
2813 frame.timelines.length = 0;
\r
2814 ele.setAttributeNS(null, "attributeName", "stroke");
\r
2815 $animate.init(ele);
\r
2816 f(0, "rgb(0, 0, 0)", "stroke");
\r
2817 f(23, "rgb(10, 10, 1)", "stroke");
\r
2819 frame.timelines.length = 0;
\r
2820 ele.setAttributeNS(null, "attributeName", "stop-color");
\r
2821 $animate.init(ele);
\r
2822 f(0, "rgb(0,0,0)", "stop-color");
\r
2823 f(23, "rgb(10,10,1)", "stop-color");
\r
2825 frame.timelines.length = 0;
\r
2826 ele.setAttributeNS(null, "attributeName", "color");
\r
2827 $animate.init(ele);
\r
2828 f(0, "rgb(0,0,0)", "color");
\r
2829 f(23, "rgb(10,10,1)", "color");
\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, "begin", "0s");
\r
2834 ele.setAttributeNS(null, "dur", "1s");
\r
2835 ele.setAttributeNS(null, "attributeName", "fill");
\r
2836 ele.setAttributeNS(null, "fill", "remove");
\r
2837 ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");
\r
2838 $animate.init(ele);
\r
2840 f(0, "rgb(0, 0, 0)", "fill");
\r
2841 f(1, "rgb(1, 0, 0)", "fill");
\r
2842 f(23, "rgb(23, 2, 1)", "fill");
\r
2844 frame.timelines.length = 0;
\r
2845 ele.setAttributeNS(null, "values", "#00083C;#18203C");
\r
2846 $animate.init(ele);
\r
2849 f(0, "rgb(0, 8, 60)", "fill");
\r
2850 f(1, "rgb(1, 9, 60)", "fill");
\r
2851 f(23, "rgb(23, 31, 60)", "fill");
\r
2853 frame.timelines.length = 0;
\r
2854 ele.setAttributeNS(null, "fill", "freeze");
\r
2855 ele.setAttributeNS(null, "values", "black;white");
\r
2856 $animate.init(ele);
\r
2857 /*色キーワードをrgb形式に変換*/
\r
2859 f(0, "rgb(0, 0, 0)", "fill");
\r
2860 f(12, "rgb(128, 128, 128)", "fill");
\r
2861 f(24, "rgb(255, 255, 255)", "fill");
\r
2863 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
2864 it("should be this for the value (the invalid partion )", function() {
\r
2865 ele.setAttributeNS(null, "begin", "0s");
\r
2866 ele.setAttributeNS(null, "dur", "1s");
\r
2867 ele.setAttributeNS(null, "attributeName", "fi");
\r
2868 ele.setAttributeNS(null, "fill", "remove");
\r
2869 ele.setAttributeNS(null, "values", "#00083C;#00107C");
\r
2870 $animate.init(ele);
\r
2873 function f (fr, result, attr) {
\r
2874 frame.setFrame(fr);
\r
2875 frame.$endFrame.setFrame(fr);
\r
2876 expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);
\r
2878 f(0, "#83.0C", "fi");
\r
2879 f(1, "#84.0C", "fi");
\r
2880 f(23, "#106.0C", "fi");
\r
2883 describe("$frame.$svgEvent object", function() {
\r
2884 var frame = base("$frame").$svgEvent,
\r
2886 base("$frame").pauseAnimation();
\r
2887 beforeEach( function() {
\r
2888 base("$frame").pauseAnimation();
\r
2889 frame = frame.up().mix( {isResolved: true} );
\r
2890 frame.first = null;
\r
2891 /*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に
\r
2892 * 影響を受けるため、新たに初期化しておく*/
\r
2893 base("$frame").timelines = frame.timelines = [];
\r
2894 frame.lastTimeLine = null;
\r
2895 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
2896 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
2897 p.appendChild(ele);
\r
2899 /*境界条件を調べておく (limit value analysis)*/
\r
2900 it("should be this for the value (limit value analysis)", function() {
\r
2901 base("$frame").pauseAnimation();
\r
2902 frame.lastTimeLine = null;
\r
2903 expect(frame.lastTimeLine).toBeNull();
\r
2904 expect(frame.first).toBeNull();
\r
2905 frame.setTimeTable();
\r
2906 expect(frame.first).toBeNull();
\r
2907 frame.addLine( base("$frame").$begin.up().mix({
\r
2914 frame.setTimeTable();
\r
2915 expect(frame.first).toEqual(
\r
2917 eventType: "begin",
\r
2928 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
2929 it("should be this for the value (the valid partion )", function() {
\r
2930 base("$frame").pauseAnimation();
\r
2931 frame.addLine( base("$frame").$begin.up().mix({
\r
2938 frame.setTimeTable();
\r
2939 frame.setTimeTable();
\r
2940 expect(frame.first).toEqual(
\r
2942 eventType: "begin",
\r
2952 frame.setTimeTable();
\r
2953 frame.setTimeTable();
\r
2954 expect(frame.first).toEqual(
\r
2956 eventType: "begin",
\r
2967 var isFiredBeginEvent = false;
\r
2968 ele.addEventListener("beginEvent", function(evt) {
\r
2969 isFiredBeginEvent = true;
\r
2970 expect(evt.target).toBe(ele);
\r
2972 ele.addEventListener("endEvent", function(evt) {
\r
2973 expect(evt.target).toBe(ele);
\r
2974 expect(isFiredBeginEvent).toBeTruthy();
\r
2976 frame.setFrame(0);
\r
2977 frame.$endFrame.setFrame(0);
\r
2978 expect(frame.first).toBeNull();
\r
2979 frame.setFrame(0);
\r
2980 frame.$endFrame.setFrame(0);
\r
2981 expect(frame.first).toBeNull();
\r
2983 frame.timelines = [];
\r
2984 frame.addLine( base("$frame").$begin.up().mix({
\r
2991 frame.setTimeTable();
\r
2992 var a = { frame: 0,
\r
2993 eventType: "begin",
\r
2996 next: { frame: 10,
\r
3002 expect(frame.first).toEqual(a);
\r
3004 frame.addLine( base("$frame").$begin.up().mix({
\r
3008 simpleDuration: 9,
\r
3012 frame.setTimeTable();
\r
3013 a.next.next = { frame: 1,
\r
3014 eventType: "begin",
\r
3019 eventType: "repeat",
\r
3023 next: { frame: 12,
\r
3030 expect(frame.first).toEqual(a);
\r
3031 frame.setFrame(11);
\r
3032 frame.$endFrame.setFrame(11);
\r
3033 expect(frame.first).toEqual( {frame: 12,
\r
3039 frame.timelines = [];
\r
3040 frame.first = null;
\r
3041 frame.addLine( base("$frame").$begin.up().mix({
\r
3045 simpleDuration: 4,
\r
3049 frame.setTimeTable();
\r
3051 eventType: "begin",
\r
3056 eventType: "repeat",
\r
3062 eventType: "repeat",
\r
3066 next: { frame: 11,
\r
3074 expect(frame.first).toEqual(a);
\r
3075 frame.setFrame(0);
\r
3076 frame.$endFrame.setFrame(0);
\r
3077 expect(frame.first).toEqual(a);
\r
3078 frame.setFrame(1);
\r
3079 frame.$endFrame.setFrame(1);
\r
3081 expect(frame.first).toEqual(a);
\r
3082 frame.setFrame(5);
\r
3083 frame.$endFrame.setFrame(5);
\r
3084 expect(frame.first).toEqual(a.next);
\r
3086 ele.addEventListener("repeatEvent", function(evt) {
\r
3087 expect(evt.target).toBe(ele);
\r
3089 frame.timelines = [];
\r
3090 frame.first = null;
\r
3091 frame.addLine( base("$frame").$begin.up().mix({
\r
3095 simpleDuration: 4,
\r
3099 frame.setFrame(9);
\r
3100 frame.$endFrame.setFrame(9);
\r
3101 expect(frame.first).toEqual({
\r
3103 eventType: "repeat",
\r
3107 next: { frame: 16,
\r
3114 afterEach( function() {
\r
3115 base("$frame").startAnimation();
\r
3118 describe("A $animateTransformElemenet object", function() {
\r
3119 describe("An init method", function() {
\r
3120 var $animate, ele, frame, p;
\r
3121 beforeEach( function() {
\r
3122 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();
\r
3123 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3124 $animate.degits = 1;
\r
3125 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3126 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");
\r
3127 p.appendChild(ele);
\r
3128 frame = base("$frame");
\r
3129 frame.timelines.length = 0;
\r
3130 frame.startTime = Date.now();
\r
3131 frame.setFrame(0);
\r
3132 frame.$endFrame.setFrame(0);
\r
3134 afterEach( function() {
\r
3135 $animate.numberOfList = -1;
\r
3137 /*境界条件を調べておく (limit value analysis)*/
\r
3138 it("should be this for the value (limit value analysis)", function() {
\r
3139 expect($animate.numberOfList).toBe(-1);
\r
3140 expect($animate.type).toBe("translate");
\r
3141 expect(p.__transformList).toBeUndefined();
\r
3142 expect($animate.isCSS).toBeFalsy();
\r
3143 expect($animate.isSum).toBeFalsy();
\r
3144 expect($animate.attrName).toBe("transform");
\r
3147 expect($animate.numberOfList).toBe(-1);
\r
3148 expect(p.__transformList).toBeUndefined();
\r
3149 expect($animate.isCSS).toBeFalsy();
\r
3150 expect($animate.type).toBe("translate");
\r
3151 expect($animate.attrName).toBe("transform");
\r
3154 expect($animate.numberOfList).toBe(-1);
\r
3155 expect(p.__transformList).toBeUndefined();
\r
3156 expect($animate.isCSS).toBeFalsy();
\r
3157 expect($animate.type).toBe("translate");
\r
3158 expect($animate.attrName).toBe("transform");
\r
3160 $animate.init(ele);
\r
3161 expect($animate.numberOfList).toBe(-1);
\r
3162 expect(p.__transformList).toEqual([]);
\r
3163 expect($animate.isCSS).toBeFalsy();
\r
3164 expect($animate.type).toBe("translate");
\r
3165 expect($animate.attrName).toBe("transform");
\r
3167 ele.setAttributeNS(null, "values", "0;1");
\r
3168 ele.setAttributeNS(null, "attributeName", "");
\r
3169 $animate.init(ele);
\r
3170 expect($animate.isCSS).toBeFalsy();
\r
3171 expect($animate.type).toBe("translate");
\r
3172 expect($animate.type).toBe("translate");
\r
3173 expect($animate.numberOfList).toBe(0);
\r
3174 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3175 value: "translate(0)",
\r
3180 ele.setAttributeNS(null, "type", "translate");
\r
3181 $animate.init(ele);
\r
3182 expect($animate.numberOfList).toBe(0);
\r
3183 expect($animate.isCSS).toBeFalsy();
\r
3184 expect($animate.type).toBe("translate");
\r
3185 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3186 value: "translate(0)",
\r
3190 $animate.tocall(0);
\r
3191 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
3193 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3194 $animate.numberOfList = -1;
\r
3195 $animate.init(ele.parentNode.lastChild);
\r
3196 expect($animate.numberOfList).toBe(1);
\r
3197 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
3198 expect(p.__transformList[1].isPlaying).toBeFalsy();
\r
3200 expect($animate.type).toBe("translate");
\r
3201 $animate.tocall(0);
\r
3202 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
3203 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
3204 $animate._setEndFrame(1);
\r
3205 expect(p.__transformList[0].isPlaying).toBeTruthy();
\r
3206 expect(p.__transformList[1].isPlaying).toBeTruthy();
\r
3208 delete p.__transformList;
\r
3209 ele.setAttributeNS(null, "type", "scale");
\r
3210 $animate.numberOfList = -1;
\r
3211 $animate.init(ele);
\r
3212 expect($animate.numberOfList).toBe(0);
\r
3213 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3214 value: "translate(0)",
\r
3218 expect($animate.type).toBe("scale");
\r
3220 delete p.__transformList;
\r
3221 $animate.numberOfList = -1;
\r
3222 ele.setAttributeNS(null, "additive", "sum");
\r
3223 ele.setAttributeNS(null, "fill", "freeze");
\r
3224 $animate.init(ele);
\r
3225 expect($animate.isSum).toBeTruthy();
\r
3226 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3227 value: "translate(0)",
\r
3231 delete p.__transformList;
\r
3232 $animate.numberOfList = -1;
\r
3233 ele.setAttributeNS(null, "additive", "replace");
\r
3234 ele.setAttributeNS(null, "fill", "remove");
\r
3235 $animate.init(ele);
\r
3236 expect(p.__transformList).toEqual([ {isPlaying: false,
\r
3237 value: "translate(0)",
\r
3242 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3243 it("should be this for the value (the valid partion )", function() {
\r
3244 ele.setAttributeNS(null, "type", "scale");
\r
3245 ele.setAttributeNS(null, "values", "0;1");
\r
3246 $animate.init(ele);
\r
3247 expect($animate.isCSS).toBeFalsy();
\r
3248 expect($animate.numberOfList).toBe(0);
\r
3249 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3250 expect($animate.tocall(0.5)).toBe("scale(0.5)");
\r
3251 expect($animate.tocall(0.9)).toBe("scale(0.9)");
\r
3252 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3254 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3255 $animate.numberOfList = -1;
\r
3256 $animate.init(ele.parentNode.lastChild);
\r
3257 expect($animate.numberOfList).toBe(1);
\r
3258 expect($animate.tocall(0)).toBe("scale(0.0)");
\r
3259 expect($animate.tocall(1)).toBe("scale(1.0)");
\r
3261 ele.parentNode.appendChild(ele.cloneNode(true));
\r
3262 $animate.up("$a").numberOfList = -1;
\r
3263 ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3264 $animate.$a.init(ele.parentNode.lastChild);
\r
3265 expect($animate.$a.numberOfList).toBe(2);
\r
3266 expect($animate.$a.isDefault).toBeTruthy();
\r
3267 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3268 expect($animate.$a.tocall(0)).toBe("scale(0.0)");
\r
3269 expect($animate.$a.tocall(1)).toBe("scale(1.0)");
\r
3270 $animate.defaultValue = $animate.$a.defaultValue;
\r
3271 expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");
\r
3273 ele.setAttributeNS(null, "additive", "sum");
\r
3274 var parentNode = ele.parentNode;
\r
3275 parentNode.appendChild(ele.cloneNode(true));
\r
3276 parentNode.__transformList = [];
\r
3277 /*additive属性のsumとreplaceの混合を避けるため、eleを削除*/
\r
3278 parentNode.removeChild(ele);
\r
3279 $animate.numberOfList = -1;
\r
3280 $animate.init(parentNode.lastChild);
\r
3281 expect($animate.numberOfList).toBe(0);
\r
3282 expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3283 expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3285 parentNode.appendChild(ele.cloneNode(true));
\r
3286 $animate.up("$a").numberOfList = -1;
\r
3287 parentNode.__transformList = [];
\r
3288 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3289 $animate.$a.init(parentNode.lastChild);
\r
3290 expect($animate.$a.numberOfList).toBe(0);
\r
3291 expect($animate.$a.isDefault).toBeTruthy();
\r
3292 expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");
\r
3293 expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");
\r
3294 expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");
\r
3295 $animate.defaultValue = $animate.$a.defaultValue;
\r
3296 expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");
\r
3298 ele.removeAttributeNS(null, "additive");
\r
3299 ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",
\r
3300 "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");
\r
3301 ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",
\r
3302 "scale(0.0)", "scale(1.0)");
\r
3303 function ad(first, second, a, b, c, d) {
\r
3305 while (parentNode.firstChild) {
\r
3306 parentNode.removeChild(parentNode.firstChild);
\r
3309 /*additive属性のreplaceとsumの混合*/
\r
3310 ele.setAttributeNS(null, "additive", first);
\r
3311 parentNode.appendChild(ele.cloneNode(true));
\r
3312 ele.setAttributeNS(null, "additive", second);
\r
3313 parentNode.appendChild(ele.cloneNode(true));
\r
3314 parentNode.__transformList = [];
\r
3315 $animate.numberOfList = -1;
\r
3316 parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");
\r
3317 $animate.up("$first").init(parentNode.firstChild);
\r
3318 $animate.up("$second").init(parentNode.lastChild);
\r
3319 expect($animate.$first.numberOfList).toBe(0);
\r
3320 expect($animate.$second.numberOfList).toBe(1);
\r
3321 expect($animate.$first.tocall(0)).toBe(a);
\r
3322 expect($animate.$second.tocall(0)).toBe(b);
\r
3323 expect($animate.$first.tocall(1)).toBe(c);
\r
3324 expect($animate.$second.tocall(1)).toBe(d);
\r
3327 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3328 it("should be this for the value (the invalid partion )", function() {
\r
3329 $animate.init(ele);
\r
3330 ele.parentNode.__transformList = null;
\r
3331 expect( function () {
\r
3332 $animate.tocall(0);
\r
3335 $animate.numberOfList = -1;
\r
3336 $animate.init(ele);
\r
3337 $animate.numberOfList = -1;
\r
3338 expect( function () {
\r
3339 $animate.tocall(0);
\r
3344 describe("A $motionElement object", function() {
\r
3345 describe("An init method", function() {
\r
3346 var $animate, ele, frame, p;
\r
3347 beforeEach( function() {
\r
3348 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3349 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3350 $animate.degits = 1;
\r
3351 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3352 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3353 p.appendChild(ele);
\r
3354 frame = base("$frame");
\r
3355 frame.timelines.length = 0;
\r
3356 frame.startTime = Date.now();
\r
3357 frame.setFrame(0);
\r
3358 frame.$endFrame.setFrame(0);
\r
3360 afterEach( function() {
\r
3361 $animate.numberOfList = -1;
\r
3362 delete $animate.element;
\r
3363 p.__transformList = null;
\r
3365 /*境界条件を調べておく (limit value analysis)*/
\r
3366 it("should be this for the value (limit value analysis)", function() {
\r
3367 expect($animate.type).toBe("translate");
\r
3368 expect($animate.mode).toBe("paced");
\r
3369 ele.setAttributeNS(null, "type", "scale");
\r
3370 expect($animate.rotate).toBe("0");
\r
3371 $animate.init(ele);
\r
3372 expect($animate.type).toBe("translate");
\r
3373 expect($animate.mode).toBe("paced");
\r
3374 expect($animate.rotate).toBe("0");
\r
3376 ele.setAttributeNS(null, "values", "0,0;1,0");
\r
3377 $animate.up("$a").init(ele);
\r
3378 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3379 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3380 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3382 var ec = ele.cloneNode(true);
\r
3383 p.appendChild(ec);
\r
3384 ec.removeAttributeNS(null, "values");
\r
3385 ec.setAttributeNS(null, "from", "0,0");
\r
3386 ec.setAttributeNS(null, "to", "1,0");
\r
3387 $animate.up("$a").init(ec);
\r
3388 expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");
\r
3389 expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");
\r
3390 expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");
\r
3392 /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
\r
3393 it("should be this for the value (the invalid partion )", function() {
\r
3397 describe("A hasAttrValues method", function() {
\r
3398 var $animate, ele, frame, p;
\r
3399 beforeEach( function() {
\r
3400 $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();
\r
3401 /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/
\r
3402 $animate.degits = 1;
\r
3403 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3404 ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
\r
3405 p.appendChild(ele);
\r
3406 frame = base("$frame");
\r
3407 frame.timelines.length = 0;
\r
3408 frame.startTime = Date.now();
\r
3409 frame.setFrame(0);
\r
3410 frame.$endFrame.setFrame(0);
\r
3412 afterEach( function() {
\r
3413 $animate.numberOfList = -1;
\r
3414 delete $animate.element;
\r
3415 p.__transformList = null;
\r
3417 /*境界条件を調べておく (limit value analysis)*/
\r
3418 it("should be this for the value (limit value analysis)", function() {
\r
3420 expect($animate.up("$a").hasAttrValues()).toBeFalsy();
\r
3421 $animate.up("$a").init(ele);
\r
3422 expect($animate.$a.hasAttrValues()).toBeFalsy();
\r
3424 ele.setAttributeNS(null, "path", "M");
\r
3425 expect($animate.$a.hasAttrValues()).toBeTruthy();
\r
3426 $animate.$animateTransformElement.up("$b").init(ele);
\r
3427 expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();
\r
3431 describe("Event", function() {
\r
3432 var $animate, ele, frame, p;
\r
3433 beforeEach( function() {
\r
3435 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3436 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3437 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3438 p.appendChild(ele);
\r
3439 frame = base("$frame");
\r
3440 frame.pauseAnimation();
\r
3441 frame.timelines.length = 0; //配列の初期化
\r
3442 frame.setFrame(0);
\r
3443 frame.$endFrame.setFrame(0);
\r
3445 /*境界条件を調べておく (limit value analysis)*/
\r
3446 it("should be this for the value (limit value analysis)", function() {
\r
3447 ele.addEventListener("beginEvent", function(evt) {
\r
3448 expect(evt.target).toBe(ele);
\r
3450 var evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3451 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3452 ele.dispatchEvent(evt);
\r
3454 ele.setAttributeNS(null, "begin", "mousedown");
\r
3455 ele.setAttributeNS(null, "dur", "1s");
\r
3456 ele.setAttributeNS(null, "attributeName", "fill");
\r
3457 ele.setAttributeNS(null, "fill", "freeze");
\r
3458 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3459 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3460 $animate.init(ele);
\r
3461 $animate.isCSS = false;
\r
3462 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3463 expect($animate.state).toBe("idling");
\r
3464 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3465 evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);
\r
3466 expect($animate.state).toBe("idling");
\r
3467 p.dispatchEvent(evt);
\r
3468 expect($animate.state).toBe("idling");
\r
3469 expect(p.getAttributeNS(null, "fill") || null).toBeNull();
\r
3471 evt = ele.ownerDocument.createEvent("MouseEvents");
\r
3472 evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);
\r
3473 frame.setFrame(frame.currentFrame);
\r
3474 frame.$endFrame.setFrame(frame.currentFrame);
\r
3475 expect($animate.isEnd).toBeFalsy();
\r
3476 expect($animate.state).toBe("idling");
\r
3477 p.dispatchEvent(evt);
\r
3478 frame.setFrame(frame.currentFrame + 1);
\r
3479 frame.$endFrame.setFrame(frame.currentFrame + 1);
\r
3480 expect($animate.state).toBe("playing");
\r
3481 frame.setFrame(frame.currentFrame + 24);
\r
3482 frame.$endFrame.setFrame(frame.currentFrame + 24);
\r
3483 expect($animate.state).toBe("idling");
\r
3484 expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");
\r
3487 describe("a beginElement method and an endElement method", function() {
\r
3488 var $animate, ele, frame, p;
\r
3489 beforeEach( function() {
\r
3490 $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();
\r
3491 p = document.createElementNS("http://www.w3.org/2000/svg", "g");
\r
3492 ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");
\r
3493 p.appendChild(ele);
\r
3494 frame = base("$frame");
\r
3495 frame.timelines.length = 0; //配列の初期化
\r
3496 frame.setFrame(0);
\r
3497 frame.$endFrame.setFrame(0);
\r
3498 ele.setAttributeNS(null, "begin", "indefinite");
\r
3499 ele.setAttributeNS(null, "dur", "1s");
\r
3500 ele.setAttributeNS(null, "dur", "1s");
\r
3501 ele.setAttributeNS(null, "attributeName", "fill");
\r
3502 ele.setAttributeNS(null, "fill", "freeze");
\r
3503 ele.setAttributeNS(null, "from", "rgb(0,0,0)");
\r
3504 ele.setAttributeNS(null, "to", "rgb(10,10,1)");
\r
3505 $animate.init(ele);
\r
3507 /*境界条件を調べておく (limit value analysis)*/
\r
3508 it("should be this for the value (limit value analysis)", function() {
\r
3509 expect(ele.beginElement()).toBeUndefined();
\r
3510 var cur = frame.currentFrame,
\r
3511 begin = frame.$begin.$1;
\r
3512 expect(begin.string).toBe("indefinite");
\r
3513 expect(begin.begin).toBe(cur);
\r
3514 expect(ele.endElement()).toBeUndefined();
\r
3516 /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
\r
3517 it("should be this for the value (the valid partion )", function() {
\r
3518 ele.addEventListener("beginEvent", function(evt){
\r
3519 expect(evt.target.nodeName).toBe("animate");
\r
3521 ele.beginElement();
\r