diff --git a/docs/refactor-whiteboard-controller.md b/docs/refactor-whiteboard-controller.md index c550485..fe78601 100644 --- a/docs/refactor-whiteboard-controller.md +++ b/docs/refactor-whiteboard-controller.md @@ -199,6 +199,22 @@ prüfen. **Offen:** der Label-Dialog (Anlegen/Bearbeiten/Löschen) und die Musik (Laden, Konvertierung, Synchronisation). +### 12. `ExportPanel` als eigene Szene ✅ + +`scenes/export/export_panel.tscn` enthält die beiden Dialoge und das Skript; +die Whiteboard-Szene instanziiert sie nur noch. Dazu gibt es +`tests/run_export_panel_tests.gd`: Es lädt **nur** diese Szene, hängt sie an +den Root und prüft die Signale — kein WhiteboardController, keine Kür-Szene. + +Das ist die Messung, um die es ging: 15 Assertions laufen ohne die 8.154 +Zeilen Controller. Der Baustein ist damit nicht nur im Code getrennt. + +Zwei Stolpersteine beim Auslagern einer Szene: + +- Kindknoten eines Szenen-Roots nutzen `parent="."`, nicht den Root-Namen. +- Ein eigener Test braucht `root.size` vor `popup_centered`, sonst platziert + Godot die Fenster bei headless-Läufen auf negative Koordinaten. + ## Nächster Durchgang: weitere Node-Schnitte Die vier verbleibenden Blöcke (Sync-Orchestrierung, Hub, Playback-Rest, diff --git a/docs/roadmap.md b/docs/roadmap.md index 4be3efd..7f873f0 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -273,7 +273,8 @@ Schritte. `docs/refactor-whiteboard-controller.md`; Stand 2026-11-13: 8.154 Zeilen; `HelpContent`, `SeasonComparisonText`, `ValidationReportView`, `ExportService`, `RulesContext`, `SeasonPanelModel`, `SyncSummaryText`, `PlaybackPose`, `ExportPanel`, - `PlaybackPanel` und `TimelineLabelModel` ausgelagert. + `PlaybackPanel`, `TimelineLabelModel` und dem ersten eigenständigen + Panel-Test ausgelagert. - [ ] Gemeinsamer Test-Harness (oder gdUnit4), Timeout pro Testlauf, Coverage; CI auf dem Gitea-/Forgejo-Remote mit `tools/test.sh` und `tools/check_export.sh`. diff --git a/rinkplanner/scenes/export/export_panel.tscn b/rinkplanner/scenes/export/export_panel.tscn new file mode 100644 index 0000000..ac43ee1 --- /dev/null +++ b/rinkplanner/scenes/export/export_panel.tscn @@ -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" diff --git a/rinkplanner/scenes/whiteboard/whiteboard.tscn b/rinkplanner/scenes/whiteboard/whiteboard.tscn index f38d460..8407845 100644 --- a/rinkplanner/scenes/whiteboard/whiteboard.tscn +++ b/rinkplanner/scenes/whiteboard/whiteboard.tscn @@ -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 diff --git a/rinkplanner/tests/run_export_panel_tests.gd b/rinkplanner/tests/run_export_panel_tests.gd new file mode 100644 index 0000000..e332361 --- /dev/null +++ b/rinkplanner/tests/run_export_panel_tests.gd @@ -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) diff --git a/rinkplanner/tests/run_export_panel_tests.gd.uid b/rinkplanner/tests/run_export_panel_tests.gd.uid new file mode 100644 index 0000000..14dcb04 --- /dev/null +++ b/rinkplanner/tests/run_export_panel_tests.gd.uid @@ -0,0 +1 @@ +uid://b6r15yds80ibm diff --git a/tools/test.sh b/tools/test.sh index 26346bb..422cde7 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -66,6 +66,9 @@ fi "$GODOT" --headless --path "$PROJECT_DIR" \ --script res://tests/run_timing_tests.gd +"$GODOT" --headless --path "$PROJECT_DIR" \ + --script res://tests/run_export_panel_tests.gd + "$GODOT" --headless --path "$PROJECT_DIR" \ --script res://tests/run_export_tests.gd