aggiunti altri test
This commit is contained in:
parent
c23b113390
commit
8b94969bb6
4
Temp/scenario_init_20251015_141354_896.txt
Normal file
4
Temp/scenario_init_20251015_141354_896.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
4
Temp/scenario_init_20251015_141438_856.txt
Normal file
4
Temp/scenario_init_20251015_141438_856.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
4
Temp/scenario_init_20251015_141624_679.txt
Normal file
4
Temp/scenario_init_20251015_141624_679.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
4
Temp/scenario_init_20251015_141748_634.txt
Normal file
4
Temp/scenario_init_20251015_141748_634.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
4
Temp/scenario_init_20251015_141841_099.txt
Normal file
4
Temp/scenario_init_20251015_141841_099.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
4
Temp/scenario_init_20251015_141914_012.txt
Normal file
4
Temp/scenario_init_20251015_141914_012.txt
Normal file
@ -0,0 +1,4 @@
|
||||
pause
|
||||
aclatch
|
||||
acunlatch
|
||||
continue
|
||||
@ -42,3 +42,48 @@ def test_simulation_engine_start_stop(fake_communicator, fake_update_queue):
|
||||
assert engine.is_alive()
|
||||
engine._stop_event.set()
|
||||
engine.join(timeout=1)
|
||||
|
||||
|
||||
def test_set_time_multiplier(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
engine.set_time_multiplier(2.5)
|
||||
assert engine.time_multiplier == 2.5
|
||||
|
||||
|
||||
def test_set_update_interval(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
engine.set_update_interval(0.5)
|
||||
assert engine.update_interval_s == 0.5
|
||||
|
||||
|
||||
def test_pause_resume(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
engine.pause()
|
||||
assert engine._is_paused is True
|
||||
engine.resume()
|
||||
assert engine._is_paused is False
|
||||
|
||||
|
||||
def test_stop(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
engine.start()
|
||||
engine.stop()
|
||||
assert not engine.is_alive() or not engine.is_running()
|
||||
|
||||
|
||||
def test_set_simulation_time(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
scenario = Scenario(name="JumpScenario")
|
||||
t = Target(target_id=2, trajectory=[Waypoint(maneuver_type=ManeuverType.FLY_TO_POINT)])
|
||||
scenario.add_target(t)
|
||||
engine.load_scenario(scenario)
|
||||
engine.set_simulation_time(42.0)
|
||||
assert getattr(t, "_sim_time_s", None) == 42.0
|
||||
|
||||
|
||||
def test_is_running_flag(fake_communicator, fake_update_queue):
|
||||
engine = SimulationEngine(fake_communicator, fake_update_queue)
|
||||
assert not engine.is_running()
|
||||
engine.start()
|
||||
assert engine.is_running()
|
||||
engine.stop()
|
||||
|
||||
@ -8,3 +8,60 @@ def test_target_list_frame_init():
|
||||
frame = TargetListFrame(root)
|
||||
assert frame is not None
|
||||
root.destroy()
|
||||
|
||||
|
||||
def test_get_targets_returns_cache():
|
||||
root = tk.Tk()
|
||||
frame = TargetListFrame(root)
|
||||
frame.targets_cache = ["dummy_target"]
|
||||
assert frame.get_targets() == ["dummy_target"]
|
||||
root.destroy()
|
||||
|
||||
|
||||
def test_update_target_list_updates_cache():
|
||||
root = tk.Tk()
|
||||
frame = TargetListFrame(root)
|
||||
from target_simulator.core.models import Target
|
||||
t = Target(target_id=1)
|
||||
t.current_range_nm = 10.0
|
||||
t.current_azimuth_deg = 45.0
|
||||
t.current_velocity_fps = 100.0
|
||||
t.current_heading_deg = 90.0
|
||||
t.current_altitude_ft = 5000.0
|
||||
frame.update_target_list([t])
|
||||
assert frame.targets_cache == [t]
|
||||
root.destroy()
|
||||
|
||||
|
||||
def test_targets_changed_callback_called():
|
||||
root = tk.Tk()
|
||||
called = {}
|
||||
def cb(targets):
|
||||
called["ok"] = True
|
||||
frame = TargetListFrame(root, targets_changed_callback=cb)
|
||||
frame.targets_cache = []
|
||||
from target_simulator.core.models import Target
|
||||
t = Target(target_id=2)
|
||||
t.current_range_nm = 20.0
|
||||
t.current_azimuth_deg = 90.0
|
||||
t.current_velocity_fps = 200.0
|
||||
t.current_heading_deg = 180.0
|
||||
t.current_altitude_ft = 10000.0
|
||||
frame.update_target_list([t])
|
||||
if frame.targets_changed_callback:
|
||||
frame.targets_changed_callback(frame.targets_cache)
|
||||
assert called.get("ok")
|
||||
root.destroy()
|
||||
|
||||
|
||||
def test_on_remove_click_no_selection(monkeypatch):
|
||||
root = tk.Tk()
|
||||
frame = TargetListFrame(root)
|
||||
frame.tree.focus = lambda: ""
|
||||
called = {}
|
||||
def warn(title, msg, parent=None):
|
||||
called["warn"] = True
|
||||
monkeypatch.setattr("tkinter.messagebox.showwarning", warn)
|
||||
frame._on_remove_click()
|
||||
assert called.get("warn")
|
||||
root.destroy()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user