8284888: [macos] javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java failed with "NimbusLookAndFeel] : ERROR: icon and imageIcon not same."

Reviewed-by: prr
This commit is contained in:
Prasanta Sadhukhan 2022-05-12 08:54:28 +00:00
parent 50d47de835
commit ff17f496f4
2 changed files with 31 additions and 18 deletions

View File

@ -690,7 +690,6 @@ sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all
sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8265770 macosx-all
javax/swing/JTree/4908142/bug4908142.java 8278348 macosx-all
javax/swing/JTable/8236907/LastVisibleRow.java 8284619 macosx-all
javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java 8284888 macosx-aarch64
############################################################################

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,8 +26,6 @@
* @key headful
* @bug 8146321 8151282
* @summary verifies JInternalFrame Icon and ImageIcon
* @library ../../regtesthelpers
* @build Util
* @run main JInternalFrameIconTest
*/
import java.io.File;
@ -79,7 +77,7 @@ public class JInternalFrameIconTest {
createImageIconUI(lookAndFeelString);
robot.waitForIdle();
robot.delay(1000);
getImageIconBufferedImage();
getImageIconBufferedImage(lookAndFeelString);
robot.waitForIdle();
robot.delay(1000);
cleanUp();
@ -89,7 +87,7 @@ public class JInternalFrameIconTest {
createIconUI(lookAndFeelString);
robot.waitForIdle();
robot.delay(1000);
getIconBufferedImage();
getIconBufferedImage(lookAndFeelString);
robot.waitForIdle();
robot.delay(1000);
cleanUp();
@ -139,6 +137,7 @@ public class JInternalFrameIconTest {
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(desktopPane, "Center");
frame.setSize(500, 500);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
@ -182,6 +181,7 @@ public class JInternalFrameIconTest {
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(desktopPane, "Center");
frame.setSize(500, 500);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
@ -189,32 +189,46 @@ public class JInternalFrameIconTest {
});
}
private static void getImageIconBufferedImage() throws Exception {
private static void getImageIconBufferedImage(String lookAndFeelString) throws Exception {
Point point = internalFrame.getLocationOnScreen();
Rectangle rect = internalFrame.getBounds();
Rectangle captureRect = new Rectangle(
Rectangle captureRect = null;
if (lookAndFeelString.contains("Aqua")) {
captureRect = new Rectangle(
point.x + internalFrame.getInsets().left,
point.y + internalFrame.getInsets().top,
rect.width - internalFrame.getInsets().left - internalFrame.getInsets().right,
internalFrame.getInsets().top);
} else {
captureRect = new Rectangle(
point.x + internalFrame.getInsets().left,
point.y + internalFrame.getInsets().top,
titleImageIcon.getIconWidth(),
titleImageIcon.getIconHeight());
}
System.out.println("imageicon captureRect " + captureRect);
imageIconImage
= robot.createScreenCapture(captureRect);
imageIconImage = robot.createScreenCapture(captureRect);
}
private static void getIconBufferedImage() throws Exception {
private static void getIconBufferedImage(String lookAndFeelString) throws Exception {
Point point = internalFrame.getLocationOnScreen();
Rectangle rect = internalFrame.getBounds();
Rectangle captureRect = new Rectangle(
Rectangle captureRect = null;
if (lookAndFeelString.contains("Aqua")) {
captureRect = new Rectangle(
point.x + internalFrame.getInsets().left,
point.y + internalFrame.getInsets().top,
rect.width - internalFrame.getInsets().left - internalFrame.getInsets().right,
internalFrame.getInsets().top);
} else {
captureRect = new Rectangle(
point.x + internalFrame.getInsets().left,
point.y + internalFrame.getInsets().top,
titleIcon.getIconWidth(),
titleIcon.getIconHeight());
}
System.out.println("icon captureRect " + captureRect);
iconImage
= robot.createScreenCapture(captureRect);
iconImage = robot.createScreenCapture(captureRect);
}
private static void testIfSame(final String lookAndFeelString)
@ -225,7 +239,7 @@ public class JInternalFrameIconTest {
String error ="[" + lookAndFeelString
+ "] : ERROR: icon and imageIcon not same.";
errorString += error;
System.err.println(error);
System.out.println(error);
} else {
System.out.println("[" + lookAndFeelString
+ "] : SUCCESS: icon and imageIcon same.");
@ -238,7 +252,7 @@ public class JInternalFrameIconTest {
if (bufferedImage1.getWidth() == bufferedImage2.getWidth()
&& bufferedImage1.getHeight() == bufferedImage2.getHeight()) {
final int colorTolerance = 25;
final int colorTolerance = 1;
final int mismatchTolerance = (int) (0.1
* bufferedImage1.getWidth() * bufferedImage1.getHeight());
int mismatchCounter = 0;