Java Code Examples for jdk.testlibrary.OSInfo#OSType
The following examples show how to use
jdk.testlibrary.OSInfo#OSType .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiScreenInsetsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws InterruptedException { OSInfo.OSType type = OSInfo.getOSType(); if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) { System.out.println("This test is for Solaris and Linux only..." + "skipping!"); return; } GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); if (gds.length < 2) { System.out.println("It's a multi-screen test... skipping!"); return; } for (int screen = 0; screen < gds.length; ++screen) { GraphicsDevice gd = gds[screen]; GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Frame frame = new Frame(gc); frame.setLocation(bounds.x + (bounds.width - SIZE) / 2, bounds.y + (bounds.height - SIZE) / 2); frame.setSize(SIZE, SIZE); frame.setUndecorated(true); frame.setVisible(true); // Maximize Frame to reach the struts frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); Thread.sleep(2000); Rectangle frameBounds = frame.getBounds(); frame.dispose(); if (bounds.x + insets.left != frameBounds.x || bounds.y + insets.top != frameBounds.y || bounds.width - insets.right - insets.left != frameBounds.width || bounds.height - insets.bottom - insets.top != frameBounds.height) { throw new RuntimeException("Test FAILED! Wrong screen #" + screen + " insets: " + insets); } } System.out.println("Test PASSED!"); }
Example 2
Source File: MultiDisplayTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static boolean checkOS() { OSInfo.OSType os = OSInfo.getOSType(); return (os.equals(OSInfo.OSType.WINDOWS) || os.equals(OSInfo.OSType.MACOSX)); }
Example 3
Source File: bug8024061.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException { OSInfo.OSType type = OSInfo.getOSType(); if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) { System.out.println("This test is for Linux and Solaris only... " + "skipping!"); return; } final bug8024061[] dnd = {null}; SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { dnd[0] = new bug8024061(); } }); final Robot robot = new Robot(); robot.setAutoDelay(10); robot.waitForIdle(); robot.delay(200); JFrame frame = dnd[0].frame; SwingUtilities.invokeAndWait(() -> { here = panel1.getLocationOnScreen(); there = panel2.getLocationOnScreen(); }); here.translate(d.width / 2, d.height / 2); there.translate(d.width / 2, d.height / 2); robot.mouseMove(here.x, here.y); robot.mousePress(InputEvent.BUTTON1_MASK); while (here.x < there.x) { here.x += 20; robot.mouseMove(here.x, here.y); System.out.println("x = " + here.x); } robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.waitForIdle(); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); System.out.println("finished"); try { if (lock.await(5, TimeUnit.SECONDS)) { if (dragEnterException == null) { System.out.println("Test passed."); } else { System.out.println("Test failed."); dragEnterException.printStackTrace(); throw new RuntimeException(dragEnterException); } } else { System.out.println("Test failed. Timeout reached"); throw new RuntimeException("Timed out waiting for dragEnter()"); } } finally { SwingUtilities.invokeLater(frame::dispose); } }
Example 4
Source File: MultiDisplayTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private static boolean checkOS() { OSInfo.OSType os = OSInfo.getOSType(); return (os.equals(OSInfo.OSType.WINDOWS) || os.equals(OSInfo.OSType.MACOSX)); }