Skip to content

8361193: Test java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java fails on MacOS X #26166

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

Open
wants to merge 2 commits into
base: pr/25971
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java 8048171 generic-all
java/awt/Mixing/AWT_Mixing/JMenuBarOverlapping.java 8159451 macosx-all
java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java 6986109 generic-all
java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.java 6986109 windows-all
java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java 8049405 macosx-all
java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java 8049405 macosx-all
java/awt/Mixing/AWT_Mixing/JPopupMenuOverlapping.java 8049405 macosx-all
java/awt/Mixing/NonOpaqueInternalFrame.java 7124549 macosx-all
Expand Down
21 changes: 18 additions & 3 deletions test/jdk/java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ public void run() {
awtPanel.add(jbutton);
jbutton.setForeground(jbColor);
jbutton.setBackground(jbColor);
jbutton.setOpaque(true);

JPanel jPanel = new JPanel();
jbutton2 = new JButton("SwingButton2");
jPanel.add(jbutton2);
jbutton2.setForeground(jb2Color);
jbutton2.setBackground(jb2Color);
jbutton2.setOpaque(true);
awtButton2 = new Button("AWT Button2");
jPanel.add(awtButton2);
awtButton2.setForeground(awt2Color);
Expand Down Expand Up @@ -163,19 +165,19 @@ public void run() {

btnLoc = awtButton.getLocationOnScreen();
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
if (!c.equals(awtColor)) {
if (!isAlmostEqualColor(c, awtColor)) {
fail("AWT Button was not redrawn properly on AWT Panel during move");
}

btnLoc = jbutton2.getLocationOnScreen();
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
if (!c.equals(jb2Color)) {
if (!isAlmostEqualColor(c, jb2Color)) {
fail("JButton was not redrawn properly on JPanel during move");
}

btnLoc = awtButton2.getLocationOnScreen();
c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
if (!c.equals(awt2Color)) {
if (!isAlmostEqualColor(c, awt2Color)) {
fail("ATW Button was not redrawn properly on JPanel during move");
}
}
Expand Down Expand Up @@ -298,6 +300,19 @@ public static synchronized void fail(String whyFailed) {
failureMessage = whyFailed;
mainThread.interrupt();
}//fail()
private static boolean isAlmostEqualColor(Color color, Color refColor) {
final int COLOR_TOLERANCE_MACOSX = 10;
if(color.equals(refColor)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(color.equals(refColor)){
if (color.equals(refColor)){

return true;
} else {
return Math.abs(color.getRed() - refColor.getRed()) <
COLOR_TOLERANCE_MACOSX &&
Math.abs(color.getGreen() - refColor.getGreen()) <
COLOR_TOLERANCE_MACOSX &&
Math.abs(color.getBlue() - refColor.getBlue()) <
COLOR_TOLERANCE_MACOSX;
}
}
}// class JButtonInGlassPane
class TestPassedException extends RuntimeException {
}