test/jdk/java/awt/MouseInfo/PointerInfoCrashTest.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 39056 jdk/test/java/awt/MouseInfo/PointerInfoCrashTest.java@d99e63b6d962
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35666
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     1
/*
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     4
 *
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     8
 *
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    13
 * accompanied this code).
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    14
 *
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    18
 *
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    21
 * questions.
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    22
 */
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    23
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    24
import java.awt.MouseInfo;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    25
import java.awt.Point;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    26
import java.awt.Toolkit;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    27
import java.awt.Window;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    28
import java.awt.peer.MouseInfoPeer;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    29
import sun.awt.ComponentFactory;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    30
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    31
/**
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    32
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 36915
diff changeset
    33
 * @key headful
35666
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    34
 * @bug 8143316
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    35
 * @modules java.desktop/java.awt.peer
36915
2258afe73d4c 8150535: [TEST_BUG] fix @library for test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java
yan
parents: 35666
diff changeset
    36
 *          java.desktop/sun.awt
35666
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    37
 * @summary Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    38
 */
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    39
public class PointerInfoCrashTest {
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    40
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    41
    public static void main(String[] args) {
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    42
        testMouseInfo();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    43
        testMouseInfoPeer();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    44
    }
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    45
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    46
    private static void testMouseInfo() {
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    47
        // call the getPointerInfo() before graphics devices initialization
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    48
        MouseInfo.getPointerInfo();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    49
    }
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    50
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    51
    private static void testMouseInfoPeer() {
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    52
        Toolkit toolkit = Toolkit.getDefaultToolkit();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    53
        if (toolkit instanceof ComponentFactory) {
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    54
            ComponentFactory componentFactory = (ComponentFactory) toolkit;
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    55
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    56
            MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    57
            mouseInfoPeer.fillPointWithCoords(new Point());
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    58
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    59
            Window win = new Window(null);
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    60
            win.setSize(300, 300);
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    61
            win.setVisible(true);
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    62
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    63
            mouseInfoPeer.isWindowUnderMouse(win);
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    64
            win.dispose();
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    65
        }
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    66
    }
d69b38870195 8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
alexsch
parents:
diff changeset
    67
}