Skip to content

Commit

Permalink
8345547: test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug427883…
Browse files Browse the repository at this point in the history
…9.java fails in ubuntu22.04

Reviewed-by: abhiscxk
  • Loading branch information
prsadhuk committed Dec 5, 2024
1 parent 2331782 commit e46d822
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions test/jdk/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, 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
Expand All @@ -26,17 +26,22 @@
* @key headful
* @bug 4278839 8233634
* @summary Incorrect cursor movement between words at the end of line
* @author Anton Nashatyrev
* @library ../../../regtesthelpers
* @build Util
* @run main bug4278839
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class bug4278839 extends JFrame {
public class bug4278839 {

private static boolean passed = true;
private static JTextArea area;
Expand All @@ -47,16 +52,12 @@ public static void main(String[] args) throws Exception {
try {

robo = new Robot();
robo.setAutoDelay(200);
robo.setAutoDelay(100);

SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
SwingUtilities.invokeAndWait(() -> createAndShowGUI());

robo.waitForIdle();
robo.delay(1000);

clickMouse();
robo.waitForIdle();
Expand Down Expand Up @@ -100,33 +101,27 @@ private static int moveCaret(boolean right) throws Exception {

final int[] result = new int[1];

SwingUtilities.invokeAndWait(new Runnable() {

@Override
public void run() {
result[0] = area.getCaretPosition();
}
SwingUtilities.invokeAndWait(() -> {
result[0] = area.getCaretPosition();
});

int pos = result[0];
return pos;
return result[0];
}

private static void clickMouse() throws Exception {
final Rectangle result[] = new Rectangle[1];

SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = new Rectangle(area.getLocationOnScreen(), area.getSize());
}
SwingUtilities.invokeAndWait(() -> {
result[0] = new Rectangle(area.getLocationOnScreen(), area.getSize());
});

Rectangle rect = result[0];

robo.mouseMove(rect.x + rect.width / 2, rect.y + rect.width / 2);
robo.mousePress(InputEvent.BUTTON1_MASK);
robo.mouseRelease(InputEvent.BUTTON1_MASK);
robo.waitForIdle();
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.waitForIdle();
}

/**
Expand Down

0 comments on commit e46d822

Please sign in to comment.