Skip to content

Commit

Permalink
8316154: Opensource JTextArea manual tests
Browse files Browse the repository at this point in the history
Reviewed-by: abhiscxk, jdv
  • Loading branch information
prsadhuk committed Sep 14, 2023
1 parent 14408bc commit 33c62e4
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions test/jdk/javax/swing/JTextArea/bug4265784.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) 1999, 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 4265784 4267291
* @summary Tests work of TAB key in JTextArea
* @key headful
* @run main bug4265784
*/

import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

public class bug4265784 {
static JFrame frame;
static JTextArea ta;
static volatile Point p;
static volatile int pos;
static volatile int pos1;

public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(100);
try {
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame("bug4265784");
ta = new JTextArea();
frame.getContentPane().add(ta);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
robot.waitForIdle();
robot.delay(1000);
SwingUtilities.invokeAndWait(() -> {
p = ta.getLocationOnScreen();
});
robot.mouseMove(p.x + 10, p.y + 10);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
SwingUtilities.invokeAndWait(() -> {
pos = ta.getCaretPosition();
});
System.out.println(pos);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.waitForIdle();
robot.delay(1000);
SwingUtilities.invokeAndWait(() -> {
pos1 = ta.getCaretPosition();
});
System.out.println(pos1);
if (pos == pos1) {
throw new RuntimeException("TAB ignored");
}
} finally {
SwingUtilities.invokeAndWait(() -> {
if (frame != null) {
frame.dispose();
}
});
}
}
}

3 comments on commit 33c62e4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@SoniaZaldana
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 33c62e4 Apr 5, 2024

Choose a reason for hiding this comment

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

@SoniaZaldana the backport was successfully created on the branch backport-SoniaZaldana-33c62e4f in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 33c62e4f from the openjdk/jdk repository.

The commit being backported was authored by Prasanta Sadhukhan on 14 Sep 2023 and was reviewed by Abhishek Kumar and Jayathirth D V.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-SoniaZaldana-33c62e4f:backport-SoniaZaldana-33c62e4f
$ git checkout backport-SoniaZaldana-33c62e4f
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-SoniaZaldana-33c62e4f

Please sign in to comment.