jdk/test/javax/swing/JSpinner/4973721/bug4973721.java
author goetz
Tue, 09 Dec 2014 11:57:46 +0100
changeset 28187 fc19df82d6ee
parent 20439 d15604f6f646
child 28071 3acb75b8df45
permissions -rw-r--r--
8066964: ppc64: argument and return type profiling, fix problem with popframe Reviewed-by: roland, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20439
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     1
/*
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     4
 *
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     8
 *
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    13
 * accompanied this code).
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    14
 *
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    18
 *
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    21
 * questions.
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    22
 */
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    23
/* @test
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    24
   @bug 4973721
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    25
   @summary Up and Down Arrow key buttons are not working for the JSpinner in Synth LAF
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    26
   @library ../../regtesthelpers
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    27
   @build Util
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    28
   @author Oleg Mokhovikov
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    29
   @run main bug4973721
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    30
*/
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    31
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    32
import java.awt.Robot;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    33
import java.awt.Toolkit;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    34
import javax.swing.event.ChangeListener;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    35
import javax.swing.event.ChangeEvent;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    36
import java.awt.event.KeyEvent;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    37
import java.awt.event.FocusListener;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    38
import java.awt.event.FocusEvent;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    39
import javax.swing.*;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    40
import sun.awt.SunToolkit;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    41
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    42
public class bug4973721 implements ChangeListener, FocusListener {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    43
    static volatile boolean bStateChanged = false;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    44
    static volatile boolean bFocusGained = false;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    45
    static JSpinner spinner;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    46
    static final Object listener = new bug4973721();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    47
    private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    48
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    49
    public void focusLost(FocusEvent e) {}
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    50
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    51
    public synchronized void focusGained(FocusEvent e) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    52
        System.out.println("focusGained");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    53
        bFocusGained = true;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    54
        notifyAll();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    55
    }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    56
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    57
    public synchronized void stateChanged(ChangeEvent e) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    58
        System.out.println("stateChanged");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    59
        bStateChanged = true;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    60
        notifyAll();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    61
    }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    62
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    63
    public static void main(String[] args) throws Exception {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    64
        UIManager.setLookAndFeel("javax.swing.plaf.synth.SynthLookAndFeel");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    65
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    66
        SwingUtilities.invokeAndWait(new Runnable() {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    67
            public void run() {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    68
                final JFrame frame = new JFrame();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    69
                spinner = new JSpinner();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    70
                frame.getContentPane().add(spinner);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    71
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    72
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    73
                frame.pack();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    74
                frame.setVisible(true);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    75
                spinner.addChangeListener((ChangeListener)listener);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    76
                spinner.addFocusListener((FocusListener)listener);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    77
                spinner.requestFocus();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    78
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    79
            }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    80
        });
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    81
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    82
        synchronized(listener) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    83
            if (!bFocusGained) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    84
                System.out.println("waiting focusGained...");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    85
                try { listener.wait(5000); } catch (InterruptedException e) {}
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    86
            }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    87
        }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    88
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    89
        boolean hasFocus = Util.invokeOnEDT(new java.util.concurrent.Callable<Boolean>() {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    90
            @Override
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    91
            public Boolean call() throws Exception {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    92
                return spinner.hasFocus();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    93
            }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    94
        });
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    95
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    96
        if (!bFocusGained && !hasFocus) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    97
            throw new RuntimeException("Couldn't request focus for spinner");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    98
        }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
    99
        Robot robot = new Robot();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   100
        robot.setAutoDelay(50);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   101
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   102
        Util.hitKeys(robot, KeyEvent.VK_UP);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   103
        toolkit.realSync();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   104
        Thread.sleep(1000);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   105
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   106
        if (!bStateChanged) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   107
            throw new RuntimeException("Up arrow key button doesn't work for a spinner in Synth L&F");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   108
        }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   109
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   110
        bStateChanged = false;
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   111
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   112
        Util.hitKeys(robot, KeyEvent.VK_DOWN);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   113
        toolkit.realSync();
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   114
        Thread.sleep(1000);
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   115
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   116
        if (!bStateChanged) {
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   117
            throw new RuntimeException("Down arrow key button doesn't work for a spinner in Synth L&F");
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   118
        }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   119
    }
d15604f6f646 8004294: [TEST_BUG] javax/swing/JSpinner/4973721/bug4973721.java failed on win2003
kshefov
parents:
diff changeset
   120
}