1 /* 2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 import com.sun.awt.AWTUtilities; 26 import java.awt.Frame; 27 import java.awt.Panel; 28 import java.awt.Point; 29 import java.awt.Rectangle; 30 import java.awt.Robot; 31 import java.awt.event.InputEvent; 32 import java.awt.event.MouseAdapter; 33 import java.awt.event.MouseEvent; 34 import javax.swing.JButton; 35 import javax.swing.SwingUtilities; 36 import test.java.awt.regtesthelpers.Util; 37 38 /** 39 * AWT/Swing overlapping test for opaque Swing components. 40 * <p>This test verify if AWT components are drawn correctly under opaque components. 41 * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6776743">JDK-6776743</a> for details 42 * <p>See base class for test info. 43 */ 44 /* 45 * @test 46 * @key headful 47 * @bug 6776743 48 * @summary Opaque overlapping test for each AWT component 49 * @library /java/awt/patchlib ../../regtesthelpers 50 * @modules java.desktop/com.sun.awt 51 * java.desktop/java.awt.peer 52 * java.desktop/sun.awt 53 * @build java.desktop/java.awt.Helper 54 * @build Util 55 * @run main OpaqueOverlapping 56 */ 57 public class OpaqueOverlapping extends OverlappingTestBase { 58 59 { 60 useClickValidation = false; 61 failMessage = "Opacity test mismatchs"; 62 63 // CR 6994264 (Choice autohides dropdown on Solaris 10) 64 skipClassNames = new String[] { "Choice" }; 65 } 66 private String testSeq; 67 private final static String checkSeq = "010000101"; 68 private Point heavyLoc; 69 private JButton light; 70 private Frame frame = null; 71 117 public void run() { 118 heavyLoc = currentAwtControl.getLocationOnScreen(); 119 } 120 }); 121 } catch (Exception e) { 122 } 123 Robot robot = Util.createRobot(); 124 robot.setAutoDelay(ROBOT_DELAY); 125 126 Util.waitForIdle(robot); 127 128 // Move the mouse pointer to the position where both 129 // components overlap 130 robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5); 131 132 // Now perform the click at this point for 9 times 133 // In the middle of the process toggle the opaque 134 // flag value. 135 for (int i = 0; i < 9; ++i) { 136 if (i == 3) { 137 AWTUtilities.setComponentMixingCutoutShape(light, 138 new Rectangle()); 139 } 140 if (i == 6) { 141 AWTUtilities.setComponentMixingCutoutShape(light, 142 null); 143 } 144 145 robot.mousePress(InputEvent.BUTTON1_MASK); 146 robot.mouseRelease(InputEvent.BUTTON1_MASK); 147 Util.waitForIdle(robot); 148 149 if (currentAwtControl.getClass() == java.awt.Choice.class && i != 1 && i != 6 && i != 8) { 150 // due to the fact that Choice doesn't get mouseClicked event if its dropdown is shown 151 robot.mousePress(InputEvent.BUTTON1_MASK); 152 robot.mouseRelease(InputEvent.BUTTON1_MASK); 153 Util.waitForIdle(robot); 154 } 155 } 156 157 Util.waitForIdle(robot); 158 159 boolean result = testSeq.equals(checkSeq); 160 if (!result) { 161 System.err.println("Expected: " + checkSeq); 162 System.err.println("Observed: " + testSeq); | 1 /* 2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 import java.awt.Frame; 26 import java.awt.Panel; 27 import java.awt.Point; 28 import java.awt.Rectangle; 29 import java.awt.Robot; 30 import java.awt.event.InputEvent; 31 import java.awt.event.MouseAdapter; 32 import java.awt.event.MouseEvent; 33 import javax.swing.JButton; 34 import javax.swing.SwingUtilities; 35 import test.java.awt.regtesthelpers.Util; 36 37 /** 38 * AWT/Swing overlapping test for opaque Swing components. 39 * <p>This test verify if AWT components are drawn correctly under opaque components. 40 * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6776743">JDK-6776743</a> for details 41 * <p>See base class for test info. 42 */ 43 /* 44 * @test 45 * @key headful 46 * @bug 6776743 8173409 47 * @summary Opaque overlapping test for each AWT component 48 * @library /java/awt/patchlib ../../regtesthelpers 49 * @modules java.desktop/java.awt.peer 50 * java.desktop/sun.awt 51 * @build java.desktop/java.awt.Helper 52 * @build Util 53 * @run main OpaqueOverlapping 54 */ 55 public class OpaqueOverlapping extends OverlappingTestBase { 56 57 { 58 useClickValidation = false; 59 failMessage = "Opacity test mismatchs"; 60 61 // CR 6994264 (Choice autohides dropdown on Solaris 10) 62 skipClassNames = new String[] { "Choice" }; 63 } 64 private String testSeq; 65 private final static String checkSeq = "010000101"; 66 private Point heavyLoc; 67 private JButton light; 68 private Frame frame = null; 69 115 public void run() { 116 heavyLoc = currentAwtControl.getLocationOnScreen(); 117 } 118 }); 119 } catch (Exception e) { 120 } 121 Robot robot = Util.createRobot(); 122 robot.setAutoDelay(ROBOT_DELAY); 123 124 Util.waitForIdle(robot); 125 126 // Move the mouse pointer to the position where both 127 // components overlap 128 robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5); 129 130 // Now perform the click at this point for 9 times 131 // In the middle of the process toggle the opaque 132 // flag value. 133 for (int i = 0; i < 9; ++i) { 134 if (i == 3) { 135 light.setMixingCutoutShape(new Rectangle()); 136 } 137 if (i == 6) { 138 light.setMixingCutoutShape(null); 139 } 140 141 robot.mousePress(InputEvent.BUTTON1_MASK); 142 robot.mouseRelease(InputEvent.BUTTON1_MASK); 143 Util.waitForIdle(robot); 144 145 if (currentAwtControl.getClass() == java.awt.Choice.class && i != 1 && i != 6 && i != 8) { 146 // due to the fact that Choice doesn't get mouseClicked event if its dropdown is shown 147 robot.mousePress(InputEvent.BUTTON1_MASK); 148 robot.mouseRelease(InputEvent.BUTTON1_MASK); 149 Util.waitForIdle(robot); 150 } 151 } 152 153 Util.waitForIdle(robot); 154 155 boolean result = testSeq.equals(checkSeq); 156 if (!result) { 157 System.err.println("Expected: " + checkSeq); 158 System.err.println("Observed: " + testSeq); |