2023-05-23 19:06:25 +02:00
|
|
|
import pytest
|
|
|
|
from threading import Thread
|
|
|
|
|
|
|
|
from godot import Vector3, SurfaceTool, Mesh, MeshInstance
|
|
|
|
|
|
|
|
|
|
|
|
def test_simple_thread():
|
|
|
|
|
|
|
|
thread_said_hello = False
|
|
|
|
|
|
|
|
def target():
|
|
|
|
nonlocal thread_said_hello
|
|
|
|
thread_said_hello = True
|
|
|
|
|
|
|
|
t = Thread(target=target, daemon=True)
|
|
|
|
t.start()
|
|
|
|
|
|
|
|
t.join(timeout=1)
|
|
|
|
assert thread_said_hello
|
|
|
|
|
|
|
|
|
2023-06-02 11:05:45 +02:00
|
|
|
def test_use_pandemonium_from_thread():
|
2023-05-23 19:06:25 +02:00
|
|
|
def target():
|
|
|
|
st = SurfaceTool()
|
|
|
|
st.begin(Mesh.PRIMITIVE_TRIANGLES)
|
|
|
|
st.add_vertex(Vector3(-1, -1, 0))
|
|
|
|
st.add_vertex(Vector3(-1, 1, 0))
|
|
|
|
st.add_vertex(Vector3(1, 1, 0))
|
|
|
|
mesh = st.commit()
|
|
|
|
mi = MeshInstance.new()
|
|
|
|
mi.mesh = mesh
|
|
|
|
mi.free()
|
|
|
|
|
|
|
|
t = Thread(target=target, daemon=True)
|
|
|
|
t.start()
|
|
|
|
|
|
|
|
t.join(timeout=1)
|