On Sat, 24 Oct 2026 18:42:20 GMT, Marius Hanl <[email protected]> wrote:
>> Did you check the link even? `onlyReuseRuns` can be tested, which I did.
>> This is what this comment is about.
>
> Just gave it a shot, this is what I meant:
>
>
> @Test
> public void testTextLayoutWithTabsIsNotCached() {
> Font font = Font.font("Amble", 11);
> Object nativeFont = FontHelper.getNativeFont(font);
>
> AtomicInteger glyphLayoutCreationCounter = new AtomicInteger();
>
> StubTextLayout textLayout = new StubTextLayout(256) {
> @Override
> protected GlyphLayout glyphLayout() {
> glyphLayoutCreationCounter.addAndGet(1);
> return super.glyphLayout();
> }
> };
> setTextLayout(textLayout, "TEXT\tTAB", nativeFont,
> TextLayout.BOUNDS_CENTER);
> assertEquals(1, glyphLayoutCreationCounter.get());
>
> // We set the same text again, but still expect a cache miss as the
> text contains tabs.
> setTextLayout(textLayout, "TEXT\tTAB", nativeFont,
> TextLayout.BOUNDS_CENTER);
> assertEquals(2, glyphLayoutCreationCounter.get());
> }
>
>
> Note that this does not mean your system test is obsolete -- it is perfectly
> valid and needed. But as you probably also know, there are many bugs in font
> / text code, and every headless tests makes catching regressions easier.
> So I'm very strongly in favor of one. Feel free to just copy mine.
Thank you for providing this test. I could add it to the suite, but it relies
on private specifics of the particular implementation.
There were two reasons why I decided to create a system test which exercises
the real thing:
1. I wanted to test the actual layout, and not the crippled StubLayout (however
useful that is)
2. I wanted to test the actual outcome using the public APIs
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2352#discussion_r4378920376