Mercurial > hg > icedtea9-forest > jdk
changeset 5833:1579507a736f
Merge
author | lana |
---|---|
date | Fri, 27 Jul 2012 22:39:44 -0700 |
parents | 80b1ecc79852 (diff) e4bae5c53fca (current diff) |
children | 1abb270d9038 |
files | src/share/classes/sun/security/krb5/ServiceName.java test/sun/security/krb5/ServiceNameClone.java test/sun/security/mscapi/ShortRSAKey512.sh test/sun/security/mscapi/ShortRSAKey768.sh |
diffstat | 19 files changed, 429 insertions(+), 269 deletions(-) [+] |
line wrap: on
line diff
--- a/make/Makefile Thu Jul 26 16:48:33 2012 -0700 +++ b/make/Makefile Fri Jul 27 22:39:44 2012 -0700 @@ -237,7 +237,7 @@ SUBDIRS += apple endif SUBDIRS_tools = launchers -SUBDIRS_misc = org sunw jpda +SUBDIRS_misc = org jpda # demos ifndef NO_DEMOS
--- a/make/common/Release.gmk Thu Jul 26 16:48:33 2012 -0700 +++ b/make/common/Release.gmk Fri Jul 27 22:39:44 2012 -0700 @@ -305,8 +305,7 @@ org/ietf \ org/omg \ org/w3c/dom \ - org/xml/sax \ - sunw + org/xml/sax # # Directories where sources may be found. If a file with the same path # name exists in more than one of these places, the one found last on this
--- a/make/docs/CORE_PKGS.gmk Thu Jul 26 16:48:33 2012 -0700 +++ b/make/docs/CORE_PKGS.gmk Fri Jul 27 22:39:44 2012 -0700 @@ -33,7 +33,6 @@ java.awt.peer \ java.awt.dnd.peer \ sun.* \ - sunw.* \ com.sun.* \ org.apache.* \ org.jcp.* \
--- a/make/sunw/Makefile Thu Jul 26 16:48:33 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -# -# Copyright (c) 1996, 2005, 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. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# 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. -# - -BUILDDIR = .. -PACKAGE = sunw -PRODUCT = sun -include $(BUILDDIR)/common/Defs.gmk - -# -# Files -# -FILES_java = \ - sunw/util/EventObject.java \ - sunw/util/EventListener.java \ - sunw/io/Serializable.java - -# -# include rules -# -include $(BUILDDIR)/common/Rules.gmk - -# -# Rules -# -clean clobber:: .delete.classlist - $(RM) -r $(CLASSBINDIR)/sunw -
--- a/makefiles/CreateJars.gmk Thu Jul 26 16:48:33 2012 -0700 +++ b/makefiles/CreateJars.gmk Fri Jul 27 22:39:44 2012 -0700 @@ -807,8 +807,7 @@ org/ietf \ org/omg \ org/w3c/dom \ - org/xml/sax \ - sunw + org/xml/sax SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc
--- a/makefiles/docs/CORE_PKGS.gmk Thu Jul 26 16:48:33 2012 -0700 +++ b/makefiles/docs/CORE_PKGS.gmk Fri Jul 27 22:39:44 2012 -0700 @@ -33,7 +33,6 @@ java.awt.peer \ java.awt.dnd.peer \ sun.* \ - sunw.* \ com.sun.* \ org.apache.* \ org.jcp.* \
--- a/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Thu Jul 26 16:48:33 2012 -0700 +++ b/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Fri Jul 27 22:39:44 2012 -0700 @@ -259,7 +259,8 @@ protected void installKeyboardActions() { super.installKeyboardActions(); - final ActionMap actionMap = comboBox.getActionMap(); + ActionMap actionMap = new ActionMapUIResource(); + actionMap.put("aquaSelectNext", highlightNextAction); actionMap.put("aquaSelectPrevious", highlightPreviousAction); actionMap.put("aquaEnterPressed", triggerSelectionAction); @@ -269,6 +270,8 @@ actionMap.put("aquaSelectEnd", highlightLastAction); actionMap.put("aquaSelectPageUp", highlightPageUpAction); actionMap.put("aquaSelectPageDown", highlightPageDownAction); + + SwingUtilities.replaceUIActionMap(comboBox, actionMap); } abstract class ComboBoxAction extends AbstractAction {
--- a/src/share/classes/java/awt/GraphicsEnvironment.java Thu Jul 26 16:48:33 2012 -0700 +++ b/src/share/classes/java/awt/GraphicsEnvironment.java Fri Jul 27 22:39:44 2012 -0700 @@ -170,12 +170,12 @@ if (System.getProperty("javaplugin.version") != null) { headless = defaultHeadless = Boolean.FALSE; } else { - if ("sun.awt.HeadlessGraphicsEnvironment".equals( - System.getProperty("java.awt.graphicsenv"))) + String osName = System.getProperty("os.name"); + if (osName.contains("OS X") && "sun.awt.HToolkit".equals( + System.getProperty("awt.toolkit"))) { headless = defaultHeadless = Boolean.TRUE; } else { - String osName = System.getProperty("os.name"); headless = defaultHeadless = Boolean.valueOf(("Linux".equals(osName) || "SunOS".equals(osName) ||
--- a/src/share/classes/javax/swing/TimerQueue.java Thu Jul 26 16:48:33 2012 -0700 +++ b/src/share/classes/javax/swing/TimerQueue.java Fri Jul 27 22:39:44 2012 -0700 @@ -187,6 +187,9 @@ addTimer(delayedTimer); } } + + // Allow run other threads on systems without kernel threads + timer.getLock().newCondition().awaitNanos(1); } catch (SecurityException ignore) { } finally { timer.getLock().unlock();
--- a/src/share/classes/sun/misc/MetaIndex.java Thu Jul 26 16:48:33 2012 -0700 +++ b/src/share/classes/sun/misc/MetaIndex.java Fri Jul 27 22:39:44 2012 -0700 @@ -71,7 +71,6 @@ org/w3c/ com/sun/imageio/ javax/ -sunw/util/ java/ sun/ ...
--- a/src/share/classes/sunw/io/Serializable.java Thu Jul 26 16:48:33 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996, 1997, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sunw.io; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - * <p> - * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - * <p> - * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - * <p> - * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the appropriate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.io.Serializable - * - * @see java.io.Serializable - */ - -public interface Serializable extends java.io.Serializable { -}
--- a/src/share/classes/sunw/util/EventListener.java Thu Jul 26 16:48:33 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sunw.util; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - * <p> - * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - * <p> - * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - * <p> - * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the approrpiate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.util.EventListener - * - * @see java.util.EventListener - */ - -public interface EventListener extends java.util.EventListener { -}
--- a/src/share/classes/sunw/util/EventObject.java Thu Jul 26 16:48:33 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 1996, 2003, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sunw.util; - -/** - * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. - * <p> - * This is a backwards compatibility class to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1 - * <p> - * To allow beans development under JDK 1.0.2, JavaSoft delivered three - * no-op interfaces/classes (sunw.io.Serializable, sunw.util.EventObject - * and sunw.util.EventListener) that could be downloaded into JDK 1.0.2 - * systems and which would act as placeholders for the real JDK 1.1 - * classes. - * <p> - * Now under JDK 1.1 we provide versions of these classes and interfaces - * that inherit from the real version in java.util and java.io. These - * mean that beans developed under JDK 1.0.2 against the sunw.* classes - * will now continue to work on JDK 1.1 and will (indirectly) inherit - * from the approrpiate java.* interfaces/classes. - * - * @deprecated This is a compatibility type to allow Java Beans that - * were developed under JDK 1.0.2 to run correctly under JDK 1.1. The - * corresponding JDK1.1 type is java.util.EventObject - * - * @see java.util.EventObject - */ - -public class EventObject extends java.util.EventObject { - - private static final long serialVersionUID = 6723767567830330255L; - - public EventObject(Object source) { - super(source); - } - -}
--- a/src/solaris/native/java/lang/java_props_md.c Thu Jul 26 16:48:33 2012 -0700 +++ b/src/solaris/native/java/lang/java_props_md.c Fri Jul 27 22:39:44 2012 -0700 @@ -398,6 +398,7 @@ PreferredToolkit prefToolkit = getPreferredToolkit(); switch (prefToolkit) { case CToolkit: + case HToolkit: sprops.graphics_env = "sun.awt.CGraphicsEnvironment"; break; case XToolkit: @@ -405,9 +406,6 @@ sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; #ifdef MACOSX break; - default: - sprops.graphics_env = "sun.java2d.HeadlessGraphicsEnvironment"; - break; } #endif /* AWT properties */
--- a/src/windows/native/sun/windows/awt_TextArea.cpp Thu Jul 26 16:48:33 2012 -0700 +++ b/src/windows/native/sun/windows/awt_TextArea.cpp Fri Jul 27 22:39:44 2012 -0700 @@ -131,48 +131,13 @@ MsgRouting mr = mrDoDefault; switch (message) { - case WM_PRINTCLIENT: - { - FORMATRANGE fr; - HDC hPrinterDC = (HDC)wParam; - int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); - int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); - int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); - int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); - - // Ensure the printer DC is in MM_TEXT mode. - ::SetMapMode ( hPrinterDC, MM_TEXT ); - - // Rendering to the same DC we are measuring. - ::ZeroMemory(&fr, sizeof(fr)); - fr.hdc = fr.hdcTarget = hPrinterDC; - // Set up the page. - fr.rcPage.left = fr.rcPage.top = 0; - fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips - fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; - fr.rc.left = fr.rcPage.left; - fr.rc.top = fr.rcPage.top; - fr.rc.right = fr.rcPage.right; - fr.rc.bottom = fr.rcPage.bottom; - - // start printing from the first visible line - LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); - LONG startCh = static_cast<LONG>(SendMessage(EM_LINEINDEX, - (WPARAM)nLine, 0)); - fr.chrg.cpMin = startCh; - fr.chrg.cpMax = -1; - - SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); - } - - break; case EM_SETCHARFORMAT: case WM_SETFONT: SetIgnoreEnChange(TRUE); break; } - retValue = AwtComponent::WindowProc(message, wParam, lParam); + retValue = AwtTextComponent::WindowProc(message, wParam, lParam); switch (message) { case EM_SETCHARFORMAT:
--- a/src/windows/native/sun/windows/awt_TextComponent.cpp Thu Jul 26 16:48:33 2012 -0700 +++ b/src/windows/native/sun/windows/awt_TextComponent.cpp Fri Jul 27 22:39:44 2012 -0700 @@ -215,6 +215,50 @@ return c; } +LRESULT +AwtTextComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { + + switch (message) { + case WM_PRINTCLIENT: + { + FORMATRANGE fr; + HDC hPrinterDC = (HDC)wParam; + int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); + int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); + int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); + int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); + + // Ensure the printer DC is in MM_TEXT mode. + ::SetMapMode ( hPrinterDC, MM_TEXT ); + + // Rendering to the same DC we are measuring. + ::ZeroMemory(&fr, sizeof(fr)); + fr.hdc = fr.hdcTarget = hPrinterDC; + // Set up the page. + fr.rcPage.left = fr.rcPage.top = 0; + fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips + fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; + fr.rc.left = fr.rcPage.left; + fr.rc.top = fr.rcPage.top; + fr.rc.right = fr.rcPage.right; + fr.rc.bottom = fr.rcPage.bottom; + + // start printing from the first visible line + LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); + LONG startCh = static_cast<LONG>(SendMessage(EM_LINEINDEX, + (WPARAM)nLine, 0)); + fr.chrg.cpMin = startCh; + fr.chrg.cpMax = -1; + + SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); + } + + break; + } + + return AwtComponent::WindowProc(message, wParam, lParam); +} + LONG AwtTextComponent::EditGetCharFromPos(POINT& pt) { return static_cast<LONG>(SendMessage(EM_CHARFROMPOS, 0, reinterpret_cast<LPARAM>(&pt)));
--- a/src/windows/native/sun/windows/awt_TextComponent.h Thu Jul 26 16:48:33 2012 -0700 +++ b/src/windows/native/sun/windows/awt_TextComponent.h Fri Jul 27 22:39:44 2012 -0700 @@ -50,6 +50,7 @@ static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline); virtual LPCTSTR GetClassName(); + LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); int RemoveCR(WCHAR *pStr);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java Fri Jul 27 22:39:44 2012 -0700 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2012, 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. + */ + +/* + * @test + * @bug 6385277 + * @summary Tests that override redirect window gets activated on click. + * @author anton.tarasov@sun.com: area=awt.focus + * @library ../../regtesthelpers + * @build Util + * @run main OverrideRedirectWindowActivationTest + */ +import java.awt.*; +import java.awt.event.*; +import java.util.concurrent.Callable; +import javax.swing.SwingUtilities; +import sun.awt.SunToolkit; +import test.java.awt.regtesthelpers.Util; + +public class OverrideRedirectWindowActivationTest { + + private static Frame frame; + private static Window window; + private static Button fbutton; + private static Button wbutton; + private static Label label; + private static Robot robot; + private static SunToolkit toolkit; + + public static void main(String[] args) throws Exception { + + if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { + System.out.println("No testing on Motif. Test passed."); + return; + } + + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); + robot.setAutoDelay(50); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + + public void eventDispatched(AWTEvent e) { + System.out.println(e); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + createAndShowWindow(); + toolkit.realSync(); + + createAndShowFrame(); + toolkit.realSync(); + + // click on Frame + clickOn(getClickPoint(frame)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + //click on Label in Window + clickOn(getClickPoint(label)); + + if (!window.isFocused()) { + throw new RuntimeException("Test failed: the window couldn't be activated by click!"); + } + + // bring focus back to the frame + clickOn(getClickPoint(fbutton)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + // Test 2. Verifies that clicking on a component of unfocusable Window + // won't activate it. + + window.setFocusableWindowState(false); + toolkit.realSync(); + + + clickOn(getClickPoint(label)); + + if (window.isFocused()) { + throw new RuntimeException("Test failed: unfocusable window got activated by click!"); + } + System.out.println("Test passed."); + + } + + private static void createAndShowWindow() { + + frame = new Frame("Test Frame"); + window = new Window(frame); + wbutton = new Button("wbutton"); + label = new Label("label"); + + window.setBounds(800, 200, 200, 100); + window.setLayout(new FlowLayout()); + window.add(wbutton); + window.add(label); + window.setVisible(true); + + } + + private static void createAndShowFrame() { + fbutton = new Button("fbutton"); + + frame.setBounds(800, 0, 200, 100); + frame.setLayout(new FlowLayout()); + frame.add(fbutton); + frame.setVisible(true); + + } + + static void clickOn(Point point) { + + robot.mouseMove(point.x, point.y); + + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + toolkit.realSync(); + } + + static Point getClickPoint(Component c) { + Point p = c.getLocationOnScreen(); + Dimension d = c.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (int) (d.getHeight() / 2)); + } + + static Point getClickPoint(Frame frame) { + Point p = frame.getLocationOnScreen(); + Dimension d = frame.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (frame.getInsets().top / 2)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Window/Grab/GrabTest.java Fri Jul 27 22:39:44 2012 -0700 @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2012, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + @test + @bug 7124430 + @summary Tests that SunToolkit.grab API works + @author anton.tarasov@oracle.com: area=awt.toolkit + @library ../../regtesthelpers + @build Util + @run main GrabTest +*/ + +import java.awt.*; +import java.awt.event.*; +import test.java.awt.regtesthelpers.Util; + +public class GrabTest { + private static Frame f; + private static Frame f1; + private static Window w; + private static Button b; + + private static Robot robot; + private static sun.awt.SunToolkit tk; + + static volatile boolean ungrabbed; + static volatile boolean buttonPressed; + static volatile boolean windowPressed; + static volatile boolean framePressed; + + static volatile boolean passed = true; + + public static void main(String[] args) { + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + System.out.println(e); + if (e instanceof sun.awt.UngrabEvent) { + ungrabbed = true; + } + } + }, sun.awt.SunToolkit.GRAB_EVENT_MASK); + + f = new Frame("Frame"); + f.setBounds(0, 0, 300, 300); + f.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + System.out.println(e); + framePressed = true; + } + }); + + f1 = new Frame("OtherFrame"); + f1.setBounds(700, 100, 200, 200); + + w = new Window(f); + w.setLayout(new FlowLayout()); + b = new Button("Press"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.out.println(e); + buttonPressed = true; + } + }); + w.add(b); + w.setBounds(400, 100, 200, 200); + w.setBackground(Color.blue); + w.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + System.out.println(e); + windowPressed = true; + } + }); + + f.setVisible(true); + w.setVisible(true); + + tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit(); + + try { + robot = new Robot(); + } catch (AWTException ex) { + throw new RuntimeException(ex); + } + + Util.waitForIdle(robot); + + test(); + } + + public static void test() { + tk.grab(w); + + // 1. Check that button press doesn't cause ungrab + Util.clickOnComp(b, robot); + Util.waitForIdle(robot); + checkAndThrow(buttonPressed, "Error: Button can not be pressed"); + if (ungrabbed) { + passed = false; + tk.grab(w); + System.err.println("Failure: [1] Press inside of Window (on Button) caused ungrab"); + } + + // 2. Check that press on the window itself doesn't cause ungrab + Util.clickOnComp(w, robot); + Util.waitForIdle(robot); + checkAndThrow(windowPressed, "Error: Window can't be pressed"); + if (ungrabbed) { + passed = false; + tk.grab(w); + System.err.println("Failure: [2] Press inside of Window caused ungrab"); + } + + // 3. Check that press on the frame causes ungrab, event must be dispatched + Util.clickOnComp(f, robot); + Util.waitForIdle(robot); + checkAndThrow(framePressed, "Error: Frame can't be pressed"); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [3] Press inside of Frame didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + // 4. Check that press on the frame's title causes ungrab + Util.clickOnTitle(f, robot); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [4] Press inside of Frame's title didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + + // 5. Check that press on the other frame's title causes ungrab + f1.setVisible(true); + Util.waitForIdle(robot); + Util.clickOnTitle(f1, robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [5] Press inside of other Frame's title didn't cause ungrab"); + } + f.requestFocus(); // restore focus + Util.waitForIdle(robot); + if (!f.hasFocus()) { + System.err.println("Error: Frame can't be focused"); + } + ungrabbed = false; + tk.grab(w); + + + // 6. Check that press on the outside area causes ungrab + Point loc = f.getLocationOnScreen(); + robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1); + Util.waitForIdle(robot); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.delay(50); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [6] Press on the outside area didn't cause ungrab"); + } + ungrabbed = false; + tk.grab(w); + + + // 7. Check that disposing the window causes ungrab + w.dispose(); + Util.waitForIdle(robot); + if (!ungrabbed) { + passed = false; + System.err.println("Failure: [7] Window disposal didn't cause ungrab"); + } + + if (passed) { + System.out.println("Test passed."); + } else { + throw new RuntimeException("Test failed."); + } + } + + public static void checkAndThrow(boolean condition, String msg) { + if (!condition) { + throw new RuntimeException(msg); + } + } +}