فهرست منبع

tests for ColorConverter.js.

Ben Houston 12 سال پیش
والد
کامیت
80cc25941b

+ 35 - 0
test/unit/math/ColorConverter.js

@@ -0,0 +1,35 @@
+module( "ColorConverter" );
+
+
+test( "fromRGB", function(){
+    var c1 = new THREE.Color();
+    var c2 = new THREE.Color().setRGB( 0, 0.5, 1 );
+    THREE.ColorConverter.fromRGB( c1, 0, 0.5, 1 );
+    ok( c1.equals( c2 ), "Ok" );
+});
+
+test( "fromHex/toHex", function(){
+    var c1 = new THREE.Color();
+    var c2 = new THREE.Color().setHex( 0x11aaff );
+    THREE.ColorConverter.fromHex( c1, 0x11aaff );
+    ok( c1.equals( c2 ), "Ok" );
+    var hex = THREE.ColorConverter.toHex( c1 );
+    ok( hex === 0x11aaff, "Ok" );
+});
+
+test( "fromHSV/toHSV", function(){
+    var c1 = new THREE.Color();
+   var c2 = new THREE.Color().setHSL( 0.25, 0.5, 0.75 );
+    var hsv = THREE.ColorConverter.toHSV( c2 );
+    THREE.ColorConverter.fromHSV( c1, hsv.h, hsv.s, hsv.v );
+    ok( c1.equals( c2 ), "Ok" );
+});
+
+test( "fromHSL/toHSL", function(){
+    var c1 = new THREE.Color();
+    var c2 = new THREE.Color().setHSL( 0.25, 0.5, 0.75 );
+    var hsl = THREE.ColorConverter.toHSL( c2 );
+    THREE.ColorConverter.fromHSL( c1, hsl.h, hsl.s, hsl.l );
+    ok( c1.equals( c2 ), "Ok" );
+});
+

+ 2 - 0
test/unit/unittests_sources.html

@@ -28,6 +28,7 @@
   <script src="../../src/math/Sphere.js"></script>
   <script src="../../src/math/Math.js"></script>  
   <script src="../../src/math/Triangle.js"></script>
+  <script src="../../examples/js/math/ColorConverter.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -47,6 +48,7 @@
   <script src="math/Matrix4.js"></script>
   <script src="math/Frustum.js"></script>
   <script src="math/Color.js"></script>
+  <script src="math/ColorConverter.js"></script>
 
 </body>
 </html>

+ 3 - 1
test/unit/unittests_three-math.html

@@ -12,6 +12,7 @@
   <!-- add ThreeJS sources to test below -->
 
   <script src="../../build/three-math.js"></script>
+  <script src="../../examples/js/math/ColorConverter.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -30,6 +31,7 @@
   <script src="math/Matrix3.js"></script>
   <script src="math/Matrix4.js"></script>
   <script src="math/Frustum.js"></script>
-
+  <script src="math/ColorConverter.js"></script>
+  
 </body>
 </html>

+ 3 - 1
test/unit/unittests_three.html

@@ -12,6 +12,7 @@
   <!-- add ThreeJS sources to test below -->
 
   <script src="../../build/three.js"></script>
+  <script src="../../examples/js/math/ColorConverter.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -30,6 +31,7 @@
   <script src="math/Matrix3.js"></script>
   <script src="math/Matrix4.js"></script>
   <script src="math/Frustum.js"></script>
-
+  <script src="math/ColorConverter.js"></script>
+  
 </body>
 </html>

+ 3 - 1
test/unit/unittests_three.min.html

@@ -12,6 +12,7 @@
   <!-- add ThreeJS sources to test below -->
 
   <script src="../../build/three.min.js"></script>
+  <script src="../../examples/js/math/ColorConverter.js"></script>
 
   <!-- add class-based unit tests below -->
 
@@ -30,6 +31,7 @@
   <script src="math/Matrix3.js"></script>
   <script src="math/Matrix4.js"></script>
   <script src="math/Frustum.js"></script>
-
+  <script src="math/ColorConverter.js"></script>
+  
 </body>
 </html>