< prev index next >

test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java

Print this page

        

@@ -22,11 +22,11 @@
  */
 
 /*
  @test
  @key headful
- @bug 6180449
+ @bug 6180449 8160764
  @summary TextArea scrolls to its left when selecting the text from the end.
  @run main TextAreaScrolling
  */
 
 import java.awt.Frame;

@@ -40,64 +40,64 @@
     Frame mainFrame;
     TextArea textArea;
     Robot robot;
 
     TextAreaScrolling() {
+        try {
+            robot = new Robot();
+        } catch (Exception ex) {
+            throw new RuntimeException("Robot Creation Failed");
+        }
+
         mainFrame = new Frame();
         mainFrame.setSize(200, 200);
         mainFrame.setLocation(200, 200);
 
         textArea = new TextArea();
         textArea.setText("1234 5678");
         textArea.setSelectionStart(3);
-        textArea.setSelectionStart(4);
+        textArea.setSelectionEnd(4);
         mainFrame.add(textArea);
         mainFrame.setVisible(true);
         textArea.requestFocusInWindow();
-
-        try {
-            robot = new Robot();
-            robot.setAutoWaitForIdle(true);
-        } catch (Exception ex) {
-            dispose();
-            System.exit(0);
-            throw new RuntimeException("Robot Creation Failed");
-        }
     }
 
     public void dispose() {
         if (mainFrame != null) {
             mainFrame.dispose();
         }
     }
 
     public void performTest() {
+        robot.waitForIdle();
+        robot.delay(200);
         Point loc = textArea.getLocationOnScreen();
         Rectangle textAreaBounds = new Rectangle();
         textArea.getBounds(textAreaBounds);
 
         // Move mouse at center in first row of TextArea.
         robot.mouseMove(loc.x + textAreaBounds.width / 2, loc.y + 5);
 
         // Perform selection by scrolling to left from end of char sequence.
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        robot.mouseMove(textAreaBounds.x - 5, loc.y + 5);
+        robot.mouseMove(loc.x - 5, loc.y + 5);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
         // Perform double click on beginning word of TextArea
         robot.mouseMove(loc.x + 5, loc.y + 5);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         robot.delay(100);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         robot.delay(100);
+        robot.waitForIdle();
 
         if (textArea.getSelectedText().contentEquals("5678")) {
             dispose();
-            throw new RuntimeException ("TextArea over scrolled towards left"
-                + "Expected selected text: '1234 ' and for mac '1234'"
+            throw new RuntimeException ("TextArea over scrolled towards left. "
+                + "Expected selected text: '1234 ' and for mac '1234' "
                 + "Actual selected text: 5678");
         }
     }
 
     public static void main(String argv[]) throws RuntimeException {
< prev index next >