./test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java

Print this page
rev 293 : Ensure that scrolling and text selection is really performed on Gnome
using method SunToolkit.realSync().

@@ -139,13 +139,24 @@
     }
 
     void moveMouseBelowTextArea( boolean shift ) {
         Dimension d = textArea.getSize();
         Point l = textArea.getLocationOnScreen();
+        int x = (int)(l.x+d.width*.5);
         int y = (int)(l.y+d.height*1.5);
         if( shift ) y+=15;
-        robot.mouseMove( (int)(l.x+d.width*.5), y );
+        robot.mouseMove( x, y );
+        // it is needed to add some small delay on Gnome
+        waitUntilScrollIsPerformed();
+    }
+
+    /**
+      * Force window toolkit to synchronize with the native windowing
+      * sub-system.
+      */
+    void waitUntilScrollIsPerformed() {
+        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
     }
 
     void checkResults() {
         //try { Thread.sleep( 30*1000 ); }
         //catch( Exception e ) { throw new RuntimeException( e ); }