RFR: 8316947: Write a test to check textArea triggers MouseEntered/MouseExited events properly
Harshitha Onkar
honkar at openjdk.org
Wed Oct 4 17:26:48 UTC 2023
On Thu, 28 Sep 2023 11:18:16 GMT, Ravi Gupta <duke at openjdk.org> wrote:
> Write a test to check textArea triggers MouseEntered/MouseExited events properly
>
> MouseEntered should be triggered only when the mouse enters the component and MouseExited should be triggered when the mouse goes out of the component.
>
> In TextArea, when we moved the mouse inside the component MouseMoved events are triggered properly. But when we slowly took the mouse outside the component that is towards the scrollbars, we could see a MouseEntered event being triggered followed by MouseExited.(before actually mouse enters the scrollbar)
>
> Testing:
> Tested using Mach5(20 times per platform) in macos,linux and windows and got all pass.
Is there source code fix or PR associated with this test. Since the PR description mentions "MouseEntered/Exited" events does not occur properly.
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 46:
> 44: private static Frame frame;
> 45: private volatile static TextArea textArea;
> 46: private volatile static List list;
Since TextArea and List are accessed only within invokeAndWait they need not be volatile.
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 55:
> 53:
> 54: private static MouseListener mListener = new MouseListener() {
> 55: public void mouseClicked(MouseEvent e) {
MouseAdapter can be used since only mouseEntered() & mouseExited() are being overridden.
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 66:
> 64: public void mouseEntered(MouseEvent e) {
> 65: System.out
> 66: .println("MouseEntered " + e.getSource().getClass().getName());
It is a bit odd to have a line break after sys.out. It looks better this way.
System.out.println("MouseEntered "
+ e.getSource().getClass().getName());
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 76:
> 74: public void mouseExited(MouseEvent e) {
> 75: System.out
> 76: .println("MouseExited " + e.getSource().getClass().getName());
Same here. Line break.
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 95:
> 93: frame.add(list);
> 94:
> 95: textArea = new TextArea("TextArea");
Rows and columns can be specified for the TextArea to reduce scan time.
Suggestion:
textArea = new TextArea("TextArea", 10, 10);
test/jdk/java/awt/event/MouseEvent/MouseEnterExitTest.java line 134:
> 132: if (frame != null) {
> 133: frame.dispose();
> 134: frame = null;
After frame.dispose() assigning the var back to null is unnecessary.
-------------
Changes requested by honkar (Committer).
PR Review: https://git.openjdk.org/jdk/pull/15961#pullrequestreview-1658089956
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346215327
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346187770
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346196406
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346197393
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346213448
PR Review Comment: https://git.openjdk.org/jdk/pull/15961#discussion_r1346199402
More information about the client-libs-dev
mailing list