RFR: 8342098: Write a test to compare the images

Phil Race prr at openjdk.org
Tue Oct 15 22:45:20 UTC 2024


On Tue, 15 Oct 2024 12:48:30 GMT, Naveen Narayanan <duke at openjdk.org> wrote:

> This testcase checks for the following:
> 
> 1. An image is drawn on the screen and a portion of it is captured using a Robot. It is tested by comparing whether the captured image is same as the source image. 
> 
> Testing:
> Tested using Mach5(20 times per platform) in MacOS, Linux and Windows. Seen all tests passing.

test/jdk/java/awt/Robot/ScreenCaptureRobotTest.java line 65:

> 63: 
> 64:     private static void initializeGUI() {
> 65:         frame = new Frame("Test frame");

Better name than "Test Frame" please - name it after the test.

test/jdk/java/awt/Robot/ScreenCaptureRobotTest.java line 92:

> 90:         Robot robot;
> 91:         robot = new Robot();
> 92:         Thread.sleep(delay);

given a Robot we usually use robot.delay(delay)
And we usually precede it by waitForIdle()

test/jdk/java/awt/Robot/ScreenCaptureRobotTest.java line 127:

> 125:         PixelGrabber pgCapturedImg = new PixelGrabber(capturedImg, 0, 0,
> 126:                 imgWidth, imgHeight, capturedPixels, 0, imgWidth);
> 127:         pgCapturedImg.grabPixels();

PixelGrabber ? You have a BufferedImage. Just get the pixels directly.

test/jdk/java/awt/Robot/ScreenCaptureRobotTest.java line 140:

> 138: 
> 139:         difference = toleranceLevel;
> 140:         if (toleranceLevel > 100) {

Why is a tolerance level needed in this test ?
That would seem to suggest it can't test the only thing it exists for.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1802091596
PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1802093700
PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1802096194
PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1802096564


More information about the client-libs-dev mailing list