Add mixer/accessibility settings, caption/reduce-motion hooks, audio volume clamping, a 24-NPC performance smoke and shortened coat/dress stride for hem clipping. Record the explicit Godot 4.3-CI/4.7-local matrix and the 0.9 production scope. Headless 250/250, Python 94/94, 24-NPC budget smoke passes.
90 lines
3.8 KiB
GDScript
90 lines
3.8 KiB
GDScript
extends RefCounted
|
|
## Headless tests for shift-result persistence (Save autoload, user:// JSON).
|
|
|
|
func _save_instance() -> Object:
|
|
var save_script: GDScript = load("res://src/autoload/save.gd")
|
|
return save_script.new()
|
|
|
|
func test_save_round_trip() -> bool:
|
|
var save := _save_instance()
|
|
var review := {
|
|
"scenario_id": "hollywood_building",
|
|
"reputation": {"rating": 82.5, "grade": "B"},
|
|
"spawned_count": 7,
|
|
"completed_at_ms": Time.get_ticks_msec(),
|
|
}
|
|
var err: int = save.save_shift_result(review)
|
|
var a := TestUtils.check_eq(err, OK, "save succeeds")
|
|
var results: Array = save.load_shift_results()
|
|
var b := TestUtils.check(results.size() > 0, "history non-empty after save")
|
|
var last: Dictionary = results[results.size() - 1]
|
|
var c := TestUtils.check_eq(last.get("scenario_id", ""), "hollywood_building", "round-trips scenario id")
|
|
var d := TestUtils.check_eq(float(last.get("reputation", {}).get("rating", 0.0)), 82.5, "round-trips rating")
|
|
save.free()
|
|
return a and b and c and d
|
|
|
|
func test_load_returns_array_when_empty_or_missing() -> bool:
|
|
# The tester home may already contain results; this only asserts shape safety.
|
|
var save := _save_instance()
|
|
var results: Array = save.load_shift_results()
|
|
var ok := TestUtils.check(results is Array, "load_shift_results always returns Array")
|
|
save.free()
|
|
return ok
|
|
|
|
func test_settings_round_trip() -> bool:
|
|
var save := _save_instance()
|
|
var err: int = save.save_settings({"look_sensitivity": 0.0035, "hud_font_scale": 1.25})
|
|
var a := TestUtils.check_eq(err, OK, "save_settings succeeds")
|
|
var loaded: Dictionary = save.load_settings()
|
|
var b := TestUtils.check(is_equal_approx(float(loaded.get("look_sensitivity", 0.0)), 0.0035), "round-trips sensitivity")
|
|
var c := TestUtils.check(is_equal_approx(float(loaded.get("hud_font_scale", 0.0)), 1.25), "round-trips font scale")
|
|
# Restore defaults so later runs are not affected.
|
|
save.save_settings(save.DEFAULT_SETTINGS)
|
|
save.free()
|
|
return a and b and c
|
|
|
|
func test_camera_settings_round_trip() -> bool:
|
|
var save := _save_instance()
|
|
var err: int = save.save_settings({
|
|
"look_sensitivity": 0.0028, "hud_font_scale": 1.0,
|
|
"invert_y": true, "head_bob": false,
|
|
})
|
|
var a := TestUtils.check_eq(err, OK, "camera settings save")
|
|
var loaded: Dictionary = save.load_settings()
|
|
var b := TestUtils.check_eq(bool(loaded.get("invert_y", false)), true,
|
|
"invert_y survives the round trip")
|
|
var c := TestUtils.check_eq(bool(loaded.get("head_bob", true)), false,
|
|
"head_bob survives the round trip")
|
|
save.save_settings(save.DEFAULT_SETTINGS)
|
|
save.free()
|
|
return a and b and c
|
|
|
|
func test_input_bindings_round_trip() -> bool:
|
|
var save := _save_instance()
|
|
var bindings := {"inspect": {"type": "key", "code": int(KEY_Z)}}
|
|
var err: int = save.save_settings({"input_bindings": bindings})
|
|
var a := TestUtils.check_eq(err, OK, "bindings save")
|
|
var loaded: Dictionary = save.load_settings()
|
|
var stored: Dictionary = loaded.get("input_bindings", {})
|
|
var inspect: Dictionary = stored.get("inspect", {})
|
|
var b := TestUtils.check_eq(int(inspect.get("code", 0)), int(KEY_Z),
|
|
"bindings survive the settings round trip")
|
|
var c := TestUtils.check_eq(str(inspect.get("type", "")), "key",
|
|
"binding type survives the settings round trip")
|
|
save.save_settings(save.DEFAULT_SETTINGS)
|
|
save.free()
|
|
return a and b and c
|
|
|
|
func test_settings_defaults_present() -> bool:
|
|
var save := _save_instance()
|
|
var defaults: Dictionary = save.load_settings()
|
|
var ok := TestUtils.check(
|
|
defaults.has("look_sensitivity") and defaults.has("hud_font_scale")
|
|
and defaults.has("invert_y") and defaults.has("head_bob")
|
|
and defaults.has("input_bindings")
|
|
and defaults.has("master_volume") and defaults.has("sfx_volume")
|
|
and defaults.has("ambience_volume") and defaults.has("captions_enabled"),
|
|
"settings have documented defaults")
|
|
save.free()
|
|
return ok
|