8296083: javax/swing/JTree/6263446/bug6263446.java fails intermittently on a VM

Reviewed-by: tr, prr
This commit is contained in:
Prasanta Sadhukhan 2022-11-17 03:25:37 +00:00
parent cc44419840
commit dd9aa7272d
2 changed files with 24 additions and 5 deletions
test/jdk
ProblemList.txt
javax/swing/JTree/6263446

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

@ -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
@ -38,7 +38,7 @@ import javax.swing.tree.*;
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;
@ -62,46 +62,59 @@ public class bug6263446 {
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
@ -109,12 +122,15 @@ public class bug6263446 {
assertEditing();
click(1);
robot.waitForIdle();
checkSelection(null);
click(2);
robot.waitForIdle();
checkSelection(FIRST);
click(3);
robot.waitForIdle();
checkSelection(ALL);
} finally {
if (frame != null) {
@ -128,7 +144,6 @@ public class bug6263446 {
for (int i = 0; i < times; i++) {
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
}
}
@ -141,7 +156,7 @@ public class bug6263446 {
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;
@ -166,9 +181,11 @@ public class bug6263446 {
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 {
@ -183,6 +200,7 @@ public class bug6263446 {
field.setAccessible(true);
DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
ce.setClickCountToStart(clicks);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
@ -248,7 +266,9 @@ public class bug6263446 {
private static void checkSelectedText(String sel) throws Exception {
assertEditing();
checkSelection(sel);
robot.waitForIdle();
cancelCellEditing();
robot.waitForIdle();
assertNotEditing();
}