Skip to content

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

Reviewed-by: tr, prr
  • Loading branch information
prsadhuk committed Nov 17, 2022
1 parent cc44419 commit dd9aa72
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 802462
# The next test below is an intermittent failure
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
javax/swing/JTree/4633594/JTreeFocusTest.java 7105441 macosx-all
javax/swing/JTree/6263446/bug6263446.java 8296083 linux-all
javax/swing/JSpinner/4788637/bug4788637.java 8296084 linux-all
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all
javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all
Expand Down
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 dd9aa72

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