Browse Source

tests: add test for prc page and one for light color temperature

rdb 7 năm trước cách đây
mục cha
commit
e0569815b5
2 tập tin đã thay đổi với 32 bổ sung0 xóa
  1. 20 0
      tests/pgraph/test_light.py
  2. 12 0
      tests/prc/test_config_page.py

+ 20 - 0
tests/pgraph/test_light.py

@@ -0,0 +1,20 @@
+from panda3d import core
+
+def luminance(col):
+    return 0.2126 * col[0] + 0.7152 * col[1] + 0.0722 * col[2]
+
+
+def test_light_colortemp():
+    # Default is all white, assuming a D65 white point.
+    light = core.PointLight("light")
+    assert light.color == (1, 1, 1, 1)
+    assert light.color_temperature == 6500
+
+    # When setting color temp, it should preserve luminance.
+    for temp in range(2000, 15000):
+        light.color_temperature = temp
+        assert abs(luminance(light.color) - 1.0) < 0.001
+
+    # Setting it to the white point will make a white color.
+    light.color_temperature = 6500
+    assert light.color.almost_equal((1, 1, 1, 1), 0.001)

+ 12 - 0
tests/prc/test_config_page.py

@@ -0,0 +1,12 @@
+from panda3d import core
+
+def test_load_unload_page():
+    var = core.ConfigVariableInt("test-var", 1)
+    assert var.value == 1
+
+    page = core.load_prc_file_data("test_load_unload_page", "test-var 2")
+    assert page
+    assert var.value == 2
+
+    assert core.unload_prc_file(page)
+    assert var.value == 1