-/*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence
- *公式ページは http://sie.sourceforge.jp/
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Mozilla SVG Cairo Renderer project.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Parts of this file contain code derived from the following files(s)
- * of the Mozilla SVG project (these parts are Copyright (C) by their
- * respective copyright-holders):
- * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
- *
- * Contributor(s):DHRNAME revulo bellbind
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-/*
- * Copyright (c) 2000 World Wide Web Consortium,
- * (Massachusetts Institute of Technology, Institut National de
- * Recherche en Informatique et en Automatique, Keio University). All
- * Rights Reserved. This program is distributed under the W3C's Software
- * Intellectual Property License. This program is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.
- * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
- */
-/*
- *Copyright (c) 2008-2010 Pivotal Labs
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-describe("SVG Spec in JavaScript", function() {
- /*Refer to W3C SVG1.1 (second edition)*/
- var doc, svg;
- beforeEach(function() {
- /*前もって実行しておく変数(The variable 'doc' is a document node, and the 'svg' is a root element node.)*/
- doc = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg");
- svg = doc.documentElement;
- });
- describe("SVG Unit :: SVG Length", function() {
- var s;
- beforeEach(function() {
- s = svg.createSVGLength();
- });
- /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGLength interface.)*/
- it("for the default value on the property of SVGLength", function() {
- /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGDocument
- * *createSVGLength()
- * *Creates an SVGLength object outside of any document trees. The object is initialized to the value of 0 user units.
- *see also http://www.w3.org/TR/SVG/types.html#InterfaceSVGLength
- * *SVG_LENGTHTYPE_NUMBER (unsigned short)
- * *No unit type was provided (i.e., a unitless value was specified), which indicates a value in user units.
- */
- expect(s.value).toEqual(0);
- expect(s.valueInSpecifiedUnits).toEqual(0);
- expect(s.unitType).toEqual(1);
- });
- /*境界条件を調べておく (limit value analysis)*/
- it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {
- var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];
- for (var i=0,tli=t.length;i<tli;++i) {
- s.newValueSpecifiedUnits(1, t[i]);
- expect(s.valueInSpecifiedUnits).toEqual(t[i]);
- expect(s.value).toEqual(t[i]);
- expect(s.valueAsString).toEqual(t[i]+"");
- expect(s.unitType).toEqual(1);
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- s.newValueSpecifiedUnits(1, t[i]);
- expect(s.valueInSpecifiedUnits).toEqual(t[i]);
- expect(s.value).toEqual(t[i]);
- expect(s.valueAsString).toEqual(t[i]+"");
- expect(s.unitType).toEqual(1);
- }
- t = null;
- });
- /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- s.newValueSpecifiedUnits(ti, 0);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a convertToSpecifiedUnits method", function() {
- var unit = ["", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"];
- for (var i=1,tli=11;i<tli;++i) {
- s.convertToSpecifiedUnits(i);
- expect(s.valueInSpecifiedUnits).toEqual(0);
- expect(s.value).toEqual(0);
- expect(s.valueAsString).toEqual("0" + unit[i-1]);
- expect(s.unitType).toEqual(i);
- }
- /*2cmにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"mm"単位に変換する。
- * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.
- */
- s.newValueSpecifiedUnits(6, 2);
- var sv = s.value;
- s.convertToSpecifiedUnits(7);
- expect(s.valueInSpecifiedUnits).toEqual(20);
- expect(s.value).toEqual(sv);
- expect(s.valueAsString).toEqual("20mm");
- expect(s.unitType).toEqual(7);
- unit = sv = null;
- });
- /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- s.convertToSpecifiedUnits(ti);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- });
- describe("SVG Unit :: SVG Matrix", function() {
- var s;
- beforeEach(function() {
- s = svg.createSVGMatrix();
- });
- it("for the default value on the property of SVGMatrix", function() {
- /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement
- * *The object is initialized to the identity matrix.
- *以下では、createSVGElementが単位行列を返しているかどうかをチェック
- */
- expect(s.a).toEqual(1);
- expect(s.b).toEqual(0);
- expect(s.c).toEqual(0);
- expect(s.d).toEqual(1);
- expect(s.e).toEqual(0);
- expect(s.f).toEqual(0);
- });
- /*境界条件を調べておく (limit value analysis about a 'multiply')*/
- it("should be this for the value, when it calls a 'multiply' method", function() {
- var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE, 0];
- for (var i=0,tli=t.length;i<tli;++i) {
- var n = svg.createSVGMatrix();
- n.a = t[i];
- n.b = t[i];
- n.c = t[i];
- n.d = t[i];
- n.e = t[i];
- s.multiply(n);
- n = null;
- }
- t = null;
- });
- it("should return the SVGMatrix Object, when it calls a 'multiply' method", function() {
- var t = s.multiply(svg.createSVGMatrix());
- expect(t.a).toEqual(1);
- expect(t.b).toEqual(0);
- expect(t.c).toEqual(0);
- expect(t.d).toEqual(1);
- expect(t.e).toEqual(0);
- expect(t.f).toEqual(0);
- /*See http://www.w3.org/TR/SVG/coords.html#InterfaceSVGMatrix
- * *..returning the resulting new matrix.
- *以下では新しいSVGMatrixオブジェクトを返しているかどうかをチェック
- */
- expect(t).toNotBe(s);
- var u = svg.createSVGMatrix();
- t.a = u.a = 2;
- t.b = u.b = 2;
- t.c = u.c = 2;
- t.d = u.d = 2;
- t.e = u.e = 2;
- t.f = u.f = 2;
- var m = t.multiply(u);
- expect(m.a).toEqual(8);
- expect(m.b).toEqual(8);
- expect(m.c).toEqual(8);
- expect(m.d).toEqual(8);
- expect(m.e).toEqual(10);
- expect(m.f).toEqual(10);
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var n = svg.createSVGMatrix(), ti = t[i];
- n.a = ti;
- n.b = ti;
- n.c = ti;
- n.d = ti;
- n.e = ti;
- n.f = ti;
- var d = s.multiply(n);
- /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/
- expect(d.a).toEqual(ti);
- expect(d.b).toEqual(ti);
- expect(d.c).toEqual(ti);
- expect(d.d).toEqual(ti);
- expect(d.e).toEqual(ti);
- expect(d.f).toEqual(ti);
- n = d = null;
- }
- t = null;
- });
- /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw an Error, when it calls a 'multiply' method", function() {
- var t = [Number.NEGATIVE_INFINITY,
- Number.POSITIVE_INFINITY,
- Number.NaN,
- undefined];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- var n = svg.createSVGMatrix();
- n.a = 0;
- n.b = 0;
- n.c = 0;
- n.d = 0;
- n.e = 0;
- n.f = ti;
- s.multiply(n);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- /*逆行列に関する境界条件を調べておく (limit value analysis about a 'inverse')*/
- it("should be this for the value, when it calls a 'inverse' method ((limit value analysis)", function() {
- var si = s.inverse(), t = [s.multiply(si), si.multiply(s)];
- s.a = -1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.a = 1;
- s.d = -1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.b = -1;
- s.c = 1;
- s.d = 1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.b = 1;
- s.c = -1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- for (var i=0;i<t.length;++i) {
- var d = t[i];
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- d = null;
- }
- si = t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'inverse' method (Equivalence partitioning, the following is the valid partion)", function() {
- var si = s.inverse(), t = [];
- s.a = -1;
- s.e = 0;
- s.f = 1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.a = 1;
- s.d = -1;
- s.e = 10000;
- s.f = -10000;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.b = -1;
- s.c = 1;
- s.d = 1;
- s.e = 0.0001;
- s.f = -0.0001;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- s.b = 1;
- s.c = -1;
- s.d = 1;
- s.e = 0.1;
- s.f = 1;
- si = s.inverse();
- t[t.length] = s.multiply(si);
- t[t.length] = si.multiply(s);
- for (var i=0;i<t.length;++i) {
- var d = t[i];
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- d = null;
- }
- si = t = null;
- });
- it("should throw an Error, when it calls a 'inverse' method", function() {
- /*以下では行列式が0なので、逆行列が成り立たない (it is invalid in these cases because the determint is zero)*/
- var t = [1, 1, 1, 1,
- 0, 0, 0, 0,
- 2, 4, 2, 4,
- 2.5, -1, 2.5, -1];
- for (var i=0;i<t.length;i+=4) {
- s.a = t[i];
- s.b = t[i+1];
- s.c = t[i+2];
- s.d = t[i+3]
- };
- expect(s.inverse).toThrow();
- t = null;
- });
- /*併進変換に関する境界条件を調べておく (limit value analysis about the 'translate')*/
- it("should be this for the value, when it calls the 'translate' method", function() {
- var t = [0, 0,
- -1, 0,
- 1, -1,
- Number.MAX_VALUE, Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.translate(t[i], t[i+1]);
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(t[i]);
- expect(d.f).toEqual(t[i+1]);
- expect(d).toNotBe(s);
- }
- });
- /*伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scale')*/
- it("should be this for the value, when it calls the 'scale' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.scale(t[i]);
- expect(d.a).toEqual(t[i]);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(t[i]);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*比率の違う伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scaleNonUniform')*/
- it("should be this for the value, when it calls the 'scaleNonUniform' method", function() {
- var t = [0, 0,
- -1, 0,
- 1, -1,
- Number.MAX_VALUE, Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.scaleNonUniform(t[i], t[i+1]);
- expect(d.a).toEqual(t[i]);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(t[i+1]);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*回転変換に関する境界条件を調べておく (limit value analysis about the 'rotate')*/
- it("should be this for the value, when it calls the 'rotate' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.rotate(t[i]);
- expect(d.a).toEqual(Math.cos(t[i] / 180 * Math.PI));
- expect(d.b).toEqual(Math.sin(t[i] / 180 * Math.PI));
- expect(d.c).toEqual(-Math.sin(t[i] / 180 * Math.PI));
- expect(d.d).toEqual(Math.cos(t[i] / 180 * Math.PI));
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*座標指定による回転変換に関する境界条件を調べておく (limit value analysis about the 'rotateFromVector')*/
- it("should be this for the value, when it calls the 'rotateFromVector'", function() {
- var t = [1, 1,
- -1, -1,
- 1, -1,
- -1, 1,
- Number.MAX_VALUE, Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.rotateFromVector(t[i], t[i+1]);
- expect(d.a).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));
- expect(d.b).toEqual(Math.sin(Math.atan2(t[i+1], t[i])));
- expect(d.c).toEqual(-Math.sin(Math.atan2(t[i+1], t[i])));
- expect(d.d).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*座標指定による回転変換に関して同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw an SVG Invalid Value Error, when it calls the 'rotateFromVector' method", function() {
- var t = [0,
- Number.NEGATIVE_INFINITY,
- Number.POSITIVE_INFINITY,
- Number.NaN,
- undefined];
- for (var i=0;i<t.length;++i) {
- var f = function() {
- var d = s.rotateFromVector(t[i], 1);
- }
- expect(f).toThrow();
- f = function() {
- var d = s.rotateFromVector(1, t[i]);
- }
- expect(f).toThrow();
- }
- t = f = null;
- });
- /*x軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipX')*/
- it("should be this for the value, when it calls the 'flipX' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.a = t[i];
- s.d = t[i];
- var d = s.flipX();
- expect(d.a).toEqual(-t[i]);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(t[i]);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*y軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipY')*/
- it("should be this for the value, when it calls the 'flipY' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.a = t[i];
- s.d = t[i];
- var d = s.flipY();
- expect(d.a).toEqual(t[i]);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(-t[i]);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*横の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewX')*/
- it("should be this for the value, when it calls the 'skewX' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.skewX(t[i]);
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(Math.tan(t[i] / 180 * Math.PI));
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- /*縦の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewY')*/
- it("should be this for the value, when it calls the 'skewY' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE];
- for (var i=0;i<t.length;i+=2) {
- var d = s.skewY(t[i]);
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(Math.tan(t[i] / 180 * Math.PI));
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- expect(d).toNotBe(s);
- }
- });
- });
- describe("SVG Unit :: SVG Transform", function() {
- var s;
- beforeEach(function() {
- s = svg.createSVGTransform();
- });
- it("for the default value on the property of SVGTransform", function() {
- /*5.11.2 Interface SVGSVGElement
- *http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement
- *
- * *The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX).
- */
- expect(s.type).toEqual(1); //SVG_TRANSFORM_MATRIX = 1
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- d = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setMatrix')*/
- it("should be this for the value, when it calls the 'setMatrix' method", function() {
- /*7.14.4 Interface SVGTransform
- *http://www.w3.org/TR/SVG/coords.html#InterfaceSVGTransform
- *
- * *void setMatrix(in SVGMatrix matrix)
- * *values from the parameter matrix are copied, the matrix parameter does not replace SVGTransform::matrix.
- */
- var m = svg.createSVGMatrix(), t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- m.a = t[i];
- m.b = t[i];
- m.c = t[i];
- m.d = t[i];
- m.e = t[i];
- m.f = t[i];
- s.setMatrix(m);
- expect(s.type).toEqual(1);
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- expect(d).toNotBe(m);
- }
- d = m = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setMatrix' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var n = svg.createSVGMatrix(), ti = t[i];
- n.a = ti;
- n.b = ti;
- n.c = ti;
- n.d = ti;
- n.e = ti;
- n.f = ti;
- s.setMatrix(n);
- s.setMatrix(n); //二重に指定しても問題はないはず (No problem is to call the 'setMatirx' method twice)
- expect(s.type).toEqual(1);
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/
- expect(d.a).toEqual(ti);
- expect(d.b).toEqual(ti);
- expect(d.c).toEqual(ti);
- expect(d.d).toEqual(ti);
- expect(d.e).toEqual(ti);
- expect(d.f).toEqual(ti);
- expect(d).toNotBe(n);
- n = d = null;
- }
- t = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setTranslate')*/
- it("should be this for the value, when it calls the 'setTranslate' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.setTranslate(t[i], t[i]);
- expect(s.type).toEqual(2); //SVG_TRANSFORM_TRANSLATE = 2
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(t[i]);
- expect(d.f).toEqual(t[i]);
- }
- d = m = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setTranslate' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i];
- s.setTranslate(ti, ti);
- s.setTranslate(ti, ti);
- expect(s.type).toEqual(2);
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(1);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(1);
- expect(d.e).toEqual(ti);
- expect(d.f).toEqual(ti);
- ti = n = d = null;
- }
- t = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setScale')*/
- it("should be this for the value, when it calls the 'setScale' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.setScale(t[i], t[i]);
- expect(s.type).toEqual(3); //SVG_TRANSFORM_SCALE = 3
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(t[i]);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(t[i]);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- }
- d = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setScale' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i];
- s.setScale(ti, ti);
- s.setScale(ti, ti);
- expect(s.type).toEqual(3);
- expect(s.angle).toEqual(0);
- var d = s.matrix;
- expect(d.a).toEqual(ti);
- expect(d.b).toEqual(0);
- expect(d.c).toEqual(0);
- expect(d.d).toEqual(ti);
- expect(d.e).toEqual(0);
- expect(d.f).toEqual(0);
- ti = n = d = null;
- }
- t = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setRotate')*/
- it("should be this for the value, when it calls the 'setRotate' method", function() {
- var t = [0,
- -1,
- 1];
- for (var i=0;i<t.length;++i) {
- s.setRotate(10, t[i], t[i]);
- var m = svg.createSVGMatrix();
- m = m.rotate(10);
- m.e = (1-m.a)*t[i] - m.c*t[i];
- m.f = -m.b*t[i] + (1-m.d)*t[i];
- expect(s.type).toEqual(4); //SVG_TRANSFORM_ROTATE = 4
- expect(s.angle).toEqual(10);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- }
- d = m = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setRotate' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], m = svg.createSVGMatrix();
- m = m.rotate(10);
- m.e = (1-m.a)*ti - m.c*ti;
- m.f = -m.b*ti + (1-m.d)*ti;
- s.setRotate(10, ti, ti);
- s.setRotate(10, ti, ti);
- expect(s.type).toEqual(4);
- expect(s.angle).toEqual(10);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- ti = n = d = null;
- }
- t = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setSkewX')*/
- it("should be this for the value, when it calls the 'setSkewX' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.setSkewX(t[i]);
- var m = svg.createSVGMatrix();
- m = m.skewX(t[i]);
- expect(s.type).toEqual(5); //SVG_TRANSFORM_SKEWX = 5
- expect(s.angle).toEqual(t[i]);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setSkewX' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], m = svg.createSVGMatrix();
- m = m.skewX(ti);
- s.setSkewX(ti);
- s.setSkewX(ti);
- expect(s.type).toEqual(5);
- expect(s.angle).toEqual(ti);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- ti = n = d = null;
- }
- t = null;
- });
- /*境界条件を調べておく (limit value analysis about the 'setSkewY')*/
- it("should be this for the value, when it calls the 'setSkewY' method", function() {
- var t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE];
- for (var i=0;i<t.length;++i) {
- s.setSkewY(t[i]);
- var m = svg.createSVGMatrix();
- m = m.skewY(t[i]);
- expect(s.type).toEqual(6); //SVG_TRANSFORM_SKEWY = 6
- expect(s.angle).toEqual(t[i]);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a 'setSkewY' method", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], m = svg.createSVGMatrix();
- m = m.skewY(ti);
- s.setSkewY(ti);
- s.setSkewY(ti);
- expect(s.type).toEqual(6);
- expect(s.angle).toEqual(ti);
- var d = s.matrix;
- expect(d.a).toEqual(m.a);
- expect(d.b).toEqual(m.b);
- expect(d.c).toEqual(m.c);
- expect(d.d).toEqual(m.d);
- expect(d.e).toEqual(m.e);
- expect(d.f).toEqual(m.f);
- ti = n = d = null;
- }
- t = null;
- });
- });
- describe("SVG Unit :: SVGNumber", function() {
- var s;
- beforeEach(function() {
- s = svg.createSVGNumber();
- });
- /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/
- it("for the default value on the property of SVGNumber", function() {
- expect(s.value).toEqual(0);
- });
- });
- describe("SVG Unit :: SVGAngle", function() {
- var s;
- beforeEach(function() {
- s = svg.createSVGAngle();
- });
- /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/
- it("for the default value on the property of SVGAngle", function() {
- expect(s.value).toEqual(0);
- expect(s.valueInSpecifiedUnits).toEqual(0);
- expect(s.unitType).toEqual(1);
- });
- /*境界条件を調べておく (limit value analysis)*/
- it("should be this for the value, when it calls a newValueSpecifiedUnits method (limit value analysis)", function() {
- var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];
- for (var i=0,tli=t.length;i<tli;++i) {
- s.newValueSpecifiedUnits(1, t[i]);
- expect(s.valueInSpecifiedUnits).toEqual(t[i]);
- expect(s.value).toEqual(t[i]);
- expect(s.valueAsString).toEqual(t[i]+"");
- expect(s.unitType).toEqual(1);
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a newValueSpecifiedUnits method (the valid partion)", function() {
- var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- s.newValueSpecifiedUnits(1, t[i]);
- expect(s.valueInSpecifiedUnits).toEqual(t[i]);
- expect(s.value).toEqual(t[i]);
- expect(s.valueAsString).toEqual(t[i]+"");
- expect(s.unitType).toEqual(1);
- }
- t = null;
- });
- /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method (the invalid partion)", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i],
- sn = function() {
- s.newValueSpecifiedUnits(ti, 0);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a convertToSpecifiedUnits method (the valid partion)", function() {
- var unit = ["", "deg", "rad", "grad"];
- for (var i=1,tli=4;i<tli;++i) {
- s.convertToSpecifiedUnits(i);
- expect(s.valueInSpecifiedUnits).toEqual(0);
- expect(s.value).toEqual(0);
- expect(s.valueAsString).toEqual("0" + unit[i-1]);
- expect(s.unitType).toEqual(i);
- }
- /*2gradにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"deg"単位に変換する。
- * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.
- */
- s.newValueSpecifiedUnits(4, 2);
- var sv = s.value;
- s.convertToSpecifiedUnits(2);
- expect(s.valueInSpecifiedUnits).toEqual(1.8);
- expect(s.value).toEqual(sv);
- expect(s.valueAsString).toEqual("1.8deg");
- expect(s.unitType).toEqual(2);
- unit = sv = null;
- });
- /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method (the invalid partion)", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- s.convertToSpecifiedUnits(ti);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- });
- describe("SVG Unit :: SVGColor (the SVGColor interface is deprecated by W3C)", function() {
- /*SVGColorインターフェースは廃止予定 (The SVGColor interface is deprecated by W3C.)*/
- var s;
- beforeEach(function() {
- svg.style.setProperty("stop-color", "white")
- s = svg.style.getPropertyCSSValue("stop-color"); //stop-colorプロパティはSVGColor型オブジェクトを返す
- });
- /*デフォルト値かどうかをチェックしていく(Checking the default value of the SVGColor interface.)*/
- it("for the default value on the property of SVGColor", function() {
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);
- expect(s.colorType).toEqual(1);
- });
- /*境界条件を調べておく (limit value analysis, when it calls a setRGBColor method)*/
- it("should be this for the value, when it calls a setRGBColor method (limit value analysis)", function() {
- var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];
- for (var i=0;i<5;++i) {
- /*すべて黒色を示す値 (All value indicate a black color)*/
- s.setRGBColor(cls[i]);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);
- expect(s.colorType).toEqual(1);
- }
- for (var i=5;i<10;++i) {
- /*すべて白色を示す値 (All value indicate a white color)*/
- s.setRGBColor(cls[i]);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);
- expect(s.colorType).toEqual(1);
- }
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setRGBColor method)*/
- it("should be this for the value, when it calls a setRGBColor method (the valid partion)", function() {
- var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];
- for (var i=0;i<3;++i) {
- /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/
- s.setRGBColor(cls[i]);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);
- expect(s.colorType).toEqual(1);
- }
- for (var i=3;i<8;++i) {
- /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/
- s.setRGBColor(cls[i]);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);
- expect(s.colorType).toEqual(1);
- }
- s.setRGBColor("rgb(20%, 40%, 99%)");
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);
- expect(s.colorType).toEqual(1);
- });
- /*setRGBColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setRGBColor method (the invalid partion)", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- s.setRGBColor(ti);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- t = null;
- });
- /*setColorメソッドの境界条件を調べておく (limit value analysis, when it calls a setColor method)*/
- it("should be this for the value, when it calls a setColor method (limit value analysis)", function() {
- var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];
- for (var i=0;i<5;++i) {
- /*すべて黒色を示す値 (All value indicate a black color)*/
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);
- expect(s.colorType).toEqual(1);
- }
- for (var i=5;i<10;++i) {
- /*すべて白色を示す値 (All value indicate a white color)*/
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);
- expect(s.colorType).toEqual(1);
- }
- s.setColor(/*SVG_COLORTYPE_CURRENTCOLOR*/ 3, null, null);
- expect(s.colorType).toEqual(3);
- });
- /*setColorメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setColor method)*/
- it("should be this for the value, when it calls a setColor method (the valid partion)", function() {
- var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];
- for (var i=0;i<3;++i) {
- /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);
- expect(s.colorType).toEqual(1);
- }
- for (var i=3;i<8;++i) {
- /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);
- expect(s.colorType).toEqual(1);
- }
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, "rgb(20%, 40%, 99%)", null);
- expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);
- expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);
- expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);
- expect(s.colorType).toEqual(1);
- });
- /*setColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
- it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setColor method (the invalid partion)", function() {
- var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];
- var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i], sn = function() {
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ti, null);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- for (var i=0,tli=cls.length;i<tli;++i) {
- var ci = cls[i], sn = function() {
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ci, ci);
- };
- expect(sn).toThrow();
- ci = sn = null;
- }
- for (var i=0,tli=cls.length;i<tli;++i) {
- var ci = cls[i], sn = function() {
- s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, null, ci);
- };
- expect(sn).toThrow();
- ci = sn = null;
- }
- for (var i=0,tli=t.length,ci=cls[0];i<tli;++i) {
- var ti = t[i], sn = function() {
- s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, null, ti);
- s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, ci, ti);
- };
- expect(sn).toThrow();
- ti = sn = null;
- }
- for (var i=0,tli=cls.length;i<tli;++i) {
- var ci = cls[i], sn = function() {
- s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, null);
- s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, ci);
- };
- expect(sn).toThrow();
- ci = sn = null;
- }
- t = cls = null;
- });
- });
- describe("SVG Unit :: SVG Point", function() {
- /*http://www.w3.org/TR/SVG/coords.html#InterfaceSVGPoint
- * 7.15.1 Interface SVGPoint
- * An SVGPoint is an (x, y) coordinate pair.
- */
- var s;
- beforeEach(function() {
- s = svg.createSVGPoint();
- });
- it("for the default value on the property of SVGPoint", function() {
- /*http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement
- * SVGPoint createSVGPoint()
- * 'The object is initialized to the point (0,0) in the user coordinate system.'
- */
- expect(s.x).toEqual(0);
- expect(s.y).toEqual(0);
- });
- /*境界条件を調べておく (limit value analysis, when it calls a matrixTransform method)*/
- it("should be this for the value, when it calls a matrixTransform method (limit value analysis)", function() {
- var matrix = svg.createSVGMatrix(), t = [0,
- -1,
- 1,
- Number.MAX_VALUE,
- Number.MIN_VALUE,
- -Number.MIN_VALUE],
- n;
- for (var i=0;i<t.length;++i) {
- matrix.a = t[i];
- matrix.c = t[i];
- n = s.matrixTransform(matrix);
- expect(n.x).toEqual(0);
- expect(n.y).toEqual(0);
- }
- for (var i=0;i<t.length;++i) {
- matrix.e = t[i];
- matrix.f = t[i];
- n = s.matrixTransform(matrix);
- expect(n.x).toEqual(t[i]);
- expect(n.y).toEqual(t[i]);
- }
- });
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a matrixTransform method (the valid partion)", function() {
- var matrix = svg.createSVGMatrix(),
- t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく
- for (var i=1;i<num;++i) {
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- t[t.length] = Math.pow(10, i);
- t[t.length] = Math.pow(10, -i);
- }
- for (var i=0,tli=t.length;i<tli;++i) {
- matrix.a = t[i];
- matrix.c = t[i];
- n = s.matrixTransform(matrix);
- expect(n.x).toEqual(0);
- expect(n.y).toEqual(0);
- }
- for (var i=0;i<t.length;++i) {
- matrix.e = t[i];
- matrix.f = t[i];
- n = s.matrixTransform(matrix);
- expect(n.x).toEqual(t[i]);
- expect(n.y).toEqual(t[i]);
- }
- });
- /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should throw a Error, when it calls a matrixTransform method (the invalid partion)", function() {
- var matrix = svg.createSVGMatrix(),
- t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}];
- for (var i=0,tli=t.length;i<tli;++i) {
- var ti = t[i],
- sn = function() {
- s.matrixTransform(ti);
- },
- stn = function() {
- s.matrixTransform();
- },
- an = function() {
- matrix.a = ti;
- s.matrixTransform(matrix);
- },
- bn = function() {
- matrix.a = 0;
- matrix.b = ti;
- s.matrixTransform(matrix);
- },
- cn = function() {
- matrix.b = 0;
- matrix.c = ti;
- s.matrixTransform(matrix);
- },
- dn = function() {
- matrix.c = 0;
- matrix.d = ti;
- s.matrixTransform(matrix);
- },
- en = function() {
- matrix.d = 0;
- matrix.e = ti;
- s.matrixTransform(matrix);
- },
- fn = function() {
- matrix.e = 0;
- matrix.f = ti;
- s.matrixTransform(matrix);
- console.log(ti);
- };
- expect(sn).toThrow();
- expect(stn).toThrow();
- expect(an).toThrow();
- expect(bn).toThrow();
- expect(cn).toThrow();
- expect(dn).toThrow();
- expect(en).toThrow();
- expect(fn).toThrow();
- ti = sn = an = bn = cn = dn = en = fn = null;
- }
- });
- });
- describe("SVG Element :: SVG TextContent Element", function() {
- var s;
- beforeEach(function() {
- s = doc.createElementNS("http://www.w3.org/2000/svg", "text");
- });
- /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGTextContentElement interface.)*/
- it("for the default value on the property of SVGTextContentElement", function() {
- expect(s.getAttributeNS(null, "textLength")).toBeNull();
- expect(s.getNumberOfChars()).toEqual(0);
- });
- /*境界条件を調べておく (limit value analysis)*/
- it("should be this for the value(limit value analysis)", function() {
- var t = [0,
- 1,
- 1000000],
- str = "";
- for (var i=0;i<t.length;++i) {
- /*文字列の生成 (created a string for the test)*/
- for (var j=0, ti=t[i];j<ti;++j) {
- str += "nん";
- }
- s.appendChild(s.ownerDocument.createTextNode(str));
- expect(s.getNumberOfChars()).toEqual(s.firstChild.length);
- s.removeChild(s.firstChild);
- s.appendChild(s.ownerDocument.createElementNS("http://sie.sourceforge.jp", "hoge"))
- .appendChild(s.ownerDocument.createTextNode(str));
- expect(s.getNumberOfChars()).toEqual(s.firstChild.firstChild.length);
- s.removeChild(s.firstChild);
- str = "";
- }
- });
- });
- describe("DOM level 2 Core :: Node", function() {
- var s;
- beforeEach(function() {
- s = doc.createElementNS("http://www.w3.org/2000/svg", "text");
- t = doc.createElementNS("http://sie.sourceforge.jp/", "hoge");
- });
- /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Node interface.)*/
- it("for the default value on the property of Node", function() {
- expect(s.firstChild).toBeNull();
- expect(s.lastChild).toBeNull();
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- });
- /*insertBeforeメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/
- it("should be this for the value, when it calls a insertBefore method (limit value analysis)", function() {
- s.insertBefore(t, null);
- expect(s.firstChild).toEqual(t)
- expect(s.lastChild).toEqual(t)
- expect(s.childNodes.item(0)).toEqual(t)
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s)
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
-
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.insertBefore(u, null);
- s.insertBefore(t, u);
- expect(s.firstChild).toEqual(t);
- expect(s.lastChild).toEqual(u);
- expect(s.childNodes.item(0)).toEqual(t);
- expect(s.childNodes.item(1)).toEqual(u);
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s)
- expect(t.nextSibling).toEqual(u);
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
-
- u.insertBefore(t, null);
- expect(s.firstChild).toEqual(u);
- expect(s.lastChild).toEqual(u);
- expect(s.childNodes.item(0)).toEqual(u);
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(u.firstChild).toEqual(t);
- expect(u.lastChild).toEqual(t);
- expect(u.childNodes.item(0)).toEqual(t);
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.parentNode).toEqual(s);
- expect(t.parentNode).toEqual(u)
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- u = void 0;
- });
- /*appendChildメソッドの境界条件を調べておく (limit value analysis, when it calls a appendChild method)*/
- it("should be this for the value, when it calls a appendChild method (limit value analysis)", function() {
- s.appendChild(t);
- expect(s.firstChild).toEqual(t);
- expect(s.lastChild).toEqual(t);
- expect(s.childNodes.item(0)).toEqual(t);
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s);
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- });
- /*removeChildメソッドの境界条件を調べておく (limit value analysis, when it calls a removeChild method)*/
- it("should be this for the value, when it calls a removeChild method (limit value analysis)", function() {
- s.insertBefore(t, null);
- s.removeChild(t);
- expect(s.firstChild).toBeNull();
- expect(s.lastChild).toBeNull();
- expect(s.childNodes.item(0)).toBeNull();
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toBeNull();
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- });
- /*replaceChildメソッドの境界条件を調べておく (limit value analysis, when it calls a replaceChild method)*/
- it("should be this for the value, when it calls a replaceChild method (limit value analysis)", function() {
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.insertBefore(t, null);
- s.replaceChild(u, t);
- expect(s.firstChild).toEqual(u)
- expect(s.lastChild).toEqual(u)
- expect(s.childNodes.item(0)).toEqual(u)
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(u.parentNode).toEqual(s)
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.firstChild).toBeNull();
- expect(u.lastChild).toBeNull();
- expect(t.parentNode).toBeNull();
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- });
- /*hasChildNodesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasChildNodes method)*/
- it("should be this for the value, when it calls a hasChildNodes method (limit value analysis)", function() {
- expect(s.hasChildNodes()).toEqual(false);
- s.appendChild(t);
- expect(s.hasChildNodes()).toEqual(true);
- s.removeChild(t);
- expect(s.hasChildNodes()).toEqual(false);
- });
- /*cloneNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a cloneNode method)*/
- it("should be this for the value, when it calls a cloneNode method (limit value analysis)", function() {
- s.appendChild(t);
- var u = s.cloneNode(false),
- v = s.cloneNode(true);
- expect(u).toNotBe(s);
- expect(u.firstChild).toBeNull();
- expect(u.lastChild).toBeNull();
- expect(u.childNodes.item(0)).toBeNull();
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.parentNode).toBeNull();
- expect(v).toNotBe(s);
- expect(v.hasChildNodes()).toEqual(true);
- expect(v.firstChild.parentNode).toEqual(v);
- expect(v.lastChild.parentNode).toEqual(v);
- expect(v.childNodes.item(0).parentNode).toEqual(v);
- expect(v.nextSibling).toBeNull();
- expect(v.previousSibling).toBeNull();
- expect(v.parentNode).toBeNull();
- });
- /*normalizeメソッドの境界条件を調べておく (limit value analysis, when it calls a normalize method)*/
- it("should be this for the value, when it calls a normalize method (limit value analysis)", function() {
- var text, ttext,
- tle = [doc.createTextNode(""), doc.createTextNode("0"), doc.createTextNode("a")];
- s.normalize();
- expect(s.firstChild).toBeNull();
- expect(s.lastChild).toBeNull();
- s.appendChild(tle[0]);
- s.normalize();
- expect(s.firstChild).toNotBe(null);
- expect(s.lastChild).toNotBe(null);
- expect(s.firstChild.nodeValue).toEqual("");
- for (var i=0; i<tle.legnth-1; ++i) {
- text = tle[i],
- ttext = tle[i+1];
- s.appendChild(text);
- s.appendChild(ttext);
- expect(s.firstChild).toEqual(text);
- expect(s.lastChild).toEqual(ttext);
- s.norbalize();
- expect(s.firstChild.nodeValue).toEqual(text.nodeValue+ttext.nodeValue);
- expect(s.firstChild).toNotBe(text);
- expect(s.lastChild).toNotBe(ttext);
- }
- });
- /*hasAttributesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasAttributes method)*/
- it("should be this for the value, when it calls a hasAttributes method (limit value analysis)", function() {
- expect(s.hasAttributes()).toEqual(false);
- s.setAttributeNS(null, "a", "b");
- expect(s.hasAttributes()).toEqual(true);
- expect(t.hasAttributes()).toEqual(false);
- t.setAttributeNS(null, "c", "d");
- expect(t.hasAttributes()).toEqual(true);
- });
-
- /*insertBeforeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a insertBefore method (the valid partion)", function() {
- var ti = [10, 500, 1000];
- for (var i=0;i<ti.length;++i) {
- for (var j=0,tili=ti[i];j<tili;++j) {
- s.insertBefore(t, null);
- }
- }
- expect(s.firstChild).toEqual(t)
- expect(s.lastChild).toEqual(t)
- expect(s.childNodes.item(0)).toEqual(t)
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s)
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
-
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.insertBefore(u, null);
- for (var i=0;i<ti.length;++i) {
- for (var j=0,tili=ti[i];j<tili;++j) {
- s.insertBefore(t, u);
- }
- }
- expect(s.firstChild).toEqual(t);
- expect(s.lastChild).toEqual(u);
- expect(s.childNodes.item(0)).toEqual(t);
- expect(s.childNodes.item(1)).toEqual(u);
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s)
- expect(t.nextSibling).toEqual(u);
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
-
- for (var i=0;i<ti.length;++i) {
- for (var j=0,tili=ti[i];j<tili;++j) {
- u.insertBefore(t, null);
- }
- }
- expect(s.firstChild).toEqual(u);
- expect(s.lastChild).toEqual(u);
- expect(s.childNodes.item(0)).toEqual(u);
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(u.firstChild).toEqual(t);
- expect(u.lastChild).toEqual(t);
- expect(u.childNodes.item(0)).toEqual(t);
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.parentNode).toEqual(s);
- expect(t.parentNode).toEqual(u)
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- u = void 0;
- });
- /*appendChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a appendChild method (the valid partion)", function() {
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.appendChild(t);
- s.appendChild(u);
- expect(s.firstChild).toEqual(t)
- expect(s.lastChild).toEqual(u)
- expect(s.childNodes.item(0)).toEqual(t)
- expect(s.childNodes.item(1)).toEqual(u)
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toEqual(s);
- expect(t.nextSibling).toEqual(u);
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- expect(u.parentNode).toEqual(s);
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toEqual(t);
- expect(u.firstChild).toBeNull();
- expect(u.lastChild).toBeNull();
- u = void 0;
- });
- /*removeChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a removeChild method (the valid partion)", function() {
- s.insertBefore(t, null);
- s.removeChild(t);
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.appendChild(u);
- s.removeChild(u);
- expect(s.firstChild).toBeNull();
- expect(s.lastChild).toBeNull();
- expect(s.childNodes.item(0)).toBeNull();
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toBeNull();
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- for (var i=0;i<100;++i) {
- s.appendChild(u);
- s.removeChild(u);
- }
- expect(s.firstChild).toBeNull();
- expect(s.lastChild).toBeNull();
- expect(s.childNodes.item(0)).toBeNull();
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(t.parentNode).toBeNull();
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- u = void 0;
- });
- /*replaceChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a replaceChild method (the valid partion)", function() {
- var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");
- s.insertBefore(t, null);
- s.replaceChild(u, t);
- s.replaceChild(t, u);
- s.replaceChild(u, t);
- expect(s.firstChild).toEqual(u)
- expect(s.lastChild).toEqual(u)
- expect(s.childNodes.item(0)).toEqual(u)
- expect(s.nextSibling).toBeNull();
- expect(s.previousSibling).toBeNull();
- expect(s.parentNode).toBeNull();
- expect(u.parentNode).toEqual(s)
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.firstChild).toBeNull();
- expect(u.lastChild).toBeNull();
- expect(t.parentNode).toBeNull();
- expect(t.nextSibling).toBeNull();
- expect(t.previousSibling).toBeNull();
- expect(t.firstChild).toBeNull();
- expect(t.lastChild).toBeNull();
- });
- /*hasChildNodesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a hasChildNodes method (the valid partion)", function() {
- for (var i=0;i<10;++i) {
- s.appendChild(t);
- expect(s.hasChildNodes()).toEqual(true);
- s.appendChild(t);
- expect(s.hasChildNodes()).toEqual(true);
- s.removeChild(t);
- expect(s.hasChildNodes()).toEqual(false);
- }
- });
- /*cloneNodeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a cloneNode method (the valid partion)", function() {
- s.appendChild(t);
- var u = s.cloneNode(false),
- v = s.cloneNode(true);
- for (var i=0;i<10;++i) {
- u = u.cloneNode(false);
- v = v.cloneNode(true);
- }
- expect(u).toNotBe(s);
- expect(u.firstChild).toBeNull();
- expect(u.lastChild).toBeNull();
- expect(u.childNodes.item(0)).toBeNull();
- expect(u.nextSibling).toBeNull();
- expect(u.previousSibling).toBeNull();
- expect(u.parentNode).toBeNull();
- expect(v).toNotBe(s);
- expect(v.hasChildNodes()).toEqual(true);
- expect(v.firstChild.parentNode).toEqual(v);
- expect(v.lastChild.parentNode).toEqual(v);
- expect(v.childNodes.item(0).parentNode).toEqual(v);
- expect(v.nextSibling).toBeNull();
- expect(v.previousSibling).toBeNull();
- expect(v.parentNode).toBeNull();
- });
- /*hasAttributesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
- it("should be this for the value, when it calls a hasAttributes method (the valid partion)", function() {
- s.setAttributeNS(null, "a", "b");
- s.setAttributeNS(null, "c", "b");
- expect(s.hasAttributes()).toEqual(true);
- });
-
- /*insertBeforeメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should be this for the value, when it calls a insertBefore method (the invalid partion)", function() {
- var sn = function() {
- s.insertBefore(t, null);
- /*HIERARCHY_REQUEST_ERR DOMException */
- t.insertBefore(s, null);
- },
- tn = function() {
- /*WRONG_DOCUMENT_ERR DOMException*/
- s.insertBefore(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), null);
- },
- un = function() {
- /*NOT_FOUND_ERR DOMException*/
- s.insertBefore(t, t.cloneNode(false));
- };
- expect(sn).toThrow();
- expect(tn).toThrow();
- expect(un).toThrow();
- });
- /*appendChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should be this for the value, when it calls a appendChild method (the invalid partion)", function() {
- var sn = function() {
- s.appendChild(t);
- /*HIERARCHY_REQUEST_ERR DOMException */
- t.appendChild(s);
- },
- tn = function() {
- /*WRONG_DOCUMENT_ERR DOMException*/
- s.appendChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));
- };
- expect(sn).toThrow();
- expect(tn).toThrow();
- });
- /*removeChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should be this for the value, when it calls a removeChild method (the invalid partion)", function() {
- var sn = function() {
- s.removeChild(s.cloneNode(false));
- },
- tn = function() {
- /*NOT_FOUND_ERR DOMException*/
- s.removeChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));
- };
- expect(sn).toThrow();
- expect(tn).toThrow();
- });
- /*replaceChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/
- it("should be this for the value, when it calls a replaceChild method (the invalid partion)", function() {
- s.appendChild(t);
- t.appendChild(t.cloneNode(false))
- var sn = function() {
- /*HIERARCHY_REQUEST_ERR DOMException */
- t.replaceChild(s, t.firstChild);
- },
- tn = function() {
- /*WRONG_DOCUMENT_ERR DOMException*/
- s.replaceChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), s.firstChild);
- },
- un = function() {
- /*NOT_FOUND_ERR DOMException*/
- s.replaceChild(t, t.cloneNode(false));
- };
- expect(sn).toThrow();
- expect(tn).toThrow();
- expect(un).toThrow();
- });
- });
- describe("DOM level 2 Core :: Document", function() {
- /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Document interface.)*/
- it("for the default value on the property of Document", function() {
- expect(doc.doctype).toBeNull();
- expect(doc.nodeName).toEqual("#document");
- expect(doc.nodeValue).toBeNull();
- expect(doc.attributes).toBeNull();
- expect(svg.ownerDocument).toEqual(doc);
- expect(svg.nodeName).toEqual("svg");
- expect(svg.namespaceURI).toEqual("http://www.w3.org/2000/svg");
- });
- /*getElementByIdメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementById method)*/
- it("should be this for the value, when it calls a getElementById method (limit value analysis)", function() {
- expect(doc.getElementById("a")).toBeNull();
- svg.setAttributeNS(null, "id", "a");
- expect(doc.getElementById("a")).toEqual(svg);
- svg.setAttributeNS(null, "id", "x");
- expect(doc.getElementById("a")).toBeNull();
- });
- /*getElementsByTagNameメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagName method)*/
- it("should be this for the value, when it calls a getElementsByTagName method (limit value analysis)", function() {
- expect(doc.getElementsByTagName("a")).toBeNull();
- });
- /*getElementsByTagNameNSメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagNameNS method)*/
- it("should be this for the value, when it calls a getElementsByTagNameNS method (limit value analysis)", function() {
- var ele = doc.createElementNS("http://www.w3.org/2000/svg", "a");
- expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "a")).toBeNull();
- expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "a")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "*").item(0)).toEqual(svg);
- expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "svg").item(0)).toEqual(svg);
- expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();
- svg.appendChild(ele);
- expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "a").item(0)).toEqual(ele);
- expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "a").item(0)).toEqual(ele);
- expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();
- expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();
- });
- /*importNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a importNode method)*/
- it("should be this for the value, when it calls a importNode method (limit value analysis)", function() {
- });
- });
+/*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
+ */\r
+/*\r
+ *Copyright (c) 2008-2010 Pivotal Labs\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining\r
+a copy of this software and associated documentation files (the\r
+"Software"), to deal in the Software without restriction, including\r
+without limitation the rights to use, copy, modify, merge, publish,\r
+distribute, sublicense, and/or sell copies of the Software, and to\r
+permit persons to whom the Software is furnished to do so, subject to\r
+the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be\r
+included in all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+describe("SVG Spec in JavaScript", function() {\r
+ /*Refer to W3C SVG1.1 (second edition)*/\r
+ var doc, svg;\r
+ beforeEach(function() {\r
+ /*前もって実行しておく変数(The variable 'doc' is a document node, and the 'svg' is a root element node.)*/\r
+ doc = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg");\r
+ svg = doc.documentElement;\r
+ });\r
+ describe("SVG Unit :: SVG Length", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGLength();\r
+ });\r
+ /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGLength interface.)*/\r
+ it("for the default value on the property of SVGLength", function() {\r
+ /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGDocument\r
+ * *createSVGLength()\r
+ * *Creates an SVGLength object outside of any document trees. The object is initialized to the value of 0 user units. \r
+ *see also http://www.w3.org/TR/SVG/types.html#InterfaceSVGLength\r
+ * *SVG_LENGTHTYPE_NUMBER (unsigned short)\r
+ * *No unit type was provided (i.e., a unitless value was specified), which indicates a value in user units.\r
+ */\r
+ expect(s.value).toEqual(0);\r
+ expect(s.valueInSpecifiedUnits).toEqual(0);\r
+ expect(s.unitType).toEqual(1);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {\r
+ var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ s.newValueSpecifiedUnits(1, t[i]);\r
+ expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
+ expect(s.value).toEqual(t[i]);\r
+ expect(s.valueAsString).toEqual(t[i]+"");\r
+ expect(s.unitType).toEqual(1);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ s.newValueSpecifiedUnits(1, t[i]);\r
+ expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
+ expect(s.value).toEqual(t[i]);\r
+ expect(s.valueAsString).toEqual(t[i]+"");\r
+ expect(s.unitType).toEqual(1);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.newValueSpecifiedUnits(ti, 0);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a convertToSpecifiedUnits method", function() {\r
+ var unit = ["", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"];\r
+ for (var i=1,tli=11;i<tli;++i) {\r
+ s.convertToSpecifiedUnits(i);\r
+ expect(s.valueInSpecifiedUnits).toEqual(0);\r
+ expect(s.value).toEqual(0);\r
+ expect(s.valueAsString).toEqual("0" + unit[i-1]);\r
+ expect(s.unitType).toEqual(i);\r
+ }\r
+ /*2cmにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"mm"単位に変換する。\r
+ * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.\r
+ */\r
+ s.newValueSpecifiedUnits(6, 2);\r
+ var sv = s.value;\r
+ s.convertToSpecifiedUnits(7);\r
+ expect(s.valueInSpecifiedUnits).toEqual(20);\r
+ expect(s.value).toEqual(sv);\r
+ expect(s.valueAsString).toEqual("20mm");\r
+ expect(s.unitType).toEqual(7);\r
+ unit = sv = null;\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.convertToSpecifiedUnits(ti);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ });\r
+ describe("SVG Unit :: SVG Matrix", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGMatrix();\r
+ });\r
+ it("for the default value on the property of SVGMatrix", function() {\r
+ /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
+ * *The object is initialized to the identity matrix.\r
+ *以下では、createSVGElementが単位行列を返しているかどうかをチェック\r
+ */\r
+ expect(s.a).toEqual(1);\r
+ expect(s.b).toEqual(0);\r
+ expect(s.c).toEqual(0);\r
+ expect(s.d).toEqual(1);\r
+ expect(s.e).toEqual(0);\r
+ expect(s.f).toEqual(0);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about a 'multiply')*/\r
+ it("should be this for the value, when it calls a 'multiply' method", function() {\r
+ var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE, 0];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var n = svg.createSVGMatrix();\r
+ n.a = t[i];\r
+ n.b = t[i];\r
+ n.c = t[i];\r
+ n.d = t[i];\r
+ n.e = t[i];\r
+ s.multiply(n);\r
+ n = null;\r
+ }\r
+ t = null;\r
+ });\r
+ it("should return the SVGMatrix Object, when it calls a 'multiply' method", function() {\r
+ var t = s.multiply(svg.createSVGMatrix());\r
+ expect(t.a).toEqual(1);\r
+ expect(t.b).toEqual(0);\r
+ expect(t.c).toEqual(0);\r
+ expect(t.d).toEqual(1);\r
+ expect(t.e).toEqual(0);\r
+ expect(t.f).toEqual(0);\r
+ /*See http://www.w3.org/TR/SVG/coords.html#InterfaceSVGMatrix\r
+ * *..returning the resulting new matrix. \r
+ *以下では新しいSVGMatrixオブジェクトを返しているかどうかをチェック\r
+ */\r
+ expect(t).toNotBe(s);\r
+ var u = svg.createSVGMatrix();\r
+ t.a = u.a = 2;\r
+ t.b = u.b = 2;\r
+ t.c = u.c = 2;\r
+ t.d = u.d = 2;\r
+ t.e = u.e = 2;\r
+ t.f = u.f = 2;\r
+ var m = t.multiply(u);\r
+ expect(m.a).toEqual(8);\r
+ expect(m.b).toEqual(8);\r
+ expect(m.c).toEqual(8);\r
+ expect(m.d).toEqual(8);\r
+ expect(m.e).toEqual(10);\r
+ expect(m.f).toEqual(10);\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var n = svg.createSVGMatrix(), ti = t[i];\r
+ n.a = ti;\r
+ n.b = ti;\r
+ n.c = ti;\r
+ n.d = ti;\r
+ n.e = ti;\r
+ n.f = ti;\r
+ var d = s.multiply(n);\r
+ /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/\r
+ expect(d.a).toEqual(ti);\r
+ expect(d.b).toEqual(ti);\r
+ expect(d.c).toEqual(ti);\r
+ expect(d.d).toEqual(ti);\r
+ expect(d.e).toEqual(ti);\r
+ expect(d.f).toEqual(ti);\r
+ n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw an Error, when it calls a 'multiply' method", function() {\r
+ var t = [Number.NEGATIVE_INFINITY,\r
+ Number.POSITIVE_INFINITY,\r
+ Number.NaN,\r
+ undefined];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ var n = svg.createSVGMatrix();\r
+ n.a = 0;\r
+ n.b = 0;\r
+ n.c = 0;\r
+ n.d = 0;\r
+ n.e = 0;\r
+ n.f = ti;\r
+ s.multiply(n);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*逆行列に関する境界条件を調べておく (limit value analysis about a 'inverse')*/\r
+ it("should be this for the value, when it calls a 'inverse' method ((limit value analysis)", function() {\r
+ var si = s.inverse(), t = [s.multiply(si), si.multiply(s)];\r
+ s.a = -1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.a = 1;\r
+ s.d = -1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.b = -1;\r
+ s.c = 1;\r
+ s.d = 1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.b = 1;\r
+ s.c = -1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ for (var i=0;i<t.length;++i) {\r
+ var d = t[i];\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ d = null;\r
+ }\r
+ si = t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'inverse' method (Equivalence partitioning, the following is the valid partion)", function() {\r
+ var si = s.inverse(), t = [];\r
+ s.a = -1;\r
+ s.e = 0;\r
+ s.f = 1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.a = 1;\r
+ s.d = -1;\r
+ s.e = 10000;\r
+ s.f = -10000;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.b = -1;\r
+ s.c = 1;\r
+ s.d = 1;\r
+ s.e = 0.0001;\r
+ s.f = -0.0001;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ s.b = 1;\r
+ s.c = -1;\r
+ s.d = 1;\r
+ s.e = 0.1;\r
+ s.f = 1;\r
+ si = s.inverse();\r
+ t[t.length] = s.multiply(si);\r
+ t[t.length] = si.multiply(s);\r
+ for (var i=0;i<t.length;++i) {\r
+ var d = t[i];\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ d = null;\r
+ }\r
+ si = t = null;\r
+ });\r
+ it("should throw an Error, when it calls a 'inverse' method", function() {\r
+ /*以下では行列式が0なので、逆行列が成り立たない (it is invalid in these cases because the determint is zero)*/\r
+ var t = [1, 1, 1, 1,\r
+ 0, 0, 0, 0,\r
+ 2, 4, 2, 4,\r
+ 2.5, -1, 2.5, -1];\r
+ for (var i=0;i<t.length;i+=4) {\r
+ s.a = t[i];\r
+ s.b = t[i+1];\r
+ s.c = t[i+2];\r
+ s.d = t[i+3];\r
+ };\r
+ expect(s.inverse).toThrow();\r
+ t = null;\r
+ });\r
+ /*併進変換に関する境界条件を調べておく (limit value analysis about the 'translate')*/\r
+ it("should be this for the value, when it calls the 'translate' method", function() {\r
+ var t = [0, 0,\r
+ -1, 0,\r
+ 1, -1,\r
+ Number.MAX_VALUE, Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.translate(t[i], t[i+1]);\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(t[i]);\r
+ expect(d.f).toEqual(t[i+1]);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scale')*/\r
+ it("should be this for the value, when it calls the 'scale' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.scale(t[i]);\r
+ expect(d.a).toEqual(t[i]);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(t[i]);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*比率の違う伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scaleNonUniform')*/\r
+ it("should be this for the value, when it calls the 'scaleNonUniform' method", function() {\r
+ var t = [0, 0,\r
+ -1, 0,\r
+ 1, -1,\r
+ Number.MAX_VALUE, Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.scaleNonUniform(t[i], t[i+1]);\r
+ expect(d.a).toEqual(t[i]);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(t[i+1]);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*回転変換に関する境界条件を調べておく (limit value analysis about the 'rotate')*/\r
+ it("should be this for the value, when it calls the 'rotate' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.rotate(t[i]);\r
+ expect(d.a).toEqual(Math.cos(t[i] / 180 * Math.PI));\r
+ expect(d.b).toEqual(Math.sin(t[i] / 180 * Math.PI));\r
+ expect(d.c).toEqual(-Math.sin(t[i] / 180 * Math.PI));\r
+ expect(d.d).toEqual(Math.cos(t[i] / 180 * Math.PI));\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*座標指定による回転変換に関する境界条件を調べておく (limit value analysis about the 'rotateFromVector')*/\r
+ it("should be this for the value, when it calls the 'rotateFromVector'", function() {\r
+ var t = [1, 1,\r
+ -1, -1,\r
+ 1, -1,\r
+ -1, 1,\r
+ Number.MAX_VALUE, Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.rotateFromVector(t[i], t[i+1]);\r
+ expect(d.a).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));\r
+ expect(d.b).toEqual(Math.sin(Math.atan2(t[i+1], t[i])));\r
+ expect(d.c).toEqual(-Math.sin(Math.atan2(t[i+1], t[i])));\r
+ expect(d.d).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ }\r
+ });\r
+ /*座標指定による回転変換に関して同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw an SVG Invalid Value Error, when it calls the 'rotateFromVector' method", function() {\r
+ var t = [0,\r
+ Number.NEGATIVE_INFINITY,\r
+ Number.POSITIVE_INFINITY,\r
+ Number.NaN,\r
+ undefined];\r
+ for (var i=0;i<t.length;++i) {\r
+ var f = function() {\r
+ var d = s.rotateFromVector(t[i], 1);\r
+ };\r
+ expect(f).toThrow();\r
+ f = function() {\r
+ var d = s.rotateFromVector(1, t[i]);\r
+ };\r
+ expect(f).toThrow();\r
+ }\r
+ t = f = null;\r
+ });\r
+ /*x軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipX')*/\r
+ it("should be this for the value, when it calls the 'flipX' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.a = t[i];\r
+ s.d = t[i];\r
+ var d = s.flipX();\r
+ expect(d.a).toEqual(-t[i]);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(t[i]);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*y軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipY')*/\r
+ it("should be this for the value, when it calls the 'flipY' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.a = t[i];\r
+ s.d = t[i];\r
+ var d = s.flipY();\r
+ expect(d.a).toEqual(t[i]);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(-t[i]);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*横の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewX')*/\r
+ it("should be this for the value, when it calls the 'skewX' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.skewX(t[i]);\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(Math.tan(t[i] / 180 * Math.PI));\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ /*縦の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewY')*/\r
+ it("should be this for the value, when it calls the 'skewY' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;i+=2) {\r
+ var d = s.skewY(t[i]);\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(Math.tan(t[i] / 180 * Math.PI));\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ expect(d).toNotBe(s);\r
+ } \r
+ });\r
+ });\r
+ describe("SVG Unit :: SVG Transform", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGTransform();\r
+ });\r
+ it("for the default value on the property of SVGTransform", function() {\r
+ /*5.11.2 Interface SVGSVGElement\r
+ *http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
+ *\r
+ * *The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX).\r
+ */\r
+ expect(s.type).toEqual(1); //SVG_TRANSFORM_MATRIX = 1\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ d = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setMatrix')*/\r
+ it("should be this for the value, when it calls the 'setMatrix' method", function() {\r
+ /*7.14.4 Interface SVGTransform\r
+ *http://www.w3.org/TR/SVG/coords.html#InterfaceSVGTransform\r
+ *\r
+ * *void setMatrix(in SVGMatrix matrix)\r
+ * *values from the parameter matrix are copied, the matrix parameter does not replace SVGTransform::matrix.\r
+ */\r
+ var m = svg.createSVGMatrix(), t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ m.a = t[i];\r
+ m.b = t[i];\r
+ m.c = t[i];\r
+ m.d = t[i];\r
+ m.e = t[i];\r
+ m.f = t[i];\r
+ s.setMatrix(m);\r
+ expect(s.type).toEqual(1);\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ expect(d).toNotBe(m);\r
+ }\r
+ d = m = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setMatrix' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var n = svg.createSVGMatrix(), ti = t[i];\r
+ n.a = ti;\r
+ n.b = ti;\r
+ n.c = ti;\r
+ n.d = ti;\r
+ n.e = ti;\r
+ n.f = ti;\r
+ s.setMatrix(n);\r
+ s.setMatrix(n); //二重に指定しても問題はないはず (No problem is to call the 'setMatirx' method twice)\r
+ expect(s.type).toEqual(1);\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/\r
+ expect(d.a).toEqual(ti);\r
+ expect(d.b).toEqual(ti);\r
+ expect(d.c).toEqual(ti);\r
+ expect(d.d).toEqual(ti);\r
+ expect(d.e).toEqual(ti);\r
+ expect(d.f).toEqual(ti);\r
+ expect(d).toNotBe(n);\r
+ n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setTranslate')*/\r
+ it("should be this for the value, when it calls the 'setTranslate' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.setTranslate(t[i], t[i]);\r
+ expect(s.type).toEqual(2); //SVG_TRANSFORM_TRANSLATE = 2\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(t[i]);\r
+ expect(d.f).toEqual(t[i]);\r
+ }\r
+ d = m = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setTranslate' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i];\r
+ s.setTranslate(ti, ti);\r
+ s.setTranslate(ti, ti);\r
+ expect(s.type).toEqual(2);\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(1);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(1);\r
+ expect(d.e).toEqual(ti);\r
+ expect(d.f).toEqual(ti);\r
+ ti = n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setScale')*/\r
+ it("should be this for the value, when it calls the 'setScale' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.setScale(t[i], t[i]);\r
+ expect(s.type).toEqual(3); //SVG_TRANSFORM_SCALE = 3\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(t[i]);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(t[i]);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ }\r
+ d = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setScale' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i];\r
+ s.setScale(ti, ti);\r
+ s.setScale(ti, ti);\r
+ expect(s.type).toEqual(3);\r
+ expect(s.angle).toEqual(0);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(ti);\r
+ expect(d.b).toEqual(0);\r
+ expect(d.c).toEqual(0);\r
+ expect(d.d).toEqual(ti);\r
+ expect(d.e).toEqual(0);\r
+ expect(d.f).toEqual(0);\r
+ ti = n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setRotate')*/\r
+ it("should be this for the value, when it calls the 'setRotate' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.setRotate(10, t[i], t[i]);\r
+ var m = svg.createSVGMatrix();\r
+ m = m.rotate(10);\r
+ m.e = (1-m.a)*t[i] - m.c*t[i];\r
+ m.f = -m.b*t[i] + (1-m.d)*t[i];\r
+ expect(s.type).toEqual(4); //SVG_TRANSFORM_ROTATE = 4\r
+ expect(s.angle).toEqual(10);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ }\r
+ d = m = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setRotate' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], m = svg.createSVGMatrix();\r
+ m = m.rotate(10);\r
+ m.e = (1-m.a)*ti - m.c*ti;\r
+ m.f = -m.b*ti + (1-m.d)*ti;\r
+ s.setRotate(10, ti, ti);\r
+ s.setRotate(10, ti, ti);\r
+ expect(s.type).toEqual(4);\r
+ expect(s.angle).toEqual(10);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ ti = n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setSkewX')*/\r
+ it("should be this for the value, when it calls the 'setSkewX' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.setSkewX(t[i]);\r
+ var m = svg.createSVGMatrix();\r
+ m = m.skewX(t[i]);\r
+ expect(s.type).toEqual(5); //SVG_TRANSFORM_SKEWX = 5\r
+ expect(s.angle).toEqual(t[i]);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setSkewX' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], m = svg.createSVGMatrix();\r
+ m = m.skewX(ti);\r
+ s.setSkewX(ti);\r
+ s.setSkewX(ti);\r
+ expect(s.type).toEqual(5);\r
+ expect(s.angle).toEqual(ti);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ ti = n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*境界条件を調べておく (limit value analysis about the 'setSkewY')*/\r
+ it("should be this for the value, when it calls the 'setSkewY' method", function() {\r
+ var t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE];\r
+ for (var i=0;i<t.length;++i) {\r
+ s.setSkewY(t[i]);\r
+ var m = svg.createSVGMatrix();\r
+ m = m.skewY(t[i]);\r
+ expect(s.type).toEqual(6); //SVG_TRANSFORM_SKEWY = 6\r
+ expect(s.angle).toEqual(t[i]);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a 'setSkewY' method", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], m = svg.createSVGMatrix();\r
+ m = m.skewY(ti);\r
+ s.setSkewY(ti);\r
+ s.setSkewY(ti);\r
+ expect(s.type).toEqual(6);\r
+ expect(s.angle).toEqual(ti);\r
+ var d = s.matrix;\r
+ expect(d.a).toEqual(m.a);\r
+ expect(d.b).toEqual(m.b);\r
+ expect(d.c).toEqual(m.c);\r
+ expect(d.d).toEqual(m.d);\r
+ expect(d.e).toEqual(m.e);\r
+ expect(d.f).toEqual(m.f);\r
+ ti = n = d = null;\r
+ }\r
+ t = null;\r
+ });\r
+ });\r
+ describe("SVG Unit :: SVGNumber", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGNumber();\r
+ });\r
+ /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/\r
+ it("for the default value on the property of SVGNumber", function() {\r
+ expect(s.value).toEqual(0);\r
+ });\r
+ });\r
+ describe("SVG Unit :: SVGAngle", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGAngle();\r
+ });\r
+ /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/\r
+ it("for the default value on the property of SVGAngle", function() {\r
+ expect(s.value).toEqual(0);\r
+ expect(s.valueInSpecifiedUnits).toEqual(0);\r
+ expect(s.unitType).toEqual(1);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value, when it calls a newValueSpecifiedUnits method (limit value analysis)", function() {\r
+ var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ s.newValueSpecifiedUnits(1, t[i]);\r
+ expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
+ expect(s.value).toEqual(t[i]);\r
+ expect(s.valueAsString).toEqual(t[i]+"");\r
+ expect(s.unitType).toEqual(1);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a newValueSpecifiedUnits method (the valid partion)", function() {\r
+ var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ s.newValueSpecifiedUnits(1, t[i]);\r
+ expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
+ expect(s.value).toEqual(t[i]);\r
+ expect(s.valueAsString).toEqual(t[i]+"");\r
+ expect(s.unitType).toEqual(1);\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method (the invalid partion)", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i],\r
+ sn = function() {\r
+ s.newValueSpecifiedUnits(ti, 0);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a convertToSpecifiedUnits method (the valid partion)", function() {\r
+ var unit = ["", "deg", "rad", "grad"];\r
+ for (var i=1,tli=4;i<tli;++i) {\r
+ s.convertToSpecifiedUnits(i);\r
+ expect(s.valueInSpecifiedUnits).toEqual(0);\r
+ expect(s.value).toEqual(0);\r
+ expect(s.valueAsString).toEqual("0" + unit[i-1]);\r
+ expect(s.unitType).toEqual(i);\r
+ }\r
+ /*2gradにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"deg"単位に変換する。\r
+ * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.\r
+ */\r
+ s.newValueSpecifiedUnits(4, 2);\r
+ var sv = s.value;\r
+ s.convertToSpecifiedUnits(2);\r
+ expect(s.valueInSpecifiedUnits).toEqual(1.8);\r
+ expect(s.value).toEqual(sv);\r
+ expect(s.valueAsString).toEqual("1.8deg");\r
+ expect(s.unitType).toEqual(2);\r
+ unit = sv = null;\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method (the invalid partion)", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.convertToSpecifiedUnits(ti);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ });\r
+ describe("SVG Unit :: SVGColor (the SVGColor interface is deprecated by W3C)", function() {\r
+ /*SVGColorインターフェースは廃止予定 (The SVGColor interface is deprecated by W3C.)*/\r
+ var s;\r
+ beforeEach(function() {\r
+ svg.style.setProperty("stop-color", "white");\r
+ s = svg.style.getPropertyCSSValue("stop-color"); //stop-colorプロパティはSVGColor型オブジェクトを返す\r
+ });\r
+ /*デフォルト値かどうかをチェックしていく(Checking the default value of the SVGColor interface.)*/\r
+ it("for the default value on the property of SVGColor", function() {\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
+ expect(s.colorType).toEqual(1);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis, when it calls a setRGBColor method)*/\r
+ it("should be this for the value, when it calls a setRGBColor method (limit value analysis)", function() {\r
+ var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];\r
+ for (var i=0;i<5;++i) {\r
+ /*すべて黒色を示す値 (All value indicate a black color)*/\r
+ s.setRGBColor(cls[i]);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ for (var i=5;i<10;++i) {\r
+ /*すべて白色を示す値 (All value indicate a white color)*/\r
+ s.setRGBColor(cls[i]);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setRGBColor method)*/\r
+ it("should be this for the value, when it calls a setRGBColor method (the valid partion)", function() {\r
+ var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
+ for (var i=0;i<3;++i) {\r
+ /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/\r
+ s.setRGBColor(cls[i]);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ for (var i=3;i<8;++i) {\r
+ /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/\r
+ s.setRGBColor(cls[i]);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ s.setRGBColor("rgb(20%, 40%, 99%)");\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);\r
+ expect(s.colorType).toEqual(1);\r
+ });\r
+ /*setRGBColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setRGBColor method (the invalid partion)", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.setRGBColor(ti);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ t = null;\r
+ });\r
+ /*setColorメソッドの境界条件を調べておく (limit value analysis, when it calls a setColor method)*/\r
+ it("should be this for the value, when it calls a setColor method (limit value analysis)", function() {\r
+ var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];\r
+ for (var i=0;i<5;++i) {\r
+ /*すべて黒色を示す値 (All value indicate a black color)*/\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ for (var i=5;i<10;++i) {\r
+ /*すべて白色を示す値 (All value indicate a white color)*/\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ s.setColor(/*SVG_COLORTYPE_CURRENTCOLOR*/ 3, null, null);\r
+ expect(s.colorType).toEqual(3);\r
+ });\r
+ /*setColorメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setColor method)*/\r
+ it("should be this for the value, when it calls a setColor method (the valid partion)", function() {\r
+ var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
+ for (var i=0;i<3;++i) {\r
+ /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ for (var i=3;i<8;++i) {\r
+ /*すべてgainsboro色を示す値 (All value indicate a gainsboro color)*/\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
+ expect(s.colorType).toEqual(1);\r
+ }\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, "rgb(20%, 40%, 99%)", null);\r
+ expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);\r
+ expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);\r
+ expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);\r
+ expect(s.colorType).toEqual(1);\r
+ });\r
+ /*setColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setColor method (the invalid partion)", function() {\r
+ var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
+ var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ti, null);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ for (var i=0,tli=cls.length;i<tli;++i) {\r
+ var ci = cls[i], sn = function() {\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ci, ci);\r
+ };\r
+ expect(sn).toThrow();\r
+ ci = sn = null;\r
+ }\r
+ for (var i=0,tli=cls.length;i<tli;++i) {\r
+ var ci = cls[i], sn = function() {\r
+ s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, null, ci);\r
+ };\r
+ expect(sn).toThrow();\r
+ ci = sn = null;\r
+ }\r
+ for (var i=0,tli=t.length,ci=cls[0];i<tli;++i) {\r
+ var ti = t[i], sn = function() {\r
+ s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, null, ti);\r
+ s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, ci, ti);\r
+ };\r
+ expect(sn).toThrow();\r
+ ti = sn = null;\r
+ }\r
+ for (var i=0,tli=cls.length;i<tli;++i) {\r
+ var ci = cls[i], sn = function() {\r
+ s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, null);\r
+ s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, ci);\r
+ };\r
+ expect(sn).toThrow();\r
+ ci = sn = null;\r
+ }\r
+ t = cls = null;\r
+ });\r
+ });\r
+ describe("SVG Unit :: SVG Point", function() {\r
+ /*http://www.w3.org/TR/SVG/coords.html#InterfaceSVGPoint\r
+ * 7.15.1 Interface SVGPoint\r
+ * An SVGPoint is an (x, y) coordinate pair.\r
+ */\r
+ var s;\r
+ beforeEach(function() {\r
+ s = svg.createSVGPoint();\r
+ });\r
+ it("for the default value on the property of SVGPoint", function() {\r
+ /*http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
+ * SVGPoint createSVGPoint()\r
+ * 'The object is initialized to the point (0,0) in the user coordinate system.'\r
+ */\r
+ expect(s.x).toEqual(0);\r
+ expect(s.y).toEqual(0);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis, when it calls a matrixTransform method)*/\r
+ it("should be this for the value, when it calls a matrixTransform method (limit value analysis)", function() {\r
+ var matrix = svg.createSVGMatrix(), t = [0,\r
+ -1,\r
+ 1,\r
+ Number.MAX_VALUE,\r
+ Number.MIN_VALUE,\r
+ -Number.MIN_VALUE],\r
+ n;\r
+ for (var i=0;i<t.length;++i) {\r
+ matrix.a = t[i];\r
+ matrix.c = t[i];\r
+ n = s.matrixTransform(matrix);\r
+ expect(n.x).toEqual(0);\r
+ expect(n.y).toEqual(0);\r
+ }\r
+ for (var i=0;i<t.length;++i) {\r
+ matrix.e = t[i];\r
+ matrix.f = t[i];\r
+ n = s.matrixTransform(matrix);\r
+ expect(n.x).toEqual(t[i]);\r
+ expect(n.y).toEqual(t[i]);\r
+ }\r
+ });\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a matrixTransform method (the valid partion)", function() {\r
+ var matrix = svg.createSVGMatrix(),\r
+ t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
+ for (var i=1;i<num;++i) {\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ t[t.length] = Math.pow(10, i);\r
+ t[t.length] = Math.pow(10, -i);\r
+ }\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ matrix.a = t[i];\r
+ matrix.c = t[i];\r
+ n = s.matrixTransform(matrix);\r
+ expect(n.x).toEqual(0);\r
+ expect(n.y).toEqual(0);\r
+ }\r
+ for (var i=0;i<t.length;++i) {\r
+ matrix.e = t[i];\r
+ matrix.f = t[i];\r
+ n = s.matrixTransform(matrix);\r
+ expect(n.x).toEqual(t[i]);\r
+ expect(n.y).toEqual(t[i]);\r
+ }\r
+ });\r
+ /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should throw a Error, when it calls a matrixTransform method (the invalid partion)", function() {\r
+ var matrix = svg.createSVGMatrix(),\r
+ t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}];\r
+ for (var i=0,tli=t.length;i<tli;++i) {\r
+ var ti = t[i],\r
+ sn = function() {\r
+ s.matrixTransform(ti);\r
+ },\r
+ stn = function() {\r
+ s.matrixTransform();\r
+ },\r
+ an = function() {\r
+ matrix.a = ti;\r
+ s.matrixTransform(matrix);\r
+ },\r
+ bn = function() {\r
+ matrix.a = 0;\r
+ matrix.b = ti;\r
+ s.matrixTransform(matrix);\r
+ },\r
+ cn = function() {\r
+ matrix.b = 0;\r
+ matrix.c = ti;\r
+ s.matrixTransform(matrix);\r
+ },\r
+ dn = function() {\r
+ matrix.c = 0;\r
+ matrix.d = ti;\r
+ s.matrixTransform(matrix);\r
+ },\r
+ en = function() {\r
+ matrix.d = 0;\r
+ matrix.e = ti;\r
+ s.matrixTransform(matrix);\r
+ },\r
+ fn = function() {\r
+ matrix.e = 0;\r
+ matrix.f = ti;\r
+ s.matrixTransform(matrix);\r
+ console.log(ti);\r
+ };\r
+ expect(sn).toThrow();\r
+ expect(stn).toThrow();\r
+ expect(an).toThrow();\r
+ expect(bn).toThrow();\r
+ expect(cn).toThrow();\r
+ expect(dn).toThrow();\r
+ expect(en).toThrow();\r
+ expect(fn).toThrow();\r
+ ti = sn = an = bn = cn = dn = en = fn = null;\r
+ }\r
+ });\r
+ });\r
+ describe("SVG Element :: SVG TextContent Element", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = doc.createElementNS("http://www.w3.org/2000/svg", "text");\r
+ });\r
+ /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGTextContentElement interface.)*/\r
+ it("for the default value on the property of SVGTextContentElement", function() {\r
+ expect(s.getAttributeNS(null, "textLength")).toBeNull();\r
+ expect(s.getNumberOfChars()).toEqual(0);\r
+ });\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value(limit value analysis)", function() {\r
+ var t = [0,\r
+ 1,\r
+ 1000000],\r
+ str = "";\r
+ for (var i=0;i<t.length;++i) {\r
+ /*文字列の生成 (created a string for the test)*/\r
+ for (var j=0, ti=t[i];j<ti;++j) {\r
+ str += "nん";\r
+ }\r
+ s.appendChild(s.ownerDocument.createTextNode(str));\r
+ expect(s.getNumberOfChars()).toEqual(s.firstChild.length);\r
+ s.removeChild(s.firstChild);\r
+ s.appendChild(s.ownerDocument.createElementNS("http://sie.sourceforge.jp", "hoge"))\r
+ .appendChild(s.ownerDocument.createTextNode(str));\r
+ expect(s.getNumberOfChars()).toEqual(s.firstChild.firstChild.length);\r
+ s.removeChild(s.firstChild);\r
+ str = "";\r
+ }\r
+ });\r
+ });\r
+ describe("DOM level 2 Core :: Node", function() {\r
+ var s;\r
+ beforeEach(function() {\r
+ s = doc.createElementNS("http://www.w3.org/2000/svg", "text");\r
+ t = doc.createElementNS("http://sie.sourceforge.jp/", "hoge");\r
+ });\r
+ /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Node interface.)*/\r
+ it("for the default value on the property of Node", function() {\r
+ expect(s.firstChild).toBeNull();\r
+ expect(s.lastChild).toBeNull();\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ });\r
+ /*insertBeforeメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/\r
+ it("should be this for the value, when it calls a insertBefore method (limit value analysis)", function() {\r
+ s.insertBefore(t, null);\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(t);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ \r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.insertBefore(u, null);\r
+ s.insertBefore(t, u);\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.childNodes.item(1)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toEqual(u);\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ \r
+ u.insertBefore(t, null);\r
+ expect(s.firstChild).toEqual(u);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(u.firstChild).toEqual(t);\r
+ expect(u.lastChild).toEqual(t);\r
+ expect(u.childNodes.item(0)).toEqual(t);\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.parentNode).toEqual(s);\r
+ expect(t.parentNode).toEqual(u);\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ u = void 0;\r
+ });\r
+ /*appendChildメソッドの境界条件を調べておく (limit value analysis, when it calls a appendChild method)*/\r
+ it("should be this for the value, when it calls a appendChild method (limit value analysis)", function() {\r
+ s.appendChild(t);\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(t);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ });\r
+ /*removeChildメソッドの境界条件を調べておく (limit value analysis, when it calls a removeChild method)*/\r
+ it("should be this for the value, when it calls a removeChild method (limit value analysis)", function() {\r
+ s.insertBefore(t, null);\r
+ s.removeChild(t);\r
+ expect(s.firstChild).toBeNull();\r
+ expect(s.lastChild).toBeNull();\r
+ expect(s.childNodes.item(0)).toBeNull();\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toBeNull();\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ });\r
+ /*replaceChildメソッドの境界条件を調べておく (limit value analysis, when it calls a replaceChild method)*/\r
+ it("should be this for the value, when it calls a replaceChild method (limit value analysis)", function() {\r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.insertBefore(t, null);\r
+ s.replaceChild(u, t);\r
+ expect(s.firstChild).toEqual(u);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(u.parentNode).toEqual(s);\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.firstChild).toBeNull();\r
+ expect(u.lastChild).toBeNull();\r
+ expect(t.parentNode).toBeNull();\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ });\r
+ /*hasChildNodesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasChildNodes method)*/\r
+ it("should be this for the value, when it calls a hasChildNodes method (limit value analysis)", function() {\r
+ expect(s.hasChildNodes()).toEqual(false);\r
+ s.appendChild(t);\r
+ expect(s.hasChildNodes()).toEqual(true);\r
+ s.removeChild(t);\r
+ expect(s.hasChildNodes()).toEqual(false);\r
+ });\r
+ /*cloneNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a cloneNode method)*/\r
+ it("should be this for the value, when it calls a cloneNode method (limit value analysis)", function() {\r
+ s.appendChild(t);\r
+ var u = s.cloneNode(false),\r
+ v = s.cloneNode(true);\r
+ expect(u).toNotBe(s);\r
+ expect(u.firstChild).toBeNull();\r
+ expect(u.lastChild).toBeNull();\r
+ expect(u.childNodes.item(0)).toBeNull();\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.parentNode).toBeNull();\r
+ expect(v).toNotBe(s);\r
+ expect(v.hasChildNodes()).toEqual(true);\r
+ expect(v.firstChild.parentNode).toEqual(v);\r
+ expect(v.lastChild.parentNode).toEqual(v);\r
+ expect(v.childNodes.item(0).parentNode).toEqual(v);\r
+ expect(v.nextSibling).toBeNull();\r
+ expect(v.previousSibling).toBeNull();\r
+ expect(v.parentNode).toBeNull();\r
+ });\r
+ /*normalizeメソッドの境界条件を調べておく (limit value analysis, when it calls a normalize method)*/\r
+ it("should be this for the value, when it calls a normalize method (limit value analysis)", function() {\r
+ var text, ttext,\r
+ tle = [doc.createTextNode(""), doc.createTextNode("0"), doc.createTextNode("a")];\r
+ s.normalize();\r
+ expect(s.firstChild).toBeNull();\r
+ expect(s.lastChild).toBeNull();\r
+ s.appendChild(tle[0]);\r
+ s.normalize();\r
+ expect(s.firstChild).toNotBe(null);\r
+ expect(s.lastChild).toNotBe(null);\r
+ expect(s.firstChild.nodeValue).toEqual("");\r
+ for (var i=0; i<tle.legnth-1; ++i) {\r
+ text = tle[i],\r
+ ttext = tle[i+1];\r
+ s.appendChild(text);\r
+ s.appendChild(ttext);\r
+ expect(s.firstChild).toEqual(text);\r
+ expect(s.lastChild).toEqual(ttext);\r
+ s.norbalize();\r
+ expect(s.firstChild.nodeValue).toEqual(text.nodeValue+ttext.nodeValue);\r
+ expect(s.firstChild).toNotBe(text);\r
+ expect(s.lastChild).toNotBe(ttext);\r
+ }\r
+ });\r
+ /*hasAttributesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasAttributes method)*/\r
+ it("should be this for the value, when it calls a hasAttributes method (limit value analysis)", function() {\r
+ expect(s.hasAttributes()).toEqual(false); \r
+ s.setAttributeNS(null, "a", "b");\r
+ expect(s.hasAttributes()).toEqual(true);\r
+ expect(t.hasAttributes()).toEqual(false); \r
+ t.setAttributeNS(null, "c", "d");\r
+ expect(t.hasAttributes()).toEqual(true);\r
+ });\r
+ \r
+ /*insertBeforeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a insertBefore method (the valid partion)", function() {\r
+ var ti = [10, 500, 1000];\r
+ for (var i=0;i<ti.length;++i) {\r
+ for (var j=0,tili=ti[i];j<tili;++j) {\r
+ s.insertBefore(t, null);\r
+ }\r
+ }\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(t);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ \r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.insertBefore(u, null);\r
+ for (var i=0;i<ti.length;++i) {\r
+ for (var j=0,tili=ti[i];j<tili;++j) {\r
+ s.insertBefore(t, u);\r
+ }\r
+ }\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.childNodes.item(1)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toEqual(u);\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ \r
+ for (var i=0;i<ti.length;++i) {\r
+ for (var j=0,tili=ti[i];j<tili;++j) {\r
+ u.insertBefore(t, null);\r
+ }\r
+ }\r
+ expect(s.firstChild).toEqual(u);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(u.firstChild).toEqual(t);\r
+ expect(u.lastChild).toEqual(t);\r
+ expect(u.childNodes.item(0)).toEqual(t);\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.parentNode).toEqual(s);\r
+ expect(t.parentNode).toEqual(u);\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ u = void 0;\r
+ });\r
+ /*appendChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a appendChild method (the valid partion)", function() {\r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.appendChild(t);\r
+ s.appendChild(u);\r
+ expect(s.firstChild).toEqual(t);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(t);\r
+ expect(s.childNodes.item(1)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toEqual(s);\r
+ expect(t.nextSibling).toEqual(u);\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ expect(u.parentNode).toEqual(s);\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toEqual(t);\r
+ expect(u.firstChild).toBeNull();\r
+ expect(u.lastChild).toBeNull();\r
+ u = void 0;\r
+ });\r
+ /*removeChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a removeChild method (the valid partion)", function() {\r
+ s.insertBefore(t, null);\r
+ s.removeChild(t);\r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.appendChild(u);\r
+ s.removeChild(u);\r
+ expect(s.firstChild).toBeNull();\r
+ expect(s.lastChild).toBeNull();\r
+ expect(s.childNodes.item(0)).toBeNull();\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toBeNull();\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ for (var i=0;i<100;++i) {\r
+ s.appendChild(u);\r
+ s.removeChild(u);\r
+ }\r
+ expect(s.firstChild).toBeNull();\r
+ expect(s.lastChild).toBeNull();\r
+ expect(s.childNodes.item(0)).toBeNull();\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(t.parentNode).toBeNull();\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ u = void 0;\r
+ });\r
+ /*replaceChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a replaceChild method (the valid partion)", function() {\r
+ var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
+ s.insertBefore(t, null);\r
+ s.replaceChild(u, t);\r
+ s.replaceChild(t, u);\r
+ s.replaceChild(u, t);\r
+ expect(s.firstChild).toEqual(u);\r
+ expect(s.lastChild).toEqual(u);\r
+ expect(s.childNodes.item(0)).toEqual(u);\r
+ expect(s.nextSibling).toBeNull();\r
+ expect(s.previousSibling).toBeNull();\r
+ expect(s.parentNode).toBeNull();\r
+ expect(u.parentNode).toEqual(s);\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.firstChild).toBeNull();\r
+ expect(u.lastChild).toBeNull();\r
+ expect(t.parentNode).toBeNull();\r
+ expect(t.nextSibling).toBeNull();\r
+ expect(t.previousSibling).toBeNull();\r
+ expect(t.firstChild).toBeNull();\r
+ expect(t.lastChild).toBeNull();\r
+ });\r
+ /*hasChildNodesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a hasChildNodes method (the valid partion)", function() {\r
+ for (var i=0;i<10;++i) {\r
+ s.appendChild(t);\r
+ expect(s.hasChildNodes()).toEqual(true);\r
+ s.appendChild(t);\r
+ expect(s.hasChildNodes()).toEqual(true);\r
+ s.removeChild(t);\r
+ expect(s.hasChildNodes()).toEqual(false);\r
+ }\r
+ });\r
+ /*cloneNodeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a cloneNode method (the valid partion)", function() {\r
+ s.appendChild(t);\r
+ var u = s.cloneNode(false),\r
+ v = s.cloneNode(true);\r
+ for (var i=0;i<10;++i) {\r
+ u = u.cloneNode(false);\r
+ v = v.cloneNode(true);\r
+ }\r
+ expect(u).toNotBe(s);\r
+ expect(u.firstChild).toBeNull();\r
+ expect(u.lastChild).toBeNull();\r
+ expect(u.childNodes.item(0)).toBeNull();\r
+ expect(u.nextSibling).toBeNull();\r
+ expect(u.previousSibling).toBeNull();\r
+ expect(u.parentNode).toBeNull();\r
+ expect(v).toNotBe(s);\r
+ expect(v.hasChildNodes()).toEqual(true);\r
+ expect(v.firstChild.parentNode).toEqual(v);\r
+ expect(v.lastChild.parentNode).toEqual(v);\r
+ expect(v.childNodes.item(0).parentNode).toEqual(v);\r
+ expect(v.nextSibling).toBeNull();\r
+ expect(v.previousSibling).toBeNull();\r
+ expect(v.parentNode).toBeNull();\r
+ });\r
+ /*hasAttributesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value, when it calls a hasAttributes method (the valid partion)", function() {\r
+ s.setAttributeNS(null, "a", "b");\r
+ s.setAttributeNS(null, "c", "b");\r
+ expect(s.hasAttributes()).toEqual(true);\r
+ });\r
+ \r
+ /*insertBeforeメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value, when it calls a insertBefore method (the invalid partion)", function() {\r
+ var sn = function() {\r
+ s.insertBefore(t, null);\r
+ /*HIERARCHY_REQUEST_ERR DOMException */\r
+ t.insertBefore(s, null);\r
+ },\r
+ tn = function() {\r
+ /*WRONG_DOCUMENT_ERR DOMException*/\r
+ s.insertBefore(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), null);\r
+ },\r
+ un = function() {\r
+ /*NOT_FOUND_ERR DOMException*/\r
+ s.insertBefore(t, t.cloneNode(false));\r
+ };\r
+ expect(sn).toThrow();\r
+ expect(tn).toThrow();\r
+ expect(un).toThrow();\r
+ });\r
+ /*appendChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value, when it calls a appendChild method (the invalid partion)", function() {\r
+ var sn = function() {\r
+ s.appendChild(t);\r
+ /*HIERARCHY_REQUEST_ERR DOMException */\r
+ t.appendChild(s);\r
+ },\r
+ tn = function() {\r
+ /*WRONG_DOCUMENT_ERR DOMException*/\r
+ s.appendChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));\r
+ };\r
+ expect(sn).toThrow();\r
+ expect(tn).toThrow();\r
+ });\r
+ /*removeChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value, when it calls a removeChild method (the invalid partion)", function() {\r
+ var sn = function() {\r
+ s.removeChild(s.cloneNode(false));\r
+ },\r
+ tn = function() {\r
+ /*NOT_FOUND_ERR DOMException*/\r
+ s.removeChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));\r
+ };\r
+ expect(sn).toThrow();\r
+ expect(tn).toThrow();\r
+ });\r
+ /*replaceChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value, when it calls a replaceChild method (the invalid partion)", function() {\r
+ s.appendChild(t);\r
+ t.appendChild(t.cloneNode(false));\r
+ var sn = function() {\r
+ /*HIERARCHY_REQUEST_ERR DOMException */\r
+ t.replaceChild(s, t.firstChild);\r
+ },\r
+ tn = function() {\r
+ /*WRONG_DOCUMENT_ERR DOMException*/\r
+ s.replaceChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), s.firstChild);\r
+ },\r
+ un = function() {\r
+ /*NOT_FOUND_ERR DOMException*/\r
+ s.replaceChild(t, t.cloneNode(false));\r
+ };\r
+ expect(sn).toThrow();\r
+ expect(tn).toThrow();\r
+ expect(un).toThrow();\r
+ });\r
+ });\r
+ describe("DOM level 2 Core :: Document", function() {\r
+ /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Document interface.)*/\r
+ it("for the default value on the property of Document", function() {\r
+ expect(doc.doctype).toBeNull();\r
+ expect(doc.nodeName).toEqual("#document");\r
+ expect(doc.nodeValue).toBeNull();\r
+ expect(doc.attributes).toBeNull();\r
+ expect(svg.ownerDocument).toEqual(doc);\r
+ expect(svg.nodeName).toEqual("svg");\r
+ expect(svg.namespaceURI).toEqual("http://www.w3.org/2000/svg");\r
+ });\r
+ /*getElementByIdメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementById method)*/\r
+ it("should be this for the value, when it calls a getElementById method (limit value analysis)", function() {\r
+ expect(doc.getElementById("a")).toBeNull();\r
+ svg.setAttributeNS(null, "id", "a");\r
+ expect(doc.getElementById("a")).toEqual(svg);\r
+ svg.setAttributeNS(null, "id", "x");\r
+ expect(doc.getElementById("a")).toBeNull();\r
+ });\r
+ /*getElementsByTagNameメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagName method)*/\r
+ it("should be this for the value, when it calls a getElementsByTagName method (limit value analysis)", function() {\r
+ expect(doc.getElementsByTagName("a")).toBeNull();\r
+ });\r
+ /*getElementsByTagNameNSメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagNameNS method)*/\r
+ it("should be this for the value, when it calls a getElementsByTagNameNS method (limit value analysis)", function() {\r
+ var ele = doc.createElementNS("http://www.w3.org/2000/svg", "a");\r
+ expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "a")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "a")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "*").item(0)).toEqual(svg);\r
+ expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "svg").item(0)).toEqual(svg);\r
+ expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
+ svg.appendChild(ele);\r
+ expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "a").item(0)).toEqual(ele);\r
+ expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "a").item(0)).toEqual(ele);\r
+ expect(doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
+ expect(doc.getElementsByTagNameNS("*", "b")).toBeNull(); \r
+ });\r
+ /*importNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a importNode method)*/\r
+ it("should be this for the value, when it calls a importNode method (limit value analysis)", function() {\r
+ });\r
+ });\r
});
\ No newline at end of file