- Export: Runtime-Bridge-Autoload und Skater-GLB samt Texturen einschließen, Editor-Addons ausschließen - tools/check_export.sh als headless Smoke-Test; ./tools/test.sh --export - RoutineFile: JSON-Format, atomare Saves, Whitelist für Legacy-.tres - Überschreibschutz für Speichern unter/Export, Session- und Autosave-Restore - Globaler Delete-Shortcut blockiert bei offenen Dialogen - Sync akzeptiert .json und Legacy-.tres, Konfliktnamen behalten die Endung - Tests für Dateiformat, Überschreiben, Session und Legacy-Schutz - Quality-Meilenstein mit 'Als Nächstes' und 'Danach' in der Roadmap
1723 lines
53 KiB
GDScript
1723 lines
53 KiB
GDScript
extends SceneTree
|
|
|
|
## Headless test for the whiteboard controller wiring. It instantiates the real
|
|
## scene, so it also verifies that toolbar nodes and unique names resolve.
|
|
##
|
|
## Run with:
|
|
## godot --headless --path rinkplanner --script res://tests/run_whiteboard_tests.gd
|
|
|
|
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
|
|
|
|
var _assertions: int = 0
|
|
var _failures: PackedStringArray = PackedStringArray()
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var scene := WhiteboardScene.instantiate()
|
|
var controller := scene as WhiteboardController
|
|
if controller != null:
|
|
controller.restore_autosave = false
|
|
controller.autosave_enabled = false
|
|
root.add_child(scene)
|
|
await process_frame
|
|
|
|
_check(controller != null, "whiteboard scene has a controller")
|
|
if controller == null:
|
|
_finish()
|
|
return
|
|
|
|
var routine := controller.get_routine()
|
|
var section := controller.get_active_section()
|
|
_check(routine != null, "controller owns a routine")
|
|
_check(section != null, "controller owns an active section")
|
|
_check(
|
|
routine != null and not routine.is_valid(),
|
|
"empty draft routine is not valid yet"
|
|
)
|
|
_check(
|
|
routine != null and _contains_error(routine.validate(), "at least one segment"),
|
|
"empty draft reports the missing segment"
|
|
)
|
|
_check(
|
|
controller.delete_segment_button.disabled,
|
|
"segment delete starts disabled without a selection"
|
|
)
|
|
|
|
var first := controller.add_segment(
|
|
Vector2(-20.0, -5.0),
|
|
Vector2(-5.0, -5.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
_check(
|
|
section.segments.size() == 1,
|
|
"add_segment appends to the active section"
|
|
)
|
|
_check(first.segment_id == "seg-001", "segment ids are generated")
|
|
_check_approx(first.get_length_m(), 15.0, "segment length comes from the curve")
|
|
_check_approx(
|
|
first.duration_seconds,
|
|
15.0 / WhiteboardController.DEFAULT_SPEED_MPS,
|
|
"segment duration is derived from the default speed"
|
|
)
|
|
_check(
|
|
first.direction == PathSegment.Direction.FORWARD,
|
|
"segment keeps the requested direction"
|
|
)
|
|
_check(
|
|
first.edge == PathSegment.Edge.OUTSIDE,
|
|
"segment keeps the requested edge"
|
|
)
|
|
|
|
var second := controller.add_segment(
|
|
Vector2(-5.0, -5.0),
|
|
Vector2(5.0, 5.0),
|
|
PathSegment.Direction.BACKWARD,
|
|
PathSegment.Edge.INSIDE
|
|
)
|
|
_check(
|
|
second.direction == PathSegment.Direction.BACKWARD,
|
|
"second segment can be backward"
|
|
)
|
|
_check(
|
|
second.edge == PathSegment.Edge.INSIDE,
|
|
"second segment can be inside"
|
|
)
|
|
|
|
var third := controller.add_segment(
|
|
Vector2(25.0, 10.0),
|
|
Vector2(40.0, 20.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.INSIDE
|
|
)
|
|
_check(
|
|
routine.rink.contains_point(third.curve.get_point_position(1)),
|
|
"segments drawn beyond the boards are clamped to the rink"
|
|
)
|
|
_check(routine.is_valid(), "routine stays valid after adding three segments")
|
|
_check(
|
|
controller.status_label.text.contains("3 Segmente"),
|
|
"status bar reports the segment count"
|
|
)
|
|
|
|
controller.undo()
|
|
routine = controller.get_routine()
|
|
section = controller.get_active_section()
|
|
_check(
|
|
section.segments.size() == 2,
|
|
"undo removes the last segment"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("2 Segmente"),
|
|
"status bar updates after undo"
|
|
)
|
|
|
|
var fourth := controller.add_segment(
|
|
Vector2(0.0, -10.0),
|
|
Vector2(10.0, -10.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
_check(fourth.segment_id == "seg-003", "segment ids are reused after undo")
|
|
_check(routine.is_valid(), "routine stays valid after undo and redraw")
|
|
|
|
var canvas := controller.rink_canvas
|
|
_check(
|
|
canvas.size.x > 0.0 and canvas.size.y > 0.0,
|
|
"canvas receives a layout size"
|
|
)
|
|
|
|
var view := canvas.get_view_transform()
|
|
var segment_count_before := section.segments.size()
|
|
_mouse_button(canvas, view.model_to_screen(Vector2(-15.0, 5.0)), true)
|
|
_mouse_motion(canvas, view.model_to_screen(Vector2(-5.0, 5.0)))
|
|
_mouse_button(canvas, view.model_to_screen(Vector2(-5.0, 5.0)), false)
|
|
|
|
_check(
|
|
section.segments.size() == segment_count_before + 1,
|
|
"mouse drag creates a segment through the controller"
|
|
)
|
|
var dragged := section.segments[section.segments.size() - 1]
|
|
_check_approx(dragged.get_length_m(), 10.0, "dragged segment uses the drag distance")
|
|
_check(
|
|
dragged.direction == PathSegment.Direction.FORWARD,
|
|
"dragged segment uses the active direction"
|
|
)
|
|
_check(
|
|
dragged.edge == PathSegment.Edge.OUTSIDE,
|
|
"dragged segment uses the active edge"
|
|
)
|
|
|
|
var tap_point := view.model_to_screen(Vector2(0.0, 10.0))
|
|
var count_before_tap := section.segments.size()
|
|
_mouse_button(canvas, tap_point, true)
|
|
_mouse_button(canvas, tap_point, false)
|
|
_check(
|
|
section.segments.size() == count_before_tap,
|
|
"a tap without drag does not create a segment"
|
|
)
|
|
|
|
var arc_left := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(10.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE,
|
|
WhiteboardController.Tool.ARC_LEFT
|
|
)
|
|
_check(arc_left.curve.point_count > 2, "arc template samples a curve")
|
|
_check(
|
|
arc_left.get_length_m() > 20.0,
|
|
"arc is longer than its straight chord"
|
|
)
|
|
var arc_left_mid := arc_left.curve.sample_baked(arc_left.get_length_m() * 0.5)
|
|
_check(arc_left_mid.y > 1.0, "left arc bulges to the left of the chord")
|
|
_check_vec(
|
|
arc_left.curve.get_point_position(0),
|
|
Vector2(-10.0, 0.0),
|
|
"arc keeps its start point"
|
|
)
|
|
_check_vec(
|
|
arc_left.curve.get_point_position(arc_left.curve.point_count - 1),
|
|
Vector2(10.0, 0.0),
|
|
"arc keeps its end point"
|
|
)
|
|
|
|
var arc_right := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(10.0, 0.0),
|
|
PathSegment.Direction.BACKWARD,
|
|
PathSegment.Edge.INSIDE,
|
|
WhiteboardController.Tool.ARC_RIGHT
|
|
)
|
|
var arc_right_mid := arc_right.curve.sample_baked(arc_right.get_length_m() * 0.5)
|
|
_check(arc_right_mid.y < -1.0, "right arc bulges to the right of the chord")
|
|
|
|
var edge_arc := controller.add_segment(
|
|
Vector2(-10.0, 10.0),
|
|
Vector2(10.0, 10.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE,
|
|
WhiteboardController.Tool.ARC_LEFT
|
|
)
|
|
for point: Vector2 in edge_arc.curve.get_baked_points():
|
|
_check(
|
|
routine.rink.contains_point(point),
|
|
"arc near the board is flattened to stay inside: %s" % point
|
|
)
|
|
_check(
|
|
arc_right.direction == PathSegment.Direction.BACKWARD,
|
|
"arc keeps the requested direction"
|
|
)
|
|
_check(
|
|
arc_right.edge == PathSegment.Edge.INSIDE,
|
|
"arc keeps the requested edge"
|
|
)
|
|
_check(routine.is_valid(), "routine stays valid with arc segments")
|
|
|
|
var count_before_arc_drag := section.segments.size()
|
|
controller.set_tool(WhiteboardController.Tool.ARC_LEFT)
|
|
_check(
|
|
controller.get_tool() == WhiteboardController.Tool.ARC_LEFT,
|
|
"tool can be selected programmatically"
|
|
)
|
|
_mouse_button(canvas, view.model_to_screen(Vector2(-15.0, 5.0)), true)
|
|
_mouse_motion(canvas, view.model_to_screen(Vector2(-5.0, 5.0)))
|
|
_mouse_button(canvas, view.model_to_screen(Vector2(-5.0, 5.0)), false)
|
|
_check(
|
|
section.segments.size() == count_before_arc_drag + 1,
|
|
"arc mode creates a segment through the drag path"
|
|
)
|
|
var dragged_arc := section.segments[section.segments.size() - 1]
|
|
_check(dragged_arc.curve.point_count > 2, "dragged arc uses the template geometry")
|
|
var dragged_arc_mid := dragged_arc.curve.sample_baked(
|
|
dragged_arc.get_length_m() * 0.5
|
|
)
|
|
_check(
|
|
dragged_arc_mid.y > 5.5,
|
|
"dragged left arc bulges below its chord"
|
|
)
|
|
|
|
# Selection and handle editing.
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
var apex_before := arc_left.curve.sample_baked(arc_left.get_length_m() * 0.5)
|
|
_mouse_button(canvas, view.model_to_screen(apex_before), true)
|
|
_mouse_button(canvas, view.model_to_screen(apex_before), false)
|
|
_check(
|
|
controller.get_selected_segment() == arc_left,
|
|
"clicking an arc selects it"
|
|
)
|
|
_check(
|
|
canvas.get_selected_segment_id() == arc_left.segment_id,
|
|
"canvas keeps the selection in sync"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("Auswahl: Bogen"),
|
|
"status bar reports the selected arc"
|
|
)
|
|
|
|
var selected_start := arc_left.curve.get_point_position(0)
|
|
var new_start := Vector2(-12.0, -2.0)
|
|
_mouse_button(canvas, view.model_to_screen(selected_start), true)
|
|
_mouse_motion(canvas, view.model_to_screen(new_start))
|
|
_mouse_button(canvas, view.model_to_screen(new_start), false)
|
|
_check_vec(
|
|
arc_left.curve.get_point_position(0),
|
|
new_start,
|
|
"start handle moves the arc start"
|
|
)
|
|
_check(
|
|
arc_left.template == PathSegment.Template.ARC,
|
|
"editing endpoints keeps the arc template"
|
|
)
|
|
|
|
var start_now := arc_left.curve.get_point_position(0)
|
|
var end_now := arc_left.curve.get_point_position(arc_left.curve.point_count - 1)
|
|
var chord_now := end_now - start_now
|
|
var mid_now := (start_now + end_now) * 0.5
|
|
var normal_now := Vector2(-chord_now.y, chord_now.x).normalized()
|
|
var deeper := mid_now + normal_now * (0.46 * chord_now.length())
|
|
var apex_now := arc_left.curve.sample_baked(arc_left.get_length_m() * 0.5)
|
|
_mouse_button(canvas, view.model_to_screen(apex_now), true)
|
|
_mouse_motion(canvas, view.model_to_screen(deeper))
|
|
_mouse_button(canvas, view.model_to_screen(deeper), false)
|
|
_check(
|
|
arc_left.arc_depth_ratio > 0.43,
|
|
"bulge handle increases the arc depth"
|
|
)
|
|
_check(
|
|
arc_left.arc_bulge_left,
|
|
"bulge stays left while dragged on the left side"
|
|
)
|
|
|
|
var apex_flip := arc_left.curve.sample_baked(arc_left.get_length_m() * 0.5)
|
|
var flipped := mid_now - normal_now * (0.3 * chord_now.length())
|
|
_mouse_button(canvas, view.model_to_screen(apex_flip), true)
|
|
_mouse_motion(canvas, view.model_to_screen(flipped))
|
|
_mouse_button(canvas, view.model_to_screen(flipped), false)
|
|
_check(
|
|
not arc_left.arc_bulge_left,
|
|
"bulge handle can flip the arc side"
|
|
)
|
|
var apex_after_flip := arc_left.curve.sample_baked(arc_left.get_length_m() * 0.5)
|
|
_check(
|
|
(apex_after_flip - mid_now).dot(normal_now) < 0.0,
|
|
"flipped arc lies on the other side of the chord"
|
|
)
|
|
|
|
controller.select_segment(arc_right.segment_id)
|
|
_check(
|
|
controller.get_selected_segment() == arc_right,
|
|
"a backward/inside segment can be selected"
|
|
)
|
|
_check(
|
|
not controller.delete_segment_button.disabled,
|
|
"segment delete is enabled with a selection"
|
|
)
|
|
_check(
|
|
controller.backward_button.button_pressed,
|
|
"toolbar shows the selected segment direction"
|
|
)
|
|
_check(
|
|
controller.inside_button.button_pressed,
|
|
"toolbar shows the selected segment edge"
|
|
)
|
|
_check(
|
|
not controller.forward_button.button_pressed,
|
|
"opposite direction button is not pressed"
|
|
)
|
|
_check(
|
|
not controller.outside_button.button_pressed,
|
|
"opposite edge button is not pressed"
|
|
)
|
|
|
|
controller.outside_button.pressed.emit()
|
|
controller.forward_button.pressed.emit()
|
|
_check(
|
|
arc_right.edge == PathSegment.Edge.OUTSIDE,
|
|
"edge button edits the selected segment"
|
|
)
|
|
_check(
|
|
arc_right.direction == PathSegment.Direction.FORWARD,
|
|
"direction button edits the selected segment"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("vorwärts")
|
|
and controller.status_label.text.contains("außen"),
|
|
"status bar shows the edited direction and edge"
|
|
)
|
|
_check(
|
|
controller.outside_button.button_pressed
|
|
and controller.forward_button.button_pressed,
|
|
"toolbar stays in sync after editing"
|
|
)
|
|
|
|
var count_before_delete := section.segments.size()
|
|
controller.delete_segment_button.pressed.emit()
|
|
_check(
|
|
section.segments.size() == count_before_delete - 1,
|
|
"segment delete button removes the selected segment"
|
|
)
|
|
_check(
|
|
not section.segments.has(arc_right),
|
|
"deleted segment is removed from the active section"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"deleting a segment clears the selection"
|
|
)
|
|
_check(
|
|
controller.delete_segment_button.disabled,
|
|
"segment delete disables again after deletion"
|
|
)
|
|
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"switching to a draw tool clears the selection"
|
|
)
|
|
_check(
|
|
canvas.get_selected_segment_id().is_empty(),
|
|
"canvas selection is cleared with the tool"
|
|
)
|
|
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
controller.select_segment(arc_left.segment_id)
|
|
_check(
|
|
controller.get_selected_segment() == arc_left,
|
|
"select_segment selects programmatically"
|
|
)
|
|
var empty_point := Vector2(25.0, -12.0)
|
|
_mouse_button(canvas, view.model_to_screen(empty_point), true)
|
|
_mouse_button(canvas, view.model_to_screen(empty_point), false)
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"clicking empty ice clears the selection"
|
|
)
|
|
|
|
var count_before_pan := section.segments.size()
|
|
var origin_before_pan: Vector2 = view.origin_px
|
|
var pan_start := view.model_to_screen(empty_point)
|
|
var pan_delta := Vector2(40.0, 0.0)
|
|
_mouse_button(canvas, pan_start, true)
|
|
_mouse_motion(canvas, pan_start + pan_delta, pan_delta)
|
|
_mouse_button(canvas, pan_start + pan_delta, false)
|
|
_check(
|
|
section.segments.size() == count_before_pan,
|
|
"select mode does not create segments"
|
|
)
|
|
_check(
|
|
view.origin_px != origin_before_pan,
|
|
"select mode pans on empty ice"
|
|
)
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
|
|
# Section management and ghosting state.
|
|
var first_section_id := section.section_id
|
|
var first_segment_count := section.segments.size()
|
|
var second_section := controller.add_section()
|
|
_check(routine.sections.size() == 2, "add_section appends a section")
|
|
_check(
|
|
controller.get_active_section() == second_section,
|
|
"a new section becomes active"
|
|
)
|
|
_check(
|
|
second_section.sequence_order == 1,
|
|
"new section is ordered after the first"
|
|
)
|
|
_check(second_section.segments.is_empty(), "new section starts empty")
|
|
_check(
|
|
controller.section_list.get_child_count() == 2,
|
|
"section list builds one button per section"
|
|
)
|
|
_check(
|
|
controller.rink_canvas.get_active_section_id() == second_section.section_id,
|
|
"canvas switches to the new active section"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("Abschnitt 2"),
|
|
"status bar shows the new active section"
|
|
)
|
|
|
|
controller.add_segment(
|
|
Vector2(-5.0, 10.0),
|
|
Vector2(5.0, 10.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
_check(
|
|
second_section.segments.size() == 1,
|
|
"segments go into the active section"
|
|
)
|
|
_check(
|
|
section.segments.size() == first_segment_count,
|
|
"other sections keep their segments"
|
|
)
|
|
|
|
controller.set_active_section(first_section_id)
|
|
_check(
|
|
controller.get_active_section() == section,
|
|
"switching sections changes the active section"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"switching sections clears the segment selection"
|
|
)
|
|
_check(
|
|
controller.rink_canvas.get_active_section_id() == first_section_id,
|
|
"canvas follows the switched section"
|
|
)
|
|
|
|
_check(
|
|
controller.rename_section(first_section_id, "Eröffnung"),
|
|
"section can be renamed"
|
|
)
|
|
_check(
|
|
section.title == "Eröffnung",
|
|
"rename updates the section title"
|
|
)
|
|
var first_button := controller.section_list.get_child(0) as Button
|
|
_check(
|
|
first_button.text.contains("Eröffnung"),
|
|
"section list shows the new title"
|
|
)
|
|
|
|
_check(
|
|
controller.move_section(first_section_id, 1),
|
|
"section can be moved down"
|
|
)
|
|
_check(
|
|
routine.sections[0] == second_section and routine.sections[1] == section,
|
|
"moving reorders the routine sections"
|
|
)
|
|
_check(
|
|
routine.sections[0].sequence_order == 0
|
|
and routine.sections[1].sequence_order == 1,
|
|
"sequence orders are renumbered after moving"
|
|
)
|
|
_check(
|
|
controller.get_active_section() == section,
|
|
"moving a section keeps it active"
|
|
)
|
|
|
|
_check(
|
|
controller.move_section(first_section_id, -1),
|
|
"section can be moved up again"
|
|
)
|
|
_check(routine.sections[0] == section, "moving up restores the order")
|
|
|
|
_check(
|
|
controller.delete_section(second_section.section_id),
|
|
"a non-active section can be deleted"
|
|
)
|
|
_check(routine.sections.size() == 1, "delete removes the section")
|
|
_check(
|
|
controller.get_active_section() == section,
|
|
"deleting a non-active section keeps the active one"
|
|
)
|
|
_check(
|
|
not controller.delete_section(first_section_id),
|
|
"the last remaining section cannot be deleted"
|
|
)
|
|
|
|
var third_section := controller.add_section()
|
|
_check(
|
|
controller.delete_section(third_section.section_id),
|
|
"the active section can be deleted when another exists"
|
|
)
|
|
_check(
|
|
controller.get_active_section() == section,
|
|
"deleting the active section falls back to the remaining one"
|
|
)
|
|
|
|
controller.rename_edit.text = "Testname"
|
|
controller.rename_dialog.confirmed.emit()
|
|
_check(
|
|
controller.get_active_section().title == "Testname",
|
|
"rename dialog applies the edited title"
|
|
)
|
|
|
|
# Segment labels.
|
|
controller.select_segment(arc_left.segment_id)
|
|
_check(
|
|
not controller.label_button.disabled,
|
|
"label button is enabled with a selection"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment_label().is_empty(),
|
|
"segments start without a label"
|
|
)
|
|
_check(
|
|
controller.set_selected_segment_label(" Eingang "),
|
|
"label can be set"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment_label() == "Eingang",
|
|
"label is trimmed"
|
|
)
|
|
_check(controller.is_dirty(), "label edit marks the routine dirty")
|
|
_check(
|
|
not controller.set_selected_segment_label("Eingang"),
|
|
"unchanged label records no history"
|
|
)
|
|
_check(controller.are_labels_visible(), "labels are visible by default")
|
|
_check(
|
|
controller.labels_toggle.button_pressed,
|
|
"labels toggle starts pressed"
|
|
)
|
|
controller.set_labels_visible(false)
|
|
_check(not controller.are_labels_visible(), "labels can be hidden")
|
|
_check(
|
|
not controller.labels_toggle.button_pressed,
|
|
"toggle reflects hidden labels"
|
|
)
|
|
controller.set_labels_visible(true)
|
|
_check(controller.are_labels_visible(), "labels can be shown again")
|
|
_check(
|
|
controller.labels_toggle.button_pressed,
|
|
"toggle reflects visible labels"
|
|
)
|
|
controller.clear_selection()
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"clear_selection removes the selection"
|
|
)
|
|
_check(
|
|
controller.label_button.disabled,
|
|
"label button is disabled without a selection"
|
|
)
|
|
controller.select_segment(arc_left.segment_id)
|
|
_check(
|
|
controller.label_button.disabled == false,
|
|
"label button is enabled again after selecting"
|
|
)
|
|
controller.label_button.pressed.emit()
|
|
_check(
|
|
controller.segment_label_dialog.visible,
|
|
"label button opens the label dialog"
|
|
)
|
|
_check(
|
|
controller.segment_label_edit.text == "Eingang",
|
|
"label dialog is prefilled"
|
|
)
|
|
controller.segment_label_edit.text = "Ausgang"
|
|
controller.segment_label_dialog.confirmed.emit()
|
|
_check(
|
|
controller.get_selected_segment_label() == "Ausgang",
|
|
"label dialog applies the edited text"
|
|
)
|
|
controller.segment_label_edit.text = ""
|
|
controller.segment_label_dialog.confirmed.emit()
|
|
_check(
|
|
controller.get_selected_segment_label().is_empty(),
|
|
"empty text removes the label"
|
|
)
|
|
controller.segment_label_dialog.hide()
|
|
controller.set_selected_segment_label("Eingang")
|
|
var saved_label := controller.get_selected_segment_label()
|
|
|
|
# Element markers (D3): a jump point/spin centre is a zero-length segment.
|
|
controller.set_tool(WhiteboardController.Tool.ELEMENT)
|
|
_check(
|
|
canvas.is_marker_placement_enabled(),
|
|
"element tool enables marker placement"
|
|
)
|
|
var marker_count_before := section.segments.size()
|
|
var duration_before_marker := controller.get_routine().get_duration_seconds()
|
|
var jump_point := Vector2(14.0, 7.0)
|
|
_mouse_button(canvas, view.model_to_screen(jump_point), true)
|
|
_mouse_button(canvas, view.model_to_screen(jump_point), false)
|
|
|
|
var jump := controller.get_selected_segment()
|
|
_check(
|
|
section.segments.size() == marker_count_before + 1,
|
|
"tap in element mode adds a marker"
|
|
)
|
|
_check(jump != null and jump.is_element_marker(), "placed marker is a point marker")
|
|
if jump != null:
|
|
_check_approx(jump.get_length_m(), 0.0, "marker has no length")
|
|
_check_approx(
|
|
jump.duration_seconds,
|
|
0.0,
|
|
"marker geometry has no traversal duration"
|
|
)
|
|
_check_approx(
|
|
jump.element_duration_seconds,
|
|
0.7,
|
|
"jump gets the default air time"
|
|
)
|
|
_check(
|
|
jump.element_type == PathSegment.ElementType.JUMP,
|
|
"default marker type is a jump"
|
|
)
|
|
_check(
|
|
jump.get_element_caption() == "Sprung",
|
|
"marker falls back to the type name"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("Sprung"),
|
|
"status bar names the placed element"
|
|
)
|
|
_check_approx(
|
|
controller.get_playback_duration(),
|
|
controller.get_routine().get_duration_seconds(),
|
|
"playback includes the marker stand time"
|
|
)
|
|
_check_approx(
|
|
controller.get_routine().get_duration_seconds(),
|
|
duration_before_marker + 0.7,
|
|
"routine duration includes the jump air time"
|
|
)
|
|
|
|
# A tap on the selected marker handle must not record an undo entry:
|
|
# undo has to remove the marker itself.
|
|
var jump_id := jump.segment_id
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
controller.select_segment(jump_id)
|
|
var marker_tap := view.model_to_screen(jump_point)
|
|
_mouse_button(canvas, marker_tap, true)
|
|
_mouse_button(canvas, marker_tap, false)
|
|
_check(controller.undo(), "tap on a marker handle is undoable")
|
|
section = controller.get_active_section()
|
|
_check(
|
|
section.get_segment_by_id(jump_id) == null,
|
|
"a plain tap adds no undo entry, so undo removes the marker"
|
|
)
|
|
_check(controller.redo(), "marker placement can be redone")
|
|
section = controller.get_active_section()
|
|
jump = section.get_segment_by_id(jump_id)
|
|
_check(jump != null, "redo restores the placed marker")
|
|
|
|
controller.set_tool(WhiteboardController.Tool.ELEMENT)
|
|
controller.set_element_type(PathSegment.ElementType.SPIN)
|
|
_check(
|
|
controller.get_element_type() == PathSegment.ElementType.SPIN,
|
|
"element type can be selected for placement"
|
|
)
|
|
var spin_point := Vector2(6.0, -6.0)
|
|
_mouse_button(canvas, view.model_to_screen(spin_point), true)
|
|
_mouse_button(canvas, view.model_to_screen(spin_point), false)
|
|
var spin := controller.get_selected_segment()
|
|
_check(
|
|
spin != null and spin.element_type == PathSegment.ElementType.SPIN,
|
|
"toolbar type is used for the next marker"
|
|
)
|
|
_check_approx(
|
|
spin.element_duration_seconds,
|
|
8.0,
|
|
"spin gets the default stand time"
|
|
)
|
|
|
|
_check(
|
|
controller.set_selected_element(
|
|
PathSegment.ElementType.SPIN,
|
|
"CCoSp4",
|
|
3
|
|
),
|
|
"element code and level can be edited"
|
|
)
|
|
_check(
|
|
spin.element_code == "CCoSp" and spin.element_level == 0,
|
|
"a canonical suffix is normalized; without features the level is Base"
|
|
)
|
|
_check(
|
|
spin.get_element_caption() == "CCoSp",
|
|
"marker caption omits the derived Base level"
|
|
)
|
|
_check_approx(
|
|
spin.element_duration_seconds,
|
|
8.0,
|
|
"editing code keeps the stand time"
|
|
)
|
|
_check(controller.undo(), "element edit can be undone")
|
|
var restored_spin := controller.get_active_section().get_segment_by_id(
|
|
spin.segment_id
|
|
)
|
|
_check(
|
|
restored_spin != null
|
|
and restored_spin.element_code.is_empty()
|
|
and restored_spin.element_level == 0,
|
|
"undo restores the previous element data"
|
|
)
|
|
_check(controller.redo(), "element edit can be redone")
|
|
spin = controller.get_active_section().get_segment_by_id(spin.segment_id)
|
|
_check(
|
|
spin != null and spin.element_code == "CCoSp",
|
|
"redo restores the element data"
|
|
)
|
|
controller.select_segment(spin.segment_id)
|
|
_check(
|
|
controller.set_selected_element_features(
|
|
PackedStringArray(
|
|
[
|
|
"difficult_variation",
|
|
"difficult_variation",
|
|
"difficult_exit",
|
|
"change_of_edge",
|
|
]
|
|
)
|
|
),
|
|
"features derive the level"
|
|
)
|
|
_check(spin.element_level == 4, "four features derive Level 4")
|
|
_check(
|
|
spin.get_element_caption() == "CCoSp L4",
|
|
"marker caption includes the derived level"
|
|
)
|
|
|
|
# Element inspector dialog.
|
|
controller.select_segment(spin.segment_id)
|
|
controller.element_button.pressed.emit()
|
|
_check(controller.element_dialog.visible, "element button opens the dialog")
|
|
_check(
|
|
controller.element_code_edit.text == "CCoSp",
|
|
"element dialog is prefilled with the normalized code"
|
|
)
|
|
var selected_code_index := controller.element_code_option.selected
|
|
_check(
|
|
selected_code_index >= 0
|
|
and str(
|
|
controller.element_code_option.get_item_metadata(selected_code_index)
|
|
) == "CCoSp",
|
|
"the code dropdown is prefilled with the catalog family"
|
|
)
|
|
_check(
|
|
not controller.element_code_edit.visible,
|
|
"a catalog code hides the free-text field"
|
|
)
|
|
_check(
|
|
controller.element_level_option.get_item_id(
|
|
controller.element_level_option.selected
|
|
) == 4,
|
|
"element dialog is prefilled with the normalized level"
|
|
)
|
|
_check(
|
|
controller.element_level_option.disabled,
|
|
"the level is read-only for a catalog spin"
|
|
)
|
|
var catalog := controller.get_element_catalog()
|
|
_check(catalog != null and catalog.season == "2026/27", "controller loads the ISU catalog")
|
|
_check(
|
|
controller.element_value_label.text.contains("4,20"),
|
|
"element dialog shows the base value of the current code and level"
|
|
)
|
|
|
|
_select_dialog_code(controller, "CCoSp")
|
|
_check(
|
|
controller.set_selected_element_features(
|
|
PackedStringArray(["difficult_variation", "difficult_exit"])
|
|
),
|
|
"features update the derived level"
|
|
)
|
|
_check(
|
|
controller.element_level_option.get_item_id(
|
|
controller.element_level_option.selected
|
|
) == 2,
|
|
"the level dropdown follows two features"
|
|
)
|
|
controller.update_element_value_hint()
|
|
_check(
|
|
controller.element_value_label.text.contains("3,00"),
|
|
"base value follows the derived level 2"
|
|
)
|
|
|
|
_set_dialog_free_text(controller, "CCoSp4")
|
|
_check(
|
|
controller.element_code_edit.visible,
|
|
"free-text mode shows the text field"
|
|
)
|
|
_check(
|
|
controller.element_value_label.text.contains("4,20"),
|
|
"a canonical suffix wins over the derived level"
|
|
)
|
|
|
|
_set_dialog_free_text(controller, "3X")
|
|
_check(
|
|
controller.element_value_label.text.contains("nicht im Katalog"),
|
|
"unknown codes are marked as not in the catalog"
|
|
)
|
|
_check(
|
|
controller.element_features_button.disabled,
|
|
"feature button is disabled for an unknown code"
|
|
)
|
|
|
|
# Level features and the derived level.
|
|
_select_dialog_code(controller, "CCoSp")
|
|
_check(
|
|
not controller.element_features_button.disabled,
|
|
"feature button is enabled for a catalog spin"
|
|
)
|
|
_check(
|
|
controller.get_selected_element_features().size() == 2,
|
|
"features are stored on the selected segment"
|
|
)
|
|
_check(
|
|
controller.element_feature_hint.text.contains("Features: 2")
|
|
and controller.element_feature_hint.text.contains("Level 2"),
|
|
"feature hint shows the derived level"
|
|
)
|
|
_check(
|
|
controller._populate_feature_menu(),
|
|
"feature menu populates for a spin"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.item_count == 18,
|
|
"feature menu lists 15 features plus the second difficult variation"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.get_item_metadata(0) == "difficult_variation",
|
|
"feature menu items carry their feature code"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.is_item_checked(0),
|
|
"the selected difficult variation is checked"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.is_item_checked(6),
|
|
"the selected difficult exit is checked"
|
|
)
|
|
controller.element_feature_menu.set_item_checked(1, false)
|
|
controller._on_feature_menu_id_pressed(1)
|
|
_check(
|
|
controller.element_feature_menu.is_item_checked(1),
|
|
"clicking a feature toggles its check state"
|
|
)
|
|
controller._on_feature_menu_hidden()
|
|
_check(
|
|
controller._dialog_features.size() == 3,
|
|
"a second difficult variation updates the pending selection"
|
|
)
|
|
_check(
|
|
controller.element_level_option.get_item_id(
|
|
controller.element_level_option.selected
|
|
) == 3,
|
|
"the pending level follows the pending features"
|
|
)
|
|
_check(
|
|
controller.element_feature_hint.text.contains("Features: 3")
|
|
and controller.element_feature_hint.text.contains("Level 3"),
|
|
"feature hint follows the pending selection and level"
|
|
)
|
|
|
|
controller.element_duration_spin.value = 6.5
|
|
controller.element_dialog.confirmed.emit()
|
|
_check(
|
|
controller.get_selected_element_caption() == "CCoSp L3",
|
|
"element dialog applies features and the derived level"
|
|
)
|
|
_check(
|
|
spin.element_features.size() == 3 and spin.element_level == 3,
|
|
"features and level are stored together"
|
|
)
|
|
_check_approx(
|
|
controller.get_selected_segment().element_duration_seconds,
|
|
6.5,
|
|
"element dialog applies the stand time"
|
|
)
|
|
|
|
_check(controller.undo(), "element dialog change can be undone")
|
|
spin = controller.get_active_section().get_segment_by_id(spin.segment_id)
|
|
_check(
|
|
spin != null and spin.element_features.size() == 2 and spin.element_level == 2,
|
|
"undo restores features and the derived level"
|
|
)
|
|
controller.select_segment(spin.segment_id)
|
|
_check(controller.redo(), "element dialog change can be redone")
|
|
spin = controller.get_active_section().get_segment_by_id(spin.segment_id)
|
|
_check(
|
|
spin != null and spin.element_features.size() == 3 and spin.element_level == 3,
|
|
"redo restores features and the derived level"
|
|
)
|
|
controller.select_segment(spin.segment_id)
|
|
|
|
_check(
|
|
controller.set_selected_element_features(PackedStringArray()),
|
|
"features can be cleared"
|
|
)
|
|
_check(
|
|
controller.get_selected_element_features().is_empty(),
|
|
"clearing removes all features"
|
|
)
|
|
_check(spin.element_level == 0, "clearing features resets the level to Base")
|
|
_check(
|
|
controller.set_selected_element_features(
|
|
PackedStringArray(["difficult_variation", "difficult_exit"])
|
|
),
|
|
"features restore Level 2"
|
|
)
|
|
_check(spin.element_level == 2, "the restored level is Level 2")
|
|
_check(
|
|
controller.get_selected_element_caption() == "CCoSp L2",
|
|
"the restored caption shows Level 2"
|
|
)
|
|
|
|
controller.element_button.pressed.emit()
|
|
_check_approx(
|
|
controller.element_duration_spin.value,
|
|
6.5,
|
|
"element dialog is prefilled with the stand time"
|
|
)
|
|
_check(
|
|
controller.element_duration_spin.editable,
|
|
"stand time is editable for point markers"
|
|
)
|
|
controller.element_dialog.hide()
|
|
|
|
# Dragging the marker handle moves the point.
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
controller.select_segment(spin.segment_id)
|
|
var moved_to := Vector2(4.0, -3.0)
|
|
var marker_screen := view.model_to_screen(spin_point)
|
|
var marker_target := view.model_to_screen(moved_to)
|
|
_mouse_button(canvas, marker_screen, true)
|
|
_mouse_motion(canvas, marker_target, marker_target - marker_screen)
|
|
_mouse_button(canvas, marker_target, false)
|
|
_check_vec(
|
|
spin.curve.get_point_position(0),
|
|
moved_to,
|
|
"dragging the marker handle moves the element"
|
|
)
|
|
_check(controller.undo(), "marker drag can be undone")
|
|
var unmoved := controller.get_active_section().get_segment_by_id(spin.segment_id)
|
|
_check(
|
|
unmoved != null and unmoved.curve.point_count == 1,
|
|
"undo keeps the marker a single point"
|
|
)
|
|
_check_vec(
|
|
unmoved.curve.get_point_position(0),
|
|
spin_point,
|
|
"undo restores the marker position"
|
|
)
|
|
_check(controller.redo(), "marker drag can be redone")
|
|
|
|
# Deleting through the inspector: a marker without an element is removed.
|
|
controller.select_segment(spin.segment_id)
|
|
controller.set_selected_element(PathSegment.ElementType.NONE, "", 0)
|
|
_check(
|
|
controller.get_active_section().get_segment_by_id(spin.segment_id) == null,
|
|
"removing the element deletes the point marker"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment() == null,
|
|
"deleting the marker clears the selection"
|
|
)
|
|
_check(controller.undo(), "marker deletion can be undone")
|
|
spin = controller.get_active_section().get_segment_by_id(spin.segment_id)
|
|
_check(
|
|
spin != null and spin.is_element_marker(),
|
|
"undo restores the deleted marker"
|
|
)
|
|
|
|
# A drawn segment can be tagged as a sequence range and untagged again.
|
|
var range_segment := controller.add_segment(
|
|
Vector2(-2.0, 11.0),
|
|
Vector2(10.0, 11.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
controller.select_segment(range_segment.segment_id)
|
|
_check(
|
|
controller.set_selected_element(
|
|
PathSegment.ElementType.SEQUENCE,
|
|
"StSq",
|
|
2
|
|
),
|
|
"a drawn segment can carry a sequence element"
|
|
)
|
|
_check(
|
|
controller.set_selected_element_features(
|
|
PackedStringArray(["variety_of_turns", "both_rotations"])
|
|
),
|
|
"a sequence range can carry level features"
|
|
)
|
|
_check(
|
|
controller.get_selected_element_caption() == "StSq L2",
|
|
"sequence range caption combines code and derived level"
|
|
)
|
|
_check(
|
|
controller.set_selected_element(PathSegment.ElementType.NONE, "", 0),
|
|
"the element tag can be removed from a range"
|
|
)
|
|
var untagged := controller.get_active_section().get_segment_by_id(
|
|
range_segment.segment_id
|
|
)
|
|
_check(
|
|
untagged != null and untagged.get_length_m() > 0.0,
|
|
"removing the tag keeps the drawn path"
|
|
)
|
|
_check(
|
|
not untagged.is_element(),
|
|
"removed range is no longer an element"
|
|
)
|
|
_check(
|
|
controller.get_element_type() != PathSegment.ElementType.NONE,
|
|
"removing a tag keeps a usable placement type"
|
|
)
|
|
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
var saved_marker_id: String = jump.segment_id
|
|
|
|
# Save/load round-trip.
|
|
var roundtrip_path := "user://test_roundtrip.json"
|
|
var saved_section_title := controller.get_active_section().title
|
|
var saved_segment_count := controller.get_active_section().segments.size()
|
|
var saved_arc_id := arc_left.segment_id
|
|
var saved_arc_depth := arc_left.arc_depth_ratio
|
|
var saved_arc_left := arc_left.arc_bulge_left
|
|
|
|
_check(controller.save_to_path(roundtrip_path), "routine can be saved")
|
|
_check(not controller.is_dirty(), "saving clears the dirty flag")
|
|
_check(
|
|
FileAccess.file_exists(roundtrip_path),
|
|
"save creates a routine file"
|
|
)
|
|
|
|
controller.add_section()
|
|
_check(controller.is_dirty(), "changes mark the routine dirty")
|
|
|
|
_check(controller.load_from_path(roundtrip_path), "routine can be loaded")
|
|
_check(
|
|
controller.get_routine().sections.size() == 1,
|
|
"load restores the section count"
|
|
)
|
|
_check(
|
|
controller.get_active_section().title == saved_section_title,
|
|
"load restores the section title"
|
|
)
|
|
_check(
|
|
controller.get_active_section().segments.size() == saved_segment_count,
|
|
"load restores all segments"
|
|
)
|
|
_check(not controller.is_dirty(), "loading clears the dirty flag")
|
|
|
|
var loaded_arc := controller.get_active_section().get_segment_by_id(
|
|
saved_arc_id
|
|
)
|
|
_check(loaded_arc != null, "loaded segments keep their ids")
|
|
if loaded_arc != null:
|
|
_check(
|
|
loaded_arc.template == PathSegment.Template.ARC,
|
|
"load restores the arc template"
|
|
)
|
|
_check_approx(
|
|
loaded_arc.arc_depth_ratio,
|
|
saved_arc_depth,
|
|
"load restores the arc depth"
|
|
)
|
|
_check(
|
|
loaded_arc.arc_bulge_left == saved_arc_left,
|
|
"load restores the arc side"
|
|
)
|
|
_check(
|
|
loaded_arc.curve.point_count > 2,
|
|
"load restores the sampled arc curve"
|
|
)
|
|
_check(
|
|
loaded_arc.label == saved_label,
|
|
"load restores the segment label"
|
|
)
|
|
|
|
var loaded_marker := controller.get_active_section().get_segment_by_id(
|
|
saved_marker_id
|
|
)
|
|
_check(loaded_marker != null, "load restores element markers")
|
|
if loaded_marker != null:
|
|
_check(loaded_marker.is_element_marker(), "loaded marker stays a point marker")
|
|
_check(
|
|
loaded_marker.element_type == PathSegment.ElementType.JUMP,
|
|
"load restores the element type"
|
|
)
|
|
_check(
|
|
loaded_marker.get_element_caption() == "Sprung",
|
|
"load restores the element caption"
|
|
)
|
|
_check_approx(
|
|
loaded_marker.element_duration_seconds,
|
|
0.7,
|
|
"load restores the element stand time"
|
|
)
|
|
_check(
|
|
loaded_marker.curve.point_count == 1,
|
|
"load keeps the marker curve as a single point"
|
|
)
|
|
|
|
DirAccess.remove_absolute(roundtrip_path)
|
|
|
|
var too_new_path := "user://test_too_new.tres"
|
|
var too_new: Routine = controller.get_routine().duplicate(true)
|
|
too_new.schema_version = Routine.CURRENT_SCHEMA_VERSION + 1
|
|
ResourceSaver.save(too_new, too_new_path)
|
|
_check(
|
|
not controller.load_from_path(too_new_path),
|
|
"newer schema versions are rejected"
|
|
)
|
|
DirAccess.remove_absolute(too_new_path)
|
|
|
|
controller.save_name_edit.text = "Test Kür"
|
|
controller.save_as_dialog.confirmed.emit()
|
|
var save_as_path := "user://routines/test_kür.json"
|
|
_check(
|
|
FileAccess.file_exists(save_as_path),
|
|
"save-as dialog writes a normalized filename"
|
|
)
|
|
_check(
|
|
controller.get_routine().title == "Test Kür",
|
|
"save-as dialog updates the routine title"
|
|
)
|
|
_check(
|
|
controller.get_current_path() == save_as_path,
|
|
"save-as dialog becomes the current file"
|
|
)
|
|
DirAccess.remove_absolute(save_as_path)
|
|
|
|
# Flow from an empty marker to a derived spin level.
|
|
controller.message_dialog.hide()
|
|
controller.element_dialog.hide()
|
|
var derived_marker := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
"",
|
|
0
|
|
)
|
|
_check(derived_marker != null, "an empty marker can be created")
|
|
controller.select_segment(derived_marker.segment_id)
|
|
controller.element_button.pressed.emit()
|
|
var spin_type_index := controller.element_dialog_type_option.get_item_index(
|
|
PathSegment.ElementType.SPIN
|
|
)
|
|
controller.element_dialog_type_option.select(spin_type_index)
|
|
controller.element_dialog_type_option.item_selected.emit(spin_type_index)
|
|
_check(
|
|
controller.element_features_button.disabled,
|
|
"feature button waits for a catalog code"
|
|
)
|
|
_select_dialog_code(controller, "CCoSp")
|
|
_check(
|
|
not controller.element_features_button.disabled,
|
|
"selecting a catalog code enables the feature button"
|
|
)
|
|
_check(
|
|
controller.element_feature_hint.text.contains("Features: 0")
|
|
and controller.element_feature_hint.text.contains("Base"),
|
|
"a catalog spin without features starts at Base"
|
|
)
|
|
_check(
|
|
controller._populate_feature_menu(),
|
|
"the feature menu opens for the pending spin"
|
|
)
|
|
controller.element_feature_menu.set_item_checked(0, true)
|
|
controller.element_feature_menu.set_item_checked(6, true)
|
|
controller._on_feature_menu_hidden()
|
|
_check(
|
|
controller.element_level_option.get_item_id(
|
|
controller.element_level_option.selected
|
|
) == 2,
|
|
"two pending features raise the pending level to Level 2"
|
|
)
|
|
controller.element_dialog.confirmed.emit()
|
|
controller.element_dialog.hide()
|
|
_check(
|
|
derived_marker.element_level == 2
|
|
and derived_marker.element_features.size() == 2,
|
|
"the confirmed marker stores features and the derived level"
|
|
)
|
|
|
|
# Validation dialog.
|
|
controller.new_routine()
|
|
controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.SPIN,
|
|
"3X",
|
|
0
|
|
)
|
|
var issues := controller.validate_routine()
|
|
_check(issues.size() == 1, "validation reports one finding")
|
|
_check(
|
|
issues.size() > 0
|
|
and issues[0].severity == ValidationIssue.Severity.ERROR,
|
|
"an unknown element code is reported as an error"
|
|
)
|
|
controller.message_dialog.hide()
|
|
controller.open_validation_dialog()
|
|
_check(controller.validation_dialog.visible, "validation button opens the dialog")
|
|
_check(
|
|
controller.validation_text.text.contains("nicht im Katalog"),
|
|
"validation dialog shows the catalog finding"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Geprüft: 1 Element in 1 Abschnitt")
|
|
and controller.validation_text.text.contains("Saison 2026/27"),
|
|
"validation dialog states the scope of the check"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Kürzel im Katalog")
|
|
and controller.validation_text.text.contains("0/1"),
|
|
"validation dialog lists the failed check with its count"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Befunde"),
|
|
"validation dialog separates checks from findings"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("nicht anwendbar (kein ChSq)")
|
|
and controller.validation_text.text.contains(
|
|
"nicht anwendbar (keine Features gesetzt)"
|
|
),
|
|
"skipped checks explain why they do not apply"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Basiswert")
|
|
and controller.validation_text.text.contains("0,00")
|
|
and controller.validation_text.text.contains("1 ohne Base Value"),
|
|
"validation dialog shows the base-value total and unscored count"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Wertung")
|
|
and controller.validation_text.text.contains("3X — —"),
|
|
"the scoring breakdown marks unknown elements as unscored"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Was ist enthalten"),
|
|
"the score caveats are available behind an info link"
|
|
)
|
|
_check(
|
|
not controller.validation_text.text.contains("1,1-Faktor"),
|
|
"the score details are hidden by default"
|
|
)
|
|
controller.validation_text.meta_clicked.emit("score_info")
|
|
_check(
|
|
controller.validation_text.text.contains("Enthalten")
|
|
and controller.validation_text.text.contains("GOE")
|
|
and controller.validation_text.text.contains("1,1-Faktor")
|
|
and controller.validation_text.text.contains("Kombinationen"),
|
|
"the score info link expands the excluded scoring parts"
|
|
)
|
|
controller.validation_text.meta_clicked.emit("score_info")
|
|
_check(
|
|
not controller.validation_text.text.contains("1,1-Faktor"),
|
|
"the score info link collapses the details again"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
|
|
controller.new_routine()
|
|
controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.SPIN,
|
|
"CCoSp",
|
|
4
|
|
)
|
|
var clean_issues := controller.validate_routine()
|
|
_check(
|
|
clean_issues.is_empty(),
|
|
"a consistent routine has no validation findings"
|
|
)
|
|
controller.open_validation_dialog()
|
|
_check(
|
|
controller.validation_text.text.contains("Keine Befunde")
|
|
and controller.validation_text.text.contains("Kürzel im Katalog")
|
|
and controller.validation_text.text.contains("1/1"),
|
|
"clean validation lists the passed checks"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Basiswert")
|
|
and controller.validation_text.text.contains("2,00"),
|
|
"clean validation shows the base value of a Base spin"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
|
|
# Adult category validation.
|
|
controller.new_routine()
|
|
_check(controller.set_adult_category("gold"), "Gold category can be selected")
|
|
_check(controller.get_adult_category() == "gold", "the routine stores the category")
|
|
var selected_category := controller.adult_category_option.selected
|
|
_check(
|
|
str(controller.adult_category_option.get_item_metadata(selected_category))
|
|
== "gold",
|
|
"the category dropdown reflects the routine"
|
|
)
|
|
for code: String in ["1T", "1S", "1Lo", "2T", "2S", "3T"]:
|
|
controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
code,
|
|
0
|
|
)
|
|
var category_issues := controller.validate_routine()
|
|
_check(
|
|
category_issues.size() >= 3,
|
|
"the Gold category reports count, jump-type and required-element findings"
|
|
)
|
|
controller.open_validation_dialog()
|
|
_check(
|
|
controller.validation_text.text.contains("Kategorie: Gold"),
|
|
"validation dialog names the adult category"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Sprungelemente: 6"),
|
|
"validation dialog reports the jump count"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("3T")
|
|
and controller.validation_text.text.contains("nicht erlaubt"),
|
|
"validation dialog reports a forbidden Gold jump"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Choreographic Spin"),
|
|
"validation dialog reports the missing choreographic spin"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Punktschätzung")
|
|
and controller.validation_text.text.contains("Geschätzte Summe"),
|
|
"Gold validation shows the PCS-based estimate"
|
|
)
|
|
controller.validation_text.meta_clicked.emit("score_assumptions")
|
|
_check(
|
|
controller.score_assumptions_panel.visible,
|
|
"the assumptions panel opens from the score estimate"
|
|
)
|
|
controller.pcs_average_spin.value = 6.0
|
|
controller.falls_spin.value = 1.0
|
|
controller.apply_score_assumptions_button.pressed.emit()
|
|
_check(
|
|
not controller.score_assumptions_panel.visible,
|
|
"applying the assumptions closes the inline panel"
|
|
)
|
|
_check(
|
|
controller.get_routine().assumed_pcs_average == 6.0
|
|
and controller.get_routine().assumed_falls == 1,
|
|
"the scoring assumptions are stored on the routine"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("PCS-Annahme: 6,00")
|
|
and controller.validation_text.text.contains("-1,00"),
|
|
"the estimate follows the changed assumptions"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
|
|
# Structured jump combination in the element dialog.
|
|
controller.new_routine()
|
|
var combo_marker := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
"2T",
|
|
0
|
|
)
|
|
controller.select_segment(combo_marker.segment_id)
|
|
controller.element_button.pressed.emit()
|
|
_check(
|
|
controller.jump_combination_box.visible,
|
|
"the jump combination controls are visible for jumps"
|
|
)
|
|
var combo_kind_index := controller.jump_kind_option.get_item_index(
|
|
PathSegment.JumpKind.COMBINATION
|
|
)
|
|
controller.jump_kind_option.select(combo_kind_index)
|
|
controller.jump_kind_option.item_selected.emit(combo_kind_index)
|
|
_check(
|
|
controller.jump_second_option.visible,
|
|
"choosing a combination reveals the second jump"
|
|
)
|
|
_select_option_by_metadata(controller.jump_second_option, "2S")
|
|
_check(
|
|
controller.element_value_label.text.contains("2,60"),
|
|
"the dialog base value sums the combination jumps"
|
|
)
|
|
controller.element_dialog.confirmed.emit()
|
|
controller.element_dialog.hide()
|
|
_check(
|
|
combo_marker.get_element_caption() == "2T+2S",
|
|
"the confirmed marker stores a structured combination"
|
|
)
|
|
_check_approx(
|
|
controller.get_element_catalog().get_segment_base_value(combo_marker),
|
|
2.60,
|
|
"the structured combination has the summed base value"
|
|
)
|
|
_check(controller.undo(), "the structured combination can be undone")
|
|
combo_marker = controller.get_active_section().get_segment_by_id(
|
|
combo_marker.segment_id
|
|
)
|
|
_check(
|
|
combo_marker != null
|
|
and combo_marker.combination_jumps.is_empty()
|
|
and combo_marker.get_element_caption() == "2T",
|
|
"undo restores the solo jump"
|
|
)
|
|
|
|
var legacy_marker := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
"3Lz+2T",
|
|
0
|
|
)
|
|
_check(
|
|
legacy_marker.element_code == "3Lz"
|
|
and legacy_marker.jump_kind == PathSegment.JumpKind.COMBINATION
|
|
and legacy_marker.combination_jumps == PackedStringArray(["2T"]),
|
|
"legacy free-text combinations are migrated on insert"
|
|
)
|
|
_check(
|
|
legacy_marker.get_element_caption() == "3Lz+2T",
|
|
"the migrated legacy marker keeps its caption"
|
|
)
|
|
|
|
controller.select_segment(combo_marker.segment_id)
|
|
controller.element_button.pressed.emit()
|
|
var sequence_kind_index := controller.jump_kind_option.get_item_index(
|
|
PathSegment.JumpKind.SEQUENCE
|
|
)
|
|
controller.jump_kind_option.select(sequence_kind_index)
|
|
controller.jump_kind_option.item_selected.emit(sequence_kind_index)
|
|
_check(
|
|
controller.jump_sequence_hint.visible
|
|
and controller.jump_sequence_hint.text.contains("mindestens ein Axel"),
|
|
"the sequence hint asks for an Axel"
|
|
)
|
|
_select_option_by_metadata(controller.jump_second_option, "2T")
|
|
_check(
|
|
controller.jump_sequence_hint.text.contains("mindestens ein Axel"),
|
|
"a sequence without an Axel keeps the warning"
|
|
)
|
|
_select_option_by_metadata(controller.jump_second_option, "2A")
|
|
_check(
|
|
controller.jump_sequence_hint.text.contains("Axel vorhanden"),
|
|
"selecting an Axel satisfies the sequence hint"
|
|
)
|
|
_check(
|
|
controller.element_value_label.text.contains("4,60"),
|
|
"the sequence base value sums 2T + 2A"
|
|
)
|
|
controller.element_dialog.confirmed.emit()
|
|
controller.element_dialog.hide()
|
|
_check(
|
|
combo_marker.get_element_caption() == "2T+2A+SEQ",
|
|
"the confirmed marker stores a structured sequence"
|
|
)
|
|
_check_approx(
|
|
controller.get_element_catalog().get_segment_base_value(combo_marker),
|
|
4.60,
|
|
"the structured sequence has the summed base value"
|
|
)
|
|
_check(controller.undo(), "the structured sequence can be undone")
|
|
|
|
controller.help_button.pressed.emit()
|
|
_check(controller.help_dialog.visible, "help button opens the help dialog")
|
|
_check(
|
|
controller.help_text.text.contains("Hilfe & Annahmen")
|
|
and controller.help_text.text.contains("PCS-Annahme")
|
|
and controller.help_text.text.contains("Gold")
|
|
and controller.help_text.text.contains("Level 4"),
|
|
"help dialog explains base value, levels, categories and PCS"
|
|
)
|
|
controller.help_dialog.hide()
|
|
|
|
# Save-as must not replace an existing file without confirmation.
|
|
var overwrite_path := "user://routines/overwrite.json"
|
|
_check(
|
|
RoutineFile.save(controller.get_routine(), overwrite_path).is_empty(),
|
|
"overwrite fixture can be saved"
|
|
)
|
|
var overwrite_before := FileAccess.get_file_as_string(overwrite_path)
|
|
controller.save_name_edit.text = "overwrite"
|
|
controller.save_as_dialog.confirmed.emit()
|
|
_check(
|
|
controller.confirm_dialog.visible,
|
|
"save-as asks before replacing an existing file"
|
|
)
|
|
_check(
|
|
FileAccess.get_file_as_string(overwrite_path) == overwrite_before,
|
|
"the existing file stays untouched before confirmation"
|
|
)
|
|
controller.confirm_dialog.canceled.emit()
|
|
controller.confirm_dialog.hide()
|
|
_check(
|
|
FileAccess.get_file_as_string(overwrite_path) == overwrite_before,
|
|
"canceling keeps the existing file"
|
|
)
|
|
controller.save_as_dialog.confirmed.emit()
|
|
controller.confirm_dialog.confirmed.emit()
|
|
controller.confirm_dialog.hide()
|
|
_check(
|
|
FileAccess.get_file_as_string(overwrite_path) != overwrite_before,
|
|
"confirming replaces the existing file"
|
|
)
|
|
_check(
|
|
controller.get_current_path() == overwrite_path,
|
|
"confirmed save-as becomes the current file"
|
|
)
|
|
DirAccess.remove_absolute(overwrite_path)
|
|
|
|
# Global Delete shortcut must not reach the canvas through a modal.
|
|
var delete_section := controller.get_active_section()
|
|
var segment_count := delete_section.segments.size()
|
|
var doomed := controller.add_segment(
|
|
Vector2(-18.0, 10.0),
|
|
Vector2(-12.0, 10.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
controller.select_segment(doomed.segment_id)
|
|
controller.undo_button.grab_focus()
|
|
controller.message_dialog.hide()
|
|
controller.validation_dialog.popup_centered()
|
|
await process_frame
|
|
var delete_event := InputEventKey.new()
|
|
delete_event.keycode = KEY_DELETE
|
|
delete_event.pressed = true
|
|
controller._unhandled_key_input(delete_event)
|
|
_check(
|
|
delete_section.segments.size() == segment_count + 1,
|
|
"a visible dialog blocks the Delete shortcut"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
controller._unhandled_key_input(delete_event)
|
|
_check(
|
|
delete_section.segments.size() == segment_count,
|
|
"Delete works again after the dialog closes"
|
|
)
|
|
|
|
# A dirty autosave is restored and reattached to the last file path.
|
|
var session_path := "user://routines/session_test.json"
|
|
controller.autosave_enabled = true
|
|
_check(controller.save_to_path(session_path), "session fixture can be saved")
|
|
controller.get_routine().title = "Autosave-Fassung"
|
|
controller._mark_dirty()
|
|
controller._save_autosave()
|
|
OS.delay_msec(1100)
|
|
controller._dirty = true
|
|
controller._save_autosave()
|
|
_check(controller._restore_session(), "session restore succeeds")
|
|
_check(
|
|
controller.get_current_path() == session_path,
|
|
"autosave restore keeps the last file path"
|
|
)
|
|
_check(controller.is_dirty(), "restored autosave is marked dirty")
|
|
_check(
|
|
controller.get_routine().title == "Autosave-Fassung",
|
|
"autosave content wins over the older file"
|
|
)
|
|
_check(controller.save_to_path(session_path), "restored autosave can be saved")
|
|
_check(
|
|
not FileAccess.file_exists(WhiteboardController.AUTOSAVE_PATH),
|
|
"saving removes the stale autosave"
|
|
)
|
|
_check(controller._restore_session(), "clean session restore succeeds")
|
|
_check(
|
|
not controller.is_dirty()
|
|
and controller.get_current_path() == session_path,
|
|
"clean session restores the file without dirty state"
|
|
)
|
|
controller.autosave_enabled = false
|
|
for path: String in [
|
|
session_path,
|
|
WhiteboardController.AUTOSAVE_PATH,
|
|
WhiteboardController.LEGACY_AUTOSAVE_PATH,
|
|
]:
|
|
if FileAccess.file_exists(path):
|
|
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
|
|
|
|
scene.queue_free()
|
|
await process_frame
|
|
_finish()
|
|
|
|
|
|
func _check(condition: bool, message: String) -> void:
|
|
_assertions += 1
|
|
if not condition:
|
|
_failures.append(message)
|
|
|
|
|
|
func _select_option_by_metadata(
|
|
option: OptionButton,
|
|
code: String
|
|
) -> void:
|
|
for index: int in range(option.item_count):
|
|
var metadata: Variant = option.get_item_metadata(index)
|
|
if metadata != null and str(metadata) == code:
|
|
option.select(index)
|
|
option.item_selected.emit(index)
|
|
return
|
|
|
|
|
|
func _select_dialog_code(
|
|
controller: WhiteboardController,
|
|
code: String
|
|
) -> void:
|
|
var index := controller._find_code_option_index(code)
|
|
if index < 0:
|
|
return
|
|
controller.element_code_option.select(index)
|
|
controller.element_code_option.item_selected.emit(index)
|
|
controller.update_element_value_hint()
|
|
|
|
|
|
func _set_dialog_free_text(
|
|
controller: WhiteboardController,
|
|
code: String
|
|
) -> void:
|
|
var free_index := controller.element_code_option.get_item_index(
|
|
WhiteboardController.CODE_OPTION_FREE_ID
|
|
)
|
|
if free_index < 0:
|
|
return
|
|
controller.element_code_option.select(free_index)
|
|
controller.element_code_option.item_selected.emit(free_index)
|
|
controller.element_code_edit.text = code
|
|
controller._update_level_control_state()
|
|
controller.update_element_feature_hint()
|
|
controller.update_element_value_hint()
|
|
|
|
|
|
func _check_approx(actual: float, expected: float, message: String) -> void:
|
|
_check(
|
|
absf(actual - expected) <= 0.001,
|
|
"%s (expected %.3f, got %.3f)" % [message, expected, actual]
|
|
)
|
|
|
|
|
|
func _mouse_button(canvas: RinkCanvas, position: Vector2, pressed: bool) -> void:
|
|
var event := InputEventMouseButton.new()
|
|
event.button_index = MOUSE_BUTTON_LEFT
|
|
event.pressed = pressed
|
|
event.position = position
|
|
canvas._gui_input(event)
|
|
|
|
|
|
func _mouse_motion(
|
|
canvas: RinkCanvas,
|
|
position: Vector2,
|
|
relative: Vector2 = Vector2.ZERO
|
|
) -> void:
|
|
var event := InputEventMouseMotion.new()
|
|
event.position = position
|
|
event.relative = relative
|
|
canvas._gui_input(event)
|
|
|
|
|
|
func _check_vec(actual: Vector2, expected: Vector2, message: String) -> void:
|
|
_check(
|
|
actual.distance_to(expected) <= 0.001,
|
|
"%s (expected %s, got %s)" % [message, expected, actual]
|
|
)
|
|
|
|
|
|
func _contains_error(errors: PackedStringArray, fragment: String) -> bool:
|
|
for error: String in errors:
|
|
if error.contains(fragment):
|
|
return true
|
|
return false
|
|
|
|
|
|
func _finish() -> void:
|
|
if _failures.is_empty():
|
|
print("PASS: %d assertions" % _assertions)
|
|
quit(0)
|
|
return
|
|
|
|
for failure: String in _failures:
|
|
printerr("FAIL: %s" % failure)
|
|
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
|
|
quit(1)
|