Skip to content

Fixed TestCopyHTML1/2: expectations were generated on a 216 dpi machine - #1394

Open
TetzkatLipHoka wants to merge 1 commit into
JAM-Software:masterfrom
TetzkatLipHoka:fix/copyhtml-tests-dpi
Open

Fixed TestCopyHTML1/2: expectations were generated on a 216 dpi machine#1394
TetzkatLipHoka wants to merge 1 commit into
JAM-Software:masterfrom
TetzkatLipHoka:fix/copyhtml-tests-dpi

Conversation

@TetzkatLipHoka

Copy link
Copy Markdown
Contributor

The two TestCopyHTML tests have been permanently red on standard-dpi machines since their introduction. They compare the CF_HTML clipboard content byte-by-byte against hardcoded strings whose pixel values come from the machine the fixture was created on - the test form's dfm carries PixelsPerInch = 216 (DefaultNodeHeight 46, TextMargin 9, ...). On a 96 dpi machine the dpi-rescale chain yields a node height of 19 instead of 18, and the only difference in the whole comparison is height="18px" vs height="19px" in the data rows (the CF_HTML offsets happen to still match because both values have two digits).

The expected string is now built from the tree's actual metrics - font, Header.Height, column widths and captions, NodeHeight[], Text[] - i.e. the same sources the HTML exporter reads, and the fixed-width CF_HTML offset header is computed exactly like MakeFragment in VirtualTrees.Export.pas. The comparison stays byte-exact, so any change to the export format still fails the test - only the machine dependency is gone. Assert.AreEqual now also reports the actual difference instead of a plain boolean message.

With this the suite is fully green for the first time: 153/153 on Delphi 13.1 and on 10 Seattle (the oldest claimed supported version, both 96 dpi). Should be green on high-dpi machines as well since all values are derived from the running tree.

🤖 Generated with Claude Code

The two tests compared the CF_HTML clipboard content byte-by-byte against
hardcoded strings whose pixel heights came from the machine the fixture was
created on (the test form's dfm carries PixelsPerInch = 216). On any other
dpi the dpi-rescale chain yields different node heights - measured on a
96 dpi machine the only difference is height="18px" vs height="19px" in the
data rows - so the tests have been permanently red on standard-dpi machines
since their introduction.

The expected string is now built from the tree's actual metrics (font,
Header.Height, column widths and captions, NodeHeight[], Text[]) using the
same sources the HTML exporter reads, with the fixed-width CF_HTML offset
header computed exactly like MakeFragment in VirtualTrees.Export.pas. The
comparison stays byte-exact, so any change to the export format still fails
the test - only the machine dependency is gone. Assert.AreEqual now also
reports the actual difference instead of a plain boolean message.

With this the whole suite is green for the first time: 153/153 on Delphi
13.1 and on 10 Seattle (the oldest claimed supported version).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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