8160764: [TEST_BUG] java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java
authorarapte
Wed, 06 Jul 2016 21:07:35 +0530
changeset 39839 9c7500fae20a
parent 39838 69e15ad7f51a
child 39840 85dfe553dd9c
8160764: [TEST_BUG] java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java Reviewed-by: alexsch, ssadetsky
jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java
--- a/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java	Tue Jul 05 19:41:47 2016 +0300
+++ b/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java	Wed Jul 06 21:07:35 2016 +0530
@@ -24,7 +24,7 @@
 /*
  @test
  @key headful
- @bug 6180449
+ @bug 6180449 8160764
  @summary TextArea scrolls to its left when selecting the text from the end.
  @run main TextAreaScrolling
  */
@@ -42,6 +42,12 @@
     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);
@@ -49,19 +55,10 @@
         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() {
@@ -71,6 +68,8 @@
     }
 
     public void performTest() {
+        robot.waitForIdle();
+        robot.delay(200);
         Point loc = textArea.getLocationOnScreen();
         Rectangle textAreaBounds = new Rectangle();
         textArea.getBounds(textAreaBounds);
@@ -80,7 +79,7 @@
 
         // 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
@@ -91,11 +90,12 @@
         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");
         }
     }