diff --git a/tests/test_crafter_feedback.gd b/tests/test_crafter_feedback.gd index 4d44d3c..dad13d2 100644 --- a/tests/test_crafter_feedback.gd +++ b/tests/test_crafter_feedback.gd @@ -115,6 +115,48 @@ func _process(delta: float) -> bool: quit(1) return true print("half a second later, still first: %s" % still) + + # --- 6. a REAL tap, through the input path ------------------ + # Everything above calls the handlers directly, which is how a + # whole class of bug kept getting missed: the crafter logic was + # fine and the BUTTON was inert, blocked by a modal guard. This + # taps the control the way a touch does. + game_state.withdraw_to_fleet(20) + var stock_before: int = game_state.building_stock(crafter_id) + var store_button: Control = scene.get_node("UI/CraftMenu/StoreOreButton") + for pressed in [true, false]: + var ev: InputEventScreenTouch = InputEventScreenTouch.new() + ev.pressed = pressed + ev.position = store_button.size / 2.0 + store_button._gui_input(ev) + if game_state.building_stock(crafter_id) <= stock_before: + print("stock %d -> %d after tapping Store ore" % [ + stock_before, game_state.building_stock(crafter_id) + ]) + print("TEST_CRAFTER_FEEDBACK: FAIL (tapping the store button did nothing)") + quit(1) + return true + print("real tap on Store ore moved %d ore into the crafter" % [ + game_state.building_stock(crafter_id) - stock_before + ]) + + # And the same tap must still work after the build menu has been + # opened and closed, which used to block every button forever. + controller._on_build_pressed() + controller._show_building_info(GameState.BUILDING_SHIP_CRAFTER) + scene.get_node("UI/BuildMenu").visible = false + game_state.withdraw_to_fleet(10) + var stock_mid: int = game_state.building_stock(crafter_id) + for pressed2 in [true, false]: + var ev2: InputEventScreenTouch = InputEventScreenTouch.new() + ev2.pressed = pressed2 + ev2.position = store_button.size / 2.0 + store_button._gui_input(ev2) + if game_state.building_stock(crafter_id) <= stock_mid: + print("TEST_CRAFTER_FEEDBACK: FAIL (store button dead after the build menu was opened and closed)") + quit(1) + return true + print("still works after opening and closing the build menu") print("TEST_CRAFTER_FEEDBACK: PASS") quit(0) return true