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: a5b42ec8b29249814dda28e751ee363869e98da0
  • Loading branch information
mrserb committed Jan 30, 2023
1 parent 563f7b5 commit 604e582
Showing 1 changed file with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
* @test
* @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 @@ -42,38 +39,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 @@ -94,7 +104,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 @@ -103,6 +113,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 604e582

@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.