Skip to content

Commit

Permalink
8233570: [TESTBUG] HTMLEditorKit test bug5043626.java is failing on m…
Browse files Browse the repository at this point in the history
…acos

Backport-of: a5b42ec
  • Loading branch information
RealCLanger committed Nov 5, 2021
1 parent e929b18 commit 889840b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ javax/swing/JTree/8003830/bug8003830.java 8199057 generic-all
javax/swing/ToolTipManager/Test6256140.java 8233560 macosx-all
javax/swing/text/View/8014863/bug8014863.java 8233561 macosx-all
javax/swing/text/StyledEditorKit/4506788/bug4506788.java 8233562 macosx-all
javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java 233570 macosx-all
javax/swing/text/GlyphPainter2/6427244/bug6427244.java 8208566 macosx-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381 macosx-all
javax/swing/JPopupMenu/4634626/bug4634626.java 8017175 macosx-all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
* @key headful
* @bug 5043626
* @summary Tests pressing Home or Ctrl+Home set cursor to invisible element <head>
* @author Alexander Potochkin
* @library ../../../../regtesthelpers
* @build Util
* @run main bug5043626
*/

Expand All @@ -43,38 +40,51 @@ public class bug5043626 {

private static Document doc;
private static Robot robot;
private static JFrame frame;

public static void main(String[] args) throws Exception {
robot = new Robot();
try {
robot = new Robot();
robot.setAutoDelay(100);

SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});

robot.waitForIdle();
robot.waitForIdle();
robot.delay(1000);

Util.hitKeys(robot, KeyEvent.VK_HOME);
Util.hitKeys(robot, KeyEvent.VK_1);
robot.keyPress(KeyEvent.VK_HOME);
robot.keyRelease(KeyEvent.VK_HOME);
robot.keyPress(KeyEvent.VK_1);
robot.keyRelease(KeyEvent.VK_1);

robot.waitForIdle();
robot.waitForIdle();

String test = getText();
String test = getText();

if (!"1test".equals(test)) {
throw new RuntimeException("Begin line action set cursor inside <head> tag");
}
if (!"1test".equals(test)) {
throw new RuntimeException("Begin line action set cursor inside <head> tag");
}

Util.hitKeys(robot, KeyEvent.VK_HOME);
Util.hitKeys(robot, KeyEvent.VK_2);
robot.keyPress(KeyEvent.VK_HOME);
robot.keyRelease(KeyEvent.VK_HOME);
robot.keyPress(KeyEvent.VK_2);
robot.keyRelease(KeyEvent.VK_2);

robot.waitForIdle();
robot.waitForIdle();

test = getText();
test = getText();

if (!"21test".equals(test)) {
throw new RuntimeException("Begin action set cursor inside <head> tag");
if (!"21test".equals(test)) {
throw new RuntimeException("Begin action set cursor inside <head> tag");
}
} finally {
if (frame != null) {
SwingUtilities.invokeAndWait(frame::dispose);
}
}
}

Expand All @@ -95,7 +105,7 @@ public void run() {
}

private static void createAndShowGUI() {
JFrame frame = new JFrame();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JEditorPane editorPane = new JEditorPane();
Expand All @@ -104,6 +114,7 @@ private static void createAndShowGUI() {
editorPane.setEditable(true);
frame.add(editorPane);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
doc = editorPane.getDocument();
editorPane.setCaretPosition(doc.getLength());
Expand Down

1 comment on commit 889840b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.