Commit daa1d43e authored by Jan Möbius's avatar Jan Möbius

Python Test for Datacontrol

parent ff8e14a2
# Include Testing package
if(BUILD_TESTING)
include( ${CMAKE_SOURCE_DIR}/OpenFlipper/tests/testGenerators.cmake )
# ========================================================================
# ========================================================================
# Tests
# ========================================================================
# ========================================================================
run_local_script_test("dataType.ofp")
endif()
# Reset everything
core.clearAll()
defaultLights = 3 #define the default lights
# Create triangle mesh
id = primitivesgenerator.addSphere()
#
if datacontrol.dataType(id) != "TriangleMesh":
print("DataType failed.")
print("Object is a " + datacontrol.dataType(id) + ". But expected to be a \"TriangleMesh\"")
core.exitFailure()
else:
print("Datatype TriangleMesh is correct")
targetMeshes = datacontrol.getTargetObjects("TriangleMesh").size
if targetMeshes != 1 :
print("Unexpected number of TriangleMeshes")
print("Expected was 0, the results is "+ str(targetMeshes) )
core.exitFailure()
else:
print("Correct number of target meshes: " + str(targetMeshes))
# Target triangle mesh
datacontrol.setTarget(id,True)
targetMeshes = datacontrol.getTargetObjects("TriangleMesh").size
if targetMeshes!= 1 :
print("Unexpected number of TriangleMeshes")
print("Expected was 1, the results is " + str(targetMeshes) )
core.exitFailure()
else:
print("Target objects correct " + str(targetMeshes))
# Create lights
lightId = typelight.addDefaultLight("MyLight")
lightId2 =typelight.addDefaultLight("MyLight2")
if lightId == -1 or lightId2 == -1 :
print("Unable to create default lights")
core.exitFailure()
else:
print("Lights created.")
if datacontrol.dataType(lightId) != "Light":
print("DataType failed.")
print("Object is a "+datacontrol.dataType(lightId)+". Expected was \"Light\"")
core.exitFailure()
else:
print("Datatype light is correct")
# Set all target and check target counters
datacontrol.setAllTarget()
targetLights = datacontrol.getTargetObjects("Light").size
if targetLights != 2+defaultLights :
print("Unexpected number of lights")
print("Expected was 2, the results is "+ str(targetLights) )
core.exitFailure()
else:
print("Number of target counts is correct: " + str(targetLights))
# Delete one light and one triangle mesh
datacontrol.objectDelete(id)
datacontrol.objectDelete(lightId)
# Target count Lights again
targetLights = datacontrol.getTargetObjects("Light").size
if targetLights != 1+defaultLights :
print("Unexpected number of lights")
print("Expected was 1, the results is " + str(targetLights) )
core.exitFailure()
else:
print("Correct number of target lights: " + str(targetLights))
targetMeshes = datacontrol.getTargetObjects("TriangleMesh").size
if targetMeshes != 0 :
print("Unexpected number of TriangleMeshes")
print("Expected was 0, the results is "+ str(targetMeshes) )
core.exitFailure()
else:
print("Correct number of target meshes: " + str(targetMeshes))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment