-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8310072: JComboBox/DisabledComboBoxFontTestAuto: Enabled and disabled ComboBox does not match in these LAFs: GTK+ #18644
Conversation
👋 Welcome back abhiscxk! A progress list of the required criteria for merging this PR into |
@kumarabhi006 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 307 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@kumarabhi006 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
} else { | ||
failingLafs.append(lafName + ", "); | ||
} | ||
System.out.println("Test Passed: "+lafName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.out.println("Test Passed: "+lafName); | |
System.out.println("Test Passed: " + lafName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
int redDiff = c1.getRed() - c2.getRed(); | ||
int blueDiff = c1.getBlue() - c2.getBlue(); | ||
int greenDiff = c1.getGreen() - c2.getGreen(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need Math.abs to get the absolute value of the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Updated.
// In Windows LAF, the ComboBox sizes are different. | ||
// Combo size is 116 x 22 where as Combo2 size is 115 X 20 and | ||
// that results in pixel offset of 1px for width and 1px for height. | ||
eColor1 = new Color(enabledImage.getRGB(x, y)); | ||
eColor2 = new Color(enabledImage2.getRGB(x + 1, y - 1)); | ||
dColor1 = new Color(disabledImage.getRGB(x, y)); | ||
dColor2 = new Color(disabledImage2.getRGB(x + 1, y - 1)); | ||
} else if (lafName.equals("GTK+")) { | ||
// In GTK LAF, the ComboBox sizes are different. | ||
// Combo size is 159 x 30 where as Combo2 size is 179 X 34 and | ||
// that results in pixel offset of 10px for width and 2px for height. | ||
eColor1 = new Color(enabledImage.getRGB(x, y)); | ||
eColor2 = new Color(enabledImage2.getRGB(x + 10, y + 2)); | ||
dColor1 = new Color(disabledImage.getRGB(x, y)); | ||
dColor2 = new Color(disabledImage2.getRGB(x + 10, y + 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed with these components, sometimes the size varies slightly between different desktop scaling values or resolutions. You have exact combobox pixel sizes in the comments, but does this stay the same when you set your device to 200% or other values?
Maybe best to leave out the exact combo size from the comments regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed with these components, sometimes the size varies slightly between different desktop scaling values or resolutions. You have exact combobox pixel sizes in the comments, but does this stay the same when you set your device to 200% or other values?
Maybe best to leave out the exact combo size from the comments regardless.
Checked with UIScale of 2 and the images are of same size. But your point seems valid that may vary between different machine for different resolution or scale.
Removed the exact size from the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me now.
@@ -44,13 +37,22 @@ | |||
|
|||
import static java.awt.image.BufferedImage.TYPE_INT_ARGB; | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we keep jtreg comment section before imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion going on regarding placement of jtreg tags. Since, we updated jtreg tags aftre imports section in recent test sprint, kept it same here as well.
@@ -99,11 +101,10 @@ private static void testMethod() throws IOException { | |||
ImageIO.write(disabledImage2, "png", new File(testDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are saving these images even in the case where test passes. In my local macOS run i see 16 images getting saved in JTwork folder. This will end up taking good amount of space in our CI test systems.
We should save image only in case of test failure foe debugging purpose.
Also i see images with Mac OS X***.png
filename and all of them are just blank and there is no combobox. Is that fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are saving these images even in the case where test passes. In my local macOS run i see 16 images getting saved in JTwork folder. This will end up taking good amount of space in our CI test systems.
We should save image only in case of test failure foe debugging purpose.
Updated to save the image only when test fails.
Also i see images with Mac OS X***.png filename and all of them are just blank and there is no combobox. Is that fine?
Even I also observed the same but not sure about this.
public class DisabledComboBoxFontTestAuto { | ||
private static JComboBox combo, combo2; | ||
private static BufferedImage enabledImage, disabledImage, enabledImage2, disabledImage2; | ||
private static Path testDir; | ||
private static String lafName; | ||
private static StringBuffer failingLafs; | ||
private static int COMBO_HEIGHT, COMBO_WIDTH, COMBO2_HEIGHT, COMBO2_WIDTH; | ||
private static final int TOLERANCE = 20; | ||
|
||
private static void createCombo() { | ||
combo = new JComboBox(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can use unicode blank character instead of "Simple JComboBox" text. I think we make this test more robust and avoid tolerance checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the initial bug "JComboBox has correct font color when disabled" be verified with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change works fine with initial bug. Test failed if I comment out the fix proposed in initial bug for Nimbus LAF.
dColor1 = new Color(disabledImage.getRGB(x, y)); | ||
dColor2 = new Color(disabledImage2.getRGB(x + 1, y - 1)); | ||
} else if (lafName.equals("GTK+")) { | ||
// In GTK LAF, the ComboBox sizes are different and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to get these internal offsets programmatically and not use constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the offsets as after having unicode blank character there is no need of these.
@jayathirthrao Ran the updated test in CI, no failure observed across platforms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated changes look good to me.
As far as I understand the test creates two enabled-JComboBox, then disables both, and then compares the disabled and enabled images. Why there are some differences in sizes and colors? |
Not sure about this.. but there is a mention in initial bug also regarding size difference #12390 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess testDir
can be moved inside testMethod()
method where it is used.
|| (c1.getBlue() != c2.getBlue()) | ||
|| (c1.getGreen() != c2.getGreen())) { | ||
|
||
|| (c1.getBlue() != c2.getBlue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition can be optimized since the test is done for all LAF and for each this method is called twice. Instead of using ||, using && would optimized slightly. You can check for true
where it checks for ==
and returns true. Its just a suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition can be optimized since the test is done for all LAF and for each this method is called twice. Instead of using ||, using && would optimized slightly. You can check for
true
where it checks for==
and returns true. Its just a suggestion.
I think current comparison with || is ok as if any of the RGB color component doesn't match, test should fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to use &&
so that comparisons for failure case fails faster than ||
.
Similar to this:
` if ((c1.getRed() == c2.getRed())
&& (c1.getBlue() == c2.getBlue())
&& (c1.getGreen() == c2.getGreen())) {
return true;
} else {
System.out.println(lafName + " Enabled RGB failure: "
+ c1.getRed() + ", "
+ c1.getBlue() + ", "
+ c1.getGreen() + " vs "
+ c2.getRed() + ", "
+ c2.getBlue() + ", "
+ c2.getGreen());
return false;
}`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logical || operator doesn't check second condition if first condition is true. It checks second condition only if first one is false.
So as per current logic, if RED component is not equal, it doesn't check for GREEN and BLUE component and fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, similar thing applies to && and hence in failure condition || checks for all the colors while && drops off at first failure only. Which is why I suggested it would be better for failure cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, its !=
here right, then it'll fail fast for failure conditions...... Then no need to optimize......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In && operator if condition evaluate to false it will not check further.
Similarly, in || operator if condition evaluate to true it will not check further.
So if c1.getRed() != c2.getRed() evaluates to true, it will not check further and fail immediately.
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Difference in size is specific to LAFs like in case on Metal and Motif the sizes are same but in Nimbus and GTK it differs in size. Similarly in GTK LAF also the insets values are different in DefaultListCellRenderer and SynthComboBoxRenderer. Color difference is only in the background color for Windows LAF which is slightly different. |
@mrserb Do you have any other suggestion ? |
This sounds about right. I looked into this difference briefly in my original fix, and checked the insets, bounds, and borders. Now that you mention it, I remember it was the insets that differed between the two renderers. Didn't seem related to the issue/fix and may be intended, so I left it as is and modified my test to use a midline scan to compare the pixel colors between the two comboboxes. |
/integrate |
/dummy |
Going to push as commit eb60822.
Your commit was automatically rebased without conflicts. |
@kumarabhi006 Pushed as commit eb60822. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
@kumarabhi006 Unknown command |
Test was failing on GTK and Windows LAF due to pixel color mismatch. Th reason behind this issue was the size of image which is different and that results in incorrect pixel comparison. Fix is to ensure that correct pixel is matched and the pixel color should remain within tolerance.
For windows LAF the background color is not an exact match and thus added a TOLERANCE field to check if the RGB difference is within limits.
@key headful
added in jtreg tag to ensure that test run for GTK LAF as well which was not the case before as it is mentioned in JBSIt does not fail in mach5 because on linux + headless mode the gtk L&F is not supported.
CI testing is green for the modified test. Link attached in JBS.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18644/head:pull/18644
$ git checkout pull/18644
Update a local copy of the PR:
$ git checkout pull/18644
$ git pull https://git.openjdk.org/jdk.git pull/18644/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18644
View PR using the GUI difftool:
$ git pr show -t 18644
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18644.diff
Webrev
Link to Webrev Comment