test: ExportPanel als eigenständige Szene mit eigenem Test

Die Probe aufs Exempel für die Modularisierung: `ExportPanel` liegt jetzt in
`scenes/export/export_panel.tscn`, die Whiteboard-Szene instanziiert sie nur
noch. Der neue `run_export_panel_tests.gd` lädt ausschließlich diese Szene und
prüft die Signale — 15 Assertions ohne WhiteboardController.

Damit ist zum ersten Mal ein Baustein nicht nur im Code, sondern auch in der
Prüfbarkeit getrennt. Die übrigen Suiten starten weiter die volle Szene.

Stolpersteine, beide dokumentiert: Kindknoten eines Szenen-Roots brauchen
`parent="."`, und ein eigener Test braucht `root.size` vor `popup_centered`,
sonst landen Fenster headless auf negativen Koordinaten.
This commit is contained in:
torsten 2026-11-13 15:03:07 +01:00
parent e47b8e0a9a
commit 94ec11ad87
7 changed files with 290 additions and 131 deletions

View file

@ -0,0 +1,134 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://src/whiteboard/view/export_panel.gd" id="1_export_panel"]
[node name="ExportPanel" type="Node"]
unique_name_in_owner = true
script = ExtResource("1_export_panel")
[node name="ExportDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Kür exportieren"
size = Vector2i(480, 520)
wrap_controls = false
ok_button_text = "Exportieren"
cancel_button_text = "Abbrechen"
[node name="ExportScroll" type="ScrollContainer" parent="ExportDialog"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_top = 8.0
offset_right = -8.0
offset_bottom = -64.0
grow_horizontal = 2
grow_vertical = 2
horizontal_scroll_mode = 0
follow_focus = true
[node name="ExportBox" type="VBoxContainer" parent="ExportDialog/ExportScroll"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="ExportNameLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Dateiname"
[node name="ExportNameEdit" type="LineEdit" parent="ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportFormatLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Format"
[node name="ExportFormatOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportScopeLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Umfang"
[node name="ExportScopeOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportHint" type="Label" parent="ExportDialog/ExportScroll/ExportBox"]
custom_minimum_size = Vector2(0, 34)
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 12
text = "Ziel: export-Ordner im App-Datenverzeichnis · der absolute Pfad erscheint nach dem Export"
autowrap_mode = 3
[node name="ExportOpenAfterCheck" type="CheckBox" parent="ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 44)
layout_mode = 2
button_pressed = true
text = "Nach dem Export öffnen"
tooltip_text = "Ergebnis nach dem Export mit dem Standardprogramm öffnen"
[node name="ExportDoneDialog" type="AcceptDialog" parent="."]
unique_name_in_owner = true
title = "Export abgeschlossen"
size = Vector2i(660, 320)
wrap_controls = false
exclusive = false
ok_button_text = "Schließen"
[node name="ExportDoneBox" type="VBoxContainer" parent="ExportDoneDialog"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 12.0
offset_top = 12.0
offset_right = -12.0
offset_bottom = -64.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 4
[node name="ExportDoneLabel" type="RichTextLabel" parent="ExportDoneDialog/ExportDoneBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 96)
layout_mode = 2
size_flags_vertical = 3
bbcode_enabled = false
scroll_active = false
selection_enabled = true
autowrap_mode = 3
[node name="ExportDoneButtons" type="HFlowContainer" parent="ExportDoneDialog/ExportDoneBox"]
layout_mode = 2
theme_override_constants/h_separation = 6
theme_override_constants/v_separation = 8
[node name="ExportOpenButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(140, 48)
layout_mode = 2
text = "Öffnen"
tooltip_text = "Datei mit dem Standardprogramm öffnen"
[node name="ExportFolderButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(180, 48)
layout_mode = 2
text = "Ordner anzeigen"
tooltip_text = "Exportordner im Dateimanager öffnen"
[node name="ExportCopyPathButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(170, 48)
layout_mode = 2
text = "Pfad kopieren"
tooltip_text = "Absoluten Dateipfad in die Zwischenablage kopieren"

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=24 format=3]
[gd_scene load_steps=25 format=3]
[ext_resource type="Script" path="res://src/whiteboard/ctrl/whiteboard_controller.gd" id="1_controller"]
[ext_resource type="Script" path="res://src/whiteboard/view/rink_canvas.gd" id="2_canvas"]
[ext_resource type="Script" path="res://src/whiteboard/view/timeline_label_lane.gd" id="3_label_lane"]
[ext_resource type="Script" path="res://src/whiteboard/view/export_panel.gd" id="3_export_panel"]
[ext_resource type="Script" path="res://src/whiteboard/view/playback_panel.gd" id="3_playback_panel"]
[ext_resource type="PackedScene" path="res://scenes/export/export_panel.tscn" id="14_export_panel_scene"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/select.svg" id="4_tool_select"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/line.svg" id="5_tool_line"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/arc_left.svg" id="6_tool_arc_left"]
@ -1654,136 +1655,8 @@ text = "Geschwindigkeit = Strecke / Zeit"
unique_name_in_owner = true
script = ExtResource("3_playback_panel")
[node name="ExportPanel" type="Node" parent="."]
[node name="ExportPanel" parent="." instance=ExtResource("14_export_panel_scene")]
unique_name_in_owner = true
script = ExtResource("3_export_panel")
[node name="ExportDialog" type="ConfirmationDialog" parent="ExportPanel"]
unique_name_in_owner = true
title = "Kür exportieren"
size = Vector2i(480, 520)
wrap_controls = false
ok_button_text = "Exportieren"
cancel_button_text = "Abbrechen"
[node name="ExportScroll" type="ScrollContainer" parent="ExportPanel/ExportDialog"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_top = 8.0
offset_right = -8.0
offset_bottom = -64.0
grow_horizontal = 2
grow_vertical = 2
horizontal_scroll_mode = 0
follow_focus = true
[node name="ExportBox" type="VBoxContainer" parent="ExportPanel/ExportDialog/ExportScroll"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="ExportNameLabel" type="Label" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Dateiname"
[node name="ExportNameEdit" type="LineEdit" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportFormatLabel" type="Label" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Format"
[node name="ExportFormatOption" type="OptionButton" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportScopeLabel" type="Label" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
layout_mode = 2
text = "Umfang"
[node name="ExportScopeOption" type="OptionButton" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
[node name="ExportHint" type="Label" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
custom_minimum_size = Vector2(0, 34)
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 12
text = "Ziel: export-Ordner im App-Datenverzeichnis · der absolute Pfad erscheint nach dem Export"
autowrap_mode = 3
[node name="ExportOpenAfterCheck" type="CheckBox" parent="ExportPanel/ExportDialog/ExportScroll/ExportBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 44)
layout_mode = 2
button_pressed = true
text = "Nach dem Export öffnen"
tooltip_text = "Ergebnis nach dem Export mit dem Standardprogramm öffnen"
[node name="ExportDoneDialog" type="AcceptDialog" parent="ExportPanel"]
unique_name_in_owner = true
title = "Export abgeschlossen"
size = Vector2i(660, 320)
wrap_controls = false
exclusive = false
ok_button_text = "Schließen"
[node name="ExportDoneBox" type="VBoxContainer" parent="ExportPanel/ExportDoneDialog"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 12.0
offset_top = 12.0
offset_right = -12.0
offset_bottom = -64.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 4
[node name="ExportDoneLabel" type="RichTextLabel" parent="ExportPanel/ExportDoneDialog/ExportDoneBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 96)
layout_mode = 2
size_flags_vertical = 3
bbcode_enabled = false
scroll_active = false
selection_enabled = true
autowrap_mode = 3
[node name="ExportDoneButtons" type="HFlowContainer" parent="ExportPanel/ExportDoneDialog/ExportDoneBox"]
layout_mode = 2
theme_override_constants/h_separation = 6
theme_override_constants/v_separation = 8
[node name="ExportOpenButton" type="Button" parent="ExportPanel/ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(140, 48)
layout_mode = 2
text = "Öffnen"
tooltip_text = "Datei mit dem Standardprogramm öffnen"
[node name="ExportFolderButton" type="Button" parent="ExportPanel/ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(180, 48)
layout_mode = 2
text = "Ordner anzeigen"
tooltip_text = "Exportordner im Dateimanager öffnen"
[node name="ExportCopyPathButton" type="Button" parent="ExportPanel/ExportDoneDialog/ExportDoneBox/ExportDoneButtons"]
unique_name_in_owner = true
custom_minimum_size = Vector2(170, 48)
layout_mode = 2
text = "Pfad kopieren"
tooltip_text = "Absoluten Dateipfad in die Zwischenablage kopieren"
[node name="ElementFeatureMenu" type="PopupMenu" parent="."]
unique_name_in_owner = true

View file

@ -0,0 +1,131 @@
extends SceneTree
## Headless test for `ExportPanel` on its own.
##
## No WhiteboardController, no routine scene: the panel is instantiated from
## `scenes/export/export_panel.tscn` and reports its choices through signals.
## This is the measure of whether the module is really separate.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_export_panel_tests.gd
const PanelScene := preload("res://scenes/export/export_panel.tscn")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var panel := PanelScene.instantiate() as ExportPanel
_check(panel != null, "the panel scene carries its script")
if panel == null:
_finish()
return
# Without a window size, popup_centered places dialogs at negative offsets
# in headless runs; give the root window a sane size.
root.size = Vector2i(1280, 800)
root.add_child(panel)
await process_frame
_check(
panel.dialog != null and panel.done_dialog != null,
"both dialogs are wired"
)
_check(
panel.format_option.item_count == 3,
"three export formats are offered"
)
var routine := Routine.new()
routine.routine_id = "panel-test"
routine.title = "Kür am See"
routine.rink = RinkDimensions.new()
var section := RoutineSection.new()
section.section_id = "s1"
section.title = "Abschnitt 1"
# Lambdas capture by value: mutate the dictionary instead of rebinding it.
var captured: Dictionary = {}
panel.export_requested.connect(
func(
path: String,
format: int,
section_id: String,
open_after: bool
) -> void:
captured["path"] = path
captured["format"] = format
captured["section_id"] = section_id
captured["open_after"] = open_after
)
panel.open_for(routine, section, Vector2i(480, 520))
_check(panel.dialog.visible, "the dialog opens")
_check(panel.name_edit.text == "Kür am See", "the routine title fills the name")
panel.dialog.confirmed.emit()
_check(
str(captured.get("path", "")).ends_with("kür_am_see.svg"),
"the default format is SVG with a clean file stem (%s)"
% captured.get("path", "")
)
_check(int(captured.get("format", -1)) == 0, "the format id is passed")
_check(
str(captured.get("section_id", "x")).is_empty(),
"the whole routine is the default scope"
)
panel.scope_option.select(1)
panel.format_option.select(2)
captured.clear()
panel.dialog.confirmed.emit()
_check(int(captured.get("format", -1)) == 2, "the PDF format is passed")
_check(
str(captured.get("path", "")).ends_with("_abschnitt_1.pdf"),
"the section suffix is added (%s)" % captured.get("path", "")
)
_check(
str(captured.get("section_id", "")) == "s1",
"the section id is passed"
)
var messages: Array = []
panel.message_requested.connect(
func(text: String) -> void:
messages.append(text)
)
panel.name_edit.text = " "
captured.clear()
panel.dialog.confirmed.emit()
_check(captured.is_empty(), "an empty name does not export")
_check(not messages.is_empty(), "an empty name asks for input")
# The done dialog only enables "open" for an existing file.
panel.show_done("/tmp/does-not-exist.pdf", Vector2i(660, 320))
_check(panel.open_button.disabled, "missing files cannot be opened")
_check(panel.done_dialog.visible, "the done dialog opens")
panel.queue_free()
await process_frame
_finish()
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
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)

View file

@ -0,0 +1 @@
uid://b6r15yds80ibm