45 lines
1.4 KiB
GDScript
45 lines
1.4 KiB
GDScript
# dungeon_result_test —— DUNGEON_RESULT 的九字段 UI 消费回归。
|
|
extends SceneTree
|
|
|
|
const DungeonResultUI = preload("res://ui/dungeon_result_ui.gd")
|
|
|
|
var _fail := 0
|
|
|
|
func _ck(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
_fail += 1
|
|
printerr("FAIL: " + message)
|
|
|
|
func _init() -> void:
|
|
await _run()
|
|
if _fail == 0:
|
|
print("PASS: dungeon_result_test (ShowDungeonResult nine fields)")
|
|
quit(0)
|
|
else:
|
|
printerr("%d check(s) failed" % _fail)
|
|
quit(1)
|
|
|
|
func _run() -> void:
|
|
var layer := CanvasLayer.new()
|
|
get_root().add_child(layer)
|
|
var result_ui := DungeonResultUI.new()
|
|
get_root().add_child(result_ui)
|
|
result_ui.setup(layer)
|
|
var result := {
|
|
"killstone_count": 2, "killmob_count": 40, "find_hidden": 1, "hidden_total": 3,
|
|
"use_potion": 5, "is_revived": 0, "killallmob": 1, "total_time": 600,
|
|
"bonus_exp": 1234,
|
|
}
|
|
result_ui.show_result(result)
|
|
await process_frame
|
|
_ck(result_ui.is_open(), "result window is visible")
|
|
_ck(result_ui.result() == result, "all nine server fields are retained")
|
|
var rows: Array = result_ui._display_rows()
|
|
_ck(rows.size() == 8, "display has the eight grouped rows")
|
|
_ck(str(rows[6][1]) == "10:00", "total_time is formatted as mm:ss")
|
|
_ck(str(rows[7][1]) == "1234", "bonus_exp is displayed")
|
|
result_ui.close()
|
|
_ck(not result_ui.is_open(), "close hides result window")
|
|
layer.queue_free()
|
|
result_ui.queue_free()
|