Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk19u Public archive

Commit

Permalink
8296083: javax/swing/JTree/6263446/bug6263446.java fails intermittent…
Browse files Browse the repository at this point in the history
…ly on a VM

Backport-of: dd9aa7272d04b49dd5cbf3ff9f9091c7d63d68ae
  • Loading branch information
Victor Rudometov authored and Paul Hohensee committed Nov 18, 2022
1 parent e8fd24d commit c68057c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions test/jdk/javax/swing/JTree/6263446/bug6263446.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, 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 Down Expand Up @@ -38,7 +38,7 @@

public class bug6263446 {

private static final String FIRST = "AAAAAAAAAAA";
private static final String FIRST = "AAAAA";
private static final String SECOND = "BB";
private static final String ALL = FIRST + " " + SECOND;
private static JTree tree;
Expand All @@ -62,59 +62,75 @@ public void run() {
try {
Point point = getClickPoint();
robot.mouseMove(point.x, point.y);
robot.waitForIdle();

// click count 3
click(1);
robot.waitForIdle();
assertNotEditing();

click(2);
robot.waitForIdle();
assertNotEditing();

click(3);
robot.waitForIdle();
assertEditing();
cancelCellEditing();
assertNotEditing();

click(4);
robot.waitForIdle();
checkSelectedText(FIRST);

click(5);
robot.waitForIdle();
checkSelectedText(ALL);

// click count 4
setClickCountToStart(4);
robot.waitForIdle();

click(1);
robot.waitForIdle();
assertNotEditing();

click(2);
robot.waitForIdle();
assertNotEditing();

click(3);
robot.waitForIdle();
assertNotEditing();

click(4);
robot.waitForIdle();
assertEditing();
cancelCellEditing();
assertNotEditing();

click(5);
robot.waitForIdle();
checkSelectedText(FIRST);

click(6);
robot.waitForIdle();
checkSelectedText(ALL);

// start path editing
startPathEditing();
assertEditing();

click(1);
robot.waitForIdle();
checkSelection(null);

click(2);
robot.waitForIdle();
checkSelection(FIRST);

click(3);
robot.waitForIdle();
checkSelection(ALL);
} finally {
if (frame != null) {
Expand All @@ -128,7 +144,6 @@ private static void click(int times) {
for (int i = 0; i < times; i++) {
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
}
}

Expand All @@ -141,7 +156,7 @@ private static Point getClickPoint() throws Exception {
public void run() {
Rectangle rect = tree.getRowBounds(0);
// UPDATE !!!
Point p = new Point(rect.x + rect.width / 2, rect.y + 2);
Point p = new Point(rect.x + rect.width/2, rect.y + rect.height/2);
SwingUtilities.convertPointToScreen(p, tree);
result[0] = p;

Expand All @@ -166,9 +181,11 @@ private static void createAndShowGUI() {


frame.getContentPane().add(tree);
frame.setAlwaysOnTop(true);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
}

private static void setClickCountToStart(final int clicks) throws Exception {
Expand All @@ -183,6 +200,7 @@ public void run() {
field.setAccessible(true);
DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
ce.setClickCountToStart(clicks);

} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
Expand Down Expand Up @@ -248,7 +266,9 @@ public void run() {
private static void checkSelectedText(String sel) throws Exception {
assertEditing();
checkSelection(sel);
robot.waitForIdle();
cancelCellEditing();
robot.waitForIdle();
assertNotEditing();
}

Expand Down

1 comment on commit c68057c

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