<Swing Dev> RFR: 8160720: [TEST_BUG] javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java

Sergey Bylokhov serb at openjdk.java.net
Mon Feb 22 18:37:45 UTC 2021


On Thu, 11 Feb 2021 21:33:44 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> I think the test does something wrong. Now I see how `uiScale` affects rendering. The test does not paint JLabel directly to the image but rather in its overridden `paintComponent`. So `uiScale` controls the size of the component or rather where the break occurs.
>> 
>> For me on Windows with 200% scaling, in the first image ‘…’ is painted over the transparent background whereas in the second image ‘…’ is over the components opaque background.
>> 
>> The test passes with `uiScale=1` but I see no ‘…’ at all. Both images are clipped at “.1”.
>> 
>> As far as I understand, the purpose of the test is to make sure combining diacritics does not affect string clipping, and it occurs at the same position whether a composite character is used of a decomposed one. Yet no clipping occurs at all with `uiScale=1`. This looks wrong even though the test passes successfully. And when the test fails with `uiScale=2`, the images suggest there's a product bug because the string is clipped differently.
>
>> For me on Windows with 200% scaling, in the first image ‘…’ is painted over the transparent background whereas in the second image ‘…’ is over the components opaque background.
>> 
>> The test passes with `uiScale=1` but I see no ‘…’ at all. Both images are clipped at “.1”.
> 
> As you can see on the screenshots below, the strings are clipped differently. In the case where `uiScale=1`, the string is not clipped, it's displayed completely in the frame.
> ![TestBadBreak java-200](https://user-images.githubusercontent.com/70774172/107700672-bebbfe00-6caf-11eb-9f26-123405c9d6df.png)
> ![TestBadBreak java-100](https://user-images.githubusercontent.com/70774172/107700678-c1b6ee80-6caf-11eb-8840-697249eaf795.png)
> 
> Shall the test be modified to do some text measurement to ensure the JLabel cannot fit the text completely? And then paint it to the image of the calculated size?
> 
> As for the clipping itself, I think the first frame, the bottom one, looks correctly: the text is clipped right to the edge of the client area whereas the second frame, the upper one, leaves some whitespace.

The rendering of the test may be affected by the uiScale, but when this test is executed, it uses only one-same scale for both use cases(different strings), and both of them should produce the same result.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2502


More information about the swing-dev mailing list