4624N/A/*
4624N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
4624N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4624N/A *
4624N/A * This code is free software; you can redistribute it and/or modify it
4624N/A * under the terms of the GNU General Public License version 2 only, as
4624N/A * published by the Free Software Foundation.
4624N/A *
4624N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4624N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4624N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4624N/A * version 2 for more details (a copy is included in the LICENSE file that
4624N/A * accompanied this code).
4624N/A *
4624N/A * You should have received a copy of the GNU General Public License version
4624N/A * 2 along with this work; if not, write to the Free Software Foundation,
4624N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4624N/A *
4624N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4624N/A * or visit www.oracle.com if you need additional information or have any
4624N/A * questions.
4624N/A */
4624N/A
4624N/A/*
4624N/A * @test
4624N/A * @bug 4530474
4624N/A * @summary Tests if background-color CSS attribute in HTML font tag in class attribute
4624N/A * @author Denis Sharypov
4624N/A * @run main bug4530474
4624N/A */
4624N/A
4624N/Aimport java.awt.*;
4624N/Aimport javax.swing.*;
4624N/A
4624N/Aimport java.io.*;
4624N/A
4624N/Aimport sun.awt.SunToolkit;
4624N/A
4624N/Apublic class bug4530474 {
4624N/A
4624N/A private static final Color TEST_COLOR = Color.BLUE;
4624N/A private static JEditorPane jep;
4624N/A
4624N/A public static void main(String args[]) throws Exception {
4624N/A
4624N/A SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
4624N/A final Robot robot = new Robot();
4624N/A robot.setAutoDelay(50);
4624N/A
4624N/A SwingUtilities.invokeAndWait(new Runnable() {
4624N/A
4624N/A @Override
4624N/A public void run() {
4624N/A createAndShowGUI();
4624N/A }
4624N/A });
4624N/A
4624N/A toolkit.realSync();
4624N/A
4624N/A SwingUtilities.invokeAndWait(new Runnable() {
4624N/A
4624N/A @Override
4624N/A public void run() {
4624N/A
4624N/A boolean passed = false;
4624N/A
4624N/A Point p = jep.getLocationOnScreen();
4624N/A Dimension d = jep.getSize();
4624N/A int x0 = p.x;
4624N/A int y = p.y + d.height / 3;
4624N/A
4624N/A StringBuilder builder = new StringBuilder("Test color: ");
4624N/A builder.append(TEST_COLOR.toString());
4624N/A builder.append(" resut colors: ");
4624N/A
4624N/A for (int x = x0; x < x0 + d.width; x++) {
4624N/A Color color = robot.getPixelColor(x, y);
4624N/A builder.append(color);
4624N/A
4624N/A if (TEST_COLOR.equals(color)) {
4624N/A passed = true;
4624N/A break;
4624N/A }
4624N/A }
4624N/A
4624N/A if (!passed) {
4624N/A throw new RuntimeException("Test Fail. " + builder.toString());
4624N/A }
4624N/A }
4624N/A });
4624N/A
4624N/A }
4624N/A
4624N/A private static void createAndShowGUI() {
4624N/A
4624N/A JFrame mainFrame = new JFrame("bug4530474");
4624N/A mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
4624N/A jep = new JEditorPane();
4624N/A
4624N/A try {
4624N/A File file = new File(System.getProperty("test.src", "."), "test.html");
4624N/A jep.setPage(file.toURL());
4624N/A } catch (Exception e) {
4624N/A throw new RuntimeException(e);
4624N/A }
4624N/A
4624N/A mainFrame.getContentPane().add(jep);
4624N/A
4624N/A mainFrame.pack();
4624N/A mainFrame.setVisible(true);
4624N/A }
4624N/A}