Repository navigation
test(capture): Make the status icon glyph test deterministic - #154
Conversation
testTheGlyphIsDarkOnAWhiteRingAndWhiteOnTheUsualOnes counted pixels past a brightness cutoff, which depends on the fill under the glyph's antialiased edges. systemRed is a dynamic color and is lighter in Aqua, so on a Mac in Light mode the saved glyph on red counted 18 bright pixels instead of 33, under the 30 the test required. The test now sums the glyph's ink inside the ring (each pixel's coverage from the fill toward the expected glyph color) and compares it with the symbol's own ink at the same size, in both Aqua and Dark Aqua.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Overview
Makes
testTheGlyphIsDarkOnAWhiteRingAndWhiteOnTheUsualOnesdeterministic by measuring the glyph's ink inside the ring instead of counting pixels past a brightness cutoff, and by drawing it under both Aqua and Dark Aqua.Motivation
The test failed once in a review run on the Mac mini (
savedon red counted 18 bright pixels, needing more than 30) and passed in CI and in other local runs.The cause is the drawing appearance.
systemRedis a dynamic color, and its Aqua variant is lighter (by Rec. 709 luma, about 0.39 against 0.42). A pixel only passed theluminance > 0.9cutoff when the white glyph covered about 84% of it, so the count depended on how many of the glyph's antialiased edge pixels sat right around that coverage. Renderingsavedon red at 2x on this Mac gives:.grayand thecopiedglyph barely change, so only that one case was near the threshold. The Mac mini has automatic Light/Dark switching on (AppleInterfaceStyleSwitchesAutomatically = 1), which fits a run made while it was in Light mode. Scale and color space were already fixed by the test's own bitmap. This isn't an app bug: the glyph draws the same, and its contrast is covered bytestEveryRingColorGetsAGlyphWithAtLeastThreeToOneContrastandtestAlwaysOnConfirmationIsSolidAndReadableOverALightMenuBar.Changes
Glyph test
ConfirmationIcon.glyphColor, so the test can't agree with a wrong pick. Each case is drawn under both Aqua and Dark Aqua through adrawing(in:)helper. Theluminance < 0.1 == 0check for white glyphs stays.glyphBoundsintoglyphCoverage(from:toward:), which the new check shares with it, and addsinkArea(in:coverage:within:).Breaking Changes
None
Testing
ConfirmationIcon.drawfail the test: no glyph (0.0), glyph at half opacity (0.50), always-white glyph (0.0 on white), glyph moved 4 pt (0.67) and 20 pt (0.0) off centerswift test: 1269 tests, 0 failuresxcodebuild testwithPRODUCT_BUNDLE_IDENTIFIER=com.epilande.Annotate.isotest: 1269 tests, 1 skipped, 0 failuresStatusIconConfirmationTests10 times withswift testand 10 iterations withxcodebuild -test-iterations, all passing