aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java90
-rw-r--r--test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java105
-rw-r--r--test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html45
-rw-r--r--test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java63
-rw-r--r--test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html43
-rw-r--r--test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java119
-rw-r--r--test/java/awt/Paint/ButtonRepaint.java88
-rw-r--r--test/java/awt/Paint/CheckboxRepaint.java93
-rw-r--r--test/java/awt/Paint/ExposeOnEDT.java293
-rw-r--r--test/java/awt/Paint/LabelRepaint.java93
-rw-r--r--test/java/awt/Paint/ListRepaint.java91
-rw-r--r--test/java/awt/Paint/bug8024864.java84
-rw-r--r--test/java/awt/Window/8027025/Test8027025.java69
-rw-r--r--test/java/awt/Window/WindowGCInFullScreen/WindowGCInFullScreen.java77
-rw-r--r--test/java/awt/event/KeyEvent/8020209/bug8020209.java120
-rw-r--r--test/java/beans/Introspector/TestTypeResolver.java2
-rw-r--r--test/java/beans/XMLEncoder/Test8027066.java41
-rw-r--r--test/javax/sound/sampled/FileReader/ReadersExceptions.java133
-rw-r--r--test/javax/swing/JInternalFrame/8020708/bug8020708.java141
-rw-r--r--test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java5
-rw-r--r--test/javax/swing/text/html/8005391/bug8005391.java61
-rw-r--r--test/sun/awt/AppContext/MultiThread/MultiThreadTest.java100
22 files changed, 1954 insertions, 2 deletions
diff --git a/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java b/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java
new file mode 100644
index 000000000..e616daadd
--- /dev/null
+++ b/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, 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 8016551
+ * @summary JMenuItem in WindowsLookAndFeel can't paint default icons
+ * @author Leonid Romanov
+ * @run main bug8016551
+ */
+
+import javax.swing.*;
+import java.awt.Graphics;
+import java.awt.Toolkit;
+import sun.awt.SunToolkit;
+
+public class bug8016551 {
+ private static volatile RuntimeException exception = null;
+
+ public static void main(String[] args) throws Exception {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ } catch (Exception e) {
+ // We intentionally allow the test to run with other l&f
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Icon icon = UIManager.getIcon("InternalFrame.closeIcon");
+ if (icon == null) {
+ return;
+ }
+
+ JMenuItem item = new TestMenuItem(icon);
+ JFrame f = new JFrame();
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.getContentPane().add(item);
+ f.pack();
+ f.setVisible(true);
+ } catch (ClassCastException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
+ tk.realSync();
+
+ if (exception != null) {
+ throw exception;
+ }
+ }
+
+ static class TestMenuItem extends JMenuItem {
+ TestMenuItem(Icon icon) {
+ super(icon);
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ try {
+ super.paint(g);
+ } catch (RuntimeException e) {
+ exception = e;
+ }
+ }
+ }
+}
+
diff --git a/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java b/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java
new file mode 100644
index 000000000..070aa4deb
--- /dev/null
+++ b/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013, 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 8026143
+ * @summary [macosx] Maximized state could be inconsistent between peer and frame
+ * @author Petr Pchelko
+ * @run main MaximizedByPlatform
+ */
+
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+
+public class MaximizedByPlatform {
+ private static Frame frame;
+ private static Rectangle availableScreenBounds;
+
+ public static void main(String[] args) {
+ if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+ // Test only for macosx. Pass
+ return;
+ }
+
+ availableScreenBounds = getAvailableScreenBounds();
+
+ // Test 1. The maximized state is set in setBounds
+ try {
+ frame = new Frame();
+ frame.setBounds(100, 100, 100, 100);
+ frame.setVisible(true);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
+ availableScreenBounds.width, availableScreenBounds.height);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
+ throw new RuntimeException("Maximized state was not set for frame in setBounds");
+ }
+ } finally {
+ frame.dispose();
+ }
+
+
+ // Test 2. The maximized state is set in setVisible
+ try {
+ frame = new Frame();
+ frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
+ availableScreenBounds.width + 100, availableScreenBounds.height);
+ frame.setVisible(true);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
+ throw new RuntimeException("Maximized state was not set for frame in setVisible");
+ }
+ } finally {
+ frame.dispose();
+ }
+ }
+
+ private static Rectangle getAvailableScreenBounds() {
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final GraphicsEnvironment graphicsEnvironment =
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final GraphicsDevice graphicsDevice =
+ graphicsEnvironment.getDefaultScreenDevice();
+
+ final Dimension screenSize = toolkit.getScreenSize();
+ final Insets screenInsets = toolkit.getScreenInsets(
+ graphicsDevice.getDefaultConfiguration());
+
+ final Rectangle availableScreenBounds = new Rectangle(screenSize);
+
+ availableScreenBounds.x += screenInsets.left;
+ availableScreenBounds.y += screenInsets.top;
+ availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
+ availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
+ return availableScreenBounds;
+ }
+}
diff --git a/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html b/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html
new file mode 100644
index 000000000..89dab3d87
--- /dev/null
+++ b/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html
@@ -0,0 +1,45 @@
+<!--
+Copyright (c) 2013, 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.
+-->
+
+<html>
+<head>
+<title> DiacriticsTest </title>
+</head>
+<body>
+<applet code="DiacriticsTest.class" width=350 height=200></applet>
+
+Test run requires the following keyboard layouts to be installed:
+Linux OS: English (US, alternative international)
+Windows OS: Hungarian
+
+To test JDK-8000423 fix (Linux only!):
+please switch to US alternative international layout and try to type diacritics
+(using the following combinations: `+e; `+u; etc.)
+
+To test JDK-7197619 fix (Windows only!):
+please switch to Hungarian keyboard layout and try to type diacritics
+(Ctrl+Alt+2 e; Ctrl+Alt+2 E)
+
+If you can do that then the test is passed; otherwise failed.
+</body>
+</html>
diff --git a/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java b/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java
new file mode 100644
index 000000000..7c610e479
--- /dev/null
+++ b/test/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013, 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 8000423 7197619 8025649
+ @summary Check if diacritical signs could be typed for TextArea and TextField
+ @run applet/manual=yesno DiacriticsTest.html
+*/
+
+
+import java.applet.Applet;
+import java.awt.*;
+import javax.swing.JPanel;
+
+
+public class DiacriticsTest extends Applet {
+
+ public void init() {
+ this.setLayout(new BorderLayout());
+ }
+
+ public void start() {
+
+ setSize(350, 200);
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(2, 1));
+
+ TextArea txtArea = new TextArea();
+ panel.add(txtArea);
+
+ TextField txtField = new TextField();
+ panel.add(txtField);
+
+ add(panel, BorderLayout.CENTER);
+
+ validate();
+ setVisible(true);
+ }
+}
+
diff --git a/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html b/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html
new file mode 100644
index 000000000..4928aeddb
--- /dev/null
+++ b/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html
@@ -0,0 +1,43 @@
+<html>
+<!--
+ Copyright (c) 2013, 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 6299858
+ @summary PIT. Focused border not shown on List if selected item is removed, XToolkit
+ @author Dmitry.Cherepanov@SUN.COM area=awt.list
+ @run applet FirstItemRemoveTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>FirstItemRemoveTest<br>Bug ID: 6299858 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="FirstItemRemoveTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
diff --git a/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java b/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java
new file mode 100644
index 000000000..85c46af64
--- /dev/null
+++ b/test/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013, 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 6299858 7124338
+ @summary PIT. Focused border not shown on List if selected item is removed, XToolkit
+ @author Dmitry.Cherepanov@SUN.COM area=awt.list
+ @run applet FirstItemRemoveTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class FirstItemRemoveTest extends Applet
+{
+ List list = new List(4, false);
+ Panel panel = new Panel();
+
+ public void init()
+ {
+ list.add("000");
+ list.add("111");
+ list.add("222");
+ list.add("333");
+ list.add("444");
+ list.add("555");
+
+ panel.setLayout(new FlowLayout ());
+ panel.add(list);
+
+ this.add(panel);
+ this.setLayout (new FlowLayout ());
+ }//End init()
+
+ public void start ()
+ {
+ setSize (200,200);
+ setVisible(true);
+ validate();
+
+ test();
+ }// start()
+
+ private void test(){
+
+ if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.MACOSX) {
+ System.err.println("Skipped. This test is not for OS X.");
+ return;
+ }
+
+ Robot r;
+ try {
+ r = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ // Removing first item in order to reproduce incorrect behaviour
+ r.delay(1000);
+ list.remove(0);
+ r.delay(1000);
+
+ // Request focus to list
+ Point loc = this.getLocationOnScreen();
+ r.delay(1000);
+
+ r.mouseMove(loc.x+10, loc.y+10);
+ r.delay(10);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ r.delay(1000);
+
+ list.requestFocusInWindow();
+ r.delay(1000);
+ r.waitForIdle();
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != list){
+ throw new RuntimeException("Test failed - list isn't focus owner.");
+ }
+
+ // The focus index should be set to first item after removing
+ // So if we press VK_SPACE then the selected item will be equals 0.
+ r.delay(100);
+ r.keyPress(KeyEvent.VK_SPACE);
+ r.delay(10);
+ r.keyRelease(KeyEvent.VK_SPACE);
+ r.delay(1000);
+ r.waitForIdle();
+
+ int selectedIndex = list.getSelectedIndex();
+ if (selectedIndex != 0){
+ throw new RuntimeException("Test failed. list.getSelectedIndex() = "+selectedIndex);
+ }
+
+ }
+
+}// class AutomaticAppletTest
diff --git a/test/java/awt/Paint/ButtonRepaint.java b/test/java/awt/Paint/ButtonRepaint.java
new file mode 100644
index 000000000..a4dc34224
--- /dev/null
+++ b/test/java/awt/Paint/ButtonRepaint.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013, 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.peer.ButtonPeer;
+
+/**
+ * @test
+ * @bug 7090424
+ * @author Sergey Bylokhov
+ */
+public final class ButtonRepaint extends Button {
+
+ public static void main(final String[] args) {
+ for (int i = 0; i < 10; ++i) {
+ final Frame frame = new Frame();
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ ButtonRepaint button = new ButtonRepaint();
+ frame.add(button);
+ frame.setVisible(true);
+ sleep();
+ button.test();
+ frame.dispose();
+ }
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ @Override
+ public void paint(final Graphics g) {
+ super.paint(g);
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ test();
+ }
+
+ void test() {
+ setLabel("");
+ setLabel(null);
+ setLabel(getLabel());
+ ((ButtonPeer) getPeer()).setLabel("");
+ ((ButtonPeer) getPeer()).setLabel(null);
+ ((ButtonPeer) getPeer()).setLabel(getLabel());
+
+ setFont(null);
+ setFont(getFont());
+ getPeer().setFont(getFont());
+
+ setBackground(null);
+ setBackground(getBackground());
+ getPeer().setBackground(getBackground());
+
+ setForeground(null);
+ setForeground(getForeground());
+ getPeer().setForeground(getForeground());
+
+ setEnabled(isEnabled());
+ getPeer().setEnabled(isEnabled());
+ }
+}
diff --git a/test/java/awt/Paint/CheckboxRepaint.java b/test/java/awt/Paint/CheckboxRepaint.java
new file mode 100644
index 000000000..e7835a463
--- /dev/null
+++ b/test/java/awt/Paint/CheckboxRepaint.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013, 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.peer.CheckboxPeer;
+
+/**
+ * @test
+ * @bug 7090424
+ * @author Sergey Bylokhov
+ */
+public final class CheckboxRepaint extends Checkbox {
+
+ public static void main(final String[] args) {
+ for (int i = 0; i < 10; ++i) {
+ final Frame frame = new Frame();
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ CheckboxRepaint checkbox = new CheckboxRepaint();
+ frame.add(checkbox);
+ frame.setVisible(true);
+ sleep();
+ checkbox.test();
+ frame.dispose();
+ }
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ @Override
+ public void paint(final Graphics g) {
+ super.paint(g);
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ test();
+ }
+
+ void test() {
+ setState(getState());
+ ((CheckboxPeer) getPeer()).setState(getState());
+
+ setCheckboxGroup(getCheckboxGroup());
+ ((CheckboxPeer) getPeer()).setCheckboxGroup(getCheckboxGroup());
+
+ setLabel("");
+ setLabel(null);
+ setLabel(getLabel());
+ ((CheckboxPeer) getPeer()).setLabel("");
+ ((CheckboxPeer) getPeer()).setLabel(null);
+ ((CheckboxPeer) getPeer()).setLabel(getLabel());
+
+ setFont(null);
+ setFont(getFont());
+ getPeer().setFont(getFont());
+
+ setBackground(null);
+ setBackground(getBackground());
+ getPeer().setBackground(getBackground());
+
+ setForeground(null);
+ setForeground(getForeground());
+ getPeer().setForeground(getForeground());
+
+ setEnabled(isEnabled());
+ getPeer().setEnabled(isEnabled());
+ }
+}
diff --git a/test/java/awt/Paint/ExposeOnEDT.java b/test/java/awt/Paint/ExposeOnEDT.java
new file mode 100644
index 000000000..cf8a3a547
--- /dev/null
+++ b/test/java/awt/Paint/ExposeOnEDT.java
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2013, 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 sun.awt.SunToolkit;
+
+import java.awt.*;
+
+/**
+ * @test
+ * @bug 7090424
+ * @author Sergey Bylokhov
+ * @run main ExposeOnEDT
+ */
+public final class ExposeOnEDT {
+
+ private static final Button buttonStub = new Button() {
+ @Override
+ public void paint(final Graphics g) {
+ buttonPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Canvas canvasStub = new Canvas() {
+ @Override
+ public void paint(final Graphics g) {
+ canvasPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Checkbox checkboxStub = new Checkbox() {
+ @Override
+ public void paint(final Graphics g) {
+ checkboxPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Choice choiceStub = new Choice() {
+ @Override
+ public void paint(final Graphics g) {
+ choicePainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Component lwComponentStub = new Component() {
+ @Override
+ public void paint(final Graphics g) {
+ lwPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Container containerStub = new Container() {
+ @Override
+ public void paint(final Graphics g) {
+ containerPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Frame frame = new Frame() {
+ @Override
+ public void paint(final Graphics g) {
+ super.paint(g);
+ framePainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Label labelStub = new Label() {
+ @Override
+ public void paint(final Graphics g) {
+ labelPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final List listStub = new List() {
+ @Override
+ public void paint(final Graphics g) {
+ listPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Panel panelStub = new Panel() {
+ @Override
+ public void paint(final Graphics g) {
+ panelPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final Scrollbar scrollbarStub = new Scrollbar() {
+ @Override
+ public void paint(final Graphics g) {
+ scrollbarPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final ScrollPane scrollPaneStub = new ScrollPane() {
+ @Override
+ public void paint(final Graphics g) {
+ scrollPanePainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final TextArea textAreaStub = new TextArea() {
+ @Override
+ public void paint(final Graphics g) {
+ textAreaPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static final TextField textFieldStub = new TextField() {
+ @Override
+ public void paint(final Graphics g) {
+ textFieldPainted = true;
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ }
+ };
+ private static volatile boolean lwPainted;
+ private static volatile boolean buttonPainted;
+ private static volatile boolean canvasPainted;
+ private static volatile boolean checkboxPainted;
+ private static volatile boolean choicePainted;
+ private static volatile boolean containerPainted;
+ private static volatile boolean framePainted;
+ private static volatile boolean labelPainted;
+ private static volatile boolean listPainted;
+ private static volatile boolean panelPainted;
+ private static volatile boolean scrollbarPainted;
+ private static volatile boolean scrollPanePainted;
+ private static volatile boolean textAreaPainted;
+ private static volatile boolean textFieldPainted;
+
+ public static void main(final String[] args) throws Exception {
+ //Frame initialisation
+ frame.setLayout(new GridLayout());
+ frame.setSize(new Dimension(200, 200));
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ sleep();
+
+ frame.add(buttonStub);
+ frame.add(canvasStub);
+ frame.add(checkboxStub);
+ frame.add(choiceStub);
+ frame.add(lwComponentStub);
+ frame.add(containerStub);
+ frame.add(labelStub);
+ frame.add(listStub);
+ frame.add(panelStub);
+ frame.add(scrollbarStub);
+ frame.add(scrollPaneStub);
+ frame.add(textAreaStub);
+ frame.add(textFieldStub);
+ frame.validate();
+ sleep();
+
+ // Force expose event from the native system.
+ initPaintedFlags();
+ frame.setSize(300, 300);
+ frame.validate();
+ sleep();
+
+ //Check results.
+ validation();
+
+ cleanup();
+ }
+
+ private static void initPaintedFlags() {
+ lwPainted = false;
+ buttonPainted = false;
+ canvasPainted = false;
+ checkboxPainted = false;
+ choicePainted = false;
+ containerPainted = false;
+ framePainted = false;
+ labelPainted = false;
+ listPainted = false;
+ panelPainted = false;
+ scrollbarPainted = false;
+ scrollPanePainted = false;
+ textAreaPainted = false;
+ textFieldPainted = false;
+ }
+
+ private static void validation() {
+ if (!buttonPainted) {
+ fail("Paint is not called a Button ");
+ }
+ if (!canvasPainted) {
+ fail("Paint is not called a Canvas ");
+ }
+ if (!checkboxPainted) {
+ fail("Paint is not called a Checkbox ");
+ }
+ if (!choicePainted) {
+ fail("Paint is not called a Choice ");
+ }
+ if (!lwPainted) {
+ fail("Paint is not called on a lightweight");
+ }
+ if (!containerPainted) {
+ fail("Paint is not called on a Container");
+ }
+ if (!labelPainted) {
+ fail("Paint is not called on a Label");
+ }
+ if (!listPainted) {
+ fail("Paint is not called on a List");
+ }
+ if (!panelPainted) {
+ fail("Paint is not called on a Panel");
+ }
+ if (!scrollbarPainted) {
+ fail("Paint is not called on a Scrollbar");
+ }
+ if (!scrollPanePainted) {
+ fail("Paint is not called on a ScrollPane");
+ }
+ if (!textAreaPainted) {
+ fail("Paint is not called on a TextArea");
+ }
+ if (!textFieldPainted) {
+ fail("Paint is not called on a TextField");
+ }
+ if (!framePainted) {
+ fail("Paint is not called on a Frame when paintAll()");
+ }
+ }
+
+ private static void sleep() {
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Thread.sleep(1000L);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ private static void fail(final String message) {
+ cleanup();
+ throw new RuntimeException(message);
+ }
+
+ private static void cleanup() {
+ frame.dispose();
+ }
+}
diff --git a/test/java/awt/Paint/LabelRepaint.java b/test/java/awt/Paint/LabelRepaint.java
new file mode 100644
index 000000000..f662f17db
--- /dev/null
+++ b/test/java/awt/Paint/LabelRepaint.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013, 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.EventQueue;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Label;
+import java.awt.peer.LabelPeer;
+
+/**
+ * @test
+ * @bug 7090424
+ * @author Sergey Bylokhov
+ */
+public final class LabelRepaint extends Label {
+
+ public static void main(final String[] args) {
+ for (int i = 0; i < 10; ++i) {
+ final Frame frame = new Frame();
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ LabelRepaint label = new LabelRepaint();
+ frame.add(label);
+ frame.setVisible(true);
+ sleep();
+ label.test();
+ frame.dispose();
+ }
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ @Override
+ public void paint(final Graphics g) {
+ super.paint(g);
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ test();
+ }
+
+ void test() {
+ setAlignment(getAlignment());
+ ((LabelPeer) getPeer()).setAlignment(getAlignment());
+
+ setText("");
+ setText(null);
+ setText(getText());
+ ((LabelPeer) getPeer()).setText("");
+ ((LabelPeer) getPeer()).setText(null);
+ ((LabelPeer) getPeer()).setText(getText());
+
+ setFont(null);
+ setFont(getFont());
+ getPeer().setFont(getFont());
+
+ setBackground(null);
+ setBackground(getBackground());
+ getPeer().setBackground(getBackground());
+
+ setForeground(null);
+ setForeground(getForeground());
+ getPeer().setForeground(getForeground());
+
+ setEnabled(isEnabled());
+ getPeer().setEnabled(isEnabled());
+ }
+}
diff --git a/test/java/awt/Paint/ListRepaint.java b/test/java/awt/Paint/ListRepaint.java
new file mode 100644
index 000000000..dc473daac
--- /dev/null
+++ b/test/java/awt/Paint/ListRepaint.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013, 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.EventQueue;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.List;
+import java.awt.peer.ListPeer;
+
+/**
+ * @test
+ * @bug 7090424
+ * @author Sergey Bylokhov
+ */
+public final class ListRepaint extends List {
+
+ public static void main(final String[] args) {
+ for (int i = 0; i < 10; ++i) {
+ final Frame frame = new Frame();
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ ListRepaint list = new ListRepaint();
+ list.add("1");
+ list.add("2");
+ list.add("3");
+ list.add("4");
+ list.select(0);
+ frame.add(list);
+ frame.setVisible(true);
+ sleep();
+ list.test();
+ frame.dispose();
+ }
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ @Override
+ public void paint(final Graphics g) {
+ super.paint(g);
+ if (!EventQueue.isDispatchThread()) {
+ throw new RuntimeException("Wrong thread");
+ }
+ test();
+ }
+
+ void test() {
+ select(0);
+ ((ListPeer) getPeer()).select(getSelectedIndex());
+
+ setFont(null);
+ setFont(getFont());
+ getPeer().setFont(getFont());
+
+ setBackground(null);
+ setBackground(getBackground());
+ getPeer().setBackground(getBackground());
+
+ setForeground(null);
+ setForeground(getForeground());
+ getPeer().setForeground(getForeground());
+
+ setEnabled(isEnabled());
+ getPeer().setEnabled(isEnabled());
+ }
+}
diff --git a/test/java/awt/Paint/bug8024864.java b/test/java/awt/Paint/bug8024864.java
new file mode 100644
index 000000000..caa62904e
--- /dev/null
+++ b/test/java/awt/Paint/bug8024864.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2013, 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 8024864
+ * @summary [macosx] Problems with rendering of controls
+ * @author Petr Pchelko
+ * @library ../regtesthelpers
+ * @build Util
+ * @run main bug8024864
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class bug8024864
+{
+ private static final int REPEATS = 30;
+
+ private static volatile JFrame frame;
+
+ private static void showTestUI() {
+ frame = new JFrame();
+ frame.setBackground(Color.green);
+ JPanel p = new JPanel();
+ p.setBackground(Color.red);
+ JLabel l = new JLabel("Test!");
+ p.add(l);
+ frame.add(p);
+ frame.pack();
+ frame.setLocation(100,100);
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ Robot r = new Robot();
+ for (int i = 0; i < REPEATS; i++) {
+ try {
+ SwingUtilities.invokeAndWait(bug8024864::showTestUI);
+ //Thread.sleep(100);
+ Util.waitTillShown(frame);
+ Util.waitForIdle(r);
+
+ Dimension frameSize = frame.getSize();
+ Point loc = new Point(frameSize.width - 5, frameSize.height - 5);
+ SwingUtilities.convertPointToScreen(loc, frame);
+ Color c = r.getPixelColor(loc.x, loc.y);
+
+ if (c.getGreen() > 200) {
+ throw new RuntimeException("TEST FAILED. Unexpected pixel color " + c);
+ }
+
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ Util.waitForIdle(r);
+ }
+ }
+ }
+}
diff --git a/test/java/awt/Window/8027025/Test8027025.java b/test/java/awt/Window/8027025/Test8027025.java
new file mode 100644
index 000000000..449889044
--- /dev/null
+++ b/test/java/awt/Window/8027025/Test8027025.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013, 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 8027025
+ * @summary [macosx] getLocationOnScreen returns 0 if parent invisible
+ * @author Petr Pchelko
+ * @run main Test8027025
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Test8027025 {
+
+ private static Frame frame;
+ private static Window window;
+
+ public static void main(String[] args) throws Exception {
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ frame = new Frame("Dummy Frame");
+ window = new Window(frame);
+ window.setSize(200, 200);
+ window.setLocationRelativeTo(frame);
+ window.setVisible(true);
+ });
+
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+
+ AtomicReference<Point> point = new AtomicReference<>();
+ SwingUtilities.invokeAndWait(() -> point.set(window.getLocationOnScreen()));
+
+ if (point.get().getX() == 0 || point.get().getY() == 0) {
+ throw new RuntimeException("Test failed. The location was not set");
+ }
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ if (window != null) {
+ window.dispose();
+ }
+ }
+ }
+}
diff --git a/test/java/awt/Window/WindowGCInFullScreen/WindowGCInFullScreen.java b/test/java/awt/Window/WindowGCInFullScreen/WindowGCInFullScreen.java
new file mode 100644
index 000000000..2b044def4
--- /dev/null
+++ b/test/java/awt/Window/WindowGCInFullScreen/WindowGCInFullScreen.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013, 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.Color;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8019591
+ * @author Sergey Bylokhov
+ */
+public class WindowGCInFullScreen {
+
+ public static void main(final String[] args)
+ throws InvocationTargetException, InterruptedException {
+ SwingUtilities.invokeAndWait(() -> {
+ final GraphicsDevice[] devices =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getScreenDevices();
+ final Frame frame = new Frame();
+ frame.setBackground(Color.GREEN);
+ frame.setUndecorated(true);
+ frame.setSize(100, 100);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ sleep();
+ for (final GraphicsDevice gd : devices) {
+ try {
+ gd.setFullScreenWindow(frame);
+ if (gd.getFullScreenWindow() != frame) {
+ throw new RuntimeException("Wrong window");
+ }
+ if (frame.getGraphicsConfiguration().getDevice() != gd) {
+ throw new RuntimeException("Wrong new GraphicsDevice");
+ }
+ } finally {
+ // cleaning up
+ gd.setFullScreenWindow(null);
+ }
+ }
+ frame.dispose();
+ });
+ }
+
+ private static void sleep() {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+}
diff --git a/test/java/awt/event/KeyEvent/8020209/bug8020209.java b/test/java/awt/event/KeyEvent/8020209/bug8020209.java
new file mode 100644
index 000000000..4ef857240
--- /dev/null
+++ b/test/java/awt/event/KeyEvent/8020209/bug8020209.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2012, 2013, 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 8020209
+ * @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
+ * @author leonid.romanov@oracle.com
+ * @run main bug8020209
+ */
+
+import sun.awt.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class bug8020209 {
+ static volatile int listenerCallCounter = 0;
+
+ static AWTKeyStroke keyStrokes[] = {
+ AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DECIMAL, InputEvent.META_MASK),
+ AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK),
+ AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK),
+ };
+
+ public static void main(String[] args) throws Exception {
+ if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+ System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
+ return;
+ }
+
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ createAndShowGUI();
+ toolkit.realSync();
+
+ for (int i = 0; i < keyStrokes.length; ++i) {
+ AWTKeyStroke ks = keyStrokes[i];
+
+ int modKeyCode = getModKeyCode(ks.getModifiers());
+ robot.keyPress(modKeyCode);
+
+ robot.keyPress(ks.getKeyCode());
+ robot.keyRelease(ks.getKeyCode());
+
+ robot.keyRelease(modKeyCode);
+
+ toolkit.realSync();
+
+ if (listenerCallCounter != 4) {
+ throw new Exception("Test failed: KeyListener for '" + ks.toString() +
+ "' called " + listenerCallCounter + " times instead of 4!");
+ }
+
+ listenerCallCounter = 0;
+ }
+
+ }
+
+ private static void createAndShowGUI() {
+ Frame frame = new Frame("Test");
+ frame.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ listenerCallCounter++;
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ listenerCallCounter++;
+ }
+ });
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private static int getModKeyCode(int mod) {
+ if ((mod & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) {
+ return KeyEvent.VK_SHIFT;
+ }
+
+ if ((mod & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) {
+ return KeyEvent.VK_CONTROL;
+ }
+
+ if ((mod & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) {
+ return KeyEvent.VK_ALT;
+ }
+
+ if ((mod & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) {
+ return KeyEvent.VK_META;
+ }
+
+ return 0;
+ }
+}
diff --git a/test/java/beans/Introspector/TestTypeResolver.java b/test/java/beans/Introspector/TestTypeResolver.java
index 1b4535f50..485b117da 100644
--- a/test/java/beans/Introspector/TestTypeResolver.java
+++ b/test/java/beans/Introspector/TestTypeResolver.java
@@ -115,6 +115,8 @@ public class TestTypeResolver {
// by private implementations of the various Type interfaces
if (expect.equals(t) && t.equals(expect))
System.out.println(", as expected");
+ else if ((expect.equals(t) || t.equals(expect)) && expect.toString().equals(t.toString()))
+ System.out.println(", as workaround of the 8023301 bug");
else {
System.out.println(" BUT SHOULD BE " + expect);
failedCases.add(c);
diff --git a/test/java/beans/XMLEncoder/Test8027066.java b/test/java/beans/XMLEncoder/Test8027066.java
new file mode 100644
index 000000000..22d495d4f
--- /dev/null
+++ b/test/java/beans/XMLEncoder/Test8027066.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013, 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 8027066
+ * @summary Tests that the same array can be encoded twice
+ * @author Anton Nashatyrev
+ */
+public class Test8027066 extends AbstractTest<String[][]> {
+ public static void main(String[] args) {
+ new Test8027066().test(true);
+ }
+
+ @Override
+ protected String[][] getObject() {
+ String[] strings = {"first", "second"};
+ String[][] arrays = {strings, strings};
+ return arrays;
+ }
+}
diff --git a/test/javax/sound/sampled/FileReader/ReadersExceptions.java b/test/javax/sound/sampled/FileReader/ReadersExceptions.java
new file mode 100644
index 000000000..e0a386ed9
--- /dev/null
+++ b/test/javax/sound/sampled/FileReader/ReadersExceptions.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013, 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.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+/**
+ * @test
+ * @bug 7058662 7058666 7058672
+ * @author Sergey Bylokhov
+ */
+public final class ReadersExceptions {
+
+ // empty channels
+ static byte[] wrongAIFFCh =
+ {0x46, 0x4f, 0x52, 0x4d, // AiffFileFormat.AIFF_MAGIC
+ 0, 0, 0, 0, // length
+ 0, 0, 0, 0, // iffType
+ 0x43, 0x4f, 0x4d, 0x4d, // chunkName
+ 0, 0, 0, 100, // chunkLen
+ 0, 0, // channels
+ 0, 0, 0, 0, //
+ 0, 10 // sampleSize
+ , 0, 0, 0, 0};
+ // empty sampleSize
+ static byte[] wrongAIFFSSL =
+ {0x46, 0x4f, 0x52, 0x4d, //AiffFileFormat.AIFF_MAGIC
+ 0, 0, 0, 0, // length
+ 0, 0, 0, 0, // iffType
+ 0x43, 0x4f, 0x4d, 0x4d, // chunkName
+ 0, 0, 0, 100, // chunkLen
+ 0, 10, // channels
+ 0, 0, 0, 0, //
+ 0, 0 // sampleSize
+ , 0, 0, 0, 0};
+ // big sampleSize
+ static byte[] wrongAIFFSSH =
+ {0x46, 0x4f, 0x52, 0x4d, //AiffFileFormat.AIFF_MAGIC
+ 0, 0, 0, 0, // length
+ 0, 0, 0, 0, // iffType
+ 0x43, 0x4f, 0x4d, 0x4d, // chunkName
+ 0, 0, 0, 100, // chunkLen
+ 0, 10, // channels
+ 0, 0, 0, 0, //
+ 0, 33 // sampleSize
+ , 0, 0, 0, 0};
+ // empty channels
+ static byte[] wrongAUCh =
+ {0x2e, 0x73, 0x6e, 0x64,//AiffFileFormat.AU_SUN_MAGIC
+ 0, 0, 0, 0, // headerSize
+ 0, 0, 0, 0, // dataSize
+ 0, 0, 0, 1, // encoding_local AuFileFormat.AU_ULAW_8
+ 0, 0, 0, 0, // sampleRate
+ 0, 0, 0, 0 // channels
+ };
+ // empty channels
+ static byte[] wrongWAVCh =
+ {0x52, 0x49, 0x46, 0x46, // WaveFileFormat.RIFF_MAGIC
+ 1, 1, 1, 1, // fileLength
+ 0x57, 0x41, 0x56, 0x45, // waveMagic
+ 0x66, 0x6d, 0x74, 0x20, // FMT_MAGIC
+ 3, 0, 0, 0, // length
+ 1, 0, // wav_type WAVE_FORMAT_PCM
+ 0, 0, // channels
+ 0, 0, 0, 0, // sampleRate
+ 0, 0, 0, 0, // avgBytesPerSec
+ 0, 0, // blockAlign
+ 1, 0, // sampleSizeInBits
+ 0x64, 0x61, 0x74, 0x61, // WaveFileFormat.DATA_MAGIC
+ 0, 0, 0, 0, // dataLength
+ };
+ // empty sampleSizeInBits
+ static byte[] wrongWAVSSB =
+ {0x52, 0x49, 0x46, 0x46, // WaveFileFormat.RIFF_MAGIC
+ 1, 1, 1, 1, // fileLength
+ 0x57, 0x41, 0x56, 0x45, // waveMagic
+ 0x66, 0x6d, 0x74, 0x20, // FMT_MAGIC
+ 3, 0, 0, 0, // length
+ 1, 0, // wav_type WAVE_FORMAT_PCM
+ 1, 0, // channels
+ 0, 0, 0, 0, // sampleRate
+ 0, 0, 0, 0, // avgBytesPerSec
+ 0, 0, // blockAlign
+ 0, 0, // sampleSizeInBits
+ 0x64, 0x61, 0x74, 0x61, // WaveFileFormat.DATA_MAGIC
+ 0, 0, 0, 0, // dataLength
+ };
+
+ public static void main(final String[] args) throws IOException {
+ test(wrongAIFFCh);
+ test(wrongAIFFSSL);
+ test(wrongAIFFSSH);
+ test(wrongAUCh);
+ test(wrongWAVCh);
+ test(wrongWAVSSB);
+ }
+
+ private static void test(final byte[] buffer) throws IOException {
+ final InputStream is = new ByteArrayInputStream(buffer);
+ try {
+ AudioSystem.getAudioFileFormat(is);
+ } catch (UnsupportedAudioFileException ignored) {
+ // Expected.
+ return;
+ }
+ throw new RuntimeException("Test Failed");
+ }
+}
diff --git a/test/javax/swing/JInternalFrame/8020708/bug8020708.java b/test/javax/swing/JInternalFrame/8020708/bug8020708.java
new file mode 100644
index 000000000..c40678d88
--- /dev/null
+++ b/test/javax/swing/JInternalFrame/8020708/bug8020708.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013, 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.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.Locale;
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 8020708
+ * @author Alexander Scherbatiy
+ * @summary NLS: mnemonics missing in SwingSet2/JInternalFrame demo
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug8020708
+ */
+public class bug8020708 {
+
+ private static final Locale[] SUPPORTED_LOCALES = {
+ Locale.ENGLISH,
+ new Locale("de"),
+ new Locale("es"),
+ new Locale("fr"),
+ new Locale("it"),
+ new Locale("ja"),
+ new Locale("ko"),
+ new Locale("pt", "BR"),
+ new Locale("sv"),
+ new Locale("zh", "CN"),
+ new Locale("zh", "TW")
+ };
+ private static final String[] LOOK_AND_FEELS = {
+ "Nimbus",
+ "Windows",
+ "Motif"
+ };
+ private static JInternalFrame internalFrame;
+ private static JFrame frame;
+
+ public static void main(String[] args) throws Exception {
+ for (Locale locale : SUPPORTED_LOCALES) {
+ for (String laf : LOOK_AND_FEELS) {
+ Locale.setDefault(locale);
+ if (!installLookAndFeel(laf)) {
+ continue;
+ }
+ testInternalFrameMnemonic();
+ }
+ }
+ }
+
+ static void testInternalFrameMnemonic() throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame("Test");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(300, 200);
+
+ JDesktopPane desktop = new JDesktopPane();
+ internalFrame = new JInternalFrame("Test");
+ internalFrame.setSize(200, 100);
+ internalFrame.setClosable(true);
+ desktop.add(internalFrame);
+ internalFrame.setVisible(true);
+ internalFrame.setMaximizable(true);
+
+ frame.getContentPane().add(desktop);
+ frame.setVisible(true);
+ }
+ });
+
+ toolkit.realSync();
+
+ Point clickPoint = Util.getCenterPoint(internalFrame);
+ robot.mouseMove(clickPoint.x, clickPoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ toolkit.realSync();
+
+ Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
+ toolkit.realSync();
+
+ Util.hitKeys(robot, KeyEvent.VK_C);
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (internalFrame.isVisible()) {
+ throw new RuntimeException("Close mnemonic does not work");
+ }
+ frame.dispose();
+ }
+ });
+ }
+
+ static final boolean installLookAndFeel(String lafName) throws Exception {
+ UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
+ for (UIManager.LookAndFeelInfo info : infos) {
+ if (info.getClassName().contains(lafName)) {
+ UIManager.setLookAndFeel(info.getClassName());
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java b/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
index 69a42d783..c2af8c075 100644
--- a/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
+++ b/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java
@@ -35,13 +35,14 @@ import java.awt.event.*;
import javax.swing.*;
public class ActionListenerCalledTwiceTest {
- static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5" };
+ static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6" };
static KeyStroke keyStrokes[] = {
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_MASK),
- KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK)
+ KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK),
+ KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK)
};
static volatile int listenerCallCounter = 0;
diff --git a/test/javax/swing/text/html/8005391/bug8005391.java b/test/javax/swing/text/html/8005391/bug8005391.java
new file mode 100644
index 000000000..525aa4980
--- /dev/null
+++ b/test/javax/swing/text/html/8005391/bug8005391.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013, 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.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
+
+/**
+ * @test
+ * @bug 8005391
+ * @author Alexander Shusherov
+ * @summary Floating behavior of HTMLEditorKit parser
+ * @run main bug8005391
+ */
+public class bug8005391 {
+
+ private static final String htmlDoc = "<html><body><tt><a href='one'>1</a>2</tt></body></html>";
+
+ public static void main(String[] args) throws Exception {
+ int N = 10;
+
+ for (int i = 0; i < N; i++) {
+ HTMLEditorKit kit = new HTMLEditorKit();
+ Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
+ HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
+ HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
+ HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0);
+ parser.parse(new CharArrayReader(htmlDoc.toCharArray()), htmlReader, true);
+ htmlReader.flush();
+ CharArrayWriter writer = new CharArrayWriter(1000);
+ kit.write(writer, doc, 0, doc.getLength());
+ writer.flush();
+
+ String result = writer.toString();
+ if (!result.contains("<tt><a")) {
+ throw new RuntimeException("The <a> and <tt> tags are swapped");
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/sun/awt/AppContext/MultiThread/MultiThreadTest.java b/test/sun/awt/AppContext/MultiThread/MultiThreadTest.java
new file mode 100644
index 000000000..4939cae15
--- /dev/null
+++ b/test/sun/awt/AppContext/MultiThread/MultiThreadTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013, 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 8019623
+ * @summary Tests that AppContext.getAppContext() works correctly in multi-threads scenario.
+ * @author Leonid Romanov
+ */
+
+import sun.awt.AppContext;
+
+public class MultiThreadTest {
+ private static final int NUM_THREADS = 2;
+
+ private static AppContextGetter[] getters = new AppContextGetter[NUM_THREADS];
+
+ public static void main(String[] args) {
+ createAndStartThreads();
+ compareAppContexts();
+ }
+
+ private static void createAndStartThreads() {
+ ThreadGroup systemGroup = getSystemThreadGroup();
+ for (int i = 0; i < NUM_THREADS; ++i) {
+ ThreadGroup tg = new ThreadGroup(systemGroup, "AppContextGetter" + i);
+ getters[i] = new AppContextGetter(tg);
+ }
+
+ for (int i = 0; i < NUM_THREADS; ++i) {
+ getters[i].start();
+ }
+
+ for (int i = 0; i < NUM_THREADS; ++i) {
+ try {
+ getters[i].join();
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ }
+
+ private static ThreadGroup getSystemThreadGroup() {
+ ThreadGroup currentThreadGroup =
+ Thread.currentThread().getThreadGroup();
+ ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
+ while (parentThreadGroup != null) {
+ currentThreadGroup = parentThreadGroup;
+ parentThreadGroup = currentThreadGroup.getParent();
+ }
+
+ return currentThreadGroup;
+ }
+
+ private static void compareAppContexts() {
+ AppContext ctx = getters[0].getAppContext();
+ for (int i = 1; i < NUM_THREADS; ++i) {
+ if (!ctx.equals(getters[i].getAppContext())) {
+ throw new RuntimeException("Unexpected AppContexts difference, could be a race condition");
+ }
+ }
+ }
+
+ private static class AppContextGetter extends Thread {
+ private AppContext appContext;
+
+ public AppContextGetter(ThreadGroup tg) {
+ super(tg, tg.getName());
+ }
+
+ AppContext getAppContext() {
+ return appContext;
+ }
+
+ @Override
+ public void run() {
+ appContext = AppContext.getAppContext();
+ }
+ }
+}