jdk/test/javax/swing/JSpinner/5012888/bug5012888.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 28071 3acb75b8df45
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12827
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
     2
 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
12827
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     4
 *
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     8
 *
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    13
 * accompanied this code).
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    14
 *
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    18
 *
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    21
 * questions.
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    22
 */
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    23
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    24
/*
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    25
 * @test 1.0 04/04/23
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    26
 * @key headful
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    27
 * @bug 5012888
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    28
 * @summary REGRESSION: Click & hold on arrow of JSpinner only transfers focus
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    29
 * @author Konstantin Eremin
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    30
 * @run main bug5012888
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    31
 */
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 28071
diff changeset
    32
12827
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    33
import javax.swing.*;
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    34
import javax.swing.event.*;
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    35
import java.awt.*;
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    36
import java.awt.event.*;
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    37
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    38
public class bug5012888 extends JFrame {
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    39
    JSpinner spinner1, spinner2;
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    40
    public bug5012888() {
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    41
      spinner1 = new JSpinner(new SpinnerNumberModel(0, -1000, 1000, 1));
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    42
      spinner2 = new JSpinner(new SpinnerNumberModel(1, -1000, 1000, 1));
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    43
      Container pane = getContentPane();
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    44
      pane.setLayout(new BorderLayout());
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    45
      pane.add(spinner1, BorderLayout.NORTH);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    46
      pane.add(spinner2, BorderLayout.SOUTH);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    47
    }
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    48
    public void doTest() throws Exception {
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 12827
diff changeset
    49
        Robot robot = new Robot();
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 12827
diff changeset
    50
        robot.waitForIdle();
12827
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    51
        Point p = spinner2.getLocationOnScreen();
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    52
        Rectangle rect = spinner2.getBounds();
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    53
        robot.mouseMove(p.x+rect.width-5, p.y+5);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    54
        robot.mousePress(InputEvent.BUTTON1_MASK);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    55
        Thread.sleep(1000);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    56
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    57
        if ( ((Integer) spinner2.getValue()).intValue() == 1 ) {
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    58
            throw new Error("Spinner value should be more than 1");
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    59
        }
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    60
    }
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    61
    public static void main(String[] argv) throws Exception {
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    62
        bug5012888 b = new bug5012888();
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    63
        b.setBounds(0, 0, 100, 100);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    64
        b.setVisible(true);
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    65
        b.doTest();
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    66
    }
c75cdabbd34b 7112115: Component.getLocationOnScreen() work incorrectly if create window in point (0, 0) on oel
denis
parents:
diff changeset
    67
}