8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
authoryan
Tue, 01 Jul 2014 12:49:36 +0400
changeset 25559 a101ec6ccfd3
parent 25558 6ecf203ea747
child 25560 8fdf0e62de64
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree Reviewed-by: pchelko Contributed-by: Dmitriy Ermashov <dmitriy.ermashov@oracle.com>
jdk/test/java/awt/Frame/DisposeParentGC/DisposeParentGC.java
jdk/test/java/awt/Frame/FramesGC/FramesGC.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShape.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShapeAndClick.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShapeDynamicallyAndClick.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/ShapedTranslucentWindowClick.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/TranslucentChoice.java
jdk/test/java/awt/Window/ShapedAndTranslucentWindows/TranslucentWindowClick.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/DisposeParentGC/DisposeParentGC.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,166 @@
+/*
+ * 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.image.BufferedImage;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.ArrayList;
+import java.util.Vector;
+
+/*
+ * @test
+ * @summary Display a dialog with a parent, the dialog contains all awt components
+ *          added to it & each components are setted with different cursors types.
+ *          Dispose the parent & collect GC. Garbage collection should happen
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main/othervm -Xmx20m DisposeParentGC
+ */
+
+public class DisposeParentGC {
+    Frame parentFrame;
+    ExtendedRobot robot;
+
+    ArrayList<PhantomReference<Dialog>> refs = new ArrayList<PhantomReference<Dialog>>();
+    ReferenceQueue<Dialog> que = new ReferenceQueue<>();
+
+    public static void main(String []args) throws Exception {
+        new DisposeParentGC().doTest();
+    }
+
+    DisposeParentGC() throws Exception {
+        robot = new ExtendedRobot();
+        EventQueue.invokeAndWait(this::initGui);
+    }
+
+    void initGui(){
+        parentFrame = new Frame("Parent Frame");
+        parentFrame.setLayout(new FlowLayout());
+
+        for (int i = 1; i <= 3; i++)
+            createDialog(i);
+
+        parentFrame.setLocation(250, 20);
+        parentFrame.pack();
+        parentFrame.setVisible(true);
+    }
+
+    public void doTest() throws Exception{
+        robot.waitForIdle();
+
+        parentFrame.dispose();
+        robot.waitForIdle();
+
+        Vector garbage = new Vector();
+        while (true) {
+            try {
+                garbage.add(new byte[1000]);
+            } catch (OutOfMemoryError er) {
+                break;
+            }
+        }
+        garbage = null;
+
+        int count = 1;
+        for (; count <= 3; count++)
+            if(que.remove(5000) == null)
+                break;
+
+        if (count < 3)
+            throw new RuntimeException("Count = "+count+". GC didn't collect the objects after the parent is disposed!");
+    }
+
+    public void createDialog(int number) {
+        Dialog child = new Dialog(parentFrame);
+        child.setTitle("Dialog " + number);
+        child.setLayout(new FlowLayout());
+        child.setLocation(20, 140 * number);
+
+        Button button = new Button("Press Me") ;
+        TextArea textArea = new TextArea(5,5);
+        TextField textField = new TextField(10);
+        Choice choice = new Choice();
+        choice.add("One");
+        choice.add("Two");
+        choice.add("Three");
+        choice.add("Four");
+        choice.add("Five");
+        List list = new List();
+        list.add("One");
+        list.add("Two");
+        list.add("Three");
+        list.add("Four");
+        list.add("Five");
+        Checkbox checkBox = new Checkbox("Hai");
+        Scrollbar scrollBar = new Scrollbar(Scrollbar.VERTICAL,0,1,0,200);
+        CheckboxGroup checkboxGroup = new CheckboxGroup();
+        Checkbox radioButton = new Checkbox("Hello" ,true, checkboxGroup);
+        Canvas canvas = new Canvas();
+        Label label = new Label("I am label!");
+        Cursor customCursor = null;
+
+        child.setLayout(new FlowLayout());
+        canvas.setSize(100,100);
+        canvas.setBackground(Color.red);
+
+        button.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
+        label.setCursor(new Cursor(Cursor.TEXT_CURSOR));
+        choice.setCursor(new Cursor(Cursor.WAIT_CURSOR));
+        list.setCursor(new Cursor(Cursor.HAND_CURSOR));
+        checkBox.setCursor(new Cursor(Cursor.MOVE_CURSOR));
+        radioButton.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
+        scrollBar.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
+        canvas.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
+        textField.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+
+        /* create a custom cursor */
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Dimension d = toolkit.getBestCursorSize(32,32);
+        int color = toolkit.getMaximumCursorColors();
+
+        if(!d.equals(new Dimension(0,0)) && color != 0 )
+            customCursor = toolkit.createCustomCursor(new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB ), new Point(10, 10), "custom cursor.");
+        else
+            System.err.println("Platform doesn't support to create a custom cursor.");
+
+        textArea.setCursor(customCursor);
+        child.add(label);
+        child.add(button);
+        child.add(choice);
+        child.add(list);
+        child.add(checkBox);
+        child.add(radioButton);
+        child.add(scrollBar);
+        child.add(canvas);
+        child.add(textArea);
+        child.add(textField);
+        child.add(button);
+        child.revalidate();
+
+        child.pack();
+        child.setVisible(true);
+        refs.add(new PhantomReference<Dialog>(child, que));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/FramesGC/FramesGC.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,159 @@
+/*
+ * 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.image.BufferedImage;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.ArrayList;
+import java.util.Vector;
+
+/*
+ * @test
+ * @summary Verify that disposed frames are collected with GC
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main/othervm -Xmx20m FramesGC
+ */
+
+
+public class FramesGC {
+
+    ExtendedRobot robot;
+    ArrayList<PhantomReference<Frame>> refs = new ArrayList<PhantomReference<Frame>>();
+    ReferenceQueue<Frame> que = new ReferenceQueue<Frame>();
+
+    public static void main(String []args) throws Exception {
+        new FramesGC().doTest();
+    }
+
+    FramesGC() throws Exception{
+        robot = new ExtendedRobot();
+    }
+
+    void doTest() throws Exception {
+        for( int i = 1; i <= 3; i++) {
+            final int j = i;
+            EventQueue.invokeAndWait(() -> {
+                createFrame(j);
+            });
+        }
+        robot.waitForIdle();
+
+        for (Frame f : Frame.getFrames())
+            f.dispose();
+
+        robot.waitForIdle();
+
+        Vector garbage = new Vector();
+        while (true) {
+            try {
+                garbage.add(new byte[1000]);
+            } catch (OutOfMemoryError er) {
+                break;
+            }
+        }
+        garbage = null;
+
+        int count = 1;
+        for(; count <= 3; count++)
+            if(que.remove(5000) == null)
+                break;
+
+        System.out.println("Total no of instances eligible for GC = " + count);
+        if(count < 3)
+            throw new RuntimeException("Count = "+count+". Test failed!");
+
+    }
+
+    void createFrame(int i){
+        Frame frame = new Frame("Frame " + i);
+
+        Button button=new Button("Press Me");
+        TextArea textArea=new TextArea(5,5);
+        TextField textField=new TextField(10);
+        Choice choice=new Choice();
+        choice.add("One");
+        choice.add("Two");
+        choice.add("Three");
+        choice.add("Four");
+        choice.add("Five");
+        List list = new List();
+        list.add("One");
+        list.add("Two");
+        list.add("Three");
+        list.add("Four");
+        list.add("Five");
+        Checkbox checkBox= new Checkbox("Hai");
+        Scrollbar scrollBar=new Scrollbar(Scrollbar.VERTICAL,0,1,0,200);
+        CheckboxGroup checkboxGroup=new CheckboxGroup();
+        Checkbox radioButton=new Checkbox("Hello" ,true, checkboxGroup);
+        Canvas canvas=new Canvas();
+        canvas.setSize(100, 100);
+        canvas.setBackground(java.awt.Color.red);
+        Label label=new Label("I am label.!");
+        Cursor customCursor=null;
+
+        frame.setLayout(new java.awt.FlowLayout());
+
+        button.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
+        label.setCursor(new Cursor(Cursor.TEXT_CURSOR));
+        choice.setCursor(new Cursor(Cursor.WAIT_CURSOR));
+        list.setCursor(new Cursor(Cursor.HAND_CURSOR));
+        checkBox.setCursor(new Cursor(Cursor.MOVE_CURSOR));
+        radioButton.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
+        scrollBar.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
+        canvas.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
+        textField.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+
+        /* create a custom cursor */
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Dimension d = toolkit.getBestCursorSize(32,32);
+        int color = toolkit.getMaximumCursorColors();
+
+        if(!d.equals(new Dimension(0,0)) && color != 0 )
+            customCursor = toolkit.createCustomCursor(new BufferedImage( 16, 16, BufferedImage.TYPE_INT_RGB ), new Point(10, 10), "custom cursor.");
+        else
+            System.err.println("Platform doesn't support to create a custom cursor.");
+
+        textArea.setCursor(customCursor);
+        frame.add(label);
+        frame.add(button);
+        frame.add(choice);
+        frame.add(list);
+        frame.add(checkBox);
+        frame.add(radioButton);
+        frame.add(scrollBar);
+        frame.add(canvas);
+        frame.add(textArea);
+        frame.add(textField);
+        frame.add(button);
+
+        frame.setLocation(20, 140 * i);
+        frame.pack();
+        frame.setVisible(true);
+        refs.add(new PhantomReference<Frame>(frame, que));
+    }
+
+}
\ No newline at end of file
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java	Tue Jul 01 12:49:36 2014 +0400
@@ -35,6 +35,19 @@
  * @bug 8013450
  * @summary Check if the window events (Focus and Activation) are triggered correctly
  *          when clicked on visible and clipped areas.
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported
+ *      by the current platform. Proceed if it is supported. Apply different
+ *      types of shapes on a Window. Make it appear with a known background.
+ *      Check if mouse events which result in window-activated events are
+ *      triggered only within the window's shape and not outside. Repeat this
+ *      for Window, Dialog and Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT Translucency type is supported, window should
+ *      gain focus and should trigger activated events only when it is clicked on the
+ *      visible areas. Events should be delivered to the background window if clicked
+ *      on the clipped areas.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @build Common ExtendedRobot
@@ -149,6 +162,7 @@
         window.setVisible(true);
     }
 
+    @Override
     public void doTest() throws Exception {
         super.doTest();
         final Point wls = new Point();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShape.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,250 @@
+/*
+ * 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.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.geom.*;
+
+/*
+ * @test
+ * @summary Check if a window set with shape appears in the expected shape
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported
+ *      by the current platform. Proceed if it is supported. Apply different
+ *      types of shapes on a Window. Make it appear with a known background. Use
+ *      get pixel color to check whether it appears as expected. Repeat this for
+ *      Window, Dialog and Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT Translucency type is supported, the
+ *      window should appear with the expected shape.
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main SetShape
+ */
+
+public class SetShape extends Common {
+
+    static int[][] pointsToCheck;
+    static Shape shape;
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) {
+            for (int i = 0; i < 6; i++) {
+                System.out.println("Checking shape "+i);
+                Area area;
+                GeneralPath path;
+                switch (i) {
+                    case 0:
+                        path = new GeneralPath();
+                        path.moveTo(0, 40);
+                        path.lineTo(40, 0);
+                        path.lineTo(110, 0);
+                        path.lineTo(150, 40);
+                        path.lineTo(150, 110);
+                        path.lineTo(110, 150);
+                        path.lineTo(40, 150);
+                        path.lineTo(0, 110);
+                        path.closePath();
+                        shape = path;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {230, 240}, {286, 332}, {314, 267}, {220, 327}, {223, 246},
+                                {229, 274}, {335, 257}, {231, 278}, {317, 299}, {266, 236},
+                                // outside shape
+                                {340, 353}, {373, 320}, {330, 220}, {384, 300}, {349, 406},
+                                {213, 355}, {361, 260}, {399, 251}, {201, 374}, {199, 257}
+                        };
+                        break;
+                    case 1:
+                        area = new Area();
+                        area.add(new Area(new Rectangle2D.Float(50, 0, 100, 150)));
+                        area.add(new Area(new Rectangle2D.Float(0, 50, 200, 50)));
+                        area.add(new Area(new Ellipse2D.Float(0, 0, 100, 100)));
+                        area.add(new Area(new Ellipse2D.Float(0, 50, 100, 100)));
+                        area.add(new Area(new Ellipse2D.Float(100, 0, 100, 100)));
+                        area.add(new Area(new Ellipse2D.Float(100, 50, 100, 100)));
+                        shape = area;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {306, 314}, {296, 266}, {276, 335}, {380, 253}, {224, 333},
+                                {396, 305}, {365, 278}, {214, 331}, {289, 349}, {367, 345},
+                                // outside shape
+                                {365, 424}, {391, 391}, {346, 413}, {261, 398}, {348, 399},
+                                {282, 400}, {386, 215}, {399, 369}, {213, 401}, {387, 215}
+                        };
+                        break;
+                    case 2:
+                        path = new GeneralPath();
+                        path.moveTo(100, 0);
+                        double angle = -Math.PI / 2;
+                        double angle_step = Math.PI * 2 / 8;
+                        for (int c = 0; c < 8; c++, angle += angle_step) {
+                            path.lineTo(100 + 100 * Math.cos(angle), 100 + 100 * Math.sin(angle));
+                            path.lineTo(100 + 40 * Math.cos(angle + angle_step / 2), 100 + 40 * Math.sin(angle + angle_step / 2));
+                        }
+                        path.closePath();
+                        shape = path;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {246, 257}, {300, 314}, {255, 347}, {291, 364}, {287, 320},
+                                {319, 276}, {269, 345}, {325, 291}, {289, 271}, {273, 339},
+                                // outside shape
+                                {373, 267}, {269, 229}, {390, 326}, {204, 216}, {379, 408},
+                                {375, 330}, {296, 213}, {367, 340}, {376, 409}, {378, 308}
+                        };
+                        break;
+                    case 3:
+                        area = new Area();
+                        area.add(new Area(new Rectangle2D.Float(-15, 85, 230, 30)));
+                        area.transform(AffineTransform.getRotateInstance(-Math.PI / 4, 100, 100));
+                        shape = area;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {240, 366}, {254, 338}, {342, 244}, {264, 344}, {343, 240},
+                                {292, 303}, {225, 374}, {263, 348}, {329, 290}, {278, 327},
+                                // outside shape
+                                {353, 289}, {334, 377}, {391, 354}, {266, 358}, {280, 364},
+                                {232, 225}, {327, 309}, {375, 208}, {397, 292}, {204, 335}
+                        };
+                        break;
+                    case 4:
+                        area = new Area();
+                        area.add(new Area(new Arc2D.Float(0, -100, 400, 400, 155, 50, Arc2D.PIE)));
+                        area.subtract(new Area(new Ellipse2D.Float(70, 115, 20, 20)));
+                        area.subtract(new Area(new Ellipse2D.Float(30, 90, 18, 18)));
+                        area.subtract(new Area(new Ellipse2D.Float(17, 50, 30, 30)));
+                        area.subtract(new Area(new Ellipse2D.Float(26, 124, 26, 26)));
+                        area.subtract(new Area(new Ellipse2D.Float(100, 85, 25, 25)));
+                        area.subtract(new Area(new Ellipse2D.Float(135, 100, 14, 14)));
+                        shape = area;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {225, 286}, {296, 276}, {318, 269}, {211, 357}, {295, 327},
+                                {207, 300}, {322, 265}, {319, 262}, {259, 294}, {261, 250},
+                                // outside shape
+                                {322, 303}, {330, 367}, {302, 395}, {227, 251}, {263, 382},
+                                {228, 383}, {280, 366}, {294, 248}, {316, 349}, {313, 294}
+                        };
+                        break;
+                    case 5:
+                        area = new Area();
+                        area.add(new Area(new Rectangle2D.Float(0, 0, 90, 90)));
+                        area.add(new Area(new Rectangle2D.Float(100, 0, 100, 200)));
+                        area.add(new Area(new Ellipse2D.Float(0, 100, 100, 100)));
+                        shape = area;
+                        pointsToCheck = new int[][]{
+                                // inside shape
+                                {275, 345}, {358, 327}, {373, 374}, {273, 331}, {251, 234},
+                                {285, 356}, {360, 287}, {319, 343}, {232, 210}, {323, 323},
+                                // outside shape
+                                {219, 291}, {270, 302}, {296, 383}, {298, 203}, {228, 293},
+                                {276, 300}, {292, 294}, {293, 216}, {298, 331}, {228, 295}
+                        };
+                        break;
+                    default:
+                        break;
+                }
+
+                for (Class<Window> windowClass : WINDOWS_TO_TEST) {
+                    new SetShape(windowClass).doTest();
+                }
+            }
+        }
+    }
+
+    public SetShape(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    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);
+        window.addComponentListener(new ComponentAdapter() {
+            @Override
+            public void componentResized(ComponentEvent e) {
+                window.setShape(shape);
+            }
+        });
+        window.setSize(200, 200);
+        window.setLocation(2*dl, 2*dl);
+        window.setVisible(true);
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+        robot.waitForIdle();
+
+        final int COUNT_TARGET = 10;
+        for(int i = 0; i < COUNT_TARGET * 2; i++) {
+            int x = pointsToCheck[i][0];
+            int y = pointsToCheck[i][1];
+            boolean inside = i < COUNT_TARGET;
+            Color c = robot.getPixelColor(x, y);
+            System.out.println("checking " + x + ", " + y + ", color = " + c);
+            boolean matchToForeground = FG_COLOR.equals(c);
+
+            if (!inside && matchToForeground || inside && !matchToForeground) {
+                System.err.println("Checking for transparency failed: point: " +
+                        x + ", " + y +
+                        ", color = " + c + (inside ? " is not of " : " is of un") +
+                        "expected foreground color " + FG_COLOR);
+                final Frame[] f = new Frame[1];
+                EventQueue.invokeAndWait(() -> {
+                    f[0] = new Frame();
+                    f[0].setUndecorated(true);
+                    f[0].setBackground(Color.YELLOW);
+                    f[0].setPreferredSize(new Dimension(2, 2));
+                    f[0].pack();
+                    f[0].setVisible(true);
+                });
+                robot.delay(1000);
+                EventQueue.invokeAndWait(() -> {
+                    f[0].setLocation(x, y);
+                });
+                robot.delay(1000);
+            }
+        }
+        EventQueue.invokeAndWait(window::dispose);
+        EventQueue.invokeAndWait(background::dispose);
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() { window.setShape(shape); }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShapeAndClick.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,216 @@
+/*
+ * 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.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+
+/*
+ * @test
+ * @summary Check if a window set with shape clips the contents
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported
+ *      by the current platform. Proceed if it is supported. Apply different types
+ *      of shapes on a Window which contains some awt components. Shape should be
+ *      applied in such a way that some components are partially clipped off. Check
+ *      if the components appear only partially and events work correctly for those
+ *      components - i.e. events occur only on the areas which appear and do not
+ *      occur on the clipped off areas. Events should be checked by clicking on the
+ *      visible and clipped regions. Repeat this for Window, Dialog and Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT Translucency type is supported, clicking
+ *      on clipped region should deliver the event to the background (it should be
+ *      another Window behind the test window)
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main SetShapeAndClick
+ */
+
+public class SetShapeAndClick extends Common {
+
+    Component south, center, north;
+    volatile int clicked;
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new SetShapeAndClick(windowClass).doTest();
+    }
+
+    public SetShapeAndClick(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        super.initBackgroundFrame();
+        background.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 0;
+            }
+        });
+    }
+
+    @Override
+    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.setLocation(2 * dl, 2 * dl);
+        window.setPreferredSize(new Dimension(200, 200));
+        window.setLayout(new BorderLayout());
+
+        window.addComponentListener(new ComponentAdapter() {
+            public void componentResized(ComponentEvent e) {
+                applyShape();
+            }
+        });
+
+        south = new Label("South");
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 3;
+            }
+        });
+        window.add(south, BorderLayout.SOUTH);
+
+        center = new List(5);
+        center.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 2;
+            }
+        });
+        window.add(center, BorderLayout.CENTER);
+
+        north = new TextField("North");
+        north.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 1;
+            }
+        });
+        window.add(north, BorderLayout.NORTH);
+
+        window.pack();
+        window.setVisible(true);
+        window.toFront();
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+
+        robot.waitForIdle();
+
+        Point wls = window.getLocationOnScreen();
+        Point ls;
+        int y;
+        ls = north.getLocationOnScreen();
+        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 1);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 2);
+
+        ls = south.getLocationOnScreen();
+        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 3);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 2);
+
+        ls = north.getLocationOnScreen();
+        y = ls.y + north.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = center.getLocationOnScreen();
+        y = ls.y + center.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = south.getLocationOnScreen();
+        y = ls.y + south.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::dispose);
+        EventQueue.invokeAndWait(background::dispose);
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() {
+        Area shape = 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();
+        shape.subtract(new Area(gp));
+
+        window.setShape(shape);
+    }
+
+    void checkClick(int x, int y, int flag) throws Exception {
+
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
+
+        clicked = 0;
+        robot.mouseMove(x, y);
+        robot.click();
+
+        for (int i = 0; i < 100; i++)
+            if ((clicked & (1 << flag)) == 0)
+                robot.delay(50);
+            else
+                break;
+
+        if ((clicked & (1 << flag)) == 0)
+            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShapeDynamicallyAndClick.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,214 @@
+/*
+ * 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.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+
+/*
+ * @test
+ * @summary Check if dynamically setting a shape works
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported
+ *      by the current platform. Proceed if it is supported. Show a window which
+ *      contains some components and apply a shape for the Window when the window
+ *      is visible. Shape should be applied in such a way that some components
+ *      are partially clipped off. Check if the components appear only partially
+ *      and events work correctly for those components - ie, events occur only on
+ *      the areas which appear and do not occur on the clipped off areas. Events
+ *      should be checked by clicking on the visible and clipped regions. Repeat
+ *      this for Window, Dialog and Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT translucency type is supported,
+ *      clicking on clipped region should deliver the event to the background (it
+ *      should be another Window behind the test window)
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main SetShapeDynamicallyAndClick
+ */
+
+public class SetShapeDynamicallyAndClick extends Common {
+
+    Component south, center, north;
+    volatile int clicked;
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new SetShapeDynamicallyAndClick(windowClass).doTest();
+    }
+
+    public SetShapeDynamicallyAndClick(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        super.initBackgroundFrame();
+        background.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 0;
+            }
+        });
+    }
+
+    @Override
+    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.setLocation(2 * dl, 2 * dl);
+        window.setPreferredSize(new Dimension(200, 200));
+        window.setLayout(new BorderLayout());
+
+        south = new Label("South");
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 3;
+            }
+        });
+        window.add(south, BorderLayout.SOUTH);
+
+        center = new List(5);
+        center.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 2;
+            }
+        });
+        window.add(center, BorderLayout.CENTER);
+
+        north = new TextField("North");
+        north.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 1;
+            }
+        });
+        window.add(north, BorderLayout.NORTH);
+
+        window.pack();
+        window.setVisible(true);
+        window.toFront();
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+
+        robot.waitForIdle();
+
+        Point wls = window.getLocationOnScreen();
+        Point ls;
+        int y;
+
+        EventQueue.invokeAndWait(this::applyShape);
+
+        robot.waitForIdle();
+
+        ls = north.getLocationOnScreen();
+        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 1);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 2);
+
+        ls = south.getLocationOnScreen();
+        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 3);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 2);
+
+        ls = north.getLocationOnScreen();
+        y = ls.y + north.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = center.getLocationOnScreen();
+        y = ls.y + center.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = south.getLocationOnScreen();
+        y = ls.y + south.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::dispose);
+        EventQueue.invokeAndWait(background::dispose);
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() {
+        Area shape = 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();
+        shape.subtract(new Area(gp));
+
+        window.setShape(shape);
+    }
+
+    void checkClick(int x, int y, int flag) throws Exception {
+
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
+
+        clicked = 0;
+        robot.mouseMove(x, y);
+        robot.click();
+
+        for (int i = 0; i < 100; i++)
+            if ((clicked & (1 << flag)) == 0)
+                robot.delay(50);
+            else
+                break;
+
+        if ((clicked & (1 << flag)) == 0)
+            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
+    }
+}
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java	Tue Jul 01 12:49:36 2014 +0400
@@ -26,8 +26,22 @@
 
 /*
  * @test
- * @summary Check if dynamically shaped window is moved and resized
- *          by robot correctly
+ * @summary Check if dynamically shaped window is dragged and resized
+ *          by mouse correctly
+ *
+ * Test Description: Check if specified translucency types PERPIXEL_TRANSPARENT
+ *      is supported on the current platform. Proceed if it is supported.
+ *      Create a window apply shape in componentResized listener. The shape
+ *      should match the window size. Drag and resize the window using AWT Robot
+ *      and verify that shape is correctly applied both with pixels checking and
+ *      clicks. Make the window appear on top of a known background. Repeat this
+ *      for Window, Dialog, Frame,
+ * Expected Result: If PERPIXEL_TRANSPARENT translucency type is supported,
+ *      the window should appear with the expected shape. Clicks should come
+ *      to visible parts of shaped window only and to background for clipped
+ *      parts.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @build Common ExtendedRobot
@@ -45,8 +59,11 @@
     public Shaped(Class windowClass) throws Exception{
         super(windowClass);
     }
+
+    @Override
     public void applyShape(){ applyDynamicShape(); }
 
+    @Override
     public void doTest() throws Exception{
         super.doTest();
 
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java	Tue Jul 01 12:49:36 2014 +0400
@@ -26,8 +26,21 @@
 
 /*
  * @test
- * @summary Check if dynamically shaped window is moved and resized
- *          using API correctly
+ * @summary Check if dynamically shaped window is moved and resized by
+ *          API correctly.
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT translucency type is
+ *      supported on the current platform. Proceed if it is supported. Create
+ *      a window and apply shape in componentResized listener. The shape should
+ *      match the window size. Drag and resize the window using API and verify
+ *      that shape is correctly applied both with pixels checking and clicks.
+ *      Make the window appear on top of a known background. Repeat this for
+ *      Window, Dialog, Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT translucency type is supported, the
+ *      window should appear with the expected shape. Clicks should come to visible
+ *      parts of shaped window only and to background for clipped parts.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @run main ShapedByAPI
@@ -44,8 +57,11 @@
     public ShapedByAPI(Class windowClass) throws Exception{
         super(windowClass);
     }
+
+    @Override
     public void applyShape(){ applyDynamicShape(); }
 
+    @Override
     public void doTest() throws Exception{
         super.doTest();
 
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java	Tue Jul 01 12:49:36 2014 +0400
@@ -27,6 +27,20 @@
  * @test
  * @summary Check if a translucent shaped window is dragged and
  *          resized correctly.
+ *
+ * Test Description: Check if TRANSLUCENT and PERPIXEL_TRANSPARENT translucency
+ *      types are supported on the current platform. Proceed if it is supported.
+ *      Create and apply opacity of 0.3 and apply shape in componentResized
+ *      listener. Drag and resize the window using AWT Robot and verify that
+ *      shape and translucency are correctly applied both with pixels checking
+ *      and clicks. Make the window appear on top of a known background. Repeat
+ *      this for Window, Dialog, Frame.
+ * Expected Result: If TRANSLUCENT and PERPIXEL_TRANSPARENT translucency types are
+ *      supported, the window should appear with the expected shape and translucency.
+ *      Clicks should come to visible parts of shaped window only and to background
+ *      for clipped parts.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @build Common ExtendedRobot
@@ -46,8 +60,10 @@
         super(windowClass, 0.3f);
     }
 
+    @Override
     public void applyShape(){ applyDynamicShape(); }
 
+    @Override
     public void doTest() throws Exception{
         super.doTest();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucentWindowClick.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,210 @@
+/*
+ * 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.*;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+import java.util.BitSet;
+
+/*
+ * @test
+ * @summary Check if a translucent shaped window trigger events correctly.
+ *
+ * Test Description: Check if TRANSLUCENT and PERPIXEL_TRANSPARENT traslucency
+ *      types are supported on the current platform. Proceed if both are
+ *      supported. Create a window with some components in it and a shape
+ *      applied. Apply the shape such that some components are partially
+ *      clipped. Set an opacity value less than 1. Check if the components
+ *      behave correctly on mouse and key events. Do this test for awt Window.
+ * Expected Result: Mouse and key events must work correctly. Only that portion
+ *      of a component within the shape should trigger events. Key events
+ *      should be tested for focus events and TextField/TextArea.
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main ShapedTranslucentWindowClick
+ */
+
+public class ShapedTranslucentWindowClick extends Common {
+
+    Component south, center, north;
+
+    volatile BitSet backgroundFlags = new BitSet(11);
+    volatile BitSet southFlags = new BitSet(11);
+    volatile BitSet centerFlags = new BitSet(11);
+    volatile BitSet northFlags = new BitSet(11);
+    static BitSet reference = BitSet.valueOf(new long[] {2047}); // 111 1111 1111
+
+    public static void main(String[] ignored) throws Exception{
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT) &&
+                checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            new ShapedTranslucentWindowClick(Window.class).doTest();
+    }
+
+    public ShapedTranslucentWindowClick(Class windowClass) throws Exception {
+        super(windowClass);
+        addListeners(south, southFlags);
+        addListeners(center, centerFlags);
+        addListeners(north, northFlags);
+        addListeners(background, backgroundFlags);
+    }
+
+    @Override
+    public void initGUI() {
+
+        window = new Window(background);
+        south = new Button("South Button");
+        center = new TextArea("Center Text Area");
+        north = new TextField("North Text Field");
+
+        window.setLocation(250, 250);
+        window.setPreferredSize(new Dimension(200, 200));
+        window.setOpacity(0.7f);
+        applyShape();
+        window.setLayout(new BorderLayout());
+
+        window.add(south, BorderLayout.SOUTH);
+        window.add(center, BorderLayout.CENTER);
+        window.add(north, BorderLayout.NORTH);
+
+        window.pack();
+        window.setVisible(true);
+        window.toFront();
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+
+        robot.waitForIdle();
+        robot.mouseMove(background.getLocationOnScreen().x+50, background.getLocationOnScreen().y+50);
+        robot.waitForIdle();
+        robot.click();
+
+        Point wls = window.getLocationOnScreen();
+        Point ls;
+        int y;
+
+        robot.waitForIdle();
+
+        ls = north.getLocationOnScreen();
+        checkClickAndType(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, northFlags);
+
+        ls = center.getLocationOnScreen();
+        checkClickAndType(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, centerFlags);
+
+        ls = center.getLocationOnScreen();
+        checkClickAndType(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, centerFlags);
+
+        ls = south.getLocationOnScreen();
+        checkClickAndType(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, southFlags);
+
+        ls = north.getLocationOnScreen();
+        y = ls.y + north.getHeight() / 2;
+        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = center.getLocationOnScreen();
+        y = ls.y + center.getHeight() / 2;
+        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = south.getLocationOnScreen();
+        y = ls.y + south.getHeight() / 2;
+        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
+
+        EventQueue.invokeAndWait(window::dispose);
+        EventQueue.invokeAndWait(background::dispose);
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() {
+        Area shape = 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();
+        shape.subtract(new Area(gp));
+
+        window.setShape(shape);
+    }
+
+    void checkClickAndType(int x, int y, BitSet bits){
+        bits.clear(0, 10);
+
+        robot.mouseMove(x, y);
+        robot.click();
+        robot.dragAndDrop(MouseInfo.getPointerInfo().getLocation(), new Point(x+5, y));
+        robot.mouseWheel(1);
+        robot.waitForIdle();
+
+        robot.type('a');
+
+        robot.mouseMove(350, 50);
+        robot.waitForIdle();
+
+        //robot.delay(20*1000);
+        if (!bits.equals(reference)){
+            for( int i = 0; i < 11; i++)
+                System.err.print(( bits.get(i) ? 1 : 0 ) + ", ");
+            System.err.println();
+            throw new RuntimeException("Bit mask is not fully set: "+bits);
+        }
+    }
+
+    static void addListeners(Component component, BitSet bits) {
+        component.addMouseListener(new MouseListener() {
+            public void mouseClicked(MouseEvent e) { bits.set(0);}
+            public void mousePressed(MouseEvent e) { bits.set(1); }
+            public void mouseReleased(MouseEvent e) { bits.set(2); }
+            public void mouseEntered(MouseEvent e) { bits.set(3); }
+            public void mouseExited(MouseEvent e) { bits.set(4); }
+        });
+        component.addMouseMotionListener(new MouseMotionListener() {
+            public void mouseDragged(MouseEvent e) { bits.set(5); }
+            public void mouseMoved(MouseEvent e) { bits.set(6); }
+        });
+        component.addMouseWheelListener((e) -> bits.set(7));
+        component.addKeyListener(new KeyListener() {
+            public void keyTyped(KeyEvent e) { bits.set(8); }
+            public void keyPressed(KeyEvent e) { bits.set(9); }
+            public void keyReleased(KeyEvent e) { bits.set(10); }
+        });
+    };
+}
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java	Tue Jul 01 12:49:36 2014 +0400
@@ -26,8 +26,21 @@
 
 /*
  * @test
- * @summary Check if statically shaped window is dragged and resized
- *          correctly.
+ * @summary Check if statically shaped window is dragged and resized correctly.
+ *
+ * Test Description: Check if PERPIXEL_TRANSPARENT translucency type is supported
+ *      on the current platform. Proceed if it is supported. Create a window
+ *      and apply some shape at window creation. The shape should be bigger than
+ *      window. Drag and resize the window using AWT Robot and verify that shape
+ *      is correctly applied both with pixels checking and clicks. Make the
+ *      window appear on top of a known background. Repeat this for Window, Dialog,
+ *      Frame.
+ * Expected Result: If specified translucency type PERPIXEL_TRANSPARENT is supported,
+ *      the window should appear with the expected shape clipped to the window
+ *      size. Clicks should come to visible parts of shaped window only and to
+ *      background for clipped parts.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @build Common ExtendedRobot
@@ -44,8 +57,11 @@
     }
 
     public StaticallyShaped(Class windowClass) throws Exception{ super(windowClass); }
+
+    @Override
     public void applyShape(){ applyStaticShape(); }
 
+    @Override
     public void doTest() throws Exception{
         super.doTest();
 
--- a/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java	Mon Jun 30 16:23:18 2014 +0400
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java	Tue Jul 01 12:49:36 2014 +0400
@@ -26,7 +26,19 @@
 /*
  * @test
  * @summary Check if translucent window is dragged and resized
-            correctly.
+ *          correctly.
+ *
+ * Test Description: Check if TRANSLUCENT translucency type is supported
+ *      on the current platform. Proceed if they are supported. Create
+ *      a window and apply opacity of 0.3. Drag and resize the window
+ *      using AWT Robot and verify that translucency is not affected.
+ *      Make the window appear on top of a known background. Repeat this
+ *      for Window, Dialog, Frame.
+ * Expected Result: If TRANSLUCENT translucency type is supported, the
+ *      window should show the background. Dragging and resizing
+ *      shouldn't affect the translucency.
+ *
+ * @author mrkam
  * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
  * @library ../../../../lib/testlibrary
  * @build Common ExtendedRobot
@@ -35,8 +47,7 @@
 public class Translucent extends Common {
 
     public static void main(String[] args) throws Exception {
-        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT) &&
-            checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
             for (Class<Window> windowClass: WINDOWS_TO_TEST){
                 new Translucent(windowClass).doTest();
             }
@@ -46,8 +57,10 @@
         super(windowClass, 0.3f);
     }
 
+    @Override
     public void applyShape(){ }
 
+    @Override
     public void doTest() throws Exception{
         super.doTest();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/TranslucentChoice.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,186 @@
+/*
+ * 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.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/*
+ * @test
+ * @summary Check if a Choice present in a window set with opacity less than 1.0
+ *          shows a translucent drop down
+ *
+ * Test Description: Check if TRANSLUCENT Translucency type is supported on the
+ *      current platform. Proceed if supported. Show a window which contains an
+ *      awt Choice and set with opacity less than 1.0. Another Window having a
+ *      canvas component drawn with an image can be used as the background for
+ *      the test window. Click on the ComboBox to show the drop down. Check if
+ *      the drop down appears translucent. Repeat this for Window, Dialog and
+ *      Frame.
+ * Expected Result: If TRANSLUCENT Translucency type is supported, the drop down
+ *      should appear translucent.
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main TranslucentChoice
+ */
+
+public class TranslucentChoice extends Common {
+
+    Choice south;
+    Component center;
+    Component north;
+    volatile int clicked;
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST){
+                new TranslucentChoice(windowClass).doTest();
+            }
+    }
+
+    public TranslucentChoice(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        super.initBackgroundFrame();
+        background.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 0;
+            }
+        });
+    }
+
+    @Override
+    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);
+        north = new Button("north");
+        window.add(north, BorderLayout.NORTH);
+
+        center = new List(5);
+        window.add(center, BorderLayout.CENTER);
+
+        Choice choice = new Choice();
+        for(int i = 0; i < 20; i++) {
+            choice.add("item " + i);
+        }
+        south = choice;
+
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 1;
+            }
+        });
+
+        window.add(south, BorderLayout.SOUTH);
+        window.setAlwaysOnTop(true);
+        window.setOpacity(0.3f);
+        window.setLocation(2 * dl, 2 * dl);
+        window.setSize(255, 255);
+        window.pack();
+        window.setVisible(true);
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+
+        Point ls = window.getLocationOnScreen();
+        clicked = 0;
+        checkClick(ls.x + window.getWidth() / 2, ls.y - 5, 0);
+
+        robot.waitForIdle(2000);
+
+        ls = south.getLocationOnScreen();
+
+        Point p1 = new Point((int) (ls.x + south.getWidth() * 0.75), ls.y + south.getHeight() * 3);
+        Point p2 = new Point((int) (ls.x + south.getWidth() * 0.75), ls.y - south.getHeight() * 2);
+        Color c1 = robot.getPixelColor(p1.x, p1.y);
+        Color c2 = robot.getPixelColor(p2.x, p2.y);
+
+        checkClick(ls.x + south.getWidth() / 2, ls.y + south.getHeight() / 2, 1);
+
+        robot.waitForIdle(2000);
+
+        Color c1b = robot.getPixelColor(p1.x, p1.y);
+        Color c2b = robot.getPixelColor(p2.x, p2.y);
+
+        if (!aproximatelyEquals(c1, c1b) && !aproximatelyEquals(south.getBackground(), c1b))
+            throw new RuntimeException("Check for opaque drop down failed. Before click: " + c1 + ", after click: " + c1b + ", expected is " + south.getBackground());
+
+        if (!aproximatelyEquals(c2,c2b) && !aproximatelyEquals(south.getBackground(), c2b))
+            throw new RuntimeException("Check for opaque drop down failed. Before click: " + c2 + ", after click: " + c2b + ", expected is " + south.getBackground());
+
+        EventQueue.invokeAndWait(() -> {
+            background.dispose();
+            window.dispose();
+        });
+
+        robot.waitForIdle();
+    }
+
+    boolean aproximatelyEquals(Color c1, Color c2) {
+        return ((Math.abs(c1.getRed()-c2.getRed())/256.0 +
+                Math.abs(c1.getGreen()-c2.getGreen())/256.0 +
+                Math.abs(c1.getBlue()-c2.getBlue())/256.0)) / 3 < 0.02;
+    }
+
+    @Override
+    public void applyShape() { }
+
+
+    void checkClick(int x, int y, int flag) throws Exception {
+
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
+
+        clicked = 0;
+        robot.mouseMove(x, y);
+        robot.click();
+
+        for (int i = 0; i < 100; i++)
+            if ((clicked & (1 << flag)) == 0)
+                robot.delay(50);
+            else
+                break;
+
+        if ((clicked & (1 << flag)) == 0)
+            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/ShapedAndTranslucentWindows/TranslucentWindowClick.java	Tue Jul 01 12:49:36 2014 +0400
@@ -0,0 +1,152 @@
+/*
+ * 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.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/*
+ * @test
+ * @summary Check if components present in a window set with opacity less than 1.0
+ *          triggers events correctly
+ *
+ * Test Description: Check if TRANSLUCENT Translucency type is supported on the
+ *      current platform. Proceed if supported. Show a window which contains some
+ *      components and set with opacity less than 1.0. Another Window having a
+ *      canvas component drawn with an image can be used as the background for the
+ *      test window. Click on the components present in the window and check if
+ *      events trigger correctly.
+ * Expected Result: The components should trigger events correctly
+ *
+ * @author mrkam
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main TranslucentWindowClick
+ */
+public class TranslucentWindowClick extends Common {
+
+    private Component south;
+    private Component center;
+    private Component north;
+
+    volatile int clicked;
+
+    public static void main(String[] args) throws Exception{
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            new TranslucentWindowClick(Window.class).doTest();
+    }
+
+    public TranslucentWindowClick(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    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.setPreferredSize(new Dimension(200, 200));
+        window.setLocation(2 * dl, 2 * dl);
+        window.setLayout(new BorderLayout());
+        window.setBackground(FG_COLOR);
+
+        south = new Button("South");
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 2; }
+        });
+        window.add(south, BorderLayout.SOUTH);
+
+        center = new List(5);
+        center.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 1; }
+        });
+        window.add(center, BorderLayout.CENTER);
+
+        north = new TextField("North");
+        north.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 0; }
+        });
+        window.add(north, BorderLayout.NORTH);
+        window.setOpacity(0.2f);
+        window.pack();
+        window.setVisible(true);
+
+        System.out.println("Checking " + window.getClass().getName() + "...");
+    }
+
+    @Override
+    public void doTest() throws Exception {
+        Point ls;
+        robot.waitForIdle();
+
+        ls = north.getLocationOnScreen();
+        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 0);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 1);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 1);
+
+        ls = south.getLocationOnScreen();
+        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 2);
+
+        EventQueue.invokeAndWait(() -> {
+            background.dispose();
+            window.dispose();
+        });
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() { }
+
+    void checkClick(int x, int y, int flag) throws Exception {
+
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
+
+        clicked = 0;
+        robot.mouseMove(x, y);
+        robot.click();
+
+        for (int i = 0; i < 100; i++)
+            if ((clicked & (1 << flag)) == 0)
+                robot.delay(50);
+            else
+                break;
+
+        if ((clicked & (1 << flag)) == 0)
+            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
+    }
+}