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

This commit is contained in:
rdb 2018-02-21 15:56:45 +01:00
parent 6c7894f68d
commit e0569815b5
2 changed files with 32 additions and 0 deletions

View File

@ -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)

View File

@ -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