jdk/test/java/awt/Paint/bug8024864.java
author kshefov
Tue, 25 Mar 2014 18:23:59 +0400
changeset 24131 740d55cc7975
parent 21247 40e9d768d8e2
child 40128 e635645d2a8a
permissions -rw-r--r--
8031422: [TEST_BUG] java/awt/Paint/bug8024864.java fails on Windows 7 Reviewed-by: pchelko, azvegint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21247
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     1
/*
24131
740d55cc7975 8031422: [TEST_BUG] java/awt/Paint/bug8024864.java fails on Windows 7
kshefov
parents: 21247
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
21247
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     4
 *
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     7
 * published by the Free Software Foundation.
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     8
 *
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    13
 * accompanied this code).
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    14
 *
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    18
 *
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    21
 * questions.
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    22
 */
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    23
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    24
/* @test
24131
740d55cc7975 8031422: [TEST_BUG] java/awt/Paint/bug8024864.java fails on Windows 7
kshefov
parents: 21247
diff changeset
    25
 * @bug 8024864 8031422
21247
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    26
 * @summary [macosx] Problems with rendering of controls
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    27
 * @author Petr Pchelko
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    28
 * @library ../regtesthelpers
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    29
 * @build Util
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    30
 * @run main bug8024864
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    31
 */
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    32
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    33
import javax.swing.*;
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    34
import java.awt.*;
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    35
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    36
import test.java.awt.regtesthelpers.Util;
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    37
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    38
public class bug8024864
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    39
{
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    40
    private static final int REPEATS = 30;
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    41
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    42
    private static volatile JFrame frame;
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    43
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    44
    private static void showTestUI() {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    45
        frame = new JFrame();
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    46
        frame.setBackground(Color.green);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    47
        JPanel p = new JPanel();
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    48
        p.setBackground(Color.red);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    49
        JLabel l = new JLabel("Test!");
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    50
        p.add(l);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    51
        frame.add(p);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    52
        frame.pack();
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    53
        frame.setLocation(100,100);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    54
        frame.setVisible(true);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    55
    }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    56
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    57
    public static void main(String[] args) throws Exception
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    58
    {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    59
        Robot r = new Robot();
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    60
        for (int i = 0; i < REPEATS; i++) {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    61
            try {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    62
                SwingUtilities.invokeAndWait(bug8024864::showTestUI);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    63
                //Thread.sleep(100);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    64
                Util.waitTillShown(frame);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    65
                Util.waitForIdle(r);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    66
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    67
                Dimension frameSize = frame.getSize();
24131
740d55cc7975 8031422: [TEST_BUG] java/awt/Paint/bug8024864.java fails on Windows 7
kshefov
parents: 21247
diff changeset
    68
                Point loc = new Point(frameSize.width - 15, frameSize.height - 15);
21247
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    69
                SwingUtilities.convertPointToScreen(loc, frame);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    70
                Color c = r.getPixelColor(loc.x, loc.y);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    71
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    72
                if (c.getGreen() > 200) {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    73
                    throw new RuntimeException("TEST FAILED. Unexpected pixel color " + c);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    74
                }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    75
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    76
            } finally {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    77
                if (frame != null) {
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    78
                    frame.dispose();
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    79
                }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    80
                Util.waitForIdle(r);
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    81
            }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    82
        }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    83
    }
40e9d768d8e2 8024864: [macosx] Problems with rendering of controls
pchelko
parents:
diff changeset
    84
}