diff options
author | Noel Grandin <noel@peralex.com> | 2015-06-09 13:27:06 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-06-11 06:47:23 +0000 |
commit | 754ade38ddb2e96187d00f3e621203cea34961fa (patch) | |
tree | 52bd945487d1a9ce850cba1d091d4f403da0481d /qadevOOo/runner/util | |
parent | c82c94b40157c08bbbc524b2dc02714cbe82dc65 (diff) |
speed up Java unit tests by removing sleeps
and replacing them with a call to XToolkitExperimental::
processEventsToIdle
Change-Id: I9fd6cb8af43d902587186310aebe78b5a5ee6932
Reviewed-on: https://gerrit.libreoffice.org/16201
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'qadevOOo/runner/util')
-rw-r--r-- | qadevOOo/runner/util/DesktopTools.java | 4 | ||||
-rw-r--r-- | qadevOOo/runner/util/utils.java | 19 |
2 files changed, 17 insertions, 6 deletions
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java index 1f6f6cfeedbc..00b7fc5ce4f7 100644 --- a/qadevOOo/runner/util/DesktopTools.java +++ b/qadevOOo/runner/util/DesktopTools.java @@ -389,7 +389,7 @@ public class DesktopTools * zoom to have a view over the hole page * @param xDoc the document to zoom */ - public static void zoomToEntirePage(XInterface xDoc) + public static void zoomToEntirePage(XMultiServiceFactory xMSF, XInterface xDoc) { try { @@ -402,7 +402,7 @@ public class DesktopTools oViewProp.setPropertyValue("ZoomType", Short.valueOf(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE)); - utils.pause(5000); + util.utils.waitForEventIdle(xMSF); } catch (Exception e) { diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java index 4a77e41e2331..a584b70d1d2c 100644 --- a/qadevOOo/runner/util/utils.java +++ b/qadevOOo/runner/util/utils.java @@ -22,6 +22,7 @@ import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatchProvider; import com.sun.star.frame.XModel; import com.sun.star.lang.XComponent; + import java.util.StringTokenizer; import java.io.*; import java.util.ArrayList; @@ -30,6 +31,7 @@ import java.net.ServerSocket; import java.net.URI; import java.net.URISyntaxException; +import com.sun.star.awt.XToolkitExperimental; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.Property; import com.sun.star.lang.XMultiServiceFactory; @@ -37,17 +39,15 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.ucb.InteractiveAugmentedIOException; import com.sun.star.ucb.XSimpleFileAccess; import com.sun.star.lang.XServiceInfo; - import com.sun.star.util.URL; import com.sun.star.util.XURLTransformer; - import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Type; import com.sun.star.uno.XComponentContext; import com.sun.star.util.XMacroExpander; + import java.text.DecimalFormat; import java.util.Calendar; - import java.util.Collections; import java.util.GregorianCalendar; @@ -661,6 +661,17 @@ public class utils { } } + public static void waitForEventIdle(XMultiServiceFactory xMSF) { + try { + XToolkitExperimental xToolkit = UnoRuntime.queryInterface( + XToolkitExperimental.class, + xMSF.createInstance("com.sun.star.awt.Toolkit")); + xToolkit.processEventsToIdle(); + } catch (com.sun.star.uno.Exception ex) { + throw new RuntimeException(ex); + } + } + /** * Validate the AppExecutionCommand. Returned is an error message, starting * with "Error:", or a warning, if the command might work. @@ -832,7 +843,7 @@ public class utils { XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); xDispatcher.dispatch(aURL, null); - utils.pause(3000); + waitForEventIdle(xMSF); } catch (Exception e) { throw new Exception("ERROR: could not dispatch URL '" + URL + "'", e); |