test: chromeless + modal-swallow coverage
Adds assertions verifying: - chromeless=true widget click at top-right reaches widget (no phantom close-button intercept). - top-tier input_block=all modal swallows outside-clicks before reaching normal-tier widgets behind it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
52
init.lua
52
init.lua
@@ -550,6 +550,58 @@ function M.run_tests(_ctx)
|
|||||||
T.assert(not panel.point_in_any_panel(sw_p * 0.75, sh_p * 0.5),
|
T.assert(not panel.point_in_any_panel(sw_p * 0.75, sh_p * 0.5),
|
||||||
"W.2 point_in_any_panel false when point outside any panel")
|
"W.2 point_in_any_panel false when point outside any panel")
|
||||||
panel._test_reset_all()
|
panel._test_reset_all()
|
||||||
|
|
||||||
|
-- ------------------------------------------------------------------
|
||||||
|
-- W.2 #12: chromeless=true suppresses phantom close-button hit-test
|
||||||
|
-- ------------------------------------------------------------------
|
||||||
|
-- Regression: chromeless widgets draw no X close-button but the
|
||||||
|
-- dispatch loop used to hit-test a phantom 26x26 zone at the top-
|
||||||
|
-- right. A click there would close the widget. Verify the click
|
||||||
|
-- now reaches the widget instead.
|
||||||
|
local chrome_clicked = false
|
||||||
|
panel.register("w_chrome", make_widget({
|
||||||
|
title = "ChromelessW",
|
||||||
|
handle_input = function(_ctx, _ev) chrome_clicked = true end,
|
||||||
|
}), { chromeless = true, layout = "center" })
|
||||||
|
panel.open("w_chrome")
|
||||||
|
local b_chrome = panel._test_get_window_bounds("w_chrome")
|
||||||
|
-- Click in the top-right area where the phantom close-button would sit.
|
||||||
|
panel._dispatch_event_for_test({
|
||||||
|
kind = "click", button = "left",
|
||||||
|
x = b_chrome.x + b_chrome.w - 10,
|
||||||
|
y = b_chrome.y + 10,
|
||||||
|
})
|
||||||
|
T.assert(chrome_clicked,
|
||||||
|
"chromeless: top-right click reaches widget (no phantom close-button)")
|
||||||
|
T.assert(panel.is_open("w_chrome"),
|
||||||
|
"chromeless: widget remains open after top-right click")
|
||||||
|
panel._test_reset_all()
|
||||||
|
|
||||||
|
-- ------------------------------------------------------------------
|
||||||
|
-- W.2 #13: top-tier input_block="all" swallows outside-clicks before
|
||||||
|
-- they can reach a normal-tier widget behind the modal.
|
||||||
|
-- ------------------------------------------------------------------
|
||||||
|
local normal_clicked_m = false
|
||||||
|
panel.register("w_norm_m", make_widget({
|
||||||
|
title = "N",
|
||||||
|
handle_input = function(_ctx, _ev) normal_clicked_m = true end,
|
||||||
|
}), { z_tier = "normal", layout = "left-half" })
|
||||||
|
panel.register("w_modal_m", make_widget({
|
||||||
|
title = "M",
|
||||||
|
handle_input = function(_ctx, _ev) end,
|
||||||
|
}), { z_tier = "top", input_block = "all", layout = "right-half" })
|
||||||
|
panel.open("w_norm_m")
|
||||||
|
panel.open("w_modal_m")
|
||||||
|
-- Click in left-half (inside normal's bounds, outside modal's bounds).
|
||||||
|
-- The modal must swallow it before normal can claim it.
|
||||||
|
local sw_mm, sh_mm = panel._test_get_screen_size()
|
||||||
|
panel._dispatch_event_for_test({
|
||||||
|
kind = "click", button = "left",
|
||||||
|
x = sw_mm * 0.25, y = sh_mm * 0.5,
|
||||||
|
})
|
||||||
|
T.assert(not normal_clicked_m,
|
||||||
|
"modal swallow: normal-tier widget does NOT receive click while top-tier all-modal is open")
|
||||||
|
panel._test_reset_all()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user