jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java
author kshefov
Tue, 01 Oct 2013 13:45:51 +0400
changeset 20440 19aa1ffadb9a
child 28071 3acb75b8df45
permissions -rw-r--r--
8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button Reviewed-by: serb, alexsch Contributed-by: vera.akulova@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20440
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     1
/*
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     4
 *
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     8
 *
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    13
 * accompanied this code).
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    14
 *
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    18
 *
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    21
 * questions.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    22
 */
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    23
/**
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    24
 * @test 1.4 08/08/05
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    25
 * @bug 6276188
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    26
 * @library ../../../../regtesthelpers
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    27
 * @build Util
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    28
 * @author Romain Guy
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    29
 * @summary Tests PRESSED and MOUSE_OVER and FOCUSED state for buttons with Synth.
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    30
 * @run main bug6276188
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    31
 */
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    32
import java.awt.*;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    33
import java.awt.image.*;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    34
import java.awt.event.*;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    35
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    36
import javax.swing.*;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    37
import javax.swing.plaf.synth.*;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    38
import sun.awt.SunToolkit;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    39
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    40
public class bug6276188 extends JFrame {
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    41
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    42
    private static JButton button;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    43
    private static Point p;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    44
    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    45
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    46
    public static void main(String[] args) throws Throwable {
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    47
        SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    48
        lookAndFeel.load(bug6276188.class.getResourceAsStream("bug6276188.xml"), bug6276188.class);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    49
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    50
        UIManager.setLookAndFeel(lookAndFeel);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    51
        SwingUtilities.invokeAndWait(new Runnable() {
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    52
            public void run() {
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    53
                JFrame testFrame = new JFrame();
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    54
                testFrame.setLayout(new BorderLayout());
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    55
                testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    56
                testFrame.add(BorderLayout.CENTER, button = new JButton());
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    57
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    58
                testFrame.setSize(new Dimension(320, 200));
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    59
                testFrame.setVisible(true);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    60
            }
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    61
        });
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    62
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    63
        p = Util.getCenterPoint(button);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    64
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    65
        Robot robot = new Robot();
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    66
        robot.setAutoDelay(50);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    67
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    68
        robot.mouseMove(p.x , p.y);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    69
        robot.mousePress(InputEvent.BUTTON1_MASK);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    70
        toolkit.realSync();
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    71
        robot.delay(1000);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    72
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    73
        Color color = robot.getPixelColor(p.x, p.y);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    74
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    75
        boolean red = color.getRed() > 0 && color.getGreen() == 0 && color.getBlue() == 0;
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    76
        if (!red) {
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    77
            System.err.println("Red: " + color.getRed() + "; Green: " + color.getGreen() + "; Blue: " + color.getBlue());
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    78
            throw new RuntimeException("Synth ButtonUI does not handle PRESSED & MOUSE_OVER state");
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    79
        }
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    80
    }
19aa1ffadb9a 8012461: [TEST_BUG] closed/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java doesn't release mouse button
kshefov
parents:
diff changeset
    81
}