8041447: Test javax/swing/dnd/7171812/bug7171812.java fails with java.lang.RuntimeException: Test failed, scroll on drag doesn't work

Reviewed-by: tr, serb
This commit is contained in:
Prasanta Sadhukhan 2023-02-22 06:13:09 +00:00
parent 180b94c73e
commit 2c52cf0746
2 changed files with 30 additions and 14 deletions
test/jdk
ProblemList.txt
javax/swing/dnd/7171812

@ -126,7 +126,6 @@ java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java 8160558 windows-a
java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java 8060176 windows-all,macosx-all
java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java 8060176 windows-all,macosx-all
java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java 8171510 macosx-all
javax/swing/dnd/7171812/bug7171812.java 8041447 macosx-all
java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all
java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252 macosx-all

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@ -26,26 +26,40 @@
* @key headful
* @bug 7171812
* @summary [macosx] Views keep scrolling back to the drag position after DnD
* @author Alexander Zuev
* @run main bug7171812
*/
import java.awt.*;
import java.awt.dnd.*;
import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.Robot;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.InputEvent;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
public class bug7171812 {
static JFrame mainFrame;
static String listData[];
static JListWithScroll<String> list;
static JScrollPane scrollPane;
static volatile Point pt;
static volatile int height;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
Robot robot = new Robot();
robot.setAutoDelay(100);
robot.setAutoWaitForIdle(true);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
@ -53,18 +67,21 @@ public class bug7171812 {
}
});
Robot robot = new Robot();
robot.setAutoDelay(10);
robot.waitForIdle();
robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
robot.mouseMove(scrollPane.getLocationOnScreen().x+5, scrollPane.getLocationOnScreen().y+offset);
robot.delay(1000);
SwingUtilities.invokeAndWait(() -> {
pt = scrollPane.getLocationOnScreen();
height = scrollPane.getHeight();
});
robot.mouseMove(pt.x + 5, pt.y + 5);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
for(int offset = 5; offset < height - 20; offset++) {
robot.mouseMove(pt.x + 5, pt.y + offset);
}
for(int offset = 5; offset < 195; offset++) {
robot.mouseMove(scrollPane.getLocationOnScreen().x+offset, scrollPane.getLocationOnScreen().y+scrollPane.getHeight()-20);
robot.mouseMove(pt.x + offset, pt.y + height - 20);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override