I added capturing a screenshot of the splash screen into the test, and I found 
that the splash screen is already closed when the screenshot is taken. I 
realised that I had changed the behaviour of the test with my screenshot code. 
The original test gets the color of the pixel on the screen before it calls 
`getScaleFactor` that displays a dialog, which results closing the splash 
screen.

https://github.com/openjdk/jdk/blob/e0b040a6c6713827033e9ba51c9ded920dd0203b/test/jdk/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java#L110-L111

I analysed the code of the splash screen, and it never opens the images with 
decorations for 100% scale: `[email protected]` or `[email protected]`.

To avoid any confusion, I modified the test code to ensure it never creates 
decorated files for 100%. If the scale factor of the main screen is 1.00, the 
second image remains with the default `@2x` decoration.

I also simplified the test. Now, `getScaleFactor` doesn't display a dialog, but 
reads the scale from `GraphicsEnvironment`. It did so anyway because the 
`Graphics` object passed to `paint` is an instance of `SunGraphics2D` in nearly 
all the cases.

The test always creates a screenshot of the splash screen and reads the color 
from the screenshot to determine whether the test fails or not.

The updated test is stable on all the platforms, I ran it many times, and the 
test never failed.

If the test ever fails again, we'll have the screenshot to analyse why.

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

Commit messages:
 - Revert to always saving screenshot of splash screen
 - Merge master
 - Use screen capture to get color from splash screen
 - Remove @modules java.desktop/sun.java2d and align colors
 - 8374304: MultiResolutionSplashTest.java fails in CI: "Image with wrong 
resolution is used for splash screen!"

Changes: https://git.openjdk.org/jdk/pull/29851/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29851&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8374304
  Stats: 143 lines in 1 file changed: 47 ins; 60 del; 36 mod
  Patch: https://git.openjdk.org/jdk/pull/29851.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29851/head:pull/29851

PR: https://git.openjdk.org/jdk/pull/29851

Reply via email to