Author: hdu
Date: Tue Sep  3 10:51:04 2013
New Revision: 1519643

URL: http://svn.apache.org/r1519643
Log:
#i123172# speedup autotest mouse dragging

many GUI autotests drag the mouse across the screen. Moving the mouse
pointer one-by-one is inefficient and takes a long time. Speeding this
up gets rid of a lot of dead time in the autotests.

Modified:
    openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl/Tester.java

Modified: 
openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl/Tester.java
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl/Tester.java?rev=1519643&r1=1519642&r2=1519643&view=diff
==============================================================================
--- openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl/Tester.java 
(original)
+++ openoffice/trunk/test/testcommon/source/org/openoffice/test/vcl/Tester.java 
Tue Sep  3 10:51:04 2013
@@ -102,13 +102,23 @@ public class Tester {
                robot.mousePress(InputEvent.BUTTON1_MASK);
                int x = fromX;
                int y = fromY;
+               // get the direction
                int dx = toX > fromX ? 1 : -1;
                int dy = toY > fromY ? 1 : -1;
+               // get the step sizes
+               final int stepTarget = 10;
+               int sx = (toX - fromX) / stepTarget;
+               int sy = (toY - fromY) / stepTarget;
+               if( sx == 0) sx = dx;
+               if( sy == 0) sy = dy;
                while (x != toX || y != toY) {
-                       if (x != toX)
-                               x = x + dx;
-                       if (y != toY)
-                               y = y + dy;
+                       x += sx;
+                       y += sy;
+                       // limit drag pos to target pos
+                       if( ((x - toX) * dx) > 0)
+                               x = toX;
+                       if( ((y - toY) * dy) > 0)
+                               y = toY;
                        robot.mouseMove(x, y);
                }
                robot.mouseRelease(InputEvent.BUTTON1_MASK);


Reply via email to