43 lines
2.7 KiB
GDScript
43 lines
2.7 KiB
GDScript
|
|
extends RefCounted
|
||
|
|
var failures=0
|
||
|
|
func check(ok,label):
|
||
|
|
if not ok:failures+=1;push_error("RUBY UI QA: "+label)
|
||
|
|
func node(w,key):return w.node_buttons.filter(func(n):return n.key==key)[0]
|
||
|
|
func shot(g,name):
|
||
|
|
await g.get_tree().process_frame;await RenderingServer.frame_post_draw
|
||
|
|
g.get_viewport().get_texture().get_image().save_png("res://captures/ruby-ui/"+name+".png")
|
||
|
|
func run(g):
|
||
|
|
await g.get_tree().create_timer(.3).timeout
|
||
|
|
g.start_game();g.set_process(false);g.reset_shift();g.game_started=true;g.paused=false
|
||
|
|
var w=g.workshop;g.coins=10000;g.essence=1000;g.development.points=9
|
||
|
|
w.toggle_tree();w.refresh();DirAccess.make_dir_recursive_absolute("res://captures/ruby-ui")
|
||
|
|
for n in w.node_buttons:
|
||
|
|
check(n.gems.filled==0,"empty sockets before purchase")
|
||
|
|
check(n.button.modulate==Color.WHITE,"all nodes initially bright")
|
||
|
|
await shot(g,"empty")
|
||
|
|
for key in ["speed","power","leadership","hire","haste","diligence"]:
|
||
|
|
var n=node(w,key);check(n.gems.slots==3,"three sockets: "+key)
|
||
|
|
for rank in range(1,4):
|
||
|
|
n.button.pressed.emit()
|
||
|
|
check(n.gems.filled==rank,"ruby added per purchase: %s/%d"%[key,rank])
|
||
|
|
check(n.button.modulate==Color.WHITE,"purchased node stays bright")
|
||
|
|
check(n.gems.mouse_filter==Control.MOUSE_FILTER_IGNORE,"rubies do not block button clicks")
|
||
|
|
check(n.button.disabled and n.gems.filled==3,"maximum remains non-purchasable with three rubies")
|
||
|
|
var gold=g.coins;var souls=g.essence;var points=g.development.points;n.button.pressed.emit()
|
||
|
|
check(g.coins==gold and g.essence==souls and g.development.points==points,"max cannot spend currency again")
|
||
|
|
for key in ["unlock1","unlock2","unlock3","unlock4","unlock5","auto"]:
|
||
|
|
var n=node(w,key);n.button.pressed.emit()
|
||
|
|
check(n.gems.slots==1 and n.gems.filled==1 and n.button.disabled,"one-time purchase gets one ruby")
|
||
|
|
for n in w.node_buttons:
|
||
|
|
check(n.button.modulate==Color.WHITE,"no dimming in any branch")
|
||
|
|
check(n.button.get_theme_stylebox("disabled")==n.button.get_theme_stylebox("normal"),"disabled and normal stone have same brightness")
|
||
|
|
check(n.gems.get_rect().end.y<=n.button.size.y+1,"rubies fit button bottom")
|
||
|
|
await shot(g,"purchased")
|
||
|
|
for scroll in w.tree.find_children("*","ScrollContainer",true,false):scroll.scroll_vertical=10000
|
||
|
|
await shot(g,"purchased-lower")
|
||
|
|
g.speed_level=1;g.development.action_level=2;g.development.leadership=3;w.helper_speed=1;w.helper_diligence=2;w.refresh()
|
||
|
|
for scroll in w.tree.find_children("*","ScrollContainer",true,false):scroll.scroll_vertical=0
|
||
|
|
await shot(g,"mixed-levels")
|
||
|
|
print("RUBY UI QA ","PASSED" if failures==0 else "FAILED",": zero/one/two/three ranks, singleton rubies, brightness, disabled maxima, purchase safety and layout")
|
||
|
|
g.get_tree().quit(1 if failures else 0)
|