RFR: 8342098: Write a test to compare the images [v2]

Naveen Narayanan duke at openjdk.org
Wed Oct 16 16:36:14 UTC 2024


On Tue, 15 Oct 2024 22:41:57 GMT, Phil Race <prr at openjdk.org> wrote:

>> Naveen Narayanan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8342098: Updated review comments
>
> 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.

Tried to get pixels directly from BufferedImage.
Got the RGB values of each pixel and compared them.
Hope this approach is ok.

> 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.

We may be comparing around 20K pixels.
Thought will keep a  0.5% variation as permissible.
Reduced a bit more now.
If this doesn’t make sense, surely we can take tolerance out.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1803453078
PR Review Comment: https://git.openjdk.org/jdk/pull/21524#discussion_r1803454866


More information about the client-libs-dev mailing list