mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-18 14:25:33 +00:00
8132376: Add @requires os.family to the client tests with access to internal OS-specific API
Reviewed-by: yan, alexsch
This commit is contained in:
parent
783e0bf4bf
commit
abdaade63f
@ -25,6 +25,7 @@
|
||||
* @test
|
||||
* @bug 8007267
|
||||
* @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
|
||||
* @requires (os.family == "mac")
|
||||
* @author leonid.romanov@oracle.com
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/com.apple.eawt
|
||||
@ -34,7 +35,6 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import sun.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ public class DefaultMenuBarTest {
|
||||
|
||||
static volatile int listenerCallCounter = 0;
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
|
||||
if (!System.getProperty("os.name").contains("OS X")) {
|
||||
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
|
||||
return;
|
||||
}
|
||||
@ -55,7 +55,6 @@ public class DefaultMenuBarTest {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
@ -64,7 +63,7 @@ public class DefaultMenuBarTest {
|
||||
robot.keyRelease(ks.getKeyCode());
|
||||
robot.keyRelease(KeyEvent.VK_META);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (listenerCallCounter != 1) {
|
||||
throw new Exception("Test failed: ActionListener either wasn't called or was called more than once");
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
@test
|
||||
@bug 4980592
|
||||
@summary switching user in XP causes an NPE in
|
||||
sun.awt.windows.WWindowPeer.displayChanged
|
||||
@requires (os.family == "windows")
|
||||
@modules java.desktop/java.awt.peer
|
||||
@modules java.desktop/sun.awt.windows
|
||||
@modules java.desktop/sun.awt
|
||||
@author son@sparc.spb.su: area=embedded
|
||||
@run main DisplayChangedTest
|
||||
*/
|
||||
/**
|
||||
* DisplayChangedTest.java
|
||||
*
|
||||
* summary: switching user in XP causes an NPE in
|
||||
* sun.awt.windows.WWindowPeer.displayChanged
|
||||
*/
|
||||
import java.awt.Frame;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class DisplayChangedTest {
|
||||
|
||||
/**
|
||||
* Test fails if it throws any exception.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void init() throws Exception {
|
||||
|
||||
if (!System.getProperty("os.name").startsWith("Windows")) {
|
||||
System.out.println("This is Windows only test.");
|
||||
return;
|
||||
}
|
||||
|
||||
Frame frame = new Frame("AWT Frame");
|
||||
frame.pack();
|
||||
|
||||
FramePeer frame_peer = AWTAccessor.getComponentAccessor()
|
||||
.getPeer(frame);
|
||||
Class comp_peer_class = Class.forName("sun.awt.windows.WComponentPeer");
|
||||
Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
|
||||
hwnd_field.setAccessible(true);
|
||||
long hwnd = hwnd_field.getLong(frame_peer);
|
||||
|
||||
Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
|
||||
Constructor constructor = clazz
|
||||
.getConstructor(new Class[]{long.class});
|
||||
Frame embedded_frame = (Frame) constructor
|
||||
.newInstance(new Object[]{new Long(hwnd)});
|
||||
frame.setVisible(true);
|
||||
|
||||
ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(
|
||||
embedded_frame);
|
||||
Class peerClass = peer.getClass();
|
||||
Method displayChangedM = peerClass.getMethod("displayChanged",
|
||||
new Class[0]);
|
||||
displayChangedM.invoke(peer, null);
|
||||
embedded_frame.dispose();
|
||||
frame.dispose();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
new DisplayChangedTest().init();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
@test
|
||||
@bug 6345002
|
||||
@summary grab problems with EmbeddedFrame
|
||||
@requires (os.family == "windows")
|
||||
@modules java.desktop/java.awt.peer
|
||||
@modules java.desktop/sun.awt
|
||||
@modules java.desktop/sun.awt.windows
|
||||
@author Oleg.Semenov@sun.com area=EmbeddedFrame
|
||||
@run main EmbeddedFrameGrabTest
|
||||
*/
|
||||
/**
|
||||
* EmbeddedFrameGrabTest.java
|
||||
*
|
||||
* summary: grab problems with EmbeddedFrame
|
||||
*/
|
||||
import java.awt.Frame;
|
||||
import java.awt.peer.FramePeer;
|
||||
import javax.swing.JComboBox;
|
||||
import java.awt.Panel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.Dialog;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class EmbeddedFrameGrabTest {
|
||||
|
||||
/**
|
||||
* Test fails if it throws any exception.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void init() throws Exception {
|
||||
|
||||
if (!System.getProperty("os.name").startsWith("Windows")) {
|
||||
System.out.println("This is Windows only test.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Frame frame = new Frame("AWT Frame");
|
||||
frame.pack();
|
||||
frame.setSize(200, 200);
|
||||
FramePeer frame_peer = AWTAccessor.getComponentAccessor()
|
||||
.getPeer(frame);
|
||||
Class comp_peer_class
|
||||
= Class.forName("sun.awt.windows.WComponentPeer");
|
||||
Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
|
||||
hwnd_field.setAccessible(true);
|
||||
long hwnd = hwnd_field.getLong(frame_peer);
|
||||
|
||||
Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
|
||||
Constructor constructor
|
||||
= clazz.getConstructor(new Class[]{long.class});
|
||||
final Frame embedded_frame
|
||||
= (Frame) constructor.newInstance(new Object[]{
|
||||
new Long(hwnd)});;
|
||||
final JComboBox<String> combo = new JComboBox<>(new String[]{
|
||||
"Item 1", "Item 2"
|
||||
});
|
||||
combo.setSelectedIndex(1);
|
||||
final Panel p = new Panel();
|
||||
p.setLayout(new BorderLayout());
|
||||
embedded_frame.add(p, BorderLayout.CENTER);
|
||||
embedded_frame.validate();
|
||||
p.add(combo);
|
||||
p.validate();
|
||||
frame.setVisible(true);
|
||||
Robot robot = new Robot();
|
||||
robot.delay(2000);
|
||||
Rectangle clos = new Rectangle(
|
||||
combo.getLocationOnScreen(), combo.getSize());
|
||||
robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.delay(1000);
|
||||
if (!combo.isPopupVisible()) {
|
||||
throw new RuntimeException("Combobox popup is not visible!");
|
||||
}
|
||||
robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height + 3);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.delay(1000);
|
||||
if (combo.getSelectedIndex() != 0) {
|
||||
throw new RuntimeException("Combobox selection has not changed!");
|
||||
}
|
||||
embedded_frame.remove(p);
|
||||
embedded_frame.dispose();
|
||||
frame.dispose();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
new EmbeddedFrameGrabTest().init();
|
||||
}
|
||||
|
||||
}
|
||||
@ -37,6 +37,8 @@ import java.lang.reflect.Proxy;
|
||||
* @bug 8013468
|
||||
* @summary Cursor does not update properly when in fullscreen mode on Mac
|
||||
* The core reason of the issue was the lack of a mouse entered event in fullscreen
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
|
||||
@ -36,6 +36,7 @@ import javax.swing.*;
|
||||
* @test
|
||||
* @bug 8024185
|
||||
* @summary Native Mac OS X full screen does not work after showing the splash
|
||||
* @requires (os.family == "mac")
|
||||
* @library ../
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @modules java.desktop/sun.awt
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user