Skip to content

Commit

Permalink
8142540: [TEST_BUG] Test sun/awt/dnd/8024061/bug8024061.java fails on…
Browse files Browse the repository at this point in the history
… ubuntu

Reviewed-by: yan, serb
  • Loading branch information
Semyon Sadetsky committed Apr 13, 2017
1 parent 2fdd517 commit 84dd569
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions jdk/test/sun/awt/dnd/8024061/bug8024061.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2017 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 @@ -70,9 +70,14 @@ public class bug8024061 {
private static final DataFlavor DropObjectFlavor;
private static final int DELAY = 1000;

private final DnDPanel panel1 = new DnDPanel(Color.yellow);
private final DnDPanel panel2 = new DnDPanel(Color.pink);
static final DnDPanel panel1 = new DnDPanel(Color.yellow);
static final DnDPanel panel2 = new DnDPanel(Color.pink);
private final JFrame frame;
static Point here;
static Point there;
static Dimension d;



private static final CountDownLatch lock = new CountDownLatch(1);
private static volatile Exception dragEnterException = null;
Expand All @@ -91,7 +96,7 @@ public class bug8024061 {
frame = new JFrame("DnDWithRobot");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

Dimension d = new Dimension(100, 100);
d = new Dimension(100, 100);

panel1.setPreferredSize(d);
panel2.setPreferredSize(d);
Expand Down Expand Up @@ -126,12 +131,15 @@ public void run() {
final Robot robot = new Robot();
robot.setAutoDelay(10);
robot.waitForIdle();
robot.delay(200);

JFrame frame = dnd[0].frame;
Point point = frame.getLocationOnScreen();
Point here = new Point(point.x + 35, point.y + 45);
Point there = new Point(point.x + 120, point.y + 45);
here.x += 25;
SwingUtilities.invokeAndWait(() -> {
here = panel1.getLocationOnScreen();
there = panel2.getLocationOnScreen();
});
here.translate(d.width / 2, d.height / 2);
there.translate(d.width / 2, d.height / 2);
robot.mouseMove(here.x, here.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
while (here.x < there.x) {
Expand Down Expand Up @@ -159,7 +167,7 @@ public void run() {
throw new RuntimeException("Timed out waiting for dragEnter()");
}
} finally {
frame.dispose();
SwingUtilities.invokeLater(frame::dispose);
}
}

Expand Down Expand Up @@ -220,7 +228,7 @@ public Object getTransferData(DataFlavor flavor)
}
}

class DnDPanel extends JPanel {
static class DnDPanel extends JPanel {
DropObject dropObject;
final DragSource dragSource;
final DropTarget dropTarget;
Expand Down

2 comments on commit 84dd569

@mrserb
Copy link
Member

@mrserb mrserb commented on 84dd569 Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk8u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 84dd569 Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-84dd5699 in my personal fork of openjdk/jdk8u-dev. To create a pull request with this backport targeting openjdk/jdk8u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 84dd5699 from the openjdk/jdk repository.

The commit being backported was authored by Semyon Sadetsky on 13 Apr 2017 and was reviewed by Yuri Nesterenko and Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk8u-dev:

$ git fetch https://github.com/openjdk-bots/jdk8u-dev mrserb-backport-84dd5699:mrserb-backport-84dd5699
$ git checkout mrserb-backport-84dd5699
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk8u-dev mrserb-backport-84dd5699

Please sign in to comment.