jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java
author aniyogi
Mon, 31 Oct 2016 12:10:08 +0530
changeset 41904 524d908e49ea
parent 40128 e635645d2a8a
permissions -rw-r--r--
8168540: [TEST_BUG] On Unity, need a delay before screenshot taking to avoid animation Reviewed-by: psadhukhan, yan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     1
/*
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
     2
 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     4
 *
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     8
 *
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    13
 * accompanied this code).
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    14
 *
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    18
 *
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    21
 * questions.
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    22
 */
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    23
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    24
/*
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    25
 * @test
40128
e635645d2a8a 8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents: 28071
diff changeset
    26
 * @key headful
41904
524d908e49ea 8168540: [TEST_BUG] On Unity, need a delay before screenshot taking to avoid animation
aniyogi
parents: 40128
diff changeset
    27
 * @bug 6796710 7124242 8168540
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    28
 * @summary Html content in JEditorPane is overlapping on swing components while resizing the application.
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    29
 * @library ../../../regtesthelpers
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    30
 * @build Util
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    31
   @run main bug6796710
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    32
 */
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    33
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    34
import java.awt.*;
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    35
import java.awt.image.BufferedImage;
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
    36
import javax.swing.*;
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    37
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    38
public class bug6796710 {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    39
    // The page is inlined because we want to be sure that the JEditorPane filled synchronously
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    40
    public static final String TEXT = "<html>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    41
            "<body>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    42
            "<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\">" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    43
            "    <tbody>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    44
            "        <tr>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    45
            "            <td>Col1</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    46
            "            <td>Col2</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    47
            "            <td>Col3</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    48
            "        </tr>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    49
            "        <tr>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    50
            "            <td>1. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    51
            "            <td>2. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    52
            "            <td>3. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    53
            "        </tr>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    54
            "    </tbody>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    55
            "</table>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    56
            "</body>" +
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    57
            "</html>";
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    58
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    59
    private static Robot robot;
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    60
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    61
    private static JFrame frame;
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    62
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    63
    private static JPanel pnBottom;
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    64
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    65
    public static void main(String[] args) throws Exception {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    66
        robot = new Robot();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    67
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    68
        SwingUtilities.invokeAndWait(new Runnable() {
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
    69
            @Override
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    70
            public void run() {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    71
                frame = new JFrame();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    72
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
    73
                frame.setUndecorated(true);
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
    74
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    75
                pnBottom = new JPanel();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    76
                pnBottom.add(new JLabel("Some label"));
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    77
                pnBottom.add(new JButton("A button"));
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    78
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    79
                JEditorPane editorPane = new JEditorPane();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    80
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    81
                editorPane.setContentType("text/html");
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    82
                editorPane.setText(TEXT);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    83
                editorPane.setEditable(false);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    84
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    85
                JPanel pnContent = new JPanel(new BorderLayout());
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    86
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    87
                pnContent.add(new JScrollPane(editorPane), BorderLayout.CENTER);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    88
                pnContent.add(pnBottom, BorderLayout.SOUTH);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    89
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    90
                frame.setContentPane(pnContent);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    91
                frame.setSize(400, 600);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    92
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    93
                frame.setVisible(true);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    94
            }
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    95
        });
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    96
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 14653
diff changeset
    97
        robot.waitForIdle();
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
    98
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
    99
        // This delay should be added for MacOSX, realSync is not enough
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
   100
        Thread.sleep(1000);
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
   101
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   102
        BufferedImage bufferedImage = getPnBottomImage();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   103
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   104
        SwingUtilities.invokeAndWait(new Runnable() {
14653
82857735f243 7124242: [macosx] Test doesn't work because of the frame round corners in the LaF
kshefov
parents: 9223
diff changeset
   105
            @Override
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   106
            public void run() {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   107
                frame.setSize(400, 150);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   108
            }
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   109
        });
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   110
41904
524d908e49ea 8168540: [TEST_BUG] On Unity, need a delay before screenshot taking to avoid animation
aniyogi
parents: 40128
diff changeset
   111
        robot.delay(1000);
9223
d331b7996fc3 7030774: javax/swing/text/CSSBorder/6796710/bug6796710.java test fails against jdk7 b134
rupashka
parents: 8530
diff changeset
   112
d331b7996fc3 7030774: javax/swing/text/CSSBorder/6796710/bug6796710.java test fails against jdk7 b134
rupashka
parents: 8530
diff changeset
   113
        // On Linux platforms realSync doesn't guaranties setSize completion
d331b7996fc3 7030774: javax/swing/text/CSSBorder/6796710/bug6796710.java test fails against jdk7 b134
rupashka
parents: 8530
diff changeset
   114
        Thread.sleep(1000);
8530
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   115
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   116
        if (!Util.compareBufferedImages(bufferedImage, getPnBottomImage())) {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   117
            throw new RuntimeException("The test failed");
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   118
        }
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   119
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   120
        System.out.println("The test bug6796710 passed.");
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   121
    }
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   122
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   123
    private static BufferedImage getPnBottomImage() {
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   124
        Rectangle rect = pnBottom.getBounds();
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   125
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   126
        Util.convertRectToScreen(rect, pnBottom.getParent());
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   127
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   128
        return robot.createScreenCapture(rect);
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   129
    }
cfe337a5776e 6796710: Html content in JEditorPane is overlapping on swing components while resizing the application.
rupashka
parents:
diff changeset
   130
}