RFR: 8338153: java/awt/Checkbox/CheckboxCheckerScalingTest.java test failed on linux machine [v2]

Harshitha Onkar honkar at openjdk.org
Wed Sep 4 00:07:19 UTC 2024


On Tue, 3 Sep 2024 09:20:36 GMT, Tejesh R <tr at openjdk.org> wrote:

>> Test failed intermittently on particular host. Though analysis pointed out to a test frame at left top on that host, I've updated the test for further stabilizing it. Two things done here:
>> 1. Move the frame to center of the screen rather than left top.
>> 2. Added tolerance checks for color comparison - this is based on analysis reports where the image didn't had exact black color which is supposed to be. So like other test cases, providing some tolerance for comparison.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Checker pattern comparison

With the updated checker pattern

- The test condition is changed to `checkmarkFound = true`  which may not be ideal condition to start with.
- Are specific pixels being compared? I think it is easier to loop through the entire image and keep track of number of pixels matching the condition compareColor(pixelColor).

I was suggesting something like the following.  A counter var - `pixelCounter` to keep track of no. of pixels and when 5-6 pixels matches the criteria exit out of the loop. 


--- a/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java
+++ b/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java
@@ -48,6 +48,8 @@ public class CheckboxCheckerScalingTest {
     private static Checkbox checkbox;
     private static BufferedImage imageAfterChecked;
     private static volatile boolean checkmarkFound = false;
+    private static final int TOLERANCE = 5;
+    private static int pixelCounter = 0;

     public static void main(String[] args) throws Exception {
         System.setProperty("sun.java2d.uiScale", "2");
@@ -58,6 +60,7 @@ public static void main(String[] args) throws Exception {
                 checkbox = new Checkbox("one");
                 checkbox.setState(true);
                 frame.add(checkbox);
                 frame.setLocationRelativeTo(null);
                 frame.pack();
                 frame.setVisible(true);
             });
@@ -72,9 +75,14 @@ public static void main(String[] args) throws Exception {
                 check: {
                     for (int i = 0; i < imageAfterChecked.getHeight(); i++) {
                         for (int j = 0; j < imageAfterChecked.getWidth(); j++) {
-                            if (Color.black.getRGB() == imageAfterChecked.getRGB(i, j)) {
-                                checkmarkFound = true;
-                                break check;
+                            Color pixelColor = new Color(imageAfterChecked.getRGB(i, j));
+                            if (compareColor(pixelColor)) {
+                                System.out.println(pixelColor);
+                                pixelCounter++;
+                                if (pixelCounter >= 5) {
+                                    checkmarkFound = true;
+                                    break check;
+                                }
                             }
                         }
                     }

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

PR Comment: https://git.openjdk.org/jdk/pull/20723#issuecomment-2327652353


More information about the client-libs-dev mailing list