Neunter Schritt der Controller-Zerlegung und der erste mit Signalen statt
reiner Funktionen. `ExportPanel` (src/whiteboard/view/export_panel.gd) besitzt
die Dialoge "Kür exportieren" und "Export abgeschlossen" und meldet nur die
Auswahl:
export_requested(pfad, format, abschnitt, danach öffnen)
Der Controller prüft, ob die Datei existiert, fragt über den bestehenden
`confirm_dialog` nach dem Überschreiben, schreibt über `ExportService` und
ruft `panel.show_done()`. Das Panel fasst kein Dateisystem an — so bleibt die
Überschreib-Bestätigung an einer Stelle statt in zwei Dialogen.
- Szene: neuer Knoten `ExportPanel` mit Skript, beide Dialoge und ihre
Kindknoten darunter umgehängt (parent-Pfade sind absolut).
- Tests greifen jetzt über `controller.export_panel.*` zu.
Controller: 8.304 -> 8.245 Zeilen. Suite grün.
2734 lines
83 KiB
GDScript
2734 lines
83 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
|
|
|
|
_check(
|
|
controller.get_tool() == WhiteboardController.Tool.SELECT,
|
|
"the select tool is active at startup"
|
|
)
|
|
|
|
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()
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
_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"
|
|
)
|
|
|
|
# The tool palette is a row of toggle buttons: clicking one switches the
|
|
# tool and exactly one icon stays highlighted.
|
|
var tool_buttons: Array[Button] = [
|
|
controller.get_node("%SelectToolButton"),
|
|
controller.get_node("%LineToolButton"),
|
|
controller.get_node("%ArcLeftToolButton"),
|
|
controller.get_node("%ArcRightToolButton"),
|
|
controller.get_node("%FreeLineToolButton"),
|
|
controller.get_node("%JumpToolButton"),
|
|
controller.get_node("%SpinToolButton"),
|
|
]
|
|
var arc_right_button: Button = controller.get_node("%ArcRightToolButton")
|
|
arc_right_button.pressed.emit()
|
|
_check(
|
|
controller.get_tool() == WhiteboardController.Tool.ARC_RIGHT,
|
|
"clicking a tool icon selects that tool"
|
|
)
|
|
controller.set_tool(WhiteboardController.Tool.ARC_LEFT)
|
|
var highlighted := 0
|
|
for button: Button in tool_buttons:
|
|
if button.button_pressed:
|
|
highlighted += 1
|
|
_check(
|
|
highlighted == 1
|
|
and (controller.get_node("%ArcLeftToolButton") as Button).button_pressed,
|
|
"exactly the active tool icon is highlighted"
|
|
)
|
|
|
|
# Jump and spin pick a point-marker type and share the element tool.
|
|
var element_buttons := [
|
|
["%JumpToolButton", PathSegment.ElementType.JUMP],
|
|
["%SpinToolButton", PathSegment.ElementType.SPIN],
|
|
]
|
|
for entry: Array in element_buttons:
|
|
var button: Button = controller.get_node(entry[0])
|
|
button.pressed.emit()
|
|
_check(
|
|
controller.get_tool() == WhiteboardController.Tool.ELEMENT
|
|
and controller.get_element_type() == entry[1],
|
|
"%s picks its element type" % entry[0]
|
|
)
|
|
var pressed_count := 0
|
|
for candidate: Array in element_buttons:
|
|
if (controller.get_node(candidate[0]) as Button).button_pressed:
|
|
pressed_count += 1
|
|
_check(
|
|
pressed_count == 1 and button.button_pressed,
|
|
"%s is the only highlighted element icon" % entry[0]
|
|
)
|
|
|
|
# The group action replaces the former sequence drawing tool and sits in
|
|
# the same top tool bar, without joining the tool button group.
|
|
var group_button: Button = controller.get_node("%GroupSequenceButton")
|
|
var select_tool_button: Button = controller.get_node("%SelectToolButton")
|
|
_check(
|
|
group_button.get_parent() == controller.get_node("%ToolButtons"),
|
|
"the group action lives in the top tool bar"
|
|
)
|
|
_check(
|
|
group_button.icon != null and group_button.text.is_empty(),
|
|
"the group action is an icon button"
|
|
)
|
|
_check(
|
|
group_button.button_group != select_tool_button.button_group,
|
|
"the group action does not join the tool button group"
|
|
)
|
|
|
|
controller.set_element_type(PathSegment.ElementType.JUMP)
|
|
controller.set_tool(WhiteboardController.Tool.ARC_LEFT)
|
|
_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"
|
|
)
|
|
|
|
# Freehand tool: the drag path is sampled into a multi-point curve.
|
|
var freehand_count_before := section.segments.size()
|
|
controller.set_tool(WhiteboardController.Tool.FREELINE)
|
|
var freehand_path: Array[Vector2] = [
|
|
Vector2(-26.0, 6.0),
|
|
Vector2(-22.0, 8.0),
|
|
Vector2(-18.0, 6.0),
|
|
Vector2(-14.0, 8.0),
|
|
Vector2(-12.0, 6.0),
|
|
]
|
|
_mouse_button(
|
|
canvas,
|
|
view.model_to_screen(freehand_path[0]),
|
|
true
|
|
)
|
|
for index: int in range(1, freehand_path.size()):
|
|
_mouse_motion(canvas, view.model_to_screen(freehand_path[index]))
|
|
_mouse_button(
|
|
canvas,
|
|
view.model_to_screen(freehand_path[freehand_path.size() - 1]),
|
|
false
|
|
)
|
|
_check(
|
|
section.segments.size() == freehand_count_before + 1,
|
|
"freehand mode creates a segment"
|
|
)
|
|
var freehand := section.segments[section.segments.size() - 1]
|
|
_check(freehand.is_freehand(), "freehand path keeps its template")
|
|
_check(
|
|
freehand.curve.point_count == freehand_path.size(),
|
|
"freehand path keeps the sampled points"
|
|
)
|
|
_check(
|
|
freehand.get_length_m() > 10.0,
|
|
"freehand length follows the drawn path"
|
|
)
|
|
_check(
|
|
freehand.duration_seconds > 0.0,
|
|
"freehand duration is derived from the path length"
|
|
)
|
|
_check(not freehand.is_marker(), "freehand is a path segment, not a marker")
|
|
|
|
# Endpoint handles reshape the curve without collapsing it to a line.
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
controller.select_segment(freehand.segment_id)
|
|
var freehand_start := freehand.curve.get_point_position(0)
|
|
controller._apply_handle_drag(
|
|
freehand,
|
|
RinkCanvas.Handle.START,
|
|
freehand_start + Vector2(1.0, 0.5)
|
|
)
|
|
_check(
|
|
freehand.curve.point_count == freehand_path.size(),
|
|
"freehand handle drag keeps all sampled points"
|
|
)
|
|
_check_vec(
|
|
freehand.curve.get_point_position(0),
|
|
freehand_start + Vector2(1.0, 0.5),
|
|
"freehand start handle moves the first point"
|
|
)
|
|
|
|
# Interior freehand points get their own small handles.
|
|
var interior_index := 2
|
|
var interior_before := freehand.curve.get_point_position(interior_index)
|
|
var interior_target := interior_before + Vector2(0.0, 1.5)
|
|
_mouse_button(
|
|
canvas,
|
|
view.model_to_screen(interior_before),
|
|
true
|
|
)
|
|
_mouse_motion(canvas, view.model_to_screen(interior_target))
|
|
_mouse_button(
|
|
canvas,
|
|
view.model_to_screen(interior_target),
|
|
false
|
|
)
|
|
_check(
|
|
freehand.curve.point_count == freehand_path.size(),
|
|
"freehand point drag keeps the sampled points"
|
|
)
|
|
_check_vec(
|
|
freehand.curve.get_point_position(interior_index),
|
|
interior_target,
|
|
"freehand interior point can be dragged"
|
|
)
|
|
_check_vec(
|
|
freehand.curve.get_point_position(0),
|
|
freehand_start + Vector2(1.0, 0.5),
|
|
"dragging one freehand point leaves the others alone"
|
|
)
|
|
|
|
# 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)
|
|
controller.set_element_type(PathSegment.ElementType.JUMP)
|
|
_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(
|
|
jump.get_jump_distance_m(),
|
|
1.0,
|
|
"a jump without a code gets a one metre vector"
|
|
)
|
|
_check(
|
|
controller.status_label.text.contains("1,0 m"),
|
|
"status bar shows the jump distance"
|
|
)
|
|
_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"
|
|
)
|
|
|
|
controller.element_button.pressed.emit()
|
|
_check(
|
|
controller.element_rotation_box.visible,
|
|
"jump dialog shows the rotation direction"
|
|
)
|
|
_check(
|
|
not controller.element_revolutions_box.visible,
|
|
"jump dialog hides the spin revolution field"
|
|
)
|
|
controller.element_dialog.hide()
|
|
|
|
# Dragging the arrow tip stores an explicit jump vector (direction and
|
|
# distance) instead of the code-derived default.
|
|
controller._apply_handle_drag(
|
|
jump,
|
|
RinkCanvas.Handle.JUMP_TIP,
|
|
jump_point + Vector2(0.0, 2.0)
|
|
)
|
|
_check(
|
|
jump.element_jump_vector.is_equal_approx(Vector2(0.0, 2.0)),
|
|
"jump tip drag stores the vector"
|
|
)
|
|
_check_approx(
|
|
jump.get_jump_distance_m(),
|
|
2.0,
|
|
"jump tip drag updates the distance"
|
|
)
|
|
_check(
|
|
canvas._handle_at(view.model_to_screen(jump_point + Vector2(0.0, 2.0)))
|
|
== RinkCanvas.Handle.JUMP_TIP,
|
|
"the arrow tip is a drag handle"
|
|
)
|
|
|
|
# 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,
|
|
4.0,
|
|
"spin gets the default stand time"
|
|
)
|
|
_check_approx(
|
|
spin.element_revolutions,
|
|
10.0,
|
|
"spin starts with the ISU combination minimum"
|
|
)
|
|
_check_approx(
|
|
spin.get_spin_revolutions_per_second(),
|
|
2.5,
|
|
"default spin rotates with 2.5 revolutions per second"
|
|
)
|
|
_check(
|
|
spin.element_rotation_direction
|
|
== PathSegment.RotationDirection.COUNTERCLOCKWISE,
|
|
"new spins rotate counterclockwise by default"
|
|
)
|
|
|
|
_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,
|
|
4.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_sit", "difficult_variation_camel",
|
|
"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_revolutions_box.visible,
|
|
"spin dialog shows the revolution field"
|
|
)
|
|
_check(
|
|
controller.element_rotation_box.visible,
|
|
"spin dialog shows the rotation direction"
|
|
)
|
|
_check(
|
|
controller.element_rotation_option.get_item_id(
|
|
controller.element_rotation_option.selected
|
|
) == PathSegment.RotationDirection.COUNTERCLOCKWISE,
|
|
"spin dialog defaults to counterclockwise"
|
|
)
|
|
_check_approx(
|
|
controller.element_revolutions_spin.value,
|
|
10.0,
|
|
"spin dialog starts with the default revolution count"
|
|
)
|
|
_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_sit", "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 == 21,
|
|
"feature menu lists 19 features plus separator and reset"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.get_item_metadata(0) == "difficult_variation_sit",
|
|
"feature menu items carry their feature code"
|
|
)
|
|
_check(
|
|
controller.element_feature_menu.is_item_checked(0),
|
|
"the selected difficult variation is checked"
|
|
)
|
|
var exit_index := -1
|
|
for index: int in range(controller.element_feature_menu.item_count):
|
|
if (
|
|
str(controller.element_feature_menu.get_item_metadata(index))
|
|
== "difficult_exit"
|
|
):
|
|
exit_index = index
|
|
_check(
|
|
exit_index >= 0
|
|
and controller.element_feature_menu.is_item_checked(exit_index),
|
|
"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_revolutions_spin.value = 12.0
|
|
var clockwise_index := controller.element_rotation_option.get_item_index(
|
|
PathSegment.RotationDirection.CLOCKWISE
|
|
)
|
|
controller.element_rotation_option.select(clockwise_index)
|
|
_check(
|
|
controller.element_revolutions_label.text.contains("1,8 U/s"),
|
|
"dialog shows the rate derived from revolutions and stand time"
|
|
)
|
|
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_approx(
|
|
controller.get_selected_segment().element_revolutions,
|
|
12.0,
|
|
"element dialog applies the revolution count"
|
|
)
|
|
_check_approx(
|
|
controller.get_selected_segment().get_spin_revolutions_per_second(),
|
|
12.0 / 6.5,
|
|
"the spin rate follows revolutions per stand time"
|
|
)
|
|
_check(
|
|
controller.get_selected_segment().element_rotation_direction
|
|
== PathSegment.RotationDirection.CLOCKWISE,
|
|
"element dialog applies the rotation direction"
|
|
)
|
|
|
|
_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"
|
|
)
|
|
_check_approx(
|
|
spin.element_revolutions,
|
|
10.0,
|
|
"undo restores the previous revolution count"
|
|
)
|
|
_check(
|
|
spin.element_rotation_direction
|
|
== PathSegment.RotationDirection.COUNTERCLOCKWISE,
|
|
"undo restores the previous rotation direction"
|
|
)
|
|
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_sit", "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()
|
|
|
|
# Season assignment: the routine carries the rule package it is checked
|
|
# against, and a season switch must not silently rewrite its data.
|
|
controller.new_routine()
|
|
_check(
|
|
controller.get_season() == "2026/27",
|
|
"a new routine gets the default season"
|
|
)
|
|
_check(
|
|
controller.get_rules_package() != null
|
|
and controller.get_rules_package().season == "2026/27",
|
|
"the active rule package matches the routine"
|
|
)
|
|
_check(
|
|
controller.set_adult_category("gold"),
|
|
"Gold is available in the default season"
|
|
)
|
|
_check(controller.set_season("2025/26"), "the season can be switched to 2025/26")
|
|
_check(
|
|
controller.get_rules_package().season == "2025/26",
|
|
"the rule package follows the season"
|
|
)
|
|
_check(
|
|
controller.get_routine().adult_category == "gold",
|
|
"the category is kept when the season changes"
|
|
)
|
|
var gold_index := -1
|
|
for index: int in range(controller.adult_category_option.item_count):
|
|
if str(controller.adult_category_option.get_item_metadata(index)) == "gold":
|
|
gold_index = index
|
|
_check(gold_index >= 0, "Gold is available in 2025/26 as well")
|
|
_check(
|
|
controller.adult_category_option.selected == gold_index,
|
|
"the dropdown keeps the selected category"
|
|
)
|
|
|
|
# A category the season does not know stays visible instead of being hidden.
|
|
controller.get_routine().adult_category = "legacy_category"
|
|
controller._sync_adult_category_option()
|
|
var unknown_index := -1
|
|
for index: int in range(controller.adult_category_option.item_count):
|
|
if (
|
|
str(controller.adult_category_option.get_item_metadata(index))
|
|
== "legacy_category"
|
|
):
|
|
unknown_index = index
|
|
_check(unknown_index >= 0, "a stored category stays visible")
|
|
_check(
|
|
controller.adult_category_option.get_item_text(unknown_index).contains(
|
|
"nicht verfügbar"
|
|
),
|
|
"an unavailable category is labelled instead of hidden"
|
|
)
|
|
controller.get_routine().adult_category = "gold"
|
|
controller._setup_adult_category_controls()
|
|
var selected_season := controller.season_option.selected
|
|
_check(
|
|
str(controller.season_option.get_item_metadata(selected_season)) == "2025/26",
|
|
"the season dropdown reflects the routine"
|
|
)
|
|
|
|
_check(controller.set_season(""), "the season can be cleared")
|
|
_check(
|
|
controller.get_rules_package() == null,
|
|
"without a season there is no rule package"
|
|
)
|
|
var unassigned_issues := controller.validate_routine()
|
|
_check(
|
|
not unassigned_issues.is_empty(),
|
|
"an unassigned season blocks element validation"
|
|
)
|
|
controller.open_validation_dialog()
|
|
_check(
|
|
controller.validation_text.text.contains("Saison nicht festgelegt"),
|
|
"the dialog explains the missing season"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
_check(
|
|
not controller.set_season("2030/31"),
|
|
"an unknown season is rejected"
|
|
)
|
|
|
|
# Saison-Upgrade-Prüfung: berichtet nur, ändert erst auf Bestätigung.
|
|
controller.new_routine()
|
|
controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.SPIN,
|
|
"ChSp",
|
|
1
|
|
)
|
|
controller.open_validation_dialog()
|
|
controller._on_validation_meta_clicked("upgrade")
|
|
_check(controller.upgrade_dialog.visible, "the upgrade dialog opens")
|
|
_check(
|
|
controller.validation_dialog.visible,
|
|
"the check dialog stays open behind the comparison"
|
|
)
|
|
_check(
|
|
controller.upgrade_text.text.contains("nicht im Katalog"),
|
|
"the report names the element the target season lacks"
|
|
)
|
|
_check(
|
|
not controller.upgrade_apply_button.disabled,
|
|
"switching the season is offered after the check"
|
|
)
|
|
_check(
|
|
controller.get_season() == "2026/27",
|
|
"checking alone does not change the season"
|
|
)
|
|
_check(
|
|
not controller.upgrade_pdf_button.disabled,
|
|
"the comparison can be written as a PDF"
|
|
)
|
|
controller._on_upgrade_pdf_pressed()
|
|
_check(
|
|
controller._last_export_path.ends_with(".pdf"),
|
|
"the comparison PDF lands in the export folder"
|
|
)
|
|
_check(
|
|
FileAccess.file_exists(controller._last_export_path),
|
|
"the comparison PDF was written"
|
|
)
|
|
controller.export_panel.done_dialog.hide()
|
|
controller._on_upgrade_apply_pressed()
|
|
_check(
|
|
controller.get_season() == "2025/26",
|
|
"confirming switches the routine to the target season"
|
|
)
|
|
controller.upgrade_dialog.hide()
|
|
controller.validation_dialog.hide()
|
|
|
|
# Programmtyp: Artistic hat eigene Grenzen und keine Punktschätzung.
|
|
controller.new_routine()
|
|
_check(
|
|
controller.get_program_type() == "free",
|
|
"a new routine is a free-skating programme"
|
|
)
|
|
_check(
|
|
controller.set_adult_category("gold"),
|
|
"Gold is available for free skating"
|
|
)
|
|
controller.open_validation_dialog()
|
|
_check(
|
|
controller.validation_text.text.contains("Geschätzte Summe"),
|
|
"free skating shows a score estimate"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
|
|
_check(
|
|
controller.set_program_type("artistic"),
|
|
"the programme type can be switched to artistic"
|
|
)
|
|
_check(
|
|
controller.get_program_type() == "artistic",
|
|
"the routine stores the programme type"
|
|
)
|
|
controller.open_validation_dialog()
|
|
_check(
|
|
controller.validation_text.text.contains("keine Punktschätzung"),
|
|
"artistic shows no score estimate"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("Gold · Artistic"),
|
|
"the header names the programme type"
|
|
)
|
|
_check(
|
|
controller.validation_text.text.contains("mindestens 1"),
|
|
"artistic reports the required minimum"
|
|
)
|
|
controller.validation_dialog.hide()
|
|
_check(
|
|
not controller.set_program_type("ballett"),
|
|
"unknown programme types are rejected"
|
|
)
|
|
|
|
controller.new_routine()
|
|
|
|
# Fuß-Deckel: ab drei fußbezogenen Features fragt der Dialog nach dem Fuß.
|
|
var spin_segment := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.SPIN,
|
|
"CCoSp",
|
|
0
|
|
)
|
|
controller.select_segment(spin_segment.segment_id)
|
|
_check(
|
|
controller.set_selected_element_features(
|
|
PackedStringArray(
|
|
[
|
|
"difficult_variation_sit",
|
|
"difficult_variation_camel",
|
|
"change_of_edge",
|
|
]
|
|
),
|
|
{
|
|
"difficult_variation_sit": "L",
|
|
"difficult_variation_camel": "R",
|
|
"change_of_edge": "R",
|
|
}
|
|
),
|
|
"features with their foot are stored on the segment"
|
|
)
|
|
_check(
|
|
spin_segment.element_feature_feet.size() == 3,
|
|
"the foot of each feature is stored"
|
|
)
|
|
controller.element_button.pressed.emit()
|
|
_check(
|
|
controller.spin_foot_panel.visible,
|
|
"the foot selector appears for three per-foot features"
|
|
)
|
|
_check(
|
|
controller.spin_foot_panel.get_child_count() == 3,
|
|
"one row per per-foot feature"
|
|
)
|
|
controller.element_dialog.hide()
|
|
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))
|
|
|
|
# Element markers take their chronological position from the drawn path:
|
|
# taps at the start or between segments insert instead of appending.
|
|
controller.new_routine()
|
|
var insert_section := controller.get_active_section()
|
|
var first_path := controller.add_segment(
|
|
Vector2(-20.0, 0.0),
|
|
Vector2(-10.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
var second_path := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
var start_marker := controller.add_element_marker(
|
|
Vector2(-19.5, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
"1T",
|
|
0
|
|
)
|
|
_check(
|
|
insert_section.segments.find(start_marker) == 0,
|
|
"a tap at the path start inserts the marker at the beginning"
|
|
)
|
|
var middle_marker := controller.add_element_marker(
|
|
Vector2(-10.0, 0.0),
|
|
PathSegment.ElementType.SPIN,
|
|
"CCoSp",
|
|
0
|
|
)
|
|
_check(
|
|
insert_section.segments.find(middle_marker) == 2,
|
|
"a tap between two segments inserts the marker there"
|
|
)
|
|
_check(
|
|
insert_section.segments.find(first_path)
|
|
< insert_section.segments.find(middle_marker)
|
|
and insert_section.segments.find(middle_marker)
|
|
< insert_section.segments.find(second_path),
|
|
"the inserted marker keeps the path order"
|
|
)
|
|
var end_marker := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.SEQUENCE,
|
|
"StSq",
|
|
0
|
|
)
|
|
_check(
|
|
insert_section.segments.find(end_marker)
|
|
== insert_section.segments.size() - 1,
|
|
"a tap behind the last segment appends the marker"
|
|
)
|
|
|
|
# Grouping consecutive segments creates one sequence range.
|
|
controller.new_routine()
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
var sequence_view := canvas.get_view_transform()
|
|
var sequence_section := controller.get_active_section()
|
|
for x_start: float in [-15.0, -5.0, 5.0]:
|
|
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_start, 0.0)), true)
|
|
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(x_start + 10.0, 0.0)))
|
|
_mouse_button(
|
|
canvas,
|
|
sequence_view.model_to_screen(Vector2(x_start + 10.0, 0.0)),
|
|
false
|
|
)
|
|
_check(
|
|
sequence_section.segments.size() == 3,
|
|
"the sequence fixture has three segments"
|
|
)
|
|
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
controller.set_multi_select_enabled(true)
|
|
controller.clear_selection()
|
|
for x_mid: float in [-10.0, 0.0, 10.0]:
|
|
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_mid, 0.0)), true)
|
|
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_mid, 0.0)), false)
|
|
_check(
|
|
controller.get_selected_segment_ids().size() == 3,
|
|
"the sequence fixture selects all three segments"
|
|
)
|
|
controller.group_sequence_button.pressed.emit()
|
|
|
|
var sequence_elements := sequence_section.get_elements()
|
|
_check(
|
|
sequence_elements.size() == 1,
|
|
"three grouped segments resolve to one sequence element"
|
|
)
|
|
if sequence_elements.size() == 1:
|
|
var sequence_element: ResolvedElement = sequence_elements[0]
|
|
_check(
|
|
sequence_element.segments.size() == 3,
|
|
"the sequence group contains all grouped segments"
|
|
)
|
|
_check(
|
|
sequence_element.get_lead() == sequence_section.segments[0],
|
|
"the first grouped segment is the sequence lead"
|
|
)
|
|
_check(
|
|
sequence_element.get_code() == "StSq",
|
|
"a new sequence starts with the StSq code"
|
|
)
|
|
_check(
|
|
sequence_element.is_sequence_range(),
|
|
"the grouped range is a sequence range, not a point marker"
|
|
)
|
|
_check(
|
|
controller.timeline_label_lane.get_element_label_count() == 1,
|
|
"the sequence group shows one timeline label"
|
|
)
|
|
|
|
# Later segments do not join the group unless they are grouped again.
|
|
controller.set_tool(WhiteboardController.Tool.LINE)
|
|
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-15.0, 5.0)), true)
|
|
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(-5.0, 5.0)))
|
|
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-5.0, 5.0)), false)
|
|
_check(
|
|
sequence_section.segments.size() == 4,
|
|
"a segment drawn after grouping is added to the section"
|
|
)
|
|
_check(
|
|
sequence_section.get_elements().size() == 1
|
|
and sequence_section.get_elements()[0].segments.size() == 3,
|
|
"a segment drawn after grouping stays outside the group"
|
|
)
|
|
|
|
# Selecting a member shows and edits the lead element.
|
|
var sequence_member := sequence_section.segments[1]
|
|
controller.select_segment(sequence_member.segment_id)
|
|
_check(
|
|
controller.get_selected_element() != null
|
|
and controller.get_selected_element().segments.size() == 3,
|
|
"selecting a member resolves the whole sequence"
|
|
)
|
|
controller.element_button.pressed.emit()
|
|
_check(controller.element_dialog.visible, "the element dialog opens from a member")
|
|
_check(
|
|
controller.element_dialog_type_option.get_item_id(
|
|
controller.element_dialog_type_option.selected
|
|
) == PathSegment.ElementType.SEQUENCE,
|
|
"the dialog shows the sequence type of the group"
|
|
)
|
|
controller.element_dialog.hide()
|
|
|
|
# Deleting the lead promotes the next member and keeps the element data.
|
|
var old_lead := sequence_section.get_elements()[0].get_lead()
|
|
controller.select_segment(old_lead.segment_id)
|
|
_check(controller.delete_selected_segment(), "the sequence lead can be deleted")
|
|
var promoted := sequence_section.get_elements()
|
|
_check(
|
|
promoted.size() == 1 and promoted[0].get_lead() != old_lead,
|
|
"deleting the lead promotes another member"
|
|
)
|
|
if promoted.size() == 1:
|
|
_check(
|
|
promoted[0].get_code() == "StSq",
|
|
"the promoted member keeps the sequence code"
|
|
)
|
|
|
|
# Clearing the element dissolves the group but keeps the path segments.
|
|
controller.select_segment(promoted[0].segments[0].segment_id)
|
|
_check(
|
|
controller.set_selected_element(PathSegment.ElementType.NONE, "", 0),
|
|
"the element can be cleared from a group"
|
|
)
|
|
_check(
|
|
promoted[0].segments[0].element_group_id.is_empty(),
|
|
"clearing the element removes the group id"
|
|
)
|
|
_check(
|
|
sequence_section.get_elements().is_empty(),
|
|
"a cleared group resolves to no elements"
|
|
)
|
|
|
|
# A marker placed near a group must not split the group in two.
|
|
controller.new_routine()
|
|
var group_section := controller.get_active_section()
|
|
var group_a := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
var group_b := controller.add_segment(
|
|
Vector2(0.0, 0.0),
|
|
Vector2(10.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
_check(
|
|
controller.group_segments_as_sequence(
|
|
PackedStringArray([group_a.segment_id, group_b.segment_id]),
|
|
"StSq",
|
|
0
|
|
) != null,
|
|
"existing segments can be grouped as a sequence"
|
|
)
|
|
var group_marker := controller.add_element_marker(
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.ElementType.JUMP,
|
|
"1T",
|
|
0
|
|
)
|
|
_check(
|
|
group_section.get_elements().size() == 2
|
|
and group_section.get_elements()[0].segments.size() == 2,
|
|
"a marker near the group does not split the sequence"
|
|
)
|
|
_check(
|
|
group_section.segments.find(group_marker) > group_section.segments.find(group_b),
|
|
"the marker is inserted behind the group"
|
|
)
|
|
_check(group_section.is_valid(), "the section stays valid with marker and group")
|
|
|
|
# A single segment can be tagged as a sequence range without a group id.
|
|
controller.new_routine()
|
|
var legacy_range := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
controller.select_segment(legacy_range.segment_id)
|
|
_check(
|
|
controller.set_selected_element(
|
|
PathSegment.ElementType.SEQUENCE,
|
|
"StSq",
|
|
0
|
|
),
|
|
"a single segment can be tagged as a sequence range"
|
|
)
|
|
_check(
|
|
legacy_range.element_group_id.is_empty(),
|
|
"a single tagged segment needs no group id yet"
|
|
)
|
|
|
|
# Multi-selection groups existing segments into a sequence.
|
|
controller.new_routine()
|
|
controller.set_tool(WhiteboardController.Tool.SELECT)
|
|
var group_view := canvas.get_view_transform()
|
|
var multi_a := controller.add_segment(
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(0.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
var multi_b := controller.add_segment(
|
|
Vector2(0.0, 0.0),
|
|
Vector2(10.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
var multi_c := controller.add_segment(
|
|
Vector2(10.0, 0.0),
|
|
Vector2(20.0, 0.0),
|
|
PathSegment.Direction.FORWARD,
|
|
PathSegment.Edge.OUTSIDE
|
|
)
|
|
controller.set_multi_select_enabled(true)
|
|
_check(
|
|
controller.multi_select_button.button_pressed,
|
|
"multi-select mode is reflected by the toggle button"
|
|
)
|
|
controller.clear_selection()
|
|
var multi_taps: Array[Vector2] = [
|
|
Vector2(-5.0, 0.0),
|
|
Vector2(5.0, 0.0),
|
|
Vector2(15.0, 0.0),
|
|
]
|
|
for point: Vector2 in multi_taps:
|
|
_mouse_button(canvas, group_view.model_to_screen(point), true)
|
|
_mouse_button(canvas, group_view.model_to_screen(point), false)
|
|
_check(
|
|
controller.get_selected_segment_ids().size() == 3,
|
|
"multi-select mode adds tapped segments to the selection"
|
|
)
|
|
_mouse_button(canvas, group_view.model_to_screen(Vector2(0.0, 12.0)), true)
|
|
_mouse_button(canvas, group_view.model_to_screen(Vector2(0.0, 12.0)), false)
|
|
_check(
|
|
controller.get_selected_segment_ids().size() == 3,
|
|
"tapping empty ice in multi-select mode keeps the selection"
|
|
)
|
|
_check(
|
|
controller.can_group_selected_as_sequence(),
|
|
"a contiguous multi-selection can become a sequence"
|
|
)
|
|
_check(
|
|
not controller.group_sequence_button.disabled,
|
|
"the group button is enabled for a valid selection"
|
|
)
|
|
_check(
|
|
controller.group_sequence_button.tooltip_text.contains("3"),
|
|
"the group button tooltip shows the selection count"
|
|
)
|
|
controller.group_sequence_button.pressed.emit()
|
|
var grouped_elements := controller.get_active_section().get_elements()
|
|
_check(
|
|
grouped_elements.size() == 1
|
|
and grouped_elements[0].segments.size() == 3,
|
|
"the group button creates one sequence element"
|
|
)
|
|
_check(
|
|
not controller.is_multi_select_enabled()
|
|
and controller.get_selected_segment_ids().size() == 1,
|
|
"grouping leaves one selected lead and ends multi-select mode"
|
|
)
|
|
if grouped_elements.size() == 1:
|
|
_check(
|
|
grouped_elements[0].get_lead() == multi_a,
|
|
"grouping starts at the first selected segment"
|
|
)
|
|
_check(
|
|
controller.group_sequence_button.disabled,
|
|
"the group button disables after grouping"
|
|
)
|
|
|
|
_check(controller.undo(), "grouping can be undone")
|
|
var ungrouped_section := controller.get_active_section()
|
|
_check(
|
|
ungrouped_section.get_elements().is_empty(),
|
|
"undo restores the plain segments"
|
|
)
|
|
|
|
# A selection with a gap cannot be grouped.
|
|
controller.set_multi_select_enabled(true)
|
|
controller.clear_selection()
|
|
for point: Vector2 in [Vector2(-5.0, 0.0), Vector2(15.0, 0.0)]:
|
|
_mouse_button(canvas, group_view.model_to_screen(point), true)
|
|
_mouse_button(canvas, group_view.model_to_screen(point), false)
|
|
_check(
|
|
controller.get_selected_segment_ids().size() == 2,
|
|
"the gap fixture selects two segments"
|
|
)
|
|
_check(
|
|
not controller.can_group_selected_as_sequence()
|
|
and controller.group_sequence_button.disabled,
|
|
"a non-contiguous selection cannot be grouped"
|
|
)
|
|
controller.set_multi_select_enabled(false)
|
|
|
|
# Smoothing a jagged freehand keeps endpoints and point count, is
|
|
# undoable and is exposed through the timing-bar button.
|
|
controller.new_routine()
|
|
var smooth_section := controller.get_active_section()
|
|
var smooth_segment := PathSegment.new()
|
|
smooth_segment.segment_id = "seg-smooth"
|
|
smooth_segment.template = PathSegment.Template.FREEHAND
|
|
smooth_segment.curve = Curve2D.new()
|
|
var smooth_points: Array[Vector2] = [
|
|
Vector2(-10.0, 0.0),
|
|
Vector2(-8.0, 2.0),
|
|
Vector2(-6.0, -2.0),
|
|
Vector2(-4.0, 2.0),
|
|
Vector2(-2.0, 0.0),
|
|
]
|
|
for point: Vector2 in smooth_points:
|
|
smooth_segment.curve.add_point(point)
|
|
smooth_segment.set_speed_mps(4.3)
|
|
smooth_section.segments.append(smooth_segment)
|
|
controller.select_segment(smooth_segment.segment_id)
|
|
_check(
|
|
controller.smooth_button.visible
|
|
and not controller.smooth_button.disabled,
|
|
"the smooth button is available for a selected freehand"
|
|
)
|
|
_check(
|
|
controller.can_smooth_selected_freehand(),
|
|
"a multi-point freehand can be smoothed"
|
|
)
|
|
var before_jitter := smooth_segment.curve.get_point_position(2)
|
|
var before_length := smooth_segment.get_length_m()
|
|
controller.smooth_button.pressed.emit()
|
|
_check(
|
|
smooth_segment.curve.point_count == smooth_points.size(),
|
|
"smoothing keeps the point count"
|
|
)
|
|
_check_vec(
|
|
smooth_segment.curve.get_point_position(0),
|
|
smooth_points[0],
|
|
"smoothing keeps the first freehand point"
|
|
)
|
|
_check_vec(
|
|
smooth_segment.curve.get_point_position(smooth_points.size() - 1),
|
|
smooth_points[smooth_points.size() - 1],
|
|
"smoothing keeps the last freehand point"
|
|
)
|
|
_check_vec(
|
|
smooth_segment.curve.get_point_position(2),
|
|
Vector2(-6.0, 0.25),
|
|
"smoothing moves the interior point between its neighbours"
|
|
)
|
|
_check(
|
|
absf(smooth_segment.get_length_m() - before_length) > 0.01,
|
|
"smoothing updates the freehand length"
|
|
)
|
|
_check(controller.undo(), "smoothing can be undone")
|
|
var restored := controller.get_active_section().get_segment_by_id(
|
|
"seg-smooth"
|
|
)
|
|
_check(restored != null, "the smoothed freehand survives undo")
|
|
if restored != null:
|
|
_check_vec(
|
|
restored.curve.get_point_position(2),
|
|
before_jitter,
|
|
"undo restores the original freehand points"
|
|
)
|
|
|
|
# Freehand strokes are simplified automatically at the end of the drag.
|
|
controller.new_routine()
|
|
controller.set_tool(WhiteboardController.Tool.FREELINE)
|
|
var simplify_view := canvas.get_view_transform()
|
|
var dense_points: Array[Vector2] = []
|
|
for index: int in range(24):
|
|
dense_points.append(
|
|
Vector2(-20.0 + float(index), 0.02 * float(index % 2))
|
|
)
|
|
_mouse_button(
|
|
canvas,
|
|
simplify_view.model_to_screen(dense_points[0]),
|
|
true
|
|
)
|
|
for index: int in range(1, dense_points.size()):
|
|
_mouse_motion(
|
|
canvas,
|
|
simplify_view.model_to_screen(dense_points[index])
|
|
)
|
|
_mouse_button(
|
|
canvas,
|
|
simplify_view.model_to_screen(dense_points[dense_points.size() - 1]),
|
|
false
|
|
)
|
|
var dense_section := controller.get_active_section()
|
|
var dense_freehand := dense_section.segments[
|
|
dense_section.segments.size() - 1
|
|
]
|
|
_check(
|
|
dense_freehand.curve.point_count < dense_points.size(),
|
|
"freehand drawing simplifies dense points automatically"
|
|
)
|
|
_check_vec(
|
|
dense_freehand.curve.get_point_position(0),
|
|
dense_points[0],
|
|
"automatic simplification keeps the start point"
|
|
)
|
|
_check_vec(
|
|
dense_freehand.curve.get_point_position(
|
|
dense_freehand.curve.point_count - 1
|
|
),
|
|
dense_points[dense_points.size() - 1],
|
|
"automatic simplification keeps the end point"
|
|
)
|
|
_check(
|
|
dense_freehand.duration_seconds > 0.0,
|
|
"automatic simplification keeps a valid duration"
|
|
)
|
|
|
|
# The manual button reduces an existing freehand and is undoable.
|
|
controller.new_routine()
|
|
var simplify_section := controller.get_active_section()
|
|
var simplify_segment := PathSegment.new()
|
|
simplify_segment.segment_id = "seg-simplify"
|
|
simplify_segment.template = PathSegment.Template.FREEHAND
|
|
simplify_segment.curve = Curve2D.new()
|
|
var simplify_points: Array[Vector2] = []
|
|
for index: int in range(30):
|
|
var point := Vector2(
|
|
-18.0 + float(index),
|
|
0.02 * float(index % 2)
|
|
)
|
|
simplify_points.append(point)
|
|
simplify_segment.curve.add_point(point)
|
|
simplify_segment.set_speed_mps(4.3)
|
|
simplify_section.segments.append(simplify_segment)
|
|
controller.select_segment(simplify_segment.segment_id)
|
|
_check(
|
|
controller.simplify_button.visible
|
|
and not controller.simplify_button.disabled,
|
|
"the simplify button is available for a selected freehand"
|
|
)
|
|
_check(
|
|
controller.can_simplify_selected_freehand(),
|
|
"a multi-point freehand can be simplified"
|
|
)
|
|
controller.simplify_button.pressed.emit()
|
|
_check(
|
|
simplify_segment.curve.point_count < simplify_points.size(),
|
|
"the simplify button reduces the point count"
|
|
)
|
|
_check_vec(
|
|
simplify_segment.curve.get_point_position(0),
|
|
simplify_points[0],
|
|
"manual simplification keeps the start point"
|
|
)
|
|
_check_vec(
|
|
simplify_segment.curve.get_point_position(
|
|
simplify_segment.curve.point_count - 1
|
|
),
|
|
simplify_points[simplify_points.size() - 1],
|
|
"manual simplification keeps the end point"
|
|
)
|
|
_check(controller.undo(), "manual simplification can be undone")
|
|
var restored_simplify := controller.get_active_section().get_segment_by_id(
|
|
"seg-simplify"
|
|
)
|
|
_check(
|
|
restored_simplify != null
|
|
and restored_simplify.curve.point_count == simplify_points.size(),
|
|
"undo restores the dense freehand points"
|
|
)
|
|
|
|
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)
|