langtools/test/jdk/jshell/EditorPadTest.java
changeset 38618 f14423456446
parent 37389 9c137b83a8b8
equal deleted inserted replaced
38617:d93a7f64e231 38618:f14423456446
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
       
    26  * @bug 8139872
    26  * @summary Testing built-in editor.
    27  * @summary Testing built-in editor.
    27  * @ignore 8139872
    28  * @modules java.desktop/java.awt
    28  * @modules jdk.jshell/jdk.internal.jshell.tool
    29  *          jdk.jshell/jdk.internal.jshell.tool
    29  * @build ReplToolTesting EditorTestBase
    30  * @build ReplToolTesting EditorTestBase
    30  * @run testng EditorPadTest
    31  * @run testng EditorPadTest
    31  */
    32  */
    32 
    33 
    33 import java.awt.AWTException;
    34 import java.awt.AWTException;
    34 import java.awt.Component;
    35 import java.awt.Component;
    35 import java.awt.Container;
    36 import java.awt.Container;
    36 import java.awt.Dimension;
    37 import java.awt.Dimension;
    37 import java.awt.Frame;
    38 import java.awt.Frame;
       
    39 import java.awt.GraphicsEnvironment;
    38 import java.awt.Point;
    40 import java.awt.Point;
    39 import java.awt.Robot;
    41 import java.awt.Robot;
    40 import java.awt.event.InputEvent;
    42 import java.awt.event.InputEvent;
    41 import java.awt.event.WindowEvent;
    43 import java.awt.event.WindowEvent;
    42 import java.lang.reflect.InvocationTargetException;
    44 import java.lang.reflect.InvocationTargetException;
    65     private static JTextArea area = null;
    67     private static JTextArea area = null;
    66     private static JButton cancel = null;
    68     private static JButton cancel = null;
    67     private static JButton accept = null;
    69     private static JButton accept = null;
    68     private static JButton exit = null;
    70     private static JButton exit = null;
    69 
    71 
       
    72     // Do not actually run if we are headless
       
    73     @Override
       
    74     public void testEditor(boolean defaultStartup, String[] args, ReplTest... tests) {
       
    75         if (!GraphicsEnvironment.isHeadless()) {
       
    76             test(defaultStartup, args, tests);
       
    77         }
       
    78     }
       
    79 
    70     @BeforeClass
    80     @BeforeClass
    71     public static void setUpEditorPadTest() {
    81     public static void setUpEditorPadTest() {
    72         try {
    82         if (!GraphicsEnvironment.isHeadless()) {
    73             robot = new Robot();
    83             try {
    74             robot.setAutoWaitForIdle(true);
    84                 robot = new Robot();
    75             robot.setAutoDelay(DELAY);
    85                 robot.setAutoWaitForIdle(true);
    76         } catch (AWTException e) {
    86                 robot.setAutoDelay(DELAY);
    77             throw new ExceptionInInitializerError(e);
    87             } catch (AWTException e) {
       
    88                 throw new ExceptionInInitializerError(e);
       
    89             }
    78         }
    90         }
    79     }
    91     }
    80 
    92 
    81     @AfterClass
    93     @AfterClass
    82     public static void shutdown() {
    94     public static void shutdown() {
   121     }
   133     }
   122 
   134 
   123     @Test
   135     @Test
   124     public void testShuttingDown() {
   136     public void testShuttingDown() {
   125         testEditor(
   137         testEditor(
   126                 (a) -> assertEditOutput(a, "/e", "", this::shutdownEditor)
   138                 (a) -> assertEditOutput(a, "/ed", "", this::shutdownEditor)
   127         );
   139         );
   128     }
   140     }
   129 
   141 
   130     private void waitForIdle() {
   142     private void waitForIdle() {
   131         robot.waitForIdle();
   143         robot.waitForIdle();