8276058: Some swing test fails on specific CI macos system
Reviewed-by: prr, kizune
This commit is contained in:
parent
81938001f9
commit
91607436b7
@ -190,7 +190,7 @@ java/awt/Toolkit/RealSync/Test.java 6849383 linux-all
|
||||
java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java 8159252 windows-all
|
||||
java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java 8072110 macosx-all
|
||||
java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.java 8073636 macosx-all
|
||||
java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java 7019055,8266245 windows-all,linux-all,macosx-aarch64
|
||||
java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java 7019055,8266245 windows-all,linux-all,macosx-all
|
||||
java/awt/Focus/8013611/JDK8013611.java 8175366 windows-all,macosx-all
|
||||
java/awt/Focus/6981400/Test1.java 8029675 windows-all,macosx-all
|
||||
java/awt/Focus/6981400/Test3.java 8173264 generic-all
|
||||
|
@ -46,6 +46,10 @@ public class MakeWindowAlwaysOnTop
|
||||
private static Frame f;
|
||||
private static Dialog d;
|
||||
|
||||
// move away from cursor
|
||||
private final static int OFFSET_X = -20;
|
||||
private final static int OFFSET_Y = -20;
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Robot r = Util.createRobot();
|
||||
@ -101,7 +105,7 @@ public class MakeWindowAlwaysOnTop
|
||||
Util.waitForIdle(r);
|
||||
|
||||
|
||||
Color c = r.getPixelColor(p.x + f.getWidth() / 2, p.y + f.getHeight() / 2);
|
||||
Color c = r.getPixelColor(p.x + f.getWidth() / 2 - OFFSET_X, p.y + f.getHeight() / 2 - OFFSET_Y);
|
||||
System.out.println("Color = " + c);
|
||||
|
||||
String exceptionMessage = null;
|
||||
|
@ -26,7 +26,9 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.image.BaseMultiResolutionImage;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -56,37 +58,56 @@ public class PressedIconTest {
|
||||
private static volatile double scale = -1;
|
||||
private static volatile int centerX;
|
||||
private static volatile int centerY;
|
||||
private static volatile Point location;
|
||||
// move away from cursor
|
||||
private final static int OFFSET_X = -20;
|
||||
private final static int OFFSET_Y = -20;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> createAndShowGUI());
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
scale = frame.getGraphicsConfiguration().getDefaultTransform()
|
||||
.getScaleX();
|
||||
Point location = frame.getLocation();
|
||||
location = frame.getLocation();
|
||||
Dimension size = frame.getSize();
|
||||
centerX = location.x + size.width / 2;
|
||||
centerY = location.y + size.height / 2;
|
||||
});
|
||||
robot.waitForIdle();
|
||||
|
||||
System.out.println("scale " + scale);
|
||||
|
||||
robot.mouseMove(centerX, centerY);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(100);
|
||||
Color color = robot.getPixelColor(centerX, centerY);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
Color color = robot.getPixelColor(centerX - OFFSET_X, centerY - OFFSET_Y);
|
||||
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
|
||||
BufferedImage img = robot.createScreenCapture(screen);
|
||||
javax.imageio.ImageIO.write(img, "png", new java.io.File("image.png"));
|
||||
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
|
||||
if ((scale == 1 && !similar(color, COLOR_1X))
|
||||
|| (scale == 2 && !similar(color, COLOR_2X))) {
|
||||
throw new RuntimeException("Colors are different!");
|
||||
if (scale == 1 && !similar(color, COLOR_1X)) {
|
||||
System.out.println("color " + color + " COLOR_1X " + COLOR_1X);
|
||||
throw new RuntimeException("Colors is different for scale=1!");
|
||||
}
|
||||
if (scale == 2 && !similar(color, COLOR_2X)) {
|
||||
System.out.println("color " + color + " COLOR_2X " + COLOR_2X);
|
||||
throw new RuntimeException("Colors is different for scale=2!");
|
||||
}
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
@ -108,6 +129,8 @@ public class PressedIconTest {
|
||||
panel.add(button, BorderLayout.CENTER);
|
||||
|
||||
frame.getContentPane().add(panel);
|
||||
frame.setUndecorated(true);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,12 @@
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JFrame;
|
||||
@ -52,6 +55,10 @@ public class bug8069348 {
|
||||
private static final Color DESKTOPPANE_COLOR = Color.YELLOW;
|
||||
private static final Color FRAME_COLOR = Color.ORANGE;
|
||||
|
||||
// move away from cursor
|
||||
private final static int OFFSET_X = -20;
|
||||
private final static int OFFSET_Y = -20;
|
||||
|
||||
private static JFrame frame;
|
||||
private static JInternalFrame internalFrame;
|
||||
|
||||
@ -66,7 +73,7 @@ public class bug8069348 {
|
||||
SwingUtilities.invokeAndWait(bug8069348::createAndShowGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.setAutoDelay(100);
|
||||
robot.waitForIdle();
|
||||
|
||||
Rectangle screenBounds = getInternalFrameScreenBounds();
|
||||
@ -79,27 +86,43 @@ public class bug8069348 {
|
||||
robot.mouseMove(x, y);
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseMove(x + dx, y + dy);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
int cx = screenBounds.x + screenBounds.width + dx / 2;
|
||||
int cy = screenBounds.y + screenBounds.height + dy / 2;
|
||||
|
||||
robot.mouseMove(cx, cy);
|
||||
if (!FRAME_COLOR.equals(robot.getPixelColor(cx, cy))) {
|
||||
robot.waitForIdle();
|
||||
Color color = robot.getPixelColor(cx - OFFSET_X, cy - OFFSET_Y);
|
||||
|
||||
if (!FRAME_COLOR.equals(color)) {
|
||||
System.out.println("cx " + cx + " cy " + cy);
|
||||
System.err.println("FRAME_COLOR Red: " + FRAME_COLOR.getRed() + "; Green: " + FRAME_COLOR.getGreen() + "; Blue: " + FRAME_COLOR.getBlue());
|
||||
System.err.println("Pixel color Red: " + color.getRed() + "; Green: " + color.getGreen() + "; Blue: " + color.getBlue());
|
||||
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
|
||||
BufferedImage img = robot.createScreenCapture(screen);
|
||||
javax.imageio.ImageIO.write(img, "png", new java.io.File("image.png"));
|
||||
|
||||
throw new RuntimeException("Internal frame is not correctly dragged!");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
|
||||
private static boolean isSupported() {
|
||||
String d3d = System.getProperty("sun.java2d.d3d");
|
||||
System.out.println("d3d " + d3d);
|
||||
return !Boolean.getBoolean(d3d) || getOSType() == OSType.WINDOWS;
|
||||
}
|
||||
|
||||
@ -138,6 +161,7 @@ public class bug8069348 {
|
||||
panel.add(desktopPane, BorderLayout.CENTER);
|
||||
frame.add(panel);
|
||||
frame.setSize(WIN_WIDTH, WIN_HEIGHT);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
frame.requestFocus();
|
||||
}
|
||||
|
@ -37,46 +37,67 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.synth.*;
|
||||
|
||||
public class bug6276188 extends JFrame {
|
||||
public class bug6276188 {
|
||||
|
||||
private static JButton button;
|
||||
private static Point p;
|
||||
private static JFrame testFrame;
|
||||
|
||||
// move away from cursor
|
||||
private final static int OFFSET_X = -20;
|
||||
private final static int OFFSET_Y = -20;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
|
||||
lookAndFeel.load(bug6276188.class.getResourceAsStream("bug6276188.xml"), bug6276188.class);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
UIManager.setLookAndFeel(lookAndFeel);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JFrame testFrame = new JFrame();
|
||||
testFrame.setLayout(new BorderLayout());
|
||||
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
testFrame.add(BorderLayout.CENTER, button = new JButton());
|
||||
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
|
||||
lookAndFeel.load(bug6276188.class.getResourceAsStream("bug6276188.xml"), bug6276188.class);
|
||||
UIManager.setLookAndFeel(lookAndFeel);
|
||||
|
||||
testFrame.setSize(new Dimension(320, 200));
|
||||
testFrame.setVisible(true);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
testFrame = new JFrame();
|
||||
testFrame.setLayout(new BorderLayout());
|
||||
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
testFrame.add(BorderLayout.CENTER, button = new JButton());
|
||||
|
||||
testFrame.setSize(new Dimension(320, 200));
|
||||
testFrame.setLocationRelativeTo(null);
|
||||
testFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
p = Util.getCenterPoint(button);
|
||||
System.out.println("Button center point: " + p);
|
||||
|
||||
robot.mouseMove(p.x , p.y);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
Color color = robot.getPixelColor(p.x - OFFSET_X, p.y - OFFSET_y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
boolean red = color.getRed() > 0 && color.getGreen() == 0 && color.getBlue() == 0;
|
||||
if (!red) {
|
||||
System.err.println("Red: " + color.getRed() + "; Green: " + color.getGreen() + "; Blue: " + color.getBlue());
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
|
||||
BufferedImage img = robot.createScreenCapture(screen);
|
||||
javax.imageio.ImageIO.write(img, "png", new java.io.File("image.png"));
|
||||
throw new RuntimeException("Synth ButtonUI does not handle PRESSED & MOUSE_OVER state");
|
||||
}
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
|
||||
p = Util.getCenterPoint(button);
|
||||
|
||||
robot.mouseMove(p.x , p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
Color color = robot.getPixelColor(p.x, p.y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
boolean red = color.getRed() > 0 && color.getGreen() == 0 && color.getBlue() == 0;
|
||||
if (!red) {
|
||||
System.err.println("Red: " + color.getRed() + "; Green: " + color.getGreen() + "; Blue: " + color.getBlue());
|
||||
throw new RuntimeException("Synth ButtonUI does not handle PRESSED & MOUSE_OVER state");
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (testFrame != null) {
|
||||
testFrame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user