# HG changeset patch # User alexsch # Date 1441713689 -14400 # Node ID 82e066c83bd0accd2ade4dab2e548c4bd782e4f0 # Parent 177450b9f1a6ab09470c6285eb8f44ba1cd69469 8135176: Moving test from javax/swing/plaf/basic/BasicHTML/4960629 to test/javax/swing/plaf/basic/BasicHTML/4960629 Reviewed-by: azvegint, alexsch Contributed-by: Shilpi Rastogi diff -r 177450b9f1a6 -r 82e066c83bd0 javax/swing/plaf/basic/BasicHTML/4960629/bug4960629.java --- a/javax/swing/plaf/basic/BasicHTML/4960629/bug4960629.java Tue Sep 08 11:28:16 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - @bug 4960629 7124238 - @summary Tests if font for html text on widgets in correct. - @author Denis Sharypov - @run main bug4960629 -*/ - -import java.awt.Font; -import java.lang.reflect.InvocationTargetException; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.AttributeSet; -import javax.swing.text.View; -import javax.swing.text.html.StyleSheet; -import javax.swing.text.html.HTMLDocument; - -public class bug4960629 { - private boolean passed = false; - private JLabel label = null; - private JFrame f = null; - - public void createAndShowGUI() throws Exception { - try { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - label = new JLabel("

This is a test of the

"); - System.out.println("UIManager.getLookAndFeel()" - + UIManager.getLookAndFeel().getClass()); - f = new JFrame(); - f.getContentPane().add(label); - f.pack(); - f.setVisible(true); - test(); - } finally { - f.dispose(); - } - } - - bug4960629() throws InvocationTargetException, InterruptedException { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - try { - createAndShowGUI(); - } catch (Exception e) { - throw new RuntimeException("Exception " - + e.getMessage()); - } - } - }); - } - - private void test() { - View root = ((View)label.getClientProperty(BasicHTML.propertyKey)) - .getView(0); - int n = root.getViewCount(); - View v = root.getView(n - 1); - AttributeSet attrs = v.getAttributes(); - StyleSheet ss = ((HTMLDocument) v.getDocument()).getStyleSheet(); - Font font = ss.getFont(attrs); - System.out.println(font.getSize()); - passed = (font.getSize() == 12); - if(!passed) { - throw new RuntimeException("Test failed."); - } - } - - public static void main(String args[]) throws Throwable { - new bug4960629(); - } -} diff -r 177450b9f1a6 -r 82e066c83bd0 test/javax/swing/plaf/basic/BasicHTML/4960629/bug4960629.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/plaf/basic/BasicHTML/4960629/bug4960629.java Tue Sep 08 16:01:29 2015 +0400 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 4960629 7124238 + @summary Tests if font for html text on widgets in correct. + @author Denis Sharypov + @run main bug4960629 +*/ + +import java.awt.Font; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.AttributeSet; +import javax.swing.text.View; +import javax.swing.text.html.StyleSheet; +import javax.swing.text.html.HTMLDocument; + +public class bug4960629 { + private boolean passed = false; + private JLabel label = null; + private JFrame f = null; + + public void createAndShowGUI() throws Exception { + try { + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + label = new JLabel("

This is a test of the

"); + System.out.println("UIManager.getLookAndFeel()" + + UIManager.getLookAndFeel().getClass()); + f = new JFrame(); + f.getContentPane().add(label); + f.pack(); + f.setVisible(true); + test(); + } finally { + f.dispose(); + } + } + + bug4960629() throws InvocationTargetException, InterruptedException { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + createAndShowGUI(); + } catch (Exception e) { + throw new RuntimeException("Exception " + + e.getMessage()); + } + } + }); + } + + private void test() { + View root = ((View)label.getClientProperty(BasicHTML.propertyKey)) + .getView(0); + int n = root.getViewCount(); + View v = root.getView(n - 1); + AttributeSet attrs = v.getAttributes(); + StyleSheet ss = ((HTMLDocument) v.getDocument()).getStyleSheet(); + Font font = ss.getFont(attrs); + System.out.println(font.getSize()); + passed = (font.getSize() == 12); + if(!passed) { + throw new RuntimeException("Test failed."); + } + } + + public static void main(String args[]) throws Throwable { + new bug4960629(); + } +}