feat: Cloud-Sync über Dropbox und Google Drive

- FTP-Sync durch Cloud-Backends ersetzt (Dropbox, Google Drive)
- OAuth-Flow mit nutzereigenen Tokens und App-Key-Konfiguration
- Zeit-Tooltips für Timeline-Labels und Abschnittsbanner beim Playback
- Tests, Build-Konfiguration und Doku aktualisiert
This commit is contained in:
torsten 2026-11-09 06:25:21 +01:00
parent 533a12ef1a
commit 74d9d6b61f
36 changed files with 3040 additions and 817 deletions

View file

@ -64,7 +64,7 @@ $GODOT --headless --path rinkplanner --script res://tests/run_touch_tests.gd
# Run canvas performance stress test
$GODOT --headless --path rinkplanner --script res://tests/run_perf_tests.gd
# Run FTP sync planning/parser/settings tests
# Run cloud sync planning/helper/settings tests
$GODOT --headless --path rinkplanner --script res://tests/run_sync_tests.gd
```

View file

@ -133,6 +133,18 @@ func _run() -> void:
controller.rink_canvas.get_playback_section_id() == section_one.section_id,
"canvas highlights the playing section"
)
_check(
controller.rink_canvas.get_section_banner_text() == section_one.title,
"section banner names the section at playback"
)
_check(
controller._section_buttons[section_one.section_id].text.begins_with("▶ "),
"section list marks the playing section"
)
_check(
controller._section_buttons[section_two.section_id].button_pressed,
"section list keeps the editing selection"
)
controller.seek_playback(3.0)
_check_vec(
@ -167,6 +179,23 @@ func _run() -> void:
controller.rink_canvas.get_playback_section_id() == section_two.section_id,
"canvas highlights the second section"
)
_check(
controller.rink_canvas.get_section_banner_text() == section_two.title,
"section banner follows the new section"
)
_check(
controller._section_buttons[section_two.section_id].text.begins_with("▶ "),
"section list marks the second section"
)
controller.rink_canvas._process(2.1)
_check(
controller.rink_canvas.get_section_banner_text().is_empty(),
"section banner fades out within two seconds"
)
_check(
controller.rink_canvas.get_section_banner_alpha() == 0.0,
"faded section banner has no alpha"
)
controller.play_button.pressed.emit()
_check(controller.is_playing(), "play button starts playback")
@ -318,6 +347,38 @@ func _run() -> void:
_check(has_spin_caption, "spin caption appears without a free-text label")
_check(has_zero_caption, "zero-duration element stays on the timeline")
# Hovering an element label exposes its track time as a tooltip.
controller.timeline_label_lane.size = Vector2(600.0, 44.0)
controller.timeline_label_lane._rebuild_items()
var hover_item: Dictionary = {}
for item: Dictionary in controller.timeline_label_lane.get_display_items():
if not bool(item["custom"]):
hover_item = item
break
_check(not hover_item.is_empty(), "element label can be hovered")
if not hover_item.is_empty():
var hover_x := float(hover_item["x"]) + 4.0
var hover_y := (
controller.timeline_label_lane.size.y
- 5.0
- float(int(hover_item["row"])) * 16.0
- 5.0
)
var hover_position := Vector2(hover_x, hover_y)
_check_approx(
controller.timeline_label_lane.get_label_time_at(hover_position),
float(hover_item["time_seconds"]),
"hovering an element label yields its track time"
)
var tooltip := controller.timeline_label_lane.get_tooltip_at(hover_position)
_check(
not tooltip.contains("Zeit im Track")
and tooltip.contains(
TimelineLabelLane.format_time(float(hover_item["time_seconds"]))
),
"element label tooltip contains only label and track time"
)
_check(
controller.add_timeline_label(5.0, "Musikstart"),
"custom timeline label is added"

View file

@ -1,7 +1,8 @@
extends SceneTree
## Headless tests for the manual FTP sync: planning rules, conflict naming,
## state persistence, protocol parsing and the settings UI wiring.
## Headless tests for the cloud sync: planning rules, conflict naming, state
## persistence, OAuth/PKCE helpers, provider path conventions and the settings
## UI wiring.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_sync_tests.gd
@ -19,7 +20,8 @@ func _init() -> void:
func _run() -> void:
_test_plan()
_test_naming()
_test_parsers()
_test_cloud_helpers()
_test_app_config()
_test_state_roundtrip()
await _test_controller_wiring()
_finish()
@ -55,17 +57,17 @@ func _test_plan() -> void:
actions[entry["name"]] = entry["action"]
_check(actions.get("neu.json") == SyncPlan.Action.UPLOAD, "nur lokal wird hochgeladen")
_check(actions.get("server-neu.json") == SyncPlan.Action.DOWNLOAD, "nur Server wird geladen")
_check(actions.get("server-neu.json") == SyncPlan.Action.DOWNLOAD, "nur Cloud wird geladen")
_check(
actions.get("beide.json") == SyncPlan.Action.CONFLICT,
"beidseitige Änderung ist ein Konflikt"
)
_check(actions.get("lokal.json") == SyncPlan.Action.UPLOAD, "lokale Änderung wird hochgeladen")
_check(actions.get("server.json") == SyncPlan.Action.DOWNLOAD, "Server-Änderung wird geladen")
_check(actions.get("server.json") == SyncPlan.Action.DOWNLOAD, "Cloud-Änderung wird geladen")
_check(actions.get("gleich.json") == SyncPlan.Action.SKIP, "unverändert wird übersprungen")
_check(
actions.get("entfernt.json") == SyncPlan.Action.SKIP,
"Server-Datei verschwunden: nicht wiederherstellen"
"Cloud-Datei verschwunden: nicht wiederherstellen"
)
var first_sync := SyncPlan.build(
@ -75,7 +77,7 @@ func _test_plan() -> void:
)
_check(
first_sync.size() == 1 and first_sync[0]["action"] == SyncPlan.Action.TAKE_SERVER,
"erster Abgleich ohne Stand übernimmt die Serverfassung"
"erster Abgleich ohne Stand übernimmt die Cloud-Fassung"
)
var local_deleted := SyncPlan.build(
@ -140,26 +142,129 @@ func _test_naming() -> void:
)
func _test_parsers() -> void:
var pasv := FtpClient.parse_pasv("227 Entering Passive Mode (10,1,2,3,200,10)")
_check(
pasv.get("host") == "10.1.2.3" and pasv.get("port") == 200 * 256 + 10,
"PASV-Antwort wird geparst"
func _test_cloud_helpers() -> void:
var url := CloudHttp.parse_url(
"https://api.dropboxapi.com/2/files/list_folder?limit=10"
)
_check(
FtpClient.parse_epsv("229 Entering Extended Passive Mode (|||6446|)") == 6446,
"EPSV-Antwort wird geparst"
url.get("scheme") == "https"
and url.get("host") == "api.dropboxapi.com"
and int(url.get("port", 0)) == 443
and url.get("path") == "/2/files/list_folder?limit=10",
"HTTPS-URL wird zerlegt"
)
var loopback := CloudHttp.parse_url("http://127.0.0.1:53682/callback")
_check(
loopback.get("host") == "127.0.0.1"
and int(loopback.get("port", 0)) == 53682,
"Loopback-URL mit Port wird zerlegt"
)
_check(CloudHttp.parse_url("ftp://example.org").is_empty(), "FTP-URL wird abgelehnt")
_check(
CloudHttp.resolve_url("https://api.example.org/a/b", "/c/d")
== "https://api.example.org:443/c/d",
"absolute Weiterleitung wird aufgelöst"
)
_check(
FtpClient.parse_epsv("229 Entering Extended Passive Mode (|||)") == -1,
"ungültige EPSV-Antwort liefert -1"
CloudHttp.resolve_url("https://api.example.org/a/b", "c")
== "https://api.example.org:443/a/c",
"relative Weiterleitung wird aufgelöst"
)
var expected := int(Time.get_unix_time_from_datetime_string("2026-10-30T09:48:28"))
_check(
FtpClient.parse_mdtm("20261030094828") == expected,
"MDTM wird als Unix-Zeit gelesen"
CloudHttp.json_stringify_ascii({"name": "Kür"}).contains("\\u00fc"),
"Header-JSON escaped Umlaute"
)
_check(FtpClient.parse_mdtm("kaputt") == -1, "ungültiges MDTM liefert -1")
# RFC 7636, Appendix B.
var verifier := "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
_check(
CloudOAuthJob.pkce_challenge(verifier)
== "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
"PKCE S256 entspricht dem Referenzwert"
)
var generated := CloudOAuthJob.new_verifier()
_check(
generated.length() >= 43 and not generated.contains("="),
"PKCE-Verifier ist lang genug und ohne Padding"
)
var authorize := CloudOAuthJob.dropbox_authorize_url("app-key", verifier)
_check(
authorize.contains("client_id=app-key")
and authorize.contains("token_access_type=offline")
and authorize.contains("code_challenge_method=S256")
and not authorize.contains("redirect_uri"),
"Dropbox-Autorisierungs-URL nutzt Offline-Zugriff und PKCE"
)
_check(
DropboxStore.remote_path("", "kuer.json") == "/kuer.json",
"Dropbox-Pfad im App-Ordner"
)
_check(
DropboxStore.remote_path("/Rinkplanner", "kuer.json")
== "/Rinkplanner/kuer.json",
"Dropbox-Pfad im Unterordner"
)
var content_headers := DropboxStore.content_headers("token", {"path": "/kuer.json"})
var content_type_count := 0
for value: String in content_headers:
if value.to_lower().begins_with("content-type:"):
content_type_count += 1
_check(
content_type_count == 1,
"Dropbox-Content-Request hat genau einen Content-Type"
)
var dropbox_time := DropboxStore.parse_timestamp("2026-11-09T12:34:56Z")
_check(dropbox_time > 0, "Dropbox-Zeitstempel wird gelesen")
_check(DropboxStore.parse_timestamp("kaputt") == -1, "ungültiger Dropbox-Zeitstempel liefert -1")
var google_time := GoogleDriveStore.parse_timestamp("2026-11-09T12:34:56.123Z")
_check(google_time == dropbox_time, "Google-Zeitstempel wird ohne Millisekunden gelesen")
_check(
GoogleDriveStore.escape_query("O'Brien") == "O\\'Brien",
"Google-Drive-Suchtext wird escaped"
)
func _test_app_config() -> void:
var path := "user://test_sync_apps.cfg"
var config := ConfigFile.new()
config.set_value("apps", "google_client_id", "gid")
config.set_value("apps", "google_client_secret", "gsecret")
config.set_value("apps", "dropbox_app_key", "dkey")
config.save(path)
var app := SyncAppConfig.read_file(path)
_check(app["google_client_id"] == "gid", "App-Konfiguration liest Google-Client-ID")
_check(app["dropbox_app_key"] == "dkey", "App-Konfiguration liest Dropbox-App-Key")
_check(SyncAppConfig.is_configured("google_drive", app), "Google gilt als eingerichtet")
_check(SyncAppConfig.is_configured("dropbox", app), "Dropbox gilt als eingerichtet")
app["google_client_secret"] = ""
_check(not SyncAppConfig.is_configured("google_drive", app), "fehlendes Secret blockiert Google")
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
# ConfigFile erwartet ';' als Kommentar und Strings in Anführungszeichen.
var literal_path := "user://test_sync_apps_literal.cfg"
var literal := FileAccess.open(literal_path, FileAccess.WRITE)
literal.store_string(
"; Kommentar\n\n[apps]\n"
+ "google_client_id=\"\"\n"
+ "dropbox_app_key=\"key123\"\n"
)
literal.close()
var literal_app := SyncAppConfig.read_file(literal_path)
_check(
literal_app["dropbox_app_key"] == "key123",
"App-Konfiguration liest quoted Strings"
)
_check(
literal_app["google_client_id"] == "",
"leere quoted Strings bleiben leer"
)
_check(
not SyncAppConfig.is_configured("google_drive", literal_app),
"leere Google-Client-ID bleibt unkonfiguriert"
)
DirAccess.remove_absolute(ProjectSettings.globalize_path(literal_path))
func _test_state_roundtrip() -> void:
@ -173,7 +278,7 @@ func _test_state_roundtrip() -> void:
_check(loaded.size() == 2, "Sync-Stand wird gespeichert und geladen")
_check(
int(loaded.get("kuer.json", {}).get("remote_modify", 0)) == 222,
"Sync-Stand behält die Server-Zeit"
"Sync-Stand behält die Cloud-Zeit"
)
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
@ -211,22 +316,33 @@ func _test_controller_wiring() -> void:
if controller == null:
return
var app_config := SyncAppConfig.load_config()
var provider := "dropbox"
if (
not SyncAppConfig.is_configured("dropbox", app_config)
and SyncAppConfig.is_configured("google_drive", app_config)
):
provider = "google_drive"
var tokens := {
provider: {
"refresh_token": "refresh",
"access_token": "access",
"expires_at": 9999999999,
"account": "konto@example.org",
},
}
controller.save_sync_settings({
"host": "ftp.example.org",
"port": 2121,
"user": "konto",
"password": "geheim",
"directory": "rinkplanner",
"ftps": false,
"verify_certificate": false,
"provider": provider,
"directory": "Kueren",
"tokens": tokens,
})
var loaded := controller.load_sync_settings()
_check(loaded["host"] == "ftp.example.org", "Sync-Einstellungen speichern den Host")
_check(int(loaded["port"]) == 2121, "Sync-Einstellungen speichern den Port")
_check(loaded["ftps"] == false, "Sync-Einstellungen speichern FTPS")
_check(loaded["provider"] == provider, "Sync-Einstellungen speichern den Anbieter")
_check(loaded["directory"] == "Kueren", "Sync-Einstellungen speichern den Cloud-Ordner")
_check(
loaded["verify_certificate"] == false,
"Sync-Einstellungen speichern die Zertifikatsprüfung"
RoutineSync.provider_tokens(loaded, provider).get("refresh_token") == "refresh",
"Sync-Einstellungen speichern den Refresh-Token"
)
controller._open_sync_settings_dialog()
@ -235,23 +351,39 @@ func _test_controller_wiring() -> void:
"Einstellungsdialog öffnet sich"
)
_check(
controller.sync_host_edit.text == "ftp.example.org",
"Dialog ist mit den gespeicherten Werten gefüllt"
controller._selected_sync_provider() == provider,
"Dialog wählt den gespeicherten Anbieter"
)
_check(
controller.sync_password_edit.secret,
"Passwortfeld ist verdeckt"
controller.sync_directory_edit.text == "Kueren",
"Dialog ist mit dem gespeicherten Ordner gefüllt"
)
_check(
controller.sync_account_value.text == "konto@example.org",
"Dialog zeigt das verbundene Konto"
)
_check(
controller.sync_connect_button.text == "Trennen",
"Verbundenes Konto bietet Trennen an"
)
controller.sync_settings_dialog.hide()
# Ohne Host öffnet "Jetzt synchronisieren" die Einstellungen statt zu starten.
controller.save_sync_settings({"host": "", "port": 21, "user": "", "password": ""})
# Ohne Refresh-Token öffnet "Jetzt synchronisieren" die Einstellungen.
controller.save_sync_settings({
"provider": "dropbox",
"directory": "Rinkplanner",
"tokens": {},
})
controller.start_sync()
_check(
controller.sync_settings_dialog.visible,
"Sync ohne Zugangsdaten öffnet die Einstellungen"
"Sync ohne Cloud-Konto öffnet die Einstellungen"
)
_check(not controller._sync_running, "ohne Cloud-Konto startet kein Sync")
_check(
controller.sync_account_value.text == "Nicht verbunden",
"Dialog zeigt den fehlenden Account"
)
_check(not controller._sync_running, "ohne Zugangsdaten startet kein Sync")
controller.sync_settings_dialog.hide()
scene.queue_free()