8299713: Test javax/swing/JTableHeader/6889007/bug6889007.java failed: Wrong type of cursor
Reviewed-by: serb, tr
This commit is contained in:
parent
b3dbf28bc0
commit
b54c4a33c6
@ -23,28 +23,42 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
@test
|
@test
|
||||||
@key headful
|
@key headful
|
||||||
@bug 6889007
|
@bug 6889007
|
||||||
@summary No resize cursor during hovering mouse over JTable
|
@summary No resize cursor during hovering mouse over JTable
|
||||||
@author Alexander Potochkin
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.plaf.basic.BasicTableHeaderUI;
|
import javax.swing.plaf.basic.BasicTableHeaderUI;
|
||||||
import javax.swing.table.JTableHeader;
|
import javax.swing.table.JTableHeader;
|
||||||
import java.awt.*;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
public class bug6889007 {
|
public class bug6889007 {
|
||||||
|
|
||||||
|
static JFrame frame;
|
||||||
|
static Robot robot;
|
||||||
|
static volatile Point point;
|
||||||
|
static volatile int width;
|
||||||
|
static volatile int height;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Robot robot = new Robot();
|
try {
|
||||||
robot.setAutoDelay(20);
|
robot = new Robot();
|
||||||
|
robot.setAutoDelay(100);
|
||||||
|
|
||||||
final JFrame frame = new JFrame();
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
frame.setUndecorated(true);
|
frame = new JFrame();
|
||||||
|
frame.setUndecorated(true);
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
JTableHeader th = new JTableHeader();
|
JTableHeader th = new JTableHeader();
|
||||||
@ -56,21 +70,33 @@ public class bug6889007 {
|
|||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
});
|
||||||
|
robot.waitForIdle();
|
||||||
|
robot.delay(1000);
|
||||||
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
|
point = frame.getLocationOnScreen();
|
||||||
|
width = frame.getWidth();
|
||||||
|
height = frame.getHeight();
|
||||||
|
});
|
||||||
|
int shift = 10;
|
||||||
|
int x = point.x;
|
||||||
|
int y = point.y + height/2;
|
||||||
|
for(int i = -shift; i < width + 2*shift; i++) {
|
||||||
|
robot.mouseMove(x++, y);
|
||||||
|
robot.waitForIdle();
|
||||||
}
|
}
|
||||||
});
|
robot.waitForIdle();
|
||||||
robot.waitForIdle();
|
// 9 is a magic test number
|
||||||
Point point = frame.getLocationOnScreen();
|
if (MyTableHeaderUI.getTestValue() != 9) {
|
||||||
int shift = 10;
|
throw new RuntimeException("Unexpected test number "
|
||||||
int x = point.x;
|
+ MyTableHeaderUI.getTestValue());
|
||||||
int y = point.y + frame.getHeight()/2;
|
}
|
||||||
for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
|
} finally {
|
||||||
robot.mouseMove(x++, y);
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
}
|
if (frame != null) {
|
||||||
robot.waitForIdle();
|
frame.dispose();
|
||||||
// 9 is a magic test number
|
}
|
||||||
if (MyTableHeaderUI.getTestValue() != 9) {
|
});
|
||||||
throw new RuntimeException("Unexpected test number "
|
|
||||||
+ MyTableHeaderUI.getTestValue());
|
|
||||||
}
|
}
|
||||||
System.out.println("ok");
|
System.out.println("ok");
|
||||||
}
|
}
|
||||||
@ -83,6 +109,15 @@ public class bug6889007 {
|
|||||||
Cursor cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
|
Cursor cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
|
||||||
if (oldColumn != -1 && newColumn != -1 &&
|
if (oldColumn != -1 && newColumn != -1 &&
|
||||||
header.getCursor() != cursor) {
|
header.getCursor() != cursor) {
|
||||||
|
try {
|
||||||
|
Dimension screenSize =
|
||||||
|
Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
Rectangle screen = new Rectangle(0, 0,
|
||||||
|
(int) screenSize.getWidth(),
|
||||||
|
(int) screenSize.getHeight());
|
||||||
|
BufferedImage img = robot.createScreenCapture(screen);
|
||||||
|
ImageIO.write(img, "png", new java.io.File("image.png"));
|
||||||
|
} catch (Exception e) {}
|
||||||
throw new RuntimeException("Wrong type of cursor!");
|
throw new RuntimeException("Wrong type of cursor!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user