Skip to content

test: pin that drawButton does not clip an oversized label - #57

Merged
dmccoystephenson merged 2 commits into
mainfrom
test/pin-draw-button-label-not-clipped
Oct 22, 2026
Merged

dmccoystephenson merged 2 commits into
mainfrom
test/pin-draw-button-label-not-clipped

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) for drawButton, with the matching doc correction.

  • The drawButton docstring described text as "The label, centered within the box", which implies the label is contained by the box. It is not: the label is drawn with drawText onto the whole surface, so a label too large for its box overflows past the box edges. An empirical probe (4x4 box, size-20 "WWWW" label) painted 172 pixels outside the box.
  • A characterization test, test_draw_button_does_not_clip_a_label_larger_than_the_box, is added. It pins that the overflow is painted, and that a press on an overflowing label pixel outside the box does not fire the callback (the hit test covers only the box).
  • The docstring and the README drawButton bullet are updated to state both facts.

No production behavior is changed. The change is purely additive and touches no public signature, so no consumer-impact check applies.

No tracking issue — gap found during triage.

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • python3 -m pytest (headless via conftest.py): 69 passed (68 previously plus 1 new)
  • The new test was confirmed to fail when label clipping (set_clip to the box around the drawText call) was temporarily injected into drawButton, and to pass once it was removed.

Deferred issues

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 2 commits October 22, 2026 08:02
The drawButton docstring described the label as "centered within the
box", but the label is drawn onto the whole surface, so one too large
for its box overflows past the box edges. Pin that behavior, and that
the overflow is not clickable, and document it in the docstring and
README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (anchor: py_compile + import + pytest run locally on the PR head, 69 passed; CI Test workflow pending at the time of posting):

  • Scope: PASS — three files, each required: the new test, the corrected drawButton docstring, and the matching README bullet. No unrelated whitespace or formatting churn (an incidental trailing-whitespace change was reverted before commit).
  • Tests-new: PASS (n/a) — no new public method was added.
  • Tests-fix: PASS (adapted) — no production fix exists, since the behavior is characterized rather than changed. The test was shown to fail when label clipping (set_clip to the box) was temporarily injected into drawButton, and to pass once it was removed.
  • Sibling structure: PASS — the test reuses the existing _make_graphik, _button_label_ink and _click_at helpers and follows the comment-led style of the neighboring drawButton tests.
  • Sibling renames: PASS (n/a) — nothing renamed.
  • Docs: PASS — the docstring and README now agree with each other and with the pinned behavior. One FAIL was found on the first pass and fixed in a follow-up commit: README.md:39 — the new sentence had been inserted between "the clickable region is exactly the drawn box" and "so this only holds when…", making "this" ambiguous. It was moved to the end of the bullet.
  • Issue resolution: PASS (n/a) — no Closes reference; gap found during triage.
  • Manual validation: PASS locally; CI to be confirmed before merge.
  • camelCase / Backward-compat: PASS — no public member added, renamed or re-signed.
  • Headless: PASS — the test runs under the dummy SDL driver set by conftest.py.
  • Version sync / No new deps: PASS (n/a) — no version or import changes.

src/test/python/preponderous/graphik/test_graphik.py:897 — outside[0] is the first overflowing label pixel in x-major order, which lies left of the box. The assertion holds for any outside pixel, so the specific choice is not load-bearing.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 14bbf9c into main Oct 22, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-button-label-not-clipped branch October 22, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant