jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java
author aghaisas
Tue, 19 Apr 2016 13:00:00 +0530
changeset 37704 20f112179039
parent 16710 f041f82cdeac
child 40128 e635645d2a8a
permissions -rw-r--r--
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows Reviewed-by: yan, arapte
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     1
/*
37704
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
     2
 * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     4
 *
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     8
 *
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    13
 * accompanied this code).
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    14
 *
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    18
 *
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    21
 * questions.
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    22
 */
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    23
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    24
/**
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    25
 * @test @summary JVM crash if the frame is disposed in DropTargetListener
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    26
 * @author Petr Pchelko
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    27
 * @library ../../regtesthelpers
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    28
 * @build Util
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    29
 * @compile DisposeFrameOnDragTest.java
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    30
 * @run main/othervm DisposeFrameOnDragTest
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    31
 */
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    32
import java.awt.AWTException;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    33
import java.awt.Point;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    34
import java.awt.Robot;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    35
import java.awt.dnd.DropTargetAdapter;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    36
import java.awt.dnd.DropTargetDragEvent;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    37
import java.awt.dnd.DropTargetDropEvent;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    38
import java.awt.event.InputEvent;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    39
import java.lang.reflect.InvocationTargetException;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    40
import java.util.TooManyListenersException;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    41
import javax.swing.JFrame;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    42
import javax.swing.JTextArea;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    43
import javax.swing.SwingUtilities;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    44
import test.java.awt.regtesthelpers.Util;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    45
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    46
public class DisposeFrameOnDragTest {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    47
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    48
    private static JTextArea textArea;
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    49
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    50
    public static void main(String[] args) throws Throwable {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    51
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    52
        SwingUtilities.invokeAndWait(new Runnable() {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    53
            @Override
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    54
            public void run() {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    55
                constructTestUI();
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    56
            }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    57
        });
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    58
37704
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    59
        Robot testRobot = null;
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    60
        try {
37704
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    61
            testRobot = new Robot();
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    62
        } catch(AWTException ex) {
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    63
            throw new RuntimeException("Error while creating Robot");
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    64
        }
37704
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    65
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    66
        Util.waitForIdle(testRobot);
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    67
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    68
        Point loc = textArea.getLocationOnScreen();
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    69
        Util.drag(testRobot,
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    70
                new Point((int) loc.x + 3, (int) loc.y + 3),
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    71
                new Point((int) loc.x + 40, (int) loc.y + 40),
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    72
                InputEvent.BUTTON1_MASK);
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    73
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    74
        Util.waitForIdle(testRobot);
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    75
20f112179039 8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents: 16710
diff changeset
    76
        testRobot.delay(200);
16710
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    77
    }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    78
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    79
    private static void constructTestUI() {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    80
        final JFrame frame = new JFrame("Test frame");
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    81
        textArea = new JTextArea("Drag Me!");
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    82
        try {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    83
            textArea.getDropTarget().addDropTargetListener(new DropTargetAdapter() {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    84
                @Override
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    85
                public void drop(DropTargetDropEvent dtde) {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    86
                    //IGNORE
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    87
                }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    88
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    89
                @Override
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    90
                public void dragOver(DropTargetDragEvent dtde) {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    91
                    frame.dispose();
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    92
                }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    93
            });
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    94
        } catch (TooManyListenersException ex) {
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    95
            throw new RuntimeException(ex);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    96
        }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    97
        textArea.setSize(100, 100);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    98
        textArea.setDragEnabled(true);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
    99
        textArea.select(0, textArea.getText().length());
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
   100
        frame.add(textArea);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
   101
        frame.setBounds(100, 100, 100, 100);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
   102
        frame.setVisible(true);
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
   103
    }
f041f82cdeac 8006941: [macosx] Deadlock in drag and drop
pchelko
parents:
diff changeset
   104
}