jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java
changeset 27763 1fba965925e8
parent 13357 6a75209a8aeb
child 40128 e635645d2a8a
equal deleted inserted replaced
27762:397a31d6d1a6 27763:1fba965925e8
    28  * @author kdm@sparc.spb.su: area= awt.TextAvent
    28  * @author kdm@sparc.spb.su: area= awt.TextAvent
    29  * @run main TextEventSequenceTest
    29  * @run main TextEventSequenceTest
    30  */
    30  */
    31 import java.awt.*;
    31 import java.awt.*;
    32 import java.awt.event.*;
    32 import java.awt.event.*;
    33 import sun.awt.SunToolkit;
       
    34 
    33 
    35 public class TextEventSequenceTest {
    34 public class TextEventSequenceTest {
    36 
    35 
    37     private static Frame f;
    36     private static Frame f;
    38     private static TextField tf;
    37     private static TextField tf;
    46         test("");
    45         test("");
    47         test(null);
    46         test(null);
    48     }
    47     }
    49 
    48 
    50     private static void test(String test) {
    49     private static void test(String test) {
    51         SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    50 
       
    51         Robot robot;
       
    52         try {
       
    53             robot = new Robot();
       
    54         }catch(Exception ex) {
       
    55             ex.printStackTrace();
       
    56             throw new RuntimeException("Unexpected failure");
       
    57         }
    52 
    58 
    53         createAndShowGUI(test);
    59         createAndShowGUI(test);
    54         toolkit.realSync();
    60         robot.waitForIdle();
    55 
    61 
    56         initCounts();
    62         initCounts();
    57         t.setText("Hello ");
    63         t.setText("Hello ");
    58         toolkit.realSync();
    64         robot.waitForIdle();
    59         t.append("World! !");
    65         t.append("World! !");
    60         toolkit.realSync();
    66         robot.waitForIdle();
    61         t.insert("from Roger Pham", 13);
    67         t.insert("from Roger Pham", 13);
    62         toolkit.realSync();
    68         robot.waitForIdle();
    63         t.replaceRange("Java Duke", 18, 28);
    69         t.replaceRange("Java Duke", 18, 28);
    64         toolkit.realSync();
    70         robot.waitForIdle();
    65         checkCounts(0, 4);
    71         checkCounts(0, 4);
    66 
    72 
    67         initCounts();
    73         initCounts();
    68         t.setText("");
    74         t.setText("");
    69         toolkit.realSync();
    75         robot.waitForIdle();
    70         t.setText("");
    76         t.setText("");
    71         toolkit.realSync();
    77         robot.waitForIdle();
    72         t.setText("");
    78         t.setText("");
    73         toolkit.realSync();
    79         robot.waitForIdle();
    74         checkCounts(1, 0);
    80         checkCounts(1, 0);
    75 
    81 
    76         initCounts();
    82         initCounts();
    77         tf.setText("Hello There!");
    83         tf.setText("Hello There!");
    78         toolkit.realSync();
    84         robot.waitForIdle();
    79         checkCounts(0, 1);
    85         checkCounts(0, 1);
    80 
    86 
    81         initCounts();
    87         initCounts();
    82         tf.setText("");
    88         tf.setText("");
    83         toolkit.realSync();
    89         robot.waitForIdle();
    84         tf.setText("");
    90         tf.setText("");
    85         toolkit.realSync();
    91         robot.waitForIdle();
    86         tf.setText("");
    92         tf.setText("");
    87         toolkit.realSync();
    93         robot.waitForIdle();
    88         checkCounts(1, 0);
    94         checkCounts(1, 0);
    89 
    95 
    90         f.dispose();
    96         f.dispose();
    91     }
    97     }
    92 
    98