63 lines
2.8 KiB
GDScript
63 lines
2.8 KiB
GDScript
extends SceneTree
|
|
|
|
const CandidateLedger = preload("res://ui/m52/candidate_ledger.gd")
|
|
|
|
var failures: Array[String] = []
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
func run_test() -> void:
|
|
root.size = Vector2(360, 520)
|
|
var ledger := CandidateLedger.new().configure({
|
|
"name": "Yori Valehook",
|
|
"profession": "长枪使",
|
|
"trait": "最后见证",
|
|
"availability": "可招募",
|
|
"cost": "14 金币",
|
|
"detail": "适合前排,攻击距离稳定",
|
|
"action_disabled": false,
|
|
})
|
|
ledger.name = "CandidateLedgerFixture"
|
|
ledger.position = Vector2(18, 12)
|
|
ledger.size = Vector2(324, 496)
|
|
root.add_child(ledger)
|
|
await process_frame
|
|
for node_name in ["LedgerShell", "LedgerHeader", "PortraitModule", "IdentityModule", "ProfessionModule", "DetailCopy", "TraitModule", "CostModule", "ActionButton"]:
|
|
expect(ledger.find_child(node_name, true, false) != null, "%s exists" % node_name)
|
|
var portrait := ledger.find_child("PortraitModule", true, false) as Control
|
|
var identity := ledger.find_child("IdentityModule", true, false) as Control
|
|
var profession := ledger.find_child("ProfessionModule", true, false) as Control
|
|
var detail := ledger.find_child("DetailCopy", true, false) as Control
|
|
var trait_control := ledger.find_child("TraitModule", true, false) as Control
|
|
var cost := ledger.find_child("CostModule", true, false) as Control
|
|
var action := ledger.find_child("ActionButton", true, false) as Control
|
|
if cost != null:
|
|
cost.set_compact(true, true)
|
|
await process_frame
|
|
expect(portrait != null and portrait.clip_contents, "portrait clips")
|
|
if portrait != null and identity != null:
|
|
expect(not portrait.get_rect().intersects(identity.get_rect()), "portrait and identity do not overlap")
|
|
if identity != null and profession != null:
|
|
expect(not identity.get_rect().intersects(profession.get_rect()), "identity and profession do not overlap")
|
|
if profession != null and detail != null:
|
|
expect(not profession.get_rect().intersects(detail.get_rect()), "profession and detail do not overlap")
|
|
if detail != null and trait_control != null:
|
|
expect(not detail.get_rect().intersects(trait_control.get_rect()), "detail and trait do not overlap")
|
|
if trait_control != null and cost != null:
|
|
expect(not trait_control.get_rect().intersects(cost.get_rect()), "trait and cost do not overlap")
|
|
if cost != null and action != null:
|
|
expect(not cost.get_rect().intersects(action.get_rect()), "cost and action do not overlap")
|
|
expect(cost != null and cost.find_child("LedgerCostChrome", true, false) != null, "ledger cost uses dedicated chrome")
|
|
if failures.is_empty():
|
|
print("ABG_M52_CANDIDATE_LEDGER_COMPONENT_OK tree=true clipping=true slots=true action=true")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append(message)
|