diff --git a/jdk/test/java/awt/AlphaComposite/HeadlessAlphaComposite.java b/jdk/test/java/awt/AlphaComposite/HeadlessAlphaComposite.java new file mode 100644 index 00000000000..71064d48bda --- /dev/null +++ b/jdk/test/java/awt/AlphaComposite/HeadlessAlphaComposite.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.image.ColorModel; + +/* + * @test + * @summary Check no exception occurrence when running AlphaComposite getInstance(), + * createContext(), getAlpha(), getRule(), hashCode() methods in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAlphaComposite + */ + +public class HeadlessAlphaComposite { + + public static void main(String args[]) { + AlphaComposite ac; + ac = AlphaComposite.getInstance(AlphaComposite.CLEAR); + ac = AlphaComposite.getInstance(AlphaComposite.DST_IN); + ac = AlphaComposite.getInstance(AlphaComposite.DST_OUT); + ac = AlphaComposite.getInstance(AlphaComposite.DST_OVER); + ac = AlphaComposite.getInstance(AlphaComposite.SRC); + ac = AlphaComposite.getInstance(AlphaComposite.SRC_IN); + ac = AlphaComposite.getInstance(AlphaComposite.SRC_OUT); + ac = AlphaComposite.getInstance(AlphaComposite.DST_IN); + ac = AlphaComposite.getInstance(AlphaComposite.SRC, (float) 0.5); + + ac = AlphaComposite.getInstance(AlphaComposite.SRC, (float) 0.5); + CompositeContext cc = ac.createContext(ColorModel.getRGBdefault(), + ColorModel.getRGBdefault(), + new RenderingHints(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON)); + + ac = AlphaComposite.getInstance(AlphaComposite.SRC, (float) 0.5); + float alpha = ac.getAlpha(); + + ac = AlphaComposite.getInstance(AlphaComposite.SRC, (float) 0.5); + int rule = ac.getRule(); + + ac = AlphaComposite.getInstance(AlphaComposite.SRC, (float) 0.5); + int hc = ac.hashCode(); + } +} diff --git a/jdk/test/java/awt/Color/HeadlessColor.java b/jdk/test/java/awt/Color/HeadlessColor.java new file mode 100644 index 00000000000..a7b23eff0ba --- /dev/null +++ b/jdk/test/java/awt/Color/HeadlessColor.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.color.ColorSpace; + +/* + * @test + * @summary Check Color constructors and methods works correctly in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessColor + */ + +public class HeadlessColor { + public static void main(String args[]) { + Color c; + + // Constructors without exceptions + c = new Color(1, 2, 3); + c = new Color(1, 2, 3, 4); + c = new Color((1 << 16) | (2 << 8) | (3)); + c = new Color((1 << 24) | (1 << 16) | (2 << 8) | (3)); + c = new Color((1 << 24) | (2 << 16) | (3 << 8) | (4), true); + c = new Color((2 << 16) | (3 << 8) | (4), false); + c = new Color(0.8f, 0.8f, 0.3f); + c = new Color(0.999f, 0.8f, 0.8f, 0.3f); + c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), + new float[]{0.8f, 0.8f, 0.3f}, 1f); + + // Constructors with exceptions + boolean exceptions = false; + try { + c = new Color(409, 400, 400); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(400, 3003, 400, 400); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(8f, 8f, 3f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(-8f, -8f, -3f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(0.999f, 8f, 8f, 3f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(20f, 8f, 8f, 3f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(-20f, -8f, -8f, -3f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), + new float[]{-8f, -8f, -3f}, 1f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + exceptions = false; + try { + c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), + new float[]{-8f, -8f, -3f}, -1f); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException " + + "when expected in headless mode"); + + + c = new Color(1, 2, 3); + c.hashCode(); + c.toString(); + if (c.getRed() != 1) + throw new RuntimeException("Incorrect red value"); + if (c.getGreen() != 2) + throw new RuntimeException("Incorrect green value"); + if (c.getBlue() != 3) + throw new RuntimeException("Incorrect bluevalue"); + if (c.getAlpha() != 255) + throw new RuntimeException("Incorrect alpha value"); + if (c.getRGB() != ((255 << 24) | (1 << 16) | (2 << 8) | (3))) + throw new RuntimeException("Incorrect rgb value"); + + int rgb = c.getRGB(); + c.brighter(); + if (rgb != c.getRGB()) + throw new RuntimeException("Color object changed RGB value after brighter() called"); + + rgb = c.getRGB(); + c.darker(); + if (rgb != c.getRGB()) + throw new RuntimeException("Color object changed RGB value after brighter() called"); + + c = new Color(1, 2, 3, 4); + c.hashCode(); + c.toString(); + if (c.getRed() != 1) + throw new RuntimeException("Incorrect red value"); + if (c.getGreen() != 2) + throw new RuntimeException("Incorrect green value"); + if (c.getBlue() != 3) + throw new RuntimeException("Incorrect bluevalue"); + if (c.getAlpha() != 4) + throw new RuntimeException("Incorrect alpha value"); + if (c.getRGB() != ((4 << 24) | (1 << 16) | (2 << 8) | (3))) + throw new RuntimeException("Incorrect rgb value"); + + rgb = c.getRGB(); + c.brighter(); + if (rgb != c.getRGB()) + throw new RuntimeException("Color object changed RGB value after brighter() called"); + + rgb = c.getRGB(); + c.darker(); + if (rgb != c.getRGB()) + throw new RuntimeException("Color object changed RGB value after brighter() called"); + + + if (!(new Color(1, 2, 3).equals(new Color(1, 2, 3)))) + throw new RuntimeException("Inequality in colors when equality expected"); + if (new Color(1, 2, 3).equals(new Color(3, 2, 1))) + throw new RuntimeException("Equality in colors when NO equality expected"); + + if (!(new Color(1, 2, 3, 4).equals(new Color(1, 2, 3, 4)))) + throw new RuntimeException("Inequality in colors when equality expected"); + if (new Color(1, 2, 3, 4).equals(new Color(4, 3, 2, 1))) + throw new RuntimeException("Equality in colors when NO equality expected"); + + c = Color.decode("0xffffff"); + c = Color.getColor("65535"); + c = Color.getColor("65535", Color.black); + c = Color.getColor("65535", 0xffffff); + + int hsb_value = Color.HSBtoRGB(0.1f, 0.2f, 0.3f); + float[] rgb_value = Color.RGBtoHSB(1, 2, 3, null); + + c = Color.getHSBColor(0.3f, 0.4f, 0.6f); + c = Color.getHSBColor(-0.3f, -0.4f, -0.6f); + c = Color.getHSBColor(30, 40, 60); + + float[] comps; + comps = Color.black.getRGBComponents(null); + comps = Color.black.getRGBColorComponents(null); + comps = Color.black.getComponents(null); + comps = Color.black.getColorComponents(null); + comps = Color.black.getComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null); + comps = Color.black.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null); + + Color.black.getColorSpace(); + Color.black.getTransparency(); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessButton.java b/jdk/test/java/awt/Component/Headless/HeadlessButton.java new file mode 100644 index 00000000000..66bfc5d2d43 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessButton.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check whether Button constructors throw HeadlessException in + * headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessButton + */ + +public class HeadlessButton { + + public static void main(String args[]) { + Button b; + + boolean exceptions = false; + try { + b = new Button(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + + exceptions = false; + try { + b = new Button("Press me"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessCanvas.java b/jdk/test/java/awt/Component/Headless/HeadlessCanvas.java new file mode 100644 index 00000000000..65d9701a642 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessCanvas.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check whether Canvas constructor does not throw exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCanvas + */ + +public class HeadlessCanvas { + public static void main(String args[]) { + Canvas c = new Canvas(); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessCheckbox.java b/jdk/test/java/awt/Component/Headless/HeadlessCheckbox.java new file mode 100644 index 00000000000..b83abc7203c --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessCheckbox.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Checkbox constructors trow HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCheckbox + */ + +public class HeadlessCheckbox { + public static void main(String args[]) { + Checkbox b; + + boolean exceptions = false; + try { + b = new Checkbox(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + CheckboxGroup cbg = new CheckboxGroup(); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", true, cbg); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", false, cbg); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", cbg, true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + b = new Checkbox("Hey, check it out!", cbg, false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessChoice.java b/jdk/test/java/awt/Component/Headless/HeadlessChoice.java new file mode 100644 index 00000000000..18733984314 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessChoice.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Choice constructor throws HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessChoice + */ + +public class HeadlessChoice { + + public static void main(String args[]) { + boolean exceptions = false; + try { + Choice c = new Choice(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessComponent.java b/jdk/test/java/awt/Component/Headless/HeadlessComponent.java new file mode 100644 index 00000000000..fb25da2b35e --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessComponent.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.event.*; +import java.util.Locale; + +/* + * @test + * @summary Check that Component methods do not throw unexpected exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessComponent + */ + +public class HeadlessComponent { + public static void main(String args[]) { + Component comp = new Component(){}; + comp.addComponentListener(new ComponentAdapter() {}); + comp.addFocusListener(new FocusAdapter(){}); + comp.addHierarchyBoundsListener(new HierarchyBoundsAdapter(){}); + comp.addHierarchyListener(e -> {}); + comp.addInputMethodListener(new InputMethodListener() { + public void inputMethodTextChanged(InputMethodEvent event) {} + public void caretPositionChanged(InputMethodEvent event) {} + }); + comp.addKeyListener(new KeyAdapter() {}); + comp.addMouseListener(new MouseAdapter() {}); + comp.addMouseMotionListener(new MouseMotionAdapter() {}); + comp.addMouseWheelListener(e -> {}); + comp.addPropertyChangeListener(e -> {}); + comp.addNotify(); + comp.getName(); + comp.setName("goober"); + comp.getParent(); + comp.getPeer(); + comp.getGraphicsConfiguration(); + comp.getTreeLock(); + comp.getToolkit(); + comp.isValid(); + comp.isDisplayable(); + comp.isVisible(); + comp.isShowing(); + comp.isEnabled(); + comp.setEnabled(false); + comp.setEnabled(true); + comp.enable(); + comp.enable(false); + comp.enable(true); + comp.disable(); + comp.isDoubleBuffered(); + comp.enableInputMethods(false); + comp.enableInputMethods(true); + comp.setVisible(false); + comp.setVisible(true); + comp.show(); + comp.show(false); + comp.show(true); + comp.hide(); + comp.getForeground(); + comp.setForeground(Color.red); + comp.isForegroundSet(); + comp.getBackground(); + comp.setBackground(Color.red); + comp.isBackgroundSet(); + comp.getFont(); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int i = 8; i < 17; i++) { + Font f1 = new Font(font, Font.PLAIN, i); + Font f2 = new Font(font, Font.BOLD, i); + Font f3 = new Font(font, Font.ITALIC, i); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, i); + + comp.setFont(f1); + comp.getFontMetrics(f1); + comp.setFont(f2); + comp.getFontMetrics(f2); + comp.setFont(f3); + comp.getFontMetrics(f3); + comp.setFont(f4); + comp.getFontMetrics(f4); + } + } + comp.isFontSet(); + + boolean exceptions = false; + try { + Container c = new Container(); + c.add(comp); + comp.getLocale(); + } catch (IllegalComponentStateException ex) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + for (Locale locale : Locale.getAvailableLocales()) + comp.setLocale(locale); + + comp.getColorModel(); + comp.getLocation(); + + exceptions = false; + try { + comp = new Component(){}; + comp.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + comp.location(); + comp.setLocation(1, 2); + comp.move(1, 2); + comp.setLocation(new Point(1, 2)); + comp.getSize(); + comp.size(); + comp.setSize(1, 32); + comp.resize(1, 32); + comp.setSize(new Dimension(1, 32)); + comp.resize(new Dimension(1, 32)); + comp.getBounds(); + comp.bounds(); + comp.setBounds(10, 10, 10, 10); + comp.reshape(10, 10, 10, 10); + comp.setBounds(new Rectangle(10, 10, 10, 10)); + comp.getX(); + comp.getY(); + comp.getWidth(); + comp.getHeight(); + comp.getBounds(new Rectangle(1, 1, 1, 1)); + comp.getSize(new Dimension(1, 2)); + comp.getLocation(new Point(1, 2)); + comp.isOpaque(); + comp.isLightweight(); + comp.getPreferredSize(); + comp.preferredSize(); + comp.getMinimumSize(); + comp.minimumSize(); + comp.getMaximumSize(); + comp.getAlignmentX(); + comp.getAlignmentY(); + comp.doLayout(); + comp.layout(); + comp.validate(); + comp.invalidate(); + comp.getGraphics(); + Cursor c = new Cursor(Cursor.CROSSHAIR_CURSOR); + comp.setCursor(c); + comp.getCursor(); + comp.isCursorSet(); + comp.contains(1, 2); + comp.inside(1, 2); + comp.contains(new Point(1, 2)); + comp.getComponentAt(1, 2); + comp.locate(1, 2); + comp.getComponentAt(new Point(1, 2)); + comp.isFocusTraversable(); + comp.isFocusable(); + comp.setFocusable(true); + comp.setFocusable(false); + comp.requestFocus(); + comp.requestFocusInWindow(); + comp.transferFocus(); + comp.getFocusCycleRootAncestor(); + comp.isFocusCycleRoot(new Container()); + comp.nextFocus(); + comp.transferFocusBackward(); + comp.transferFocusUpCycle(); + comp.hasFocus(); + comp.isFocusOwner(); + comp.toString(); + comp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + comp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + comp.setComponentOrientation(ComponentOrientation.UNKNOWN); + comp.getComponentOrientation(); + comp.getAccessibleContext(); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessContainer.java b/jdk/test/java/awt/Component/Headless/HeadlessContainer.java new file mode 100644 index 00000000000..bb4b00d7f0c --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessContainer.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.util.*; + +/* + * @test + * @summary Check that Container methods do not throw unexpected exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessContainer + */ + +public class HeadlessContainer { + public static void main(String args[]) { + Container lw = new java.awt.Container(); + Component c1 = lw.add(new Component(){}); + Component c2 = lw.add(new Component(){}); + Component c3 = lw.add(new Component(){}); + + lw.getComponentCount(); + lw.countComponents(); + lw.getComponent(1); + lw.getComponent(2); + Component[] cs = lw.getComponents(); + Insets ins = lw.getInsets(); + ins = lw.insets(); + lw.remove(1); + lw.remove((java.awt.Component) c2); + lw.removeAll(); + + lw.add(c1); + lw.add(c2); + lw.add(c3); + lw.getLayout(); + lw.setLayout(new FlowLayout()); + lw.doLayout(); + lw.layout(); + lw.invalidate(); + lw.validate(); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int i = 8; i < 17; i++) { + Font f1 = new Font(font, Font.PLAIN, i); + Font f2 = new Font(font, Font.BOLD, i); + Font f3 = new Font(font, Font.ITALIC, i); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, i); + + lw.setFont(f1); + lw.setFont(f2); + lw.setFont(f3); + lw.setFont(f4); + } + } + lw.getPreferredSize(); + lw.preferredSize(); + lw.getMinimumSize(); + lw.minimumSize(); + lw.getMaximumSize(); + lw.getAlignmentX(); + lw.getAlignmentY(); + lw.getComponentAt(1, 2); + lw.locate(1, 2); + lw.getComponentAt(new Point(1, 2)); + lw.isFocusCycleRoot(new Container()); + lw.transferFocusBackward(); + lw.getName(); + lw.setName("goober"); + lw.getName(); + lw.getParent(); + lw.getPeer(); + lw.getGraphicsConfiguration(); + lw.getTreeLock(); + lw.getToolkit(); + lw.isValid(); + lw.isDisplayable(); + lw.isVisible(); + lw.isShowing(); + lw.isEnabled(); + lw.setEnabled(false); + lw.setEnabled(true); + lw.enable(); + lw.enable(false); + lw.enable(true); + lw.disable(); + lw.isDoubleBuffered(); + lw.enableInputMethods(false); + lw.enableInputMethods(true); + lw.setVisible(false); + lw.setVisible(true); + lw.show(); + lw.show(false); + lw.show(true); + lw.hide(); + lw.getForeground(); + lw.setForeground(Color.red); + lw.isForegroundSet(); + lw.getBackground(); + lw.setBackground(Color.red); + lw.isBackgroundSet(); + lw.getFont(); + lw.isFontSet(); + + boolean exceptions = false; + try { + Container c = new Container(); + lw = new java.awt.Container(); + c.add(lw); + lw.getLocale(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + for (Locale locale : Locale.getAvailableLocales()) + lw.setLocale(locale); + + lw.getColorModel(); + lw.getLocation(); + + exceptions = false; + try { + lw.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + lw.location(); + lw.setLocation(1, 2); + lw.move(1, 2); + lw.setLocation(new Point(1, 2)); + lw.getSize(); + lw.size(); + lw.setSize(1, 32); + lw.resize(1, 32); + lw.setSize(new Dimension(1, 32)); + lw.resize(new Dimension(1, 32)); + lw.getBounds(); + lw.bounds(); + lw.setBounds(10, 10, 10, 10); + lw.reshape(10, 10, 10, 10); + lw.setBounds(new Rectangle(10, 10, 10, 10)); + lw.getX(); + lw.getY(); + lw.getWidth(); + lw.getHeight(); + lw.getBounds(new Rectangle(1, 1, 1, 1)); + lw.getSize(new Dimension(1, 2)); + lw.getLocation(new Point(1, 2)); + lw.isOpaque(); + lw.isLightweight(); + lw.getGraphics(); + + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + lw.getFontMetrics(f1); + lw.getFontMetrics(f2); + lw.getFontMetrics(f3); + lw.getFontMetrics(f4); + } + } + + Cursor c = new Cursor(Cursor.CROSSHAIR_CURSOR); + lw.setCursor(c); + lw.getCursor(); + lw.isCursorSet(); + lw.contains(1, 2); + lw.inside(1, 2); + lw.contains(new Point(1, 2)); + lw.isFocusTraversable(); + lw.isFocusable(); + lw.setFocusable(true); + lw.setFocusable(false); + lw.requestFocus(); + lw.requestFocusInWindow(); + lw.transferFocus(); + lw.getFocusCycleRootAncestor(); + lw.nextFocus(); + lw.transferFocusUpCycle(); + lw.hasFocus(); + lw.isFocusOwner(); + lw.toString(); + lw.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + lw.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + lw.setComponentOrientation(ComponentOrientation.UNKNOWN); + lw.getComponentOrientation(); + lw.getAccessibleContext(); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessDialog.java b/jdk/test/java/awt/Component/Headless/HeadlessDialog.java new file mode 100644 index 00000000000..55b0525fdbb --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessDialog.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Dialog constructors throw expected HeadlessException + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDialog + */ + +public class HeadlessDialog { + public static void main(String args[]) { + boolean exceptions = false; + Dialog d; + + try { + d = new Dialog(new Frame("Hi there")); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new Dialog(new Frame("Hi there"), true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new Dialog(new Frame("Hi there"), false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new Dialog(new Frame("Hi there"), "Dialog title"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new Dialog(new Frame("Hi there"), "Dialog title", true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new Dialog(new Frame("Hi there"), "Dialog title", false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessFileDialog.java b/jdk/test/java/awt/Component/Headless/HeadlessFileDialog.java new file mode 100644 index 00000000000..7c39693d21d --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessFileDialog.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that FileDialog constructors throw HeadlessException + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessFileDialog + */ + +public class HeadlessFileDialog { + public static void main(String args[]) { + FileDialog d; + boolean exceptions = false; + try { + d = new FileDialog(new Frame("Hi there")); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new FileDialog(new Frame("Hi there"), "Dialog title"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new FileDialog(new Frame("Hi there"), "Dialog title", FileDialog.LOAD); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + d = new FileDialog(new Frame("Hi there"), "Dialog title", FileDialog.SAVE); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessFrame.java b/jdk/test/java/awt/Component/Headless/HeadlessFrame.java new file mode 100644 index 00000000000..f85ad57e792 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessFrame.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Font constructors and throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessFrame + */ + +public class HeadlessFrame { + public static void main(String args[]) { + Frame f; + boolean exceptions = false; + + try { + f = new Frame(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + f = new Frame("Frame me peculiar"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessLabel.java b/jdk/test/java/awt/Component/Headless/HeadlessLabel.java new file mode 100644 index 00000000000..1fcc1763126 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessLabel.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Label constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessLabel + */ + +public class HeadlessLabel { + public static void main(String args[]) { + Label l; + + boolean exceptions = false; + try { + l = new Label(); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new Label("Label me blue"); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new Label("Label me blue", 200); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessList.java b/jdk/test/java/awt/Component/Headless/HeadlessList.java new file mode 100644 index 00000000000..652de8f4722 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessList.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that List constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessList + */ + +public class HeadlessList { + public static void main(String args[]) { + List l; + + boolean exceptions = false; + try { + l = new List(); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(10); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(1000); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(10, true); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(10, false); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(1000, true); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + l = new List(1000, false); + } catch (java.awt.HeadlessException java_awt_HeadlessException) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessPanel.java b/jdk/test/java/awt/Component/Headless/HeadlessPanel.java new file mode 100644 index 00000000000..65b809c898d --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessPanel.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that Panel constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPanel + */ + +public class HeadlessPanel { + public static void main(String args[]) { + Panel p; + p = new Panel(); + p = new Panel(new FlowLayout()); + p.getAccessibleContext(); + Component c1 = p.add(new Component(){}); + Component c2 = p.add(new Component(){}); + Component c3 = p.add(new Component(){}); + p.getComponentCount(); + p.countComponents(); + p.getComponent(1); + p.getComponent(2); + Component[] cs = p.getComponents(); + Insets ins = p.getInsets(); + ins = p.insets(); + p.remove(0); + p.remove((Component) c2); + p.removeAll(); + + p.add(c1); + p.add(c2); + p.add(c3); + p.getLayout(); + p.setLayout(new FlowLayout()); + p.doLayout(); + p.layout(); + p.invalidate(); + p.validate(); + + p.getPreferredSize(); + p.preferredSize(); + p.getMinimumSize(); + p.minimumSize(); + p.getMaximumSize(); + p.getAlignmentX(); + p.getAlignmentY(); + p.getComponentAt(1, 2); + p.locate(1, 2); + p.getComponentAt(new Point(1, 2)); + p.isFocusCycleRoot(new Container()); + p.transferFocusBackward(); + p.setName("goober"); + p.getName(); + p.getParent(); + p.getPeer(); + p.getGraphicsConfiguration(); + p.getTreeLock(); + p.getToolkit(); + p.isValid(); + p.isDisplayable(); + p.isVisible(); + p.isShowing(); + p.isEnabled(); + p.setEnabled(false); + p.setEnabled(true); + p.enable(); + p.enable(false); + p.enable(true); + p.disable(); + p.isDoubleBuffered(); + p.enableInputMethods(false); + p.enableInputMethods(true); + p.setVisible(false); + p.setVisible(true); + p.show(); + p.show(false); + p.show(true); + p.hide(); + p.getForeground(); + p.setForeground(Color.red); + p.isForegroundSet(); + p.getBackground(); + p.setBackground(Color.red); + p.isBackgroundSet(); + p.getFont(); + p.isFontSet(); + p.getColorModel(); + p.getLocation(); + p.location(); + p.setLocation(1, 2); + p.move(1, 2); + p.setLocation(new Point(1, 2)); + p.getSize(); + p.size(); + p.setSize(1, 32); + p.resize(1, 32); + p.setSize(new Dimension(1, 32)); + p.resize(new Dimension(1, 32)); + p.getBounds(); + p.bounds(); + p.setBounds(10, 10, 10, 10); + p.reshape(10, 10, 10, 10); + p.setBounds(new Rectangle(10, 10, 10, 10)); + p.getX(); + p.getY(); + p.getWidth(); + p.getHeight(); + p.getBounds(new Rectangle(1, 1, 1, 1)); + p.getSize(new Dimension(1, 2)); + p.getLocation(new Point(1, 2)); + p.isOpaque(); + p.isLightweight(); + p.getGraphics(); + + + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + p.setFont(f1); + p.setFont(f2); + p.setFont(f3); + p.setFont(f4); + } + } + + boolean exceptions = false; + try { + Container c = new Container(); + p = new Panel(); + c.add(p); + p.getLocale(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + for (Locale locale : Locale.getAvailableLocales()) + p.setLocale(locale); + + exceptions = false; + try { + p.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j + < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + p.getFontMetrics(f1); + p.getFontMetrics(f2); + p.getFontMetrics(f3); + p.getFontMetrics(f4); + } + } + + Cursor c = new Cursor(Cursor.CROSSHAIR_CURSOR); + p.setCursor(c); + p.getCursor(); + p.isCursorSet(); + p.contains(1, 2); + p.inside(1, 2); + p.contains(new Point(1, 2)); + p.isFocusTraversable(); + p.isFocusable(); + p.setFocusable(true); + p.setFocusable(false); + p.requestFocus(); + p.requestFocusInWindow(); + p.transferFocus(); + p.getFocusCycleRootAncestor(); + p.nextFocus(); + p.transferFocusUpCycle(); + p.hasFocus(); + p.isFocusOwner(); + p.toString(); + p.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + p.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + p.setComponentOrientation(ComponentOrientation.UNKNOWN); + p.getComponentOrientation(); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessScrollPane.java b/jdk/test/java/awt/Component/Headless/HeadlessScrollPane.java new file mode 100644 index 00000000000..2ce741e3c16 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessScrollPane.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that ScrollPane constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessScrollPane + */ + +public class HeadlessScrollPane { + public static void main(String args[]) { + ScrollPane s; + boolean exceptions = false; + + try { + s = new ScrollPane(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new ScrollPane(ScrollPane.SCROLLBARS_NEVER); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessScrollbar.java b/jdk/test/java/awt/Component/Headless/HeadlessScrollbar.java new file mode 100644 index 00000000000..a7eb9eab7f2 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessScrollbar.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Scrollbar constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessScrollbar + */ + +public class HeadlessScrollbar { + + public static void main(String args[]) { + Scrollbar s; + boolean exceptions = false; + + try { + s = new Scrollbar(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new Scrollbar(Scrollbar.HORIZONTAL); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new Scrollbar(Scrollbar.VERTICAL); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new Scrollbar(Scrollbar.HORIZONTAL, 1, 10, 0, 100); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + s = new Scrollbar(Scrollbar.VERTICAL, 1, 10, 0, 100); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessTextArea.java b/jdk/test/java/awt/Component/Headless/HeadlessTextArea.java new file mode 100644 index 00000000000..18fdd13bea5 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessTextArea.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that TextArea constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessTextArea + */ + +public class HeadlessTextArea { + public static void main(String args[]) { + TextArea t; + boolean exceptions = false; + + try { + t = new TextArea(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea(10, 100); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there", 10, 100); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there", 10, 100, TextArea.SCROLLBARS_BOTH); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there", 10, 100, TextArea.SCROLLBARS_HORIZONTAL_ONLY); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there", 10, 100, TextArea.SCROLLBARS_VERTICAL_ONLY); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextArea("Hi there", 10, 100, TextArea.SCROLLBARS_NONE); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessTextField.java b/jdk/test/java/awt/Component/Headless/HeadlessTextField.java new file mode 100644 index 00000000000..2f57f53b8c6 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessTextField.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that TextField constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessTextField + */ + +public class HeadlessTextField { + public static void main(String args[]) { + TextField t; + boolean exceptions = false; + + try { + t = new TextField(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextField("Hi there"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + try { + t = new TextField(20); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextField(200); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + try { + t = new TextField("Hi there", 20); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + t = new TextField("Hi there", 200); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Component/Headless/HeadlessWindow.java b/jdk/test/java/awt/Component/Headless/HeadlessWindow.java new file mode 100644 index 00000000000..cd123d05568 --- /dev/null +++ b/jdk/test/java/awt/Component/Headless/HeadlessWindow.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Window constructor throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessWindow + */ + +public class HeadlessWindow { + public static void main(String args[]) { + boolean exceptions = false; + try { + Window b = new Window(new Frame("Hi there")); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Cursor/HeadlessCursor.java b/jdk/test/java/awt/Cursor/HeadlessCursor.java new file mode 100644 index 00000000000..ccb27179cc8 --- /dev/null +++ b/jdk/test/java/awt/Cursor/HeadlessCursor.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Cursor constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCursor + */ + +public class HeadlessCursor { + public static void main(String args[]) { + Cursor c; + c = new Cursor(Cursor.CROSSHAIR_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.DEFAULT_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.E_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.HAND_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.N_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.NE_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.NW_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.S_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.SE_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.SW_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.TEXT_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.W_RESIZE_CURSOR); + c.getType(); + c.getName(); + c = new Cursor(Cursor.WAIT_CURSOR); + c.getType(); + c.getName(); + + c = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR); + c = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); + c = Cursor.getDefaultCursor(); + c.getType(); + c.getName(); + } +} diff --git a/jdk/test/java/awt/EventQueue/HeadlessEventQueue.java b/jdk/test/java/awt/EventQueue/HeadlessEventQueue.java new file mode 100644 index 00000000000..877b108e376 --- /dev/null +++ b/jdk/test/java/awt/EventQueue/HeadlessEventQueue.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that EventQueue constructor does not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessEventQueue + */ + +public class HeadlessEventQueue { + public static void main(String args[]) { + EventQueue eq = new EventQueue(); + } +} diff --git a/jdk/test/java/awt/Focus/Headless/HeadlessContainerOrderFocusTraversalPolicy.java b/jdk/test/java/awt/Focus/Headless/HeadlessContainerOrderFocusTraversalPolicy.java new file mode 100644 index 00000000000..4254e50fec5 --- /dev/null +++ b/jdk/test/java/awt/Focus/Headless/HeadlessContainerOrderFocusTraversalPolicy.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that ContainerOrderFocusTraversalPolicy constructor and + * methods do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessContainerOrderFocusTraversalPolicy + */ + +public class HeadlessContainerOrderFocusTraversalPolicy { + + public static void main(String args[]) { + ContainerOrderFocusTraversalPolicy cot = new ContainerOrderFocusTraversalPolicy(); + + Container c = new Container(); + Component cb1; + Component cb2; + Component cb3; + + c.setFocusCycleRoot(true); + c.setFocusTraversalPolicy(cot); + c.add(cb1 = new Component(){}); + c.add(cb2 = new Component(){}); + c.add(cb3 = new Component(){}); + + cot.getComponentAfter(c, cb1); + cot.getComponentAfter(c, cb2); + cot.getComponentAfter(c, cb3); + + cot.getComponentBefore(c, cb1); + cot.getComponentBefore(c, cb2); + cot.getComponentBefore(c, cb3); + + cot.getFirstComponent(c); + + cot.getLastComponent(c); + + cot.getDefaultComponent(c); + cot.setImplicitDownCycleTraversal(true); + cot.setImplicitDownCycleTraversal(false); + cot.getImplicitDownCycleTraversal(); + } +} diff --git a/jdk/test/java/awt/Focus/Headless/HeadlessDefaultFocusTraversalPolicy.java b/jdk/test/java/awt/Focus/Headless/HeadlessDefaultFocusTraversalPolicy.java new file mode 100644 index 00000000000..100212746b9 --- /dev/null +++ b/jdk/test/java/awt/Focus/Headless/HeadlessDefaultFocusTraversalPolicy.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that DefaultFocusTraversalPolicy constructor and + * methods do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDefaultFocusTraversalPolicy + */ + +public class HeadlessDefaultFocusTraversalPolicy { + public static void main(String args[]) { + Container c = new Container(); + Component cb1; + Component cb2; + Component cb3; + + DefaultFocusTraversalPolicy cot = new DefaultFocusTraversalPolicy(); + c.setFocusCycleRoot(true); + c.setFocusTraversalPolicy(cot); + c.add(cb1 = new Component(){}); + c.add(cb2 = new Component(){}); + c.add(cb3 = new Component(){}); + + cot.getComponentAfter(c, cb1); + cot.getComponentAfter(c, cb2); + cot.getComponentAfter(c, cb3); + + cot.getComponentBefore(c, cb1); + cot.getComponentBefore(c, cb2); + cot.getComponentBefore(c, cb3); + + cot.getFirstComponent(c); + + cot.getLastComponent(c); + + cot.getDefaultComponent(c); + + cot.setImplicitDownCycleTraversal(true); + + cot.setImplicitDownCycleTraversal(false); + + cot.getImplicitDownCycleTraversal(); + } +} diff --git a/jdk/test/java/awt/Focus/Headless/HeadlessDefaultKeyboardFocusManager.java b/jdk/test/java/awt/Focus/Headless/HeadlessDefaultKeyboardFocusManager.java new file mode 100644 index 00000000000..637deea4404 --- /dev/null +++ b/jdk/test/java/awt/Focus/Headless/HeadlessDefaultKeyboardFocusManager.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that DefaultKeyboardFocusManager constructor does not + * throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDefaultKeyboardFocusManager + */ + +public class HeadlessDefaultKeyboardFocusManager { + public static void main(String args[]) { + DefaultKeyboardFocusManager dfk = new DefaultKeyboardFocusManager(); + } +} diff --git a/jdk/test/java/awt/FontClass/HeadlessFont.java b/jdk/test/java/awt/FontClass/HeadlessFont.java new file mode 100644 index 00000000000..e9eba8836e9 --- /dev/null +++ b/jdk/test/java/awt/FontClass/HeadlessFont.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.font.TextAttribute; +import java.awt.geom.AffineTransform; +import java.text.AttributedCharacterIterator; +import java.text.StringCharacterIterator; +import java.util.HashMap; +import java.util.Map; + +/* + * @test + * @summary Check that Font constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessFont + */ + +public class HeadlessFont { + + public static void main(String args[]) { + HashMap attMap = new HashMap(); + attMap.put(TextAttribute.FAMILY, "Helvetica Bold"); + attMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_LIGHT); + attMap.put(TextAttribute.WIDTH, TextAttribute.WIDTH_REGULAR); + attMap.put(TextAttribute.SIZE, new Float(20)); + attMap.put(TextAttribute.FOREGROUND, Color.white); + attMap.put(TextAttribute.BACKGROUND, Color.black); + + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int i = 8; i < 17; i++) { + Font f1 = new Font(font, Font.PLAIN, i); + Font f2 = new Font(font, Font.BOLD, i); + Font f3 = new Font(font, Font.ITALIC, i); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, i); + + FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(f1); + metrics = Toolkit.getDefaultToolkit().getFontMetrics(f2); + metrics = Toolkit.getDefaultToolkit().getFontMetrics(f3); + metrics = Toolkit.getDefaultToolkit().getFontMetrics(f4); + + AffineTransform trans = f1.getTransform(); + trans = f2.getTransform(); + trans = f3.getTransform(); + trans = f4.getTransform(); + + String str; + str = f1.getFamily(); + str = f2.getFamily(); + str = f3.getFamily(); + str = f4.getFamily(); + + str = f1.getPSName(); + str = f2.getPSName(); + str = f3.getPSName(); + str = f4.getPSName(); + + str = f1.getName(); + str = f2.getName(); + str = f3.getName(); + str = f4.getName(); + + str = f1.getFontName(); + str = f2.getFontName(); + str = f3.getFontName(); + str = f4.getFontName(); + + str = f1.toString(); + str = f2.toString(); + str = f3.toString(); + str = f4.toString(); + + int s; + s = f1.getStyle(); + s = f2.getStyle(); + s = f3.getStyle(); + s = f4.getStyle(); + + s = f1.getSize(); + s = f2.getSize(); + s = f3.getSize(); + s = f4.getSize(); + + s = f1.hashCode(); + s = f2.hashCode(); + s = f3.hashCode(); + s = f4.hashCode(); + + s = f1.getNumGlyphs(); + s = f2.getNumGlyphs(); + s = f3.getNumGlyphs(); + s = f4.getNumGlyphs(); + + s = f1.getMissingGlyphCode(); + s = f2.getMissingGlyphCode(); + s = f3.getMissingGlyphCode(); + s = f4.getMissingGlyphCode(); + + float f; + f = f1.getSize2D(); + f = f2.getSize2D(); + f = f3.getSize2D(); + f = f4.getSize2D(); + + + byte b; + b = f1.getBaselineFor('c'); + b = f2.getBaselineFor('c'); + b = f3.getBaselineFor('c'); + b = f4.getBaselineFor('c'); + + Map m = f1.getAttributes(); + m = f2.getAttributes(); + m = f3.getAttributes(); + m = f4.getAttributes(); + + AttributedCharacterIterator.Attribute[] a; + a = f1.getAvailableAttributes(); + a = f2.getAvailableAttributes(); + a = f3.getAvailableAttributes(); + a = f4.getAvailableAttributes(); + + + Font fnt; + fnt = f1.deriveFont(Font.BOLD | Font.ITALIC, (float) 80); + fnt = f2.deriveFont(Font.BOLD | Font.ITALIC, (float) 80); + fnt = f3.deriveFont(Font.BOLD | Font.ITALIC, (float) 80); + fnt = f4.deriveFont(Font.BOLD | Font.ITALIC, (float) 80); + + fnt = f1.deriveFont(80f); + fnt = f2.deriveFont(80f); + fnt = f3.deriveFont(80f); + fnt = f4.deriveFont(80f); + + fnt = f1.deriveFont(Font.BOLD | Font.ITALIC); + fnt = f2.deriveFont(Font.BOLD | Font.ITALIC); + fnt = f3.deriveFont(Font.BOLD | Font.ITALIC); + fnt = f4.deriveFont(Font.BOLD | Font.ITALIC); + + fnt = f1.deriveFont(attMap); + fnt = f2.deriveFont(attMap); + fnt = f3.deriveFont(attMap); + fnt = f4.deriveFont(attMap); + + + if (!f1.isPlain()) + throw new RuntimeException("Plain font " + f1.getName() + " says it's not plain"); + if (f2.isPlain()) + throw new RuntimeException("Bold font " + f1.getName() + " says it is plain"); + if (f3.isPlain()) + throw new RuntimeException("Italic font " + f1.getName() + " says it is plain"); + if (f4.isPlain()) + throw new RuntimeException("Bold|Italic font " + f1.getName() + " says it is plain"); + + if (f1.isBold()) + throw new RuntimeException("Plain font " + f1.getName() + " says it is bold"); + if (!f2.isBold()) + throw new RuntimeException("Bold font " + f1.getName() + " says it's not bold"); + if (f3.isBold()) + throw new RuntimeException("Italic font " + f1.getName() + " says it is bold"); + if (!f4.isBold()) + throw new RuntimeException("Bold|Italic font " + f1.getName() + " says it's not bold"); + + if (f1.isItalic()) + throw new RuntimeException("Plain font " + f1.getName() + " says it is italic"); + if (f2.isItalic()) + throw new RuntimeException("Bold font " + f1.getName() + " says it is italic"); + if (!f3.isItalic()) + throw new RuntimeException("Italic font " + f1.getName() + " says it's not italic"); + if (!f4.isItalic()) + throw new RuntimeException("Bold|Italic font " + f1.getName() + " says it's not italic"); + + f1.canDisplay('~'); + f2.canDisplay('~'); + f3.canDisplay('~'); + f4.canDisplay('~'); + f1.canDisplay('c'); + f2.canDisplay('c'); + f3.canDisplay('c'); + f4.canDisplay('c'); + + f1.canDisplayUpTo("canDisplayUpTo"); + f2.canDisplayUpTo("canDisplayUpTo"); + f3.canDisplayUpTo("canDisplayUpTo"); + f4.canDisplayUpTo("canDisplayUpTo"); + + str = "canDisplayUpTo"; + f1.canDisplayUpTo(str.toCharArray(), 0, str.length()); + f2.canDisplayUpTo(str.toCharArray(), 0, str.length()); + f3.canDisplayUpTo(str.toCharArray(), 0, str.length()); + f4.canDisplayUpTo(str.toCharArray(), 0, str.length()); + + f1.canDisplayUpTo(new StringCharacterIterator(str), 0, str.length()); + f2.canDisplayUpTo(new StringCharacterIterator(str), 0, str.length()); + f3.canDisplayUpTo(new StringCharacterIterator(str), 0, str.length()); + f4.canDisplayUpTo(new StringCharacterIterator(str), 0, str.length()); + + f1.getItalicAngle(); + f2.getItalicAngle(); + f3.getItalicAngle(); + f4.getItalicAngle(); + + f1.hasUniformLineMetrics(); + f2.hasUniformLineMetrics(); + f3.hasUniformLineMetrics(); + f4.hasUniformLineMetrics(); + + f1.getPeer(); + f2.getPeer(); + f3.getPeer(); + f4.getPeer(); + } + } + + Font f = new Font(attMap); + f = Font.getFont(attMap); + f = Font.decode(null); + } +} diff --git a/jdk/test/java/awt/GradientPaint/HeadlessGradientPaint.java b/jdk/test/java/awt/GradientPaint/HeadlessGradientPaint.java new file mode 100644 index 00000000000..2f6faecf9c7 --- /dev/null +++ b/jdk/test/java/awt/GradientPaint/HeadlessGradientPaint.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that GradientPaint that constructors and methods do not + * throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessGradientPaint + */ + +public class HeadlessGradientPaint { + public static void main(String args[]) { + GradientPaint gp; + gp = new GradientPaint(10, 10, Color.red, 20, 20, Color.blue); + gp = new GradientPaint(new Point(10, 10), Color.red, new Point(20, 20), Color.blue); + gp = new GradientPaint(10, 10, Color.red, 20, 20, Color.blue, true); + gp = new GradientPaint(10, 10, Color.red, 20, 20, Color.blue, false); + gp = new GradientPaint(new Point(10, 10), Color.red, new Point(20, 20), Color.blue, true); + gp = new GradientPaint(new Point(10, 10), Color.red, new Point(20, 20), Color.blue, false); + + gp = new GradientPaint(10, 10, Color.red, 20, 20, Color.blue, false); + gp.getPoint1(); + gp.getColor1(); + gp.getPoint2(); + gp.getColor2(); + gp.isCyclic(); + gp.getTransparency(); + } +} diff --git a/jdk/test/java/awt/Graphics2D/Headless/HeadlessPoint.java b/jdk/test/java/awt/Graphics2D/Headless/HeadlessPoint.java new file mode 100644 index 00000000000..3fc74492c76 --- /dev/null +++ b/jdk/test/java/awt/Graphics2D/Headless/HeadlessPoint.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Point constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPoint + */ + +public class HeadlessPoint { + public static void main(String args[]) { + Point p; + p = new Point(); + p = new Point(new Point(1, 2)); + p = new Point(1, 2); + p.getX(); + p.getY(); + p.getLocation(); + p.setLocation(new Point(3, 4)); + } +} diff --git a/jdk/test/java/awt/Graphics2D/Headless/HeadlessPolygon.java b/jdk/test/java/awt/Graphics2D/Headless/HeadlessPolygon.java new file mode 100644 index 00000000000..11138158d6f --- /dev/null +++ b/jdk/test/java/awt/Graphics2D/Headless/HeadlessPolygon.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Polygon; + +/* + * @test + * @summary Check that Polygon constructor does not throw unexpected exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPolygon + */ + +public class HeadlessPolygon { + public static void main(String args[]) { + new Polygon(); + } +} diff --git a/jdk/test/java/awt/Graphics2D/Headless/HeadlessRectangle.java b/jdk/test/java/awt/Graphics2D/Headless/HeadlessRectangle.java new file mode 100644 index 00000000000..b71972375e8 --- /dev/null +++ b/jdk/test/java/awt/Graphics2D/Headless/HeadlessRectangle.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Rectangle constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessRectangle + */ + +public class HeadlessRectangle { + public static void main(String args[]) { + Rectangle r; + r = new Rectangle(); + r = new Rectangle(new Rectangle()); + r = new Rectangle(100, 200); + r = new Rectangle(new Point(100, 200), new Dimension(300, 400)); + r = new Rectangle(new Point(100, 200)); + r = new Rectangle(new Dimension(300, 400)); + r = new Rectangle(100, 200, 300, 400); + r.getX(); + r.getY(); + r.getWidth(); + r.getHeight(); + r.getBounds(); + r.getBounds2D(); + r.getLocation(); + r.getSize(); + r.contains(new Point(1, 2)); + r.contains(1, 2); + r.contains(new Rectangle(1, 2, 3, 4)); + r.contains(1, 2, 3, 4); + r.add(1, 2); + r.add(new Point(1, 2)); + r.add(new Rectangle(1, 2, 3, 4)); + r.grow(1, 2); + r.isEmpty(); + r.toString(); + r.hashCode(); + r.getMinX(); + r.getMinY(); + r.getMaxX(); + r.getMaxY(); + r.getCenterX(); + r.getCenterY(); + r.getFrame(); + } +} diff --git a/jdk/test/java/awt/GraphicsConfiguration/HeadlessGraphicsConfiguration.java b/jdk/test/java/awt/GraphicsConfiguration/HeadlessGraphicsConfiguration.java new file mode 100644 index 00000000000..c1efe666921 --- /dev/null +++ b/jdk/test/java/awt/GraphicsConfiguration/HeadlessGraphicsConfiguration.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; + +/* + * @test + * @summary Check that GraphicsConfiguration methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessGraphicsConfiguration + */ + +public class HeadlessGraphicsConfiguration { + public static void main(String args[]) { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Graphics2D gd = ge.createGraphics(new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR)); + GraphicsConfiguration gc = gd.getDeviceConfiguration(); + GraphicsDevice gdev = gc.getDevice(); + BufferedImage bi = gc.createCompatibleImage(100, 100); + bi = gc.createCompatibleImage(100, 100, Transparency.TRANSLUCENT); + + ColorModel cm = gc.getColorModel(); + cm = gc.getColorModel(Transparency.TRANSLUCENT); + + AffineTransform at = gc.getDefaultTransform(); + at = gc.getNormalizingTransform(); + + Rectangle r = gc.getBounds(); + } +} diff --git a/jdk/test/java/awt/GraphicsDevice/HeadlessGraphicsDevice.java b/jdk/test/java/awt/GraphicsDevice/HeadlessGraphicsDevice.java new file mode 100644 index 00000000000..3301f54ee05 --- /dev/null +++ b/jdk/test/java/awt/GraphicsDevice/HeadlessGraphicsDevice.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.image.BufferedImage; + +/* + * @test + * @summary Check that GraphicsDevice methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessGraphicsDevice + */ + +public class HeadlessGraphicsDevice { + public static void main(String args[]) { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Graphics2D gd = ge.createGraphics(new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR)); + GraphicsConfiguration gc = gd.getDeviceConfiguration(); + GraphicsDevice gdev = gc.getDevice(); + + for (GraphicsConfiguration gcl : gdev.getConfigurations()) + gcl.toString(); + + gdev.getDefaultConfiguration().toString(); + gdev.getIDstring(); + + if (gdev.getType() != GraphicsDevice.TYPE_IMAGE_BUFFER) + throw new RuntimeException("Created GraphicsDevice that should be IMAGE_BUFFER but it isn't"); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/HeadlessGraphicsEnvironment.java b/jdk/test/java/awt/GraphicsEnvironment/HeadlessGraphicsEnvironment.java new file mode 100644 index 00000000000..60e6ea230d1 --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/HeadlessGraphicsEnvironment.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.image.BufferedImage; + +/* + * @test + * @summary Check that GraphicsEnvironment methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessGraphicsEnvironment + */ + +public class HeadlessGraphicsEnvironment { + public static void main(String args[]) { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + if (!GraphicsEnvironment.isHeadless()) + throw new RuntimeException("GraphicsEnvironment.isHeadless says it's not headless mode when it is"); + + boolean exceptions = false; + try { + GraphicsDevice[] gdl = ge.getScreenDevices(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when excepted"); + + exceptions = false; + try { + GraphicsDevice gdl = ge.getDefaultScreenDevice(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when excepted"); + + Graphics2D gd = ge.createGraphics(new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR)); + + for (Font font : ge.getAllFonts()) { + for (float j = 8; j < 17; j++) { + Font f1 = font.deriveFont(Font.PLAIN, j); + Font f2 = font.deriveFont(Font.BOLD, j); + Font f3 = font.deriveFont(Font.ITALIC, j); + Font f4 = font.deriveFont(Font.BOLD | Font.ITALIC, j); + + f1.hasUniformLineMetrics(); + f2.hasUniformLineMetrics(); + f3.hasUniformLineMetrics(); + f4.hasUniformLineMetrics(); + } + } + + String[] fNames = ge.getAvailableFontFamilyNames(); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessAWTEventMulticaster.java b/jdk/test/java/awt/Headless/HeadlessAWTEventMulticaster.java new file mode 100644 index 00000000000..8459c84cb0b --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessAWTEventMulticaster.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.event.*; + +/* + * @test + * @summary Check for AWTEventMulticaster working in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAWTEventMulticaster + */ + +public class HeadlessAWTEventMulticaster { + class ComponentListenerImpl implements ComponentListener { + public boolean hidden = false; + public boolean moved = false; + public boolean resized = false; + public boolean shown = false; + + public void componentHidden(ComponentEvent e) { + hidden = true; + } + + public void componentMoved(ComponentEvent e) { + moved = true; + } + + public void componentResized(ComponentEvent e) { + resized = true; + } + + public void componentShown(ComponentEvent e) { + shown = true; + } + } + + class ContainerListenerImpl implements ContainerListener { + public boolean removed = false; + public boolean added = false; + + public void componentAdded(ContainerEvent e) { + added = true; + } + + public void componentRemoved(ContainerEvent e) { + removed = true; + } + } + + class FocusListenerImpl implements FocusListener { + public boolean gained = false; + public boolean lost = false; + + public void focusGained(FocusEvent e) { + gained = true; + } + + public void focusLost(FocusEvent e) { + lost = true; + } + } + + class KeyListenerImpl implements KeyListener { + public boolean pressed = false; + public boolean released = false; + public boolean typed = false; + + public void keyPressed(KeyEvent e) { + pressed = true; + } + + public void keyReleased(KeyEvent e) { + released = true; + } + + public void keyTyped(KeyEvent e) { + typed = true; + } + } + + public static void main(String args[]) { + new HeadlessAWTEventMulticaster().doTest(); + } + + void doTest() { + ComponentListener compList; + ComponentListenerImpl compListImpl; + + ContainerListener contList; + ContainerListenerImpl contListImpl; + + FocusListener focList; + FocusListenerImpl focListImpl; + + KeyListener keyList; + KeyListenerImpl keyListImpl; + + Component component = new Component(){}; + + // Component resized + compListImpl = new ComponentListenerImpl(); + compList = AWTEventMulticaster.add(compListImpl, null); + compList.componentResized(new ComponentEvent(component, + ComponentEvent.COMPONENT_RESIZED)); + if (compListImpl.hidden || compListImpl.moved || compListImpl.shown) { + throw new RuntimeException("Wrong id delivered: hidden || moved || shown"); + } + if (!compListImpl.resized) { + throw new RuntimeException("Expected id, resized, not delivered"); + } + + // Component moved + compListImpl = new ComponentListenerImpl(); + compList = AWTEventMulticaster.add(compListImpl, null); + compList.componentMoved(new ComponentEvent(component, + ComponentEvent.COMPONENT_MOVED)); + if (compListImpl.hidden || compListImpl.resized || compListImpl.shown) { + throw new RuntimeException("Wrong id delivered: hidden || resized || shown"); + } + if (!compListImpl.moved) { + throw new RuntimeException("Expected id, moved, not delivered"); + } + + // Component shown + compListImpl = new ComponentListenerImpl(); + compList = AWTEventMulticaster.add(compListImpl, null); + compList.componentShown(new ComponentEvent(component, + ComponentEvent.COMPONENT_SHOWN)); + if (compListImpl.hidden || compListImpl.resized || compListImpl.moved) { + throw new RuntimeException("Wrong id delivered: hidden || resized || moved"); + } + if (!compListImpl.shown) { + throw new RuntimeException("Expected id, shown, not delivered"); + } + + // Component hidden + compListImpl = new ComponentListenerImpl(); + compList = AWTEventMulticaster.add(compListImpl, null); + compList.componentHidden(new ComponentEvent(component, + ComponentEvent.COMPONENT_HIDDEN)); + if (compListImpl.shown || compListImpl.resized || compListImpl.moved) { + throw new RuntimeException("Wrong id delivered: shown || resized || moved"); + } + if (!compListImpl.hidden) { + throw new RuntimeException("Expected id, hidden, not delivered"); + } + + // Component added + contListImpl = new ContainerListenerImpl(); + contList = AWTEventMulticaster.add(contListImpl, null); + contList.componentAdded(new ContainerEvent(component, + ContainerEvent.COMPONENT_ADDED, component)); + if (contListImpl.removed) { + throw new RuntimeException("Wrong id delivered: removed"); + } + if (!contListImpl.added) { + throw new RuntimeException("Expected id, added, not delivered"); + } + + // Component removed + contListImpl = new ContainerListenerImpl(); + contList = AWTEventMulticaster.add(contListImpl, null); + contList.componentRemoved(new ContainerEvent(component, + ContainerEvent.COMPONENT_REMOVED, component)); + if (contListImpl.added) { + throw new RuntimeException("Wrong id delivered: added"); + } + if (!contListImpl.removed) { + throw new RuntimeException("Expected id, removed, not delivered"); + } + + // Focus gained + focListImpl = new FocusListenerImpl(); + focList = AWTEventMulticaster.add(focListImpl, null); + focList.focusGained(new FocusEvent(component, FocusEvent.FOCUS_GAINED)); + if (focListImpl.lost) { + throw new RuntimeException("Wrong id delivered: lost"); + } + if (!focListImpl.gained) { + throw new RuntimeException("Expected id, gained, not delivered"); + } + + // Focus lost + focListImpl = new FocusListenerImpl(); + focList = AWTEventMulticaster.add(focListImpl, null); + focList.focusLost(new FocusEvent(component, FocusEvent.FOCUS_LOST)); + if (focListImpl.gained) { + throw new RuntimeException("Wrong id delivered: gained"); + } + if (!focListImpl.lost) { + throw new RuntimeException("Expected id, lost, not delivered"); + } + + // Key typed + keyListImpl = new KeyListenerImpl(); + keyList = AWTEventMulticaster.add(keyListImpl, null); + keyList.keyTyped(new KeyEvent(component, + KeyEvent.KEY_TYPED, 0L, 0, 0)); + if (keyListImpl.pressed || keyListImpl.released) + throw new RuntimeException("Wrong id delivered: pressed || released"); + + if (!keyListImpl.typed) + throw new RuntimeException("Expected id, typed, not delivered"); + + // Key pressed + keyListImpl = new KeyListenerImpl(); + keyList = AWTEventMulticaster.add(keyListImpl, null); + keyList.keyPressed(new KeyEvent(component, + KeyEvent.KEY_PRESSED, 0L, 0, 0)); + if (keyListImpl.typed || keyListImpl.released) + throw new RuntimeException("Wrong id delivered: typed || released"); + + if (!keyListImpl.pressed) + throw new RuntimeException("Expected id, pressed, not delivered"); + + // Key released + keyListImpl = new KeyListenerImpl(); + keyList = AWTEventMulticaster.add(keyListImpl, null); + keyList.keyReleased(new KeyEvent(component, + KeyEvent.KEY_RELEASED, 0L, 0, 0)); + if (keyListImpl.pressed || keyListImpl.typed) + throw new RuntimeException("Wrong id delivered: pressed || typed"); + + if (!keyListImpl.released) + throw new RuntimeException("Expected id, released, not delivered"); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessAWTException.java b/jdk/test/java/awt/Headless/HeadlessAWTException.java new file mode 100644 index 00000000000..c6d9de30434 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessAWTException.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that AWTException can be created in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAWTException + */ + +public class HeadlessAWTException { + + public static void main (String[] args) { + AWTException e = new AWTException("aa"); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessBasicStroke.java b/jdk/test/java/awt/Headless/HeadlessBasicStroke.java new file mode 100644 index 00000000000..b3c479fbf9a --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessBasicStroke.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that BasicStroke constructors and get-methods do not + * throw exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBasicStroke + */ + + +public class HeadlessBasicStroke { + public static void main (String[] args) { + BasicStroke bs; + + // Constructors without exceptions + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, 3, null, -1); + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 3, + new float[]{(float) 2.0, (float) 3.0}, 0); + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 3, + new float[]{(float) 2.0, (float) 3.0}, 1); + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, (float) 3); + + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 3); + + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, (float) 3); + + bs = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3); + + bs = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 3); + + bs = new BasicStroke(1, BasicStroke.JOIN_ROUND, BasicStroke.CAP_SQUARE, 3); + + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); + + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); + + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); + + bs = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + + bs = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND); + + bs = new BasicStroke(1, BasicStroke.JOIN_ROUND, BasicStroke.CAP_SQUARE); + + bs = new BasicStroke((float) 0.1); + + bs = new BasicStroke((float) 0.9); + + bs = new BasicStroke(4); + + bs = new BasicStroke(10); + + bs = new BasicStroke(20); + + bs = new BasicStroke(100); + + bs = new BasicStroke(); + + // Constructors with exceptions + boolean exceptions = false; + try { + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + exceptions = false; + try { + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + exceptions = false; + try { + bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, (float) 0.2); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + exceptions = false; + try { + bs = new BasicStroke(1, 5678, 92039, 3); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + exceptions = false; + try { + bs = new BasicStroke(1, 5678, 92039); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + exceptions = false; + try { + bs = new BasicStroke((float) -0.9); + } catch (IllegalArgumentException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw IllegalArgumentException when expected"); + + // Create stroke shape + bs = new BasicStroke(20); + bs.createStrokedShape(new Rectangle(10, 10, 10, 10)); + + // Get-methods + bs = new BasicStroke(100); + bs.getLineWidth(); + bs.getEndCap(); + bs.getLineJoin(); + bs.getMiterLimit(); + bs.getDashArray(); + bs.getDashPhase(); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessBorderLayout.java b/jdk/test/java/awt/Headless/HeadlessBorderLayout.java new file mode 100644 index 00000000000..2a4d51ac3dc --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessBorderLayout.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check BorderLayout constructors and methods working in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBorderLayout + */ + +public class HeadlessBorderLayout { + public static void main (String[] args) { + BorderLayout bl; + bl = new BorderLayout(); + bl = new BorderLayout(10, 10); + bl.getHgap(); + bl.setHgap(10); + bl.getVgap(); + bl.setVgap(10); + + bl = new BorderLayout(); + bl.setVgap(10); + bl.addLayoutComponent(new Component(){}, BorderLayout.AFTER_LAST_LINE); + bl.addLayoutComponent(new Component(){}, BorderLayout.AFTER_LINE_ENDS); + bl.addLayoutComponent(new Component(){}, BorderLayout.BEFORE_FIRST_LINE); + bl.addLayoutComponent(new Component(){}, BorderLayout.BEFORE_LINE_BEGINS); + bl.addLayoutComponent(new Component(){}, BorderLayout.PAGE_START); + bl.addLayoutComponent(new Component(){}, BorderLayout.PAGE_END); + bl.addLayoutComponent(new Component(){}, BorderLayout.LINE_START); + bl.addLayoutComponent(new Component(){}, BorderLayout.LINE_END); + bl.addLayoutComponent(new Component(){}, BorderLayout.CENTER); + bl.addLayoutComponent(new Component(){}, BorderLayout.EAST); + bl.addLayoutComponent(new Component(){}, BorderLayout.NORTH); + bl.addLayoutComponent(new Component(){}, BorderLayout.SOUTH); + bl.addLayoutComponent(new Component(){}, BorderLayout.WEST); + + Component cb = new Component(){}; + bl.addLayoutComponent(cb, BorderLayout.WEST); + bl.removeLayoutComponent(cb); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessCardLayout.java b/jdk/test/java/awt/Headless/HeadlessCardLayout.java new file mode 100644 index 00000000000..7f6829d5cd4 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessCardLayout.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check whether CardLayout constructor and methods do not throw exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCardLayout + */ + +public class HeadlessCardLayout { + + public static void main(String args[]) { + CardLayout cl; + cl = new CardLayout(); + cl = new CardLayout(10, 10); + cl.getHgap(); + cl.setHgap(10); + cl.getVgap(); + cl.setVgap(10); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessCheckboxGroup.java b/jdk/test/java/awt/Headless/HeadlessCheckboxGroup.java new file mode 100644 index 00000000000..818359a3ad4 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessCheckboxGroup.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that CheckboxGroup constructor and toString() method do not throw + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCheckboxGroup + */ + +public class HeadlessCheckboxGroup { + public static void main(String args[]) { + CheckboxGroup cbg = new CheckboxGroup(); + cbg.toString(); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessCheckboxMenuItem.java b/jdk/test/java/awt/Headless/HeadlessCheckboxMenuItem.java new file mode 100644 index 00000000000..1ac9f2aeeb4 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessCheckboxMenuItem.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that CheckboxMenuItem constructors throw HeadlessException + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCheckboxMenuItem + */ + +public class HeadlessCheckboxMenuItem { + + public static void main(String args[]) { + CheckboxMenuItem c; + + boolean exceptions = false; + try { + c = new CheckboxMenuItem(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + c = new CheckboxMenuItem("Choices..."); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + c = new CheckboxMenuItem("Choices...", true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + exceptions = false; + try { + c = new CheckboxMenuItem("Choices...", false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("Constructor did not throw HeadlessException"); + + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessComponentOrientation.java b/jdk/test/java/awt/Headless/HeadlessComponentOrientation.java new file mode 100644 index 00000000000..6803b72f4a5 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessComponentOrientation.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that ComponentOrientation methods do not throw exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessComponentOrientation + */ + +public class HeadlessComponentOrientation { + public static void main(String args[]) { + ComponentOrientation.LEFT_TO_RIGHT.isHorizontal(); + ComponentOrientation.RIGHT_TO_LEFT.isHorizontal(); + ComponentOrientation.UNKNOWN.isHorizontal(); + ComponentOrientation.LEFT_TO_RIGHT.isLeftToRight(); + ComponentOrientation.RIGHT_TO_LEFT.isLeftToRight(); + ComponentOrientation.UNKNOWN.isLeftToRight(); + + for (Locale locale : Locale.getAvailableLocales()) + ComponentOrientation.getOrientation(locale); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessDimension.java b/jdk/test/java/awt/Headless/HeadlessDimension.java new file mode 100644 index 00000000000..7170a0fdb60 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessDimension.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Dimension constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDimension + */ + +public class HeadlessDimension { + public static void main(String args[]) { + Dimension d; + d = new Dimension(); + d = new Dimension(new Dimension()); + + d = new Dimension(100, 100); + double f = d.getWidth(); + f = d.getHeight(); + + d = new Dimension(); + d.setSize(100.0, 100.0); + d.setSize(100, 100); + + d = new Dimension(100, 100); + Dimension d2 = d.getSize(); + + d = new Dimension(100, 100); + d2 = new Dimension(200, 200); + d.setSize(d2); + + new Dimension(100, 100).equals(new Dimension(200, 200)); + + d.hashCode(); + d.toString(); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessFlowLayout.java b/jdk/test/java/awt/Headless/HeadlessFlowLayout.java new file mode 100644 index 00000000000..cf5a9c16252 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessFlowLayout.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that FlowLayout constructor and method do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessFlowLayout + */ + +public class HeadlessFlowLayout { + + public static void main(String args[]) { + FlowLayout bs = new FlowLayout(); + bs.getHgap(); + bs.setHgap(10); + bs.getVgap(); + bs.setVgap(10); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessMediaTracker.java b/jdk/test/java/awt/Headless/HeadlessMediaTracker.java new file mode 100644 index 00000000000..652990f9afe --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessMediaTracker.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that MediaTracker constructor does not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessMediaTracker + */ + +public class HeadlessMediaTracker { + public static void main(String args[]) { + new MediaTracker(new Component(){}); + } +} diff --git a/jdk/test/java/awt/Headless/HeadlessPopupMenu.java b/jdk/test/java/awt/Headless/HeadlessPopupMenu.java new file mode 100644 index 00000000000..a20bfe47666 --- /dev/null +++ b/jdk/test/java/awt/Headless/HeadlessPopupMenu.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that PopupMenu constructors do not throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPopupMenu + */ + +public class HeadlessPopupMenu { + public static void main(String args[]) { + PopupMenu pm; + boolean exceptions = false; + try { + pm = new PopupMenu(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + pm = new PopupMenu("Popup menu"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Insets/HeadlessInsets.java b/jdk/test/java/awt/Insets/HeadlessInsets.java new file mode 100644 index 00000000000..b04ba11fae4 --- /dev/null +++ b/jdk/test/java/awt/Insets/HeadlessInsets.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Insets constructor does not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessInsets + */ + +public class HeadlessInsets { + public static void main(String args[]) { + new Insets(1, 2, 3, 4); + } +} diff --git a/jdk/test/java/awt/Menu/Headless/HeadlessMenu.java b/jdk/test/java/awt/Menu/Headless/HeadlessMenu.java new file mode 100644 index 00000000000..6c51b8d66fe --- /dev/null +++ b/jdk/test/java/awt/Menu/Headless/HeadlessMenu.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that Menu constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessMenu + */ + +public class HeadlessMenu { + public static void main(String args[]) { + Menu m; + boolean exceptions = false; + try { + m = new Menu(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + m = new Menu("A Menu"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + m = new Menu("A Menu", false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + m = new Menu("A Menu", true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Menu/Headless/HeadlessMenuItem.java b/jdk/test/java/awt/Menu/Headless/HeadlessMenuItem.java new file mode 100644 index 00000000000..3a3db2b2185 --- /dev/null +++ b/jdk/test/java/awt/Menu/Headless/HeadlessMenuItem.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.event.KeyEvent; + +/* + * @test + * @summary Check that MenuItem constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessMenuItem + */ + +public class HeadlessMenuItem { + + public static void main(String args[]) { + MenuItem mi; + + boolean exceptions = false; + try { + mi = new MenuItem(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + mi = new MenuItem("Choose me"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + MenuShortcut ms = new MenuShortcut(KeyEvent.VK_A); + mi = new MenuItem("Choose me", ms); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Menu/Headless/HeadlessMenuShortcut.java b/jdk/test/java/awt/Menu/Headless/HeadlessMenuShortcut.java new file mode 100644 index 00000000000..50de7b34bc3 --- /dev/null +++ b/jdk/test/java/awt/Menu/Headless/HeadlessMenuShortcut.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.MenuShortcut; +import java.awt.event.KeyEvent; + +/* + * @test + * @summary Check that MenuShortcut constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessMenuShortcut + */ + +public class HeadlessMenuShortcut { + public static void main(String args[]) { + MenuShortcut ms; + ms = new MenuShortcut(KeyEvent.VK_A); + ms = new MenuShortcut(KeyEvent.VK_A, true); + ms = new MenuShortcut(KeyEvent.VK_A, false); + } +} diff --git a/jdk/test/java/awt/MenuBar/HeadlessMenuBar.java b/jdk/test/java/awt/MenuBar/HeadlessMenuBar.java new file mode 100644 index 00000000000..3e2c659f659 --- /dev/null +++ b/jdk/test/java/awt/MenuBar/HeadlessMenuBar.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check that MenuBar constructor does not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessMenuBar + */ + +public class HeadlessMenuBar { + public static void main(String args[]) { + boolean exceptions = false; + try { + MenuBar m = new MenuBar(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/Toolkit/Headless/HeadlessToolkit.java b/jdk/test/java/awt/Toolkit/Headless/HeadlessToolkit.java new file mode 100644 index 00000000000..1f7ceeeea00 --- /dev/null +++ b/jdk/test/java/awt/Toolkit/Headless/HeadlessToolkit.java @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.event.AWTEventListener; +import java.awt.event.KeyEvent; +import java.awt.im.InputMethodHighlight; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.MemoryImageSource; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Map; + +/* + * @test + * @summary Check that Toolkit methods do not throw unexpected exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessToolkit + */ + +public class HeadlessToolkit { + + class awtEventListener implements AWTEventListener { + public void eventDispatched(AWTEvent e) { + } + } + + class propChangeListener implements PropertyChangeListener { + public void propertyChange(PropertyChangeEvent e) { + } + } + + public static void main(String args[]) throws IOException { + new HeadlessToolkit().doTest(); + } + + void doTest() throws IOException { + Toolkit tk = Toolkit.getDefaultToolkit(); + String[] fl = tk.getFontList(); + FontMetrics fm = tk.getFontMetrics(new Font(fl[0], Font.PLAIN, 10)); + tk.sync(); + tk.beep(); + + boolean exceptions = false; + try { + Dimension d = tk.getScreenSize(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + int res = tk.getScreenResolution(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Graphics2D gd = ge.createGraphics(new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR)); + GraphicsConfiguration gc = gd.getDeviceConfiguration(); + Insets res = tk.getScreenInsets(gc); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + ColorModel cm = tk.getColorModel(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + int km = tk.getMenuShortcutKeyMask(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + boolean state = tk.getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + boolean state = tk.getLockingKeyState(KeyEvent.VK_NUM_LOCK); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + boolean state = tk.getLockingKeyState(KeyEvent.VK_KANA_LOCK); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + boolean state = tk.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_NUM_LOCK, true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_KANA_LOCK, true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_NUM_LOCK, false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_KANA_LOCK, false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + tk.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + Dimension d = tk.getBestCursorSize(32, 32); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + int n = tk.getMaximumCursorColors(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + EventQueue eq = tk.getSystemEventQueue(); + awtEventListener el = new awtEventListener(); + tk.addAWTEventListener(el, 0xffffffff); + tk.removeAWTEventListener(el); + + File[] images = new File[]{new File("image.png"), new File("image.jpg"), new File("image.gif")}; + Image im; + for (File image : images) { + String path = image.getCanonicalPath(); + ImageIO.write(new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB), path.substring(path.lastIndexOf('.')+1), image); + + im = tk.getImage(image.getAbsolutePath()); + im.flush(); + + FileInputStream fis = new FileInputStream(image); + byte[] b = new byte[(int) (image.length())]; + fis.read(b); + fis.close(); + im = tk.createImage(b); + im.flush(); + + im = tk.createImage(image.getAbsolutePath()); + im.flush(); + + } + + im = tk.getImage(new URL("http://openjdk.java.net/images/openjdk.png")); + im.flush(); + + im = tk.createImage(new URL("http://openjdk.java.net/images/openjdk.png")); + im.flush(); + + MemoryImageSource mis; + int pixels[] = new int[50 * 50]; + int index = 0; + for (int y = 0; y < 50; y++) { + int red = (y * 255) / 49; + for (int x = 0; x < 50; x++) { + int blue = (x * 255) / 49; + pixels[index++] = (255 << 24) | (red << 16) | blue; + } + } + mis = new MemoryImageSource(50, 50, pixels, 0, 50); + im = tk.createImage(mis); + im.flush(); + + + exceptions = false; + try { + Cursor cur = tk.createCustomCursor(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB), new Point(0, 0), "Stop"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + Cursor cur = tk.createCustomCursor(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB), new Point(0, 0), "Stop"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + InputMethodHighlight imh = new InputMethodHighlight(true, InputMethodHighlight.CONVERTED_TEXT); + Map m = tk.mapInputMethodHighlight(imh); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + Clipboard cl = tk.getSystemClipboard(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/java/awt/applet/Applet/HeadlessApplet.java b/jdk/test/java/awt/applet/Applet/HeadlessApplet.java new file mode 100644 index 00000000000..c258e080a22 --- /dev/null +++ b/jdk/test/java/awt/applet/Applet/HeadlessApplet.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.applet.Applet; +import java.awt.HeadlessException; + +/* + * @test + * @summary Check HeadlessException occurrence when trying to create Applet + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessApplet + */ + +public class HeadlessApplet { + + public static void main(String args[]) { + boolean noExceptions = true; + + try { + Applet a = new Applet(); + } catch (HeadlessException e) { + noExceptions = false; + } + + if (noExceptions) { + throw new RuntimeException("No HeadlessException occured when creating Applet in headless mode"); + } + } +} diff --git a/jdk/test/java/awt/datatransfer/Headless/HeadlessClipboard.java b/jdk/test/java/awt/datatransfer/Headless/HeadlessClipboard.java new file mode 100644 index 00000000000..6023618e6e3 --- /dev/null +++ b/jdk/test/java/awt/datatransfer/Headless/HeadlessClipboard.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.datatransfer.Clipboard; + +/* + * @test + * @summary Check Clipboard constructor and getName() method do not throw + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessClipboard + */ + +public class HeadlessClipboard { + public static void main(String args[]) { + Clipboard cb = new Clipboard("dummy"); + cb.getName(); + } +} diff --git a/jdk/test/java/awt/datatransfer/Headless/HeadlessDataFlavor.java b/jdk/test/java/awt/datatransfer/Headless/HeadlessDataFlavor.java new file mode 100644 index 00000000000..0f2cb08a63d --- /dev/null +++ b/jdk/test/java/awt/datatransfer/Headless/HeadlessDataFlavor.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.datatransfer.DataFlavor; + +/* + * @test + * @summary Check that DataFlavor constructors do not throw unexpected exceptions + * in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDataFlavor + */ + +public class HeadlessDataFlavor { + public static void main(String args[]) throws Exception { + DataFlavor df; + df = new DataFlavor(); + df = new DataFlavor("text/plain", "plain jane text"); + df = new DataFlavor("text/html", "HTML text"); + df = new DataFlavor("text/plain"); + df = new DataFlavor("text/html"); + df.toString(); + } +} diff --git a/jdk/test/java/awt/datatransfer/Headless/HeadlessSystemFlavorMap.java b/jdk/test/java/awt/datatransfer/Headless/HeadlessSystemFlavorMap.java new file mode 100644 index 00000000000..741d3f9c019 --- /dev/null +++ b/jdk/test/java/awt/datatransfer/Headless/HeadlessSystemFlavorMap.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.datatransfer.FlavorMap; +import java.awt.datatransfer.SystemFlavorMap; + +/* + * @test + * @summary Check that SystemFlavorMap constructor does not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessSystemFlavorMap + */ + +public class HeadlessSystemFlavorMap { + public static void main(String args[]) { + FlavorMap sfm = SystemFlavorMap.getDefaultFlavorMap(); + } +} diff --git a/jdk/test/java/awt/im/Headless/HeadlessInputContext.java b/jdk/test/java/awt/im/Headless/HeadlessInputContext.java new file mode 100644 index 00000000000..23e78c13551 --- /dev/null +++ b/jdk/test/java/awt/im/Headless/HeadlessInputContext.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.im.InputContext; +import java.util.Locale; + +/* + * @test + * @summary Check that InputContext methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessInputContext + */ + +public class HeadlessInputContext { + public static void main(String args[]) { + InputContext ic = InputContext.getInstance(); + + for (Locale locale : Locale.getAvailableLocales()) + ic.selectInputMethod(locale); + + ic.getLocale(); + } +} diff --git a/jdk/test/java/awt/im/Headless/HeadlessInputMethodHighlight.java b/jdk/test/java/awt/im/Headless/HeadlessInputMethodHighlight.java new file mode 100644 index 00000000000..96ab0069fbc --- /dev/null +++ b/jdk/test/java/awt/im/Headless/HeadlessInputMethodHighlight.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.im.InputMethodHighlight; + +/* + * @test + * @summary Check that InputMethodHighlight constructors do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessInputMethodHighlight + */ + +public class HeadlessInputMethodHighlight { + public static void main(String args[]) { + InputMethodHighlight imh; + imh = new InputMethodHighlight(true, InputMethodHighlight.CONVERTED_TEXT); + imh = new InputMethodHighlight(false,InputMethodHighlight.CONVERTED_TEXT); + imh = new InputMethodHighlight(true, InputMethodHighlight.RAW_TEXT); + imh = new InputMethodHighlight(false,InputMethodHighlight.RAW_TEXT); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessAffineTransformOp.java b/jdk/test/java/awt/image/Headless/HeadlessAffineTransformOp.java new file mode 100644 index 00000000000..2ea9acc9380 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessAffineTransformOp.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; + +/* + * @test + * @summary Check that AffineTransformOp constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAffineTransformOp + */ + +public class HeadlessAffineTransformOp { + public static void main(String args[]) { + AffineTransformOp ato; + + ato = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR); + ato = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + ato = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR); + ato.getInterpolationType(); + ato.getTransform(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessAreaAveragingScaleFilter.java b/jdk/test/java/awt/image/Headless/HeadlessAreaAveragingScaleFilter.java new file mode 100644 index 00000000000..d4cc48060a1 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessAreaAveragingScaleFilter.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.AreaAveragingScaleFilter; + +/* + * @test + * @summary Check that AreaAveragingScaleFilter constructor and clone() method + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAreaAveragingScaleFilter + */ + +public class HeadlessAreaAveragingScaleFilter { + public static void main(String args[]) { + new AreaAveragingScaleFilter(100, 100).clone(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessBufferedImage.java b/jdk/test/java/awt/image/Headless/HeadlessBufferedImage.java new file mode 100644 index 00000000000..a993e9535a7 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessBufferedImage.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.BufferedImage; + +/* + * @test + * @summary Check that BufferedImage constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBufferedImage + */ + +public class HeadlessBufferedImage { + + public static void main(String args[]) { + BufferedImage bi; + bi = new BufferedImage(300, 300, BufferedImage.TYPE_3BYTE_BGR); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_4BYTE_ABGR); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_BYTE_BINARY); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_BYTE_GRAY); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_BYTE_INDEXED); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB_PRE); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_INT_BGR); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_USHORT_565_RGB); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_USHORT_GRAY); + bi = new BufferedImage(300, 300, BufferedImage.TYPE_USHORT_555_RGB); + bi.getType(); + bi.getColorModel(); + bi.getRaster(); + bi.getAlphaRaster(); + bi.getRGB(1, 1); + bi.getWidth(); + bi.getHeight(); + bi.getSource(); + bi.flush(); + bi.getGraphics(); + bi.createGraphics(); + BufferedImage bi2 = bi.getSubimage(10, 10, 200, 200); + bi.isAlphaPremultiplied(); + bi.coerceData(true); + bi.coerceData(false); + bi.toString(); + bi.getSources(); + bi.getPropertyNames(); + bi.getMinX(); + bi.getMinY(); + bi.getSampleModel(); + bi.getNumXTiles(); + bi.getNumYTiles(); + bi.getMinTileX(); + bi.getMinTileY(); + bi.getTileWidth(); + bi.getTileHeight(); + bi.getTileGridXOffset(); + bi.getTileGridYOffset(); + bi.getData(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessBufferedImageFilter.java b/jdk/test/java/awt/image/Headless/HeadlessBufferedImageFilter.java new file mode 100644 index 00000000000..ea23c0df507 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessBufferedImageFilter.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.*; +import java.awt.geom.*; + +/* + * @test + * @summary Check that BufferedImageFilter constructor and clone() method do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBufferedImageFilter + */ + +public class HeadlessBufferedImageFilter { + public static void main(String args[]) { + new BufferedImageFilter(new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR)).clone(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessColorModel.java b/jdk/test/java/awt/image/Headless/HeadlessColorModel.java new file mode 100644 index 00000000000..d3d78e59a6b --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessColorModel.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.*; + +/* + * @test + * @summary Check that ColorModel methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessColorModel + */ + +public class HeadlessColorModel { + public static void main(String args[]) { + ColorModel cm = new ColorModel(32) { + public int getAlpha(int pixel) { return 255; } + public int getBlue(int pixel) { return 255; } + public int getGreen(int pixel) { return 255; } + public int getRed(int pixel) { return 255; } + }; + + cm.hasAlpha(); + cm.isAlphaPremultiplied(); + cm.getTransferType(); + cm.getPixelSize(); + cm.getComponentSize(); + cm.getComponentSize(); + cm.getTransparency(); + cm.getNumComponents(); + cm.getNumColorComponents(); + cm.getRed(20); + cm.getGreen(20); + cm.getBlue(20); + cm.getAlpha(20); + cm.getRGB(20); + cm.isAlphaPremultiplied(); + cm.isAlphaPremultiplied(); + + cm = ColorModel.getRGBdefault(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessCropImageFilter.java b/jdk/test/java/awt/image/Headless/HeadlessCropImageFilter.java new file mode 100644 index 00000000000..7d22f47c47d --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessCropImageFilter.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.CropImageFilter; + +/* + * @test + * @summary Check that CropImageFilter constructor and clone() method + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCropImageFilter + */ + +public class HeadlessCropImageFilter { + public static void main (String[] args) { + new CropImageFilter(20, 20, 40, 50).clone(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessImageFilter.java b/jdk/test/java/awt/image/Headless/HeadlessImageFilter.java new file mode 100644 index 00000000000..16782c54285 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessImageFilter.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.ImageFilter; + +/* + * @test + * @summary Check that ImageFilter constructor and clone() method + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessImageFilter + */ + +public class HeadlessImageFilter { + public static void main(String args[]) { + new ImageFilter().clone(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessIndexColorModel.java b/jdk/test/java/awt/image/Headless/HeadlessIndexColorModel.java new file mode 100644 index 00000000000..e197afab2b1 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessIndexColorModel.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.IndexColorModel; + +/* + * @test + * @summary Check that IndexColorModel constructor and methods + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessIndexColorModel + */ + +public class HeadlessIndexColorModel { + public static void main(String args[]) { + IndexColorModel cm = + new IndexColorModel(8, 1, new byte[]{(byte) 128}, new byte[]{(byte) 128}, new byte[]{(byte) 128}); + cm.getTransparency(); + cm.getComponentSize(); + cm.isAlphaPremultiplied(); + cm.hasAlpha(); + cm.isAlphaPremultiplied(); + cm.getTransferType(); + cm.getPixelSize(); + cm.getComponentSize(); + cm.getNumComponents(); + cm.getNumColorComponents(); + cm.getRed(20); + cm.getGreen(20); + cm.getBlue(20); + cm.getAlpha(20); + cm.getRGB(20); + cm.isAlphaPremultiplied(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessRGBImageFilter.java b/jdk/test/java/awt/image/Headless/HeadlessRGBImageFilter.java new file mode 100644 index 00000000000..41ce7ca44df --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessRGBImageFilter.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.RGBImageFilter; + +/* + * @test + * @summary Check that RGBImageFilter constructor and clone() method + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessRGBImageFilter + */ + +public class HeadlessRGBImageFilter { + + public static void main(String args[]) { + new RGBImageFilter() { + public int filterRGB(int x, int y, int rgb) { + return 0; + } + }.clone(); + } +} diff --git a/jdk/test/java/awt/image/Headless/HeadlessReplicateScaleFilter.java b/jdk/test/java/awt/image/Headless/HeadlessReplicateScaleFilter.java new file mode 100644 index 00000000000..187553a2238 --- /dev/null +++ b/jdk/test/java/awt/image/Headless/HeadlessReplicateScaleFilter.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.image.ReplicateScaleFilter; + +/* + * @test + * @summary Check that ReplicateScaleFilter constructor and clone() method + * do not throw unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessReplicateScaleFilter + */ + +public class HeadlessReplicateScaleFilter { + public static void main(String args[]) { + new ReplicateScaleFilter(100, 100).clone(); + } +} diff --git a/jdk/test/java/awt/print/Headless/HeadlessBook.java b/jdk/test/java/awt/print/Headless/HeadlessBook.java new file mode 100644 index 00000000000..fa73c0a91a1 --- /dev/null +++ b/jdk/test/java/awt/print/Headless/HeadlessBook.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.print.Book; + +/* + * @test + * @summary Check that Book constructor and getNumberOfPages() method do not throw + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBook + */ + +public class HeadlessBook { + public static void main(String args[]) { + new Book().getNumberOfPages(); + } +} diff --git a/jdk/test/java/awt/print/Headless/HeadlessPageFormat.java b/jdk/test/java/awt/print/Headless/HeadlessPageFormat.java new file mode 100644 index 00000000000..7210264d5f9 --- /dev/null +++ b/jdk/test/java/awt/print/Headless/HeadlessPageFormat.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.print.PageFormat; +import java.awt.print.Paper; + +/* + * @test + * @summary Check that PageFormat constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPageFormat + */ + +public class HeadlessPageFormat { + public static void main(String args[]) { + PageFormat pf; + pf = (PageFormat) new PageFormat().clone(); + pf.getWidth(); + pf.getHeight(); + pf.getImageableX(); + pf.getImageableY(); + pf.getImageableWidth(); + pf.getImageableHeight(); + pf.getPaper(); + pf.setPaper(new Paper()); + pf.setOrientation(PageFormat.PORTRAIT); + if (pf.getOrientation() != PageFormat.PORTRAIT) + throw new RuntimeException("Changing Orientation did not result in a change: PageFormat.PORTRAIT"); + + pf.setOrientation(PageFormat.LANDSCAPE); + if (pf.getOrientation() != PageFormat.LANDSCAPE) + throw new RuntimeException("Changing Orientation did not result in a change: PageFormat.LANDSCAPE"); + + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + if (pf.getOrientation() != PageFormat.REVERSE_LANDSCAPE) + throw new RuntimeException("Changing Orientation did not result in a change: PageFormat.REVERSE_LANDSCAPE"); + + pf.getOrientation(); + pf.getMatrix(); + } +} diff --git a/jdk/test/java/awt/print/Headless/HeadlessPaper.java b/jdk/test/java/awt/print/Headless/HeadlessPaper.java new file mode 100644 index 00000000000..7fcb93a96b5 --- /dev/null +++ b/jdk/test/java/awt/print/Headless/HeadlessPaper.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.print.Paper; + +/* + * @test + * @summary Check that Paper constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPaper + */ + +public class HeadlessPaper { + public static void main(String args[]) { + Paper p; + p = (Paper) new Paper().clone(); + p.getHeight(); + p.setSize(200.0, 300.0); + p.getWidth(); + p.setImageableArea(1.0, 1.0, 300.0, 400.0); + p.getImageableX(); + p.getImageableY(); + p.getImageableWidth(); + p.getImageableHeight(); + } +} diff --git a/jdk/test/java/awt/print/Headless/HeadlessPrinterJob.java b/jdk/test/java/awt/print/Headless/HeadlessPrinterJob.java new file mode 100644 index 00000000000..ff7a22ec8a3 --- /dev/null +++ b/jdk/test/java/awt/print/Headless/HeadlessPrinterJob.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.print.PrintService; +import javax.print.attribute.PrintServiceAttributeSet; +import java.awt.*; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RoundRectangle2D; +import java.awt.print.*; + +/* + * @test + * @summary Check that PrinterJob constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessPrinterJob + */ + +public class HeadlessPrinterJob { + + class testPrintable implements Printable { + + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) { + Graphics2D g2 = (Graphics2D) graphics; + + if (pageIndex >= 10) { + return Printable.NO_SUCH_PAGE; + } + + int gridWidth = 400 / 6; + int gridHeight = 300 / 2; + + int rowspacing = 5; + int columnspacing = 7; + int rectWidth = gridWidth - columnspacing; + int rectHeight = gridHeight - rowspacing; + + Color fg3D = Color.lightGray; + + g2.setPaint(fg3D); + g2.drawRect(80, 80, 400 - 1, 310); + g2.setPaint(Color.black); + + int x = 85; + int y = 87; + + + // draw Line2D.Double + g2.draw(new Line2D.Double(x, y + rectHeight - 1, x + rectWidth, y)); + x += gridWidth; + + // draw Rectangle2D.Double + //g2.setStroke(stroke); + g2.draw(new Rectangle2D.Double(x, y, rectWidth, rectHeight)); + x += gridWidth; + + // draw RoundRectangle2D.Double + //g2.setStroke(dashed); + g2.draw(new RoundRectangle2D.Double(x, y, rectWidth, + rectHeight, 10, 10)); + return Printable.PAGE_EXISTS; + } + } + + class testPageable implements Pageable { + + public int getNumberOfPages() { + return 10; + } + + public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException { + PageFormat pf = null; + if (pageIndex >= 10) { + throw new IndexOutOfBoundsException("Wrong page#"); + } + switch (pageIndex) { + case 0: + case 2: + case 4: + case 6: + case 8: + pf = new PageFormat(); + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + break; + case 1: + case 3: + case 5: + case 7: + case 9: + pf = new PageFormat(); + pf.setOrientation(PageFormat.LANDSCAPE); + break; + } + return pf; + } + + public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException { + if (pageIndex >= 10) { + throw new IndexOutOfBoundsException("Wrong page#"); + } + return new testPrintable(); + } + } + + public static void main(String args[]) throws Exception { + new HeadlessPrinterJob().doTest(); + } + + void doTest() throws Exception { + PrinterJob pj = PrinterJob.getPrinterJob(); + for (PrintService psl : pj.lookupPrintServices()) { + PrintServiceAttributeSet psas = psl.getAttributes(); + pj.setPrintService(psl); + } + PrintService ps = pj.getPrintService(); + pj.setPrintable(new testPrintable()); + + pj = PrinterJob.getPrinterJob(); + PageFormat pf = new PageFormat(); + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + pj.setPrintable(new testPrintable(), pf); + pj.setPageable(new testPageable()); + + boolean exceptions = false; + try { + pj.printDialog(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + pj = PrinterJob.getPrinterJob(); + pf = new PageFormat(); + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + pf = pj.pageDialog(pf); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + pf = new PageFormat(); + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + pf = pj.defaultPage(pf); + pf = pj.defaultPage(); + + pf = new PageFormat(); + pf.setOrientation(PageFormat.REVERSE_LANDSCAPE); + pf = pj.validatePage(pf); + pj.setCopies(10); + pj.getCopies(); + pj.getUserName(); + pj.setJobName("no-job-name"); + pj.getJobName(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessAbstractSpinnerModel.java b/jdk/test/javax/swing/Headless/HeadlessAbstractSpinnerModel.java new file mode 100644 index 00000000000..74ca68ce4d3 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessAbstractSpinnerModel.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; + +/* + * @test + * @summary Check that AbstractSpinnerModel constructor and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessAbstractSpinnerModel + */ + +public class HeadlessAbstractSpinnerModel { + public static void main (String[] args){ + AbstractSpinnerModel model = new AbstractSpinnerModel(){ + public Object getValue() { return null; } + public void setValue(Object value) {} + public Object getNextValue() { return null; } + public Object getPreviousValue() { return null; } + }; + model.getPreviousValue(); + model.getNextValue(); + model.setValue("next"); + model.getValue(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessBox.java b/jdk/test/javax/swing/Headless/HeadlessBox.java new file mode 100644 index 00000000000..ff3de6b83c3 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessBox.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that Box constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBox + */ + +public class HeadlessBox { + + public static void main(String args[]) { + for (Box b : new Box[]{new Box(BoxLayout.X_AXIS), new Box(BoxLayout.Y_AXIS)}) { + b = Box.createHorizontalBox(); + b = Box.createVerticalBox(); + b = new Box(BoxLayout.Y_AXIS); + b.getAccessibleContext(); + b.requestFocus(); + b.requestFocusInWindow(); + b.getPreferredSize(); + b.getMaximumSize(); + b.getMinimumSize(); + b.contains(1, 2); + Component c1 = b.add(new Component() { + }); + Component c2 = b.add(new Component() { + }); + Component c3 = b.add(new Component() { + }); + b.getComponentCount(); + b.countComponents(); + b.getComponent(1); + b.getComponent(2); + Component[] cs = b.getComponents(); + + boolean exceptions = false; + try { + b.setLayout(new BoxLayout(new Container(), BoxLayout.Y_AXIS)); + } catch (AWTError e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("AWTError did not occur when expected"); + + exceptions = false; + try { + b.setLayout(new BoxLayout(new Container(), BoxLayout.X_AXIS)); + } catch (AWTError e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("AWTError did not occur when expected"); + + b.getLayout(); + b.invalidate(); + b.validate(); + b.revalidate(); + + Insets ins = b.getInsets(); + b.getAlignmentY(); + b.getAlignmentX(); + b.getGraphics(); + b.setVisible(false); + b.setVisible(true); + b.setEnabled(false); + b.setEnabled(true); + b.setForeground(Color.red); + b.setBackground(Color.red); + + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + b.setFont(f1); + b.setFont(f2); + b.setFont(f3); + b.setFont(f4); + + b.getFontMetrics(f1); + b.getFontMetrics(f2); + b.getFontMetrics(f3); + b.getFontMetrics(f4); + + } + } + + b.enable(); + b.disable(); + b.reshape(10, 10, 10, 10); + b.getBounds(new Rectangle(1, 1, 1, 1)); + b.getSize(new Dimension(1, 2)); + b.getSize(new Dimension(1, 2)); + b.getLocation(new Point(1, 2)); + b.getX(); + b.getY(); + b.getWidth(); + b.getHeight(); + b.isOpaque(); + b.isValidateRoot(); + b.isOptimizedDrawingEnabled(); + b.isDoubleBuffered(); + + b.remove(0); + b.remove(c2); + b.removeAll(); + b.layout(); + b.preferredSize(); + b.minimumSize(); + b.getComponentAt(1, 2); + b.locate(1, 2); + b.getComponentAt(new Point(1, 2)); + b.isFocusCycleRoot(new Container()); + b.transferFocusBackward(); + b.setName("goober"); + b.getName(); + b.getParent(); + b.getPeer(); + b.getGraphicsConfiguration(); + b.getTreeLock(); + b.getToolkit(); + b.isValid(); + b.isDisplayable(); + b.isVisible(); + b.isShowing(); + b.isEnabled(); + b.enable(false); + b.enable(true); + b.enableInputMethods(false); + b.enableInputMethods(true); + b.show(); + b.show(false); + b.show(true); + b.hide(); + b.getForeground(); + b.isForegroundSet(); + b.getBackground(); + b.isBackgroundSet(); + b.getFont(); + b.isFontSet(); + b.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + b.setLocale(locale); + + b.getColorModel(); + b.getLocation(); + + exceptions = false; + try { + b.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + b.location(); + b.setLocation(1, 2); + b.move(1, 2); + b.setLocation(new Point(1, 2)); + b.getSize(); + b.size(); + b.setSize(1, 32); + b.resize(1, 32); + b.setSize(new Dimension(1, 32)); + b.resize(new Dimension(1, 32)); + b.getBounds(); + b.bounds(); + b.setBounds(10, 10, 10, 10); + b.setBounds(new Rectangle(10, 10, 10, 10)); + b.isLightweight(); + b.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + b.getCursor(); + b.isCursorSet(); + b.inside(1, 2); + b.contains(new Point(1, 2)); + b.isFocusTraversable(); + b.isFocusable(); + b.setFocusable(true); + b.setFocusable(false); + b.transferFocus(); + b.getFocusCycleRootAncestor(); + b.nextFocus(); + b.transferFocusUpCycle(); + b.hasFocus(); + b.isFocusOwner(); + b.toString(); + b.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + b.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + b.setComponentOrientation(ComponentOrientation.UNKNOWN); + b.getComponentOrientation(); + } + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessBox_Filler.java b/jdk/test/javax/swing/Headless/HeadlessBox_Filler.java new file mode 100644 index 00000000000..970148f7c1b --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessBox_Filler.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that Box.Filler constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessBox_Filler + */ + +public class HeadlessBox_Filler { + public static void main(String args[]) { + Box.Filler bf = new Box.Filler(new Dimension(10, 10), + new Dimension(20, 20), + new Dimension(30, 30)); + bf.getMinimumSize(); + bf.getPreferredSize(); + bf.getMaximumSize(); + bf.getAccessibleContext(); + bf.requestFocus(); + bf.requestFocusInWindow(); + bf.contains(1, 2); + Component c1 = bf.add(new Component(){}); + Component c2 = bf.add(new Component(){}); + Component c3 = bf.add(new Component(){}); + Insets ins = bf.getInsets(); + bf.getAlignmentY(); + bf.getAlignmentX(); + bf.getGraphics(); + bf.setVisible(false); + bf.setVisible(true); + bf.setEnabled(false); + bf.setEnabled(true); + bf.setForeground(Color.red); + bf.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + bf.setFont(f1); + bf.setFont(f2); + bf.setFont(f3); + bf.setFont(f4); + + bf.getFontMetrics(f1); + bf.getFontMetrics(f2); + bf.getFontMetrics(f3); + bf.getFontMetrics(f4); + } + } + bf.enable(); + bf.disable(); + bf.reshape(10, 10, 10, 10); + bf.getBounds(new Rectangle(1, 1, 1, 1)); + bf.getSize(new Dimension(1, 2)); + bf.getLocation(new Point(1, 2)); + bf.getX(); + bf.getY(); + bf.getWidth(); + bf.getHeight(); + bf.isOpaque(); + bf.isValidateRoot(); + bf.isOptimizedDrawingEnabled(); + bf.isDoubleBuffered(); + bf.getComponentCount(); + bf.countComponents(); + bf.getComponent(1); + bf.getComponent(2); + Component[] cs = bf.getComponents(); + bf.getLayout(); + bf.setLayout(new FlowLayout()); + bf.doLayout(); + bf.layout(); + bf.invalidate(); + bf.validate(); + bf.preferredSize(); + bf.remove(0); + bf.remove(c2); + bf.removeAll(); + bf.minimumSize(); + bf.getComponentAt(1, 2); + bf.locate(1, 2); + bf.getComponentAt(new Point(1, 2)); + bf.isFocusCycleRoot(new Container()); + bf.transferFocusBackward(); + bf.setName("goober"); + bf.getName(); + bf.getParent(); + bf.getPeer(); + bf.getGraphicsConfiguration(); + bf.getTreeLock(); + bf.getToolkit(); + bf.isValid(); + bf.isDisplayable(); + bf.isVisible(); + bf.isShowing(); + bf.isEnabled(); + bf.enable(false); + bf.enable(true); + bf.enableInputMethods(false); + bf.enableInputMethods(true); + bf.show(); + bf.show(false); + bf.show(true); + bf.hide(); + bf.getForeground(); + bf.isForegroundSet(); + bf.getBackground(); + bf.isBackgroundSet(); + bf.getFont(); + bf.isFontSet(); + + Container c = new Container(); + c.add(bf); + bf.getLocale(); + + for (Locale locale : Locale.getAvailableLocales()) + bf.setLocale(locale); + + bf.getColorModel(); + bf.getLocation(); + + boolean exceptions = false; + try { + bf.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + bf.setLocation(1, 2); + bf.move(1, 2); + bf.setLocation(new Point(1, 2)); + bf.getSize(); + bf.size(); + bf.setSize(1, 32); + bf.resize(1, 32); + bf.setSize(new Dimension(1, 32)); + bf.resize(new Dimension(1, 32)); + bf.getBounds(); + bf.bounds(); + bf.setBounds(10, 10, 10, 10); + bf.setBounds(new Rectangle(10, 10, 10, 10)); + bf.isLightweight(); + bf.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + bf.getCursor(); + bf.isCursorSet(); + bf.inside(1, 2); + bf.contains(new Point(1, 2)); + bf.isFocusTraversable(); + bf.isFocusable(); + bf.setFocusable(true); + bf.setFocusable(false); + bf.transferFocus(); + bf.getFocusCycleRootAncestor(); + bf.nextFocus(); + bf.transferFocusUpCycle(); + bf.hasFocus(); + bf.isFocusOwner(); + bf.toString(); + bf.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + bf.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + bf.setComponentOrientation(ComponentOrientation.UNKNOWN); + bf.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessCellRendererPane.java b/jdk/test/javax/swing/Headless/HeadlessCellRendererPane.java new file mode 100644 index 00000000000..43494535241 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessCellRendererPane.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that CellRendererPane constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessCellRendererPane + */ + +public class HeadlessCellRendererPane { + public static void main(String args[]) { + CellRendererPane crp = new CellRendererPane(); + Component c1 = crp.add(new Component(){}); + Component c2 = crp.add(new Component(){}); + Component c3 = crp.add(new Component(){}); + crp.setLayout(new FlowLayout()); + crp.invalidate(); + crp.getAccessibleContext(); + crp.getComponentCount(); + crp.countComponents(); + crp.getComponent(1); + crp.getComponent(2); + Component[] cs = crp.getComponents(); + Insets ins = crp.getInsets(); + ins = crp.insets(); + crp.getLayout(); + crp.setLayout(new FlowLayout()); + crp.setLayout(new FlowLayout()); + crp.doLayout(); + crp.layout(); + crp.invalidate(); + crp.validate(); + crp.remove(0); + crp.remove((Component) c2); + crp.removeAll(); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + crp.setFont(f1); + crp.setFont(f2); + crp.setFont(f3); + crp.setFont(f4); + + crp.getFontMetrics(f1); + crp.getFontMetrics(f2); + crp.getFontMetrics(f3); + crp.getFontMetrics(f4); + } + } + crp.getPreferredSize(); + crp.preferredSize(); + crp.getMinimumSize(); + crp.minimumSize(); + crp.getMaximumSize(); + crp.getAlignmentX(); + crp.getAlignmentY(); + crp.getComponentAt(1, 2); + crp.locate(1, 2); + crp.getComponentAt(new Point(1, 2)); + crp.isFocusCycleRoot(new Container()); + crp.transferFocusBackward(); + crp.setName("goober"); + crp.getName(); + crp.getParent(); + crp.getPeer(); + crp.getGraphicsConfiguration(); + crp.getTreeLock(); + crp.getToolkit(); + crp.isValid(); + crp.isDisplayable(); + crp.isVisible(); + crp.isShowing(); + crp.isEnabled(); + crp.setEnabled(false); + crp.setEnabled(true); + crp.enable(); + crp.enable(false); + crp.enable(true); + crp.disable(); + crp.isDoubleBuffered(); + crp.enableInputMethods(false); + crp.enableInputMethods(true); + crp.setVisible(false); + crp.setVisible(true); + crp.show(); + crp.show(false); + crp.show(true); + crp.hide(); + crp.getForeground(); + crp.setForeground(Color.red); + crp.isForegroundSet(); + crp.getBackground(); + crp.setBackground(Color.red); + crp.isBackgroundSet(); + crp.getFont(); + crp.isFontSet(); + + boolean exceptions = false; + try { + Container c = new Container(); + c.add(crp); + crp.getLocale(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + for (Locale locale : Locale.getAvailableLocales()) + crp.setLocale(locale); + + crp.getColorModel(); + crp.getLocation(); + + exceptions = false; + try { + crp.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + crp.location(); + crp.setLocation(1, 2); + crp.move(1, 2); + crp.setLocation(new Point(1, 2)); + crp.getSize(); + crp.size(); + crp.setSize(1, 32); + crp.resize(1, 32); + crp.setSize(new Dimension(1, 32)); + crp.resize(new Dimension(1, 32)); + crp.getBounds(); + crp.bounds(); + crp.setBounds(10, 10, 10, 10); + crp.reshape(10, 10, 10, 10); + crp.setBounds(new Rectangle(10, 10, 10, 10)); + crp.getX(); + crp.getY(); + crp.getWidth(); + crp.getHeight(); + crp.getBounds(new Rectangle(1, 1, 1, 1)); + crp.getSize(new Dimension(1, 2)); + crp.getLocation(new Point(1, 2)); + crp.isOpaque(); + crp.isLightweight(); + crp.getGraphics(); + crp.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + crp.getCursor(); + crp.isCursorSet(); + crp.contains(1, 2); + crp.inside(1, 2); + crp.contains(new Point(1, 2)); + crp.isFocusTraversable(); + crp.isFocusable(); + crp.setFocusable(true); + crp.setFocusable(false); + crp.requestFocus(); + crp.requestFocusInWindow(); + crp.transferFocus(); + crp.getFocusCycleRootAncestor(); + crp.nextFocus(); + crp.transferFocusUpCycle(); + crp.hasFocus(); + crp.isFocusOwner(); + crp.toString(); + crp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + crp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + crp.setComponentOrientation(ComponentOrientation.UNKNOWN); + crp.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer.java b/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer.java new file mode 100644 index 00000000000..efac418a393 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that DefaultListCellRenderer constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDefaultListCellRenderer + */ + +public class HeadlessDefaultListCellRenderer { + public static void main(String args[]) { + DefaultListCellRenderer dcr = new DefaultListCellRenderer(); + Component c1 = dcr.add(new Component(){}); + Component c2 = dcr.add(new Component(){}); + Component c3 = dcr.add(new Component(){}); + dcr.setLayout(new FlowLayout()); + dcr.invalidate(); + dcr.validate(); + dcr.getAccessibleContext(); + dcr.requestFocus(); + dcr.requestFocusInWindow(); + dcr.getPreferredSize(); + dcr.getMaximumSize(); + dcr.getMinimumSize(); + dcr.contains(1, 2); + Insets ins = dcr.getInsets(); + dcr.getAlignmentY(); + dcr.getAlignmentX(); + dcr.getGraphics(); + dcr.setVisible(false); + dcr.setVisible(true); + dcr.setEnabled(false); + dcr.setEnabled(true); + dcr.setForeground(Color.red); + dcr.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + dcr.setFont(f1); + dcr.setFont(f2); + dcr.setFont(f3); + dcr.setFont(f4); + + dcr.getFontMetrics(f1); + dcr.getFontMetrics(f2); + dcr.getFontMetrics(f3); + dcr.getFontMetrics(f4); + } + } + dcr.enable(); + dcr.disable(); + dcr.reshape(10, 10, 10, 10); + dcr.getBounds(new Rectangle(1, 1, 1, 1)); + dcr.getSize(new Dimension(1, 2)); + dcr.getLocation(new Point(1, 2)); + dcr.getX(); + dcr.getY(); + dcr.getWidth(); + dcr.getHeight(); + dcr.isOpaque(); + dcr.isValidateRoot(); + dcr.isOptimizedDrawingEnabled(); + dcr.isDoubleBuffered(); + dcr.getComponentCount(); + dcr.countComponents(); + dcr.getComponent(1); + dcr.getComponent(2); + Component[] cs = dcr.getComponents(); + ins = dcr.insets(); + dcr.remove(0); + dcr.remove((java.awt.Component) c2); + dcr.removeAll(); + dcr.getLayout(); + dcr.setLayout(new FlowLayout()); + dcr.doLayout(); + dcr.layout(); + dcr.invalidate(); + dcr.validate(); + dcr.revalidate(); + dcr.preferredSize(); + dcr.minimumSize(); + dcr.getComponentAt(1, 2); + dcr.locate(1, 2); + dcr.getComponentAt(new Point(1, 2)); + dcr.isFocusCycleRoot(new Container()); + dcr.transferFocusBackward(); + dcr.setName("goober"); + dcr.getName(); + dcr.getParent(); + dcr.getPeer(); + dcr.getGraphicsConfiguration(); + dcr.getTreeLock(); + dcr.getToolkit(); + dcr.isValid(); + dcr.isDisplayable(); + dcr.isVisible(); + dcr.isShowing(); + dcr.isEnabled(); + dcr.enable(false); + dcr.enable(true); + dcr.enableInputMethods(false); + dcr.enableInputMethods(true); + dcr.show(); + dcr.show(false); + dcr.show(true); + dcr.hide(); + dcr.getForeground(); + dcr.isForegroundSet(); + dcr.getBackground(); + dcr.isBackgroundSet(); + dcr.getFont(); + dcr.isFontSet(); + + Container c = new Container(); + c.add(dcr); + dcr.getLocale(); + + for (Locale locale : Locale.getAvailableLocales()) + dcr.setLocale(locale); + + dcr.getColorModel(); + dcr.getLocation(); + + boolean exceptions = false; + try { + dcr.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + dcr.location(); + dcr.setLocation(1, 2); + dcr.move(1, 2); + dcr.setLocation(new Point(1, 2)); + dcr.getSize(); + dcr.size(); + dcr.setSize(1, 32); + dcr.resize(1, 32); + dcr.setSize(new Dimension(1, 32)); + dcr.resize(new Dimension(1, 32)); + dcr.getBounds(); + dcr.bounds(); + dcr.setBounds(10, 10, 10, 10); + dcr.setBounds(new Rectangle(10, 10, 10, 10)); + dcr.isLightweight(); + dcr.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + dcr.getCursor(); + dcr.isCursorSet(); + dcr.inside(1, 2); + dcr.contains(new Point(1, 2)); + dcr.isFocusTraversable(); + dcr.isFocusable(); + dcr.setFocusable(true); + dcr.setFocusable(false); + dcr.transferFocus(); + dcr.getFocusCycleRootAncestor(); + dcr.nextFocus(); + dcr.transferFocusUpCycle(); + dcr.hasFocus(); + dcr.isFocusOwner(); + dcr.toString(); + dcr.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + dcr.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + dcr.setComponentOrientation(ComponentOrientation.UNKNOWN); + dcr.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer_UIResource.java b/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer_UIResource.java new file mode 100644 index 00000000000..457a1b0a9a6 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessDefaultListCellRenderer_UIResource.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that DefaultListCellRenderer.UIResource constructors and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessDefaultListCellRenderer_UIResource + */ + +public class HeadlessDefaultListCellRenderer_UIResource { + public static void main(String args[]) { + DefaultListCellRenderer.UIResource dcr = new DefaultListCellRenderer.UIResource(); + Component c1 = dcr.add(new Component(){}); + Component c2 = dcr.add(new Component(){}); + Component c3 = dcr.add(new Component(){}); + dcr.setLayout(new FlowLayout()); + dcr.invalidate(); + dcr.validate(); + dcr.getAccessibleContext(); + dcr.requestFocus(); + dcr.requestFocusInWindow(); + dcr.getPreferredSize(); + dcr.getMaximumSize(); + dcr.getMinimumSize(); + dcr.contains(1, 2); + Insets ins = dcr.getInsets(); + dcr.getAlignmentY(); + dcr.getAlignmentX(); + dcr.getGraphics(); + dcr.setVisible(false); + dcr.setVisible(true); + dcr.setEnabled(false); + dcr.setEnabled(true); + dcr.setForeground(Color.red); + dcr.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + dcr.setFont(f1); + dcr.setFont(f2); + dcr.setFont(f3); + dcr.setFont(f4); + + dcr.getFontMetrics(f1); + dcr.getFontMetrics(f2); + dcr.getFontMetrics(f3); + dcr.getFontMetrics(f4); + } + } + dcr.enable(); + dcr.disable(); + dcr.reshape(10, 10, 10, 10); + dcr.getBounds(new Rectangle(1, 1, 1, 1)); + dcr.getSize(new Dimension(1, 2)); + dcr.getLocation(new Point(1, 2)); + dcr.getX(); + dcr.getY(); + dcr.getWidth(); + dcr.getHeight(); + dcr.isOpaque(); + dcr.isValidateRoot(); + dcr.isOptimizedDrawingEnabled(); + dcr.isDoubleBuffered(); + dcr.getComponentCount(); + dcr.countComponents(); + dcr.getComponent(1); + dcr.getComponent(2); + Component[] cs = dcr.getComponents(); + ins = dcr.insets(); + dcr.remove(0); + dcr.remove((java.awt.Component) c2); + dcr.removeAll(); + dcr.getLayout(); + dcr.setLayout(new FlowLayout()); + dcr.doLayout(); + dcr.layout(); + dcr.invalidate(); + dcr.validate(); + dcr.revalidate(); + dcr.preferredSize(); + dcr.minimumSize(); + dcr.getComponentAt(1, 2); + dcr.locate(1, 2); + dcr.getComponentAt(new Point(1, 2)); + dcr.isFocusCycleRoot(new Container()); + dcr.transferFocusBackward(); + dcr.setName("goober"); + dcr.getName(); + dcr.getParent(); + dcr.getPeer(); + dcr.getGraphicsConfiguration(); + dcr.getTreeLock(); + dcr.getToolkit(); + dcr.isValid(); + dcr.isDisplayable(); + dcr.isVisible(); + dcr.isShowing(); + dcr.isEnabled(); + dcr.enable(false); + dcr.enable(true); + dcr.enableInputMethods(false); + dcr.enableInputMethods(true); + dcr.show(); + dcr.show(false); + dcr.show(true); + dcr.hide(); + dcr.getForeground(); + dcr.isForegroundSet(); + dcr.getBackground(); + dcr.isBackgroundSet(); + dcr.getFont(); + dcr.isFontSet(); + + Container c = new Container(); + c.add(dcr); + dcr.getLocale(); + + for (Locale locale : Locale.getAvailableLocales()) + dcr.setLocale(locale); + + dcr.getColorModel(); + dcr.getLocation(); + + boolean exceptions = false; + try { + dcr.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + dcr.location(); + dcr.setLocation(1, 2); + dcr.move(1, 2); + dcr.setLocation(new Point(1, 2)); + dcr.getSize(); + dcr.size(); + dcr.setSize(1, 32); + dcr.resize(1, 32); + dcr.setSize(new Dimension(1, 32)); + dcr.resize(new Dimension(1, 32)); + dcr.getBounds(); + dcr.bounds(); + dcr.setBounds(10, 10, 10, 10); + dcr.setBounds(new Rectangle(10, 10, 10, 10)); + dcr.isLightweight(); + dcr.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + dcr.getCursor(); + dcr.isCursorSet(); + dcr.inside(1, 2); + dcr.contains(new Point(1, 2)); + dcr.isFocusTraversable(); + dcr.isFocusable(); + dcr.setFocusable(true); + dcr.setFocusable(false); + dcr.transferFocus(); + dcr.getFocusCycleRootAncestor(); + dcr.nextFocus(); + dcr.transferFocusUpCycle(); + dcr.hasFocus(); + dcr.isFocusOwner(); + dcr.toString(); + dcr.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + dcr.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + dcr.setComponentOrientation(ComponentOrientation.UNKNOWN); + dcr.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessGrayFilter.java b/jdk/test/javax/swing/Headless/HeadlessGrayFilter.java new file mode 100644 index 00000000000..07320b9bbf0 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessGrayFilter.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; + +/* + * @test + * @summary Check that GrayFilter constructor and clone() method do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessGrayFilter + */ + +public class HeadlessGrayFilter { + public static void main(String args[]) { + new GrayFilter(true, 60).clone(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJApplet.java b/jdk/test/javax/swing/Headless/HeadlessJApplet.java new file mode 100644 index 00000000000..e0ac858ac09 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJApplet.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JApplet; +import java.awt.HeadlessException; + +/* + * @test + * @summary Check that JApplet constructor throws HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJApplet + */ + +public class HeadlessJApplet { + public static void main(String args[]) { + boolean exceptions = false; + try { + new JApplet(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJButton.java b/jdk/test/javax/swing/Headless/HeadlessJButton.java new file mode 100644 index 00000000000..7f80803f247 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJButton.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JButton constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJButton + */ + +public class HeadlessJButton { + public static void main(String args[]) { + JButton b = new JButton(); + b = new JButton("Press me"); + b.getAccessibleContext(); + b.isFocusTraversable(); + b.setEnabled(false); + b.setEnabled(true); + b.requestFocus(); + b.requestFocusInWindow(); + b.getPreferredSize(); + b.getMaximumSize(); + b.getMinimumSize(); + b.contains(1, 2); + Component c1 = b.add(new Component(){}); + Component c2 = b.add(new Component(){}); + Component c3 = b.add(new Component(){}); + Insets ins = b.getInsets(); + b.getAlignmentY(); + b.getAlignmentX(); + b.getGraphics(); + b.setVisible(false); + b.setVisible(true); + b.setForeground(Color.red); + b.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + b.setFont(f1); + b.setFont(f2); + b.setFont(f3); + b.setFont(f4); + + b.getFontMetrics(f1); + b.getFontMetrics(f2); + b.getFontMetrics(f3); + b.getFontMetrics(f4); + } + } + b.enable(); + b.disable(); + b.reshape(10, 10, 10, 10); + b.getBounds(new Rectangle(1, 1, 1, 1)); + b.getSize(new Dimension(1, 2)); + b.getLocation(new Point(1, 2)); + b.getX(); + b.getY(); + b.getWidth(); + b.getHeight(); + b.isOpaque(); + b.isValidateRoot(); + b.isOptimizedDrawingEnabled(); + b.isDoubleBuffered(); + b.getComponentCount(); + b.countComponents(); + b.getComponent(1); + b.getComponent(2); + Component[] cs = b.getComponents(); + b.getLayout(); + b.setLayout(new FlowLayout()); + b.doLayout(); + b.layout(); + b.invalidate(); + b.validate(); + b.remove(0); + b.remove(c2); + b.removeAll(); + b.preferredSize(); + b.minimumSize(); + b.getComponentAt(1, 2); + b.locate(1, 2); + b.getComponentAt(new Point(1, 2)); + b.isFocusCycleRoot(new Container()); + b.transferFocusBackward(); + b.setName("goober"); + b.getName(); + b.getParent(); + b.getPeer(); + b.getGraphicsConfiguration(); + b.getTreeLock(); + b.getToolkit(); + b.isValid(); + b.isDisplayable(); + b.isVisible(); + b.isShowing(); + b.isEnabled(); + b.enable(false); + b.enable(true); + b.enableInputMethods(false); + b.enableInputMethods(true); + b.show(); + b.show(false); + b.show(true); + b.hide(); + b.getForeground(); + b.isForegroundSet(); + b.getBackground(); + b.isBackgroundSet(); + b.getFont(); + b.isFontSet(); + Container c = new Container(); + c.add(b); + b.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + b.setLocale(locale); + + b.getColorModel(); + b.getLocation(); + + boolean exceptions = false; + try { + b.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + b.location(); + b.setLocation(1, 2); + b.move(1, 2); + b.setLocation(new Point(1, 2)); + b.getSize(); + b.size(); + b.setSize(1, 32); + b.resize(1, 32); + b.setSize(new Dimension(1, 32)); + b.resize(new Dimension(1, 32)); + b.getBounds(); + b.bounds(); + b.setBounds(10, 10, 10, 10); + b.setBounds(new Rectangle(10, 10, 10, 10)); + b.isLightweight(); + b.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + b.getCursor(); + b.isCursorSet(); + b.inside(1, 2); + b.contains(new Point(1, 2)); + b.isFocusable(); + b.setFocusable(true); + b.setFocusable(false); + b.transferFocus(); + b.getFocusCycleRootAncestor(); + b.nextFocus(); + b.transferFocusUpCycle(); + b.hasFocus(); + b.isFocusOwner(); + b.toString(); + b.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + b.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + b.setComponentOrientation(ComponentOrientation.UNKNOWN); + b.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJCheckBox.java b/jdk/test/javax/swing/Headless/HeadlessJCheckBox.java new file mode 100644 index 00000000000..9fd98563682 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJCheckBox.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JCheckBox constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJCheckBox + */ + +public class HeadlessJCheckBox { + public static void main(String args[]) { + JCheckBox ch; + ch = new JCheckBox(); + ch = new JCheckBox("Press me"); + ch = new JCheckBox("Press me", true); + ch = new JCheckBox("Press me", false); + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJCheckBoxMenuItem.java b/jdk/test/javax/swing/Headless/HeadlessJCheckBoxMenuItem.java new file mode 100644 index 00000000000..80673aae532 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJCheckBoxMenuItem.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JCheckBoxMenuItem constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJCheckBoxMenuItem + */ + +public class HeadlessJCheckBoxMenuItem { + public static void main(String args[]) { + JCheckBoxMenuItem ch; + ch = new JCheckBoxMenuItem(); + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJColorChooser.java b/jdk/test/javax/swing/Headless/HeadlessJColorChooser.java new file mode 100644 index 00000000000..a78383c2800 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJColorChooser.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JColorChooser constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJColorChooser + */ + +public class HeadlessJColorChooser { + public static void main(String args[]) { + JColorChooser cc; + cc = new JColorChooser(); + cc.getAccessibleContext(); + cc.isFocusTraversable(); + cc.setEnabled(false); + cc.setEnabled(true); + cc.requestFocus(); + cc.requestFocusInWindow(); + cc.getPreferredSize(); + cc.getMaximumSize(); + cc.getMinimumSize(); + cc.contains(1, 2); + Component c1 = cc.add(new Component(){}); + Component c2 = cc.add(new Component(){}); + Component c3 = cc.add(new Component(){}); + Insets ins = cc.getInsets(); + cc.getAlignmentY(); + cc.getAlignmentX(); + cc.getGraphics(); + cc.setVisible(false); + cc.setVisible(true); + cc.setForeground(Color.red); + cc.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + cc.setFont(f1); + cc.setFont(f2); + cc.setFont(f3); + cc.setFont(f4); + + cc.getFontMetrics(f1); + cc.getFontMetrics(f2); + cc.getFontMetrics(f3); + cc.getFontMetrics(f4); + } + } + cc.enable(); + cc.disable(); + cc.reshape(10, 10, 10, 10); + cc.getBounds(new Rectangle(1, 1, 1, 1)); + cc.getSize(new Dimension(1, 2)); + cc.getLocation(new Point(1, 2)); + cc.getX(); + cc.getY(); + cc.getWidth(); + cc.getHeight(); + cc.isOpaque(); + cc.isValidateRoot(); + cc.isOptimizedDrawingEnabled(); + cc.isDoubleBuffered(); + cc.getComponentCount(); + cc.countComponents(); + cc.getComponent(1); + cc.getComponent(2); + Component[] cs = cc.getComponents(); + cc.getLayout(); + cc.setLayout(new FlowLayout()); + cc.doLayout(); + cc.layout(); + cc.invalidate(); + cc.validate(); + cc.remove(0); + cc.remove(c2); + cc.removeAll(); + cc.preferredSize(); + cc.minimumSize(); + cc.getComponentAt(1, 2); + cc.locate(1, 2); + cc.getComponentAt(new Point(1, 2)); + cc.isFocusCycleRoot(new Container()); + cc.transferFocusBackward(); + cc.setName("goober"); + cc.getName(); + cc.getParent(); + cc.getPeer(); + cc.getGraphicsConfiguration(); + cc.getTreeLock(); + cc.getToolkit(); + cc.isValid(); + cc.isDisplayable(); + cc.isVisible(); + cc.isShowing(); + cc.isEnabled(); + cc.enable(false); + cc.enable(true); + cc.enableInputMethods(false); + cc.enableInputMethods(true); + cc.show(); + cc.show(false); + cc.show(true); + cc.hide(); + cc.getForeground(); + cc.isForegroundSet(); + cc.getBackground(); + cc.isBackgroundSet(); + cc.getFont(); + cc.isFontSet(); + Container c = new Container(); + c.add(cc); + cc.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + cc.setLocale(locale); + + cc.getColorModel(); + cc.getLocation(); + + boolean exceptions = false; + try { + cc.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + cc.location(); + cc.setLocation(1, 2); + cc.move(1, 2); + cc.setLocation(new Point(1, 2)); + cc.getSize(); + cc.size(); + cc.setSize(1, 32); + cc.resize(1, 32); + cc.setSize(new Dimension(1, 32)); + cc.resize(new Dimension(1, 32)); + cc.getBounds(); + cc.bounds(); + cc.setBounds(10, 10, 10, 10); + cc.setBounds(new Rectangle(10, 10, 10, 10)); + cc.isLightweight(); + cc.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + cc.getCursor(); + cc.isCursorSet(); + cc.inside(1, 2); + cc.contains(new Point(1, 2)); + cc.isFocusable(); + cc.setFocusable(true); + cc.setFocusable(false); + cc.transferFocus(); + cc.getFocusCycleRootAncestor(); + cc.nextFocus(); + cc.transferFocusUpCycle(); + cc.hasFocus(); + cc.isFocusOwner(); + cc.toString(); + cc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + cc.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + cc.setComponentOrientation(ComponentOrientation.UNKNOWN); + cc.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJComboBox.java b/jdk/test/javax/swing/Headless/HeadlessJComboBox.java new file mode 100644 index 00000000000..b5160543db2 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJComboBox.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JComboBox constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJComboBox + */ + +public class HeadlessJComboBox { + public static void main(String args[]) { + JComboBox ch; + ch = new JComboBox(); + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJComponent.java b/jdk/test/javax/swing/Headless/HeadlessJComponent.java new file mode 100644 index 00000000000..80c10818a31 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJComponent.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JComponent constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJComponent + */ + +public class HeadlessJComponent { + public static void main(String args[]) { + JComponent ch = new JComponent(){}; + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJDesktopPane.java b/jdk/test/javax/swing/Headless/HeadlessJDesktopPane.java new file mode 100644 index 00000000000..2a1d231e3f2 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJDesktopPane.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JDesktopPane constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJDesktopPane + */ + +public class HeadlessJDesktopPane { + public static void main(String args[]) { + JComponent ch = new JComponent(){}; + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJDialog.java b/jdk/test/javax/swing/Headless/HeadlessJDialog.java new file mode 100644 index 00000000000..f5c174ead60 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJDialog.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; + +/* + * @test + * @summary Check that JDialog constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJDialog + */ + +public class HeadlessJDialog { + public static void main(String args[]) { + boolean exceptions = false; + JDialog b; + + try { + b = new JDialog(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title")); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title"), true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title"), false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title"), "Dialog title"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title"), "Dialog title", true); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + b = new JDialog(new Frame("Frame title"), "Dialog title", false); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJEditorPane.java b/jdk/test/javax/swing/Headless/HeadlessJEditorPane.java new file mode 100644 index 00000000000..1b408b38e4f --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJEditorPane.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JEditorPane constructors and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJEditorPane + */ + +public class HeadlessJEditorPane { + public static void main(String args[]) { + JEditorPane b; + b = new JEditorPane("text/plain", "The Text"); + b = new JEditorPane("unknown/unknown", "The Text"); + b = new JEditorPane(); + b.getAccessibleContext(); + b.isFocusTraversable(); + b.setEnabled(false); + b.setEnabled(true); + b.requestFocus(); + b.requestFocusInWindow(); + b.getPreferredSize(); + b.getMaximumSize(); + b.getMinimumSize(); + b.contains(1, 2); + Component c1 = b.add(new Component(){}); + Component c2 = b.add(new Component(){}); + Component c3 = b.add(new Component(){}); + Insets ins = b.getInsets(); + b.getAlignmentY(); + b.getAlignmentX(); + b.getGraphics(); + b.setVisible(false); + b.setVisible(true); + b.setForeground(Color.red); + b.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + b.setFont(f1); + b.setFont(f2); + b.setFont(f3); + b.setFont(f4); + + b.getFontMetrics(f1); + b.getFontMetrics(f2); + b.getFontMetrics(f3); + b.getFontMetrics(f4); + } + } + b.enable(); + b.disable(); + b.reshape(10, 10, 10, 10); + b.getBounds(new Rectangle(1, 1, 1, 1)); + b.getSize(new Dimension(1, 2)); + b.getLocation(new Point(1, 2)); + b.getX(); + b.getY(); + b.getWidth(); + b.getHeight(); + b.isOpaque(); + b.isValidateRoot(); + b.isOptimizedDrawingEnabled(); + b.isDoubleBuffered(); + b.getComponentCount(); + b.countComponents(); + b.getComponent(1); + b.getComponent(2); + Component[] cs = b.getComponents(); + b.getLayout(); + b.setLayout(new FlowLayout()); + b.doLayout(); + b.layout(); + b.invalidate(); + b.validate(); + b.remove(0); + b.remove(c2); + b.removeAll(); + b.preferredSize(); + b.minimumSize(); + b.getComponentAt(1, 2); + b.locate(1, 2); + b.getComponentAt(new Point(1, 2)); + b.isFocusCycleRoot(new Container()); + b.transferFocusBackward(); + b.setName("goober"); + b.getName(); + b.getParent(); + b.getPeer(); + b.getGraphicsConfiguration(); + b.getTreeLock(); + b.getToolkit(); + b.isValid(); + b.isDisplayable(); + b.isVisible(); + b.isShowing(); + b.isEnabled(); + b.enable(false); + b.enable(true); + b.enableInputMethods(false); + b.enableInputMethods(true); + b.show(); + b.show(false); + b.show(true); + b.hide(); + b.getForeground(); + b.isForegroundSet(); + b.getBackground(); + b.isBackgroundSet(); + b.getFont(); + b.isFontSet(); + Container c = new Container(); + c.add(b); + b.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + b.setLocale(locale); + + b.getColorModel(); + b.getLocation(); + + boolean exceptions = false; + try { + b.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + b.location(); + b.setLocation(1, 2); + b.move(1, 2); + b.setLocation(new Point(1, 2)); + b.getSize(); + b.size(); + b.setSize(1, 32); + b.resize(1, 32); + b.setSize(new Dimension(1, 32)); + b.resize(new Dimension(1, 32)); + b.getBounds(); + b.bounds(); + b.setBounds(10, 10, 10, 10); + b.setBounds(new Rectangle(10, 10, 10, 10)); + b.isLightweight(); + b.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + b.getCursor(); + b.isCursorSet(); + b.inside(1, 2); + b.contains(new Point(1, 2)); + b.isFocusable(); + b.setFocusable(true); + b.setFocusable(false); + b.transferFocus(); + b.getFocusCycleRootAncestor(); + b.nextFocus(); + b.transferFocusUpCycle(); + b.hasFocus(); + b.isFocusOwner(); + b.toString(); + b.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + b.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + b.setComponentOrientation(ComponentOrientation.UNKNOWN); + b.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJFileChooser.java b/jdk/test/javax/swing/Headless/HeadlessJFileChooser.java new file mode 100644 index 00000000000..7acac2baf27 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJFileChooser.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JFileChooser constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJFileChooser + */ + +public class HeadlessJFileChooser { + public static void main(String args[]) { + JFileChooser ch = new JFileChooser(); + ch.getAccessibleContext(); + ch.isFocusTraversable(); + ch.setEnabled(false); + ch.setEnabled(true); + ch.requestFocus(); + ch.requestFocusInWindow(); + ch.getPreferredSize(); + ch.getMaximumSize(); + ch.getMinimumSize(); + ch.contains(1, 2); + Component c1 = ch.add(new Component(){}); + Component c2 = ch.add(new Component(){}); + Component c3 = ch.add(new Component(){}); + Insets ins = ch.getInsets(); + ch.getAlignmentY(); + ch.getAlignmentX(); + ch.getGraphics(); + ch.setVisible(false); + ch.setVisible(true); + ch.setForeground(Color.red); + ch.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + ch.setFont(f1); + ch.setFont(f2); + ch.setFont(f3); + ch.setFont(f4); + + ch.getFontMetrics(f1); + ch.getFontMetrics(f2); + ch.getFontMetrics(f3); + ch.getFontMetrics(f4); + } + } + ch.enable(); + ch.disable(); + ch.reshape(10, 10, 10, 10); + ch.getBounds(new Rectangle(1, 1, 1, 1)); + ch.getSize(new Dimension(1, 2)); + ch.getLocation(new Point(1, 2)); + ch.getX(); + ch.getY(); + ch.getWidth(); + ch.getHeight(); + ch.isOpaque(); + ch.isValidateRoot(); + ch.isOptimizedDrawingEnabled(); + ch.isDoubleBuffered(); + ch.getComponentCount(); + ch.countComponents(); + ch.getComponent(1); + ch.getComponent(2); + Component[] cs = ch.getComponents(); + ch.getLayout(); + ch.setLayout(new FlowLayout()); + ch.doLayout(); + ch.layout(); + ch.invalidate(); + ch.validate(); + ch.remove(0); + ch.remove(c2); + ch.removeAll(); + ch.preferredSize(); + ch.minimumSize(); + ch.getComponentAt(1, 2); + ch.locate(1, 2); + ch.getComponentAt(new Point(1, 2)); + ch.isFocusCycleRoot(new Container()); + ch.transferFocusBackward(); + ch.setName("goober"); + ch.getName(); + ch.getParent(); + ch.getPeer(); + ch.getGraphicsConfiguration(); + ch.getTreeLock(); + ch.getToolkit(); + ch.isValid(); + ch.isDisplayable(); + ch.isVisible(); + ch.isShowing(); + ch.isEnabled(); + ch.enable(false); + ch.enable(true); + ch.enableInputMethods(false); + ch.enableInputMethods(true); + ch.show(); + ch.show(false); + ch.show(true); + ch.hide(); + ch.getForeground(); + ch.isForegroundSet(); + ch.getBackground(); + ch.isBackgroundSet(); + ch.getFont(); + ch.isFontSet(); + Container c = new Container(); + c.add(ch); + ch.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + ch.setLocale(locale); + + ch.getColorModel(); + ch.getLocation(); + + boolean exceptions = false; + try { + ch.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + ch.location(); + ch.setLocation(1, 2); + ch.move(1, 2); + ch.setLocation(new Point(1, 2)); + ch.getSize(); + ch.size(); + ch.setSize(1, 32); + ch.resize(1, 32); + ch.setSize(new Dimension(1, 32)); + ch.resize(new Dimension(1, 32)); + ch.getBounds(); + ch.bounds(); + ch.setBounds(10, 10, 10, 10); + ch.setBounds(new Rectangle(10, 10, 10, 10)); + ch.isLightweight(); + ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + ch.getCursor(); + ch.isCursorSet(); + ch.inside(1, 2); + ch.contains(new Point(1, 2)); + ch.isFocusable(); + ch.setFocusable(true); + ch.setFocusable(false); + ch.transferFocus(); + ch.getFocusCycleRootAncestor(); + ch.nextFocus(); + ch.transferFocusUpCycle(); + ch.hasFocus(); + ch.isFocusOwner(); + ch.toString(); + ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + ch.setComponentOrientation(ComponentOrientation.UNKNOWN); + ch.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJFormattedTextField.java b/jdk/test/javax/swing/Headless/HeadlessJFormattedTextField.java new file mode 100644 index 00000000000..21049a76d37 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJFormattedTextField.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; + +/* + * @test + * @summary Check that JFormattedTextField constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJFormattedTextField + */ + +public class HeadlessJFormattedTextField { + public static void main(String args[]) { + JTextField f = new JTextField("field"); + f.selectAll(); + f.getSelectionStart(); + f.getSelectionEnd(); + f.selectAll(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJFrame.java b/jdk/test/javax/swing/Headless/HeadlessJFrame.java new file mode 100644 index 00000000000..b1a077459d8 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJFrame.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import java.awt.HeadlessException; + +/* + * @test + * @summary Check that JFrame constructors throw HeadlessException in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJFrame + */ + +public class HeadlessJFrame { + public static void main(String args[]) { + boolean exceptions = false; + try { + JFrame b = new JFrame(); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + + exceptions = false; + try { + JFrame b = new JFrame("Swingin' in the window"); + } catch (HeadlessException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("HeadlessException did not occur when expected"); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJInternalFrame.java b/jdk/test/javax/swing/Headless/HeadlessJInternalFrame.java new file mode 100644 index 00000000000..f642b1a8ccd --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJInternalFrame.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import javax.swing.plaf.basic.BasicInternalFrameTitlePane; +import javax.swing.plaf.basic.BasicInternalFrameUI; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Locale; + +/* + * @test + * @summary Check that JInternalFrame constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJInternalFrame + */ + +public class HeadlessJInternalFrame { + public static void main(String args[]) { + JInternalFrame intf = new JInternalFrame("TEST"); + intf.setUI(new BasicInternalFrameUI(intf) { + protected JComponent createNorthPane(JInternalFrame w) { + titlePane = new BasicInternalFrameTitlePane(w) { + protected PropertyChangeListener createPropertyChangeListener() { + return new BasicInternalFrameTitlePane.PropertyChangeHandler() { + int countUI = 0; + + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("UI")) + countUI++; + else if (countUI > 1) + throw new RuntimeException("Test failed. Listener not removed!"); + } + }; + } + }; + return titlePane; + } + }); + intf.setUI(null); + intf.getAccessibleContext(); + intf.isFocusTraversable(); + intf.setEnabled(false); + intf.setEnabled(true); + intf.requestFocus(); + intf.requestFocusInWindow(); + intf.getPreferredSize(); + intf.getMaximumSize(); + intf.getMinimumSize(); + intf.contains(1, 2); + Component c1 = intf.add(new Component(){}); + Component c2 = intf.add(new Component(){}); + Component c3 = intf.add(new Component(){}); + Insets ins = intf.getInsets(); + intf.getAlignmentY(); + intf.getAlignmentX(); + intf.getGraphics(); + intf.setVisible(false); + intf.setVisible(true); + intf.setForeground(Color.red); + intf.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + intf.setFont(f1); + intf.setFont(f2); + intf.setFont(f3); + intf.setFont(f4); + + intf.getFontMetrics(f1); + intf.getFontMetrics(f2); + intf.getFontMetrics(f3); + intf.getFontMetrics(f4); + } + } + intf.enable(); + intf.disable(); + intf.reshape(10, 10, 10, 10); + intf.getBounds(new Rectangle(1, 1, 1, 1)); + intf.getSize(new Dimension(1, 2)); + intf.getLocation(new Point(1, 2)); + intf.getX(); + intf.getY(); + intf.getWidth(); + intf.getHeight(); + intf.isOpaque(); + intf.isValidateRoot(); + intf.isOptimizedDrawingEnabled(); + intf.isDoubleBuffered(); + intf.getComponentCount(); + intf.countComponents(); + intf.getComponent(0); + Component[] cs = intf.getComponents(); + intf.getLayout(); + intf.setLayout(new FlowLayout()); + intf.doLayout(); + intf.layout(); + intf.invalidate(); + intf.validate(); + intf.remove(0); + intf.remove(c2); + intf.removeAll(); + intf.preferredSize(); + intf.minimumSize(); + intf.getComponentAt(1, 2); + intf.locate(1, 2); + intf.getComponentAt(new Point(1, 2)); + intf.isFocusCycleRoot(new Container()); + intf.transferFocusBackward(); + intf.setName("goober"); + intf.getName(); + intf.getParent(); + intf.getPeer(); + intf.getGraphicsConfiguration(); + intf.getTreeLock(); + intf.getToolkit(); + intf.isValid(); + intf.isDisplayable(); + intf.isVisible(); + intf.isShowing(); + intf.isEnabled(); + intf.enable(false); + intf.enable(true); + intf.enableInputMethods(false); + intf.enableInputMethods(true); + intf.show(); + intf.show(false); + intf.show(true); + intf.hide(); + intf.getForeground(); + intf.isForegroundSet(); + intf.getBackground(); + intf.isBackgroundSet(); + intf.getFont(); + intf.isFontSet(); + Container c = new Container(); + c.add(intf); + intf.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + intf.setLocale(locale); + + intf.getColorModel(); + intf.getLocation(); + + boolean exceptions = false; + try { + intf.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + intf.location(); + intf.setLocation(1, 2); + intf.move(1, 2); + intf.setLocation(new Point(1, 2)); + intf.getSize(); + intf.size(); + intf.setSize(1, 32); + intf.resize(1, 32); + intf.setSize(new Dimension(1, 32)); + intf.resize(new Dimension(1, 32)); + intf.getBounds(); + intf.bounds(); + intf.setBounds(10, 10, 10, 10); + intf.setBounds(new Rectangle(10, 10, 10, 10)); + intf.isLightweight(); + intf.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + intf.getCursor(); + intf.isCursorSet(); + intf.inside(1, 2); + intf.contains(new Point(1, 2)); + intf.isFocusable(); + intf.setFocusable(true); + intf.setFocusable(false); + intf.transferFocus(); + intf.getFocusCycleRootAncestor(); + intf.nextFocus(); + intf.transferFocusUpCycle(); + intf.hasFocus(); + intf.isFocusOwner(); + intf.toString(); + intf.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + intf.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + intf.setComponentOrientation(ComponentOrientation.UNKNOWN); + intf.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJInternalFrame_JDesktopIcon.java b/jdk/test/javax/swing/Headless/HeadlessJInternalFrame_JDesktopIcon.java new file mode 100644 index 00000000000..e6c1cf4e2e8 --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJInternalFrame_JDesktopIcon.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JInternalFrame.JDesktopIcon constructor and methods do not throw + * unexpected exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJInternalFrame_JDesktopIcon + */ + +public class HeadlessJInternalFrame_JDesktopIcon { + public static void main(String args[]) { + JInternalFrame.JDesktopIcon jdi = new JInternalFrame.JDesktopIcon(new JInternalFrame()); + jdi.getAccessibleContext(); + jdi.isFocusTraversable(); + jdi.setEnabled(false); + jdi.setEnabled(true); + jdi.requestFocus(); + jdi.requestFocusInWindow(); + jdi.getPreferredSize(); + jdi.getMaximumSize(); + jdi.getMinimumSize(); + jdi.contains(1, 2); + Component c1 = jdi.add(new Component(){}); + Component c2 = jdi.add(new Component(){}); + Component c3 = jdi.add(new Component(){}); + Insets ins = jdi.getInsets(); + jdi.getAlignmentY(); + jdi.getAlignmentX(); + jdi.getGraphics(); + jdi.setVisible(false); + jdi.setVisible(true); + jdi.setForeground(Color.red); + jdi.setBackground(Color.red); + for (String font : Toolkit.getDefaultToolkit().getFontList()) { + for (int j = 8; j < 17; j++) { + Font f1 = new Font(font, Font.PLAIN, j); + Font f2 = new Font(font, Font.BOLD, j); + Font f3 = new Font(font, Font.ITALIC, j); + Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); + + jdi.setFont(f1); + jdi.setFont(f2); + jdi.setFont(f3); + jdi.setFont(f4); + + jdi.getFontMetrics(f1); + jdi.getFontMetrics(f2); + jdi.getFontMetrics(f3); + jdi.getFontMetrics(f4); + } + } + jdi.enable(); + jdi.disable(); + jdi.reshape(10, 10, 10, 10); + jdi.getBounds(new Rectangle(1, 1, 1, 1)); + jdi.getSize(new Dimension(1, 2)); + jdi.getLocation(new Point(1, 2)); + jdi.getX(); + jdi.getY(); + jdi.getWidth(); + jdi.getHeight(); + jdi.isOpaque(); + jdi.isValidateRoot(); + jdi.isOptimizedDrawingEnabled(); + jdi.isDoubleBuffered(); + jdi.getComponentCount(); + jdi.countComponents(); + jdi.getComponent(1); + jdi.getComponent(2); + Component[] cs = jdi.getComponents(); + jdi.getLayout(); + jdi.setLayout(new FlowLayout()); + jdi.doLayout(); + jdi.layout(); + jdi.invalidate(); + jdi.validate(); + jdi.remove(0); + jdi.remove(c2); + jdi.removeAll(); + jdi.preferredSize(); + jdi.minimumSize(); + jdi.getComponentAt(1, 2); + jdi.locate(1, 2); + jdi.getComponentAt(new Point(1, 2)); + jdi.isFocusCycleRoot(new Container()); + jdi.transferFocusBackward(); + jdi.setName("goober"); + jdi.getName(); + jdi.getParent(); + jdi.getPeer(); + jdi.getGraphicsConfiguration(); + jdi.getTreeLock(); + jdi.getToolkit(); + jdi.isValid(); + jdi.isDisplayable(); + jdi.isVisible(); + jdi.isShowing(); + jdi.isEnabled(); + jdi.enable(false); + jdi.enable(true); + jdi.enableInputMethods(false); + jdi.enableInputMethods(true); + jdi.show(); + jdi.show(false); + jdi.show(true); + jdi.hide(); + jdi.getForeground(); + jdi.isForegroundSet(); + jdi.getBackground(); + jdi.isBackgroundSet(); + jdi.getFont(); + jdi.isFontSet(); + Container c = new Container(); + c.add(jdi); + jdi.getLocale(); + for (Locale locale : Locale.getAvailableLocales()) + jdi.setLocale(locale); + + jdi.getColorModel(); + jdi.getLocation(); + + boolean exceptions = false; + try { + jdi.getLocationOnScreen(); + } catch (IllegalComponentStateException e) { + exceptions = true; + } + if (!exceptions) + throw new RuntimeException("IllegalComponentStateException did not occur when expected"); + + jdi.location(); + jdi.setLocation(1, 2); + jdi.move(1, 2); + jdi.setLocation(new Point(1, 2)); + jdi.getSize(); + jdi.size(); + jdi.setSize(1, 32); + jdi.resize(1, 32); + jdi.setSize(new Dimension(1, 32)); + jdi.resize(new Dimension(1, 32)); + jdi.getBounds(); + jdi.bounds(); + jdi.setBounds(10, 10, 10, 10); + jdi.setBounds(new Rectangle(10, 10, 10, 10)); + jdi.isLightweight(); + jdi.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + jdi.getCursor(); + jdi.isCursorSet(); + jdi.inside(1, 2); + jdi.contains(new Point(1, 2)); + jdi.isFocusable(); + jdi.setFocusable(true); + jdi.setFocusable(false); + jdi.transferFocus(); + jdi.getFocusCycleRootAncestor(); + jdi.nextFocus(); + jdi.transferFocusUpCycle(); + jdi.hasFocus(); + jdi.isFocusOwner(); + jdi.toString(); + jdi.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + jdi.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + jdi.setComponentOrientation(ComponentOrientation.UNKNOWN); + jdi.getComponentOrientation(); + } +} diff --git a/jdk/test/javax/swing/Headless/HeadlessJLabel.java b/jdk/test/javax/swing/Headless/HeadlessJLabel.java new file mode 100644 index 00000000000..a61c1fb672c --- /dev/null +++ b/jdk/test/javax/swing/Headless/HeadlessJLabel.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.util.Locale; + +/* + * @test + * @summary Check that JLabel constructor and methods do not throw unexpected + * exceptions in headless mode + * @run main/othervm -Djava.awt.headless=true HeadlessJLabel + */ + +public class HeadlessJLabel { + public static void main(String args[]) { + JLabel l = new JLabel("