svnno****@sourc*****
svnno****@sourc*****
2011年 4月 19日 (火) 20:59:46 JST
Revision: 2614
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2614
Author: dhrname
Date: 2011-04-19 20:59:46 +0900 (Tue, 19 Apr 2011)
Log Message:
-----------
SVGColorインターフェースの有効同値クラスのテストを追加
Modified Paths:
--------------
trunk/Spec/spec/SvgDomSpec.js
Modified: trunk/Spec/spec/SvgDomSpec.js
===================================================================
--- trunk/Spec/spec/SvgDomSpec.js 2011-04-19 11:58:15 UTC (rev 2613)
+++ trunk/Spec/spec/SvgDomSpec.js 2011-04-19 11:59:46 UTC (rev 2614)
@@ -1006,17 +1006,64 @@
t = null;
});
});
- describe("SVG Unit :: SVGColor", function() {
- var s = [];
+ 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[s.length] = svg.style.getPropertyCSSValue("stop-color"); //SVGColor型オブジェクトを返す
+ s = svg.style.getPropertyCSSValue("stop-color"); //stop-colorプロパティはSVGColor型オブジェクトを返す
});
- /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGColor interface.)*/
+ /*デフォルト値かどうかをチェックしていく(Checking the default value of the SVGColor interface.)*/
it("for the default value on the property of SVGColor", function() {
- expect(typeof s.rgbColor.red.getFloatValue(2)).toEqual(0);
- expect(typeof s.rgbColor.green.getFloatValue(2)).toEqual(0);
- expect(typeof s.rgbColor.blue.getFloatValue(2)).toEqual(0);
+ 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);
+ });
});
});
\ No newline at end of file