Path: blob/master/test/jdk/java/awt/MouseInfo/PointerInfoCrashTest.java
41149 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.awt.MouseInfo;24import java.awt.Point;25import java.awt.Toolkit;26import java.awt.Window;27import java.awt.peer.MouseInfoPeer;28import sun.awt.ComponentFactory;2930/**31* @test32* @key headful33* @bug 814331634* @modules java.desktop/java.awt.peer35* java.desktop/sun.awt36* @summary Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)37*/38public class PointerInfoCrashTest {3940public static void main(String[] args) {41testMouseInfo();42testMouseInfoPeer();43}4445private static void testMouseInfo() {46// call the getPointerInfo() before graphics devices initialization47MouseInfo.getPointerInfo();48}4950private static void testMouseInfoPeer() {51Toolkit toolkit = Toolkit.getDefaultToolkit();52if (toolkit instanceof ComponentFactory) {53ComponentFactory componentFactory = (ComponentFactory) toolkit;5455MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();56mouseInfoPeer.fillPointWithCoords(new Point());5758Window win = new Window(null);59win.setSize(300, 300);60win.setVisible(true);6162mouseInfoPeer.isWindowUnderMouse(win);63win.dispose();64}65}66}676869