-/*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence\r
- *公式ページは http://sie.sourceforge.jp/\r
- */\r
-/* ***** BEGIN LICENSE BLOCK *****\r
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
- *\r
- * The contents of this file are subject to the Mozilla Public License Version\r
- * 1.1 (the "License"); you may not use this file except in compliance with\r
- * the License. You may obtain a copy of the License at\r
- * http://www.mozilla.org/MPL/\r
- *\r
- * Software distributed under the License is distributed on an "AS IS" basis,\r
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
- * for the specific language governing rights and limitations under the\r
- * License.\r
- *\r
- * The Original Code is the Mozilla SVG Cairo Renderer project.\r
- *\r
- * The Initial Developer of the Original Code is IBM Corporation.\r
- * Portions created by the Initial Developer are Copyright (C) 2004\r
- * the Initial Developer. All Rights Reserved.\r
- *\r
- * Parts of this file contain code derived from the following files(s)\r
- * of the Mozilla SVG project (these parts are Copyright (C) by their\r
- * respective copyright-holders):\r
- * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp\r
- *\r
- * Contributor(s):DHRNAME revulo bellbind\r
- *\r
- * Alternatively, the contents of this file may be used under the terms of\r
- * either of the GNU General Public License Version 2 or later (the "GPL"),\r
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
- * in which case the provisions of the GPL or the LGPL are applicable instead\r
- * of those above. If you wish to allow use of your version of this file only\r
- * under the terms of either the GPL or the LGPL, and not to allow others to\r
- * use your version of this file under the terms of the MPL, indicate your\r
- * decision by deleting the provisions above and replace them with the notice\r
- * and other provisions required by the GPL or the LGPL. If you do not delete\r
- * the provisions above, a recipient may use your version of this file under\r
- * the terms of any one of the MPL, the GPL or the LGPL.\r
- *\r
- * ***** END LICENSE BLOCK ***** */\r
-/*\r
- * Copyright (c) 2000 World Wide Web Consortium,\r
- * (Massachusetts Institute of Technology, Institut National de\r
- * Recherche en Informatique et en Automatique, Keio University). All\r
- * Rights Reserved. This program is distributed under the W3C's Software\r
- * Intellectual Property License. This program is distributed in the\r
- * hope that it will be useful, but WITHOUT ANY WARRANTY; without even\r
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
- * PURPOSE.\r
- * See W3C License http://www.w3.org/Consortium/Legal/ for more details.\r
+/*SIE under the MIT Lisence\r
+ *公式ページは http://sie.osdn.jp/\r
*/\r
/*\r
*Copyright (c) 2008-2010 Pivotal Labs\r
it("should be this for the value (limit value analysis)", function() {\r
expect(typeof frame.setFrame).toBe("function");\r
expect(frame.timelines.length).toBe(0);\r
- expect(frame.rank).toBe(0);\r
+ expect(frame.isBegin).toBeFalsy();\r
expect(frame.startAnimation()).toBeUndefined();\r
frame.setFrame();\r
frame.setFrame(0);\r
expect(frame.isPaused).toBeFalsy();\r
expect(frame.pauseAnimation()).toBeUndefined();\r
expect(frame.isPaused).toBeTruthy();\r
+\r
});\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
frame.timelines.length = 0;\r
frame.addLine( {\r
begin: 1,\r
- activeTime: 1,\r
- rank:2\r
+ activeTime: 1\r
+ } );\r
+ frame.addLine( {\r
+ begin: 1,\r
+ activeTime: 1\r
} );\r
frame.addLine( {\r
begin: 1,\r
- activeTime: 1,\r
- rank:1\r
+ activeTime: 2\r
} );\r
- expect(frame.timelines[0].rank).toBe(1);\r
- expect(frame.timelines[1].rank).toBe(2);\r
+ expect(frame.timelines[2].activeTime).toBe(2);\r
});\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
frame.setFrame(0);\r
});\r
} );\r
- \r
+ describe("the $frame.$list object", function() {\r
+ var frame = base("$frame").$list.up("$2");\r
+ beforeEach( function() {\r
+ frame.timelines = [];\r
+ frame.isPaused = false;\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ } );\r
+ afterEach( function() {\r
+ frame.timelines = [];\r
+ } );\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value (limit value analysis)", function() {\r
+ \r
+ expect(frame.WAITING).toBe(0);\r
+ expect(frame.BEGINNING).toBe(1);\r
+ expect(frame.PLAYING).toBe(2);\r
+ expect(frame.ENDING).toBe(3);\r
+ expect(frame.POSTWAITING).toBe(4);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.end).toBe(0);\r
+ \r
+ expect(frame.beginList).toEqual({\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ });\r
+ expect(frame.endList).toEqual({\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ });\r
+ \r
+ expect(typeof frame.getMaxList).toBe("function");\r
+ \r
+ expect(typeof frame.updateState).toBe("function");\r
+ expect(frame.updateState(0).state).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.updateState(0).state).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.updateState(0).state).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.updateState(0).state).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ \r
+ frame.state = 100;\r
+ expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState().state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ \r
+ expect(frame.beginList).toEqual({\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ });\r
+ expect(frame.endList).toEqual({\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ });\r
+ \r
+ expect(frame.getMaxList(0, frame.beginList)).toBe(-1);\r
+ expect(frame.getMaxList(0, frame.endList)).toBe(-1);\r
+ \r
+ frame.begin = 12;\r
+ frame.init();\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.begin).toBe(0);\r
+ expect(frame.init()).toBe(frame);\r
+\r
+ } );\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value (the valid partion)", function() {\r
+ \r
+ function appendBegin(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.beginList = {\r
+ value: num,\r
+ next: frame.beginList\r
+ };\r
+ };\r
+ appendBegin(0);\r
+ expect(frame.getMaxList(0, frame.beginList)).toBe(0);\r
+ expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
+ expect(frame.begin).toBe(0);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ frame.state = frame.WAITING;\r
+ expect(frame.getMaxList(0, frame.beginList)).toBe(0);\r
+ expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(3).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(4).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ appendBegin(1);\r
+ expect(frame.getMaxList(1, frame.beginList)).toBe(1);\r
+ expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(1).state).toBe(frame.ENDING);\r
+ expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ \r
+ frame.begin = 0;\r
+ frame.state = frame.WAITING;\r
+ expect(frame.updateState(0).state).toBe(frame.BEGINNING);\r
+ expect(frame.begin).toBe(0);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0).state).toBe(frame.PLAYING);\r
+ expect(frame.begin).toBe(0);\r
+ expect(frame.updateState(1).state).toBe(frame.ENDING);\r
+ expect(frame.end).toBe(1);\r
+ expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
+ expect(frame.begin).toBe(1);\r
+ expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
+ \r
+ function appendEnd(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ frame.endList = {\r
+ value: num,\r
+ next: frame.endList\r
+ };\r
+ };\r
+ appendEnd(3);\r
+ expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(3).state).toBe(frame.ENDING);\r
+ expect(frame.state).toBe(frame.ENDING);\r
+ expect(frame.end).toBe(3);\r
+ expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ \r
+ appendEnd(4);\r
+ expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(2).state).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(3).state).toBe(frame.ENDING);\r
+ expect(frame.state).toBe(frame.ENDING);\r
+ expect(frame.end).toBe(3);\r
+ expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ \r
+ appendEnd(1);\r
+ expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(1).state).toBe(frame.ENDING);\r
+ expect(frame.end).toBe(1);\r
+ expect(frame.updateState(1).state).toBe(frame.POSTWAITING);\r
+ } );\r
+ /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value (the invalid partion)", function() {\r
+ expect(frame.updateState()).toBe(frame);\r
+ expect(frame.updateState(null)).toBe(frame);\r
+ });\r
+ describe("the setFrame method (override)", function() {\r
+ var frame = base("$frame").$list.up("$3");\r
+ beforeEach( function() {\r
+ frame.timelines = [];\r
+ frame.isPaused = false;\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ } );\r
+ afterEach( function() {\r
+ frame.timelines = [];\r
+ frame.beginList = frame.$list.beginList;\r
+ frame.endList = frame.$list.endList;\r
+ frame.currentFrame = 0;\r
+ } );\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value (limit value analysis)", function() {\r
+ expect(typeof frame.setFrame).toBe("function");\r
+ expect(frame.currentFrame).toBe(0);\r
+ \r
+ frame.setFrame(0);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.currentFrame).toBe(0);\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.currentFrame).toBe(1);\r
+ \r
+ expect(typeof frame.addEvent).toBe("function");\r
+ expect(typeof frame.addBeginList).toBe("function");\r
+ expect(typeof frame.addEndList).toBe("function");\r
+ \r
+ expect(frame.addBeginList(1).value).toBe(1);\r
+ expect(frame.beginList.next.value).toBe(Number.MAX_VALUE);\r
+ expect(frame.addEndList(1).value).toBe(1);\r
+ expect(frame.endList.next.value).toBe(Number.MAX_VALUE);\r
+ \r
+\r
+\r
+ } );\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value (the valid partion)", function() {\r
+ function appendBegin(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.addBeginList(num);\r
+ };\r
+ appendBegin(0);\r
+ expect(frame.currentFrame).toBe(0);\r
+ frame.setFrame(0);\r
+ expect(frame.currentFrame).toBe(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(1);\r
+ expect(frame.currentFrame).toBe(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ frame.begin = 0;\r
+ appendBegin(1);\r
+ frame.setFrame(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(2);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ function appendEnd(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ frame.addEndList(num);\r
+ };\r
+ \r
+ appendEnd(3);\r
+ frame.setFrame(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(2);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(3);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ frame.setFrame(4);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ \r
+ appendBegin(5);\r
+ frame.setFrame(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(2);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(3);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ frame.setFrame(4);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ frame.setFrame(5);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(6);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ appendEnd(6);\r
+ frame.setFrame(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.currentFrame).toBe(0);\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.currentFrame).toBe(1);\r
+ frame.setFrame(2);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.currentFrame).toBe(2);\r
+ frame.setFrame(3);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ frame.setFrame(4);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ frame.setFrame(5);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.setFrame(6);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ expect(frame.currentFrame).toBe(6);\r
+ \r
+ /*負荷テスト*/\r
+ for (var i=0;i<10000;++i) {\r
+ frame.setFrame(i);\r
+ }\r
+ \r
+ frame.beginList = base("$frame").$listbeginList;\r
+ frame.endList = base("$frame").$list.endList;\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ var obj = { name: "", value: 0};\r
+ frame.addEvent("begin", function(evt) { obj.name = "a";});\r
+ frame.beginList = {\r
+ value: 0,\r
+ next: frame.beginList\r
+ };\r
+ frame.setFrame(0);\r
+ expect(frame.currentFrame).toBe(0);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(obj.name).toBe("a");\r
+ frame.addEvent("play", function(evt) { obj.name = "b";});\r
+ frame.setFrame(1);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(obj.name).toBe("b");\r
+ frame.addEvent("end", function(evt) { obj.value = 1;});\r
+ frame.endList = {\r
+ value: 0,\r
+ next: frame.endList\r
+ };\r
+ frame.setFrame(0);\r
+ expect(frame.currentFrame).toBe(0);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ expect(obj.value).toBe(1);\r
+ var t = 0;\r
+ frame.addEvent("begin", function(evt) {\r
+ expect(evt.state).toBe(frame.BEGINNING);\r
+ t = 1;\r
+ });\r
+ frame.addEvent("end", function(evt) {\r
+ expect(evt.state).toBe(frame.ENDING);\r
+ t = 2;\r
+ });\r
+ frame.addEvent("play", function(evt) {\r
+ expect(evt.state).toBe(frame.PLAYING);\r
+ t = 3;\r
+ });\r
+ frame.setFrame(0);\r
+ expect(t).toBe(2);\r
+ \r
+ t=0;\r
+ frame.begin = 0;\r
+ frame.state = frame.WAITING;\r
+ expect(frame.getMaxList(12, frame.endList)).toBe(0);\r
+ frame.setFrame(12);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ expect(t).toBe(2);\r
+ \r
+ /*addBeginListメソッドのチェックなど*/\r
+ expect(frame.addBeginList(1).value).toBe(1);\r
+ expect(frame.addBeginList(0).value).toBe(0);\r
+ expect(frame.beginList.next.value).toBe(1);\r
+ expect(frame.addBeginList(2).value).toBe(2);\r
+ expect(frame.beginList.next.value).toBe(0);\r
+ \r
+ expect(frame.addEndList(1).value).toBe(1);\r
+ expect(frame.addEndList(0).value).toBe(0);\r
+ expect(frame.endList.next.value).toBe(1);\r
+ expect(frame.addEndList(2).value).toBe(2);\r
+ expect(frame.endList.next.value).toBe(0);\r
+ } );\r
+ } );\r
+ } );\r
describe("$begin object", function() {\r
var begin = base("$frame").$begin.up();\r
/*境界条件を調べておく (limit value analysis)*/\r
expect(begin.string).toBe("");\r
expect(begin.isResolved).toBeFalsy();\r
expect(begin.eventTarget).toBe(document.documentElement);\r
- expect(typeof begin.listener).toBe("function");\r
expect(begin.eventOffset).toBe(0);\r
expect(begin.repeat).toBe(0);\r
expect(begin.accessKey).toBe("");\r
it("should be this for the value (the valid partion)", function() {\r
begin.string = " hoge ";\r
expect(begin.string).toBe(" hoge ");\r
+ var $list = begin.$list;\r
+ expect(begin.$list).toBe($list);\r
+ expect(begin.updateList().$list).not.toBe($list);\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
expect(begin.parse().begin).toBe(0);\r
begin.string = "-0ms";\r
expect(begin.parse().begin).toBe(0);\r
+ begin.string = "-0ms;-0ms";\r
+ expect(begin.parse().begin).toBe(0);\r
+ begin.string = "-0ms;1";\r
+ expect(begin.parse().begin).toBe(1000*begin.fpms);\r
\r
expect(begin.eventOffset).toBe(0);\r
begin.string = "click";\r
expect(begin.isResolved).toBeFalsy();\r
} );\r
} );\r
- \r
- describe("A listener method in $begin object", function() {\r
- var obj = begin.up();\r
- beforeEach( function() {\r
- begin.string = "";\r
- /*配列は初期化しておく*/\r
- begin.timelines.length = 0;\r
- obj.$activate = begin.$activate.up();\r
- obj.startTime = Date.now();\r
- obj.setFrame(0);\r
- } );\r
- /*境界条件を調べておく (limit value analysis)*/\r
- it("should be this for the value (limit value analysis)", function() {\r
- obj.isResolved = true;\r
- obj.listener();\r
- expect(obj.begin).toBe(0);\r
- \r
- obj.listener( {\r
- timeStamp: Date.now()\r
- } );\r
- expect(obj.begin).toBe(0);\r
- expect(obj.activeTime).toBeGreaterThan(0);\r
- expect(obj.timelines.length).toBe(1);\r
-\r
- obj.isResolved = false;\r
- obj.listener( {\r
- timeStamp: Date.now()\r
- } );\r
- expect(obj.begin).toBe(0);\r
- expect(obj.activeTime).toBeGreaterThan(0);\r
- expect(obj.timelines.length).toBe(1);\r
- /*配列を初期化*/\r
- obj.timelines.length = 0;\r
-\r
- obj.up().mix( {\r
- begin: 1,\r
- eventOffset: 1,\r
- $activate: begin.$activate.up().mix( {\r
- dur: "12"\r
- } )\r
- })\r
- .listener( {\r
- timeStamp: Date.now()\r
- } );\r
- expect(obj.$1.begin).toBe(1);\r
- expect(obj.$1.activeTime).toBe(Math.floor(12000*obj.fpms));\r
- expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
- expect(obj.timelines[0]).toBe(obj.$1);\r
- } );\r
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion)", function() {\r
- obj.up().mix( {\r
- begin: 1,\r
- eventOffset: 1,\r
- $activate: begin.$activate.up().mix( {\r
- end: begin.$activate.end.up().mix( {\r
- string: "1s"\r
- } )\r
- } )\r
- })\r
- .listener( {\r
- timeStamp: Date.now()\r
- } );\r
- expect(obj.$1.begin).toBe(1);\r
- expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);\r
- expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
- expect(obj.timelines[0]).toBe(obj.$1);\r
-\r
- obj.up().mix( {\r
- begin: 1,\r
- eventOffset: 1,\r
- $activate: begin.$activate.up().mix( {\r
- end: begin.$activate.end.up().mix( {\r
- string: "1s"\r
- } )\r
- } )\r
- })\r
- .listener( {\r
- timeStamp: Date.now()\r
- } );\r
- expect(obj.$1.begin).toBe(1);\r
- expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);\r
- expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
- expect(obj.timelines[1]).toBe(obj.$1);\r
- obj.$1.listener( {\r
- timeStamp: (Date.now() + 500)\r
- } );\r
- expect(obj.$1.begin).toBe(1);\r
- expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);\r
- expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
- expect(obj.timelines[1]).toBe(obj.$1);\r
- } );\r
- /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
- it("should be this for the value (the invalid partion)", function() {\r
- } );\r
- } );\r
} );\r
describe("A $end object", function() {\r
var end = base("$frame").$begin.$end.up();\r
end.string = null;\r
expect(end.up().call()).toBeNull();\r
} );\r
-\r
- describe("A listener method in $end object", function() {\r
- var obj,\r
- begin = base("$frame").$begin;\r
- beforeEach( function() {\r
- end.string = "";\r
- /*配列は初期化しておく*/\r
- end.timelines.length = 0;\r
- obj = end.up();\r
- obj.$begin = begin.up().mix( {\r
- begin: 12,\r
- activeTime: 120\r
- } );\r
- obj.$begin.$activate = begin.$activate.up();\r
- obj.addLine(obj.$begin);\r
- } );\r
- /*境界条件を調べておく (limit value analysis)*/\r
- it("should be this for the value (limit value analysis)", function() {\r
- expect(obj.timelines[0]).toBe(obj.$begin);\r
- expect(obj.timelines[0]).not.toBe(obj);\r
- obj.listener();\r
- expect(obj.timelines[0]).not.toBe(obj.$begin);\r
-\r
- obj.addLine(obj.$begin.mix( {\r
- begin: 12,\r
- activeTime: 120\r
- } ) );\r
- obj.listener({\r
- timeStamp: (Date.now() + 12)\r
- } );\r
- expect(obj.timelines[0]).not.toBe(obj.$begin);\r
- } );\r
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion)", function() {\r
- obj.$begin.$activate.begin = 0;\r
- obj.mix( {\r
- string: "event"\r
- } ).parse();\r
- obj.listener({\r
- timeStamp: (Date.now() + 120)\r
- } );\r
- expect(obj.timelines[0]).not.toBe(obj.$begin);\r
- expect(obj.begin).toBe(0);\r
- expect(obj.$begin.activeTime).toBe(0);\r
-\r
- obj.addLine(obj.$begin.mix( {\r
- begin: 12,\r
- activeTime: 120\r
- } ) );\r
- obj.$begin.$activate.begin = 0;\r
- obj.mix( {\r
- string: "event+1000ms"\r
- } ).parse();\r
- obj.listener({\r
- timeStamp: (Date.now() + 12)\r
- } );\r
- expect(obj.timelines[0]).toBe(obj.$begin);\r
- expect(obj.begin).toBe(Math.ceil(1000*obj.fpms));\r
- expect(obj.$begin.activeTime).toBe(Math.ceil(1000*obj.fpms));\r
- } );\r
- /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
- it("should be this for the value (the invalid partion)", function() {\r
- } );\r
- } )\r
} );\r
describe("A $activate object", function() {\r
var act = base("$frame").$begin.$activate.up();\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
- expect(act.resolvedTime()).toBe((+new Date()));\r
+ expect(act.resolvedTime()).not.toBe(0);\r
\r
/*Activate Duration = dur*/\r
act.up("$b");\r
expect(abc).toBe(act.$b.simpleDur);\r
act.dur = null;\r
expect(act.up().call()).toBeNull();\r
- \r
- /*AD = end -begin*/\r
- act.begin = 1;\r
- act.up("$eb").end = act.end.up().mix( {string: "120ms" } );\r
- expect( act.$eb.mix( {\r
- dur: "indefinite",\r
- simpleDur: act.simpleDur,\r
- repeatCount: 12,\r
- repeatDur: null,\r
- } ).call() ).toBe(Math.floor(120*act.fpms) - 1);\r
- expect( act.$eb.mix( {\r
- dur: "12",\r
- repeatCount: "indefinite",\r
- repeatDur: null,\r
- } ).call() ).toBe(Math.floor(120*act.fpms) - 1);\r
- expect( act.$eb.mix( {\r
- dur: "12",\r
- simpleDur: act.simpleDur,
- repeatCount: null,\r
- repeatDur: "indefinite",\r
- } ).call() ).toBe(Math.floor(120*act.fpms) - 1);\r
- act.$eb.end *= 3;\r
- expect( act.$eb.mix( {\r
- dur: "12",\r
- simpleDur: act.simpleDur,
- repeatCount: "indefinite",\r
- repeatDur: "indefinite",\r
- } ).call() ).toBe(Math.floor(120*act.fpms)*3 - 1);\r
\r
- /*AD = Min(dur, end - begin)*/\r
- act.up("$c").end = act.end.up().mix( { string: "12" } );\r
+ act.up("$c");\r
act.$c.mix( {\r
dur: "10",\r
simpleDur: act.simpleDur,
repeatCount: null,\r
repeatDur: null\r
} );\r
- expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);\r
- expect(act.$c.simpleDur).toBe(Math.floor(15000*act.fpms));\r
+ expect(act.$c.call()).toBe(Math.floor(15000*act.fpms));\r
\r
- /*AD = Min(repeatCount*dur, end - begin)*/\r
- expect(act.$c.end).toBe(Math.floor(12000*act.fpms));\r
+ /*AD = repeatCount*dur*/\r
act.$c.mix( {\r
dur: "10",\r
simpleDur: act.simpleDur,
repeatCount: 2,\r
repeatDur: null\r
} );\r
- expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);\r
+ act.$c.call();\r
expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
act.$c.mix( {\r
dur: "10",\r
expect(act.$c.call()).toBe(Math.floor(10000*act.fpms));\r
expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
\r
- /*AD = Min(repeatDur, end - begin)*/\r
+ /*AD = repeatDur*/\r
act.$c.mix( {\r
dur: "indefinite",\r
simpleDur: act.simpleDur,
repeatCount: 2,\r
repeatDur: "15"\r
} );\r
- expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);\r
+ act.$c.call();\r
expect(act.$c.simpleDur).toBeNull();\r
act.$c.mix( {\r
dur: "indefinite",\r
repeatCount: null,\r
repeatDur: "15"\r
} );\r
- expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);\r
+ act.$c.call();\r
expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
act.$c.mix( {\r
dur: "10",\r
expect(act.$c.call()).toBe(Math.floor(11000*act.fpms));\r
expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
\r
- /*AD = Min(repeatCount*d, repeatDur, end - begin)*/\r
+ /*AD = Min(repeatCount*d, repeatDur)*/\r
act.$c.mix( {\r
dur: "10",\r
simpleDur: act.simpleDur,
repeatCount: 2,\r
repeatDur: "15"\r
} );\r
- expect(act.$c.call()).toBe(Math.floor(12000*act.fpms) - 1);\r
+ act.$c.call();\r
expect(act.$c.simpleDur).toBe(Math.floor(10000*act.fpms));\r
act.$c.mix( {\r
dur: "10",\r
act.repeatDur = null;\r
act.repeatCount = "indefinite";\r
act.dur = "1";\r
- expect(act.call()).toBe(0);\r
+ expect(act.call()).toBeNull();\r
act.repeatCount = null;\r
act.repeatDur = "indefinite";\r
act.dur = "1";\r
- expect(act.call()).toBe(0);\r
+ expect(act.call()).toBeNull();\r
act.repeatDur = "indefinite";\r
act.repeatCount = "indefinite";\r
act.dur = "1";\r
- expect(act.call()).toBe(0);\r
+ expect(act.call()).toBeNull();\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
expect(from.numList()).toEqual([]);\r
expect(from.strList()[0]).toBe("a");\r
\r
+ /*前後の空白を除去する処理をしない。なぜなら、文字列リストの空白は保持するのが望ましいから\r
+ * 文字列リストの空白を除去した例: "M 20 20 M M" -> "M20 20 MM"となってしまう*/\r
+ \r
from.string = null;\r
expect( function() {\r
from.numList();\r
expect(from.call()).toBe(from.numList);\r
\r
from = base("$from").up();\r
- from.up("$to");\r
- from.$to.from = from;\r
- from.string = "inline";\r
- arr.string = from.$to.string = "block";\r
- expect(from.$to.call()).toBe(from.$to.numList);\r
- expect(from.$to.numList).toEqual(arr);\r
- expect(from.$to.strList).toEqual(["block"]);\r
- arr.string = from.string;\r
- expect(from.numList).toEqual(arr);\r
- expect(from.strList).toEqual(["inline"]);\r
- expect(from.advance(0)).toBe("");\r
- expect(from.$to.from).toBe(from.numList);\r
- expect(from.$to.advance(0)).toBe("inline"); \r
- expect(from.call()).toBe(from.numList);\r
+ f(from.up(), "inline", "block");\r
+ f(from.up(), " inline", " block ");\r
+ function f(from, inline, block) {\r
+ from.up("$to");\r
+ from.$to.from = from;\r
+ from.string = inline;\r
+ arr.string = from.$to.string = block;\r
+ expect(from.$to.call()).toBe(from.$to.numList);\r
+ expect(from.$to.numList).toEqual(arr);\r
+ expect(from.$to.strList).toEqual([block]);\r
+ arr.string = from.string;\r
+ expect(from.numList).toEqual(arr);\r
+ expect(from.strList).toEqual([inline]);\r
+ expect(from.advance(0)).toBe("");\r
+ expect(from.$to.from).toBe(from.numList);\r
+ expect(from.$to.advance(0)).toBe("inline");\r
+ expect(from.$to.advance(1)).toBe("block");\r
+ expect(from.call()).toBe(from.numList);\r
+ }\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
expect(from.call()).toBe(from.numList);\r
\r
from = base("$from").up();\r
- from.up("$to");\r
- from.string = "a-10s1.5";\r
- from.$to.string = "a10s-3";\r
- from.$to.from = from;\r
- from.$to.call();\r
- from.$to.degit = 1;\r
- expect(from.$to.advance(0)).toBe("a-10.0s1.5");\r
- expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");\r
- expect(from.$to.advance(1)).toBe("a10.0s-3.0");\r
- \r
- from.$to.additive[0] = 1;\r
- from.$to.accumulate[1] = 2;\r
- expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");\r
- from.$to.additive[0] = 0.5;\r
- from.$to.accumulate[1] = 0.8;\r
- expect(from.$to.advance(1)).toBe("a10.5s-2.2");\r
+ f(from.up(), "a-10s1.5", "a10s-3");\r
+ f(from.up(), " a-10s1.5", " a10s-3 ");\r
+ function f(from, fromString, toString) {\r
+ from.up("$to");\r
+ from.string = fromString;\r
+ from.$to.string = toString;\r
+ from.$to.from = from;\r
+ from.$to.call();\r
+ from.$to.degit = 1;\r
+ expect(from.$to.advance(0)).toBe("a-10.0s1.5");\r
+ expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");\r
+ expect(from.$to.advance(1)).toBe("a10.0s-3.0");\r
+\r
+ from.$to.additive[0] = 1;\r
+ from.$to.accumulate[1] = 2;\r
+ expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");\r
+ from.$to.additive[0] = 0.5;\r
+ from.$to.accumulate[1] = 0.8;\r
+ expect(from.$to.advance(1)).toBe("a10.5s-2.2");\r
+ }\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
calc.to.from.string = "inline";\r
expect(calc.call()(0.2)).toBe("inline");\r
expect(calc.call()(0.3)).toBe("inline");\r
+ \r
+ calc.to = base("$from").up();\r
+ calc.to.from = base("$from").up(); \r
+ calc.mode = "linear";\r
+ calc.keyTime = 1;\r
+ calc.to.degit = 1;\r
+ calc.to.string = "1 1";\r
+ calc.to.from.string = "0.0 1";\r
+ expect(calc.call()(0.2)).toBe("0.2 1.0");\r
+ expect(calc.call()(0.3)).toBe("0.3 1.0");\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
base("$frame").timelines.length = 0;\r
s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");\r
} );\r
+ afterEach( function() {\r
+ attr.isCSS = false;\r
+ } );\r
/*境界条件を調べておく (limit value analysis)*/\r
it("should be this for the value (limit value analysis)", function() {\r
expect(attr.element).toBeNull();\r
function check(attrName, num) {\r
s.setAttribute(attrName, "1");\r
expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
- var l = attr.push(s);\r
+ var fr = attr.push(s);\r
expect(attr.element).toBe(p);\r
var timelines = base("$frame").timelines;\r
expect(timelines.length).toBe(num);\r
var line = timelines[num-1];\r
- expect(line.string).toBe("0");\r
- expect(line).toBe(l); //タイムラインのオブジェクトを返す\r
- var act = line.$activate;\r
+ expect(line).not.toBe(fr);\r
+ var act = fr.$activate;\r
expect(act.dur).toBeNull();\r
- expect(act.end).toBe(0);\r
expect(act.repeatCount).toBeNull();\r
expect(act.repeatDur).toBeNull();\r
expect(act.min).toBe("0");\r
expect(attr.isCSS).toBeTruthy();\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion on a spline mode )", function() {\r
+ it("should be this for the value (the valid partion )", function() {\r
s.setAttribute("from", "1");\r
var p = document.createElement("g");\r
p.appendChild(s);\r
function check2(attrName, value) {\r
s.setAttribute(attrName, value);\r
expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
- attr.push(s);\r
+ var fr = attr.push(s);\r
expect(attr.element).toBe(p);\r
var timelines = base("$frame").timelines;\r
var line = timelines[timelines.length-1];\r
- expect(line.string).toBe(values[0]);\r
- var act = line.$activate;\r
+ expect(fr.string).toBe(values[0]);\r
+ var act = fr.$activate;\r
expect(act.dur).toBe(values[1]);\r
- expect(act.end).toBe(values[2]);\r
expect(act.repeatCount).toBe(values[3]);\r
expect(act.repeatDur).toBe(values[4]);\r
expect(act.min).toBe(values[5]);\r
s.setAttributeNS(null, "attributeName", "display");\r
attr.push(s);\r
expect(attr.setAttribute("block")).toBeUndefined();\r
- expect(p4.hasAttributeNS(null, "display")).toBeTruthy();\r
+ expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
expect(attr.isCSS).toBeTruthy();\r
expect(p4.style.getPropertyValue("display")).toBe("block");\r
\r
p4.setAttributeNS(null, "style", "display: none");\r
attr.push(s);\r
expect(attr.setAttribute("block")).toBeUndefined();\r
- expect(p4.hasAttributeNS(null, "display")).toBeTruthy();\r
+ expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
expect(p4.style.getPropertyValue("display")).toBe("block");\r
expect(attr.removeAttribute()).toBeUndefined();\r
expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
attr.push(s);\r
var timelines = base("$frame").timelines;\r
expect(timelines.length).toBe(0);\r
- s.setAttributeNS(null, "from", "1");\r
+ s.setAttributeNS(null, "from", "0");\r
attr.push(s);\r
expect(timelines.length).toBe(1);\r
expect(attr.push(12)).toBeNull();\r
} );\r
} );\r
} );\r
- describe("A $setElemenet object", function() {\r
+ describe("A $setElement object", function() {\r
describe("A timeline property", function() {\r
var $set, ele, frame;\r
beforeEach( function() {\r
expect($set.element).toBeNull();\r
} );\r
} );\r
+ \r
describe("An init method", function() {\r
var $set, ele, frame;\r
beforeEach( function() {\r
expect($set.timeline).toBe(frame.$begin);\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion on a spline mode )", function() {\r
+ it("should be this for the value (the valid partion )", function() {\r
ele.setAttributeNS(null, "to", "t1");\r
$set.init(ele);\r
expect($set.to).toBe("t1");\r
frame.startTime = Date.now();\r
frame.setFrame(0);\r
} );\r
+ afterEach( function() {\r
+ $set.isCSS = false;\r
+ } );\r
/*境界条件を調べておく (limit value analysis)*/\r
it("should be this for the value (limit value analysis)", function() {\r
expect($set.isEnd).toBeFalsy();\r
- expect($set.state).toBe("idling");\r
ele.setAttributeNS(null, "dur", "1s");\r
ele.setAttributeNS(null, "attributeName", "fill");\r
ele.setAttributeNS(null, "to", "red");\r
$set.init(ele);\r
+ /*テストしやすくするために、CSSではなくXML属性として扱う*/\r
+ $set.isCSS = false;\r
expect($set.timeline).not.toBe(frame.$begin);\r
frame.setFrame(0);\r
expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
- expect($set.state).toBe("playing");\r
\r
+ var line = $set.timeline;\r
+ expect(line.$list.state).toBe(line.$list.PLAYING);\r
frame.setFrame(24);\r
+ expect(line.$list.state).toBe(line.$list.POSTWAITING);\r
expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();\r
- expect($set.state).toBe("idling");\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
ele.setAttributeNS(null, "attributeName", "fill");\r
ele.setAttributeNS(null, "to", "red");\r
$set.init(ele);\r
+ /*テストしやすくするために、CSSではなくXML属性として扱う*/\r
+ $set.isCSS = false;\r
var f = function(num) {\r
frame.setFrame(num);\r
expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();\r
\r
ele.setAttributeNS(null, "fill", "freeze");\r
$set.init(ele);\r
+ $set.isCSS = false;\r
f(0);\r
f(1);\r
f(23);\r
ele.setAttributeNS(null, "to", "red");\r
/*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/\r
$set.init(ele);\r
+ $set.isCSS = false;\r
var f = function(num) {\r
frame.setFrame(num);\r
expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
ele.setAttributeNS(null, "to", "M20 20 L10 30");\r
$animate.init(ele);\r
- \r
+ expect($animate.isCSS).toBeFalsy();\r
frame.setFrame(0);\r
var p = ele.parentNode;\r
/*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、\r
frame.timelines.length = 0;\r
ele.setAttributeNS(null, "calcMode", "discrete");\r
$animate.init(ele);\r
+ expect($animate.isCSS).toBeFalsy();\r
expect($animate.mode).toBe("discrete");\r
f(24, "M20.0 0.0 L20.0 30.0");\r
f(25, "M20.0 0.0 L20.0 30.0");\r
f(37, "M20.0 20.0 L10.0 30.0");\r
f(48, "M20.0 20.0 L10.0 30.0");\r
\r
- ["display", "visibility", "xlink:href",\r
- "stroke-linecap", "font-style"].forEach( function(attrName) {\r
+ [ ["display", "inline", "none"],\r
+ ["visibility", "hidden", "visible"],\r
+ ["stroke-linecap", "round", "square"],\r
+ ["font-style", "italic", "normal"]\r
+ ].forEach( function(attr) {\r
+ var attrName = attr[0],\r
+ from = attr[1],\r
+ to = attr[2];\r
function g(fr, result) {\r
frame.setFrame(fr);\r
- expect(p.getAttribute(attrName) || "").toBe(result);\r
+ expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);\r
};\r
\r
+ \r
+ ele.setAttributeNS(null, "from", from);\r
+ ele.setAttributeNS(null, "to", to);\r
frame.timelines.length = 0;\r
ele.setAttributeNS(null, "calcMode", "linear");\r
ele.setAttributeNS(null, "attributeName", attrName);\r
$animate.init(ele);\r
expect($animate.mode).toBe("discrete");\r
- g(24, "M20.0 0.0 L20.0 30.0");\r
- g(25, "M20.0 0.0 L20.0 30.0");\r
- g(37, "M20.0 20.0 L10.0 30.0");\r
- g(48, "M20.0 20.0 L10.0 30.0");\r
+ g(24, from);\r
+ g(25, from);\r
+ g(37, to);\r
+ g(48, to);\r
} );\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
f(192, "300");\r
f(300, "300");\r
\r
- ["display", "visibility", "xlink:href",\r
- "stroke-linecap", "font-style"].forEach( function(attrName) {\r
+ ( function(attrName) {\r
function g(fr, result) {\r
frame.setFrame(fr);\r
- expect(p.getAttribute(attrName)).toBe(result);\r
+ expect(p.style.getPropertyValue(attrName)).toBe(result);\r
};\r
\r
frame.timelines.length = 0;\r
expect($animate.mode).toBe("discrete");\r
g(cur+0, "inline");\r
g(cur+48, "block");\r
- g(cur+976, "inline");\r
+ g(cur+96, "inline");\r
g(cur+192, "block");\r
g(cur+300, "block");\r
- } );\r
+ } )("display");\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion )", function() {\r
\r
f = function (fr, result, attr) {\r
frame.setFrame(fr);\r
- expect(p.getAttributeNS(null, attr)).toBe(result);\r
+ expect(p.style.getPropertyValue(attr).replace(/\s/g, "")).toBe(result.replace(/\s/g, ""));\r
};\r
} );\r
/*境界条件を調べておく (limit value analysis)*/\r
$animate.init(ele);\r
/*rgb形式に変換しない*/\r
\r
+ function f (fr, result, attr) {\r
+ frame.setFrame(fr);\r
+ expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);\r
+ };\r
f(0, "#83.0C", "fi");\r
f(1, "#84.0C", "fi");\r
f(23, "#106.0C", "fi"); \r
base("$frame").pauseAnimation();\r
beforeEach( function() {\r
base("$frame").pauseAnimation();\r
- frame = frame.up();\r
+ frame = frame.up().mix( {isResolved: true} );\r
frame.first = null;\r
/*firstプロパティとtimelinesプロパティは$frameオブジェクトのフレーム進行に\r
* 影響を受けるため、新たに初期化しておく*/\r
frame.setTimeTable();\r
expect(frame.first).toBeNull();\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 0,\r
activeTime: 0,\r
it("should be this for the value (the valid partion )", function() {\r
base("$frame").pauseAnimation();\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 0,\r
activeTime: 0,\r
\r
frame.timelines = [];\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 0,\r
activeTime: 10,\r
expect(frame.first).toEqual(a);\r
\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 1,\r
simpleDuration: 9,\r
eventType: "begin",\r
target: ele,\r
\r
- next: { firstFrame: 10,\r
+ next: {\r
frame: 10,\r
eventType: "repeat",\r
- limit: 12,\r
count: 1,\r
- simpleDuration: 9,\r
target: ele,\r
\r
next: { frame: 12,\r
frame.timelines = [];\r
frame.first = null;\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 1,\r
simpleDuration: 4,\r
eventType: "begin",\r
target: ele,\r
\r
- next: {firstFrame:5,\r
+ next: {\r
frame: 5,\r
eventType: "repeat",\r
- limit: 11,\r
count: 1,\r
- simpleDuration: 4,\r
target: ele,\r
\r
- next: { frame: 11,\r
- eventType: "end",\r
+ next: {\r
+ frame: 9,\r
+ eventType: "repeat",\r
+ count: 2,\r
target: ele,\r
- next: null\r
+ \r
+ next: { frame: 11,\r
+ eventType: "end",\r
+ target: ele,\r
+ next: null\r
+ }\r
}\r
}\r
};\r
a = a.next;\r
expect(frame.first).toEqual(a);\r
frame.setFrame(5);\r
- a.count = 1;\r
- a.frame = 9;\r
- expect(frame.first).toEqual(a);\r
+ expect(frame.first).toEqual(a.next);\r
\r
ele.addEventListener("repeatEvent", function(evt) {\r
expect(evt.target).toBe(ele);\r
frame.timelines = [];\r
frame.first = null;\r
frame.addLine( base("$frame").$begin.up().mix({\r
+ isResolved: true,\r
timelines: [],\r
begin: 1,\r
simpleDuration: 4,\r
target: ele\r
}) );\r
frame.setFrame(9);\r
- a.count = 2;\r
- a.limit = 16;\r
- a.next.frame = 16;\r
- expect(frame.first).toEqual(a);\r
+ expect(frame.first).toEqual({\r
+ frame: 13,\r
+ eventType: "repeat",\r
+ count: 3,\r
+ target: ele,\r
+ \r
+ next: { frame: 16,\r
+ eventType: "end",\r
+ target: ele,\r
+ next: null\r
+ }\r
+ } );\r
} );\r
afterEach( function() {\r
base("$frame").startAnimation();\r
var $animate, ele, frame, p;\r
beforeEach( function() {\r
$animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.up();\r
+ /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
+ $animate.degits = 1;\r
p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
ele = document.createElementNS("http://www.w3.org/2000/svg", "animateTransform");\r
p.appendChild(ele);\r
expect($animate.numberOfList).toBe(-1);\r
expect($animate.type).toBe("translate");\r
expect(p.__transformList).toBeUndefined();\r
+ expect($animate.isCSS).toBeFalsy();\r
+ expect($animate.isSum).toBeFalsy();\r
+ expect($animate.attrName).toBe("transform");\r
\r
$animate.init();\r
expect($animate.numberOfList).toBe(-1);\r
expect(p.__transformList).toBeUndefined();\r
+ expect($animate.isCSS).toBeFalsy();\r
expect($animate.type).toBe("translate");\r
+ expect($animate.attrName).toBe("transform");\r
\r
$animate.init(p);\r
expect($animate.numberOfList).toBe(-1);\r
expect(p.__transformList).toBeUndefined();\r
+ expect($animate.isCSS).toBeFalsy();\r
expect($animate.type).toBe("translate");\r
+ expect($animate.attrName).toBe("transform");\r
\r
$animate.init(ele);\r
expect($animate.numberOfList).toBe(-1);\r
expect(p.__transformList).toEqual([]);\r
+ expect($animate.isCSS).toBeFalsy();\r
+ expect($animate.type).toBe("translate");\r
+ expect($animate.attrName).toBe("transform");\r
\r
ele.setAttributeNS(null, "values", "0;1");\r
+ ele.setAttributeNS(null, "attributeName", "");\r
$animate.init(ele);\r
+ expect($animate.isCSS).toBeFalsy();\r
+ expect($animate.type).toBe("translate");\r
expect($animate.type).toBe("translate");\r
expect($animate.numberOfList).toBe(0);\r
- expect(p.__transformList).toEqual(["translate(0)"]);\r
+ expect(p.__transformList).toEqual([ {isPlaying: false,\r
+ value: "translate(0)",\r
+ isSum: false,\r
+ isRemove: true\r
+ } ]);\r
\r
ele.setAttributeNS(null, "type", "translate");\r
$animate.init(ele);\r
expect($animate.numberOfList).toBe(0);\r
+ expect($animate.isCSS).toBeFalsy();\r
expect($animate.type).toBe("translate");\r
- expect(p.__transformList).toEqual(["translate(0)"]);\r
+ expect(p.__transformList).toEqual([ {isPlaying: false,\r
+ value: "translate(0)",\r
+ isSum: false,\r
+ isRemove: true\r
+ } ]);\r
+ $animate.tocall(0);\r
+ expect(p.__transformList[0].isPlaying).toBeTruthy();\r
\r
ele.parentNode.appendChild(ele.cloneNode(true));\r
$animate.numberOfList = -1;\r
$animate.init(ele.parentNode.lastChild);\r
expect($animate.numberOfList).toBe(1);\r
- expect(p.__transformList).toEqual(["translate(0)", "translate(0)"]);\r
+ expect(p.__transformList[0].isPlaying).toBeTruthy();\r
+ expect(p.__transformList[1].isPlaying).toBeFalsy();\r
+\r
expect($animate.type).toBe("translate");\r
+ $animate.tocall(0);\r
+ expect(p.__transformList[0].isPlaying).toBeTruthy();\r
+ expect(p.__transformList[1].isPlaying).toBeTruthy();\r
+ $animate._setEndFrame(1);\r
+ expect(p.__transformList[0].isPlaying).toBeTruthy();\r
+ expect(p.__transformList[1].isPlaying).toBeFalsy();\r
\r
delete p.__transformList;\r
ele.setAttributeNS(null, "type", "scale");\r
$animate.numberOfList = -1;\r
$animate.init(ele);\r
expect($animate.numberOfList).toBe(0);\r
- expect(p.__transformList).toEqual(["translate(0)"]);\r
+ expect(p.__transformList).toEqual([ {isPlaying: false,\r
+ value: "translate(0)",\r
+ isSum: false,\r
+ isRemove: true\r
+ } ]);\r
expect($animate.type).toBe("scale");\r
- \r
- expect($animate.isSum).toBeFalsy();\r
+\r
+ delete p.__transformList;\r
+ $animate.numberOfList = -1;\r
ele.setAttributeNS(null, "additive", "sum");\r
+ ele.setAttributeNS(null, "fill", "freeze");\r
$animate.init(ele);\r
expect($animate.isSum).toBeTruthy();\r
+ expect(p.__transformList).toEqual([ {isPlaying: false,\r
+ value: "translate(0)",\r
+ isSum: true,\r
+ isRemove: false\r
+ } ]);\r
+ delete p.__transformList;\r
+ $animate.numberOfList = -1;\r
ele.setAttributeNS(null, "additive", "replace");\r
+ ele.setAttributeNS(null, "fill", "remove");\r
$animate.init(ele);\r
- expect($animate.isSum).toBeFalsy();\r
+ expect(p.__transformList).toEqual([ {isPlaying: false,\r
+ value: "translate(0)",\r
+ isSum: false,\r
+ isRemove: true\r
+ } ]);\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion )", function() {\r
ele.setAttributeNS(null, "type", "scale");\r
ele.setAttributeNS(null, "values", "0;1");\r
$animate.init(ele);\r
+ expect($animate.isCSS).toBeFalsy();\r
expect($animate.numberOfList).toBe(0);\r
expect($animate.tocall(0)).toBe("scale(0.0)");\r
expect($animate.tocall(0.5)).toBe("scale(0.5)");\r
expect($animate.$a.tocall(0)).toBe("scale(0.0)");\r
expect($animate.$a.tocall(1)).toBe("scale(1.0)");\r
$animate.defaultValue = $animate.$a.defaultValue;\r
- expect($animate.tocall(0.1)).toBe("scale(0.1)");\r
+ expect($animate.$a.tocall(0.1)).toBe("scale(0.1)");\r
\r
ele.setAttributeNS(null, "additive", "sum");\r
var parentNode = ele.parentNode;\r
$animate.defaultValue = $animate.$a.defaultValue;\r
expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");\r
\r
- /*子要素を全部消す*/\r
- while (parentNode.firstChild) {\r
- parentNode.removeChild(parentNode.firstChild);\r
- }\r
- \r
- /*additive属性のreplaceとsumの混合*/\r
ele.removeAttributeNS(null, "additive");\r
- parentNode.appendChild(ele.cloneNode(true));\r
- ele.setAttributeNS(null, "additive", "sum");\r
- parentNode.appendChild(ele.cloneNode(true));\r
- parentNode.__transformList = [];\r
- $animate.numberOfList = -1;\r
- parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
- $animate.up("$b").init(parentNode.firstChild);\r
- $animate.up("$c").init(parentNode.lastChild);\r
- expect($animate.$b.numberOfList).toBe(0);\r
- expect($animate.$c.numberOfList).toBe(1);\r
- expect($animate.$b.tocall(0)).toBe("scale(0.0)");\r
- expect($animate.$c.tocall(0)).toBe("scale(0.0) scale(0.0)");\r
- expect($animate.$b.tocall(1)).toBe("scale(1.0)");\r
- expect($animate.$c.tocall(1)).toBe("scale(1.0) scale(1.0)");\r
+ ad("replace", "sum", "scale(0.0) translate(0)", "scale(0.0) scale(0.0)",\r
+ "scale(1.0) scale(0.0)", "scale(1.0) scale(1.0)");\r
+ ad("sum", "replace", "matrix(0 0 0 0 0 0) scale(0.0)", "scale(0.0)",\r
+ "scale(0.0)", "scale(1.0)");\r
+ function ad(first, second, a, b, c, d) {\r
+ /*子要素を全部消す*/\r
+ while (parentNode.firstChild) {\r
+ parentNode.removeChild(parentNode.firstChild);\r
+ }\r
+ \r
+ /*additive属性のreplaceとsumの混合*/\r
+ ele.setAttributeNS(null, "additive", first);\r
+ parentNode.appendChild(ele.cloneNode(true));\r
+ ele.setAttributeNS(null, "additive", second);\r
+ parentNode.appendChild(ele.cloneNode(true));\r
+ parentNode.__transformList = [];\r
+ $animate.numberOfList = -1;\r
+ parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
+ $animate.up("$first").init(parentNode.firstChild);\r
+ $animate.up("$second").init(parentNode.lastChild);\r
+ expect($animate.$first.numberOfList).toBe(0);\r
+ expect($animate.$second.numberOfList).toBe(1);\r
+ expect($animate.$first.tocall(0)).toBe(a);\r
+ expect($animate.$second.tocall(0)).toBe(b);\r
+ expect($animate.$first.tocall(1)).toBe(c);\r
+ expect($animate.$second.tocall(1)).toBe(d);\r
+ };\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion )", function() {\r
var $animate, ele, frame, p;\r
beforeEach( function() {\r
$animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();\r
+ /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
+ $animate.degits = 1;\r
p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");\r
p.appendChild(ele);\r
} );\r
afterEach( function() {\r
$animate.numberOfList = -1;\r
+ delete $animate.element;\r
p.__transformList = null;\r
} );\r
/*境界条件を調べておく (limit value analysis)*/\r
it("should be this for the value (limit value analysis)", function() {\r
expect($animate.type).toBe("translate");\r
+ expect($animate.mode).toBe("paced");\r
ele.setAttributeNS(null, "type", "scale");\r
+ expect($animate.rotate).toBe("0");\r
$animate.init(ele);\r
expect($animate.type).toBe("translate");\r
+ expect($animate.mode).toBe("paced");\r
+ expect($animate.rotate).toBe("0");\r
\r
- ele.setAttributeNS(null, "values", "0;1");\r
+ ele.setAttributeNS(null, "values", "0,0;1,0");\r
$animate.up("$a").init(ele);\r
- expect($animate.$a.tocall(0)).toBe("translate(0.0)");\r
- expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");\r
- expect($animate.$a.tocall(1)).toBe("translate(1.0)");\r
+ expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");\r
+ expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");\r
+ expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");\r
\r
var ec = ele.cloneNode(true);\r
+ p.appendChild(ec);\r
ec.removeAttributeNS(null, "values");\r
- ec.setAttributeNS(null, "from", "0");\r
- ec.setAttributeNS(null, "to", "1");\r
+ ec.setAttributeNS(null, "from", "0,0");\r
+ ec.setAttributeNS(null, "to", "1,0");\r
$animate.up("$a").init(ec);\r
- expect($animate.$a.tocall(0)).toBe("translate(0.0)");\r
- expect($animate.$a.tocall(0.5)).toBe("translate(0.5)");\r
- expect($animate.$a.tocall(1)).toBe("translate(1.0)");\r
+ expect($animate.$a.tocall(0)).toBe("translate(0.0,0.0)");\r
+ expect($animate.$a.tocall(0.5)).toBe("translate(0.5,0.0)");\r
+ expect($animate.$a.tocall(1)).toBe("translate(1.0,0.0)");\r
+ } );\r
+ /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value (the invalid partion )", function() {\r
+ $animate.init();\r
+ } );\r
+ } );\r
+ describe("A hasAttrValues method", function() {\r
+ var $animate, ele, frame, p;\r
+ beforeEach( function() {\r
+ $animate = base("$calcMode").$attribute.$setElement.$animateElement.$animateTransformElement.$motionElement.up();\r
+ /*ここでは、データ量を削るため、degitsプロパティを小数点以下1桁に設定*/\r
+ $animate.degits = 1;\r
+ p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
+ ele = document.createElementNS("http://www.w3.org/2000/svg", "animateMotion");\r
+ p.appendChild(ele);\r
+ frame = base("$frame");\r
+ frame.timelines.length = 0;\r
+ frame.startTime = Date.now();\r
+ frame.setFrame(0);\r
+ } );\r
+ afterEach( function() {\r
+ $animate.numberOfList = -1;\r
+ delete $animate.element;\r
+ p.__transformList = null;\r
+ } );\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value (limit value analysis)", function() {\r
+ \r
+ expect($animate.up("$a").hasAttrValues()).toBeFalsy();\r
+ $animate.up("$a").init(ele);\r
+ expect($animate.$a.hasAttrValues()).toBeFalsy();\r
\r
+ ele.setAttributeNS(null, "path", "M");\r
+ expect($animate.$a.hasAttrValues()).toBeTruthy();\r
+ $animate.$animateTransformElement.up("$b").init(ele);\r
+ expect($animate.$animateTransformElement.$b.hasAttrValues()).toBeFalsy();\r
} );\r
} );\r
} );\r
ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
$animate.init(ele);\r
+ $animate.isCSS = false;\r
expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
- expect($animate.state).toBe("idling");\r
evt = ele.ownerDocument.createEvent("MouseEvents");\r
evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
- expect($animate.state).toBe("idling");\r
p.dispatchEvent(evt);\r
- expect($animate.state).toBe("idling");\r
expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
\r
evt = ele.ownerDocument.createEvent("MouseEvents");\r
evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
frame.setFrame(frame.currentFrame);\r
expect($animate.isEnd).toBeFalsy();\r
- expect($animate.state).toBe("idling");\r
p.dispatchEvent(evt);\r
frame.setFrame(frame.currentFrame + 1);\r
- expect($animate.state).toBe("playing");\r
frame.setFrame(frame.currentFrame + 24);\r
- expect($animate.state).toBe("idling");\r
expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");\r
} );\r
} );\r