Files
Diabolo/Demon_v0.19/hud_tests.gd
T

73 lines
3.9 KiB
GDScript

extends RefCounted
var checks=0
func check(value):
checks+=1
if not value:push_error("HUD QA failed #%d" % checks);Engine.get_main_loop().quit(1)
func buttons(node):
var found=[]
for child in node.get_children():
if child is Button and child.is_visible_in_tree():found.append(child)
found.append_array(buttons(child))
return found
func point(g,p):
var m=InputEventMouseMotion.new();m.position=p;m.global_position=p;Input.parse_input_event(m)
await g.get_tree().process_frame
func run(g):
await g.get_tree().create_timer(.3).timeout
await preload("res://workshop_tests.gd").new().click(g,g.menu.main_start)
var w=g.workshop
check(not g.ui_compat.visible and g.sound_button==null)
check(not g.stats.is_visible_in_tree() and not w.panel.is_visible_in_tree())
check(buttons(g.hud).size()==2)
check(w.build_button.text.is_empty() and w.grimoire_button.text.is_empty())
check(w.build_button.position.x>1400 and w.build_button.position.y>780)
check(w.grimoire_button.position.x>w.build_button.position.x)
g.coins=12345;g.done=99;g.essence=42;g.refresh_ui()
check(g.gold_value.text=="12345" and g.souls_value.text=="42")
check(g.gold_value.is_visible_in_tree() and g.souls_value.is_visible_in_tree())
check(g.development.xp_bar.is_visible_in_tree() and g.development.xp_bar.position.y>870)
check(g.development.xp_bar.mouse_filter==Control.MOUSE_FILTER_IGNORE)
for p in [Vector2(100,100),Vector2(670,845),Vector2(920,845),Vector2(800,860),Vector2(1350,50)]:
await point(g,p)
check(g.get_viewport().gui_get_hovered_control()==null)
await preload("res://workshop_tests.gd").new().click(g,w.grimoire_button)
check(w.tree.visible and g.paused)
await preload("res://workshop_tests.gd").new().click(g,w.grimoire_button)
check(not w.tree.visible and not g.paused)
await preload("res://workshop_tests.gd").new().click(g,w.build_button)
check(w.build_mode)
await preload("res://workshop_tests.gd").new().click(g,w.grimoire_button)
check(w.tree.visible and not w.build_mode)
await preload("res://workshop_tests.gd").new().click(g,w.build_button)
check(w.build_mode and not w.tree.visible)
w.toggle_build()
var s=g.souls[0];s.required=[0,4,5];s.served=[0];s.entering=false;s.entry_time=1;s.node.position=Vector3(-1,0,1)
w.sentences.update_label(s);w.sentences.update_icons()
check(s.label.text.is_empty() and not s.label.visible and s.task_icon_nodes.size()==3)
for i in range(3):
check(s.task_icon_nodes[i].kind==w.Icon.APPARATUS[s.required[i]])
check(s.task_icon_nodes[i].mouse_filter==Control.MOUSE_FILTER_IGNORE)
check(s.task_icon_nodes[0].completed and not s.task_icon_nodes[1].completed)
await point(g,s.task_badge.get_global_rect().get_center())
check(g.get_viewport().gui_get_hovered_control()==null)
if is_instance_valid(g.development.bubble):g.development.bubble.queue_free();g.development.bubble=null
if is_instance_valid(g.life.hero_bubble):g.life.hero_bubble.queue_free();g.life.hero_bubble=null
w.dialogue_clock=0;var serial=g.dialogue.serial
w.update_soul_dialogue(29.9);check(g.dialogue.serial==serial)
w.update_soul_dialogue(.11);check(g.dialogue.serial==serial)
w.announce_soul(s,"Немедленная реплика");check(g.dialogue.serial==serial)
g.paused=true;var before=w.dialogue_clock;w.update(10);check(is_equal_approx(before,w.dialogue_clock))
g.paused=false;g.talk_clock=99.9;w.update(.05);check(not is_instance_valid(g.life.hero_bubble))
w.update(.06);check(is_instance_valid(g.life.hero_bubble))
var badge=s.task_badge;g.souls.erase(s);s.node.queue_free()
await g.get_tree().process_frame
await g.get_tree().process_frame
check(not is_instance_valid(badge))
print("PASS: two icon-only lower-right controls; coin/soul counters; removed HUD regions and task badges do not intercept the mouse")
print("PASS: identical task/catalogue pictograms, green completion marks, cleanup; soul dialogue disabled, heroine 100s, manual triggers throttled")
print("ALL HUD TESTS PASSED — DEMON 0.19")
g.get_tree().quit()