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 /vcl | |
parent | loplugin:staticmethods (diff) | |
download | core-754ade38ddb2e96187d00f3e621203cea34961fa.tar.gz core-754ade38ddb2e96187d00f3e621203cea34961fa.zip |
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 'vcl')
-rw-r--r-- | vcl/qa/complex/persistent_window_states/DocumentHandle.java | 26 | ||||
-rw-r--r-- | vcl/qa/complex/persistent_window_states/PersistentWindowTest.java | 4 |
2 files changed, 16 insertions, 14 deletions
diff --git a/vcl/qa/complex/persistent_window_states/DocumentHandle.java b/vcl/qa/complex/persistent_window_states/DocumentHandle.java index 99893d6fcf30..ec09cac7a89a 100644 --- a/vcl/qa/complex/persistent_window_states/DocumentHandle.java +++ b/vcl/qa/complex/persistent_window_states/DocumentHandle.java @@ -18,16 +18,18 @@ package complex.persistent_window_states; -import com.sun.star.awt.Rectangle; +import helper.WindowListener; + import com.sun.star.awt.PosSize; -import com.sun.star.frame.XComponentLoader; +import com.sun.star.awt.Rectangle; import com.sun.star.awt.XWindow; -import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyState; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.frame.XFrame; +import com.sun.star.beans.PropertyValue; import com.sun.star.frame.FrameSearchFlag; -import helper.WindowListener; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; /** * Load and resize a document. @@ -57,7 +59,7 @@ public class DocumentHandle { * @param hidden If true, the document is loaded hidden. * @return The size of the opened/created document. */ - public Rectangle loadDocument(String docName, boolean hidden) + public Rectangle loadDocument(XMultiServiceFactory xMSF, String docName, boolean hidden) throws Exception{ wl.resetTrigger(); try { @@ -85,7 +87,7 @@ public class DocumentHandle { XComponentLoader xFrameLoader = UnoRuntime.queryInterface(XComponentLoader.class, xFrame); xFrameLoader.loadComponentFromURL(docName, "_self", 0, szArgs); // wait for the document to load. - util.utils.pause(10000); + util.utils.waitForEventIdle(xMSF); xWin = xFrame.getContainerWindow(); xWin.addWindowListener(wl); @@ -123,13 +125,13 @@ public class DocumentHandle { * Y-Position +10 pixel * @return True if resize worked. */ - public boolean resizeDocument() { + public boolean resizeDocument(XMultiServiceFactory xMSF) { Rectangle newPosSize = xWin.getPosSize(); newPosSize.Width = newPosSize.Width - 20; newPosSize.Height = newPosSize.Height - 20; newPosSize.X = newPosSize.X + 80; newPosSize.Y = newPosSize.Y + 80; - return resizeDocument(newPosSize); + return resizeDocument(xMSF, newPosSize); } /** @@ -137,11 +139,11 @@ public class DocumentHandle { * @param newPosSize The new position and size of the window. * @return True if resize worked. */ - private boolean resizeDocument(Rectangle newPosSize){ + private boolean resizeDocument(XMultiServiceFactory xMSF, Rectangle newPosSize){ wl.resetTrigger(); xWin.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, newPosSize.Height, PosSize.POSSIZE); - util.utils.pause(3000); + util.utils.waitForEventIdle(xMSF); return wl.resizedTrigger; } } diff --git a/vcl/qa/complex/persistent_window_states/PersistentWindowTest.java b/vcl/qa/complex/persistent_window_states/PersistentWindowTest.java index fd91beb4617d..5f2df615d82c 100644 --- a/vcl/qa/complex/persistent_window_states/PersistentWindowTest.java +++ b/vcl/qa/complex/persistent_window_states/PersistentWindowTest.java @@ -120,7 +120,7 @@ public class PersistentWindowTest Rectangle rect1 = handle.getDocumentPosSize(); // resize - handle.resizeDocument(); + handle.resizeDocument(getMSF()); // after resize Rectangle rect2 = handle.getDocumentPosSize(); @@ -269,7 +269,7 @@ public class PersistentWindowTest } } docHandle = new DocumentHandle(xCompLoader); - docHandle.loadDocument(docLoader, false); + docHandle.loadDocument(xMSF, docLoader, false); } catch (com.sun.star.uno.Exception e) { |