svnno****@sourc*****
svnno****@sourc*****
2011年 4月 26日 (火) 20:49:57 JST
Revision: 2629 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2629 Author: dhrname Date: 2011-04-26 20:49:57 +0900 (Tue, 26 Apr 2011) Log Message: ----------- setRGBColorメソッドとsetColorメソッドにおけるさまざまなテストを追加 Modified Paths: -------------- trunk/Spec/spec/SvgDomSpec.js Modified: trunk/Spec/spec/SvgDomSpec.js =================================================================== --- trunk/Spec/spec/SvgDomSpec.js 2011-04-26 11:47:37 UTC (rev 2628) +++ trunk/Spec/spec/SvgDomSpec.js 2011-04-26 11:49:57 UTC (rev 2629) @@ -1065,5 +1065,76 @@ 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 'Not Supported Error', 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, cls[0], 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); + }); + /*setRGBColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/ + it("should throw a DOMException 'Not Supported Error', 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.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ti, null); + }; + expect(sn).toThrow(); + ti = sn = null; + } + t = null; + }); }); }); \ No newline at end of file