Files
gplan-2/game/tests/unit/presentation/settings_store_test.gd
T
DKChan 9f21236f80 工程(注释标记词换代·oracle→判据出处): 用户 2026-11-07 令——判据出处注记的标记词改用项目已有中文名,避免 Oracle 被读成数据库。注释格式句、机检正则、标识符、卡片与登记同步换代;零行为改动。
改动面 112 文件 572+/572-:game/tests/** 与 game/probe/** 共 106 件 545 行 `# oracle:`→`# 判据出处:`;tools/capability_audit.py 正则字面量换中文+ORACLE_*→CRITERION_*/check_oracle_markers→check_criterion_markers/oracle_marked(flagged)→criterion_* 共 11 行;test-conventions.md:119 格式句+:155 措辞;待办清单与需求卡片-QA覆盖余量收口批各 1 处字面量;coverage_enum.py:21 与 camp_scene_layout_test.gd:101 旁支措辞;ui_click_probe.gd 对拍局部变量 oracle→expected 7 处;auto_player.gd 三处 safe_set 真值措辞。不动:历史审计报告两份、test-oracle-anchor 分支名、git 史、生成日志;指针格式/扫描面/判红条件/验收义务全不变。

读数(区内实跑):改前 capability_audit --strict「417 注记函数·红项 0」→改后「417 判据出处注记函数·红项 0」exit=0;新标记 545 行/106 文件,现行义务面 oracle 残留 0(在册沿革除外);diff 自检 game/ 非注释新增行仅 6 行且全在 ui_click_probe.gd 的 expected 变量段;112 改动文件 CRLF=0;py_compile tools/capability_audit.py OK;--docs exit=0【验收通过】无新增红;--gates exit=0(静态扫描绿、闸壳 bash -n ×13 失败 0)。
2026-11-07 07:11:15 +08:00

68 lines
3.2 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tests/unit/presentation/settings_store_test.gd — 设置存储单元契约(回读/缺省/应用链)
# 断言面 = SettingsStore 公开方法:save_settings/load_settings 持久化回读、缺文件出厂默认、
# apply() 引擎档应用(UiKit.motion_scale 双态)。隔离卫生:一律经 _init path 注入指向临时 cfg,
# 禁碰真实 user://settings.cfg(ui_click_probe 设置面段同款纪律)。
# 运行:godot --headless --path game --script res://tests/unit/presentation/settings_store_test.gd
extends SceneTree
const Kit := preload("res://tests/unit/test_kit.gd")
const StoreScript := preload("res://presentation/settings_store.gd")
const ISO_PATH := "user://settings_store_unit_test.cfg" # 隔离注路径(临时件——测毕清理)
func _init() -> void:
# 判据出处: design/gdd/systems/表现与支撑/设置与本地化.md:4 (设置存储宿主——装载组)
_test_settings_roundtrip()
_test_settings_default()
_test_settings_apply_chain()
_cleanup()
quit(Kit.finish("settings_store_test"))
func _cleanup() -> void:
DirAccess.remove_absolute(ProjectSettings.globalize_path(ISO_PATH))
# ---- 持久化回读(写 true→存→新实例回读 true;节/键 motion/reduced)----
func _test_settings_roundtrip() -> void:
# 判据出处: design/gdd/systems/表现与支撑/设置与本地化.md:4 (设置写读往返组)
var w = StoreScript.new(ISO_PATH)
w.reduced_motion = true
Kit.check("前置:save_settings 落盘成功", w.save_settings())
var r = StoreScript.new(ISO_PATH)
r.load_settings()
Kit.check("持久化回读:新实例回读 reduced_motion=true(motion/reduced 节键)〔断言补齐批 V6〕", r.reduced_motion == true)
w.reduced_motion = false
Kit.check("回写往返:改 false 再存再读得 false〔断言补齐批 V6〕", w.save_settings() and (func():
var r2 = StoreScript.new(ISO_PATH)
r2.load_settings()
return r2.reduced_motion == false).call())
# ---- 缺省值(无文件缺省 false)----
func _test_settings_default() -> void:
# 判据出处: design/gdd/systems/表现与支撑/设置与本地化.md:4 (出厂默认组)
var absent_path := "user://settings_store_unit_absent_%d.cfg" % (Time.get_ticks_msec())
DirAccess.remove_absolute(ProjectSettings.globalize_path(absent_path)) # 确保无文件
var d = StoreScript.new(absent_path)
d.load_settings()
Kit.check("无文件缺省:reduced_motion=false(缺文件=出厂默认合法态)〔断言补齐批 V7〕", d.reduced_motion == false)
# ---- 引擎档应用链(reduced→apply()→UiKit.motion_scale==0.5,false→1.0;测毕还原静态初值)----
func _test_settings_apply_chain() -> void:
# 判据出处: design/gdd/systems/表现与支撑/设置与本地化.md:4 (应用链组)
var saved_scale: float = UiKit.motion_scale # 静态初值留底——测毕还原
var a = StoreScript.new(ISO_PATH)
a.reduced_motion = true
a.apply()
Kit.check("应用链:reduced=true → UiKit.motion_scale==0.5〔断言补齐批 V8〕", UiKit.motion_scale == 0.5)
a.reduced_motion = false
a.apply()
Kit.check("应用链:reduced=false → UiKit.motion_scale==1.0〔断言补齐批 V8〕", UiKit.motion_scale == 1.0)
UiKit.motion_scale = saved_scale # 还原(静态共享面——不渗入其他套件)