8041915: Move 8 awt tests to OpenJDK regression tests tree
authoryan
Mon, 26 May 2014 15:50:10 +0400
changeset 25108 cbf21a81a738
parent 25107 9a16a601de25
child 25109 61e7baccc995
8041915: Move 8 awt tests to OpenJDK regression tests tree Reviewed-by: pchelko, alexsch Contributed-by: Dmitriy Ermashov <dmitriy.ermashov@oracle.com>
jdk/test/java/awt/EventQueue/InvocationEventTest/InvocationEventTest.java
jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Common.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java
jdk/test/lib/testlibrary/ExtendedRobot.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/EventQueue/InvocationEventTest/InvocationEventTest.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+
+/*
+ * @test
+ * @summary  To Test the following assertions in InvovationEvent.
+ * 1.InvocationEvent when dispatched, should invoke the
+ *   run() method of the Runnable Interface.
+ * 2.If catchExceptions is false, Exception should be
+ *   propagated up to the EventDispatchThread's dispatch loop.
+ * 3.If catchExceptions is true, InvocationEvent.getExceptions()
+ *   should return the exception thrown inside thr run() method.
+ * 4.When InvocationEvent object is posted on to the EventQueue,
+ *   InvocationEvent.dispatch() method should be invoked by the
+ *   EventQueue.
+ * 5.If the notifier object is not null, notifyAll() of the
+ *   notifier object should be invoked when the run() method returns.
+ * 6.To test whether the threads are invoked in the right order
+ *   When InvocationEvents are nested.
+ * 7.The getWhen method should return timestamp which is less than
+ *   current System time and greater than the time before it has
+ *   actually happened
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @run main InvocationEventTest
+ */
+
+public class InvocationEventTest {
+    EventQueue eventQ1 = new EventQueue();
+
+    Object lock = new Object();
+
+    static final int delay = 5000;
+
+    public volatile boolean notifierStatus = false;
+    public Object notifierLock = new Object();
+
+    public volatile boolean threadStatus = false;
+    public volatile boolean childInvoked = false;
+
+    public synchronized void doTest() throws Exception {
+        // Testing assertions 1, 2 and 7:
+        // 1.InvocationEvent when dispatched, should invoke the
+        //   run() method of the Runnable Interface.
+        // 2.If catchExceptions is false, Exception should be
+        //   propagated up to the EventDispatchThread's dispatch loop.
+        // 7.The getWhen method should return timestamp which is less than
+        //   current System time and greater than the time before it has
+        //   actually happened
+
+        long timeBeforeInvoking = System.currentTimeMillis();
+
+        Thread.sleep(10);
+
+        InvocationEvent invoc = new InvocationEvent(this, () -> { threadStatus = true; }, lock, false);
+        invoc.dispatch();
+
+        Thread.sleep(10);
+
+        if (!threadStatus) {
+            synchronized (lock) {
+                lock.wait(delay);
+            }
+        }
+
+        // testing getException() when no exception is thrown
+        if (invoc.getWhen() <= timeBeforeInvoking ||
+                invoc.getWhen() >= System.currentTimeMillis()) {
+            throw new RuntimeException("getWhen method is not getting the time at which event occured");
+        }
+
+        if (invoc.getException() != null) {
+            throw new RuntimeException("InvocationEvent.getException() does not return null " +
+                    "when catchException is false");
+        }
+
+        // testing the normal behaviour of InvocationEvent
+        if (!threadStatus) {
+            throw new RuntimeException("InvocationEvent when dispatched, did not" +
+                    " invoke the run() of the Runnable interface  ");
+        }
+        threadStatus = false;
+
+        // Testing assertion 3:
+        // 3.If catchExceptions is true, InvocationEvent.getExceptions()
+        //   should return the exception thrown inside the run() method.
+        RuntimeException sampleExn = new RuntimeException(" test exception");
+
+        invoc = new InvocationEvent(this, () -> { threadStatus = true; throw sampleExn; }, lock, true);
+        invoc.dispatch();
+        if (!threadStatus) {
+            synchronized (lock) {
+                lock.wait(delay);
+            }
+        }
+        // testing getException() when exception is thrown
+        // Should return the same exception thrown inside the run() method
+        if (!invoc.getException().equals(sampleExn)) {
+            throw new RuntimeException("getException() does not return " +
+                    "the same Exception thrown inside the run() method ");
+        }
+        threadStatus = false;
+
+        // Testing assertions 4 and 5:
+        // 4.When InvocationEvent object is posted on to the EventQueue,
+        //   InvocationEvent.dispatch() method should be invoked by the
+        //   EventQueue.
+        // 5.If the notifier object is not null, notifyAll() of the
+        //   notifier object should be invoked when the run() method returns.
+
+        Thread notify = new Thread(){
+            public void run() {
+                synchronized (this) {
+                    try { wait(); } catch (InterruptedException e) { throw new RuntimeException(e); }
+                }
+                notifierStatus = true;
+                synchronized (notifierLock) {
+                    notifierLock.notifyAll();
+                }
+            }
+        };
+        notify.start();
+
+        while (notify.getState() != Thread.State.WAITING)
+            Thread.sleep(delay/5);
+
+        InvocationEvent invocation = new InvocationEvent(this, () -> { }, (Object) notify, false);
+        eventQ1.postEvent(invocation);
+
+        while(!invocation.isDispatched())
+            synchronized (notifierLock) {
+                notifierLock.wait(delay);
+            }
+
+        while (notify.getState() != Thread.State.TERMINATED)
+            Thread.sleep(delay/5);
+
+        if (!notifierStatus) {
+            throw new RuntimeException("Notifier object did not get notified" +
+                    " When the run method of the Runnable returns ");
+        }
+
+        // Testing assertion 6:
+        // 6.To test whether the threads are invoked in the right order
+        //   When InvocationEvents are nested.
+        Thread thread = new Thread(){
+            public void run() {
+                InvocationEvent evt = new InvocationEvent(this, () -> { childInvoked = true; }, (Object) this, false);
+                new EventQueue().postEvent(evt);
+                synchronized (this) {
+                    try {
+                        wait(delay);
+                    } catch (InterruptedException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+                threadStatus = true;
+            }
+        };
+
+        invocation = new InvocationEvent(this, thread, lock, false);
+
+        eventQ1.postEvent(invocation);
+
+        while (!invocation.isDispatched())
+            synchronized (lock) {
+                lock.wait(delay);
+            }
+
+        if (!threadStatus || !childInvoked) {
+            throw new RuntimeException("Nesting of InvocationEvents when dispatched," +
+                    " did not invoke the run() of the Runnables properly ");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        new InvocationEventTest().doTest();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary An attempt to set non-trivial background, shape, or translucency
+ *          to a decorated toplevel should end with an exception.
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main DecoratedExceptions
+ */
+public class DecoratedExceptions {
+    public static void main(String args[]) throws Exception{
+        ExtendedRobot robot = new ExtendedRobot();
+        Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(() -> {
+            Frame frame = new Frame("Frame");
+            frame.setBounds(50,50,400,200);
+            try {
+                frame.setOpacity(0.5f);
+                throw new RuntimeException("No exception when Opacity set to a decorated Frame");
+            }catch(IllegalComponentStateException e) {
+            }
+            try {
+                frame.setShape(new Rectangle(50,50,400,200));
+                throw new RuntimeException("No exception when Shape set to a decorated Frame");
+            }catch(IllegalComponentStateException e) {
+            }
+            try {
+                frame.setBackground(new Color(50, 50, 50, 100));
+                throw new RuntimeException("No exception when Alpha background set to a decorated Frame");
+            }catch(IllegalComponentStateException e) {
+            }
+            frame.setVisible(true);
+            Dialog dialog = new Dialog( frame );
+            try {
+                dialog.setOpacity(0.5f);
+                throw new RuntimeException("No exception when Opacity set to a decorated Dialog");
+            }catch(IllegalComponentStateException e) {
+            }
+            try {
+                dialog.setShape(new Rectangle(50,50,400,200));
+                throw new RuntimeException("No exception when Shape set to a decorated Dialog");
+            }catch(IllegalComponentStateException e) {
+            }
+            try {
+                dialog.setBackground(new Color(50, 50, 50, 100));
+                throw new RuntimeException("No exception when Alpha background set to a decorated Dialog");
+            }catch(IllegalComponentStateException e) {
+            }
+            dialog.setVisible(true);
+        });
+        robot.waitForIdle(1000);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Common.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.geom.Area;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.security.SecureRandom;
+
+
+/*
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ */
+public abstract class Common {
+
+    ExtendedRobot robot;
+    Class<? extends Frame> windowClass;
+    Frame background;
+    BufferedImage foreground;
+    Window window;
+    Container componentsContainer;
+
+    float opacity = 1.0f;
+    static final int STATIC_STEP = 30;
+    static final int STATIC_WIDTH = 25;
+    static final int STATIC_BLOCKS = 30;
+    static final Color BG_COLOR = Color.BLUE;
+    static final Color FG_COLOR = Color.RED;
+    static final int delay = 1000;
+    static final SecureRandom random = new SecureRandom();
+    static final int dl = 100;
+    static final Class[] WINDOWS_TO_TEST = { Window.class, Frame.class, Dialog.class };
+
+    public Common(Class windowClass, float opacity) throws Exception{
+        this.opacity = opacity;
+        robot = new ExtendedRobot();
+        this.windowClass = windowClass;
+        EventQueue.invokeAndWait(this::initBackgroundFrame);
+        EventQueue.invokeAndWait(this::initGUI);
+    }
+
+    public Common(Class windowClass) throws Exception{
+        this(windowClass, 1.0f);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+    };
+
+    public void dispose() {
+        window.dispose();
+        background.dispose();
+    }
+
+    public abstract void applyShape();
+
+    public void applyDynamicShape() {
+        final Area a = new Area();
+        Dimension size = window.getSize();
+        for (int x = 0; x < 3; x++) {
+            for (int y = 0; y < 3; y++) {
+                a.add(new Area(new Rectangle2D.Double(
+                        x * size.getWidth() / 17*6, y * size.getHeight() / 17*6,
+                        size.getWidth() / 17*5, size.getHeight() / 17*5)));
+            }
+        }
+        window.setShape(a);
+    }
+
+    public void applyStaticShape() {
+        final Area a = new Area();
+        for (int x = 0; x < STATIC_BLOCKS; x++) {
+            for (int y = 0; y < STATIC_BLOCKS; y++) {
+                a.add(new Area(new Rectangle2D.Float(
+                        x*STATIC_STEP, y*STATIC_STEP,
+                        STATIC_WIDTH, STATIC_WIDTH)));
+            }
+        }
+        window.setShape(a);
+    }
+
+    public BufferedImage getForegroundWindow() throws Exception {
+        final BufferedImage f[] = new BufferedImage[1];
+        EventQueue.invokeAndWait( () -> {
+            f[0] = new BufferedImage(window.getWidth(),
+                    window.getHeight(), BufferedImage.TYPE_INT_RGB);
+            window.printAll(f[0].createGraphics());
+        });
+        robot.waitForIdle(delay);
+        return f[0];
+    }
+
+    public static boolean checkTranslucencyMode(GraphicsDevice.WindowTranslucency mode) {
+
+        if (!GraphicsEnvironment
+                .getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice()
+                .isWindowTranslucencySupported(mode)){
+            System.out.println(mode+" translucency mode isn't supported");
+            return false;
+        } else {
+            return true;
+        }
+
+    }
+
+    public void applyAppDragNResizeSupport() {
+        MouseAdapter m = new MouseAdapter() {
+
+            private Point dragOrigin = null;
+            private Dimension origSize = null;
+            private Point origLoc = null;
+            private boolean left = false;
+            private boolean top = false;
+            private boolean bottom = false;
+            private boolean right = false;
+
+            public void mousePressed(MouseEvent e) {
+                dragOrigin = e.getLocationOnScreen();
+                origSize = window.getSize();
+                origLoc = window.getLocationOnScreen();
+                right = (origLoc.x + window.getWidth() - dragOrigin.x) < 5;
+                left = !right && dragOrigin.x - origLoc.x < 5;
+                bottom = (origLoc.y + window.getHeight() - dragOrigin.y) < 5;
+                top = !bottom && dragOrigin.y - origLoc.y < 5;
+            }
+
+            public void mouseReleased(MouseEvent e) { resize(e); }
+            public void mouseDragged(MouseEvent e) { resize(e); }
+
+            void resize(MouseEvent e) {
+                Point dragDelta = e.getLocationOnScreen();
+                dragDelta.translate(-dragOrigin.x, -dragOrigin.y);
+                Point newLoc = new Point(origLoc);
+                newLoc.translate(dragDelta.x, dragDelta.y);
+                Dimension newSize = new Dimension(origSize);
+                if (left || right) {
+                    newSize.width += right ? dragDelta.x : -dragDelta.x;
+                }
+                if (top || bottom) {
+                    newSize.height += bottom ? dragDelta.y : -dragDelta.y;
+                }
+                if (right || (top || bottom) && !left) {
+                    newLoc.x = origLoc.x;
+                }
+                if (bottom || (left || right) && !top) {
+                    newLoc.y = origLoc.y;
+                }
+                window.setBounds(newLoc.x, newLoc.y, newSize.width, newSize.height);
+            }
+        };
+        for (Component comp : window.getComponents()) {
+            comp.addMouseListener(m);
+            comp.addMouseMotionListener(m);
+        }
+
+        window.addMouseListener(m);
+        window.addMouseMotionListener(m);
+    }
+
+    public void checkTranslucentShape() throws Exception {
+        foreground = getForegroundWindow();
+        Point[] points = new Point[4];
+
+        Dimension size = window.getSize();
+        Point location = window.getLocationOnScreen();
+
+        points[0] = new Point(20, 20);
+        points[1] = new Point(20, size.height-20);
+        points[2] = new Point(size.width-20, 20);
+        points[3] = new Point(size.width-20, size.height-20);
+
+        for (Point p : points){
+            p.translate(location.x, location.y);
+            Color actual = robot.getPixelColor(p.x, p.y);
+            if (actual.equals(BG_COLOR)|| actual.equals(FG_COLOR))
+                throw new RuntimeException("Error in point "+p+": "+actual+" equals to foreground or background color");
+            else
+                System.out.println("OK with foreground point "+p);
+        }
+    }
+
+    public void checkStaticShape() throws Exception {
+        Point[] points = new Point[4];
+
+        Dimension size = window.getSize();
+        int xFactor = (int) Math.floor(size.getWidth()/STATIC_STEP)-1;
+        int yFactor = (int) Math.floor(size.getHeight()/STATIC_STEP)-1;
+
+        // background
+        points[0] = new Point((STATIC_STEP+STATIC_WIDTH)/2, (STATIC_STEP+STATIC_WIDTH)/2);
+        points[1] = new Point(STATIC_STEP*xFactor+(STATIC_STEP+STATIC_WIDTH)/2, STATIC_STEP*yFactor+(STATIC_STEP+STATIC_WIDTH)/2);
+        points[2] = new Point((STATIC_STEP+STATIC_WIDTH)/2, STATIC_STEP*yFactor+(STATIC_STEP+STATIC_WIDTH)/2);
+        points[3] = new Point(STATIC_STEP*xFactor+(STATIC_STEP+STATIC_WIDTH)/2, (STATIC_STEP+STATIC_WIDTH)/2);
+        checkShape(points, true);
+
+        // foreground
+        if (opacity < 1.0f){
+            checkTranslucentShape();
+        } else {
+            points[0] = new Point((STATIC_WIDTH) / 2, (STATIC_WIDTH) / 2);
+            points[1] = new Point(STATIC_STEP * xFactor + (STATIC_WIDTH) / 2, STATIC_STEP * yFactor + (STATIC_WIDTH) / 2);
+            points[2] = new Point((STATIC_WIDTH) / 2, STATIC_STEP * yFactor + (STATIC_WIDTH) / 2);
+            points[3] = new Point(STATIC_STEP * xFactor + (STATIC_WIDTH) / 2, (STATIC_WIDTH) / 2);
+            checkShape(points, false);
+        }
+    }
+
+    public void checkDynamicShape() throws Exception {
+        Point[] points = new Point[4];
+
+        Dimension size = window.getSize();
+
+        int blockSizeX = (int) (size.getWidth() / 17);
+        int blockSizeY = (int) (size.getHeight() / 17);
+
+        // background
+        points[0] = new Point((int) (blockSizeX * 5.5), (int) (blockSizeY * 5.5));
+        points[1] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5));
+        points[2] = new Point((int) (blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5));
+        points[3] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (blockSizeY * 5.5));
+        checkShape(points, true);
+
+        // foreground
+        if (opacity < 1.0f){
+            checkTranslucentShape();
+        } else {
+            points[0] = new Point(3 * blockSizeX, 3 * blockSizeY);
+            points[1] = new Point(14 * blockSizeX, 14 * blockSizeY);
+            points[2] = new Point(3 * blockSizeX, 14 * blockSizeY);
+            points[3] = new Point(14 * blockSizeX, 3 * blockSizeY);
+            checkShape(points, false);
+        }
+    }
+
+    public void checkShape(Point[] points, boolean areBackgroundPoints) throws Exception {
+
+        Point location = window.getLocationOnScreen();
+
+        for (Point p : points) {
+            p.translate(location.x, location.y);
+            if (areBackgroundPoints) {
+                if (!robot.getPixelColor(p.x, p.y).equals(BG_COLOR))
+                    throw new RuntimeException("Background point " + p + " color " + robot.getPixelColor(p.x, p.y) +
+                            " does not equal to background color " + BG_COLOR);
+                else
+                    System.out.println("OK with background point " + p);
+            } else {
+                if (robot.getPixelColor(p.x, p.y).equals(BG_COLOR))
+                    throw new RuntimeException("Foreground point " + p +
+                            " equals to background color " + BG_COLOR);
+                else
+                    System.out.println("OK with foreground point " + p);
+            }
+        }
+    }
+
+    public void initBackgroundFrame() {
+        background = new Frame();
+        background.setUndecorated(true);
+        background.setBackground(BG_COLOR);
+        background.setSize(500, 500);
+        background.setLocation(dl, dl);
+        background.setVisible(true);
+    }
+
+    public void initGUI() {
+        if (windowClass.equals(Frame.class)) {
+            window = new Frame();
+            ((Frame) window).setUndecorated(true);
+        } else  if (windowClass.equals(Dialog.class)) {
+            window = new Dialog(background);
+            ((Dialog) window).setUndecorated(true);
+        } else {
+            window = new Window(background);
+        }
+
+        window.setBackground(FG_COLOR);
+        componentsContainer = new Panel();
+        window.add(componentsContainer, BorderLayout.CENTER);
+        window.setLocation(2 * dl, 2 * dl);
+        window.setSize(255, 255);
+        if (opacity < 1.0f)
+            window.setOpacity(opacity);
+        window.addComponentListener(new ComponentAdapter() {
+            public void componentResized(ComponentEvent e) {
+                applyShape();
+            }
+        });
+        applyShape();
+        window.setVisible(true);
+        applyAppDragNResizeSupport();
+        window.toFront();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+import java.util.HashMap;
+
+/*
+ * @test
+ * @bug 8013450
+ * @summary Check if the window events (Focus and Activation) are triggered correctly
+ *          when clicked on visible and clipped areas.
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main FocusAWTTest
+ */
+
+public class FocusAWTTest extends Common {
+
+    ExtendedRobot robot;
+    int dx;
+    int dy;
+    static final int x = 20;
+    static final int y = 400;
+
+    static volatile HashMap<String, Boolean> flags = new HashMap<String, Boolean>();
+    static {
+        flags.put("backgroundWindowActivated", false);
+        flags.put("backgroundWindowDeactivated", false);
+        flags.put("backgroundWindowGotFocus", false);
+        flags.put("backgroundWindowLostFocus", false);
+        flags.put("foregroundWindowGotFocus", false);
+        flags.put("foregroundWindowLostFocus", false);
+        flags.put("foregroundWindowActivated", false);
+        flags.put("foregroundWindowDeactivated", false);
+    }
+
+    public static void main(String[] ignored) throws Exception{
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST) {
+                new FocusAWTTest(windowClass).doTest();
+            }
+    }
+
+    public FocusAWTTest(Class windowClass) throws Exception {
+        super(windowClass);
+        this.robot = new ExtendedRobot();
+        robot.waitForIdle();
+        EventQueue.invokeAndWait(() -> {
+            dx = background.getX() - x;
+            dy = background.getY() - y;
+        });
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        background = new Frame();
+        background.setSize(300, 300);
+        background.setLocation(x, y);
+        background.setFocusable(true);
+        background.setFocusableWindowState(true);
+
+        background.addWindowFocusListener(new WindowFocusListener() {
+            public void windowGainedFocus(WindowEvent e) { flags.put("backgroundWindowGotFocus", true); }
+            public void windowLostFocus(WindowEvent e) { flags.put("backgroundWindowLostFocus", true); }
+        });
+
+        background.addWindowListener(new WindowAdapter() {
+            public void windowActivated(WindowEvent e) { flags.put("backgroundWindowActivated", true); }
+            public void windowDeactivated(WindowEvent e) { flags.put("backgroundWindowDeactivated", true); }
+        });
+        background.add(new TextArea());
+        background.setVisible(true);
+    }
+
+    @Override
+    public void initGUI() {
+        if (windowClass.equals(Frame.class)) {
+            window = new Frame() {
+                public void paint(Graphics g) {
+                    g.setColor(Color.BLUE);
+                    g.fillRect(0, 0, 200, 200);
+                }
+            };
+            ((Frame) window).setUndecorated(true);
+        } else if (windowClass.equals(Dialog.class)) {
+            window = new Dialog(background) {
+                public void paint(Graphics g) {
+                    g.setColor(Color.BLUE);
+                    g.fillRect(0, 0, 200, 200);
+                }
+            };
+            ((Dialog) window).setUndecorated(true);
+        } else {
+            window = new Window(background) {
+                public void paint(Graphics g) {
+                    g.setColor(Color.BLUE);
+                    g.fillRect(0, 0, 200, 200);
+                }
+            };
+            window.setFocusable(true);
+            window.setFocusableWindowState(true);
+        }
+
+        window.setPreferredSize(new Dimension(200, 200));
+        window.setLocation(70 + dx, 450 + dy);
+        window.setLayout(new BorderLayout());
+
+        window.addWindowFocusListener(new WindowFocusListener() {
+            public void windowGainedFocus(WindowEvent e) { flags.put("foregroundWindowGotFocus", true); }
+            public void windowLostFocus(WindowEvent e) { flags.put("foregroundWindowLostFocus", true); }
+        });
+
+        window.addWindowListener(new WindowAdapter() {
+            public void windowActivated(WindowEvent e) { flags.put("foregroundWindowActivated", true); }
+            public void windowDeactivated(WindowEvent e) { flags.put("foregroundWindowDeactivated", true); }
+        });
+
+        applyShape();
+        window.pack();
+        window.setAlwaysOnTop(true);
+        window.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+        super.doTest();
+        final Point wls = new Point();
+        final Dimension size = new Dimension();
+        EventQueue.invokeAndWait(() -> {
+            window.requestFocus();
+            wls.setLocation(window.getLocationOnScreen());
+            window.getSize(size);
+        });
+
+        robot.waitForIdle();
+
+        check(wls.x + size.width - 5, wls.y + 5, wls.x + size.width / 3, wls.y + size.height / 3);
+        check(wls.x + size.width / 2, wls.y + size.height / 2, wls.x + size.width * 2 / 3, wls.y + size.height * 2 / 3);
+
+        EventQueue.invokeAndWait(() -> {
+            background.dispose();
+            window.dispose();
+        });
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() {
+        Shape shape;
+        Area a = new Area(new Rectangle2D.Float(0, 0, 200, 200));
+        GeneralPath gp;
+        gp = new GeneralPath();
+        gp.moveTo(190, 0);
+        gp.lineTo(200, 0);
+        gp.lineTo(200, 10);
+        gp.lineTo(10, 200);
+        gp.lineTo(0, 200);
+        gp.lineTo(0, 190);
+        gp.closePath();
+        a.subtract(new Area(gp));
+        shape = a;
+
+        window.setShape(shape);
+    }
+
+    private void check(int xb, int yb, int xw, int yw) throws Exception {
+        checkClick(xb, yb, "backgroundWindowGotFocus");
+        checkClick(xw, yw, "foregroundWindowGotFocus");
+        checkClick(xb, yb, "foregroundWindowLostFocus");
+        checkClick(xw, yw, "backgroundWindowLostFocus");
+
+        if (window instanceof Dialog || window instanceof Frame) {
+            checkClick(xb, yb, "backgroundWindowActivated");
+            checkClick(xw, yw, "foregroundWindowActivated");
+            checkClick(xb, yb, "foregroundWindowDeactivated");
+            checkClick(xw, yw, "backgroundWindowDeactivated");
+        }
+
+    }
+
+    private void checkClick(int x, int y, String flag) throws Exception {
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " to trigger.");
+
+        flags.put(flag, false);
+
+        robot.mouseMove(x, y);
+        robot.click();
+        int i = 0;
+        while (i < 5000 && !flags.get(flag)) {
+            robot.waitForIdle(50);
+            i += 50;
+        }
+
+        if (!flags.get(flag))
+            throw new RuntimeException(flag + " is not triggered for click on point " + x + ", " + y + " for " + windowClass + "!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+
+/*
+ * @test
+ * @summary Check if dynamically shaped window is moved and resized
+ *          by robot correctly
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main Shaped
+ */
+public class Shaped extends Common{
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new Shaped(windowClass).doTest();
+            }
+    }
+
+    public Shaped(Class windowClass) throws Exception{
+        super(windowClass);
+    }
+    public void applyShape(){ applyDynamicShape(); }
+
+    public void doTest() throws Exception{
+        super.doTest();
+
+        checkDynamicShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+
+/*
+ * @test
+ * @summary Check if dynamically shaped window is moved and resized
+ *          using API correctly
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @run main ShapedByAPI
+ */
+public class ShapedByAPI extends Common {
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new ShapedByAPI(windowClass).doTest();
+            }
+    }
+
+    public ShapedByAPI(Class windowClass) throws Exception{
+        super(windowClass);
+    }
+    public void applyShape(){ applyDynamicShape(); }
+
+    public void doTest() throws Exception{
+        super.doTest();
+
+        checkDynamicShape();
+
+        EventQueue.invokeAndWait(() -> {
+            Point location = window.getLocationOnScreen();
+            location.translate(random.nextInt(dl), random.nextInt(dl));
+            window.setLocation(location);
+        });
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        EventQueue.invokeAndWait(() -> {
+            Dimension size = window.getSize();
+            window.setSize(size.width+random.nextInt(2*dl)-dl, size.height+random.nextInt(2*dl)-dl);
+        });
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if a translucent shaped window is dragged and
+ *          resized correctly.
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main ShapedTranslucent
+ */
+public class ShapedTranslucent extends Common {
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT) &&
+            checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new ShapedTranslucent(windowClass).doTest();
+            }
+    }
+
+    public ShapedTranslucent(Class windowClass) throws Exception{
+        super(windowClass, 0.3f);
+    }
+
+    public void applyShape(){ applyDynamicShape(); }
+
+    public void doTest() throws Exception{
+        super.doTest();
+
+        checkDynamicShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+
+/*
+ * @test
+ * @summary Check if statically shaped window is dragged and resized
+ *          correctly.
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main StaticallyShaped
+ */
+
+public class StaticallyShaped extends Common {
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new StaticallyShaped(windowClass).doTest();
+            }
+    }
+
+    public StaticallyShaped(Class windowClass) throws Exception{ super(windowClass); }
+    public void applyShape(){ applyStaticShape(); }
+
+    public void doTest() throws Exception{
+        super.doTest();
+
+        checkStaticShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkStaticShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkStaticShape();
+
+        dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java	Mon May 26 15:50:10 2014 +0400
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if translucent window is dragged and resized
+            correctly.
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main Translucent
+ */
+public class Translucent extends Common {
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT) &&
+            checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new Translucent(windowClass).doTest();
+            }
+    }
+
+    public Translucent(Class windowClass) throws Exception{
+        super(windowClass, 0.3f);
+    }
+
+    public void applyShape(){ }
+
+    public void doTest() throws Exception{
+        super.doTest();
+
+        checkTranslucentShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkTranslucentShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkTranslucentShape();
+
+        dispose();
+        robot.waitForIdle(delay);
+    }
+}
--- a/jdk/test/lib/testlibrary/ExtendedRobot.java	Mon May 26 14:33:49 2014 +0400
+++ b/jdk/test/lib/testlibrary/ExtendedRobot.java	Mon May 26 15:50:10 2014 +0400
@@ -25,7 +25,6 @@
 
 import sun.awt.ExtendedKeyCodes;
 import sun.awt.SunToolkit;
-import sun.security.action.GetIntegerAction;
 
 import java.awt.AWTException;
 import java.awt.Robot;
@@ -34,8 +33,6 @@
 import java.awt.Point;
 import java.awt.MouseInfo;
 import java.awt.event.InputEvent;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 /**
  * ExtendedRobot is a subclass of {@link java.awt.Robot}. It provides some convenience methods that are
@@ -312,6 +309,48 @@
         mouseMove(position.x, position.y);
     }
 
+
+    /**
+     * Emulate native drag and drop process using {@code InputEvent.BUTTON1_DOWN_MASK}.
+     * The method successively moves mouse cursor to point with coordinates
+     * ({@code fromX}, {@code fromY}), presses mouse button 1, drag mouse to
+     * point with coordinates ({@code toX}, {@code toY}) and releases mouse
+     * button 1 at last.
+     *
+     * @param   fromX   Source point x coordinate
+     * @param   fromY   Source point y coordinate
+     * @param   toX     Destination point x coordinate
+     * @param   toY     Destination point y coordinate
+     *
+     * @see     #mousePress(int)
+     * @see     #glide(int, int, int, int)
+     */
+    public void dragAndDrop(int fromX, int fromY, int toX, int toY){
+        mouseMove(fromX, fromY);
+        mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        waitForIdle();
+        glide(toX, toY);
+        mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        waitForIdle();
+    }
+
+    /**
+     * Emulate native drag and drop process using {@code InputEvent.BUTTON1_DOWN_MASK}.
+     * The method successively moves mouse cursor to point {@code from},
+     * presses mouse button 1, drag mouse to point {@code to} and releases
+     * mouse button 1 at last.
+     *
+     * @param   from    Source point
+     * @param   to      Destination point
+     *
+     * @see     #mousePress(int)
+     * @see     #glide(int, int, int, int)
+     * @see     #dragAndDrop(int, int, int, int)
+     */
+    public void dragAndDrop(Point from, Point to){
+        dragAndDrop(from.x, from.y, to.x, to.y);
+    }
+
     /**
      * Successively presses and releases a given key.
      * <p>