jdk.testlibrary.OSInfo Java Examples

The following examples show how to use jdk.testlibrary.OSInfo. 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: bug7172652.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #2
Source File: bug7172652.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #3
Source File: bug7172652.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #4
Source File: bug7172652.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #5
Source File: DeadKeyMacOSXInputText.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        createAndShowGUI(robot);

        // Pressed keys: Alt + E + A
        // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_ALT);

        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        robot.waitForIdle();

        if (state != 3) {
            throw new RuntimeException("Wrong number of key events.");
        }
    }
 
Example #6
Source File: deadKeyMacOSX.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        createAndShowGUI(robot);

        // Pressed keys: Alt + E + A
        // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_ALT);

        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);

        if (state != 3) {
            throw new RuntimeException("Wrong number of key events.");
        }
    }
 
Example #7
Source File: bug8003399.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
            OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) {
        FileSystemView fsv = FileSystemView.getFileSystemView();
        for (File file : fsv.getFiles(fsv.getHomeDirectory(), false)) {
            if(file.isDirectory()) {
                for (File file1 : fsv.getFiles(file, false)) {
                    if(file1.isDirectory())
                    {
                        String path = file1.getPath();
                        if(path.startsWith("::{") &&
                                path.toLowerCase().endsWith(".library-ms")) {
                            throw new RuntimeException("Unconverted library link found");
                        }
                    }
                }
            }
        }
    }
    System.out.println("ok");
}
 
Example #8
Source File: FileDialogForPackages.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        Sysout.createDialogWithInstructions(new String[]{
                "Press PASS, this test is for MacOS X only."});
        return;
    }

    System.setProperty("apple.awt.use-file-dialog-packages", "true");

    setLayout(new GridLayout(1, 1));

    fd = new FileDialog(new Frame(), "Open");
    fd.setDirectory(APPLICATIONS_FOLDER);

    showBtn = new Button("Show File Dialog");
    showBtn.addActionListener(this);
    add(showBtn);
    String[] instructions = {
            "1) Click on 'Show File Dialog' button. A file dialog will come up.",
            "2) Navigate to the Applications folder if not already there",
            "3) Check that the application bundles can be selected and can not be navigated",
            "4) If it's true then the test passed, otherwise it failed."};
    Sysout.createDialogWithInstructions(instructions);
}
 
Example #9
Source File: FileDialogForDirectories.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        Sysout.createDialogWithInstructions(new String[]{
                "Press PASS, this test is for MacOS X only."});
        return;
    }

    System.setProperty("apple.awt.fileDialogForDirectories", "true");

    setLayout(new GridLayout(1, 1));

    fd = new FileDialog(new Frame(), "Open");

    showBtn = new Button("Show File Dialog");
    showBtn.addActionListener(this);
    add(showBtn);
    String[] instructions = {
            "1) Click on 'Show File Dialog' button. A file dialog will come up.",
            "2) Check that files can't be selected.",
            "3) Check that directories can be selected.",
            "4) Repeat steps 1 - 3 a few times for different files and directories.",
            "5) If it's true then the test passed, otherwise it failed."};
    Sysout.createDialogWithInstructions(instructions);
}
 
Example #10
Source File: bug6840086.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test was skipped because it is sensible only for Windows.");

        return;
    }

    for (String key : KEYS) {
        Image image = (Image) ShellFolder.get(key);

        if (image == null) {
            throw new RuntimeException("The image '" + key + "' not found.");
        }

        if (image != ShellFolder.get(key)) {
            throw new RuntimeException("The image '" + key + "' is not cached.");
        }
    }

    System.out.println("The test passed.");
}
 
Example #11
Source File: bug4524490.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            fileChooser = new JFileChooser();
            fileChooser.showOpenDialog(null);
        }
    });

    robot.waitForIdle();

    if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
    } else {
        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
    }
    checkFocus();
}
 
Example #12
Source File: bug8046391.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    OSType type = OSInfo.getOSType();
    if (type != OSType.WINDOWS) {
        System.out.println("This test is for Windows only... skipping!");
        return;
    }

    SwingUtilities.invokeAndWait(() -> {
        try {
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }
        System.out.println("Creating JFileChooser...");
        JFileChooser fileChooser = new JFileChooser();
        System.out.println("Test passed: chooser = " + fileChooser);
    });
    // Test fails if creating JFileChooser hangs
}
 
Example #13
Source File: NSTexturedJFrame.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        System.out.println("This test is for OSX, considered passed.");
        return;
    }
    robot = new ExtendedRobot();
    robot.setAutoDelay(50);
    // Default window appearance
    showFrame();
    step++;
    // apple.awt.brushMetalLook appearance
    showFrame();
    step++;
    // Window.style appearance
    showFrame();

    // images on step 1 and 2 should be same
    testImages(images[1], images[2], false);
    // images on step 1 and 2 should be different from default
    testImages(images[0], images[1], true);
    testImages(images[0], images[2], true);
}
 
Example #14
Source File: bug8032667_image_diff.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if(!OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())){
            return;
        }

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {

                JCheckBox checkBox = new JCheckBox();
                checkBox.setSelected(true);
                checkBox.setSize(new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT));

                final BufferedImage image1 = getHiDPIImage(checkBox);
                final BufferedImage image2 = getScaledImage(checkBox);

                if(equal(image1, image2)){
                    throw new RuntimeException("2x image equals to non smooth image");
                }
            }
        });
    }
 
Example #15
Source File: bug7172652.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #16
Source File: bug7172652.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #17
Source File: bug7172652.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("ok");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            setup();
        }
    });

    test();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
Example #18
Source File: Test.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean checkExpectedOptionSupport() {
    if (OSInfo.getOSType().equals(OSInfo.OSType.SOLARIS)) {
        double solarisVersion = OSInfo.getSolarisVersion();
        if (solarisVersion >= solarisVersionToCheck) {
            System.out.println("This Solaris version (" + solarisVersion
                    + ") should support SO_FLOW_SLA option");
            return true;
        } else {
            System.out.println("This Solaris version (" + solarisVersion
                    + ") should not support SO_FLOW_SLA option");
        }
    } else {
        System.out.println("Not Solaris, SO_FLOW_SLA should not be " +
                "supported");
    }
    return false;
}
 
Example #19
Source File: bug7154841.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        return; // Test only for Mac OS X
    }

    try {
        ExtendedRobot r = new ExtendedRobot();
        r.setAutoDelay(100);
        r.setAutoWaitForIdle(true);
        r.mouseMove(0, 0);

        SwingUtilities.invokeAndWait(bug7154841::initAndShowUI);

        r.waitForIdle(200);

        SwingUtilities.invokeAndWait(() -> {
            popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2);
        });

        r.waitForIdle(200);

        int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10;
        int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2);
        for (int x = center - 10 * STEP; x < center + 10 * STEP; x += STEP) {
            r.mouseMove(x, y);
        }

        if (!passed) {
            throw new RuntimeException("Failed: no mouse events on the popup menu");
        }
    } finally {
        SwingUtilities.invokeLater(() -> {
            if (frame != null) {
                frame.dispose();
            }
        });
    }
}
 
Example #20
Source File: NSImageToMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #21
Source File: bug4251301.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
        System.out.println("This test is not applicable for MacOS. Passed.");
        return;
    }
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
    Robot robot = new Robot();
    robot.waitForIdle();
    test.waitTestResult();
}
 
Example #22
Source File: bug6940863.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test is suitable only for Windows OS. Skipped");
        return;
    }

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JTextArea textArea = new JTextArea();

            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);

            scrollPane = new JScrollPane(textArea);

            scrollPane.setMinimumSize(new Dimension(200, 100));
            scrollPane.setPreferredSize(new Dimension(300, 150));

            frame = new JFrame("Vertical scrollbar shown without text");

            frame.setContentPane(scrollPane);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);

            timer.setRepeats(false);
            timer.start();
        }
    });
}
 
Example #23
Source File: bug8072769.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
        if (SystemTray.isSupported()) {
            test();
        } else {
            System.out.println("SystemTray not supported. " +
                    "Test is skipped.");
        }
    } else {
        System.out.println("Test will only run on Windows platform. " +
                "Test is skipped.");
    }
    System.out.println("ok");
}
 
Example #24
Source File: bug8072769.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
        if (SystemTray.isSupported()) {
            test();
        } else {
            System.out.println("SystemTray not supported. " +
                    "Test is skipped.");
        }
    } else {
        System.out.println("Test will only run on Windows platform. " +
                "Test is skipped.");
    }
    System.out.println("ok");
}
 
Example #25
Source File: bug6416920.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){
            return;
        }

        bug6416920 test = new bug6416920();
        test.layout.padSelectedTab(SwingConstants.TOP, 0);
        if (test.rects[0].width < 0) {
            throw new RuntimeException("A selected tab isn't painted properly " +
                    "in the scroll tab layout under WindowsLookAndFeel " +
                    "in Windows' \"Windows XP\" theme.");
        }
    }
 
Example #26
Source File: bug8072769.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
        if (SystemTray.isSupported()) {
            test();
        } else {
            System.out.println("SystemTray not supported. " +
                    "Test is skipped.");
        }
    } else {
        System.out.println("Test will only run on Windows platform. " +
                "Test is skipped.");
    }
    System.out.println("ok");
}
 
Example #27
Source File: PopupPosTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void start ()
{
    if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
        // On OS X, popup isn't under the mouse
        return;
    }
    Frame frame = new TestFrame();
}
 
Example #28
Source File: bug6579827.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS ||
            OSInfo.getWindowsVersion() != OSInfo.WINDOWS_VISTA) {
        System.out.println("This test is only for Windows Vista. Skipped.");

        return;
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception e) {
                e.printStackTrace();

                throw new RuntimeException(e);
            }

            JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 0);

            Dimension prefferdSize = slider.getPreferredSize();

            slider.setPaintTrack(false);
            slider.putClientProperty("Slider.paintThumbArrowShape", Boolean.TRUE);

            if (prefferdSize.equals(slider.getPreferredSize())) {
                throw new RuntimeException();
            }
        }
    });
}
 
Example #29
Source File: bug8072769.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
        if (SystemTray.isSupported()) {
            test();
        } else {
            System.out.println("SystemTray not supported. " +
                    "Test is skipped.");
        }
    } else {
        System.out.println("Test will only run on Windows platform. " +
                "Test is skipped.");
    }
    System.out.println("ok");
}
 
Example #30
Source File: bug4796987.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS
            && OSInfo.getWindowsVersion() == OSInfo.WINDOWS_XP) {
        UIManager.setLookAndFeel(new WindowsLookAndFeel());
        testButtonBorder();
    }
}