jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 38410 bbecc75e4521
child 39541 2d0b64d48027
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38410
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     1
/*
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     4
 *
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     8
 *
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    13
 * accompanied this code).
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    14
 *
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    18
 *
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    21
 * questions.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    22
 */
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    23
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    24
/*
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    25
  @test
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    26
  @summary  Tests that GTK LaF is supported on solaris
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    27
            regardless of jdk.gtk.version flag values.
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    28
  @bug 8156121
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 38410
diff changeset
    29
  @key headful
38410
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    30
  @requires (os.name == "linux" | os.name == "solaris")
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    31
  @run main/othervm -Djdk.gtk.version=2 DemandGTK
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    32
  @run main/othervm -Djdk.gtk.version=3 DemandGTK
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    33
*/
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    34
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    35
import javax.swing.JFrame;
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    36
import javax.swing.UIManager;
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    37
import javax.swing.SwingUtilities;
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    38
import java.awt.Robot;
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    39
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    40
public class DemandGTK {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    41
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    42
    static JFrame frame;
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    43
    public static void createAndShow() {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    44
        try {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    45
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    46
        } catch(Exception cnf) {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    47
            cnf.printStackTrace();
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    48
            throw new RuntimeException("GTK LaF must be supported");
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    49
        }
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    50
        frame = new JFrame("JFrame");
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    51
        frame.setSize(200, 200);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    52
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    53
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    54
        frame.setVisible(true);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    55
    }
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    56
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    57
    /**
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    58
     * @param args the command line arguments
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    59
     */
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    60
    public static void main(String[] args) throws Exception {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    61
        SwingUtilities.invokeAndWait(DemandGTK::createAndShow);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    62
        Robot robot = new Robot();
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    63
        robot.waitForIdle();
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    64
        robot.delay(1000);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    65
        SwingUtilities.invokeAndWait( () -> {
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    66
            frame.setVisible(false);
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    67
            frame.dispose();
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    68
        });
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    69
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    70
    }
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    71
}
bbecc75e4521 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux
yan
parents:
diff changeset
    72